tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r547908 - in /incubator/tuscany/java/sca: modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/ modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/ modules/binding-jsonrpc/src/main/java/org/apache/tuscany...
Date Sat, 16 Jun 2007 11:39:32 GMT
Author: antelder
Date: Sat Jun 16 04:39:31 2007
New Revision: 547908

URL: http://svn.apache.org/viewvc?view=rev&rev=547908
Log:
extension-helper, further simplification - no longer need scdl qname

Modified:
    incubator/tuscany/java/sca/modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBindingActivator.java
    incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingActivator.java
    incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingActivator.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingActivator.java
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/BindingsActivator.java
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java
    incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationActivator.java
    incubator/tuscany/java/sca/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java

Modified: incubator/tuscany/java/sca/modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBindingActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBindingActivator.java?view=diff&rev=547908&r1=547907&r2=547908
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBindingActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBindingActivator.java
Sat Jun 16 04:39:31 2007
@@ -19,33 +19,24 @@
 
 package org.apache.tuscany.sca.binding.ajax;
 
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.assembly.xml.Constants;
 import org.apache.tuscany.sca.http.ServletHost;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
 import org.apache.tuscany.sca.spi.BindingActivator;
-import org.apache.tuscany.sca.spi.InvokerFactory;
 import org.apache.tuscany.sca.spi.ComponentLifecycle;
+import org.apache.tuscany.sca.spi.InvokerFactory;
 
 public class AjaxBindingActivator implements BindingActivator<AjaxBinding>{
 
     private ServletHost servletHost;
     
-    public static QName AJAX_BINDING_QNAME = new QName(Constants.SCA10_NS, "binding.ajax");
-
     public AjaxBindingActivator(ServletHost servletHost) {
         this.servletHost = servletHost;
     }
 
     public Class<AjaxBinding> getBindingClass() {
         return AjaxBinding.class;
-    }
-
-    public QName getSCDLQName() {
-        return AJAX_BINDING_QNAME;
     }
 
     public InvokerFactory createInvokerFactory(RuntimeComponent rc, RuntimeComponentReference
rcr, AjaxBinding binding) {

Modified: incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingActivator.java?view=diff&rev=547908&r1=547907&r2=547908
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingActivator.java
Sat Jun 16 04:39:31 2007
@@ -19,10 +19,7 @@
 
 package org.apache.tuscany.sca.binding.ejb;
 
-import javax.xml.namespace.QName;
-
 import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.assembly.xml.Constants;
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.invocation.Invoker;
@@ -36,8 +33,6 @@
 
 public class EJBBindingActivator implements BindingActivator {
 
-    public static final QName BINDING_EJB = new QName(Constants.SCA10_NS, "binding.ejb");
-    
     public InvokerFactory createInvokerFactory(RuntimeComponent rc, RuntimeComponentReference
rcr, final Binding binding) {
         // TODO: assumes a Java interface, need to support tuscany generic Interface
         final Class si = ((JavaInterface)rcr.getInterfaceContract().getInterface()).getJavaClass();
@@ -54,10 +49,6 @@
 
     public Class getBindingClass() {
         return EJBBinding.class;
-    }
-
-    public QName getSCDLQName() {
-        return BINDING_EJB;
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingActivator.java?view=diff&rev=547908&r1=547907&r2=547908
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingActivator.java
Sat Jun 16 04:39:31 2007
@@ -19,31 +19,21 @@
 
 package org.apache.tuscany.sca.binding.jsonrpc;
 
-import static org.osoa.sca.Constants.SCA_NS;
-
-import javax.xml.namespace.QName;
-
 import org.apache.tuscany.sca.http.ServletHost;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
 import org.apache.tuscany.sca.spi.BindingActivator;
-import org.apache.tuscany.sca.spi.InvokerFactory;
 import org.apache.tuscany.sca.spi.ComponentLifecycle;
+import org.apache.tuscany.sca.spi.InvokerFactory;
 import org.osoa.sca.ServiceRuntimeException;
 
 public class JSONRPCBindingActivator implements BindingActivator<JSONRPCBinding> {
 
     protected ServletHost servletHost;
 
-    protected static final QName JSONRPC_BINDING_QN = new QName(SCA_NS, "binding.jsonrpc");
-
     public JSONRPCBindingActivator(ServletHost servletHost) {
         this.servletHost = servletHost;
-    }
-
-    public QName getSCDLQName() {
-        return JSONRPC_BINDING_QN;
     }
 
     public Class<JSONRPCBinding> getBindingClass() {

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingActivator.java?view=diff&rev=547908&r1=547907&r2=547908
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingActivator.java
Sat Jun 16 04:39:31 2007
@@ -19,29 +19,20 @@
 
 package org.apache.tuscany.sca.binding.rmi;
 
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.assembly.xml.Constants;
 import org.apache.tuscany.sca.rmi.RMIHost;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
 import org.apache.tuscany.sca.spi.BindingActivator;
-import org.apache.tuscany.sca.spi.InvokerFactory;
 import org.apache.tuscany.sca.spi.ComponentLifecycle;
+import org.apache.tuscany.sca.spi.InvokerFactory;
 
 public class RMIBindingActivator implements BindingActivator<RMIBinding> {
 
     private RMIHost rmiHost;
 
-    private QName BINDING_RMI_QNAME = new QName(Constants.SCA10_NS, "binding.rmi");
-
     public RMIBindingActivator(RMIHost rmiHost) {
         this.rmiHost = rmiHost;
-    }
-
-    public QName getSCDLQName() {
-        return BINDING_RMI_QNAME;
     }
 
     public Class<RMIBinding> getBindingClass() {

Modified: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java?view=diff&rev=547908&r1=547907&r2=547908
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java
Sat Jun 16 04:39:31 2007
@@ -19,8 +19,6 @@
 
 package org.apache.tuscany.sca.spi;
 
-import javax.xml.namespace.QName;
-
 import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -28,8 +26,6 @@
 
 public interface BindingActivator<B extends Binding> {
 
-    QName getSCDLQName();
-    
     Class<B> getBindingClass();
 
     InvokerFactory createInvokerFactory(RuntimeComponent rc, RuntimeComponentReference rcr,
B binding);

Modified: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java?view=diff&rev=547908&r1=547907&r2=547908
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java
Sat Jun 16 04:39:31 2007
@@ -19,15 +19,11 @@
 
 package org.apache.tuscany.sca.spi;
 
-import javax.xml.namespace.QName;
-
 import org.apache.tuscany.sca.assembly.ComponentType;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 
 public interface ImplementationActivator<T> {
 
-    QName getSCDLQName();
-    
     Class<T> getImplementationClass();
 
     InvokerFactory createInvokerFactory(RuntimeComponent rc, ComponentType ct, T implementation);

Modified: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/BindingsActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/BindingsActivator.java?view=diff&rev=547908&r1=547907&r2=547908
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/BindingsActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/BindingsActivator.java
Sat Jun 16 04:39:31 2007
@@ -22,8 +22,11 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.namespace.QName;
+
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.xml.Constants;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
@@ -42,8 +45,8 @@
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
 import org.apache.tuscany.sca.spi.BindingActivator;
-import org.apache.tuscany.sca.spi.InvokerFactory;
 import org.apache.tuscany.sca.spi.ComponentLifecycle;
+import org.apache.tuscany.sca.spi.InvokerFactory;
 
 public class BindingsActivator implements ModuleActivator {
 
@@ -61,7 +64,8 @@
 
         for (final BindingActivator bindingActivator : bindingActivators) {
 
-            staxProcessors.addArtifactProcessor(new BindingSCDLProcessor(bindingActivator.getSCDLQName(),
bindingActivator.getBindingClass()));
+            QName scdlQName = getBindingQName(bindingActivator.getBindingClass());
+            staxProcessors.addArtifactProcessor(new BindingSCDLProcessor(scdlQName, bindingActivator.getBindingClass()));
 
             if (bindingActivator.getBindingClass() != null) {
                 // Add a ProviderFactory
@@ -130,8 +134,8 @@
         for (final BindingActivator bindingActivator : bindingActivators) {
 
             // Remove the binding SCDL processor from the runtime
-            if (staxProcessors != null && bindingActivator.getSCDLQName() != null)
{
-                StAXArtifactProcessor processor = staxProcessors.getProcessor(bindingActivator.getSCDLQName());
+            if (staxProcessors != null) {
+                StAXArtifactProcessor processor = staxProcessors.getProcessor(getBindingQName(bindingActivator.getBindingClass()));
                 if (processor != null) {
                     staxProcessors.removeArtifactProcessor(processor);
                 }
@@ -146,6 +150,26 @@
             }
         }
     }
+
+    protected QName getBindingQName(Class bindingClass) {
+        String localName = bindingClass.getName();
+        if (localName.lastIndexOf('.') > -1) {
+            localName = localName.substring(localName.lastIndexOf('.') + 1);
+        }
+        if (localName.endsWith("Binding")) {
+            localName = localName.substring(0, localName.length()-7);
+        }
+        StringBuilder sb = new StringBuilder(localName);
+        for (int i=0; i<sb.length(); i++) {
+            if (Character.isUpperCase(sb.charAt(i))) {
+                sb.setCharAt(i, Character.toLowerCase(sb.charAt(i)));
+            } else {
+                break;
+            }
+        }
+        return new QName(Constants.SCA10_NS, "binding." + sb.toString());
+    }
+
 
     public Object[] getExtensionPoints() {
         return null; // not used by binding or implementation extensions

Modified: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java?view=diff&rev=547908&r1=547907&r2=547908
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java
Sat Jun 16 04:39:31 2007
@@ -25,6 +25,7 @@
 
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.xml.Constants;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
@@ -67,7 +68,7 @@
         for (final ImplementationActivator implementationActivator : implementationActivators)
{
 
             Class<Implementation> implClass = implementationActivator.getImplementationClass();
-            QName scdlQName = implementationActivator.getSCDLQName();
+            QName scdlQName = getSCDLQName(implClass);
             staxProcessors.addArtifactProcessor(new SCDLProcessor(assemblyFactory, scdlQName,
implClass, registry, factories));
 
             if (implementationActivator.getImplementationClass() != null && providerFactories
!= null) {
@@ -80,8 +81,8 @@
         StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
 
         for (final ImplementationActivator implementationActivator : implementationActivators)
{
-            if (staxProcessors != null && implementationActivator.getSCDLQName()
!= null) {
-                StAXArtifactProcessor processor = staxProcessors.getProcessor(implementationActivator.getSCDLQName());
+            if (staxProcessors != null) {
+                StAXArtifactProcessor processor = staxProcessors.getProcessor(getSCDLQName(implementationActivator.getImplementationClass()));
                 if (processor != null) {
                     staxProcessors.removeArtifactProcessor(processor);
                 }
@@ -110,6 +111,26 @@
             }
         });
     }
+
+    protected QName getSCDLQName(Class implementationClass) {
+        String localName = implementationClass.getName();
+        if (localName.lastIndexOf('.') > -1) {
+            localName = localName.substring(localName.lastIndexOf('.') + 1);
+        }
+        if (localName.endsWith("Implementation")) {
+            localName = localName.substring(0, localName.length() - 14);
+        }
+        StringBuilder sb = new StringBuilder(localName);
+        for (int i=0; i<sb.length(); i++) {
+            if (Character.isUpperCase(sb.charAt(i))) {
+                sb.setCharAt(i, Character.toLowerCase(sb.charAt(i)));
+            } else {
+                break;
+            }
+        }
+        return new QName(Constants.SCA10_NS, "implementation." + sb.toString());
+    }
+
 
     public Object[] getExtensionPoints() {
         return null;

Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationActivator.java?view=diff&rev=547908&r1=547907&r2=547908
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationActivator.java
Sat Jun 16 04:39:31 2007
@@ -19,10 +19,7 @@
 
 package org.apache.tuscany.sca.implementation.script;
 
-import javax.xml.namespace.QName;
-
 import org.apache.tuscany.sca.assembly.ComponentType;
-import org.apache.tuscany.sca.assembly.xml.Constants;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.spi.ImplementationActivator;
 import org.apache.tuscany.sca.spi.InvokerFactory;
@@ -30,17 +27,11 @@
 
 public class ScriptImplementationActivator implements ImplementationActivator<ScriptImplementation>
{
 
-    private static final QName IMPLEMENTATION_SCRIPT_QNAME = new QName(Constants.SCA10_NS,
"implementation.script");
-
     // TODO: seems wrong to need PropertyValueObjectFactory, could it be on Property somehow?

     protected PropertyValueObjectFactory propertyFactory;
 
     public ScriptImplementationActivator(PropertyValueObjectFactory propertyFactory) {
         this.propertyFactory = propertyFactory;
-    }
-
-    public QName getSCDLQName() {
-        return IMPLEMENTATION_SCRIPT_QNAME;
     }
 
     public Class<ScriptImplementation> getImplementationClass() {

Modified: incubator/tuscany/java/sca/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java?view=diff&rev=547908&r1=547907&r2=547908
==============================================================================
--- incubator/tuscany/java/sca/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java
(original)
+++ incubator/tuscany/java/sca/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java
Sat Jun 16 04:39:31 2007
@@ -19,21 +19,12 @@
 
 package sample;
 
-import javax.xml.namespace.QName;
-
 import org.apache.tuscany.sca.assembly.ComponentType;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.spi.ImplementationActivator;
 import org.apache.tuscany.sca.spi.InvokerFactory;
-import org.osoa.sca.Constants;
 
 public class JavaImplementationActivator implements ImplementationActivator<JavaImplementation>
{
-
-    private static final QName IMPLEMENTATION_JAVA = new QName(Constants.SCA_NS, "implementation.java");
-    
-    public QName getSCDLQName() {
-        return IMPLEMENTATION_JAVA;
-    }
 
     public Class<JavaImplementation> getImplementationClass() {
         return JavaImplementation.class;



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


Mime
View raw message