User: starksm
Date: 02/04/08 21:14:13
Modified: src/main/org/jboss/naming Tag: Branch_2_4
NonSerializableFactory.java
Log:
Add additional utility methods
Revision Changes Path
No revision
No revision
1.5.6.3 +44 -27 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.6.2
retrieving revision 1.5.6.3
diff -u -r1.5.6.2 -r1.5.6.3
--- NonSerializableFactory.java 14 Dec 2001 03:22:12 -0000 1.5.6.2
+++ NonSerializableFactory.java 9 Apr 2002 04:14:13 -0000 1.5.6.3
@@ -1,5 +1,5 @@
/*
- * JBoss, the OpenSource EJB server
+ * JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
@@ -65,8 +65,8 @@
@see javax.naming.spi.ObjectFactory
@see #rebind(Context, String, Object)
-@author [EMAIL PROTECTED]
-@version $Revision: 1.5.6.2 $
+@author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>.
+@version $Revision: 1.5.6.3 $
*/
public class NonSerializableFactory implements ObjectFactory
{
@@ -156,38 +156,55 @@
*/
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 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();
- // 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);
- }
+ /** 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 must exist.
+ @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
+ {
+ rebind(name, target, false);
+ }
+
+ /** 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.
+ @param target, the non-Serializable object to bind.
+ @param createSubcontexts, a flag indicating if subcontexts of name should
+ be created if they do not already exist.
+ @throws NamingException, thrown on failure to rebind key into ctx.
+ */
+ public static synchronized void rebind(Name name, Object target,
+ boolean createSubcontexts) throws NamingException
+ {
+ String key = name.toString();
+ InitialContext ctx = new InitialContext();
+ if( createSubcontexts == true && name.size() > 1 )
+ {
+ int size = name.size() - 1;
+ Util.createSubcontext(ctx, name.getPrefix(size));
+ }
+ 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