gnu.javax.naming.giop

Class ContextContinuation

Implemented Interfaces:
Context

public class ContextContinuation
extends Object
implements Context

The context to represent the corba naming service. Being the naming service, the returned context supports creating the subcontexts, forwarding this task to the existing naming service. When listing bindings, it uses the Context.BATCHSIZE property to determine, how many bindings should be returned at once (the process is transparend)

Field Summary

int
DEFAULT_BATCH_SIZE
This number of bindings will be requested from the naming server at once, while the subsequent bindings will be requested via binding iterator one by one.
int
howMany
The batch size for list operations - how many to return at once.

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

ContextContinuation(Object nsObject, Hashtable<K,V> props, ORB anOrb, GiopNamingServiceFactory aFactory)
Creates a new naming context that uses naming service, represented by the given CORBA object.

Method Summary

Object
addToEnvironment(String key, Object value)
Add new environment property to the environment of this context.
void
bind(String name, Object obj)
Give the specified name for the specified object.
void
bind(Name name, Object obj)
Give the specified name for the specified object.
void
close()
Releases all resources, associated with this context.
String
composeName(String name1, String name2)
Not supported
Name
composeName(Name name, Name prefix)
Not supported.
Context
createSubcontext(String subContext)
Creates the new naming subcontext and binds it to the current (this) context.
Context
createSubcontext(Name subContext)
Creates the new naming subcontext and binds it to the current (this) context.
void
destroySubcontext(String subContext)
Removes the naming subcontext from this naming context.
void
destroySubcontext(Name subContext)
Removes the naming subcontext from this naming context.
int
getBatchSize()
Get the batch size from the environment properties.
Hashtable<K,V>
getEnvironment()
Returns the environment, associated with this naming context.
String
getNameInNamespace()
Returs the full name of this naming context.
NameParser
getNameParser(String name)
Not supported.
NameParser
getNameParser(Name name)
Not supported.
NamingEnumeration<T>
list(String name)
Creates and returns the enumeration over the name bindings that are present the given subcontext.
NamingEnumeration<T>
list(Name name)
Creates and returns the enumeration over the name bindings that are present the given subcontext.
NamingEnumeration<T>
listBindings(String name)
Creates and returns the enumeration over the name - object bindings that are present the given subcontext.
NamingEnumeration<T>
listBindings(Name name)
Creates and returns the enumeration over the name - object bindings that are present the given subcontext.
Object
lookup(String name)
Gets the previously named object by name.
Object
lookup(Name name)
Gets the previously named object by name.
Object
lookupLink(String name)
Not supported.
Object
lookupLink(Name name)
Not supported.
void
rebind(String name, Object obj)
Give the specified name for the specified object.
void
rebind(Name name, Object obj)
Give the specified name for the specified object.
Object
removeFromEnvironment(String propName)
Removes the property with the given name from the environment.
void
rename(String oldName, String newName)
Renames the existing binding, removing the existing and giving the new name for the same object.
void
rename(Name oldName, Name newName)
Renames the existing binding, removing the existing and giving the new name for the same object.
NameComponent[]
toGiop(Name name)
Convert the Name into array of the name components, required to the CORBA naming service.
void
unbind(String name)
Removes the name - object mapping from the current context.
void
unbind(Name name)
Removes the name - object mapping from the current context.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

DEFAULT_BATCH_SIZE

public int DEFAULT_BATCH_SIZE
This number of bindings will be requested from the naming server at once, while the subsequent bindings will be requested via binding iterator one by one. Use Context.BATCHSIZE to override the value of this constant.

howMany

public final int howMany
The batch size for list operations - how many to return at once.

Constructor Details

ContextContinuation

public ContextContinuation(Object nsObject,
                           Hashtable<K,V> props,
                           ORB anOrb,
                           GiopNamingServiceFactory aFactory)
Creates a new naming context that uses naming service, represented by the given CORBA object.
Parameters:
nsObject - the naming service object. It must be possible to narrow it into the NamingContextExt.
props - the environment table.
anOrb - the associated ORB. This reference is used during cleanup.
aFactory - parent factory. This reference is used during cleanup.

Method Details

addToEnvironment

public Object addToEnvironment(String key,
                               Object value)
            throws NamingException
Add new environment property to the environment of this context. Both name and value of the new property must not be null. If the property is already defined, is current value is replaced by the propVal.
Specified by:
addToEnvironment in interface Context
Parameters:
key - the name of the new property
value - the value of the new property
Returns:
the previous value of this property or null if the property has not been previously defined
Throws:
NamingException -

bind

public void bind(String name,
                 Object obj)
            throws NamingException
Give the specified name for the specified object. The passed name must not be already bound to some other object.
Specified by:
bind in interface Context
Parameters:
name - the name that will be given to the object (in the scope of this context).
obj - the object being named.
Throws:
NamingException - if the naming operation has failed due other reasons.

bind

public void bind(Name name,
                 Object obj)
            throws NamingException
Give the specified name for the specified object. The passed name must not be already bound to some other object. The components of the name are mapped into the components of the CORBA name.
Specified by:
bind in interface Context
Parameters:
name - the name that will be given to the object (in the scope of this context).
obj - the object being named.
Throws:
NamingException - if the naming operation has failed due other reasons.

close

public void close()
            throws NamingException
Releases all resources, associated with this context. The close() method can be called several times, but after it has been once invoked, it is not allowed to call any other method of this context. This method destroys the ORB, if we have one.
Specified by:
close in interface Context
Throws:
NamingException -

composeName

public String composeName(String name1,
                          String name2)
            throws NamingException
Not supported
Specified by:
composeName in interface Context

composeName

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

createSubcontext

public Context createSubcontext(String subContext)
            throws NamingException
Creates the new naming subcontext and binds it to the current (this) context. The returned object will wrap around the newly created CORBA subcontext
Specified by:
createSubcontext in interface Context
Parameters:
subContext - the name of the new context being created
Returns:
the newly created context, bound to the instance of the context on that the method has been called
Throws:
NamingException -

createSubcontext

public Context createSubcontext(Name subContext)
            throws NamingException
Creates the new naming subcontext and binds it to the current (this) context. The returned object will wrap around the newly created CORBA subcontext
Specified by:
createSubcontext in interface Context
Parameters:
subContext - the name of the new context being created
Returns:
the newly created context, bound to the instance of the context on that the method has been called
Throws:
NamingException -

destroySubcontext

public void destroySubcontext(String subContext)
            throws NamingException
Removes the naming subcontext from this naming context. Returns without action if such subcontext does not exist. The context being destroyed must be empty.
Specified by:
destroySubcontext in interface Context
Parameters:
subContext - the name of the subcontext beig removed.
Throws:
NamingException -

destroySubcontext

public void destroySubcontext(Name subContext)
            throws NamingException
Removes the naming subcontext from this naming context. Returns without action if such subcontext does not exist. The context being destroyed must be empty.
Specified by:
destroySubcontext in interface Context
Parameters:
subContext - the name of the subcontext beig removed.
Throws:
NamingException -

getBatchSize

public int getBatchSize()
Get the batch size from the environment properties. The batch size is used for listing operations.
Returns:
the batch size, or some default value if not specified.

getEnvironment

public Hashtable<K,V> getEnvironment()
            throws NamingException
Returns the environment, associated with this naming context. The returned table should never be modified by the caller. Use addToEnvironment(String,Object) and removeFromEnvironment(String) to modify the environement, if needed.
Specified by:
getEnvironment in interface Context
Returns:
the table, representing the environment of this context
Throws:
NamingException -

getNameInNamespace

public String getNameInNamespace()
            throws NamingException
Returs the full name of this naming context. The returned string is not a JNDI composite name and should not be passed directly to the methods of the naming context. This implementation returns the IOR.
Specified by:
getNameInNamespace in interface Context
Returns:
the full name of this naming context, in its own namespace.
Throws:
NamingException -

getNameParser

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

getNameParser

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

list

public NamingEnumeration<T> list(String name)
            throws NamingException
Creates and returns the enumeration over the name bindings that are present the given subcontext. The enumeration elements have the type of NameClassPair, providing also information about the class of the bound object. The behaviour in the case if the bindings are added or removed later is not defined. The contents of the subcontexts are not included.
Specified by:
list in interface Context
Parameters:
name - the name of the subcontext
Returns:
the enumeration over the names, known for the given subcontext.
Throws:
NamingException -

list

public NamingEnumeration<T> list(Name name)
            throws NamingException
Creates and returns the enumeration over the name bindings that are present the given subcontext. The enumeration elements have the type of NameClassPair, providing also information about the class of the bound object. The behaviour in the case if the bindings are added or removed later is not defined. The contents of the subcontexts are not included.
Specified by:
list in interface Context
Parameters:
name - the name of the subcontext
Returns:
the enumeration over the names, known for the given subcontext.
Throws:
NamingException -

listBindings

public NamingEnumeration<T> listBindings(String name)
            throws NamingException
Creates and returns the enumeration over the name - object bindings that are present the given subcontext. The enumeration elements have the type of Binding, providing also information about the class of the bound object. The behaviour in the case if the bindings are added or removed later is not defined. The contents of the subcontexts are not included.
Specified by:
listBindings in interface Context
Parameters:
name - the name of the subcontext
Returns:
the enumeration over the names, known for the given subcontext.
Throws:
NamingException -

listBindings

public NamingEnumeration<T> listBindings(Name name)
            throws NamingException
Creates and returns the enumeration over the name - object bindings that are present the given subcontext. The enumeration elements have the type of Binding, providing also information about the class of the bound object. The behaviour in the case if the bindings are added or removed later is not defined. The contents of the subcontexts are not included.
Specified by:
listBindings in interface Context
Parameters:
name - the name of the subcontext
Returns:
the enumeration over the names, known for the given subcontext.
Throws:
NamingException -

lookup

public Object lookup(String name)
            throws NamingException
Gets the previously named object by name. If the passed name is empty, the method should return a cloned instance of this naming context.
Specified by:
lookup in interface Context
Parameters:
name - the name of the object being searched in this context
Returns:
the named object
Throws:
NamingException - if the naming fails.

lookup

public Object lookup(Name name)
            throws NamingException
Gets the previously named object by name. If the passed name is empty, the method should return a cloned instance of this naming context.
Specified by:
lookup in interface Context
Parameters:
name - the name of the object being searched in this context
Returns:
the named object

lookupLink

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

lookupLink

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

rebind

public void rebind(String name,
                   Object obj)
            throws NamingException
Give the specified name for the specified object. Unlike bind, this method silently replaces the existing binding for this name, if one exists.
Specified by:
rebind in interface Context
Parameters:
name - the name that will be given to the object (in the scope of this context).
obj - the object being named.
Throws:
NamingException - if the naming operation has failed due other reasons.

rebind

public void rebind(Name name,
                   Object obj)
            throws NamingException
Give the specified name for the specified object. Unlike bind, this method silently replaces the existing binding for this name, if one exists.
Specified by:
rebind in interface Context
Parameters:
name - the name that will be given to the object (in the scope of this context).
obj - the object being named.
Throws:
NamingException - if the naming operation has failed due other reasons.

removeFromEnvironment

public Object removeFromEnvironment(String propName)
            throws NamingException
Removes the property with the given name from the environment. Returns without action if this property is not defined.
Specified by:
removeFromEnvironment in interface Context
Parameters:
propName - the name of the property being removed.
Returns:
the value of the property that has been removed or null if the property was not defined.
Throws:
NamingException -

rename

public void rename(String oldName,
                   String newName)
            throws NamingException
Renames the existing binding, removing the existing and giving the new name for the same object.
Specified by:
rename in interface Context
Parameters:
oldName - the existing name of the known object
newName - the new name of the same object
Throws:
NamingException - if the naming operation has failed due other reasons.

rename

public void rename(Name oldName,
                   Name newName)
            throws NamingException
Renames the existing binding, removing the existing and giving the new name for the same object.
Specified by:
rename in interface Context
Parameters:
oldName - the existing name of the known object
newName - the new name of the same object
Throws:
NamingException - if the naming operation has failed due other reasons.

toGiop

public NameComponent[] toGiop(Name name)
            throws InvalidName
Convert the Name into array of the name components, required to the CORBA naming service. First the string representation is obtained, then it is converted using parsing rules of the CORBA name.
Parameters:
name - then name to convert
Returns:
the converted array of components.

unbind

public void unbind(String name)
            throws NamingException
Removes the name - object mapping from the current context. This method returns without action if the name is not bound to an object in the terminal context, but throws NameNotFoundException if one of the intermadiate contexts does not exist.
Specified by:
unbind in interface Context
Parameters:
name - the name to be removed
Throws:
NamingException - if the naming operation has failed due other reasons.

unbind

public void unbind(Name name)
            throws NamingException
Removes the name - object mapping from the current context. This method returns without action if the name is not bound to an object in the terminal context, but throws NameNotFoundException if one of the intermadiate contexts does not exist.
Specified by:
unbind in interface Context
Parameters:
name - the name to be removed
Throws:
NamingException - if the naming operation has failed due other reasons.

ContextContinuation.java -- handles corbaname: urls Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.