You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2007/05/18 00:59:39 UTC

svn commit: r539153 - in /incubator/tuscany/sandbox/slaws/sample-sca-toys: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/tuscany/ src/main/java/org/apache/tuscany/sca/ src/main/java/org/apache/tu...

Author: slaws
Date: Thu May 17 15:59:37 2007
New Revision: 539153

URL: http://svn.apache.org/viewvc?view=rev&rev=539153
Log:
Playing with the extension point registry 

Added:
    incubator/tuscany/sandbox/slaws/sample-sca-toys/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/pom.xml   (with props)
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/extension/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/extension/SCAToysModuleActivator.java   (with props)
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspector.java   (with props)
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspectorImpl.java   (with props)
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/META-INF/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/META-INF/services/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/sca-toys.composite
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/apache/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/apache/tuscany/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/apache/tuscany/sca/
    incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/apache/tuscany/sca/ScaToysTestCase.java   (with props)

Added: incubator/tuscany/sandbox/slaws/sample-sca-toys/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/slaws/sample-sca-toys/pom.xml?view=auto&rev=539153
==============================================================================
--- incubator/tuscany/sandbox/slaws/sample-sca-toys/pom.xml (added)
+++ incubator/tuscany/sandbox/slaws/sample-sca-toys/pom.xml Thu May 17 15:59:37 2007
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * Licensed to the Apache Software Foundation (ASF) under one
+    * or more contributor license agreements.  See the NOTICE file
+    * distributed with this work for additional information
+    * regarding copyright ownership.  The ASF licenses this file
+    * to you under the Apache License, Version 2.0 (the
+    * "License"); you may not use this file except in compliance
+    * with the License.  You may obtain a copy of the License at
+    * 
+    *   http://www.apache.org/licenses/LICENSE-2.0
+    * 
+    * Unless required by applicable law or agreed to in writing,
+    * software distributed under the License is distributed on an
+    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    * KIND, either express or implied.  See the License for the
+    * specific language governing permissions and limitations
+    * under the License.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-sca</artifactId>
+        <version>1.0-incubating-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    <artifactId>sample-sca-toys</artifactId>
+    <name>Apache Tuscany SCA Toys</name>
+
+    <repositories>
+       <repository>
+          <id>apache.incubator</id>
+          <url>http://people.apache.org/repo/m2-incubating-repository</url>
+       </repository>
+    </repositories>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.2</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+       <finalName>${artifactId}</finalName>
+    </build>
+</project>

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/extension/SCAToysModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/extension/SCAToysModuleActivator.java?view=auto&rev=539153
==============================================================================
--- incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/extension/SCAToysModuleActivator.java (added)
+++ incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/extension/SCAToysModuleActivator.java Thu May 17 15:59:37 2007
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.scatoys.extension;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+//import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+//import org.apache.tuscany.sca.interfacedef.java.introspect.ExtensibleJavaInterfaceIntrospector;
+//import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospector;
+import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceIntrospectorExtensionPoint;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+
+/**
+ * Implements a module activator for the SCAToys implementation extension module.
+ * This is currently a cheat just to gain back door access to the ExtensionPointRegistry
+ */
+public class SCAToysModuleActivator implements ModuleActivator {
+    
+    private static ExtensionPointRegistry epr = null;
+
+    public static ExtensionPointRegistry getExtensionPointRegistry(){
+        return epr;
+    }
+    public Object[] getExtensionPoints() {
+        // This module extension does not contribute any new extension point
+        return null;
+    }
+
+    public void start(ExtensionPointRegistry registry) {
+        // store away the ExtensionPointRegistry reference so that 
+        // SCAToys can get its hands on it
+        epr = registry;
+    }
+
+    public void stop(ExtensionPointRegistry registry) {
+    }
+}

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/extension/SCAToysModuleActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/extension/SCAToysModuleActivator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspector.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspector.java?view=auto&rev=539153
==============================================================================
--- incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspector.java (added)
+++ incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspector.java Thu May 17 15:59:37 2007
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.scatoys.inspector;
+
+
+/**
+ * The ExtensionPointRegistryInspector service interface.
+ */
+public interface ExtensionPointRegistryInspector {
+
+    public String eprAsString();
+
+}

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspector.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspectorImpl.java?view=auto&rev=539153
==============================================================================
--- incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspectorImpl.java (added)
+++ incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspectorImpl.java Thu May 17 15:59:37 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.scatoys.inspector;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.scatoys.extension.SCAToysModuleActivator;
+import org.osoa.sca.annotations.Reference;
+
+
+/**
+ * An implementation of the ExtensionPointRegistryInspector service.
+ */
+public class ExtensionPointRegistryInspectorImpl implements ExtensionPointRegistryInspector {
+
+    public String eprAsString() {
+        StringBuffer extensionPointRegistryString = new StringBuffer("Extension Point Registry \n");
+        
+        try {
+            // get the extension point registry we are hanging onto
+            // We have to assume the type of the extension point registry here!
+            DefaultExtensionPointRegistry extensionPointRegistry = (DefaultExtensionPointRegistry)
+                                                                    SCAToysModuleActivator.getExtensionPointRegistry();
+            // get the Map of extension points
+            // This is a private (!) field so a bit of sneaky reflection is required
+            Field extensionPointsField = extensionPointRegistry.getClass().getDeclaredField("extensionPoints");
+            extensionPointsField.setAccessible(true);
+            Map<Class<?>, Object> extensionPoints = (Map<Class<?>, Object>) extensionPointsField.get(extensionPointRegistry);
+            
+            // Record all the registered extension points
+            Set<Class<?>> keySet = extensionPoints.keySet();
+            for(Class<?>key : keySet){
+                extensionPointRegistryString.append(key.getName());
+                extensionPointRegistryString.append("\n");
+            }
+            
+        } catch (Exception ex) {
+            System.out.println(ex.toString());
+        }
+
+        return extensionPointRegistryString.toString();
+    }
+
+}

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspectorImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/java/org/apache/tuscany/sca/scatoys/inspector/ExtensionPointRegistryInspectorImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator?view=auto&rev=539153
==============================================================================
--- incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator (added)
+++ incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator Thu May 17 15:59:37 2007
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License. 
+# Implementation class for the ExtensionActivator
+org.apache.tuscany.sca.scatoys.extension.SCAToysModuleActivator

Added: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/sca-toys.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/sca-toys.composite?view=auto&rev=539153
==============================================================================
--- incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/sca-toys.composite (added)
+++ incubator/tuscany/sandbox/slaws/sample-sca-toys/src/main/resources/sca-toys.composite Thu May 17 15:59:37 2007
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+           name="Calculator">
+
+    <component name="ExtensionPointRegistryInspectorComponent">
+		<implementation.java class="org.apache.tuscany.sca.scatoys.inspector.ExtensionPointRegistryInspectorImpl"/>
+    </component>
+
+</composite>

Added: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/apache/tuscany/sca/ScaToysTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/apache/tuscany/sca/ScaToysTestCase.java?view=auto&rev=539153
==============================================================================
--- incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/apache/tuscany/sca/ScaToysTestCase.java (added)
+++ incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/apache/tuscany/sca/ScaToysTestCase.java Thu May 17 15:59:37 2007
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.scatoys.inspector.ExtensionPointRegistryInspector;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class ScaToysTestCase extends TestCase {
+
+    private ExtensionPointRegistryInspector eprInspector;
+    private SCADomain scaDomain;
+
+    protected void setUp() throws Exception {
+        scaDomain = SCADomain.newInstance("sca-toys.composite");
+        eprInspector = scaDomain.getService(ExtensionPointRegistryInspector.class, 
+                                                 "ExtensionPointRegistryInspectorComponent");
+    }
+
+    protected void tearDown() throws Exception {
+        scaDomain.close();
+    }
+
+    public void testCalculator() throws Exception {
+        // Inspec the extension point registry
+        System.out.println(eprInspector.eprAsString());
+    }
+}

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/apache/tuscany/sca/ScaToysTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/slaws/sample-sca-toys/src/test/java/org/apache/tuscany/sca/ScaToysTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org