01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.apache.openejb.server.cxf;
18:
19: import org.apache.cxf.Bus;
20: import org.apache.openejb.DeploymentInfo;
21: import org.apache.openejb.core.webservices.PortData;
22: import org.apache.openejb.server.cxf.ejb.EjbWsContainer;
23: import org.apache.openejb.server.cxf.pojo.PojoWsContainer;
24: import org.apache.openejb.server.cxf.client.SaajInterceptor;
25: import org.apache.openejb.server.httpd.HttpListener;
26: import org.apache.openejb.server.webservices.WsService;
27:
28: import javax.naming.Context;
29: import java.net.URL;
30: import java.util.Map;
31: import java.util.TreeMap;
32:
33: public class CxfService extends WsService {
34: private final Map<String, CxfWsContainer> wsContainers = new TreeMap<String, CxfWsContainer>();
35:
36: public CxfService() {
37: SaajInterceptor.registerInterceptors();
38: }
39:
40: public String getName() {
41: return "cxf";
42: }
43:
44: protected HttpListener createEjbWsContainer(URL moduleBaseUrl,
45: PortData port, DeploymentInfo deploymentInfo) {
46: Bus bus = CxfWsContainer.getBus();
47:
48: CxfCatalogUtils.loadOASISCatalog(bus, moduleBaseUrl,
49: "META-INF/jax-ws-catalog.xml");
50:
51: EjbWsContainer container = new EjbWsContainer(bus, port,
52: deploymentInfo);
53: container.start();
54: wsContainers.put(deploymentInfo.getDeploymentID().toString(),
55: container);
56: return container;
57: }
58:
59: protected void destroyEjbWsContainer(String deploymentId) {
60: CxfWsContainer container = wsContainers.remove(deploymentId);
61: if (container != null) {
62: container.destroy();
63: }
64: }
65:
66: protected HttpListener createPojoWsContainer(URL moduleBaseUrl,
67: PortData port, String serviceId, Class target,
68: Context context, String contextRoot) {
69: Bus bus = CxfWsContainer.getBus();
70:
71: CxfCatalogUtils.loadOASISCatalog(bus, moduleBaseUrl,
72: "META-INF/jax-ws-catalog.xml");
73:
74: PojoWsContainer container = new PojoWsContainer(bus, port,
75: context, target);
76: container.start();
77: wsContainers.put(serviceId, container);
78: return container;
79: }
80:
81: protected void destroyPojoWsContainer(String serviceId) {
82: CxfWsContainer container = wsContainers.remove(serviceId);
83: if (container != null) {
84: container.destroy();
85: }
86: }
87: }
|