servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r679580 - in /servicemix/components/engines/servicemix-wsn2005/trunk: ./ src/main/java/org/apache/servicemix/wsn/ src/main/java/org/apache/servicemix/wsn/client/ src/main/java/org/apache/servicemix/wsn/component/ src/main/java/org/apache/se...
Date Thu, 24 Jul 2008 22:20:00 GMT
Author: gnodet
Date: Thu Jul 24 15:19:58 2008
New Revision: 679580

URL: http://svn.apache.org/viewvc?rev=679580&view=rev
Log:
SM-1481: Refactor a bit the WS-Notification component to be independant on servicemix-core and to work in OSGi

Added:
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNDeployableEndpoint.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNPublisherEndpoint.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNPullPointEndpoint.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNServiceUnit.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNSubscriptionEndpoint.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/spring/WSNDeployableEndpointFactoryBean.java
Removed:
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/JAXBMarshaler.java
Modified:
    servicemix/components/engines/servicemix-wsn2005/trunk/pom.xml
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/AbstractCreatePullPoint.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/AbstractNotificationBroker.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/AbstractWSAClient.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/CreatePullPoint.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/NotificationBroker.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/Publisher.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/PullPoint.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/Subscription.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNComponent.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNDeployer.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNEndpoint.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/jbi/JbiPublisher.java
    servicemix/components/engines/servicemix-wsn2005/trunk/src/main/resources/META-INF/spring/servicemix-wsn2005.xml
    servicemix/components/engines/servicemix-wsn2005/trunk/src/test/java/org/apache/servicemix/wsn/component/WSNComponentTest.java

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/pom.xml?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/pom.xml (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/pom.xml Thu Jul 24 15:19:58 2008
@@ -48,14 +48,18 @@
     <cxf-version>2.1.1</cxf-version>
 
     <servicemix.osgi.import>
+        org.apache.servicemix;resolution:=optional,
         org.apache.servicemix.client*;resolution:=optional,
+        org.apache.servicemix.common,
         org.apache.servicemix.common.osgi,
+        org.apache.servicemix.executors.impl,
+        org.apache.servicemix.jbi.resolver;resolution:=optional,
         org.apache.xbean.spring.context.v2,
         org.springframework.beans.factory.xml,
         *
     </servicemix.osgi.import>
     <servicemix.osgi.export>
-        org.apache.servicemix*;version=${project.version},
+        org.apache.servicemix.wsn*;version=${project.version},
         META-INF.services.org.apache.xbean.spring.http.servicemix.apache.org.wsn
     </servicemix.osgi.export>
   </properties>

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/AbstractCreatePullPoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/AbstractCreatePullPoint.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/AbstractCreatePullPoint.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/AbstractCreatePullPoint.java Thu Jul 24 15:19:58 2008
@@ -27,10 +27,10 @@
 
 import org.w3c.dom.Element;
 
-import org.apache.activemq.util.IdGenerator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.jbi.util.DOMUtil;
+import org.apache.servicemix.id.IdGenerator;
+import org.apache.servicemix.common.util.DOMUtil;
 import org.apache.servicemix.wsn.client.AbstractWSAClient;
 import org.oasis_open.docs.wsn.b_2.CreatePullPointResponse;
 import org.oasis_open.docs.wsn.b_2.UnableToCreatePullPointFaultType;

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/AbstractNotificationBroker.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/AbstractNotificationBroker.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/AbstractNotificationBroker.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/AbstractNotificationBroker.java Thu Jul 24 15:19:58 2008
@@ -26,9 +26,9 @@
 import javax.jws.WebService;
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
 
-import org.apache.activemq.util.IdGenerator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.id.IdGenerator;
 import org.apache.servicemix.wsn.client.AbstractWSAClient;
 import org.oasis_open.docs.wsn.b_2.GetCurrentMessage;
 import org.oasis_open.docs.wsn.b_2.GetCurrentMessageResponse;

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/AbstractWSAClient.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/AbstractWSAClient.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/AbstractWSAClient.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/AbstractWSAClient.java Thu Jul 24 15:19:58 2008
@@ -17,9 +17,15 @@
 package org.apache.servicemix.wsn.client;
 
 import javax.jbi.JBIException;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.component.ComponentContext;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
+import javax.xml.bind.util.JAXBSource;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.Source;
@@ -29,34 +35,29 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
-import org.apache.servicemix.client.DefaultServiceMixClient;
-import org.apache.servicemix.client.ServiceMixClient;
-import org.apache.servicemix.client.ServiceMixClientFacade;
-import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.common.util.DOMUtil;
+import org.apache.servicemix.common.util.URIResolver;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.apache.servicemix.jbi.resolver.EndpointResolver;
-import org.apache.servicemix.jbi.resolver.ServiceAndEndpointNameResolver;
-import org.apache.servicemix.jbi.resolver.URIResolver;
-import org.apache.servicemix.jbi.util.DOMUtil;
 import org.oasis_open.docs.wsn.b_2.Subscribe;
 import org.oasis_open.docs.wsn.br_2.RegisterPublisher;
 
 public abstract class AbstractWSAClient {
 
+    private static JAXBContext jaxbContext;
+
     private W3CEndpointReference endpoint;
 
-    private EndpointResolver resolver;
+    private ComponentContext context;
 
-    private ServiceMixClient client;
+    private ServiceEndpoint serviceEndpoint;
 
     public AbstractWSAClient() {
     }
 
-    public AbstractWSAClient(W3CEndpointReference endpoint, ServiceMixClient client) {
+    public AbstractWSAClient(ComponentContext context, W3CEndpointReference endpoint) {
+        this.context = context;
         this.endpoint = endpoint;
-        this.resolver = resolveWSA(endpoint);
-        this.client = client;
     }
 
     public static W3CEndpointReference createWSA(String address) {
@@ -80,21 +81,9 @@
         return null;
     }
 
-    public static ServiceMixClient createJaxbClient(JBIContainer container) throws JBIException, JAXBException {
-        DefaultServiceMixClient client = new DefaultServiceMixClient(container);
-        client.setMarshaler(new JAXBMarshaler(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
-        return client;
-    }
-
-    public static ServiceMixClient createJaxbClient(ComponentContext context) throws JAXBException {
-        ServiceMixClientFacade client = new ServiceMixClientFacade(context);
-        client.setMarshaler(new JAXBMarshaler(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
-        return client;
-    }
-
-    public static EndpointResolver resolveWSA(W3CEndpointReference ref) {
+    public static ServiceEndpoint resolveWSA(W3CEndpointReference ref, ComponentContext context) {
         String[] parts = URIResolver.split3(getWSAAddress(ref));
-        return new ServiceAndEndpointNameResolver(new QName(parts[0], parts[1]), parts[2]);
+        return context.getEndpoint(new QName(parts[0], parts[1]), parts[2]);
     }
 
     public W3CEndpointReference getEndpoint() {
@@ -105,28 +94,80 @@
         this.endpoint = endpoint;
     }
 
-    public EndpointResolver getResolver() {
-        return resolver;
+    public ServiceEndpoint getServiceEndpoint() {
+        if (serviceEndpoint == null && endpoint != null) {
+            serviceEndpoint = resolveWSA(endpoint, context);
+        }
+        return serviceEndpoint;
     }
 
-    public void setResolver(EndpointResolver resolver) {
-        this.resolver = resolver;
+    public void setServiceEndpoint(ServiceEndpoint serviceEndpoint) {
+        this.serviceEndpoint = serviceEndpoint;
     }
 
-    public ServiceMixClient getClient() {
-        return client;
+    public ComponentContext getContext() {
+        return context;
     }
 
-    public void setClient(ServiceMixClient client) {
-        this.client = client;
+    public void setContext(ComponentContext context) {
+        this.context = context;
     }
 
     protected Object request(Object request) throws JBIException {
-        return client.request(resolver, null, null, request);
+        return request(null, request);
+    }
+
+    protected Object request(QName operation, Object request) throws JBIException {
+        try {
+            InOut exchange = getContext().getDeliveryChannel().createExchangeFactory().createInOutExchange();
+            exchange.setEndpoint(getServiceEndpoint());
+            exchange.setOperation(operation);
+            NormalizedMessage in = exchange.createMessage();
+            exchange.setInMessage(in);
+            in.setContent(new JAXBSource(getJAXBContext(), request));
+            getContext().getDeliveryChannel().sendSync(exchange);
+            if (exchange.getStatus() == ExchangeStatus.ERROR) {
+                throw new JBIException(exchange.getError());
+            } else if (exchange.getFault() != null) {
+                throw new JBIException(exchange.getFault().toString());
+            } else {
+                NormalizedMessage out = exchange.getOutMessage();
+                Object result = getJAXBContext().createUnmarshaller().unmarshal(out.getContent());
+                exchange.setStatus(ExchangeStatus.DONE);
+                getContext().getDeliveryChannel().send(exchange);
+                return result;
+            }
+        } catch (JAXBException e) {
+            throw new JBIException(e);
+        }
     }
 
     protected void send(Object request) throws JBIException {
-        client.sendSync(resolver, null, null, request);
+        send(null, request);
+    }
+
+    protected void send(QName operation, Object request) throws JBIException {
+        try {
+            InOnly exchange = getContext().getDeliveryChannel().createExchangeFactory().createInOnlyExchange();
+            exchange.setEndpoint(getServiceEndpoint());
+            exchange.setOperation(operation);
+            NormalizedMessage in = exchange.createMessage();
+            exchange.setInMessage(in);
+            in.setContent(new JAXBSource(getJAXBContext(), request));
+            getContext().getDeliveryChannel().sendSync(exchange);
+            if (exchange.getStatus() == ExchangeStatus.ERROR) {
+                throw new JBIException(exchange.getError());
+            }
+        } catch (JAXBException e) {
+            throw new JBIException(e);
+        }
+    }
+
+    private synchronized JAXBContext getJAXBContext() throws JAXBException {
+        if (jaxbContext == null) {
+            jaxbContext = JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class);
+        }
+        return jaxbContext;
     }
 
 }

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/CreatePullPoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/CreatePullPoint.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/CreatePullPoint.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/CreatePullPoint.java Thu Jul 24 15:19:58 2008
@@ -18,17 +18,9 @@
 
 import javax.jbi.JBIException;
 import javax.jbi.component.ComponentContext;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
 
-import org.apache.servicemix.client.ServiceMixClient;
-import org.apache.servicemix.client.ServiceMixClientFacade;
-import org.apache.servicemix.jbi.container.JBIContainer;
-import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver;
 import org.oasis_open.docs.wsn.b_2.CreatePullPointResponse;
-import org.oasis_open.docs.wsn.b_2.Subscribe;
-import org.oasis_open.docs.wsn.br_2.RegisterPublisher;
 
 public class CreatePullPoint extends AbstractWSAClient {
 
@@ -38,45 +30,18 @@
 
     public static final QName NOTIFICATION_BROKER = new QName(WSN_URI, WSN_SERVICE);
 
-    public CreatePullPoint(ComponentContext context) throws JAXBException {
-        ServiceMixClientFacade client = new ServiceMixClientFacade(context);
-        client.setMarshaler(new JAXBMarshaler(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
-        setClient(client);
-        setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER));
+    public CreatePullPoint(ComponentContext context) {
+        this(context, "Broker");
     }
 
-    public CreatePullPoint(ComponentContext context, String brokerName) throws JAXBException {
-        setClient(createJaxbClient(context));
-        setEndpoint(createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName));
-        setResolver(resolveWSA(getEndpoint()));
-    }
-
-    public CreatePullPoint(JBIContainer container) throws JBIException, JAXBException {
-        setClient(createJaxbClient(container));
-        setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER));
-    }
-
-    public CreatePullPoint(JBIContainer container, String brokerName) throws JBIException, JAXBException {
-        setClient(createJaxbClient(container));
-        setEndpoint(createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName));
-        setResolver(resolveWSA(getEndpoint()));
-    }
-
-    public CreatePullPoint(ServiceMixClient client) {
-        setClient(client);
-        setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER));
-    }
-
-    public CreatePullPoint(ServiceMixClient client, String brokerName) {
-        setClient(client);
-        setEndpoint(createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName));
-        setResolver(resolveWSA(getEndpoint()));
+    public CreatePullPoint(ComponentContext context, String brokerName) {
+        super(context, createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName));
     }
 
     public PullPoint createPullPoint() throws JBIException {
         CreatePullPointResponse response = (CreatePullPointResponse) request(
                 new org.oasis_open.docs.wsn.b_2.CreatePullPoint());
-        return new PullPoint(response.getPullPoint(), getClient());
+        return new PullPoint(getContext(), response.getPullPoint());
     }
 
 }

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/NotificationBroker.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/NotificationBroker.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/NotificationBroker.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/NotificationBroker.java Thu Jul 24 15:19:58 2008
@@ -20,16 +20,10 @@
 
 import javax.jbi.JBIException;
 import javax.jbi.component.ComponentContext;
-import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
 
-import org.apache.servicemix.client.ServiceMixClient;
-import org.apache.servicemix.client.ServiceMixClientFacade;
-import org.apache.servicemix.jbi.container.JBIContainer;
-import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver;
 import org.apache.servicemix.wsn.AbstractSubscription;
 import org.oasis_open.docs.wsn.b_2.FilterType;
 import org.oasis_open.docs.wsn.b_2.GetCurrentMessage;
@@ -52,39 +46,16 @@
 
     public static final QName NOTIFICATION_BROKER = new QName(WSN_URI, WSN_SERVICE);
 
-    public NotificationBroker(ComponentContext context) throws JAXBException {
-        ServiceMixClientFacade client = new ServiceMixClientFacade(context);
-        client.setMarshaler(new JAXBMarshaler(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class)));
-        setClient(client);
-        setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER));
+    public NotificationBroker(ComponentContext context) {
+        this(context, "Broker");
     }
 
-    public NotificationBroker(ComponentContext context, String brokerName) throws JAXBException {
-        setClient(createJaxbClient(context));
-        setEndpoint(createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName));
-        setResolver(resolveWSA(getEndpoint()));
+    public NotificationBroker(ComponentContext context, String brokerName) {
+        this(context, createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName));
     }
 
-    public NotificationBroker(JBIContainer container) throws JBIException, JAXBException {
-        setClient(createJaxbClient(container));
-        setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER));
-    }
-
-    public NotificationBroker(JBIContainer container, String brokerName) throws JBIException, JAXBException {
-        setClient(createJaxbClient(container));
-        setEndpoint(createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName));
-        setResolver(resolveWSA(getEndpoint()));
-    }
-
-    public NotificationBroker(ServiceMixClient client) {
-        setClient(client);
-        setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER));
-    }
-
-    public NotificationBroker(ServiceMixClient client, String brokerName) {
-        setClient(client);
-        setEndpoint(createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName));
-        setResolver(resolveWSA(getEndpoint()));
+    public NotificationBroker(ComponentContext context, W3CEndpointReference endpoint) {
+        super(context, endpoint);
     }
 
     public void notify(String topic, Object msg) throws JBIException {
@@ -135,7 +106,7 @@
             subscribeRequest.getSubscriptionPolicy().getAny().add(new UseRaw());
         }
         SubscribeResponse response = (SubscribeResponse) request(subscribeRequest);
-        return new Subscription(response.getSubscriptionReference(), getClient());
+        return new Subscription(getContext(), response.getSubscriptionReference());
     }
 
     public List<Object> getCurrentMessage(String topic) throws JBIException {
@@ -161,7 +132,7 @@
         }
         registerPublisherRequest.setDemand(Boolean.valueOf(demand));
         RegisterPublisherResponse response = (RegisterPublisherResponse) request(registerPublisherRequest);
-        return new Publisher(response.getPublisherRegistrationReference(), getClient());
+        return new Publisher(getContext(), response.getPublisherRegistrationReference());
     }
 
 }

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/Publisher.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/Publisher.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/Publisher.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/Publisher.java Thu Jul 24 15:19:58 2008
@@ -17,15 +17,15 @@
 package org.apache.servicemix.wsn.client;
 
 import javax.jbi.JBIException;
+import javax.jbi.component.ComponentContext;
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
 
-import org.apache.servicemix.client.ServiceMixClient;
 import org.oasis_open.docs.wsn.br_2.DestroyRegistration;
 
 public class Publisher extends AbstractWSAClient {
 
-    public Publisher(W3CEndpointReference publisherRegistrationReference, ServiceMixClient client) {
-        super(publisherRegistrationReference, client);
+    public Publisher(ComponentContext context, W3CEndpointReference publisherRegistrationReference) {
+        super(context, publisherRegistrationReference);
     }
 
     public void destroy() throws JBIException {

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/PullPoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/PullPoint.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/PullPoint.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/PullPoint.java Thu Jul 24 15:19:58 2008
@@ -20,11 +20,9 @@
 import java.util.List;
 
 import javax.jbi.JBIException;
-import javax.xml.bind.JAXBException;
+import javax.jbi.component.ComponentContext;
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
 
-import org.apache.servicemix.client.ServiceMixClient;
-import org.apache.servicemix.jbi.container.JBIContainer;
 import org.oasis_open.docs.wsn.b_2.DestroyPullPoint;
 import org.oasis_open.docs.wsn.b_2.GetMessages;
 import org.oasis_open.docs.wsn.b_2.GetMessagesResponse;
@@ -32,12 +30,8 @@
 
 public class PullPoint extends AbstractWSAClient {
 
-    public PullPoint(W3CEndpointReference pullPoint, ServiceMixClient client) {
-        super(pullPoint, client);
-    }
-
-    public PullPoint(W3CEndpointReference pullPoint, JBIContainer container) throws JBIException, JAXBException {
-        super(pullPoint, createJaxbClient(container));
+    public PullPoint(ComponentContext context, W3CEndpointReference pullPoint) {
+        super(context, pullPoint);
     }
 
     public List<NotificationMessageHolderType> getMessages(int max) throws JBIException {

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/Subscription.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/Subscription.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/Subscription.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/client/Subscription.java Thu Jul 24 15:19:58 2008
@@ -17,17 +17,17 @@
 package org.apache.servicemix.wsn.client;
 
 import javax.jbi.JBIException;
+import javax.jbi.component.ComponentContext;
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
 
-import org.apache.servicemix.client.ServiceMixClient;
 import org.oasis_open.docs.wsn.b_2.PauseSubscription;
 import org.oasis_open.docs.wsn.b_2.ResumeSubscription;
 import org.oasis_open.docs.wsn.b_2.Unsubscribe;
 
 public class Subscription extends AbstractWSAClient {
 
-    public Subscription(W3CEndpointReference subscriptionReference, ServiceMixClient client) {
-        super(subscriptionReference, client);
+    public Subscription(ComponentContext context, W3CEndpointReference subscriptionReference) {
+        super(context, subscriptionReference);
     }
 
     public void pause() throws JBIException {

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNComponent.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNComponent.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNComponent.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNComponent.java Thu Jul 24 15:19:58 2008
@@ -31,6 +31,7 @@
 import javax.wsdl.Definition;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.xml.WSDLLocator;
 import javax.xml.namespace.QName;
 
 import org.w3c.dom.Document;
@@ -49,6 +50,7 @@
 import org.apache.servicemix.wsn.jbi.JbiNotificationBroker;
 import org.apache.servicemix.wsn.jms.JmsCreatePullPoint;
 import org.springframework.core.io.Resource;
+import org.xml.sax.InputSource;
 
 public class WSNComponent extends DefaultComponent {
 
@@ -111,9 +113,7 @@
     protected Class[] getEndpointClasses() {
         return new Class[] {
             WSNEndpoint.class,
-            WSNDeployer.WSNPublisherEndpoint.class,
-            WSNDeployer.WSNPullPointEndpoint.class,
-            WSNDeployer.WSNSubscriptionEndpoint.class,
+            WSNDeployableEndpoint.class,
         };
     }
 
@@ -226,10 +226,30 @@
             Document doc = descriptions.get(interfaceName);
             if (doc == null) {
                 if (flattener == null) {
-                    URL resource = getClass().getClassLoader().getResource("org/apache/servicemix/wsn/wsn.wsdl");
+                    final URL resource = getClass().getClassLoader().getResource("org/apache/servicemix/wsn/wsn.wsdl");
                     WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
                     reader.setFeature(Constants.FEATURE_VERBOSE, false);
-                    Definition definition = reader.readWSDL(null, resource.toString());
+                    // Do not let wsdl4j read imports, as it uses the URL getContent() which fails because wsdl
+                    // is not a known extension in OSGi
+                    Definition definition = reader.readWSDL(new WSDLLocator() {
+                        private String last = null;
+                        public InputSource getBaseInputSource() {
+                            return new InputSource(resource.toString());
+                        }
+                        public InputSource getImportInputSource(String parentLocation, String importLocation) {
+                            int idx = parentLocation.lastIndexOf('/');
+                            last = parentLocation.substring(0, idx + 1) + importLocation;
+                            return new InputSource(last);
+                        }
+                        public String getBaseURI() {
+                            return resource.toString();
+                        }
+                        public String getLatestImportURI() {
+                            return last;
+                        }
+                        public void close() {
+                        }
+                    });
                     flattener = new WSDLFlattener(definition);
                 }
                 Definition flatDef = flattener.getDefinition(interfaceName);

Added: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNDeployableEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNDeployableEndpoint.java?rev=679580&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNDeployableEndpoint.java (added)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNDeployableEndpoint.java Thu Jul 24 15:19:58 2008
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.wsn.component;
+
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.wsn.EndpointManager;
+import org.apache.servicemix.wsn.EndpointRegistrationException;
+import org.apache.servicemix.wsn.jms.JmsCreatePullPoint;
+import org.apache.servicemix.wsn.jbi.JbiNotificationBroker;
+
+public abstract class WSNDeployableEndpoint extends Endpoint implements EndpointManager {
+
+    public JbiNotificationBroker getNotificationBroker() {
+        return ((WSNComponent) serviceUnit.getComponent()).getNotificationBroker();
+    }
+
+    public JmsCreatePullPoint getCreatePullPoint() {
+        return ((WSNComponent) serviceUnit.getComponent()).getCreatePullPoint();
+    }
+
+    @Override
+    public ExchangeProcessor getProcessor() {
+        return null;
+    }
+
+    public Object register(String address, Object service) throws EndpointRegistrationException {
+        return null;
+    }
+
+    public void unregister(Object endpoint) throws EndpointRegistrationException {
+    }
+
+}

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNDeployer.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNDeployer.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNDeployer.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNDeployer.java Thu Jul 24 15:19:58 2008
@@ -20,35 +20,19 @@
 import java.io.FilenameFilter;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
 
 import javax.jbi.management.DeploymentException;
-import javax.jbi.management.LifeCycleMBean;
-import javax.jbi.messaging.MessageExchange.Role;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
-import javax.xml.namespace.QName;
 
 import org.apache.servicemix.common.AbstractDeployer;
 import org.apache.servicemix.common.Deployer;
 import org.apache.servicemix.common.Endpoint;
-import org.apache.servicemix.common.ExchangeProcessor;
 import org.apache.servicemix.common.ServiceMixComponent;
 import org.apache.servicemix.common.ServiceUnit;
-import org.apache.servicemix.id.IdGenerator;
-import org.apache.servicemix.wsn.EndpointManager;
-import org.apache.servicemix.wsn.EndpointRegistrationException;
-import org.apache.servicemix.wsn.client.AbstractWSAClient;
-import org.apache.servicemix.wsn.jbi.JbiNotificationBroker;
-import org.apache.servicemix.wsn.jms.JmsCreatePullPoint;
 import org.oasis_open.docs.wsn.b_2.CreatePullPoint;
-import org.oasis_open.docs.wsn.b_2.CreatePullPointResponse;
 import org.oasis_open.docs.wsn.b_2.Subscribe;
-import org.oasis_open.docs.wsn.b_2.SubscribeResponse;
 import org.oasis_open.docs.wsn.br_2.RegisterPublisher;
-import org.oasis_open.docs.wsn.br_2.RegisterPublisherResponse;
 import org.oasis_open.docs.wsn.brw_2.NotificationBroker;
 
 public class WSNDeployer extends AbstractDeployer implements Deployer {
@@ -75,7 +59,7 @@
     public ServiceUnit deploy(String serviceUnitName, String serviceUnitRootPath) throws DeploymentException {
         File[] xmls = new File(serviceUnitRootPath).listFiles(filter);
         if (xmls == null || xmls.length == 0) {
-            throw failure("deploy", "No wsdl found", null);
+            throw failure("deploy", "No xml files found", null);
         }
         WSNServiceUnit su = new WSNServiceUnit();
         su.setComponent(component);
@@ -123,174 +107,6 @@
         }
     }
 
-    public class WSNSubscriptionEndpoint extends Endpoint implements EndpointManager {
-
-        private Subscribe request;
-
-        private SubscribeResponse response;
-
-        public WSNSubscriptionEndpoint(Subscribe request) throws DeploymentException {
-            this.service = new QName("http://servicemix.org/wsnotification", "Subscription");
-            this.endpoint = new IdGenerator().generateSanitizedId();
-            this.request = request;
-        }
-
-        @Override
-        public Role getRole() {
-            return Role.CONSUMER;
-        }
-
-        @Override
-        public void activate() throws Exception {
-            JbiNotificationBroker broker = ((WSNComponent) serviceUnit.getComponent())
-                    .getNotificationBroker();
-            response = broker.handleSubscribe(request, this);
-        }
-
-        @Override
-        public void deactivate() throws Exception {
-            JbiNotificationBroker broker = ((WSNComponent) serviceUnit.getComponent())
-                    .getNotificationBroker();
-            broker.unsubscribe(AbstractWSAClient.getWSAAddress(response.getSubscriptionReference()));
-        }
-
-        @Override
-        public ExchangeProcessor getProcessor() {
-            return null;
-        }
-
-        public Object register(String address, Object service) throws EndpointRegistrationException {
-            return null;
-        }
-
-        public void unregister(Object endpoint) throws EndpointRegistrationException {
-        }
-
-    }
-
-    public class WSNPullPointEndpoint extends Endpoint implements EndpointManager {
-
-        private CreatePullPoint request;
-
-        private CreatePullPointResponse response;
-
-        public WSNPullPointEndpoint(CreatePullPoint request) throws DeploymentException {
-            this.service = new QName("http://servicemix.org/wsnotification", "Subscription");
-            this.endpoint = new IdGenerator().generateSanitizedId();
-            this.request = request;
-        }
-
-        @Override
-        public Role getRole() {
-            return Role.PROVIDER;
-        }
-
-        @Override
-        public void activate() throws Exception {
-            JmsCreatePullPoint createPullPoint = ((WSNComponent) serviceUnit.getComponent())
-                    .getCreatePullPoint();
-            response = createPullPoint.createPullPoint(request);
-        }
-
-        @Override
-        public void deactivate() throws Exception {
-            JmsCreatePullPoint createPullPoint = ((WSNComponent) serviceUnit.getComponent())
-                    .getCreatePullPoint();
-            createPullPoint.destroyPullPoint(AbstractWSAClient.getWSAAddress(response.getPullPoint()));
-        }
-
-        @Override
-        public ExchangeProcessor getProcessor() {
-            return null;
-        }
-
-        public Object register(String address, Object service) throws EndpointRegistrationException {
-            return null;
-        }
-
-        public void unregister(Object endpoint) throws EndpointRegistrationException {
-        }
-
-    }
-
-    public static class WSNPublisherEndpoint extends Endpoint implements EndpointManager {
-
-        private RegisterPublisher request;
-
-        private RegisterPublisherResponse response;
-
-        public WSNPublisherEndpoint(RegisterPublisher request) {
-            this.service = new QName("http://servicemix.org/wsnotification", "Publisher");
-            this.endpoint = new IdGenerator().generateSanitizedId();
-            this.request = request;
-        }
-
-        @Override
-        public Role getRole() {
-            return Role.CONSUMER;
-        }
-
-        @Override
-        public void activate() throws Exception {
-            JbiNotificationBroker broker = ((WSNComponent) serviceUnit.getComponent())
-                    .getNotificationBroker();
-            response = broker.handleRegisterPublisher(request, this);
-        }
-
-        @Override
-        public void deactivate() throws Exception {
-            JbiNotificationBroker broker = ((WSNComponent) serviceUnit.getComponent())
-                    .getNotificationBroker();
-            broker.unsubscribe(AbstractWSAClient.getWSAAddress(response.getPublisherRegistrationReference()));
-        }
-
-        @Override
-        public ExchangeProcessor getProcessor() {
-            return null;
-        }
-
-        public Object register(String address, Object service) throws EndpointRegistrationException {
-            return null;
-        }
-
-        public void unregister(Object endpoint) throws EndpointRegistrationException {
-        }
-
-    }
-
-    public static class WSNServiceUnit extends ServiceUnit {
-        public void start() throws Exception {
-            List<Endpoint> activated = new ArrayList<Endpoint>();
-            try {
-                for (Iterator iter = getEndpoints().iterator(); iter.hasNext();) {
-                    Endpoint endpoint = (Endpoint) iter.next();
-                    if (endpoint instanceof WSNPullPointEndpoint) {
-                        endpoint.activate();
-                        activated.add(endpoint);
-                    }
-                }
-                for (Iterator iter = getEndpoints().iterator(); iter.hasNext();) {
-                    Endpoint endpoint = (Endpoint) iter.next();
-                    if (endpoint instanceof WSNSubscriptionEndpoint) {
-                        endpoint.activate();
-                        activated.add(endpoint);
-                    }
-                }
-                this.status = LifeCycleMBean.STARTED;
-            } catch (Exception e) {
-                // Deactivate activated endpoints
-                for (Endpoint endpoint : activated) {
-                    try {
-                        endpoint.deactivate();
-                    } catch (Exception e2) {
-                        // do nothing
-                    }
-                }
-                throw e;
-            }
-        }
-    }
-
     public static class XmlFilter implements FilenameFilter {
 
         public boolean accept(File dir, String name) {

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNEndpoint.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNEndpoint.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNEndpoint.java Thu Jul 24 15:19:58 2008
@@ -39,8 +39,8 @@
 
 import org.apache.servicemix.common.ExchangeProcessor;
 import org.apache.servicemix.common.endpoints.ProviderEndpoint;
+import org.apache.servicemix.common.util.URIResolver;
 import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.apache.servicemix.jbi.resolver.URIResolver;
 import org.apache.servicemix.wsn.ComponentContextAware;
 import org.oasis_open.docs.wsrf.bf_2.BaseFaultType;
 
@@ -121,8 +121,7 @@
             if (e.getCause() instanceof Exception) {
                 WebFault fa = (WebFault) e.getCause().getClass().getAnnotation(WebFault.class);
                 if (!(exchange instanceof InOnly) && fa != null) {
-                    BaseFaultType info = (BaseFaultType) e.getCause().getClass().getMethod("getFaultInfo").invoke(
-                            e.getCause());
+                    BaseFaultType info = (BaseFaultType) e.getCause().getClass().getMethod("getFaultInfo").invoke(e.getCause());
                     Fault fault = exchange.createFault();
                     exchange.setFault(fault);
                     exchange.setError((Exception) e.getCause());
@@ -149,7 +148,7 @@
             StringWriter writer = new StringWriter();
             jaxbContext.createMarshaller().marshal(output, writer);
             msg.setContent(new StringSource(writer.toString()));
-            send(exchange);
+            sendSync(exchange);
         }
     }
 

Added: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNPublisherEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNPublisherEndpoint.java?rev=679580&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNPublisherEndpoint.java (added)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNPublisherEndpoint.java Thu Jul 24 15:19:58 2008
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.wsn.component;
+
+import javax.xml.namespace.QName;
+import javax.jbi.messaging.MessageExchange;
+
+import org.oasis_open.docs.wsn.br_2.RegisterPublisher;
+import org.oasis_open.docs.wsn.br_2.RegisterPublisherResponse;
+import org.apache.servicemix.id.IdGenerator;
+import org.apache.servicemix.wsn.client.AbstractWSAClient;
+
+public class WSNPublisherEndpoint extends WSNDeployableEndpoint {
+
+    private RegisterPublisher request;
+
+    private RegisterPublisherResponse response;
+
+    public WSNPublisherEndpoint(RegisterPublisher request) {
+        this(request, null, null);
+    }
+
+    public WSNPublisherEndpoint(RegisterPublisher request, QName service, String endpoint) {
+        this.request = request;
+        if (service != null) {
+            this.service = service;
+        } else {
+            this.service = new QName("http://servicemix.org/wsnotification", "Publisher");
+        }
+        if (endpoint != null) {
+            this.endpoint = endpoint;
+        } else {
+            this.endpoint = new IdGenerator().generateSanitizedId();
+        }
+    }
+
+    @Override
+    public MessageExchange.Role getRole() {
+        return MessageExchange.Role.CONSUMER;
+    }
+
+    @Override
+    public void activate() throws Exception {
+        response = getNotificationBroker().handleRegisterPublisher(request, this);
+    }
+
+    @Override
+    public void deactivate() throws Exception {
+        getNotificationBroker().unsubscribe(AbstractWSAClient.getWSAAddress(response.getPublisherRegistrationReference()));
+    }
+
+}

Added: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNPullPointEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNPullPointEndpoint.java?rev=679580&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNPullPointEndpoint.java (added)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNPullPointEndpoint.java Thu Jul 24 15:19:58 2008
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.wsn.component;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.MessageExchange;
+import javax.xml.namespace.QName;
+
+import org.oasis_open.docs.wsn.b_2.CreatePullPoint;
+import org.oasis_open.docs.wsn.b_2.CreatePullPointResponse;
+import org.apache.servicemix.id.IdGenerator;
+import org.apache.servicemix.wsn.client.AbstractWSAClient;
+
+public class WSNPullPointEndpoint extends WSNDeployableEndpoint {
+
+    private CreatePullPoint request;
+
+    private CreatePullPointResponse response;
+
+    public WSNPullPointEndpoint(CreatePullPoint request) throws DeploymentException {
+        this(request, null, null);
+    }
+
+    public WSNPullPointEndpoint(CreatePullPoint request, QName service, String endpoint) {
+        this.request = request;
+        if (service != null) {
+            this.service = service;
+        } else {
+            this.service = new QName("http://servicemix.org/wsnotification", "PullPoint");
+        }
+        if (endpoint != null) {
+            this.endpoint = endpoint;
+        } else {
+            this.endpoint = new IdGenerator().generateSanitizedId();
+        }
+    }
+
+    @Override
+    public MessageExchange.Role getRole() {
+        return MessageExchange.Role.PROVIDER;
+    }
+
+    @Override
+    public void activate() throws Exception {
+        response = getCreatePullPoint().createPullPoint(request);
+    }
+
+    @Override
+    public void deactivate() throws Exception {
+        getCreatePullPoint().destroyPullPoint(AbstractWSAClient.getWSAAddress(response.getPullPoint()));
+    }
+
+}

Added: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNServiceUnit.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNServiceUnit.java?rev=679580&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNServiceUnit.java (added)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNServiceUnit.java Thu Jul 24 15:19:58 2008
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.wsn.component;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.jbi.management.LifeCycleMBean;
+
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.common.Endpoint;
+
+public class WSNServiceUnit extends ServiceUnit {
+
+    public void start() throws Exception {
+        List<Endpoint> activated = new ArrayList<Endpoint>();
+        try {
+            for (Iterator iter = getEndpoints().iterator(); iter.hasNext();) {
+                Endpoint endpoint = (Endpoint) iter.next();
+                if (endpoint instanceof WSNPullPointEndpoint) {
+                    endpoint.activate();
+                    activated.add(endpoint);
+                }
+            }
+            for (Iterator iter = getEndpoints().iterator(); iter.hasNext();) {
+                Endpoint endpoint = (Endpoint) iter.next();
+                if (endpoint instanceof WSNSubscriptionEndpoint) {
+                    endpoint.activate();
+                    activated.add(endpoint);
+                }
+            }
+            for (Iterator iter = getEndpoints().iterator(); iter.hasNext();) {
+                Endpoint endpoint = (Endpoint) iter.next();
+                if (endpoint instanceof WSNPublisherEndpoint) {
+                    endpoint.activate();
+                    activated.add(endpoint);
+                }
+            }
+            this.status = LifeCycleMBean.STARTED;
+        } catch (Exception e) {
+            // Deactivate activated endpoints
+            for (Endpoint endpoint : activated) {
+                try {
+                    endpoint.deactivate();
+                } catch (Exception e2) {
+                    // do nothing
+                }
+            }
+            throw e;
+        }
+    }
+
+}

Added: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNSubscriptionEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNSubscriptionEndpoint.java?rev=679580&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNSubscriptionEndpoint.java (added)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/component/WSNSubscriptionEndpoint.java Thu Jul 24 15:19:58 2008
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.wsn.component;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.MessageExchange;
+import javax.xml.namespace.QName;
+
+import org.oasis_open.docs.wsn.b_2.Subscribe;
+import org.oasis_open.docs.wsn.b_2.SubscribeResponse;
+import org.apache.servicemix.id.IdGenerator;
+import org.apache.servicemix.wsn.client.AbstractWSAClient;
+
+public class WSNSubscriptionEndpoint extends WSNDeployableEndpoint {
+
+    private Subscribe request;
+
+    private SubscribeResponse response;
+
+    public WSNSubscriptionEndpoint(Subscribe request) throws DeploymentException {
+        this(request, null, null);
+    }
+
+    public WSNSubscriptionEndpoint(Subscribe request, QName service, String endpoint) {
+        this.request = request;
+        if (service != null) {
+            this.service = service;
+        } else {
+            this.service = new QName("http://servicemix.org/wsnotification", "Subscription");
+        }
+        if (endpoint != null) {
+            this.endpoint = endpoint;
+        } else {
+            this.endpoint = new IdGenerator().generateSanitizedId();
+        }
+    }
+
+    @Override
+    public MessageExchange.Role getRole() {
+        return MessageExchange.Role.CONSUMER;
+    }
+
+    @Override
+    public void activate() throws Exception {
+        response = getNotificationBroker().handleSubscribe(request, this);
+    }
+
+    @Override
+    public void deactivate() throws Exception {
+        getNotificationBroker().unsubscribe(AbstractWSAClient.getWSAAddress(response.getSubscriptionReference()));
+    }
+
+}

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/jbi/JbiPublisher.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/jbi/JbiPublisher.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/jbi/JbiPublisher.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/jbi/JbiPublisher.java Thu Jul 24 15:19:58 2008
@@ -19,7 +19,6 @@
 import javax.jbi.JBIException;
 import javax.jbi.component.ComponentContext;
 import javax.jbi.servicedesc.ServiceEndpoint;
-import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
 
 import org.apache.servicemix.wsn.ComponentContextAware;
@@ -59,15 +58,11 @@
     protected Object startSubscription() {
         Subscription subscription = null;
         try {
-            NotificationBroker broker = new NotificationBroker(getContext());
-            broker.setResolver(AbstractWSAClient.resolveWSA(publisherReference));
+            NotificationBroker broker = new NotificationBroker(getContext(), publisherReference);
             subscription = broker.subscribe(AbstractWSAClient.createWSA(notificationBrokerAddress), "noTopic", null);
         } catch (JBIException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
-        } catch (JAXBException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
         }
         return subscription;
     }

Added: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/spring/WSNDeployableEndpointFactoryBean.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/spring/WSNDeployableEndpointFactoryBean.java?rev=679580&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/spring/WSNDeployableEndpointFactoryBean.java (added)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/java/org/apache/servicemix/wsn/spring/WSNDeployableEndpointFactoryBean.java Thu Jul 24 15:19:58 2008
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.wsn.spring;
+
+import java.io.InputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.namespace.QName;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.Resource;
+import org.apache.servicemix.wsn.component.WSNDeployableEndpoint;
+import org.apache.servicemix.wsn.component.WSNEndpoint;
+import org.apache.servicemix.wsn.component.WSNSubscriptionEndpoint;
+import org.apache.servicemix.wsn.component.WSNPullPointEndpoint;
+import org.apache.servicemix.wsn.component.WSNPublisherEndpoint;
+import org.oasis_open.docs.wsn.brw_2.NotificationBroker;
+import org.oasis_open.docs.wsn.b_2.Subscribe;
+import org.oasis_open.docs.wsn.b_2.CreatePullPoint;
+import org.oasis_open.docs.wsn.br_2.RegisterPublisher;
+
+/**
+ * @org.apache.xbean.XBean element="endpoint"
+ */
+public class WSNDeployableEndpointFactoryBean implements FactoryBean, InitializingBean {
+
+    private QName service;
+    private String endpoint;
+    private Resource resource;
+    private Object request;
+
+    public QName getService() {
+        return service;
+    }
+
+    public void setService(QName service) {
+        this.service = service;
+    }
+
+    public String getEndpoint() {
+        return endpoint;
+    }
+
+    public void setEndpoint(String endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    public Resource getResource() {
+        return resource;
+    }
+
+    public void setResource(Resource resource) {
+        this.resource = resource;
+    }
+
+    public Object getRequest() {
+        return request;
+    }
+
+    public void setRequest(Object request) {
+        this.request = request;
+    }
+
+    public void afterPropertiesSet() throws Exception {
+        if (request == null && resource == null) {
+            throw new IllegalStateException("One of request or resource properties must be set");
+        }
+    }
+
+    public Object getObject() throws Exception {
+        if (request == null && resource != null) {
+            JAXBContext context = WSNEndpoint.createJAXBContext(NotificationBroker.class);
+            InputStream is = resource.getInputStream();
+            try {
+                request = context.createUnmarshaller().unmarshal(is);
+            } finally {
+                is.close();
+            }
+        }
+        if (request instanceof Subscribe) {
+            return new WSNSubscriptionEndpoint((Subscribe) request, service, endpoint);
+        } else if (request instanceof CreatePullPoint) {
+            return new WSNPullPointEndpoint((CreatePullPoint) request, service, endpoint);
+        } else if (request instanceof RegisterPublisher) {
+            return new WSNPublisherEndpoint((RegisterPublisher) request, service, endpoint);
+        } else {
+            throw new IllegalStateException("Unrecognized request of type " + request.getClass());
+        }
+    }
+
+    public Class getObjectType() {
+        return WSNDeployableEndpoint.class;
+    }
+
+    public boolean isSingleton() {
+        return false;
+    }
+}

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/main/resources/META-INF/spring/servicemix-wsn2005.xml
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/main/resources/META-INF/spring/servicemix-wsn2005.xml?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/main/resources/META-INF/spring/servicemix-wsn2005.xml (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/main/resources/META-INF/spring/servicemix-wsn2005.xml Thu Jul 24 15:19:58 2008
@@ -20,6 +20,7 @@
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
        xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="
   http://www.springframework.org/schema/beans
@@ -27,10 +28,23 @@
   http://www.springframework.org/schema/util
   http://www.springframework.org/schema/util/spring-util.xsd
   http://www.springframework.org/schema/osgi
-  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+  http://www.springframework.org/schema/osgi/spring-osgi.xsd
+  http://www.springframework.org/schema/osgi-compendium
+  http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">
 
     <bean id="servicemix-wsn2005" class="org.apache.servicemix.wsn.component.WSNComponent">
         <property name="connectionFactory" ref="connectionFactory" />
+        <property name="executorFactory" ref="executorFactory" />
+    </bean>
+
+    <bean id="executorFactory" class="org.apache.servicemix.executors.impl.ExecutorFactoryImpl">
+        <property name="defaultConfig">
+            <bean class="org.apache.servicemix.executors.impl.ExecutorConfig">
+                <property name="corePoolSize" value="${threadPoolCorePoolSize}"/>
+                <property name="maximumPoolSize" value="${threadPoolMaximumPoolSize}"/>
+                <property name="queueSize" value="${threadPoolQueueSize}"/>
+            </bean>
+        </property>
     </bean>
 
     <bean id="endpoint-tracker" class="org.apache.servicemix.common.osgi.EndpointTracker">
@@ -52,4 +66,12 @@
 
     <osgi:reference id="connectionFactory" interface="javax.jms.ConnectionFactory" />
 
+    <osgix:property-placeholder persistent-id="servicemix-wsn2005">
+        <osgix:default-properties>
+            <prop key="threadPoolCorePoolSize">8</prop>
+            <prop key="threadPoolMaximumPoolSize">32</prop>
+            <prop key="threadPoolQueueSize">256</prop>
+        </osgix:default-properties>
+    </osgix:property-placeholder>
+
 </beans>

Modified: servicemix/components/engines/servicemix-wsn2005/trunk/src/test/java/org/apache/servicemix/wsn/component/WSNComponentTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-wsn2005/trunk/src/test/java/org/apache/servicemix/wsn/component/WSNComponentTest.java?rev=679580&r1=679579&r2=679580&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-wsn2005/trunk/src/test/java/org/apache/servicemix/wsn/component/WSNComponentTest.java (original)
+++ servicemix/components/engines/servicemix-wsn2005/trunk/src/test/java/org/apache/servicemix/wsn/component/WSNComponentTest.java Thu Jul 24 15:19:58 2008
@@ -49,6 +49,8 @@
 import org.apache.servicemix.wsn.client.PullPoint;
 import org.apache.servicemix.wsn.client.Subscription;
 import org.apache.servicemix.wsn.spring.PublisherComponent;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.client.DefaultServiceMixClient;
 import org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType;
 import org.oasis_open.docs.wsn.b_2.Notify;
 
@@ -58,6 +60,7 @@
         new QName("http://servicemix.org/wsnotification", "NotificationBroker");
 
     private JBIContainer jbi;
+    private ServiceMixClient client;
     private BrokerService jmsBroker;
     private NotificationBroker wsnBroker;
     private CreatePullPoint wsnCreatePullPoint;
@@ -66,23 +69,26 @@
     protected void setUp() throws Exception {
         jmsBroker = new BrokerService();
         jmsBroker.setPersistent(false);
-        jmsBroker.addConnector("vm://localhost");
+        jmsBroker.addConnector("tcp://localhost:61616");
         jmsBroker.start();
 
         jbi = new JBIContainer();
         jbi.setEmbedded(true);
+        jbi.setCreateJmxConnector(false);
         jbi.init();
         jbi.start();
 
+        client = new DefaultServiceMixClient(jbi);
+
         wsnComponent = new WSNComponent();
-        wsnComponent.setConnectionFactory(new ActiveMQConnectionFactory("vm://localhost"));
+        wsnComponent.setConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61616"));
         ActivationSpec as = new ActivationSpec();
         as.setComponentName("servicemix-wsn2005");
         as.setComponent(wsnComponent);
         jbi.activateComponent(as);
 
-        wsnBroker = new NotificationBroker(jbi);
-        wsnCreatePullPoint = new CreatePullPoint(jbi);
+        wsnBroker = new NotificationBroker(client.getContext());
+        wsnCreatePullPoint = new CreatePullPoint(client.getContext());
     }
 
     protected void tearDown() throws Exception {
@@ -287,8 +293,8 @@
 
         wsnBroker.notify("myTopic", parse("<hello>world</hello>"));
         PullPoint pullPoint = new PullPoint(
-                        AbstractWSAClient.createWSA("http://www.consumer.org/service/endpoint"),
-                        jbi);
+                        client.getContext(),
+                        AbstractWSAClient.createWSA("http://www.consumer.org/service/endpoint"));
         Thread.sleep(500);
         assertEquals(1, pullPoint.getMessages(0).size());
     }



Mime
View raw message