Hi,

Though I haven't looked deep into the simplifications I really feel it would
be better to have them as part of the SPIs than as an optional thing outside
it.  As a developer I'd be more inclined to look up the SPIs and go on than
look over the SPIs for additional utils or helpers.  Just as perspective
thats all :)

- Venkat

On 6/6/07, ant elder <[EMAIL PROTECTED]> wrote:

I'm not sure i agree about the sample, wont it be even more confusing
having
it use the old way? Maybe if there was something the sample was doing that
required the complex SPI but while there isn't wont it just seem odd to do
it an unnecessarily complicated way.

Do we even want this simpler SPI? If we do i think we should use it, if we
don't we should scrap it now, which I'm fine with doing. Maybe it would be
better to just move some of the simplifications to the existing SPI?

   ...ant

On 6/5/07, Jean-Sebastien Delfino <[EMAIL PROTECTED]> wrote:
>
> Ant,
>
> This commit introduced breaking changes to the helloworld-ws-reference
> and helloworld-ws-service samples, using some kind of <binding.console>.
> Probably an oversight :)
>
> More important, I think we should revert to the official Tuscany SPIs in
> the implementation-crud sample, as it is our main sample to show people
> how to develop extensions using these SPIs.
>
> I'll be happy to have another new sample showing how to use the new
> simplified extension layer, as I think that this new layer will be very
> useful.
>
> This will avoid confusion, and will also allow people to compare and
> choose between the two layers and ways to develop extensions.
>
> Thanks...
>
> [EMAIL PROTECTED] wrote:
> > Author: antelder
> > Date: Tue Jun  5 09:00:23 2007
> > New Revision: 544528
> >
> > URL: http://svn.apache.org/viewvc?view=rev&rev=544528
> > Log:
> > Change implementation-crud sample to use extension-helper instead of
> core spi (hoping that may prompt some review comments on if the
> extension-helper needs changes)
> >
> > Added:
> >
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java
> >
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationActivator.java
> (with props)
> >
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java
> (with props)
> >
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator
> >       - copied, changed from r544134,
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
> > Removed:
> >
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationFactory.java
> >
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/DefaultCRUDImplementationFactory.java
> >
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/impl/
> >
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/module/
> >
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/provider/
> >
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
> > Modified:
> >
>
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/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java
> >
>
incubator/tuscany/java/sca/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite
> >
>
incubator/tuscany/java/sca/samples/helloworld-ws-service/src/main/resources/helloworldws.composite
> >     incubator/tuscany/java/sca/samples/implementation-crud/pom.xml
> >
> > 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=544528&r1=544527&r2=544528
> >
>
==============================================================================
> > ---
>
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
> Tue Jun  5 09:00:23 2007
> > @@ -68,7 +68,7 @@
> >
> >              Class<Implementation> implClass =
> implementationActivator.getImplementationClass();
> >              QName scdlQName = implementationActivator.getSCDLQName();
> > -            staxProcessors.addArtifactProcessor(new
> SCDLProcessor(assemblyFactory, scdlQName, implClass));
> > +            staxProcessors.addArtifactProcessor(new
> SCDLProcessor(assemblyFactory, scdlQName, implClass, registry,
factories));
> >
> >              if (implementationActivator.getImplementationClass() !=
> null && providerFactories != null) {
> >                  addImplementationProvider(implementationActivator,
> providerFactories);
> >
> > 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=544528&r1=544527&r2=544528
> >
>
==============================================================================
> > ---
>
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
> Tue Jun  5 09:00:23 2007
> > @@ -21,10 +21,13 @@
> >
> >  import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
> >
> > +import java.lang.reflect.Constructor;
> >  import java.lang.reflect.Method;
> > +import java.util.ArrayList;
> >  import java.util.Arrays;
> >  import java.util.HashMap;
> >  import java.util.HashSet;
> > +import java.util.List;
> >  import java.util.Map;
> >  import java.util.Set;
> >
> > @@ -37,6 +40,8 @@
> >  import org.apache.tuscany.sca.assembly.Implementation;
> >  import
> org.apache.tuscany.sca.contribution.service.ContributionReadException;
> >  import
> org.apache.tuscany.sca.contribution.service.ContributionWriteException;
> > +import org.apache.tuscany.sca.core.ExtensionPointRegistry;
> > +import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint;
> >  import org.apache.tuscany.sca.spi.utils.AbstractStAXArtifactProcessor
;
> >  import org.apache.tuscany.sca.spi.utils.DynamicImplementation;
> >
> > @@ -48,14 +53,18 @@
> >
> >      protected QName scdlQName;
> >      protected Class<Implementation> implementationClass;
> > +    protected ExtensionPointRegistry registry;
> > +    protected ModelFactoryExtensionPoint factories;
> >
> >      protected Map<String, Method> attributeSetters;
> >      protected Method elementTextSetter;
> >
> > -    public SCDLProcessor(AssemblyFactory assemblyFactory, QName
> scdlQName, Class<Implementation> implementationClass) {
> > +    public SCDLProcessor(AssemblyFactory assemblyFactory, QName
> scdlQName, Class<Implementation> implementationClass,
ExtensionPointRegistry
> registry, ModelFactoryExtensionPoint factories) {
> >          super(assemblyFactory);
> >          this.scdlQName = scdlQName;
> >          this.implementationClass = implementationClass;
> > +        this.registry = registry;
> > +        this.factories = factories;
> >          initAttributes();
> >      }
> >
> > @@ -72,6 +81,23 @@
> >          }
> >      }
> >
> > +    private Object[] getImplConstrArgs() {
> > +        Constructor[] cs = implementationClass.getConstructors();
> > +        if (cs.length != 1) {
> > +            throw new IllegalArgumentException("Implementation class
> must have a single constructor: "+ implementationClass.getName());
> > +        }
> > +        List args = new ArrayList();
> > +        for (Class c : cs[0].getParameterTypes()) {
> > +            Object o = factories.getFactory(c);
> > +            if (o == null) {
> > +                o = registry.getExtensionPoint(c);
> > +            }
> > +            args.add(o);
> > +        }
> > +        return args.toArray();
> > +    }
> > +
> > +
> >      public QName getArtifactType() {
> >          return scdlQName;
> >      }
> > @@ -83,7 +109,7 @@
> >      public Implementation read(XMLStreamReader reader) throws
> ContributionReadException, XMLStreamException {
> >          Implementation impl;
> >          try {
> > -            impl = implementationClass.newInstance();
> > +            impl =
>
(Implementation)implementationClass.getConstructors()[0].newInstance(getImplConstrArgs());
> >          } catch (Exception e) {
> >              throw new RuntimeException(e);
> >          }
> >
> > Modified:
>
incubator/tuscany/java/sca/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java
> > URL:
>
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java?view=diff&rev=544528&r1=544527&r2=544528
> >
>
==============================================================================
> > ---
>
incubator/tuscany/java/sca/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java
> (original)
> > +++
>
incubator/tuscany/java/sca/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java
> Tue Jun  5 09:00:23 2007
> > @@ -30,8 +30,10 @@
> >          SCADomain scaDomain = SCADomain.newInstance("
> helloworldwsclient.composite");
> >          HelloWorldService helloWorldService = scaDomain.getService(
> HelloWorldService.class, "HelloWorldServiceComponent");
> >
> > -        String value = helloWorldService.getGreetings("World");
> > -        System.out.println(value);
> > +//        String value = helloWorldService.getGreetings("World");
> > +//        System.out.println(value);
> > +
> > +        Thread.sleep(900000);
> >
> >          scaDomain.close();
> >      }
> >
> > Modified:
>
incubator/tuscany/java/sca/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite
> > URL:
>
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite?view=diff&rev=544528&r1=544527&r2=544528
> >
>
==============================================================================
> > ---
>
incubator/tuscany/java/sca/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite
> (original)
> > +++
>
incubator/tuscany/java/sca/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite
> Tue Jun  5 09:00:23 2007
> > @@ -22,13 +22,18 @@
> >       xmlns:hw="http://helloworld";
> >       name="helloworldwsclient">
> >
> > +    <service name="HelloWorldService"
> promote="HelloWorldServiceComponent">
> > +        <interface.java interface="helloworld.HelloWorldService" />
> > +        <binding.console/>
> > +    </service>
> > +
> >      <component name="HelloWorldServiceComponent">
> >        <implementation.java class="
helloworld.HelloWorldServiceComponent
> "/>
> >      </component>
> >
> >      <reference name="HelloWorldService"
> promote="HelloWorldServiceComponent/helloWorldService">
> >          <interface.java interface="helloworld.HelloWorldService" />
> > -        <binding.ws wsdlElement="
> http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
> > +        <binding.console/>
> >      </reference>
> >
> >  </composite>
> >
> > Modified:
>
incubator/tuscany/java/sca/samples/helloworld-ws-service/src/main/resources/helloworldws.composite
> > URL:
>
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/helloworld-ws-service/src/main/resources/helloworldws.composite?view=diff&rev=544528&r1=544527&r2=544528
> >
>
==============================================================================
> > ---
>
incubator/tuscany/java/sca/samples/helloworld-ws-service/src/main/resources/helloworldws.composite
> (original)
> > +++
>
incubator/tuscany/java/sca/samples/helloworld-ws-service/src/main/resources/helloworldws.composite
> Tue Jun  5 09:00:23 2007
> > @@ -22,11 +22,12 @@
> >       xmlns:hw="http://helloworld";
> >      name="helloworldws">
> >
> > -    <component name="HelloWorldServiceComponent">
> > -         <service name="HelloWorldService">
> > +         <service name="HelloWorldService"
> promote="HelloWorldServiceComponent">
> >               <interface.wsdl interface="
> http://helloworld#wsdl.interface(HelloWorld)" />
> >               <binding.ws />
> >           </service>
> > +
> > +    <component name="HelloWorldServiceComponent">
> >          <implementation.java class="helloworld.HelloWorldImpl" />
> >      </component>
> >
> >
> > Modified:
incubator/tuscany/java/sca/samples/implementation-crud/pom.xml
> > URL:
>
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/pom.xml?view=diff&rev=544528&r1=544527&r2=544528
> >
>
==============================================================================
> > --- incubator/tuscany/java/sca/samples/implementation-crud/pom.xml
> (original)
> > +++ incubator/tuscany/java/sca/samples/implementation-crud/pom.xml Tue
> Jun  5 09:00:23 2007
> > @@ -36,15 +36,10 @@
> >      </repositories>
> >
> >      <dependencies>
> > -        <dependency>
> > -            <groupId>org.apache.tuscany.sca</groupId>
> > -            <artifactId>sca-api</artifactId>
> > -            <version>1.0-incubating-SNAPSHOT</version>
> > -        </dependency>
> >
> >          <dependency>
> >              <groupId>org.apache.tuscany.sca</groupId>
> > -            <artifactId>tuscany-host-embedded</artifactId>
> > +            <artifactId>tuscany-extension-helper</artifactId>
> >              <version>1.0-incubating-SNAPSHOT</version>
> >          </dependency>
> >
> > @@ -52,7 +47,7 @@
> >              <groupId>org.apache.tuscany.sca</groupId>
> >              <artifactId>tuscany-interface-java-xml</artifactId>
> >              <version>1.0-incubating-SNAPSHOT</version>
> > -        </dependency>
> > +        </dependency>
> >
> >          <dependency>
> >              <groupId>junit</groupId>
> >
> > Added:
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java
> > URL:
>
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java?view=auto&rev=544528
> >
>
==============================================================================
> > ---
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java
> (added)
> > +++
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java
> Tue Jun  5 09:00:23 2007
> > @@ -0,0 +1,79 @@
> > +/*
> > + * 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 crud;
> > +
> > +import java.util.Collections;
> > +import java.util.List;
> > +
> > +import org.apache.tuscany.sca.assembly.AssemblyFactory;
> > +import org.apache.tuscany.sca.assembly.Service;
> > +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
> > +import
> org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
> > +import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
> > +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract
;
> > +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.spi.utils.AbstractImplementation;
> > +
> > +
> > +/**
> > + * The model representing a sample CRUD implementation in an SCA
> assembly model.
> > + */
> > +public class CRUDImplementation extends AbstractImplementation {
> > +
> > +    private Service crudService;
> > +    private String directory;
> > +
> > +    public CRUDImplementation(AssemblyFactory assemblyFactory,
> > +                              JavaInterfaceIntrospectorExtensionPoint
> visitors) {
> > +
> > +            // CRUD implementation always provide a single service
> exposing
> > +            // the CRUD interface, and have no references and
> properties
> > +            crudService = assemblyFactory.createService();
> > +            crudService.setName("CRUD");
> > +
> > +            JavaInterfaceFactory javaFactory = new
> DefaultJavaInterfaceFactory();
> > +            JavaInterfaceIntrospector introspector = new
> ExtensibleJavaInterfaceIntrospector(javaFactory, visitors);
> > +
> > +            JavaInterface javaInterface;
> > +            try {
> > +                javaInterface = introspector.introspect(CRUD.class);
> > +            } catch (InvalidInterfaceException e) {
> > +                throw new IllegalArgumentException(e);
> > +            }
> > +            JavaInterfaceContract interfaceContract =
> javaFactory.createJavaInterfaceContract();
> > +            interfaceContract.setInterface(javaInterface);
> > +            crudService.setInterfaceContract(interfaceContract);
> > +    }
> > +
> > +    public String getDirectory() {
> > +        return directory;
> > +    }
> > +
> > +    public void setDirectory(String directory) {
> > +        this.directory = directory;
> > +    }
> > +
> > +    public List<Service> getServices() {
> > +        // The sample CRUD implementation provides a single fixed
CRUD
> service
> > +        return Collections.singletonList(crudService);
> > +    }
> > +}
> >
> > Added:
>
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=auto&rev=544528
> >
>
==============================================================================
> > ---
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationActivator.java
> (added)
> > +++
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationActivator.java
> Tue Jun  5 09:00:23 2007
> > @@ -0,0 +1,51 @@
> > +/*
> > + * 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 crud;
> > +
> > +import javax.xml.namespace.QName;
> > +
> > +import org.apache.tuscany.sca.interfacedef.Operation;
> > +import org.apache.tuscany.sca.invocation.Invoker;
> > +import org.apache.tuscany.sca.runtime.RuntimeComponent;
> > +import org.apache.tuscany.sca.spi.ImplementationActivator;
> > +import org.apache.tuscany.sca.spi.InvokerFactory;
> > +
> > +import crud.backend.ResourceManager;
> > +
> > +public class CRUDImplementationActivator implements
> ImplementationActivator<CRUDImplementation> {
> > +
> > +    private static final QName IMPLEMENTATION_CRUD = new QName("
> http://crud";, "implementation.crud");
> > +
> > +    public InvokerFactory createInvokerFactory(RuntimeComponent rc,
> final CRUDImplementation implementation) {
> > +        return new InvokerFactory() {
> > +            public Invoker createInvoker(Operation operation) {
> > +                return new CRUDInvoker(operation, new
ResourceManager(
> implementation.getDirectory()));
> > +            }};
> > +    }
> > +
> > +    public Class<CRUDImplementation> getImplementationClass() {
> > +        return CRUDImplementation.class;
> > +    }
> > +
> > +    public QName getSCDLQName() {
> > +        return IMPLEMENTATION_CRUD;
> > +    }
> > +
> > +}
> >
> > Propchange:
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationActivator.java
> >
>
------------------------------------------------------------------------------
> >     svn:eol-style = native
> >
> > Propchange:
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationActivator.java
> >
>
------------------------------------------------------------------------------
> >     svn:keywords = Rev Date
> >
> > Added:
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java
> > URL:
>
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java?view=auto&rev=544528
> >
>
==============================================================================
> > ---
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java
> (added)
> > +++
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java
> Tue Jun  5 09:00:23 2007
> > @@ -0,0 +1,77 @@
> > +/*
> > + * 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 crud;
> > +
> > +import java.lang.reflect.InvocationTargetException;
> > +
> > +import org.apache.tuscany.sca.interfacedef.Operation;
> > +import org.apache.tuscany.sca.invocation.Invoker;
> > +import org.apache.tuscany.sca.invocation.Message;
> > +
> > +import crud.backend.ResourceManager;
> > +
> > +/**
> > + * Implements a target invoker for CRUD component implementations.
> > + *
> > + * The target invoker is responsible for dispatching invocations to
the
> particular
> > + * component implementation logic. In this example we are simply
> delegating the
> > + * CRUD operation invocations to the corresponding methods on our
fake
> > + * resource manager.
> > + */
> > +public class CRUDInvoker implements Invoker {
> > +    private Operation operation;
> > +    private ResourceManager resourceManager;
> > +
> > +    public CRUDInvoker(Operation operation, ResourceManager
> resourceManager) {
> > +        this.operation = operation;
> > +        this.resourceManager = resourceManager;
> > +    }
> > +
> > +    public Message invoke(Message msg) {
> > +        try {
> > +            Object[] args = msg.getBody();
> > +            Object resp = doTheWork(args);
> > +            msg.setBody(resp);
> > +        } catch (InvocationTargetException e) {
> > +            msg.setFaultBody(e.getCause());
> > +        }
> > +        return msg;
> > +    }
> > +
> > +    public Object doTheWork(Object[] args) throws
> InvocationTargetException {
> > +        if (operation.getName().equals("create")) {
> > +            return resourceManager.createResource(args[0]);
> > +
> > +        } else if (operation.getName().equals("retrieve")) {
> > +            return resourceManager.retrieveResource((String)args[0]);
> > +
> > +        } else if (operation.getName().equals("update")) {
> > +            return resourceManager.updateResource((String)args[0],
> args[1]);
> > +
> > +        } else if (operation.getName().equals("delete")) {
> > +            resourceManager.deleteResource((String)args[0]);
> > +            return null;
> > +
> > +        } else {
> > +            return null;
> > +        }
> > +    }
> > +
> > +}
> >
> > Propchange:
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java
> >
>
------------------------------------------------------------------------------
> >     svn:eol-style = native
> >
> > Propchange:
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java
> >
>
------------------------------------------------------------------------------
> >     svn:keywords = Rev Date
> >
> > Copied:
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator
> (from r544134,
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator)
> > URL:
>
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator?view=diff&rev=544528&p1=incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator&r1=544134&p2=incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator&r2=544528
> >
>
==============================================================================
> > ---
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
> (original)
> > +++
>
incubator/tuscany/java/sca/samples/implementation-crud/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator
> Tue Jun  5 09:00:23 2007
> > @@ -15,4 +15,4 @@
> >  # specific language governing permissions and limitations
> >  # under the License.
> >  # Implementation class for the ExtensionActivator
> > -crud.module.CRUDModuleActivator
> > +crud.CRUDImplementationActivator
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
>
>
> --
> Jean-Sebastien
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to