tyrex.naming
Class MemoryContext

java.lang.Object
  extended bytyrex.naming.MemoryContext
All Implemented Interfaces:
javax.naming.Context

public class MemoryContext
extends java.lang.Object
implements javax.naming.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.

Version:
$Revision: 1.10 $ $Date: 2001/03/19 17:39:00 $
Author:
Assaf Arkin
See Also:
MemoryContextFactory

Field Summary
static javax.naming.NameParser DefaultNameParser
          The default name parser for this context.
static java.lang.String NameSeparator
          The default name separator for this context is '/'.
static java.lang.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(java.util.Hashtable env)
          Construct a new context with the specified environment attributes.
(package private) MemoryContext(MemoryBinding bindings, java.util.Hashtable env)
          Construct a new context with the specified bindings and environment attributes.
 
Method Summary
 java.lang.Object addToEnvironment(java.lang.String name, java.lang.Object value)
           
 void bind(javax.naming.Name name, java.lang.Object value)
           
 void bind(java.lang.String name, java.lang.Object value)
           
 void close()
           
 javax.naming.Name composeName(javax.naming.Name name, javax.naming.Name prefix)
           
 java.lang.String composeName(java.lang.String name, java.lang.String prefix)
           
 javax.naming.Context createSubcontext(javax.naming.Name name)
           
 javax.naming.Context createSubcontext(java.lang.String name)
           
(package private)  void debug(java.io.PrintWriter writer)
           
 void destroySubcontext(javax.naming.Name name)
           
 void destroySubcontext(java.lang.String name)
           
 MemoryBinding getBindings()
          Returns the bindings represented by this context.
 java.util.Hashtable getEnvironment()
           
 java.lang.String getNameInNamespace()
           
 javax.naming.NameParser getNameParser(javax.naming.Name name)
           
 javax.naming.NameParser getNameParser(java.lang.String name)
           
 javax.naming.NamingEnumeration list(javax.naming.Name name)
           
 javax.naming.NamingEnumeration list(java.lang.String name)
           
 javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
           
 javax.naming.NamingEnumeration listBindings(java.lang.String name)
           
 java.lang.Object lookup(javax.naming.Name name)
           
 java.lang.Object lookup(java.lang.String name)
           
 java.lang.Object lookupLink(javax.naming.Name name)
           
 java.lang.Object lookupLink(java.lang.String name)
           
 void rebind(javax.naming.Name name, java.lang.Object value)
           
 void rebind(java.lang.String name, java.lang.Object value)
           
 java.lang.Object removeFromEnvironment(java.lang.String name)
           
 void rename(javax.naming.Name oldName, javax.naming.Name newName)
           
 void rename(java.lang.String oldName, java.lang.String newName)
           
 java.lang.String toString()
           
 void unbind(javax.naming.Name name)
           
 void unbind(java.lang.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 java.lang.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 java.lang.String NameSeparator
The default name separator for this context is '/'.

See Also:
Constant Field Values

DefaultNameParser

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

Constructor Detail

MemoryContext

public MemoryContext(java.util.Hashtable env)
              throws javax.naming.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:
javax.naming.NotContextException - The attribute Context.PROVIDER_URL does not specify a context
javax.naming.InvalidNameException - The attribute Context.PROVIDER_URL is an invalid name
javax.naming.NamingException

MemoryContext

MemoryContext(MemoryBinding bindings,
              java.util.Hashtable env)
Construct a new context with the specified bindings and environment attributes.

Method Detail

lookup

public java.lang.Object lookup(java.lang.String name)
                        throws javax.naming.NamingException
Specified by:
lookup in interface javax.naming.Context
Throws:
javax.naming.NamingException

lookup

public java.lang.Object lookup(javax.naming.Name name)
                        throws javax.naming.NamingException
Specified by:
lookup in interface javax.naming.Context
Throws:
javax.naming.NamingException

lookupLink

public java.lang.Object lookupLink(java.lang.String name)
                            throws javax.naming.NamingException
Specified by:
lookupLink in interface javax.naming.Context
Throws:
javax.naming.NamingException

lookupLink

public java.lang.Object lookupLink(javax.naming.Name name)
                            throws javax.naming.NamingException
Specified by:
lookupLink in interface javax.naming.Context
Throws:
javax.naming.NamingException

bind

public void bind(java.lang.String name,
                 java.lang.Object value)
          throws javax.naming.NamingException
Specified by:
bind in interface javax.naming.Context
Throws:
javax.naming.NamingException

bind

public void bind(javax.naming.Name name,
                 java.lang.Object value)
          throws javax.naming.NamingException
Specified by:
bind in interface javax.naming.Context
Throws:
javax.naming.NamingException

rebind

public void rebind(java.lang.String name,
                   java.lang.Object value)
            throws javax.naming.NamingException
Specified by:
rebind in interface javax.naming.Context
Throws:
javax.naming.NamingException

rebind

public void rebind(javax.naming.Name name,
                   java.lang.Object value)
            throws javax.naming.NamingException
Specified by:
rebind in interface javax.naming.Context
Throws:
javax.naming.NamingException

unbind

public void unbind(java.lang.String name)
            throws javax.naming.NamingException
Specified by:
unbind in interface javax.naming.Context
Throws:
javax.naming.NamingException

unbind

public void unbind(javax.naming.Name name)
            throws javax.naming.NamingException
Specified by:
unbind in interface javax.naming.Context
Throws:
javax.naming.NamingException

rename

public void rename(java.lang.String oldName,
                   java.lang.String newName)
            throws javax.naming.NamingException
Specified by:
rename in interface javax.naming.Context
Throws:
javax.naming.NamingException

rename

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

list

public javax.naming.NamingEnumeration list(java.lang.String name)
                                    throws javax.naming.NamingException
Specified by:
list in interface javax.naming.Context
Throws:
javax.naming.NamingException

list

public javax.naming.NamingEnumeration list(javax.naming.Name name)
                                    throws javax.naming.NamingException
Specified by:
list in interface javax.naming.Context
Throws:
javax.naming.NamingException

listBindings

public javax.naming.NamingEnumeration listBindings(java.lang.String name)
                                            throws javax.naming.NamingException
Specified by:
listBindings in interface javax.naming.Context
Throws:
javax.naming.NamingException

listBindings

public javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
                                            throws javax.naming.NamingException
Specified by:
listBindings in interface javax.naming.Context
Throws:
javax.naming.NamingException

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name)
                                      throws javax.naming.NamingException
Specified by:
createSubcontext in interface javax.naming.Context
Throws:
javax.naming.NamingException

createSubcontext

public javax.naming.Context createSubcontext(javax.naming.Name name)
                                      throws javax.naming.NamingException
Specified by:
createSubcontext in interface javax.naming.Context
Throws:
javax.naming.NamingException

destroySubcontext

public void destroySubcontext(java.lang.String name)
                       throws javax.naming.NamingException
Specified by:
destroySubcontext in interface javax.naming.Context
Throws:
javax.naming.NamingException

destroySubcontext

public void destroySubcontext(javax.naming.Name name)
                       throws javax.naming.NamingException
Specified by:
destroySubcontext in interface javax.naming.Context
Throws:
javax.naming.NamingException

getNameParser

public javax.naming.NameParser getNameParser(java.lang.String name)
                                      throws javax.naming.NamingException
Specified by:
getNameParser in interface javax.naming.Context
Throws:
javax.naming.NamingException

getNameParser

public javax.naming.NameParser getNameParser(javax.naming.Name name)
                                      throws javax.naming.NamingException
Specified by:
getNameParser in interface javax.naming.Context
Throws:
javax.naming.NamingException

composeName

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

composeName

public java.lang.String composeName(java.lang.String name,
                                    java.lang.String prefix)
Specified by:
composeName in interface javax.naming.Context

getNameInNamespace

public java.lang.String getNameInNamespace()
                                    throws javax.naming.NamingException
Specified by:
getNameInNamespace in interface javax.naming.Context
Throws:
javax.naming.NamingException

addToEnvironment

public java.lang.Object addToEnvironment(java.lang.String name,
                                         java.lang.Object value)
                                  throws javax.naming.NamingException
Specified by:
addToEnvironment in interface javax.naming.Context
Throws:
javax.naming.NamingException

getEnvironment

public java.util.Hashtable getEnvironment()
Specified by:
getEnvironment in interface javax.naming.Context

removeFromEnvironment

public java.lang.Object removeFromEnvironment(java.lang.String name)
Specified by:
removeFromEnvironment in interface javax.naming.Context

close

public void close()
Specified by:
close in interface javax.naming.Context

toString

public java.lang.String toString()

getBindings

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


debug

void debug(java.io.PrintWriter writer)


Original code is Copyright (c) 1999-2001, Intalio, Inc. All Rights Reserved. Contributions by MetaBoss team are Copyright (c) 2003-2005, Softaris Pty. Ltd. All Rights Reserved.