KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > wsn > client > CreatePullPoint


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

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 JavaDoc;
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 JavaDoc WSN_URI = "http://servicemix.org/wsnotification";
36     public static String JavaDoc WSN_SERVICE = "CreatePullPoint";
37     
38     public static QName JavaDoc NOTIFICATION_BROKER = new QName JavaDoc(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 JavaDoc 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 JavaDoc 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 JavaDoc 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