1 8 package org.codehaus.spice.jndikit.test; 9 10 import java.util.Hashtable ; 11 import javax.naming.Context ; 12 import javax.naming.Name ; 13 import javax.naming.Reference ; 14 import javax.naming.StringRefAddr ; 15 import javax.naming.spi.ObjectFactory ; 16 17 18 25 public class TestObjectFactory implements ObjectFactory 26 { 27 28 46 public Object getObjectInstance( Object obj, Name name, Context nameCtx, 47 Hashtable environment ) throws Exception 48 { 49 Object result = null; 50 if( obj instanceof Reference ) 51 { 52 Reference ref = ( Reference ) obj; 53 String clazz = ref.getClassName(); 54 if( clazz.equals( TestDataReferenceable.class.getName() ) ) 55 { 56 String value = null; 57 StringRefAddr str = ( StringRefAddr ) ref.get( "value" ); 58 if( str != null ) 59 { 60 value = ( String ) str.getContent(); 61 } 62 result = new TestDataReferenceable( value ); 63 } 64 else if( clazz.equals( ExceptionReferenceable.class.getName() ) ) 65 { 66 throw new Exception ( "Encountered " + clazz ); 67 } 68 } 69 return result; 70 } 71 72 } 73 | Popular Tags |