1 8 package org.codehaus.spice.jndikit.rmi.test; 9 10 import java.util.Hashtable ; 11 import javax.naming.Context ; 12 import javax.naming.NamingException ; 13 import javax.naming.ServiceUnavailableException ; 14 15 import org.codehaus.spice.jndikit.Namespace; 16 import org.codehaus.spice.jndikit.NamingProvider; 17 import org.codehaus.spice.jndikit.RemoteContext; 18 import org.codehaus.spice.jndikit.StandardNamespace; 19 import org.codehaus.spice.jndikit.rmi.RMIInitialContextFactory; 20 import org.codehaus.spice.jndikit.test.TestStateFactory; 21 22 28 public class RMIContextTestCase 29 extends AbstractRMIContextTestCase 30 { 31 public RMIContextTestCase() 32 { 33 super( new StandardNamespaceICF() ); 34 } 35 36 static class StandardNamespaceICF extends RMIInitialContextFactory 37 { 38 39 public Context getInitialContext( Hashtable environment ) 40 throws NamingException 41 { 42 environment.put( Context.STATE_FACTORIES, 43 TestStateFactory.class.getName() ); 44 return super.getInitialContext( environment ); 45 } 46 47 protected Namespace newNamespace( final Hashtable environment ) 48 throws NamingException 49 { 50 try 51 { 52 final NamingProvider provider = 53 ( NamingProvider ) environment.get( 54 RemoteContext.NAMING_PROVIDER ); 55 56 return new StandardNamespace( provider.getNameParser() ); 57 } 58 catch( final Exception e ) 59 { 60 if( e instanceof NamingException ) 61 { 62 throw ( NamingException ) e; 63 } 64 else 65 { 66 final ServiceUnavailableException sue = 67 new ServiceUnavailableException ( e.getMessage() ); 68 sue.setRootCause( e ); 69 throw sue; 70 } 71 } 72 } 73 } 74 } 75 | Popular Tags |