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> serverRefs, java.lang.String protocol, java.lang.String initialContextFactoryName)
          Constructs a new CMI context from a given environment.
CMIContext(org.ow2.carol.cmi.reference.ServerRef serverRef, 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> serverRefs,
                  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:
serverRefs - a set of references on server 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 serverRef,
                  java.lang.String initialContextFactoryName,
                  boolean replicationEnabled)
           throws CMINamingException
Constructs a new CMI context from a given environment. Servers must call it.

Parameters:
serverRef - 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 CMINamingException
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.

bind

public void bind(javax.naming.Name name,
                 java.lang.Object obj)
          throws CMINamingException
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.

bind

public void bind(java.lang.String name,
                 java.lang.Object obj)
          throws CMINamingException
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.

close

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

composeName

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

composeName

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

createSubcontext

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

createSubcontext

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

destroySubcontext

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

destroySubcontext

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

getEnvironment

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

getNameInNamespace

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

getNameParser

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

getNameParser

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

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 CMINamingException
Specified by:
lookupLink in interface javax.naming.Context
Throws:
CMINamingException

lookupLink

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

rebind

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

rebind

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

removeFromEnvironment

public java.lang.Object removeFromEnvironment(java.lang.String propName)
                                       throws CMINamingException
Specified by:
removeFromEnvironment in interface javax.naming.Context
Throws:
CMINamingException

rename

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

rename

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

unbind

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

unbind

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

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 © 2007 OW2 Consortium. All Rights Reserved.