servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r406050 - in /incubator/servicemix/trunk/tooling/maven2-plugins: ./ archetypes/ archetypes/servicemix-service-engine/ archetypes/servicemix-service-engine/src/ archetypes/servicemix-service-engine/src/main/ archetypes/servicemix-service-eng...
Date Sat, 13 May 2006 09:04:21 GMT
Author: gnodet
Date: Sat May 13 02:04:19 2006
New Revision: 406050

URL: http://svn.apache.org/viewcvs?rev=406050&view=rev
Log:
SM-341: Create an m2 archetype for service engines based on servicemix-common

Added:
    incubator/servicemix/trunk/tooling/maven2-plugins/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/pom.xml
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/META-INF/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/META-INF/maven/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/META-INF/maven/archetype.xml
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/pom.xml
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyBootstrap.java
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyComponent.java
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyDeployer.java
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyEndpoint.java
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyLifeCycle.java
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MySpringComponent.java
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/resources/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/java/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/java/MySpringComponentTest.java
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/resources/
    incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/resources/spring.xml

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/pom.xml?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/pom.xml
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/pom.xml
Sat May 13 02:04:19 2006
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.servicemix.archetypes</groupId>
+  <artifactId>servicemix-service-engine</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Archetype - servicemix-service-engine</name>
+  <url>http://maven.apache.org</url>
+</project>

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/META-INF/maven/archetype.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/META-INF/maven/archetype.xml?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/META-INF/maven/archetype.xml
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/META-INF/maven/archetype.xml
Sat May 13 02:04:19 2006
@@ -0,0 +1,17 @@
+<archetype>
+  <id>servicemix-se</id>
+  <sources>
+    <source>src/main/java/MyBootstrap.java</source>
+    <source>src/main/java/MyComponent.java</source>
+    <source>src/main/java/MyDeployer.java</source>
+    <source>src/main/java/MyEndpoint.java</source>
+    <source>src/main/java/MyLifeCycle.java</source>
+    <source>src/main/java/MySpringComponent.java</source>
+  </sources>
+  <testSources>
+    <source>src/test/java/MySpringComponentTest.java</source>
+  </testSources>
+  <testResources>
+    <resource>src/test/resources/spring.xml</resource>
+  </testResources>
+</archetype>

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/pom.xml?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/pom.xml
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/pom.xml
Sat May 13 02:04:19 2006
@@ -0,0 +1,70 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>${groupId}</groupId>
+  <artifactId>${artifactId}</artifactId>
+  <packaging>jbi-component</packaging>
+  <version>${version}</version>
+  <name>A custom project</name>
+  <url>http://www.myorganization.org</url>
+  <properties>
+    <servicemixVersion>3.0-SNAPSHOT</servicemixVersion>
+    <servicemixJbiPluginVersion>1.0-SNAPSHOT</servicemixJbiPluginVersion>
+    <xbeanPluginVersion>2.3</xbeanPluginVersion>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-jbi</artifactId>
+      <version>${servicemixVersion}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-common</artifactId>
+      <version>${servicemixVersion}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-core</artifactId>
+      <version>${servicemixVersion}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.servicemix.plugins</groupId>
+        <artifactId>maven2-jbi-plugin</artifactId>
+        <version>${servicemixJbiPluginVersion}</version>
+        <extensions>true</extensions>
+        <configuration>
+          <type>service-engine</type>
+          <bootstrap>${packageName}.MyBootstrap</bootstrap>
+          <component>${packageName}.MyComponent</component>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>maven-xbean-plugin</artifactId>
+        <version>${xbeanPluginVersion}</version>
+        <executions>
+          <execution>
+            <configuration>
+              <namespace>http://${packageName}/1.0</namespace>
+            </configuration>
+            <goals>
+              <goal>mapping</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyBootstrap.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyBootstrap.java?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyBootstrap.java
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyBootstrap.java
Sat May 13 02:04:19 2006
@@ -0,0 +1,32 @@
+package ${packageName};
+
+import org.apache.servicemix.common.BaseBootstrap;
+
+/**
+ * Bootstrap class.
+ * This class is usefull to perform tasks at installation / uninstallation time 
+ */
+public class MyBootstrap extends BaseBootstrap
+{
+
+    protected void doInit() throws Exception {
+        super.doInit();
+    }
+    
+    protected void doCleanUp() throws Exception {
+        super.doCleanUp();
+    }
+ 
+    protected void doOnInstall() throws Exception {
+        super.doOnInstall();
+    }
+ 
+    protected void doOnUninstall() throws Exception {
+        super.doOnUninstall();
+    }
+ 
+    protected Object getExtensionMBean() throws Exception {
+        return null;
+    }
+    
+}

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyComponent.java?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyComponent.java
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyComponent.java
Sat May 13 02:04:19 2006
@@ -0,0 +1,28 @@
+package ${packageName};
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.BaseServiceUnitManager;
+import org.apache.servicemix.common.Deployer;
+
+/**
+ *
+ */
+public class MyComponent extends BaseComponent
+{
+    /* (non-Javadoc)
+     * @see org.servicemix.common.BaseComponent#createLifeCycle()
+     */
+    protected BaseLifeCycle createLifeCycle() {
+        return new MyLifeCycle(this);
+    }
+
+    /* (non-Javadoc)
+     * @see org.servicemix.common.BaseComponent#createServiceUnitManager()
+     */
+    public BaseServiceUnitManager createServiceUnitManager() {
+        Deployer[] deployers = new Deployer[] { new MyDeployer(this) };
+        return new BaseServiceUnitManager(this, deployers);
+    }
+
+}

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyDeployer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyDeployer.java?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyDeployer.java
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyDeployer.java
Sat May 13 02:04:19 2006
@@ -0,0 +1,22 @@
+package ${packageName};
+
+import javax.jbi.management.DeploymentException;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.xbean.AbstractXBeanDeployer;
+
+public class MyDeployer extends AbstractXBeanDeployer {
+
+    public MyDeployer(BaseComponent component) {
+        super(component);
+    }
+
+    protected boolean validate(Endpoint endpoint) throws DeploymentException {
+        if (endpoint instanceof MyEndpoint == false) {
+            throw new DeploymentException("Endpoint should be a MyEndpoint");
+        }
+        ((MyEndpoint) endpoint).validate();
+        return true;
+    }
+}

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyEndpoint.java?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyEndpoint.java
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyEndpoint.java
Sat May 13 02:04:19 2006
@@ -0,0 +1,146 @@
+package ${packageName};
+
+import javax.jbi.component.ComponentContext;
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessageExchangeFactory;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.servicedesc.ServiceEndpoint;
+
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ExchangeProcessor;
+
+/**
+ * @org.apache.xbean.XBean element="endpoint"
+ */
+public class MyEndpoint extends Endpoint implements ExchangeProcessor {
+
+    private ServiceEndpoint activated;
+    private DeliveryChannel channel;
+    private MessageExchangeFactory exchangeFactory;
+    
+    /* (non-Javadoc)
+     * @see org.apache.servicemix.common.Endpoint#getRole()
+     */
+    public Role getRole() {
+        return Role.PROVIDER;
+    }
+
+    public void activate() throws Exception {
+        logger = this.serviceUnit.getComponent().getLogger();
+        ComponentContext ctx = getServiceUnit().getComponent().getComponentContext();
+        channel = ctx.getDeliveryChannel();
+        exchangeFactory = channel.createExchangeFactory();
+        activated = ctx.activateEndpoint(service, endpoint);
+        start();
+    }
+
+    public void deactivate() throws Exception {
+        stop();
+        ServiceEndpoint ep = activated;
+        activated = null;
+        ComponentContext ctx = getServiceUnit().getComponent().getComponentContext();
+        ctx.deactivateEndpoint(ep);
+    }
+
+    public ExchangeProcessor getProcessor() {
+        return this;
+    }
+    
+    public void validate() throws DeploymentException {
+    }
+    
+    protected void send(MessageExchange me) throws MessagingException {
+        if (me.getRole() == MessageExchange.Role.CONSUMER &&
+            me.getStatus() == ExchangeStatus.ACTIVE) {
+            BaseLifeCycle lf = (BaseLifeCycle) getServiceUnit().getComponent().getLifeCycle();
+            lf.sendConsumerExchange(me, (Endpoint) this);
+        } else {
+            channel.send(me);
+        }
+    }
+    
+    protected void done(MessageExchange me) throws MessagingException {
+        me.setStatus(ExchangeStatus.DONE);
+        send(me);
+    }
+    
+    protected void fail(MessageExchange me, Exception error) throws MessagingException {
+        me.setError(error);
+        send(me);
+    }
+    
+    public void start() throws Exception {
+    }
+    
+    public void stop() {
+    }
+
+    public void process(MessageExchange exchange) throws Exception {
+        // The component acts as a provider, this means that another component has requested
our service
+        // As this exchange is active, this is either an in or a fault (out are send by this
component)
+        if (exchange.getRole() == MessageExchange.Role.PROVIDER) {
+            // Check here if the mep is supported by this component
+            if (exchange instanceof InOut == false) {
+               throw new UnsupportedOperationException("Unsupported MEP: " + exchange.getPattern());
+            }
+            // In message
+            if (exchange.getMessage("in") != null) {
+                NormalizedMessage in = exchange.getMessage("in");
+                // TODO ... handle the in message
+                // If the MEP is an InOnly, RobustInOnly, you have to set the exchange to
DONE status
+                // else, you have to create an Out message and populate it
+                // For now, just echo back
+                NormalizedMessage out = exchange.createMessage();
+                out.setContent(in.getContent());
+                exchange.setMessage(out, "out");
+                channel.send(exchange);
+            // Fault message
+            } else if (exchange.getFault() != null) {
+                // TODO ... handle the fault
+                exchange.setStatus(ExchangeStatus.DONE);
+                channel.send(exchange);
+            // This is not compliant with the default MEPs
+            } else {
+                throw new IllegalStateException("Provider exchange is ACTIVE, but no in or
fault is provided");
+            }
+        // The component acts as a consumer, this means this exchange is received because
+        // we sent it to another component.  As it is active, this is either an out or a
fault
+        // If this component does not create / send exchanges, you may just throw an UnsupportedOperationException
+        } else if (exchange.getRole() == MessageExchange.Role.CONSUMER) {
+            // Exchange is finished
+            if (exchange.getStatus() == ExchangeStatus.DONE) {
+                return;
+            // Exchange has been aborted with an exception
+            } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+                return;
+            // Exchange is active
+            } else {
+                // Out message
+                if (exchange.getMessage("out") != null) {
+                    // TODO ... handle the response
+                    exchange.setStatus(ExchangeStatus.DONE);
+                    channel.send(exchange);
+                // Fault message
+                } else if (exchange.getFault() != null) {
+                    // TODO ... handle the fault
+                    exchange.setStatus(ExchangeStatus.DONE);
+                    channel.send(exchange);
+                // This is not compliant with the default MEPs
+                } else {
+                    throw new IllegalStateException("Consumer exchange is ACTIVE, but no
out or fault is provided");
+                }
+            }
+        // Unknown role
+        } else {
+            throw new IllegalStateException("Unkown role: " + exchange.getRole());
+        }
+    }
+
+}

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyLifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyLifeCycle.java?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyLifeCycle.java
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MyLifeCycle.java
Sat May 13 02:04:19 2006
@@ -0,0 +1,15 @@
+package ${packageName};
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+
+/**
+ *
+ */
+public class MyLifeCycle extends BaseLifeCycle {
+
+    public MyLifeCycle(BaseComponent component) {
+        super(component);
+    }
+
+}

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MySpringComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MySpringComponent.java?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MySpringComponent.java
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/main/java/MySpringComponent.java
Sat May 13 02:04:19 2006
@@ -0,0 +1,89 @@
+package ${packageName};
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.common.xbean.XBeanServiceUnit;
+
+/**
+ * 
+ * @org.apache.xbean.XBean element="component"
+ *                  description="My component"
+ */
+public class MySpringComponent extends BaseComponent {
+
+    private MyEndpoint[] endpoints;
+
+    /**
+     * @return Returns the endpoints.
+     */
+    public MyEndpoint[] getEndpoints() {
+        return endpoints;
+    }
+
+    /**
+     * @param endpoints The endpoints to set.
+     */
+    public void setEndpoints(MyEndpoint[] endpoints) {
+        this.endpoints = endpoints;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.servicemix.common.BaseComponent#createLifeCycle()
+     */
+    protected BaseLifeCycle createLifeCycle() {
+        return new LifeCycle();
+    }
+
+    /**
+     * @author gnodet
+     */
+    public class LifeCycle extends MyLifeCycle {
+
+        protected ServiceUnit su;
+        
+        public LifeCycle() {
+            super(MySpringComponent.this);
+        }
+        
+        /* (non-Javadoc)
+         * @see org.servicemix.common.BaseLifeCycle#doInit()
+         */
+        protected void doInit() throws Exception {
+            super.doInit();
+            su = new XBeanServiceUnit();
+            su.setComponent(MySpringComponent.this);
+            for (int i = 0; i < endpoints.length; i++) {
+                endpoints[i].setServiceUnit(su);
+                endpoints[i].validate();
+                su.addEndpoint(endpoints[i]);
+            }
+            getRegistry().registerServiceUnit(su);
+        }
+
+        /* (non-Javadoc)
+         * @see org.servicemix.common.BaseLifeCycle#doStart()
+         */
+        protected void doStart() throws Exception {
+            super.doStart();
+            su.start();
+        }
+        
+        /* (non-Javadoc)
+         * @see org.servicemix.common.BaseLifeCycle#doStop()
+         */
+        protected void doStop() throws Exception {
+            su.stop();
+            super.doStop();
+        }
+        
+        /* (non-Javadoc)
+         * @see org.servicemix.common.BaseLifeCycle#doShutDown()
+         */
+        protected void doShutDown() throws Exception {
+            su.shutDown();
+            super.doShutDown();
+        }
+    }
+
+}

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/java/MySpringComponentTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/java/MySpringComponentTest.java?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/java/MySpringComponentTest.java
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/java/MySpringComponentTest.java
Sat May 13 02:04:19 2006
@@ -0,0 +1,40 @@
+package ${packageName};
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class MySpringComponentTest extends SpringTestSupport {
+
+    public void test() throws Exception {
+        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+        InOut me = client.createInOutExchange();
+        me.setService(new QName("urn:test", "service"));
+        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
+        client.sendSync(me);
+        if (me.getStatus() == ExchangeStatus.ERROR) {
+            if (me.getFault() != null) {
+                fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
+            } else if (me.getError() != null) {
+                throw me.getError();
+            } else {
+                fail("Received ERROR status");
+            }
+        } else {
+            System.out.println(new SourceTransformer().toString(me.getOutMessage().getContent()));
+        }
+        client.done(me);
+    }
+    
+    protected AbstractXmlApplicationContext createBeanFactory() {
+        return new ClassPathXmlApplicationContext("spring.xml");
+    }
+    
+}

Added: incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/resources/spring.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/resources/spring.xml?rev=406050&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/resources/spring.xml
(added)
+++ incubator/servicemix/trunk/tooling/maven2-plugins/archetypes/servicemix-service-engine/src/main/resources/archetype-resources/src/test/resources/spring.xml
Sat May 13 02:04:19 2006
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0" 
+	     xmlns:my="http://${packageName}/1.0"
+       xmlns:test="urn:test">
+
+  <sm:container id="jbi" embedded="true" createMBeanServer="false">
+    
+    <sm:activationSpecs>
+
+      <sm:activationSpec>
+      	<sm:component>
+            <my:component>
+            	<my:endpoints>
+            		<my:endpoint service="test:service" endpoint="endpoint" />
+            	</my:endpoints>
+            </my:component>
+        </sm:component>
+      </sm:activationSpec>
+
+    </sm:activationSpecs>
+  </sm:container>
+
+</beans>



Mime
View raw message