KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > cxf > CXFWebServiceContainer


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.geronimo.cxf;
18
19 import org.apache.cxf.Bus;
20 import org.apache.cxf.binding.xml.XMLConstants;
21 import org.apache.cxf.jaxws.EndpointImpl;
22 import org.apache.cxf.transport.DestinationFactory;
23 import org.apache.cxf.transport.DestinationFactoryManager;
24 import org.apache.geronimo.webservices.WebServiceContainer;
25
26 //TODO consider putting most of this in the CXFWebServiceContaInerFactoryGBean
27
public class CXFWebServiceContainer implements WebServiceContainer {
28
29     private final GeronimoDestination destination;
30     private final Bus bus;
31
32
33     public CXFWebServiceContainer(PortInfo portInfo, Object JavaDoc target, Bus bus) {
34         //TODO actually use portInfo
35
this.bus = bus;
36         DestinationFactoryManager destinationFactoryManager = bus.getExtension(DestinationFactoryManager.class);
37         DestinationFactory factory = new GeronimoDestinationFactory(bus);
38         destinationFactoryManager.registerDestinationFactory("http://cxf.apache.org/transports/http/configuration", factory);
39         destinationFactoryManager.registerDestinationFactory("http://www.w3.org/2003/05/soap/bindings/HTTP/", factory);
40         destinationFactoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", factory);
41         destinationFactoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/http/", factory);
42         destinationFactoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", factory);
43         destinationFactoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", factory);
44         destinationFactoryManager.registerDestinationFactory(XMLConstants.NS_XML_FORMAT, factory);
45         EndpointImpl publishedEndpoint = publishEndpoint(target);
46         destination = (GeronimoDestination) publishedEndpoint.getServer().getDestination();
47     }
48
49     public void invoke(Request request, Response response) throws Exception JavaDoc {
50
51             destination.invoke(request, response);
52     }
53
54
55     public void getWsdl(Request request, Response response) throws Exception JavaDoc {
56     }
57
58     private EndpointImpl publishEndpoint(Object JavaDoc target) {
59
60         assert target != null : "null target received";
61
62         EndpointImpl ep = new EndpointImpl(bus, target, (String JavaDoc)null);
63         ep.publish("http://nopath");
64         return ep;
65
66     }
67
68 }
69
Popular Tags