org.media.naming
Class MemoryContext

java.lang.Object
  |
  +--org.media.naming.MemoryContext
All Implemented Interfaces:
Context

public class MemoryContext
extends Object
implements Context

An in-memory JNDI service provider. Binds objects into a namespace held entirely in memory, supporting serializable, remoteable and local objects. The in-memory service provider is particularly useful for holding resource factories (the JNDI ENC) and exposing run-time services and configuration objects.

An instance of MemoryContext constructed with no environment attribute will use it's namespace and serve as the root of that namespace. Such a namespace is no accessible except through the creating context, and is garbage collected when all such contexts are no longer referenced. If necessary the root context can be duplicated using lookup( "" ).

If the environment attribute Context.PROVIDER_URL is set, the context will reference a node in a namespace shared by all such contexts. That tree is statically held in memory for the life time of the virtual machine.

This class was inspired by the tyrex.naming package from the Tyrex project. All credits for the good stuff should go to Assaf Arkin and the Exolab group, all the bad stuff blame it on me :).

Version:
$Revision: 1.2 $ $Date: 2001/06/04 10:23:21 $
Author:
Remus Pereni
See Also:
MemoryContextFactory

Field Summary
static NameParser DefaultNameParser
          The default name parser for this context.
static String NameSeparator
          The default name separator for this context is '/'.
static String ReadOnly
          Environment attribute to set a context read-only.
 
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 
Constructor Summary
MemoryContext(Hashtable env)
          Construct a new context with the specified environment attributes.
 
Method Summary
 Object addToEnvironment(String name, Object value)
           
 void bind(Name name, Object value)
           
 void bind(String name, Object value)
           
 void close()
           
 Name composeName(Name name, Name prefix)
           
 String composeName(String name, String prefix)
           
 Context createSubcontext(Name name)
           
 Context createSubcontext(String name)
           
 void destroySubcontext(Name name)
           
 void destroySubcontext(String name)
           
 MemoryBinding getBindings()
          Returns the bindings represented by this context.
 Hashtable getEnvironment()
           
 String getNameInNamespace()
           
 NameParser getNameParser(Name name)
           
 NameParser getNameParser(String name)
           
 NamingEnumeration list(Name name)
           
 NamingEnumeration list(String name)
           
 NamingEnumeration listBindings(Name name)
           
 NamingEnumeration listBindings(String name)
           
 Object lookup(Name name)
           
 Object lookup(String name)
           
 Object lookupLink(Name name)
           
 Object lookupLink(String name)
           
 void rebind(Name name, Object value)
           
 void rebind(String name, Object value)
           
 Object removeFromEnvironment(String name)
           
 void rename(Name oldName, Name newName)
           
 void rename(String oldName, String newName)
           
 String toString()
           
 void unbind(Name name)
           
 void unbind(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ReadOnly

public static final String ReadOnly
Environment attribute to set a context read-only. The value must be a string equal to true. Once the context has been set read-only, it cannot be reset to read-write.

See Also:
Constant Field Values

NameSeparator

public static final String NameSeparator
The default name separator for this context is '/'.

See Also:
Constant Field Values

DefaultNameParser

public static final NameParser DefaultNameParser
The default name parser for this context.

Constructor Detail

MemoryContext

public MemoryContext(Hashtable env)
              throws NamingException
Construct a new context with the specified environment attributes. The environment property Context.PROVIDER_URL names the underlying bindings. If the property is absent, the returned context has it's own binding space which is not shared with other contexts created in this manner.

Parameters:
env - The environment attributes
Throws:
NotContextException - The attribute Context.PROVIDER_URL does not specify a context
InvalidNameException - The attribute Context.PROVIDER_URL is an invalid name
NamingException
Method Detail

lookup

public Object lookup(String name)
              throws NamingException
Specified by:
lookup in interface Context
NamingException

lookup

public Object lookup(Name name)
              throws NamingException
Specified by:
lookup in interface Context
NamingException

lookupLink

public Object lookupLink(String name)
                  throws NamingException
Specified by:
lookupLink in interface Context
NamingException

lookupLink

public Object lookupLink(Name name)
                  throws NamingException
Specified by:
lookupLink in interface Context
NamingException

bind

public void bind(String name,
                 Object value)
          throws NamingException
Specified by:
bind in interface Context
NamingException

bind

public void bind(Name name,
                 Object value)
          throws NamingException
Specified by:
bind in interface Context
NamingException

rebind

public void rebind(String name,
                   Object value)
            throws NamingException
Specified by:
rebind in interface Context
NamingException

rebind

public void rebind(Name name,
                   Object value)
            throws NamingException
Specified by:
rebind in interface Context
NamingException

unbind

public void unbind(String name)
            throws NamingException
Specified by:
unbind in interface Context
NamingException

unbind

public void unbind(Name name)
            throws NamingException
Specified by:
unbind in interface Context
NamingException

rename

public void rename(String oldName,
                   String newName)
            throws NamingException
Specified by:
rename in interface Context
NamingException

rename

public void rename(Name oldName,
                   Name newName)
            throws NamingException
Specified by:
rename in interface Context
NamingException

list

public NamingEnumeration list(String name)
                       throws NamingException
Specified by:
list in interface Context
NamingException

list

public NamingEnumeration list(Name name)
                       throws NamingException
Specified by:
list in interface Context
NamingException

listBindings

public NamingEnumeration listBindings(String name)
                               throws NamingException
Specified by:
listBindings in interface Context
NamingException

listBindings

public NamingEnumeration listBindings(Name name)
                               throws NamingException
Specified by:
listBindings in interface Context
NamingException

createSubcontext

public Context createSubcontext(String name)
                         throws NamingException
Specified by:
createSubcontext in interface Context
NamingException

createSubcontext

public Context createSubcontext(Name name)
                         throws NamingException
Specified by:
createSubcontext in interface Context
NamingException

destroySubcontext

public void destroySubcontext(String name)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
NamingException

destroySubcontext

public void destroySubcontext(Name name)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
NamingException

getNameParser

public NameParser getNameParser(String name)
                         throws NamingException
Specified by:
getNameParser in interface Context
NamingException

getNameParser

public NameParser getNameParser(Name name)
                         throws NamingException
Specified by:
getNameParser in interface Context
NamingException

composeName

public Name composeName(Name name,
                        Name prefix)
                 throws NamingException
Specified by:
composeName in interface Context
NamingException

composeName

public String composeName(String name,
                          String prefix)
Specified by:
composeName in interface Context

getNameInNamespace

public String getNameInNamespace()
                          throws NamingException
Specified by:
getNameInNamespace in interface Context
NamingException

addToEnvironment

public Object addToEnvironment(String name,
                               Object value)
                        throws NamingException
Specified by:
addToEnvironment in interface Context
NamingException

getEnvironment

public Hashtable getEnvironment()
Specified by:
getEnvironment in interface Context

removeFromEnvironment

public Object removeFromEnvironment(String name)
Specified by:
removeFromEnvironment in interface Context

close

public void close()
Specified by:
close in interface Context

toString

public String toString()
Overrides:
toString in class Object

getBindings

public MemoryBinding getBindings()
Returns the bindings represented by this context. Used when assigning a memory context into the ENC.



"Copyright © 2000-2002 Internet Multicasting Services, media.org & noLimits Technologies. All Rights Reserved."