You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2008/08/20 20:41:29 UTC

svn commit: r687417 - in /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb: client/ core/ivm/ core/ivm/naming/

Author: dblevins
Date: Wed Aug 20 11:41:28 2008
New Revision: 687417

URL: http://svn.apache.org/viewvc?rev=687417&view=rev
Log:
OPENEJB-896: VM-scoped Security for embedded scenarios
OPENEJB-897: LocalInitialContext.close() to logout of embedded container
Also Depricated the IvmContextFactory, we don't need it anymore.
Moved most of the embedded startup/stop logic into the LocalInitialContext class.
BaseEjbProxyHandler will do the associate/disassociate calls if there is no ThreadContext and there is an local client security idenity.

Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/ClientSecurity.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextWrapper.java
Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/client/LocalInitialContext.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/client/LocalInitialContextFactory.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/BaseEjbProxyHandler.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/InitContextFactory.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/client/LocalInitialContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/client/LocalInitialContext.java?rev=687417&r1=687416&r2=687417&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/client/LocalInitialContext.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/client/LocalInitialContext.java Wed Aug 20 11:41:28 2008
@@ -17,46 +17,59 @@
 package org.apache.openejb.client;
 
 import org.apache.openejb.OpenEJB;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.SecurityService;
+import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.LogCategory;
-import org.apache.openejb.core.ivm.naming.InitContextFactory;
+import org.apache.openejb.core.ivm.ClientSecurity;
+import org.apache.openejb.core.ivm.naming.ContextWrapper;
 
-import javax.naming.Binding;
 import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NameClassPair;
-import javax.naming.NameParser;
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
+import javax.naming.AuthenticationException;
+import javax.security.auth.login.LoginException;
 import java.util.Hashtable;
+import java.util.Properties;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
 
 /**
  * @version $Rev$ $Date$
  */
-public class LocalInitialContext implements Context {
+public class LocalInitialContext extends ContextWrapper {
 
+    private static final String OPENEJB_EMBEDDED_REMOTABLE = "openejb.embedded.remotable";
     private static Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP, LocalInitialContext.class);
-    private final Context context;
+
     private final LocalInitialContextFactory factory;
+    private Properties properties;
+    private Object clientIdentity;
+    private Object serviceManager;
+
+    public LocalInitialContext(Hashtable env, LocalInitialContextFactory factory) throws NamingException {
+        super(getContainerSystemEjbContext());
+        properties = new Properties();
+        properties.putAll(env);
 
-    public LocalInitialContext(Context context, LocalInitialContextFactory factory) {
-        this.context = context;
         this.factory = factory;
-    }
 
-    public Object addToEnvironment(String propName, Object propVal) throws NamingException {
-        return context.addToEnvironment(propName, propVal);
-    }
+        login();
 
-    public void bind(Name name, Object obj) throws NamingException {
-        context.bind(name, obj);
+        startNetworkServices();
     }
 
-    public void bind(String name, Object obj) throws NamingException {
-        context.bind(name, obj);
+    public void close() throws NamingException {
+        logger.debug("LocalIntialContext.close()");
+
+        logout();
+
+        stopNetworkServices();
+
+        tearDownOpenEJB();
     }
 
-    public void close() throws NamingException {
+    private void tearDownOpenEJB() throws NamingException {
         if (factory.bootedOpenEJB()){
             logger.info("Destroying container system");
             factory.close();
@@ -65,103 +78,95 @@
         }
     }
 
-    public Name composeName(Name name, Name prefix) throws NamingException {
-        return context.composeName(name, prefix);
-    }
-
-    public String composeName(String name, String prefix) throws NamingException {
-        return context.composeName(name, prefix);
-    }
-
-    public Context createSubcontext(Name name) throws NamingException {
-        return context.createSubcontext(name);
-    }
-
-    public Context createSubcontext(String name) throws NamingException {
-        return context.createSubcontext(name);
-    }
-
-    public void destroySubcontext(Name name) throws NamingException {
-        context.destroySubcontext(name);
-    }
-
-    public void destroySubcontext(String name) throws NamingException {
-        context.destroySubcontext(name);
-    }
-
-    public Hashtable<?, ?> getEnvironment() throws NamingException {
-        return context.getEnvironment();
-    }
-
-    public String getNameInNamespace() throws NamingException {
-        return context.getNameInNamespace();
-    }
-
-    public NameParser getNameParser(Name name) throws NamingException {
-        return context.getNameParser(name);
-    }
-
-    public NameParser getNameParser(String name) throws NamingException {
-        return context.getNameParser(name);
-    }
-
-    public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
-        return context.list(name);
-    }
-
-    public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
-        return context.list(name);
-    }
-
-    public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
-        return context.listBindings(name);
-    }
-
-    public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
-        return context.listBindings(name);
-    }
-
-    public Object lookup(Name name) throws NamingException {
-        return context.lookup(name);
-    }
-
-    public Object lookup(String name) throws NamingException {
-        return context.lookup(name);
-    }
-
-    public Object lookupLink(Name name) throws NamingException {
-        return context.lookupLink(name);
-    }
-
-    public Object lookupLink(String name) throws NamingException {
-        return context.lookupLink(name);
+    private void login() throws AuthenticationException {
+        String user = (String) properties.get(Context.SECURITY_PRINCIPAL);
+        String pass = (String) properties.get(Context.SECURITY_CREDENTIALS);
+        String realmName = (String) properties.get("openejb.authentication.realmName");
+
+        if (user != null && pass != null){
+            try {
+                logger.info("Logging in");
+                SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
+                if (realmName == null) {
+                    clientIdentity = securityService.login(user, pass);
+                } else {
+                    clientIdentity = securityService.login(realmName, user, pass);
+                }
+                ClientSecurity.setIdentity(clientIdentity);
+            } catch (LoginException e) {
+                throw (AuthenticationException) new AuthenticationException("User could not be authenticated: "+user).initCause(e);
+            }
+        }
     }
 
-    public void rebind(Name name, Object obj) throws NamingException {
-        context.rebind(name, obj);
+    private void logout() {
+        if (clientIdentity != null) {
+            logger.info("Logging out");
+            ClientSecurity.setIdentity(null);
+        }
     }
 
-    public void rebind(String name, Object obj) throws NamingException {
-        context.rebind(name, obj);
-    }
+    private void startNetworkServices() {
+        if (!properties.getProperty(OPENEJB_EMBEDDED_REMOTABLE, "false").equalsIgnoreCase("true")) {
+            return;
+        }
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
 
-    public Object removeFromEnvironment(String propName) throws NamingException {
-        return context.removeFromEnvironment(propName);
+        try {
+            logger.info("Starting network services");
+            Class serviceManagerClass = classLoader.loadClass("org.apache.openejb.server.ServiceManager");
+            Method init = serviceManagerClass.getMethod("init");
+            Method start = serviceManagerClass.getMethod("start", boolean.class);
+
+            serviceManager = serviceManagerClass.newInstance();
+            try {
+                init.invoke(serviceManager);
+            } catch (InvocationTargetException e) {
+                Throwable cause = e.getCause();
+                String msg = "Option Enabled '" + OPENEJB_EMBEDDED_REMOTABLE + "'.  Error, unable to initialize ServiceManager.  Cause: " + cause.getClass().getName() + ": " + cause.getMessage();
+                throw new IllegalStateException(msg, cause);
+            }
+            try {
+                start.invoke(serviceManager, false);
+            } catch (InvocationTargetException e) {
+                Throwable cause = e.getCause();
+                String msg = "Option Enabled '" + OPENEJB_EMBEDDED_REMOTABLE + "'.  Error, unable to start ServiceManager.  Cause: " + cause.getClass().getName() + ": " + cause.getMessage();
+                throw new IllegalStateException(msg, cause);
+            }
+        } catch (ClassNotFoundException e) {
+            String msg = "Enabling option '" + OPENEJB_EMBEDDED_REMOTABLE + "' requires class 'org.apache.openejb.server.ServiceManager' to be available.  Make sure you have the openejb-server-*.jar in your classpath and at least one protocol implementation such as openejb-ejbd-*.jar.";
+            throw new IllegalStateException(msg, e);
+        } catch (NoSuchMethodException e) {
+            String msg = "Option Enabled '" + OPENEJB_EMBEDDED_REMOTABLE + "'.  Error, 'init' and 'start' methods not found on as expected on class 'org.apache.openejb.server.ServiceManager'.  This should never happen.";
+            throw new IllegalStateException(msg, e);
+        } catch (InstantiationException e) {
+            String msg = "Option Enabled '" + OPENEJB_EMBEDDED_REMOTABLE + "'.  Error, unable to instantiate ServiceManager class 'org.apache.openejb.server.ServiceManager'.";
+            throw new IllegalStateException(msg, e);
+        } catch (IllegalAccessException e) {
+            String msg = "Option Enabled '" + OPENEJB_EMBEDDED_REMOTABLE + "'.  Error, 'init' and 'start' methods cannot be accessed on class 'org.apache.openejb.server.ServiceManager'.  The VM SecurityManager settings must be adjusted.";
+            throw new IllegalStateException(msg, e);
+        }
     }
 
-    public void rename(Name oldName, Name newName) throws NamingException {
-        context.rename(oldName, newName);
-    }
 
-    public void rename(String oldName, String newName) throws NamingException {
-        context.rename(oldName, newName);
+    private void stopNetworkServices() {
+        if (serviceManager != null){
+            logger.info("Stopping network services");
+            try {
+                Method stop = serviceManager.getClass().getMethod("stop");
+                stop.invoke(serviceManager);
+                Thread.sleep(3000);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
     }
 
-    public void unbind(Name name) throws NamingException {
-        context.unbind(name);
-    }
 
-    public void unbind(String name) throws NamingException {
-        context.unbind(name);
+    private static Context getContainerSystemEjbContext() throws NamingException {
+        ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
+        Context context = containerSystem.getJNDIContext();
+        context = (Context) context.lookup("java:openejb/ejb");
+        return context;
     }
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/client/LocalInitialContextFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/client/LocalInitialContextFactory.java?rev=687417&r1=687416&r2=687417&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/client/LocalInitialContextFactory.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/client/LocalInitialContextFactory.java Wed Aug 20 11:41:28 2008
@@ -22,7 +22,6 @@
 
 import javax.naming.Context;
 import javax.naming.NamingException;
-import javax.naming.spi.InitialContextFactory;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Constructor;
@@ -35,10 +34,8 @@
 public class LocalInitialContextFactory implements javax.naming.spi.InitialContextFactory {
 
     private static OpenEJBInstance openejb;
-    private static final String OPENEJB_EMBEDDED_REMOTABLE = "openejb.embedded.remotable";
 
     private boolean bootedOpenEJB;
-    private Object serviceManager;
 
     public Context getInitialContext(Hashtable env) throws javax.naming.NamingException {
         init(env);
@@ -70,75 +67,28 @@
         SystemInstance.init(properties);
         SystemInstance.get().setProperty("openejb.embedded", "true");
         openejb.init(properties);
-        if (properties.getProperty(OPENEJB_EMBEDDED_REMOTABLE, "false").equalsIgnoreCase("true")) {
-            bootServerServices();
-        }
     }
 
     public void close(){
         openejb = null;
-        if (serviceManager != null){
-            try {
-                Method stop = serviceManager.getClass().getMethod("stop");
-                stop.invoke(serviceManager);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private void bootServerServices() {
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
-        try {
-            Class serviceManagerClass = classLoader.loadClass("org.apache.openejb.server.ServiceManager");
-            Method init = serviceManagerClass.getMethod("init");
-            Method start = serviceManagerClass.getMethod("start", boolean.class);
-
-            serviceManager = serviceManagerClass.newInstance();
-            try {
-                init.invoke(serviceManager);
-            } catch (InvocationTargetException e) {
-                Throwable cause = e.getCause();
-                String msg = "Option Enabled '" + OPENEJB_EMBEDDED_REMOTABLE + "'.  Error, unable to initialize ServiceManager.  Cause: " + cause.getClass().getName() + ": " + cause.getMessage();
-                throw new IllegalStateException(msg, cause);
-            }
-            try {
-                start.invoke(serviceManager, false);
-            } catch (InvocationTargetException e) {
-                Throwable cause = e.getCause();
-                String msg = "Option Enabled '" + OPENEJB_EMBEDDED_REMOTABLE + "'.  Error, unable to start ServiceManager.  Cause: " + cause.getClass().getName() + ": " + cause.getMessage();
-                throw new IllegalStateException(msg, cause);
-            }
-        } catch (ClassNotFoundException e) {
-            String msg = "Enabling option '" + OPENEJB_EMBEDDED_REMOTABLE + "' requires class 'org.apache.openejb.server.ServiceManager' to be available.  Make sure you have the openejb-server-*.jar in your classpath and at least one protocol implementation such as openejb-ejbd-*.jar.";
-            throw new IllegalStateException(msg, e);
-        } catch (NoSuchMethodException e) {
-            String msg = "Option Enabled '" + OPENEJB_EMBEDDED_REMOTABLE + "'.  Error, 'init' and 'start' methods not found on as expected on class 'org.apache.openejb.server.ServiceManager'.  This should never happen.";
-            throw new IllegalStateException(msg, e);
-        } catch (InstantiationException e) {
-            String msg = "Option Enabled '" + OPENEJB_EMBEDDED_REMOTABLE + "'.  Error, unable to instantiate ServiceManager class 'org.apache.openejb.server.ServiceManager'.";
-            throw new IllegalStateException(msg, e);
-        } catch (IllegalAccessException e) {
-            String msg = "Option Enabled '" + OPENEJB_EMBEDDED_REMOTABLE + "'.  Error, 'init' and 'start' methods cannot be accessed on class 'org.apache.openejb.server.ServiceManager'.  The VM SecurityManager settings must be adjusted.";
-            throw new IllegalStateException(msg, e);
-        }
     }
 
     private Context getLocalInitialContext(Hashtable env) throws javax.naming.NamingException {
         Context context = null;
         try {
-            InitialContextFactory factory = null;
             ClassLoader cl = SystemInstance.get().getClassLoader();
-            Class ivmFactoryClass = Class.forName("org.apache.openejb.core.ivm.naming.InitContextFactory", true, cl);
 
-            factory = (InitialContextFactory) ivmFactoryClass.newInstance();
-            context = factory.getInitialContext(env);
+            Class localInitialContext = Class.forName("org.apache.openejb.client.LocalInitialContext", true, cl);
 
-            Class clientWrapper = Class.forName("org.apache.openejb.client.LocalInitialContext", true, cl);
-            Constructor constructor = clientWrapper.getConstructor(Context.class, this.getClass());
-            context = (Context) constructor.newInstance(context, this);
-        } catch (Exception e) {
+            Constructor constructor = localInitialContext.getConstructor(Hashtable.class, this.getClass());
+            context = (Context) constructor.newInstance(env, this);
+        } catch (Throwable e) {
+            if (e instanceof InvocationTargetException) {
+                InvocationTargetException ite = (InvocationTargetException) e;
+                if (ite.getTargetException() != null){
+                    e = ite.getTargetException();
+                }
+            }
             throw (NamingException) new javax.naming.NamingException("Cannot instantiate a LocalInitialContext. Exception: "
                     + e.getClass().getName() + " " + e.getMessage()).initCause(e);
         }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/BaseEjbProxyHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/BaseEjbProxyHandler.java?rev=687417&r1=687416&r2=687417&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/BaseEjbProxyHandler.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/BaseEjbProxyHandler.java Wed Aug 20 11:41:28 2008
@@ -57,8 +57,10 @@
 import org.apache.openejb.RpcContainer;
 import org.apache.openejb.DeploymentInfo;
 import org.apache.openejb.core.CoreDeploymentInfo;
+import org.apache.openejb.core.ThreadContext;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.spi.ContainerSystem;
+import org.apache.openejb.spi.SecurityService;
 import org.apache.openejb.util.proxy.InvocationHandler;
 import org.apache.openejb.util.proxy.ProxyManager;
 
@@ -83,6 +85,8 @@
 
     protected boolean isInvalidReference = false;
 
+    protected Object clientIdentity;
+
     /*
     * The EJB 1.1 specification requires that arguments and return values between beans adhere to the
     * Java RMI copy semantics which requires that the all arguments be passed by value (copied) and 
@@ -245,38 +249,52 @@
 
         Class interfce = getInvokedInterface(method);
 
-        if (strategy == CLASSLOADER_COPY) {
 
-            IntraVmCopyMonitor.pre(strategy);
-            ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
-            Thread.currentThread().setContextClassLoader(getDeploymentInfo().getClassLoader());
-            try {
-                args = copyArgs(args);
-                method = copyMethod(method);
-                interfce = copyObj(interfce);
-            } finally {
-                Thread.currentThread().setContextClassLoader(oldClassLoader);
-                IntraVmCopyMonitor.post();
+        ThreadContext callContext = ThreadContext.getThreadContext();
+        Object localClientIdentity = ClientSecurity.getIdentity();
+        try {
+            if (callContext == null && localClientIdentity != null) {
+                SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
+                securityService.associate(localClientIdentity);
+            }
+            if (strategy == CLASSLOADER_COPY) {
+
+                IntraVmCopyMonitor.pre(strategy);
+                ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+                Thread.currentThread().setContextClassLoader(getDeploymentInfo().getClassLoader());
+                try {
+                    args = copyArgs(args);
+                    method = copyMethod(method);
+                    interfce = copyObj(interfce);
+                } finally {
+                    Thread.currentThread().setContextClassLoader(oldClassLoader);
+                    IntraVmCopyMonitor.post();
+                }
+
+            } else if (strategy == COPY && args != null && args.length > 0) {
+
+                IntraVmCopyMonitor.pre(strategy);
+                try {
+                    args = copyArgs(args);
+                } finally {
+                    IntraVmCopyMonitor.post();
+                }
             }
 
-        } else if (strategy == COPY && args != null && args.length > 0) {
-
-            IntraVmCopyMonitor.pre(strategy);
             try {
-                args = copyArgs(args);
-            } finally {
-                IntraVmCopyMonitor.post();
-            }
-        }
 
-        try {
-
-            Object returnValue = _invoke(proxy, interfce, method, args);
+                Object returnValue = _invoke(proxy, interfce, method, args);
 
-            return copy(strategy, returnValue);
-        } catch (Throwable throwable) {
-            throwable = copy(strategy, throwable);
-            throw convertException(throwable, method, interfce);
+                return copy(strategy, returnValue);
+            } catch (Throwable throwable) {
+                throwable = copy(strategy, throwable);
+                throw convertException(throwable, method, interfce);
+            }
+        } finally {
+            if (callContext == null && localClientIdentity != null) {
+                SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
+                securityService.disassociate();
+            }
         }
     }
 

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/ClientSecurity.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/ClientSecurity.java?rev=687417&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/ClientSecurity.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/ClientSecurity.java Wed Aug 20 11:41:28 2008
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.core.ivm;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ClientSecurity {
+
+    private static Object clientIdentity;
+
+    public static Object getIdentity() {
+        return clientIdentity;
+    }
+
+    public static void setIdentity(Object clientIdentity) {
+        ClientSecurity.clientIdentity = clientIdentity;
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextWrapper.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextWrapper.java?rev=687417&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextWrapper.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextWrapper.java Wed Aug 20 11:41:28 2008
@@ -0,0 +1,153 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.core.ivm.naming;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NameClassPair;
+import javax.naming.Binding;
+import java.util.Hashtable;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ContextWrapper implements Context {
+    protected final Context context;
+
+    public ContextWrapper(Context context) {
+        this.context = context;
+    }
+
+    public Object addToEnvironment(String propName, Object propVal) throws NamingException {
+        return context.addToEnvironment(propName, propVal);
+    }
+
+    public void bind(Name name, Object obj) throws NamingException {
+        context.bind(name, obj);
+    }
+
+    public void bind(String name, Object obj) throws NamingException {
+        context.bind(name, obj);
+    }
+
+    public void close() throws NamingException {
+        context.close();
+    }
+
+    public Name composeName(Name name, Name prefix) throws NamingException {
+        return context.composeName(name, prefix);
+    }
+
+    public String composeName(String name, String prefix) throws NamingException {
+        return context.composeName(name, prefix);
+    }
+
+    public Context createSubcontext(Name name) throws NamingException {
+        return context.createSubcontext(name);
+    }
+
+    public Context createSubcontext(String name) throws NamingException {
+        return context.createSubcontext(name);
+    }
+
+    public void destroySubcontext(Name name) throws NamingException {
+        context.destroySubcontext(name);
+    }
+
+    public void destroySubcontext(String name) throws NamingException {
+        context.destroySubcontext(name);
+    }
+
+    public Hashtable<?, ?> getEnvironment() throws NamingException {
+        return context.getEnvironment();
+    }
+
+    public String getNameInNamespace() throws NamingException {
+        return context.getNameInNamespace();
+    }
+
+    public NameParser getNameParser(Name name) throws NamingException {
+        return context.getNameParser(name);
+    }
+
+    public NameParser getNameParser(String name) throws NamingException {
+        return context.getNameParser(name);
+    }
+
+    public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
+        return context.list(name);
+    }
+
+    public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
+        return context.list(name);
+    }
+
+    public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
+        return context.listBindings(name);
+    }
+
+    public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
+        return context.listBindings(name);
+    }
+
+    public Object lookup(Name name) throws NamingException {
+        return context.lookup(name);
+    }
+
+    public Object lookup(String name) throws NamingException {
+        return context.lookup(name);
+    }
+
+    public Object lookupLink(Name name) throws NamingException {
+        return context.lookupLink(name);
+    }
+
+    public Object lookupLink(String name) throws NamingException {
+        return context.lookupLink(name);
+    }
+
+    public void rebind(Name name, Object obj) throws NamingException {
+        context.rebind(name, obj);
+    }
+
+    public void rebind(String name, Object obj) throws NamingException {
+        context.rebind(name, obj);
+    }
+
+    public Object removeFromEnvironment(String propName) throws NamingException {
+        return context.removeFromEnvironment(propName);
+    }
+
+    public void rename(Name oldName, Name newName) throws NamingException {
+        context.rename(oldName, newName);
+    }
+
+    public void rename(String oldName, String newName) throws NamingException {
+        context.rename(oldName, newName);
+    }
+
+    public void unbind(Name name) throws NamingException {
+        context.unbind(name);
+    }
+
+    public void unbind(String name) throws NamingException {
+        context.unbind(name);
+    }
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/InitContextFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/InitContextFactory.java?rev=687417&r1=687416&r2=687417&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/InitContextFactory.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/InitContextFactory.java Wed Aug 20 11:41:28 2008
@@ -28,6 +28,9 @@
 import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.spi.SecurityService;
 
+/**
+ * @Depricated Use org.apache.openejb.client.LocalInitialContextFactory
+ */
 public class InitContextFactory implements javax.naming.spi.InitialContextFactory {
 
     public Context getInitialContext(Hashtable env) throws javax.naming.NamingException {