1 25 package org.objectweb.carol.jndi.spi; 26 27 import javax.naming.Context ; 28 import javax.naming.Name ; 29 import javax.naming.NamingException ; 30 import javax.naming.Reference ; 31 import javax.naming.spi.ObjectFactory ; 32 33 import org.objectweb.carol.jndi.registry.RegistryWrapperContext; 34 import org.objectweb.carol.jndi.wrapping.JNDIRemoteResource; 35 import org.objectweb.carol.rmi.exception.NamingExceptionHelper; 36 37 import com.sun.jndi.rmi.registry.RemoteReference; 38 39 49 public class JRMPLocalContext extends JRMPContext implements Context { 50 51 56 public JRMPLocalContext(Context jrmpLocalContext) throws NamingException { 57 super(new RegistryWrapperContext(jrmpLocalContext.getEnvironment())); 58 } 59 60 68 protected Object unwrapObject(Object o, Name name) throws NamingException { 69 try { 70 if (o instanceof RemoteReference) { 71 Reference objRef = ((RemoteReference) o).getReference(); 73 ObjectFactory objFact = (ObjectFactory ) (Class.forName(objRef.getFactoryClassName())).newInstance(); 74 return objFact.getObjectInstance(objRef, name, this, getEnvironment()); 75 } else if (o instanceof JNDIRemoteResource) { 76 return ((JNDIRemoteResource) o).getResource(); 77 } else { 78 return o; 79 } 80 } catch (Exception e) { 81 throw NamingExceptionHelper.create("Cannot unwrap object '" + o + "' with name '" + name + "'.", e); 82 } 83 } 84 85 } 86 | Popular Tags |