User: starksm Date: 02/02/08 17:56:07 Modified: src/main/org/jboss/naming NonSerializableFactory.java Log: Add Name based versions of rebind and unbind Revision Changes Path 1.8 +43 -3 jboss/src/main/org/jboss/naming/NonSerializableFactory.java Index: NonSerializableFactory.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/naming/NonSerializableFactory.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- NonSerializableFactory.java 3 Aug 2001 17:15:55 -0000 1.7 +++ NonSerializableFactory.java 9 Feb 2002 01:56:07 -0000 1.8 @@ -11,6 +11,7 @@ import java.util.Hashtable; import java.util.Map; import javax.naming.Context; +import javax.naming.InitialContext; import javax.naming.Name; import javax.naming.NameAlreadyBoundException; import javax.naming.NameNotFoundException; @@ -64,8 +65,8 @@ @see javax.naming.spi.ObjectFactory @see #rebind(Context, String, Object) -@author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>. -@version $Revision: 1.7 $ +@author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>. +@version $Revision: 1.8 $ */ public class NonSerializableFactory implements ObjectFactory { @@ -104,7 +105,6 @@ /** Remove a binding from the NonSerializableFactory map. @param key, the key into the NonSerializableFactory map to remove. - @param target, the non-Serializable object to bind. @throws NameNotFoundException, thrown if key does not exist in the NonSerializableFactory map */ @@ -113,6 +113,19 @@ if( wrapperMap.remove(key) == null ) throw new NameNotFoundException(key+" was not found in the NonSerializableFactory map"); } + /** Remove a binding from the NonSerializableFactory map. + + @param name, the name for the key into NonSerializableFactory map to remove. + The key is obtained as name.toString(). + @throws NameNotFoundException, thrown if key does not exist in the + NonSerializableFactory map + */ + public static void unbind(Name name) throws NameNotFoundException + { + String key = name.toString(); + if( wrapperMap.remove(key) == null ) + throw new NameNotFoundException(key+" was not found in the NonSerializableFactory map"); + } /** Lookup a value from the NonSerializableFactory map. @return the object bound to key is one exists, null otherwise. @@ -122,6 +135,15 @@ Object value = wrapperMap.get(key); return value; } + /** Lookup a value from the NonSerializableFactory map. + @return the object bound to key is one exists, null otherwise. + */ + public static Object lookup(Name name) + { + String key = name.toString(); + Object value = wrapperMap.get(key); + return value; + } /** A convience method that simplifies the process of rebinding a non-zerializable object into a JNDI context. @@ -142,6 +164,24 @@ Reference memoryRef = new Reference(className, addr, factory, null); ctx.rebind(key, memoryRef); } + + /** A convience method that simplifies the process of rebinding a + non-zerializable object into a JNDI context. This version binds the + target object into the default IntitialContext using name path. + + @param name, the name to use as JNDI path name. The key into the + NonSerializableFactory map is obtained from the toString() value of name. + The name parameter cannot be a 0 length name. + Any subcontexts between the root and the name. + @param target, the non-Serializable object to bind. + @throws NamingException, thrown on failure to rebind key into ctx. + */ + public static synchronized void rebind(Name name, Object target) throws NamingException + { + String key = name.toString(); + InitialContext ctx = new InitialContext(); + rebind(ctx, key, target); + } // --- Begin ObjectFactory interface methods /** Transform the obj Reference bound into the JNDI namespace into the
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
