001 /** 002 * 003 * Copyright 2003-2005 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * 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 package org.apache.geronimo.tomcat; 018 019 import org.apache.catalina.Context; 020 import org.apache.catalina.Lifecycle; 021 import org.apache.catalina.startup.ContextConfig; 022 import org.apache.catalina.startup.Embedded; 023 import org.apache.commons.logging.Log; 024 import org.apache.commons.logging.LogFactory; 025 import org.apache.geronimo.webservices.WebServiceContainer; 026 027 /** 028 * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $ 029 */ 030 public class TomcatGeronimoEmbedded extends Embedded{ 031 032 private static final Log log = LogFactory.getLog(TomcatGeronimoEmbedded.class); 033 034 public Context createContext(String path, String docBase, ClassLoader cl) { 035 036 if( log.isDebugEnabled() ) 037 log.debug("Creating context '" + path + "' with docBase '" + 038 docBase + "'"); 039 040 GeronimoStandardContext context = new GeronimoStandardContext(); 041 042 context.setDocBase(docBase); 043 context.setPath(path); 044 045 if (cl != null) 046 context.setParentClassLoader(cl); 047 048 ContextConfig config = new ContextConfig(); 049 config.setCustomAuthenticators(authenticators); 050 ((Lifecycle) context).addLifecycleListener(config); 051 052 context.setDelegate(true); 053 return (context); 054 055 } 056 057 public Context createEJBWebServiceContext(String contextPath, 058 WebServiceContainer webServiceContainer, 059 String securityRealmName, 060 String realmName, 061 String transportGuarantee, 062 String authMethod, 063 ClassLoader classLoader) { 064 065 if( log.isDebugEnabled() ) 066 log.debug("Creating EJBWebService context '" + contextPath + "'."); 067 068 TomcatEJBWebServiceContext context = new TomcatEJBWebServiceContext(contextPath, webServiceContainer, securityRealmName, realmName, transportGuarantee, authMethod, classLoader); 069 070 ContextConfig config = new ContextConfig(); 071 config.setCustomAuthenticators(authenticators); 072 ((Lifecycle) context).addLifecycleListener(config); 073 074 return (context); 075 076 } 077 078 }