User: starksm
Date: 01/11/09 02:41:00
Modified: src/main/org/jboss/naming Tag: Branch_2_4
NonSerializableFactory.java
Log:
Add a rebind that accepts a Name value
Revision Changes Path
No revision
No revision
1.5.6.1 +50 -4 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.5
retrieving revision 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- NonSerializableFactory.java 2001/03/21 23:07:50 1.5
+++ NonSerializableFactory.java 2001/11/09 10:41:00 1.5.6.1
@@ -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 [EMAIL PROTECTED]
-@version $Revision: 1.5 $
+@author [EMAIL PROTECTED]
+@version $Revision: 1.5.6.1 $
*/
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,7 +113,20 @@
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.
@@ -134,13 +156,37 @@
*/
public static synchronized void rebind(Context ctx, String key, Object target)
throws NamingException
{
- NonSerializableFactory.rebind(key, target);
// Bind a reference to target using NonSerializableFactory as the
ObjectFactory
String className = target.getClass().getName();
String factory = NonSerializableFactory.class.getName();
StringRefAddr addr = new StringRefAddr("nns", key);
Reference memoryRef = new Reference(className, addr, factory, null);
ctx.rebind(key, memoryRef);
+ NonSerializableFactory.rebind(key, target);
+ }
+
+ /** 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 obtain 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();
+ // Bind a reference to target using NonSerializableFactory as the
ObjectFactory
+ String className = target.getClass().getName();
+ String factory = NonSerializableFactory.class.getName();
+ StringRefAddr addr = new StringRefAddr("nns", key);
+ Reference memoryRef = new Reference(className, addr, factory, null);
+ InitialContext ctx = new InitialContext();
+ Util.rebind(ctx, name, memoryRef);
+ NonSerializableFactory.rebind(key, target);
}
// --- Begin ObjectFactory interface methods
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development