org.ow2.carol.cmi.jndi.context
Class CMIContext

java.lang.Object
  extended by org.ow2.carol.cmi.jndi.context.CMIContext
All Implemented Interfaces:
javax.naming.Context

@NotThreadSafe
public final class CMIContext
extends java.lang.Object
implements javax.naming.Context

The CMI context intercepts the accesses to JNDI and delegates the management of cluster view at an instance of ClusterViewManager which is a singleton. An instance of CMIContext is relative at a protocol. Instances owned by a server must have a local registry to perform operations such a bind.

Author:
The new CMI team
See Also:
ClusterViewManager

Field Summary
 
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
CMIContext(java.util.List<org.ow2.carol.cmi.reference.ServerRef> remoteRegistries, java.lang.String protocol, java.lang.String initialContextFactoryName)
          Constructs a new CMI context from a given environment.
CMIContext(org.ow2.carol.cmi.reference.ServerRef localRegistry, java.lang.String initialContextFactoryName, boolean replicationEnabled)
          Constructs a new CMI context from a given environment.
 
Method Summary
 java.lang.Object addToEnvironment(java.lang.String propName, java.lang.Object propVal)
          Adds a new environment property to the environment of this context.
 void bind(javax.naming.Name name, java.lang.Object obj)
          Bind a new clustered object.
 void bind(java.lang.String name, java.lang.Object obj)
          Bind a new clustered object.
 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)
           
 void destroySubcontext(javax.naming.Name name)
           
 void destroySubcontext(java.lang.String name)
           
 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<javax.naming.NameClassPair> list(javax.naming.Name name)
           
 javax.naming.NamingEnumeration<javax.naming.NameClassPair> list(java.lang.String name)
           
 javax.naming.NamingEnumeration<javax.naming.Binding> listBindings(javax.naming.Name name)
           
 javax.naming.NamingEnumeration<javax.naming.Binding> listBindings(java.lang.String name)
           
 java.lang.Object lookup(javax.naming.Name name)
          Looks up an object.
 java.lang.Object lookup(java.lang.String name)
          Looks up an object.
 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 obj)
           
 void rebind(java.lang.String name, java.lang.Object obj)
           
 void register()
          Registers this context in the associated instance of ServerClusterViewManager.
 java.lang.Object removeFromEnvironment(java.lang.String propName)
           
 void rename(javax.naming.Name oldName, javax.naming.Name newName)
           
 void rename(java.lang.String oldName, java.lang.String newName)
           
 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, toString, wait, wait, wait
 

Constructor Detail

CMIContext

public CMIContext(java.util.List<org.ow2.carol.cmi.reference.ServerRef> remoteRegistries,
                  java.lang.String protocol,
                  java.lang.String initialContextFactoryName)
           throws CMINamingException
Constructs a new CMI context from a given environment. Clients must call this constructor.

Parameters:
remoteRegistries - a list of references on remote registries to perform lookups
protocol - the protocol associated (JRMP, IRMI or IIOP)
initialContextFactoryName - a factory to construct real contexts
Throws:
CMINamingException - if the default LB policy for access to JNDI cannot be retrieved
See Also:
which contructs this

CMIContext

public CMIContext(org.ow2.carol.cmi.reference.ServerRef localRegistry,
                  java.lang.String initialContextFactoryName,
                  boolean replicationEnabled)
           throws CMINamingException
Constructs a new CMI context from a given environment. Servers must call it.

Parameters:
localRegistry - a reference on a local registry to perform binds
initialContextFactoryName - a factory to construct real contexts
replicationEnabled - true to use the manager of the cluster view
Throws:
CMINamingException - if the default LB policy for access to JNDI cannot be retrieved or if the instance of ServerClusterViewManager cannot be retrieved (when replication is enabled)
See Also:
which contruct this
Method Detail

addToEnvironment

public java.lang.Object addToEnvironment(java.lang.String propName,
                                         java.lang.Object propVal)
                                  throws javax.naming.NamingException
Adds a new environment property to the environment of this context. If the property already exists, its value is overwritten.

Specified by:
addToEnvironment in interface javax.naming.Context
Parameters:
propName - the name of the environment property to add; may not be null
propVal - the value of the property to add; may not be null
Returns:
the previous value of the property, or null if the property was not in the environment before
Throws:
CMINamingException - if a naming exception is encountered.
javax.naming.NamingException

bind

public void bind(javax.naming.Name name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Bind a new clustered object.

Specified by:
bind in interface javax.naming.Context
Parameters:
name - The name to bind; may not be empty.
obj - The object to bind; possibly null.
Throws:
CMINamingException - if a naming exception is encountered.
javax.naming.NamingException

bind

public void bind(java.lang.String name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Bind a new clustered object.

Specified by:
bind in interface javax.naming.Context
Parameters:
name - The name to bind; may not be empty.
obj - The object to bind; possibly null.
Throws:
CMINamingException - if a naming exception is encountered.
javax.naming.NamingException

close

public void close()
           throws javax.naming.NamingException
Specified by:
close 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)
                             throws javax.naming.NamingException
Specified by:
composeName 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

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

destroySubcontext

public void destroySubcontext(javax.naming.Name name)
                       throws javax.naming.NamingException
Specified by:
destroySubcontext 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

getEnvironment

public java.util.Hashtable<?,?> getEnvironment()
                                        throws javax.naming.NamingException
Specified by:
getEnvironment in interface javax.naming.Context
Throws:
javax.naming.NamingException

getNameInNamespace

public java.lang.String getNameInNamespace()
                                    throws javax.naming.NamingException
Specified by:
getNameInNamespace 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

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

list

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

list

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

listBindings

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

listBindings

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

lookup

public java.lang.Object lookup(javax.naming.Name name)
                        throws javax.naming.NamingException
Looks up an object.

Specified by:
lookup in interface javax.naming.Context
Parameters:
name - the name of the object to look up.
Returns:
A CMI proxy if CMI is activated, the bound object otherwise.
Throws:
javax.naming.NamingException - if a naming exception is encountered.

lookup

public java.lang.Object lookup(java.lang.String name)
                        throws javax.naming.NamingException
Looks up an object.

Specified by:
lookup in interface javax.naming.Context
Parameters:
name - the name of the object to look up.
Returns:
A CMI proxy if CMI is activated, the bound object otherwise.
Throws:
javax.naming.NamingException - if a naming exception is encountered.

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

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

rebind

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

rebind

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

removeFromEnvironment

public java.lang.Object removeFromEnvironment(java.lang.String propName)
                                       throws javax.naming.NamingException
Specified by:
removeFromEnvironment 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

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

unbind

public void unbind(javax.naming.Name name)
            throws javax.naming.NamingException
Specified by:
unbind 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

register

public void register()
              throws CMIContextException
Registers this context in the associated instance of ServerClusterViewManager.

Throws:
CMIContextException - if this context is associated with an instance of ClientClusterViewManager


Copyright © 2008 OW2 Consortium. All Rights Reserved.