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    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: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
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    }