org.apache.yoko.orb.CosNaming
Class NamingContextBase

java.lang.Object
  extended by org.omg.PortableServer.Servant
      extended by org.omg.CosNaming.NamingContextExtPOA
          extended by org.apache.yoko.orb.CosNaming.NamingContextBase
All Implemented Interfaces:
InvokeHandler, NamingContextExtOperations, NamingContextOperations
Direct Known Subclasses:
TransientNamingContext

public abstract class NamingContextBase
extends NamingContextExtPOA


Field Summary
protected static Logger logger
           
protected  String nonEscaped
           
protected  ORB orb
           
protected  POA poa
           
 
Constructor Summary
NamingContextBase(ORB orb, POA poa)
          Create a new base NamingContext (super class constructor for the derived classes).
 
Method Summary
 void bind_context(NameComponent[] n, NamingContext nc)
          Bind a new context to a given name.
 NamingContext bind_new_context(NameComponent[] n)
          Create a new context and bind it in at the target location.
 void bind(NameComponent[] n, Object obj)
          Bind an object to a given name.
protected abstract  void bindObject(NameComponent n, Object obj, BindingTypeHolder type)
          Bind an object into the current context.
protected  void debug(String message)
          Log a line of debug output
abstract  void destroy()
          Destroy a context.
protected  String encodeRFC2396Name(String name)
          Perform RFC 2396 escape encoding of a name value.
protected  void escapeName(String name, StringBuffer out)
          Process a name or kind element of a NameComponent, adding escape characters for '.' or '/' characters that might appear in the name.
protected  NameComponent[] extractSubName(NameComponent[] name)
          Extract the tail portion of a name.
protected  boolean isDebugEnabled()
          Test if debug logging is currently available.
abstract  void list(int how_many, BindingListHolder bl, BindingIteratorHolder bi)
          Create a list of bound objects an contexts contained within this context.
protected  void logNameComponent(String message, NameComponent[] n)
          Log the name components passed in for a request.
protected  void nameToString(NameComponent name, StringBuffer out)
          Convert a NameComponent item into a string form, appending it to a StringBuffer.
abstract  NamingContext new_context()
          Create a new context of the same type as the calling context.
 void rebind_context(NameComponent[] n, NamingContext nc)
          Rebind a context to a given name.
 void rebind(NameComponent[] n, Object obj)
          Rebind an object to a given name.
 Object resolve_str(String n)
          Resolve a bound object or context using a name in String form.
 Object resolve(NameComponent[] n)
          Resolve an an entry in the context tree.
protected  NamingContext resolveContext(NameComponent name)
          Resolve a name to a context object stored that has already been stored in this context.
protected abstract  Object resolveObject(NameComponent n, BindingTypeHolder type)
          Resolve an object in this context (single level resolution).
 NameComponent[] to_name(String sn)
          Perform the reverse operation of the to_string() method, parsing a String context name into an array of NameComponents.
 String to_string(NameComponent[] n)
          Convert an array of NameComponents into the string form of a context name.
 String to_url(String addr, String sn)
          Create a URL name for accessing a component by name.
 void unbind(NameComponent[] n)
          Remove an entry from the context tree.
protected abstract  Object unbindObject(NameComponent n)
          Unbind an object from the current context.
protected  void validateName(NameComponent[] n)
          Perform common name validity checking.
 
Methods inherited from class org.omg.CosNaming.NamingContextExtPOA
_all_interfaces, _invoke, _this, _this
 
Methods inherited from class org.omg.PortableServer.Servant
_default_POA, _get_delegate, _get_interface_def, _get_interface, _is_a, _non_existent, _object_id, _orb, _poa, _set_delegate, _this_object, _this_object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Logger logger

nonEscaped

protected final String nonEscaped
See Also:
Constant Field Values

orb

protected ORB orb

poa

protected POA poa
Constructor Detail

NamingContextBase

public NamingContextBase(ORB orb,
                         POA poa)
                  throws Exception
Create a new base NamingContext (super class constructor for the derived classes).

Parameters:
orb - The ORB this is hosted on.
Throws:
Exception
Method Detail

bind

public void bind(NameComponent[] n,
                 Object obj)
          throws NotFound,
                 CannotProceed,
                 InvalidName,
                 AlreadyBound
Bind an object to a given name.

Parameters:
n - An array of NameComponents that are the target name. The last element in the array is binding name for the object. The remainder of the array is the path for resolving the naming context, relative to the current context. All path contexts must already be bound in the context tree.
obj - The object to be bound.
Throws:
NotFound
CannotProceed
InvalidName
AlreadyBound

rebind

public void rebind(NameComponent[] n,
                   Object obj)
            throws NotFound,
                   CannotProceed,
                   InvalidName
Rebind an object to a given name. If an object is already bound with this name, the new object replaces the bound object's value. If no object has been bound already, this is the same as a bind operation.

Parameters:
n - An array of NameComponents that are the target name. The last element in the array is binding name for the object. The remainder of the array is the path for resolving the naming context, relative to the current context. All path contexts must already be bound in the context tree.
obj - The new value for this binding.
Throws:
NotFound
CannotProceed
InvalidName
AlreadyBound

bind_context

public void bind_context(NameComponent[] n,
                         NamingContext nc)
                  throws NotFound,
                         CannotProceed,
                         InvalidName,
                         AlreadyBound
Bind a new context to a given name.

Parameters:
n - An array of NameComponents that are the target name. The last element in the array is binding name for the object. The remainder of the array is the path for resolving the naming context, relative to the current context. All path contexts must already be bound in the context tree.
nc - The new naming context added to the tree.
Throws:
NotFound
CannotProceed
InvalidName
AlreadyBound

rebind_context

public void rebind_context(NameComponent[] n,
                           NamingContext nc)
                    throws NotFound,
                           CannotProceed,
                           InvalidName
Rebind a context to a given name. If a context is already bound with this name, the new context replaces the existing context. If no context has been bound already, this is the same as a bind operation.

Parameters:
n - An array of NameComponents that are the target name. The last element in the array is binding name for the object. The remainder of the array is the path for resolving the naming context, relative to the current context. All path contexts must already be bound in the context tree.
nc - The new context to be bound with the name.
Throws:
NotFound
CannotProceed
InvalidName
AlreadyBound

resolve

public Object resolve(NameComponent[] n)
               throws NotFound,
                      CannotProceed,
                      InvalidName
Resolve an an entry in the context tree. The resolved object may be a bound object or another NamingContext. If the named entry is not found, a NotFound exception is thrown.

Parameters:
n - An array of NameComponents that are the target name. The last element in the array is binding name for the object. The remainder of the array is the path for resolving the naming context, relative to the current context. All path contexts must already be bound in the context tree.
Returns:
The object bound at the indicated location.
Throws:
NotFound
CannotProceed
InvalidName
AlreadyBound

unbind

public void unbind(NameComponent[] n)
            throws NotFound,
                   CannotProceed,
                   InvalidName
Remove an entry from the context tree. The target object may be a bound object or another NamingContext. If the named entry is not found, a NotFound exception is thrown.

Parameters:
n - An array of NameComponents that are the target name. The last element in the array is binding name for the object. The remainder of the array is the path for resolving the naming context, relative to the current context. All path contexts must already be bound in the context tree.
Throws:
NotFound
CannotProceed
InvalidName
AlreadyBound

bind_new_context

public NamingContext bind_new_context(NameComponent[] n)
                               throws NotFound,
                                      AlreadyBound,
                                      CannotProceed,
                                      InvalidName
Create a new context and bind it in at the target location.

Parameters:
n - An array of NameComponents that are the target name. The last element in the array is binding name for the object. The remainder of the array is the path for resolving the naming context, relative to the current context. All path contexts must already be bound in the context tree.
Returns:
The newly created context.
Throws:
NotFound
CannotProceed
InvalidName
AlreadyBound

to_string

public String to_string(NameComponent[] n)
                 throws InvalidName
Convert an array of NameComponents into the string form of a context name.

Parameters:
n - The array of NameComponents to convert.
Returns:
The context name, in string form.
Throws:
InvalidName

to_name

public NameComponent[] to_name(String sn)
                        throws InvalidName
Perform the reverse operation of the to_string() method, parsing a String context name into an array of NameComponents.

Parameters:
sn - The string form of the name.
Returns:
An array of NameComponents parsed from the String name.
Throws:
InvalidName

to_url

public String to_url(String addr,
                     String sn)
              throws InvalidAddress,
                     InvalidName
Create a URL name for accessing a component by name. The URL will have a corbaname: protocol.

Parameters:
addr - The address location for the naming service used to resolve the object. This is in "host:port" form, just line a corbaloc: URL.
sn - The string mae of the target object.
Returns:
A URL for accessing this object, in String form.
Throws:
InvalidAddress
InvalidName

resolve_str

public Object resolve_str(String n)
                   throws NotFound,
                          CannotProceed,
                          InvalidName
Resolve a bound object or context using a name in String form.

Parameters:
n - The string name of the object context. This must be a form parseable by to_name().
Returns:
The bound object or context.
Throws:
NotFound
CannotProceed
InvalidName

new_context

public abstract NamingContext new_context()
                                   throws SystemException
Create a new context of the same type as the calling context.

Returns:
A new NamingContext item.
Throws:
NotFound
SystemException

destroy

public abstract void destroy()
                      throws NotEmpty
Destroy a context. This method should clean up any backing resources associated with the context.

Throws:
NotEmpty

list

public abstract void list(int how_many,
                          BindingListHolder bl,
                          BindingIteratorHolder bi)
                   throws SystemException
Create a list of bound objects an contexts contained within this context.

Parameters:
how_many - The count of elements to return as a BindingList.
bl - A holder element for returning the source binding list.
bi - A holder for returning a BindingIterator. Any extra elements not returned in the BindingList are returned in the BindingIterator.
Throws:
SystemException

resolveObject

protected abstract Object resolveObject(NameComponent n,
                                        BindingTypeHolder type)
                                 throws SystemException
Resolve an object in this context (single level resolution).

Parameters:
n - The name of the target object.
type - A type holder for returning the bound object type information.
Returns:
The bound object. Returns null if the object does not exist in the context.
Throws:
SystemException

bindObject

protected abstract void bindObject(NameComponent n,
                                   Object obj,
                                   BindingTypeHolder type)
                            throws SystemException
Bind an object into the current context. This can be either an object or a naming context.

Parameters:
n - The single-level name of the target object.
obj - The object or context to be bound.
type -
Throws:
SystemException

unbindObject

protected abstract Object unbindObject(NameComponent n)
                                throws SystemException
Unbind an object from the current context.

Parameters:
n - The name of the target object (single level).
Returns:
The object associated with the binding. Returns null if there was no binding currently associated with this name.
Throws:
SystemException

resolveContext

protected NamingContext resolveContext(NameComponent name)
                                throws NotFound
Resolve a name to a context object stored that has already been stored in this context. Throws an exception if the name cannot be resolved or if the resolved object is not a naming context.

Parameters:
name - The target name.
Returns:
The resolved NamingContext object.
Throws:
NotFound

extractSubName

protected NameComponent[] extractSubName(NameComponent[] name)
Extract the tail portion of a name. This is used to strip off the first name element so we can recurse on the name resolutions with a resolved context.

Parameters:
name - The current name array (this MUST have 2 or more elements).
Returns:
An array of NameComponent items that is one element smaller than the argument array, with the elements shifted over.

validateName

protected void validateName(NameComponent[] n)
                     throws InvalidName
Perform common name validity checking.

Parameters:
n - The NameComponent array to check.
Throws:
InvalidName

nameToString

protected void nameToString(NameComponent name,
                            StringBuffer out)
Convert a NameComponent item into a string form, appending it to a StringBuffer.

Parameters:
name - The source NameComponent.
out - The StringBuffer location used to store the name value (appended to the end).

escapeName

protected void escapeName(String name,
                          StringBuffer out)
Process a name or kind element of a NameComponent, adding escape characters for '.' or '/' characters that might appear in the name.

Parameters:
name - The name element to process.
out - The StringBuffer to copy the escaped name into.

encodeRFC2396Name

protected String encodeRFC2396Name(String name)
Perform RFC 2396 escape encoding of a name value.

Parameters:
name - The input name value.
Returns:
An encoded name, with special characters converted into a hex encoded value.

isDebugEnabled

protected boolean isDebugEnabled()
Test if debug logging is currently available.

Returns:
True if debug level (FINE) logging is currently turned on.

debug

protected void debug(String message)
Log a line of debug output

Parameters:
message - The message to log

logNameComponent

protected void logNameComponent(String message,
                                NameComponent[] n)
Log the name components passed in for a request.

Parameters:
message - A message describing the request context.
n - The array of name components.


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.