001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.axis.server;
017:
018: import org.apache.axis.description.JavaServiceDesc;
019: import org.apache.axis.handlers.soap.SOAPService;
020: import org.apache.axis.providers.java.RPCProvider;
021: import org.apache.geronimo.gbean.GBeanInfo;
022: import org.apache.geronimo.gbean.GBeanInfoBuilder;
023: import org.apache.geronimo.gbean.GBeanLifecycle;
024: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
025: import org.apache.geronimo.openejb.EjbDeployment;
026: import org.apache.geronimo.webservices.SoapHandler;
027: import org.apache.openejb.server.axis.EjbContainerProvider;
028:
029: import java.net.URI;
030:
031: public class EjbWebServiceGBean implements GBeanLifecycle {
032:
033: private final SoapHandler soapHandler;
034: private final URI location;
035:
036: protected EjbWebServiceGBean() {
037: soapHandler = null;
038: location = null;
039: }
040:
041: public EjbWebServiceGBean(EjbDeployment ejbDeploymentContext,
042: URI location, URI wsdlURI, SoapHandler soapHandler,
043: ServiceInfo serviceInfo, String securityRealmName,
044: String realmName, String transportGuarantee,
045: String authMethod, String[] virtualHosts) throws Exception {
046:
047: this .soapHandler = soapHandler;
048: this .location = location;
049:
050: //for use as a template
051: if (ejbDeploymentContext == null) {
052: return;
053: }
054: RPCProvider provider = new EjbContainerProvider(
055: ejbDeploymentContext.getDeploymentInfo(), serviceInfo
056: .getHandlerInfos());
057: SOAPService service = new SOAPService(null, provider, null);
058:
059: JavaServiceDesc serviceDesc = serviceInfo.getServiceDesc();
060: service.setServiceDescription(serviceDesc);
061:
062: ClassLoader classLoader = ejbDeploymentContext.getClassLoader();
063:
064: Class serviceEndpointInterface = classLoader
065: .loadClass(ejbDeploymentContext
066: .getServiceEndpointInterfaceName());
067:
068: service.setOption("className", serviceEndpointInterface
069: .getName());
070: serviceDesc.setImplClass(serviceEndpointInterface);
071:
072: AxisWebServiceContainer axisContainer = new AxisWebServiceContainer(
073: location, wsdlURI, service, serviceInfo.getWsdlMap(),
074: classLoader);
075: if (soapHandler != null) {
076: soapHandler.addWebService(location.getPath(), virtualHosts,
077: axisContainer, securityRealmName, realmName,
078: transportGuarantee, authMethod, classLoader);
079: }
080: }
081:
082: public void doStart() throws Exception {
083:
084: }
085:
086: public void doStop() throws Exception {
087: if (soapHandler != null) {
088: soapHandler.removeWebService(location.getPath());
089: }
090: }
091:
092: public void doFail() {
093:
094: }
095:
096: public static final GBeanInfo GBEAN_INFO;
097:
098: static {
099: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
100: EjbWebServiceGBean.class, EjbWebServiceGBean.class,
101: NameFactory.WEB_SERVICE_LINK);
102:
103: // infoFactory.addOperation("invoke", new Class[]{WebServiceContainer.Request.class, WebServiceContainer.Response.class});
104:
105: infoFactory.addReference("EjbDeployment", EjbDeployment.class);
106: infoFactory.addAttribute("location", URI.class, true);
107: infoFactory.addAttribute("wsdlURI", URI.class, true);
108: infoFactory.addAttribute("securityRealmName", String.class,
109: true);
110: infoFactory.addAttribute("realmName", String.class, true);
111: infoFactory.addAttribute("transportGuarantee", String.class,
112: true);
113: infoFactory.addAttribute("authMethod", String.class, true);
114: infoFactory
115: .addAttribute("serviceInfo", ServiceInfo.class, true);
116: infoFactory.addAttribute("virtualHosts", String[].class, true);
117: infoFactory.addReference("WebServiceContainer",
118: SoapHandler.class);
119:
120: infoFactory.setConstructor(new String[] { "EjbDeployment",
121: "location", "wsdlURI", "WebServiceContainer",
122: "serviceInfo", "securityRealmName", "realmName",
123: "transportGuarantee", "authMethod", "virtualHosts" });
124:
125: GBEAN_INFO = infoFactory.getBeanInfo();
126: }
127:
128: public static GBeanInfo getGBeanInfo() {
129: return GBEAN_INFO;
130: }
131:
132: }
|