tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r545862 - in /incubator/tuscany/java/sca: modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ modules/implementation-script/src/main/java/org/apache/tusc...
Date Sun, 10 Jun 2007 10:09:25 GMT
Author: antelder
Date: Sun Jun 10 03:09:23 2007
New Revision: 545862

URL: http://svn.apache.org/viewvc?view=rev&rev=545862
Log:
Change Implementation extensions to not require implementing the Implementation interface

Added:
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/PojoImplementation.java
  (with props)
Modified:
    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/ImplementationImplementationProvider.java
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java
    incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationActivator.java
    incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationActivator.java

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=545862&r1=545861&r2=545862
==============================================================================
--- 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
Sun Jun 10 03:09:23 2007
@@ -21,14 +21,14 @@
 
 import javax.xml.namespace.QName;
 
-import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.ComponentType;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 
-public interface ImplementationActivator<T extends Implementation> {
+public interface ImplementationActivator<T> {
 
     QName getSCDLQName();
     
     Class<T> getImplementationClass();
 
-    InvokerFactory createInvokerFactory(RuntimeComponent rc, T implementation);
+    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/ImplementationImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationImplementationProvider.java?view=diff&rev=545862&r1=545861&r2=545862
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationImplementationProvider.java
(original)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationImplementationProvider.java
Sun Jun 10 03:09:23 2007
@@ -44,13 +44,15 @@
     ImplementationActivator implementationActivator;
     RuntimeComponent runtimeComponent;
     Implementation impl;
+    Object userImpl;
     
     List<InvokerProxy> invokers = new ArrayList<InvokerProxy>();
     
-    public ImplementationImplementationProvider(ImplementationActivator implementationActivator,
RuntimeComponent rc, Implementation impl) {
+    public ImplementationImplementationProvider(ImplementationActivator implementationActivator,
RuntimeComponent rc, Implementation impl, Object userImpl) {
         this.implementationActivator = implementationActivator;
         this.runtimeComponent = rc;
         this.impl = impl;
+        this.userImpl = userImpl;
     }
 
     public Invoker createInvoker(RuntimeComponentService arg0, final Operation op) {
@@ -64,7 +66,7 @@
     }
 
     public void start() {
-        InvokerFactory factory = implementationActivator.createInvokerFactory(runtimeComponent,
impl);
+        InvokerFactory factory = implementationActivator.createInvokerFactory(runtimeComponent,
impl, userImpl);
         for (InvokerProxy invoker : invokers) {
             invoker.start(factory);
         }

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=545862&r1=545861&r2=545862
==============================================================================
--- 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
Sun Jun 10 03:09:23 2007
@@ -93,10 +93,20 @@
 
         providerFactories.addProviderFactory(new ImplementationProviderFactory() {
             public ImplementationProvider createImplementationProvider(final RuntimeComponent
rc, final Implementation impl) {
-                return new ImplementationImplementationProvider(implementationActivator,
rc, impl);
+                if (impl instanceof PojoImplementation) {
+                    return new ImplementationImplementationProvider(implementationActivator,
rc, impl, ((PojoImplementation)impl).getUserImpl());
+                } else {
+                    return new ImplementationImplementationProvider(implementationActivator,
rc, impl, impl);
+                }
             }
             public Class getModelType() {
-                return implementationActivator.getImplementationClass();
+                Class c = implementationActivator.getImplementationClass();
+
+                if (Implementation.class.isAssignableFrom(c)) {
+                    return c;
+                } else {
+                    return PojoImplementation.class;
+                }
             }
         });
     }

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/PojoImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/PojoImplementation.java?view=auto&rev=545862
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/PojoImplementation.java
(added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/PojoImplementation.java
Sun Jun 10 03:09:23 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.spi.impl;
+
+import org.apache.tuscany.sca.spi.utils.DynamicImplementation;
+
+/**
+ * Enables Implementation extensions to use a simple POJO
+ * for the mplementation objcet instead of requiring
+ * implementing the Implementation interface. 
+ */
+public class PojoImplementation<Implementation> extends DynamicImplementation {
+    
+    Object userImpl;
+    
+    public PojoImplementation(Object userImpl) {
+        this.userImpl = userImpl;
+    }
+
+    public Object getUserImpl() {
+        return userImpl;
+    }
+    
+
+}

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/PojoImplementation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/PojoImplementation.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java?view=diff&rev=545862&r1=545861&r2=545862
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java
(original)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java
Sun Jun 10 03:09:23 2007
@@ -76,7 +76,11 @@
             if ("setElementText".equals(m.getName())) {
                 elementTextSetter = m;
             } else if ((m.getName().startsWith("set"))) {
-                attributeSetters.put(m.getName().substring(3).toLowerCase(), m);
+                String name = m.getName().substring(3).toLowerCase();
+                if (name.endsWith("_")) {
+                    name = name.substring(0,name.length()-1);
+                }
+                attributeSetters.put(name, m);
             }
         }
     }
@@ -103,13 +107,19 @@
     }
 
     public Class<Implementation> getModelType() {
-        return implementationClass;
+        Class clazz;
+        if (Implementation.class.isAssignableFrom(implementationClass)) {
+            clazz = implementationClass;
+        } else {
+            clazz = PojoImplementation.class;
+        }
+        return clazz;
     }
 
     public Implementation read(XMLStreamReader reader) throws ContributionReadException,
XMLStreamException {
-        Implementation impl;
+        Object impl;
         try {
-            impl = (Implementation)implementationClass.getConstructors()[0].newInstance(getImplConstrArgs());
+            impl = implementationClass.getConstructors()[0].newInstance(getImplConstrArgs());
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
@@ -139,8 +149,12 @@
         while (!(reader.getEventType() == END_ELEMENT && scdlQName.equals(reader.getName()))
&& reader.hasNext()) {
             reader.next();
         }
+        
+        if (!(impl instanceof Implementation)) {
+            impl = new PojoImplementation(impl);
+        }
 
-        return impl;
+        return (Implementation)impl;
     }
 
     public void write(Implementation arg0, XMLStreamWriter arg1) throws ContributionWriteException,
XMLStreamException {

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=545862&r1=545861&r2=545862
==============================================================================
--- 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
Sun Jun 10 03:09:23 2007
@@ -21,6 +21,7 @@
 
 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;
@@ -46,7 +47,8 @@
         return ScriptImplementation.class;
     }
 
-    public InvokerFactory createInvokerFactory(RuntimeComponent runtimeComponent, ScriptImplementation
implementation) {
-        return new ScriptInvokerFactory(runtimeComponent, implementation, propertyFactory);
+    public InvokerFactory createInvokerFactory(RuntimeComponent rc, ComponentType ct, ScriptImplementation
implementation) {
+        return new ScriptInvokerFactory(rc, implementation, propertyFactory);
     }
+
 }

Modified: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationActivator.java?view=diff&rev=545862&r1=545861&r2=545862
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationActivator.java
(original)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationActivator.java
Sun Jun 10 03:09:23 2007
@@ -21,6 +21,7 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.tuscany.sca.assembly.ComponentType;
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -33,7 +34,7 @@
 
     private static final QName IMPLEMENTATION_CRUD = new QName("http://crud", "implementation.crud");
     
-    public InvokerFactory createInvokerFactory(RuntimeComponent rc, final CRUDImplementation
implementation) {
+    public InvokerFactory createInvokerFactory(RuntimeComponent rc, ComponentType ct, final
CRUDImplementation implementation) {
         return new InvokerFactory() {
             public Invoker createInvoker(Operation operation) {
                 return new CRUDInvoker(operation, new ResourceManager(implementation.getDirectory()));



---------------------------------------------------------------------
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