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 */
017
018 package org.apache.geronimo.axis2.pojo;
019
020 import java.net.URL;
021 import java.util.Map;
022
023 import javax.naming.Context;
024 import javax.naming.NamingException;
025 import javax.transaction.TransactionManager;
026
027 import org.apache.commons.logging.Log;
028 import org.apache.commons.logging.LogFactory;
029 import org.apache.geronimo.gbean.GBeanInfo;
030 import org.apache.geronimo.gbean.GBeanInfoBuilder;
031 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
032 import org.apache.geronimo.kernel.Kernel;
033 import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
034 import org.apache.geronimo.transaction.GeronimoUserTransaction;
035 import org.apache.geronimo.webservices.WebServiceContainer;
036 import org.apache.geronimo.webservices.WebServiceContainerFactory;
037
038 /**
039 * @version $Rev$ $Date$
040 */
041 public class POJOWebServiceContainerFactoryGBean implements WebServiceContainerFactory {
042
043 private static final Log LOG = LogFactory.getLog(POJOWebServiceContainerFactoryGBean.class);
044
045 private final ClassLoader classLoader;
046 private final org.apache.geronimo.jaxws.PortInfo portInfo;
047 private final String endpointClassName;
048 private URL configurationBaseUrl;
049 private Context context;
050
051 public POJOWebServiceContainerFactoryGBean(org.apache.geronimo.jaxws.PortInfo portInfo,
052 String endpointClassName,
053 ClassLoader classLoader,
054 Map componentContext,
055 Kernel kernel,
056 TransactionManager transactionManager,
057 URL configurationBaseUrl)
058 throws InstantiationException, IllegalAccessException, ClassNotFoundException {
059
060 if (componentContext != null) {
061 GeronimoUserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);
062 try {
063 this.context = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext,
064 userTransaction,
065 kernel,
066 classLoader);
067 } catch (NamingException e) {
068 LOG.warn("Failed to create naming context", e);
069 }
070 }
071
072 this.portInfo = portInfo;
073 this.classLoader = classLoader;
074 this.endpointClassName = endpointClassName;
075 this.configurationBaseUrl = configurationBaseUrl;
076 }
077
078 public WebServiceContainer getWebServiceContainer() {
079 POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName, classLoader, context, configurationBaseUrl);
080 try {
081 container.init();
082 } catch (Exception e) {
083 throw new RuntimeException("Failure initializing web service containter", e);
084 }
085 return container;
086 }
087
088 public static final GBeanInfo GBEAN_INFO;
089
090 static {
091 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(POJOWebServiceContainerFactoryGBean.class, NameFactory.GERONIMO_SERVICE);
092 infoBuilder.addAttribute("portInfo", org.apache.geronimo.jaxws.PortInfo.class, true, true);
093 infoBuilder.addAttribute("endpointClassName", String.class, true, true);
094 infoBuilder.addAttribute("classLoader", ClassLoader.class, false);
095 infoBuilder.addAttribute("componentContext", Map.class, true, true);
096 infoBuilder.addAttribute("kernel", Kernel.class, false);
097 infoBuilder.addReference("TransactionManager", TransactionManager.class, NameFactory.TRANSACTION_MANAGER);
098 infoBuilder.addAttribute("configurationBaseUrl", URL.class, true);
099
100 infoBuilder.setConstructor(new String[]{"portInfo", "endpointClassName", "classLoader",
101 "componentContext", "kernel", "TransactionManager", "configurationBaseUrl"});
102 GBEAN_INFO = infoBuilder.getBeanInfo();
103 }
104
105 public static GBeanInfo getGBeanInfo() {
106 return GBEAN_INFO;
107 }
108 }