Home » geronimo-2.2-source-release » org.apache.geronimo.axis2.pojo » [javadoc | source]

    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   
   18   package org.apache.geronimo.axis2.pojo;
   19   
   20   import java.net.URL;
   21   import java.util.Map;
   22   
   23   import javax.naming.Context;
   24   import javax.naming.NamingException;
   25   import javax.transaction.TransactionManager;
   26   
   27   import org.slf4j.Logger;
   28   import org.slf4j.LoggerFactory;
   29   import org.apache.geronimo.gbean.GBeanInfo;
   30   import org.apache.geronimo.gbean.GBeanInfoBuilder;
   31   import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
   32   import org.apache.geronimo.jaxws.annotations.AnnotationHolder;
   33   import org.apache.geronimo.kernel.Kernel;
   34   import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
   35   import org.apache.geronimo.naming.reference.SimpleReference;
   36   import org.apache.geronimo.transaction.GeronimoUserTransaction;
   37   import org.apache.geronimo.webservices.WebServiceContainer;
   38   import org.apache.geronimo.webservices.WebServiceContainerFactory;
   39   
   40   /**
   41    * @version $Rev$ $Date$
   42    */
   43   public class POJOWebServiceContainerFactoryGBean implements WebServiceContainerFactory
   44   {
   45       private static final Logger LOG = LoggerFactory.getLogger(POJOWebServiceContainerFactoryGBean.class);
   46       
   47       private final ClassLoader classLoader;
   48       private final org.apache.geronimo.jaxws.PortInfo portInfo;
   49       private final String endpointClassName;
   50       private URL configurationBaseUrl;
   51       private Context context;
   52       private AnnotationHolder holder;
   53       private String contextRoot;
   54   
   55       public POJOWebServiceContainerFactoryGBean(org.apache.geronimo.jaxws.PortInfo portInfo,
   56                                                  String endpointClassName,
   57                                                  ClassLoader classLoader,
   58                                                  Map componentContext,
   59                                                  Kernel kernel,
   60                                                  TransactionManager transactionManager,
   61                                                  URL configurationBaseUrl,
   62                                                  AnnotationHolder holder,
   63                                                  String contextRoot)
   64           throws InstantiationException, IllegalAccessException, ClassNotFoundException {
   65           
   66           if (componentContext != null) {
   67               
   68               // The name should match WebServiceContextAnnotationHelper.RELATIVE_JNDI_NAME
   69               componentContext.put("env/WebServiceContext", new WebServiceContextReference());
   70               
   71               GeronimoUserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);
   72               try {
   73                   this.context = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext,
   74                           userTransaction,
   75                           kernel,
   76                           classLoader);
   77               } catch (NamingException e) {
   78                   LOG.warn("Failed to create naming context", e);
   79               }
   80           }
   81           
   82           this.portInfo = portInfo;
   83           this.classLoader = classLoader;
   84           this.endpointClassName = endpointClassName;
   85           this.configurationBaseUrl = configurationBaseUrl;   
   86           this.holder = holder;
   87           this.contextRoot = contextRoot;
   88       }
   89   
   90       public WebServiceContainer getWebServiceContainer() {
   91           POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName, classLoader, 
   92                                                                           context, configurationBaseUrl, holder, contextRoot);
   93           try {
   94               container.init();
   95           } catch (Exception e) {
   96               throw new RuntimeException("Failure initializing web service containter", e);
   97           }
   98           return container;
   99       }
  100   
  101       private static class WebServiceContextReference extends SimpleReference {
  102           public Object getContent() throws NamingException {
  103               return new POJOWebServiceContext();
  104           }        
  105       }
  106       
  107       public static final GBeanInfo GBEAN_INFO;
  108   
  109       static {
  110           GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(POJOWebServiceContainerFactoryGBean.class, GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
  111           infoBuilder.addAttribute("portInfo", org.apache.geronimo.jaxws.PortInfo.class, true, true);
  112           infoBuilder.addAttribute("endpointClassName", String.class, true, true);
  113           infoBuilder.addAttribute("classLoader", ClassLoader.class, false);
  114           infoBuilder.addAttribute("componentContext", Map.class, true, true);
  115           infoBuilder.addAttribute("kernel", Kernel.class, false);
  116           infoBuilder.addReference("TransactionManager", TransactionManager.class, NameFactory.JTA_RESOURCE);
  117           infoBuilder.addAttribute("configurationBaseUrl", URL.class, true);
  118           infoBuilder.addAttribute("holder", AnnotationHolder.class, true);
  119           infoBuilder.addAttribute("contextRoot", String.class, true, true);
  120   
  121           infoBuilder.setConstructor(new String[]{
  122                   "portInfo", 
  123                   "endpointClassName", 
  124                   "classLoader",
  125                   "componentContext", 
  126                   "kernel", 
  127                   "TransactionManager", 
  128                   "configurationBaseUrl", 
  129                   "holder", 
  130                   "contextRoot"
  131           });
  132           
  133           GBEAN_INFO = infoBuilder.getBeanInfo();
  134       }
  135   
  136       public static GBeanInfo getGBeanInfo() {
  137           return GBEAN_INFO;
  138       }
  139   }

Home » geronimo-2.2-source-release » org.apache.geronimo.axis2.pojo » [javadoc | source]