You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/04/11 19:47:14 UTC

svn commit: r393269 - in /incubator/servicemix/trunk/servicemix-wsn2005: ./ src/main/java/org/apache/servicemix/wsn/component/ src/main/java/org/apache/servicemix/wsn/spring/ src/test/java/org/apache/servicemix/wsn/component/ src/test/resources/org/apa...

Author: gnodet
Date: Tue Apr 11 10:47:12 2006
New Revision: 393269

URL: http://svn.apache.org/viewcvs?rev=393269&view=rev
Log:
SM-339: Allow configuration of subscriptions and producers with XBean
The XBean integration has not been completed due to some problems with qdox version parsing java 5

Added:
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/CreatePullPointFactoryBean.java
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/PublisherComponent.java
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/RegisterPublisherFactoryBean.java
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/SubscribeFactoryBean.java
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/WSNSpringComponent.java
    incubator/servicemix/trunk/servicemix-wsn2005/src/test/java/org/apache/servicemix/wsn/component/WSNSpringComponentTest.java
    incubator/servicemix/trunk/servicemix-wsn2005/src/test/resources/org/apache/servicemix/wsn/spring.xml
Modified:
    incubator/servicemix/trunk/servicemix-wsn2005/maven.xml
    incubator/servicemix/trunk/servicemix-wsn2005/project.xml
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/component/WSNDeployer.java

Modified: incubator/servicemix/trunk/servicemix-wsn2005/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/maven.xml?rev=393269&r1=393268&r2=393269&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/maven.xml (original)
+++ incubator/servicemix/trunk/servicemix-wsn2005/maven.xml Tue Apr 11 10:47:12 2006
@@ -23,10 +23,32 @@
          xmlns:maven="jelly:maven"
          xmlns:artifact="artifact">
 
-	 <preGoal name="java:compile">
+  <preGoal name="java:compile">
+    <!--
+    <attainGoal name="xbean:generate" />
+    -->
            <attainGoal name="jaxws:compile"/>
          </preGoal>
 
+  <goal name="xbean:generate" description="Generates the XBean XSD, documentation and META-INF/services files.">
+    <path id="test.classpath">
+      <pathelement path="${maven.build.dest}" />
+      <pathelement path="${basedir}/target/classes" />
+      <pathelement path="${basedir}/target/test-classes" />
+      <path refid="maven.dependency.classpath" />
+    </path>
+
+    <taskdef name="xsdGenerate" classname="org.apache.xbean.spring.generator.MappingGeneratorTask">
+      <classpath refid="test.classpath" />
+    </taskdef>
+    <xsdGenerate
+    destFile="${basedir}/target/servicemix-wsn2005-${pom.currentVersion}.xsd" namespace="http://servicemix.apache.org/wsn2005/1.0"
+    		classpathref="test.classpath" srcdir="${basedir}/src/main/java"  metaInfDir="${basedir}/target/generated/"/>
+  	<copy file="${basedir}/target/servicemix-wsn2005-${pom.currentVersion}.xsd" todir="${basedir}/target/generated/"/>
+  	<copy file="${basedir}/target/servicemix-wsn2005-${pom.currentVersion}.xsd" todir="${basedir}/../xdocs"/>    
+    <copy file="${basedir}/target/servicemix-wsn2005-${pom.currentVersion}.xsd.html" todir="${basedir}/../xdocs"/>
+  </goal>
+  
          <goal name="jaxws:compile" prereqs="setclasspath" description="generate JAX-WS POJOS from WSDL">
            <mkdir dir="${jaxws.compiled.java.dir}"/>
            <mkdir dir="${jaxws.compiled.classes.dir}"/>

Modified: incubator/servicemix/trunk/servicemix-wsn2005/project.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/project.xml?rev=393269&r1=393268&r2=393269&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/project.xml (original)
+++ incubator/servicemix/trunk/servicemix-wsn2005/project.xml Tue Apr 11 10:47:12 2006
@@ -238,7 +238,56 @@
       <id>log4j</id>
       <version>${log4j_version}</version>
     </dependency>
+
+      <dependency>
+        <groupId>annogen</groupId>
+        <artifactId>annogen</artifactId>
+        <version>${annogen_version}</version>
+        <properties>
+          <scope>compile</scope>
+        </properties>
+      </dependency>
+      <dependency>
+        <groupId>qdox</groupId>
+        <artifactId>qdox</artifactId>
+        <version>${qdox_version}</version>
+        <properties>
+          <scope>compile</scope>
+        </properties>
+      </dependency>
+
   </dependencies>
 
+    <build>
+        <unitTest>
+            <resources>
+              <resource>
+                  <directory>src/test/resources</directory>
+                <includes>
+                  <include>**/*</include>
+                </includes>
+              </resource>
+            </resources>
+            <includes>
+                <include>**/*Test.*</include>
+            </includes>
+            <excludes>
+            </excludes>
+        </unitTest>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>target/generated</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+        </resources>
+    </build>
 
 </project>

Modified: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/component/WSNDeployer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/component/WSNDeployer.java?rev=393269&r1=393268&r2=393269&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/component/WSNDeployer.java (original)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/component/WSNDeployer.java Tue Apr 11 10:47:12 2006
@@ -17,6 +17,8 @@
 
 import java.io.File;
 import java.io.FilenameFilter;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -75,7 +77,15 @@
         su.setName(serviceUnitName);
         su.setRootPath(serviceUnitRootPath);
         for (int i = 0; i < xmls.length; i++) {
-            Endpoint ep = createEndpoint(xmls[i]);
+            Endpoint ep;
+            URL url;
+            try {
+                url = xmls[i].toURL();
+            } catch (MalformedURLException e) {
+                // TODO Auto-generated catch block
+                throw new DeploymentException("Error deploying xml file", e); 
+            }
+            ep = createEndpoint(url);
             ep.setServiceUnit(su);
             su.addEndpoint(ep);
         }
@@ -85,13 +95,17 @@
         return su;
     }
 
-    protected Endpoint createEndpoint(File file) throws DeploymentException {
+    public Endpoint createEndpoint(URL url) throws DeploymentException {
         Object request = null;
         try {
-            request = context.createUnmarshaller().unmarshal(file);
+            request = context.createUnmarshaller().unmarshal(url);
         } catch (JAXBException e) {
             throw failure("deploy", "Invalid xml", e);
         }
+        return createEndpoint(request);
+    }
+    
+    public Endpoint createEndpoint(Object request) throws DeploymentException {
         if (request instanceof Subscribe) {
             return new WSNSubscriptionEndpoint((Subscribe) request);
         } else if (request instanceof CreatePullPoint) {

Added: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/CreatePullPointFactoryBean.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/CreatePullPointFactoryBean.java?rev=393269&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/CreatePullPointFactoryBean.java (added)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/CreatePullPointFactoryBean.java Tue Apr 11 10:47:12 2006
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.wsn.spring;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.oasis_open.docs.wsn.b_2.CreatePullPoint;
+import org.springframework.beans.factory.FactoryBean;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+public class CreatePullPointFactoryBean implements FactoryBean {
+
+    private String address;
+    
+    /**
+     * @return Returns the address.
+     */
+    public String getAddress() {
+        return address;
+    }
+
+    /**
+     * @param address The address to set.
+     */
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public Object getObject() throws Exception {
+        CreatePullPoint createPullPoint = new CreatePullPoint();
+        if (address != null) {
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            factory.setNamespaceAware(true);
+            Document doc = factory.newDocumentBuilder().newDocument();
+            Element el = doc.createElementNS("http://servicemix.apache.org/wsn2005/1.0", "address");
+            Text txt = doc.createTextNode(address);
+            el.appendChild(txt);
+            doc.appendChild(el);
+            createPullPoint.getAny().add(el);
+        }
+        return createPullPoint;
+    }
+
+    public Class getObjectType() {
+        return CreatePullPoint.class;
+    }
+
+    public boolean isSingleton() {
+        return false;
+    }
+
+}

Added: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/PublisherComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/PublisherComponent.java?rev=393269&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/PublisherComponent.java (added)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/PublisherComponent.java Tue Apr 11 10:47:12 2006
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.wsn.spring;
+
+import java.io.StringWriter;
+
+import javax.jbi.JBIException;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.bind.JAXBContext;
+import javax.xml.transform.Source;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.MessageExchangeListener;
+import org.apache.servicemix.components.util.ComponentSupport;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.wsn.client.AbstractWSAClient;
+import org.apache.servicemix.wsn.client.NotificationBroker;
+import org.oasis_open.docs.wsn.b_2.Subscribe;
+import org.oasis_open.docs.wsn.b_2.SubscribeResponse;
+import org.oasis_open.docs.wsn.b_2.Unsubscribe;
+import org.oasis_open.docs.wsn.b_2.UnsubscribeResponse;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public class PublisherComponent extends ComponentSupport implements MessageExchangeListener {
+
+    private static final Log log = LogFactory.getLog(PublisherComponent.class);
+    
+    private NotificationBroker wsnBroker;
+    private String topic;
+    private boolean demand;
+    private String subscriptionEndpoint = "subscription";
+    private Subscribe subscription;
+    
+    /**
+     * @return Returns the demand.
+     */
+    public boolean getDemand() {
+        return demand;
+    }
+
+    /**
+     * @param demand The demand to set.
+     */
+    public void setDemand(boolean demand) {
+        this.demand = demand;
+    }
+
+    /**
+     * @return Returns the topic.
+     */
+    public String getTopic() {
+        return topic;
+    }
+
+    /**
+     * @param topic The topic to set.
+     */
+    public void setTopic(String topic) {
+        this.topic = topic;
+    }
+
+    public void init() throws JBIException {
+        super.init();
+        getContext().activateEndpoint(getService(), subscriptionEndpoint);
+    }
+    
+    public void start() throws JBIException {
+        new Thread() {
+            public void run() {
+                try {
+                    wsnBroker = new NotificationBroker(getContext());
+                    String wsaAddress = getService().getNamespaceURI() + "/" + getService().getLocalPart() + "/" + subscriptionEndpoint;
+                    wsnBroker.registerPublisher(AbstractWSAClient.createWSA(wsaAddress),
+                                                topic,
+                                                demand);
+                } catch (Exception e) {
+                    log.error("Could not create wsn client", e);
+                }
+            }
+        }.start();
+    }
+    
+    public void shutDown() throws JBIException {
+        super.shutDown();
+    }
+    
+    public void onMessageExchange(MessageExchange exchange) throws MessagingException {
+        if (exchange.getStatus() != ExchangeStatus.ACTIVE) {
+            return;
+        }
+        // This is a notification from the WSN broker
+        if (exchange.getEndpoint().getEndpointName().equals(subscriptionEndpoint)) {
+            try {
+                JAXBContext jaxbContext = JAXBContext.newInstance(Subscribe.class);
+                Source src = exchange.getMessage("in").getContent();
+                Object input = jaxbContext.createUnmarshaller().unmarshal(src);
+                if (input instanceof Subscribe) {
+                    subscription = (Subscribe) input;
+                    SubscribeResponse response = new SubscribeResponse();
+                    String wsaAddress = getService().getNamespaceURI() + "/" + getService().getLocalPart() + "/" + subscriptionEndpoint;
+                    response.setSubscriptionReference(AbstractWSAClient.createWSA(wsaAddress));
+                    StringWriter writer = new StringWriter();
+                    jaxbContext.createMarshaller().marshal(response, writer);
+                    NormalizedMessage out = exchange.createMessage();
+                    out.setContent(new StringSource(writer.toString()));
+                    exchange.setMessage(out, "out");
+                    send(exchange);
+                } else if (input instanceof Unsubscribe) {
+                    subscription = null;
+                    UnsubscribeResponse response = new UnsubscribeResponse();
+                    StringWriter writer = new StringWriter();
+                    jaxbContext.createMarshaller().marshal(response, writer);
+                    NormalizedMessage out = exchange.createMessage();
+                    out.setContent(new StringSource(writer.toString()));
+                    exchange.setMessage(out, "out");
+                    send(exchange);
+                } else {
+                    throw new Exception("Unkown request");
+                }
+            } catch (Exception e) {
+                fail(exchange, e);
+            }
+        // This is a notification to publish
+        } else {
+            try {
+                if (!demand || subscription != null) {
+                    Node n = new SourceTransformer().toDOMNode(exchange.getMessage("in"));
+                    if (n instanceof Document) {
+                        n = ((Document) n).getDocumentElement();
+                    }
+                    wsnBroker.notify(topic, n);
+                    done(exchange);
+                } else {
+                    log.info("Ingore notification as the publisher is no subscribers");
+                }
+            } catch (Exception e) {
+                fail(exchange, e);
+            }
+        }
+    }
+
+}

Added: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/RegisterPublisherFactoryBean.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/RegisterPublisherFactoryBean.java?rev=393269&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/RegisterPublisherFactoryBean.java (added)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/RegisterPublisherFactoryBean.java Tue Apr 11 10:47:12 2006
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.wsn.spring;
+
+import org.apache.servicemix.wsn.client.AbstractWSAClient;
+import org.oasis_open.docs.wsn.b_2.TopicExpressionType;
+import org.oasis_open.docs.wsn.br_2.RegisterPublisher;
+import org.springframework.beans.factory.FactoryBean;
+
+public class RegisterPublisherFactoryBean implements FactoryBean {
+
+    private String publisher;
+    private String topic;
+    private boolean demand;
+    
+    /**
+     * @return Returns the demand.
+     */
+    public boolean isDemand() {
+        return demand;
+    }
+
+    /**
+     * @param demand The demand to set.
+     */
+    public void setDemand(boolean demand) {
+        this.demand = demand;
+    }
+
+    /**
+     * @return Returns the publisher.
+     */
+    public String getPublisher() {
+        return publisher;
+    }
+
+    /**
+     * @param publisher The publisher to set.
+     */
+    public void setPublisher(String publisher) {
+        this.publisher = publisher;
+    }
+
+    /**
+     * @return Returns the topic.
+     */
+    public String getTopic() {
+        return topic;
+    }
+
+    /**
+     * @param topic The topic to set.
+     */
+    public void setTopic(String topic) {
+        this.topic = topic;
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.beans.factory.FactoryBean#getObject()
+     */
+    public Object getObject() throws Exception {
+        RegisterPublisher registerPublisher = new RegisterPublisher();
+        registerPublisher.setPublisherReference(AbstractWSAClient.createWSA(publisher));
+        if (topic != null) {
+            TopicExpressionType topicExp = new TopicExpressionType();
+            topicExp.getContent().add(topic);
+            registerPublisher.getTopic().add(topicExp);
+        }
+        registerPublisher.setDemand(new Boolean(demand));
+        return registerPublisher;
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+     */
+    public Class getObjectType() {
+        return RegisterPublisher.class;
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+     */
+    public boolean isSingleton() {
+        return false;
+    }
+
+}

Added: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/SubscribeFactoryBean.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/SubscribeFactoryBean.java?rev=393269&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/SubscribeFactoryBean.java (added)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/SubscribeFactoryBean.java Tue Apr 11 10:47:12 2006
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.wsn.spring;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.servicemix.wsn.AbstractSubscription;
+import org.apache.servicemix.wsn.client.AbstractWSAClient;
+import org.oasis_open.docs.wsn.b_2.FilterType;
+import org.oasis_open.docs.wsn.b_2.QueryExpressionType;
+import org.oasis_open.docs.wsn.b_2.Subscribe;
+import org.oasis_open.docs.wsn.b_2.TopicExpressionType;
+import org.oasis_open.docs.wsn.b_2.UseRaw;
+import org.springframework.beans.factory.FactoryBean;
+
+public class SubscribeFactoryBean implements FactoryBean {
+
+    private String consumer;
+    private String topic;
+    private String xpath;
+    private boolean raw;
+    
+    /**
+     * @return Returns the consumer.
+     */
+    public String getConsumer() {
+        return consumer;
+    }
+
+    /**
+     * @param consumer The consumer to set.
+     */
+    public void setConsumer(String consumer) {
+        this.consumer = consumer;
+    }
+
+    /**
+     * @return Returns the topic.
+     */
+    public String getTopic() {
+        return topic;
+    }
+
+    /**
+     * @param topic The topic to set.
+     */
+    public void setTopic(String topic) {
+        this.topic = topic;
+    }
+
+    /**
+     * @return Returns the xpath.
+     */
+    public String getXpath() {
+        return xpath;
+    }
+
+    /**
+     * @param xpath The xpath to set.
+     */
+    public void setXpath(String xpath) {
+        this.xpath = xpath;
+    }
+
+    /**
+     * @return Returns the raw.
+     */
+    public boolean isRaw() {
+        return raw;
+    }
+
+    /**
+     * @param raw The raw to set.
+     */
+    public void setRaw(boolean raw) {
+        this.raw = raw;
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.beans.factory.FactoryBean#getObject()
+     */
+    public Object getObject() throws Exception {
+        Subscribe subscribe = new Subscribe();
+        subscribe.setConsumerReference(AbstractWSAClient.createWSA(consumer));
+        subscribe.setFilter(new FilterType());
+        if (topic != null) {
+            TopicExpressionType topicExp = new TopicExpressionType();
+            topicExp.getContent().add(topic);
+            subscribe.getFilter().getAny().add(new JAXBElement<TopicExpressionType>(AbstractSubscription.QNAME_TOPIC_EXPRESSION, TopicExpressionType.class, topicExp));
+        }
+        if (xpath != null) {
+            QueryExpressionType xpathExp = new QueryExpressionType();
+            xpathExp.setDialect(AbstractSubscription.XPATH1_URI);
+            xpathExp.getContent().add(xpath);
+            subscribe.getFilter().getAny().add(new JAXBElement<QueryExpressionType>(AbstractSubscription.QNAME_MESSAGE_CONTENT, QueryExpressionType.class, xpathExp));
+        }
+        if (raw) {
+            subscribe.setSubscriptionPolicy(new Subscribe.SubscriptionPolicy());
+            subscribe.getSubscriptionPolicy().getAny().add(new UseRaw());
+        }
+        return subscribe;
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+     */
+    public Class getObjectType() {
+        return Subscribe.class;
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+     */
+    public boolean isSingleton() {
+        return false;
+    }
+
+}

Added: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/WSNSpringComponent.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/WSNSpringComponent.java?rev=393269&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/WSNSpringComponent.java (added)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/apache/servicemix/wsn/spring/WSNSpringComponent.java Tue Apr 11 10:47:12 2006
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.wsn.spring;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.wsn.component.WSNDeployer;
+import org.apache.servicemix.wsn.component.WSNLifeCycle;
+import org.springframework.core.io.Resource;
+
+/**
+ * 
+ * @author gnodet
+ * @version $Revision: 376451 $
+ * @org.apache.xbean.XBean element="component"
+ *                  description="An WS-Notification component"
+ */
+public class WSNSpringComponent extends BaseComponent {
+
+    private Resource[] resources;
+    
+    private Object[] requests; 
+    
+    /**
+     * @return Returns the endpoints.
+     */
+    public Resource[] getResources() {
+        return resources;
+    }
+
+    /**
+     * @param endpoints The endpoints to set.
+     */
+    public void setResources(Resource[] endpoints) {
+        this.resources = endpoints;
+    }
+    
+    /**
+     * @return Returns the requests.
+     */
+    public Object[] getRequests() {
+        return requests;
+    }
+
+    /**
+     * @param requests The requests to set.
+     */
+    public void setRequests(Object[] requests) {
+        this.requests = requests;
+    }
+
+    /**
+     * @return Returns the connectionFactory.
+     */
+    public ConnectionFactory getConnectionFactory() {
+        return ((WSNLifeCycle) lifeCycle).getConnectionFactory();
+    }
+
+    /**
+     * @param connectionFactory The connectionFactory to set.
+     */
+    public void setConnectionFactory(ConnectionFactory connectionFactory) {
+        ((WSNLifeCycle) lifeCycle).setConnectionFactory(connectionFactory);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.servicemix.common.BaseComponent#createLifeCycle()
+     */
+    protected BaseLifeCycle createLifeCycle() {
+        return new LifeCycle();
+    }
+
+    public class LifeCycle extends WSNLifeCycle {
+
+        protected ServiceUnit su;
+        
+        public LifeCycle() {
+            super(WSNSpringComponent.this);
+        }
+        
+        /* (non-Javadoc)
+         * @see org.servicemix.common.BaseLifeCycle#doInit()
+         */
+        protected void doInit() throws Exception {
+            super.doInit();
+            su = new ServiceUnit();
+            su.setComponent(WSNSpringComponent.this);
+            WSNDeployer deployer = new WSNDeployer(WSNSpringComponent.this);
+            if (resources != null) {
+                for (int i = 0; i < resources.length; i++) {
+                    Endpoint ep = deployer.createEndpoint(resources[i].getURL());
+                    ep.setServiceUnit(su);
+                    su.addEndpoint(ep);
+                }
+            }
+            if (requests != null) {
+                for (int i = 0; i < requests.length; i++) {
+                    Endpoint ep = deployer.createEndpoint(requests[i]);
+                    ep.setServiceUnit(su);
+                    su.addEndpoint(ep);
+                }
+            }
+            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/servicemix-wsn2005/src/test/java/org/apache/servicemix/wsn/component/WSNSpringComponentTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/src/test/java/org/apache/servicemix/wsn/component/WSNSpringComponentTest.java?rev=393269&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/test/java/org/apache/servicemix/wsn/component/WSNSpringComponentTest.java (added)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/test/java/org/apache/servicemix/wsn/component/WSNSpringComponentTest.java Tue Apr 11 10:47:12 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.wsn.component;
+
+import org.apache.servicemix.tck.Receiver;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class WSNSpringComponentTest extends SpringTestSupport {
+
+    protected AbstractXmlApplicationContext createBeanFactory() {
+        return new ClassPathXmlApplicationContext("org/apache/servicemix/wsn/spring.xml");
+    }
+    
+    public void test() throws Exception {
+        Receiver receiver = (Receiver) jbi.getBean("receiver");
+        receiver.getMessageList().assertMessagesReceived(1);
+    }
+    
+}

Added: incubator/servicemix/trunk/servicemix-wsn2005/src/test/resources/org/apache/servicemix/wsn/spring.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/src/test/resources/org/apache/servicemix/wsn/spring.xml?rev=393269&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/test/resources/org/apache/servicemix/wsn/spring.xml (added)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/test/resources/org/apache/servicemix/wsn/spring.xml Tue Apr 11 10:47:12 2006
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0" 
+	   xmlns:amq="http://activemq.org/config/1.0"
+	   xmlns:test="http://servicemix.org/test">
+
+  <!-- the JBI container -->
+  <sm:container id="jbi" embedded="true">
+    <sm:activationSpecs>
+
+      <sm:activationSpec id="receiver" service="test:service" endpoint="endpoint">
+        <sm:component>
+          <bean class="org.apache.servicemix.tck.ReceiverComponent">
+          </bean>
+        </sm:component>
+      </sm:activationSpec>
+
+      <sm:activationSpec>
+      	<sm:component>
+      	  <bean class="org.apache.servicemix.wsn.spring.WSNSpringComponent">
+      	    <property name="requests">
+      	      <list>
+      	        <bean class="org.apache.servicemix.wsn.spring.SubscribeFactoryBean">
+      	          <property name="consumer" value="http://servicemix.org/test/service/endpoint" />
+      	          <property name="topic" value="myTopic" />
+      	        </bean>
+      	      </list>
+      	    </property>
+      	    <property name="connectionFactory" ref="connectionFactory" />
+      	  </bean>
+        </sm:component>
+      </sm:activationSpec>
+      
+      <sm:activationSpec service="test:publisher" endpoint="endpoint">
+        <sm:component>
+          <bean class="org.apache.servicemix.wsn.spring.PublisherComponent">
+    	    <property name="topic" value="myTopic" />
+          </bean>
+        </sm:component>
+      </sm:activationSpec>
+      
+      <sm:activationSpec destinationService="test:publisher" destinationEndpoint="endpoint">
+        <sm:component>
+          <bean class="org.apache.servicemix.components.quartz.QuartzComponent">
+            <property name="triggers">
+              <map>
+                <entry>
+                  <key>
+                    <bean class="org.quartz.SimpleTrigger">
+                      <property name="repeatInterval" value="2000"/>
+                      <property name="repeatCount" value="20"/>
+                    </bean>
+                  </key>
+                    <bean class="org.quartz.JobDetail">
+                      <property name="name" value="My Example Job"/>
+                      <property name="group" value="ServiceMix"/>
+                    </bean>
+                </entry>
+              </map>
+            </property>
+          </bean>
+        </sm:component>
+      </sm:activationSpec>
+
+    </sm:activationSpecs>
+  </sm:container>
+
+  <bean id="connectionFactory" 
+        class="org.apache.activemq.ActiveMQConnectionFactory"
+        depends-on="broker">
+    <property name="brokerURL" value="tcp://localhost:61216" />
+  </bean>
+  
+  <amq:broker id="broker" persistent="false">
+
+    <amq:transportConnectors>
+      <amq:transportConnector uri="tcp://localhost:61216" />
+    </amq:transportConnectors>
+
+  </amq:broker>
+
+
+</beans>