1 17 package org.apache.servicemix.wsn.client; 18 19 import javax.jbi.JBIException; 20 import javax.jbi.component.ComponentContext; 21 import javax.xml.bind.JAXBContext; 22 import javax.xml.bind.JAXBException; 23 import javax.xml.namespace.QName ; 24 25 import org.apache.servicemix.client.ServiceMixClient; 26 import org.apache.servicemix.client.ServiceMixClientFacade; 27 import org.apache.servicemix.jbi.container.JBIContainer; 28 import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver; 29 import org.oasis_open.docs.wsn.b_2.CreatePullPointResponse; 30 import org.oasis_open.docs.wsn.b_2.Subscribe; 31 import org.oasis_open.docs.wsn.br_2.RegisterPublisher; 32 33 public class CreatePullPoint extends AbstractWSAClient { 34 35 public static String WSN_URI = "http://servicemix.org/wsnotification"; 36 public static String WSN_SERVICE = "CreatePullPoint"; 37 38 public static QName NOTIFICATION_BROKER = new QName (WSN_URI, WSN_SERVICE); 39 40 public CreatePullPoint(ComponentContext context) throws JAXBException { 41 ServiceMixClientFacade client = new ServiceMixClientFacade(context); 42 client.setMarshaler(new JAXBMarshaler(JAXBContext.newInstance(Subscribe.class, RegisterPublisher.class))); 43 setClient(client); 44 setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER)); 45 } 46 47 public CreatePullPoint(ComponentContext context, String brokerName) throws JAXBException { 48 setClient(createJaxbClient(context)); 49 setEndpoint(createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName)); 50 setResolver(resolveWSA(getEndpoint())); 51 } 52 53 public CreatePullPoint(JBIContainer container) throws JBIException, JAXBException { 54 setClient(createJaxbClient(container)); 55 setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER)); 56 } 57 58 public CreatePullPoint(JBIContainer container, String brokerName) throws JBIException, JAXBException { 59 setClient(createJaxbClient(container)); 60 setEndpoint(createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName)); 61 setResolver(resolveWSA(getEndpoint())); 62 } 63 64 public CreatePullPoint(ServiceMixClient client) { 65 setClient(client); 66 setResolver(new ServiceNameEndpointResolver(NOTIFICATION_BROKER)); 67 } 68 69 public CreatePullPoint(ServiceMixClient client, String brokerName) { 70 setClient(client); 71 setEndpoint(createWSA(WSN_URI + "/" + WSN_SERVICE + "/" + brokerName)); 72 setResolver(resolveWSA(getEndpoint())); 73 } 74 75 public PullPoint createPullPoint() throws JBIException { 76 CreatePullPointResponse response = (CreatePullPointResponse) request(new org.oasis_open.docs.wsn.b_2.CreatePullPoint()); 77 return new PullPoint(response.getPullPoint(), getClient()); 78 } 79 80 } 81 | Popular Tags |