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.axis2.ejb;
017:
018: import java.net.URL;
019:
020: import javax.naming.Context;
021:
022: import org.apache.geronimo.gbean.GBeanInfo;
023: import org.apache.geronimo.gbean.GBeanInfoBuilder;
024: import org.apache.geronimo.gbean.GBeanLifecycle;
025: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
026: import org.apache.geronimo.jaxws.PortInfo;
027: import org.apache.geronimo.kernel.Kernel;
028: import org.apache.geronimo.openejb.EjbDeployment;
029: import org.apache.geronimo.webservices.SoapHandler;
030: import org.apache.openejb.DeploymentInfo;
031:
032: /**
033: * @version $Rev$ $Date$
034: */
035: public class EJBWebServiceGBean implements GBeanLifecycle {
036:
037: private SoapHandler soapHandler;
038: private String location;
039: private EJBWebServiceContainer container;
040:
041: public EJBWebServiceGBean(EjbDeployment ejbDeploymentContext,
042: PortInfo portInfo, Kernel kernel, URL configurationBaseUrl,
043: SoapHandler soapHandler, String securityRealmName,
044: String realmName, String transportGuarantee,
045: String authMethod, String[] virtualHosts) throws Exception {
046: if (ejbDeploymentContext == null || soapHandler == null
047: || portInfo == null) {
048: return;
049: }
050:
051: this .soapHandler = soapHandler;
052: this .location = portInfo.getLocation();
053:
054: assert this .location != null : "null location received";
055:
056: String beanClassName = ejbDeploymentContext.getBeanClass()
057: .getName();
058: Context context = ejbDeploymentContext.getComponentContext();
059: ClassLoader classLoader = ejbDeploymentContext.getClassLoader();
060: DeploymentInfo deploymnetInfo = ejbDeploymentContext
061: .getDeploymentInfo();
062:
063: this .container = new EJBWebServiceContainer(portInfo,
064: beanClassName, classLoader, context,
065: configurationBaseUrl, deploymnetInfo);
066: this .container.init();
067:
068: if (soapHandler != null) {
069: soapHandler.addWebService(this .location, virtualHosts,
070: this .container, securityRealmName, realmName,
071: transportGuarantee, authMethod, classLoader);
072: }
073:
074: }
075:
076: public void doStart() throws Exception {
077: }
078:
079: public void doStop() throws Exception {
080: if (this .soapHandler != null) {
081: this .soapHandler.removeWebService(this .location);
082: }
083: if (this .container != null) {
084: this .container.destroy();
085: }
086: }
087:
088: public void doFail() {
089: }
090:
091: public static final GBeanInfo GBEAN_INFO;
092:
093: static {
094: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
095: EJBWebServiceGBean.class, EJBWebServiceGBean.class,
096: NameFactory.WEB_SERVICE_LINK);
097:
098: infoFactory.addReference("EjbDeployment", EjbDeployment.class);
099: infoFactory.addAttribute("portInfo", PortInfo.class, true);
100: infoFactory.addAttribute("kernel", Kernel.class, false);
101: infoFactory.addAttribute("configurationBaseUrl", URL.class,
102: true);
103: infoFactory.addAttribute("securityRealmName", String.class,
104: true);
105: infoFactory.addAttribute("realmName", String.class, true);
106: infoFactory.addAttribute("transportGuarantee", String.class,
107: true);
108: infoFactory.addAttribute("authMethod", String.class, true);
109: infoFactory.addAttribute("virtualHosts", String[].class, true);
110: infoFactory.addReference("WebServiceContainer",
111: SoapHandler.class);
112:
113: infoFactory.setConstructor(new String[] { "EjbDeployment",
114: "portInfo", "kernel", "configurationBaseUrl",
115: "WebServiceContainer", "securityRealmName",
116: "realmName", "transportGuarantee", "authMethod",
117: "virtualHosts" });
118:
119: GBEAN_INFO = infoFactory.getBeanInfo();
120: }
121:
122: public static GBeanInfo getGBeanInfo() {
123: return GBEAN_INFO;
124: }
125:
126: }
|