|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.naming.NonSerializableFactory
A utility class that allows one to bind a non-serializable object into a
local JNDI context. The binding will only be valid for the lifetime of the
VM in which the JNDI InitialContext lives. An example usage code snippet is:
// The non-Serializable object to bind
Object nonserializable = ...;
// An arbitrary key to use in the StringRefAddr. The best key is the jndi
// name that the object will be bound under.
String key = ...;
// This places nonserializable into the NonSerializableFactory hashmap under key
NonSerializableFactory.rebind(key, nonserializable);
Context ctx = new InitialContext();
// Bind a reference to nonserializable using NonSerializableFactory as the ObjectFactory
String className = nonserializable.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);
Or you can use the rebind(Context, String, Object) convience method to simplify
the number of steps to:
Context ctx = new InitialContext();
// The non-Serializable object to bind
Object nonserializable = ...;
// The jndiName that the object will be bound into ctx with
String jndiName = ...;
// This places nonserializable into the NonSerializableFactory hashmap under key
NonSerializableFactory.rebind(ctx, jndiName, nonserializable);
To unbind the object, use the following code snippet:
new InitialContext().unbind(key);
NonSerializableFactory.unbind(key);
ObjectFactory
,
rebind(Context, String, Object)
Constructor Summary | |
NonSerializableFactory()
|
Method Summary | |
static void |
bind(String key,
Object target)
Place an object into the NonSerializableFactory namespace for subsequent access by getObject. |
Object |
getObjectInstance(Object obj,
Name name,
Context nameCtx,
Hashtable env)
Transform the obj Reference bound into the JNDI namespace into the actual non-Serializable object. |
static Object |
lookup(Name name)
Lookup a value from the NonSerializableFactory map. |
static Object |
lookup(String key)
Lookup a value from the NonSerializableFactory map. |
static void |
rebind(Context ctx,
String key,
Object target)
A convience method that simplifies the process of rebinding a non-zerializable object into a JNDI context. |
static void |
rebind(Name name,
Object target)
A convience method that simplifies the process of rebinding a non-zerializable object into a JNDI context. |
static void |
rebind(Name name,
Object target,
boolean createSubcontexts)
A convience method that simplifies the process of rebinding a non-zerializable object into a JNDI context. |
static void |
rebind(String key,
Object target)
Place or replace an object in the NonSerializableFactory namespce for subsequent access by getObject. |
static void |
unbind(Name name)
Remove a binding from the NonSerializableFactory map. |
static void |
unbind(String key)
Remove a binding from the NonSerializableFactory map. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public NonSerializableFactory()
Method Detail |
public static void bind(String key, Object target) throws NameAlreadyBoundException
NameAlreadyBoundException,
- thrown if key already exists in the
NonSerializableFactory map
NameAlreadyBoundException
public static void rebind(String key, Object target)
public static void unbind(String key) throws NameNotFoundException
NameNotFoundException,
- thrown if key does not exist in the
NonSerializableFactory map
NameNotFoundException
public static void unbind(Name name) throws NameNotFoundException
NameNotFoundException,
- thrown if key does not exist in the
NonSerializableFactory map
NameNotFoundException
public static Object lookup(String key)
public static Object lookup(Name name)
public static void rebind(Context ctx, String key, Object target) throws NamingException
NamingException,
- thrown on failure to rebind key into ctx.
NamingException
public static void rebind(Name name, Object target) throws NamingException
NamingException,
- thrown on failure to rebind key into ctx.
NamingException
public static void rebind(Name name, Object target, boolean createSubcontexts) throws NamingException
NamingException,
- thrown on failure to rebind key into ctx.
NamingException
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception
getObjectInstance
in interface ObjectFactory
Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |