remm 2002/12/14 06:05:13 Modified: catalina/src/share/org/apache/naming/factory Constants.java EjbFactory.java Added: catalina/src/share/org/apache/naming/factory OpenEjbFactory.java Log: - Add EJB JNDI ENC entries support through OpenEJB 0.9. This has zero dependencies with OpenEJB. - HOWTO coming soon (although the integration is likely to get refined). - I plan to port that feature to 4.1.x (I can't see any reason not to). - Contributed by Jacek Laskowski <jacek_laskowski at hp.com> Revision Changes Path 1.2 +6 -3 jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/factory/Constants.java Index: Constants.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/factory/Constants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Constants.java 18 Jul 2002 16:47:36 -0000 1.1 +++ Constants.java 14 Dec 2002 14:05:12 -0000 1.2 @@ -91,6 +91,9 @@ public static final String DBCP_DATASOURCE_FACTORY = "org.apache.commons.dbcp.BasicDataSourceFactory"; + public static final String OPENEJB_EJB_FACTORY = + Package + ".OpenEjbFactory"; + public static final String TYREX_RESOURCE_FACTORY = Package + ".TyrexResourceFactory"; 1.2 +13 -5 jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/factory/EjbFactory.java Index: EjbFactory.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/factory/EjbFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- EjbFactory.java 18 Jul 2002 16:47:34 -0000 1.1 +++ EjbFactory.java 14 Dec 2002 14:05:12 -0000 1.2 @@ -174,9 +174,17 @@ } catch(Throwable t) { } } + } else { + String javaxEjbFactoryClassName = + System.getProperty("javax.ejb.Factory", + Constants.OPENEJB_EJB_FACTORY); + try { + factory = (ObjectFactory) + Class.forName(javaxEjbFactoryClassName).newInstance(); + } catch(Throwable t) { + } } - // Note: No defaults here if (factory != null) { return factory.getObjectInstance (obj, name, nameCtx, environment); 1.1 jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/factory/OpenEjbFactory.java Index: OpenEjbFactory.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/factory/OpenEjbFactory.java,v 1.1 2002/12/14 14:05:12 remm Exp $ * $Revision: 1.1 $ * $Date: 2002/12/14 14:05:12 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.naming.factory; import org.apache.naming.EjbRef; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.Name; import javax.naming.Reference; import javax.naming.RefAddr; import javax.naming.spi.ObjectFactory; import java.util.Hashtable; import java.util.Properties; /** * Object factory for EJBs. * * @author Jacek Laskowski * @author Remy Maucherat * @version $Revision: 1.1 $ $Date: 2002/12/14 14:05:12 $ */ public class OpenEjbFactory implements ObjectFactory { // -------------------------------------------------------------- Constants protected static final String DEFAULT_OPENEJB_FACTORY = "org.openejb.client.LocalInitialContextFactory"; // -------------------------------------------------- ObjectFactory Methods /** * Crete a new EJB instance using OpenEJB. * * @param obj The reference object describing the DataSource */ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { Object beanObj = null; if (obj instanceof EjbRef) { Reference ref = (Reference) obj; String factory = DEFAULT_OPENEJB_FACTORY; RefAddr factoryRefAddr = ref.get("openejb.factory"); if (factoryRefAddr != null) { // Retrieving the OpenEJB factory factory = factoryRefAddr.getContent().toString(); } Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, factory); RefAddr linkRefAddr = ref.get("openejb.link"); if (linkRefAddr != null) { String ejbLink = linkRefAddr.getContent().toString(); beanObj = (new InitialContext(env)).lookup(ejbLink); } } return beanObj; } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>