org.apache.tuscany.sca.host.corba.naming
Class NamingContextBase

java.lang.Object
  extended by org.omg.PortableServer.Servant
      extended by org.omg.CosNaming.NamingContextExtPOA
          extended by org.apache.tuscany.sca.host.corba.naming.NamingContextBase
All Implemented Interfaces:
org.omg.CORBA.portable.InvokeHandler, org.omg.CosNaming.NamingContextExtOperations, org.omg.CosNaming.NamingContextOperations
Direct Known Subclasses:
TransientNamingContext

public abstract class NamingContextBase
extends org.omg.CosNaming.NamingContextExtPOA


Field Summary
protected static java.util.logging.Logger logger
           
protected  java.lang.String nonEscaped
           
protected  org.omg.CORBA.ORB orb
           
protected  org.omg.PortableServer.POA poa
           
 
Constructor Summary
NamingContextBase(org.omg.CORBA.ORB orb, org.omg.PortableServer.POA poa)
          Create a new base NamingContext (super class constructor for the derived classes).
 
Method Summary
 void bind_context(org.omg.CosNaming.NameComponent[] n, org.omg.CosNaming.NamingContext nc)
          Bind a new context to a given name.
 org.omg.CosNaming.NamingContext bind_new_context(org.omg.CosNaming.NameComponent[] n)
          Create a new context and bind it in at the target location.
 void bind(org.omg.CosNaming.NameComponent[] n, org.omg.CORBA.Object obj)
          Bind an object to a given name.
protected abstract  void bindObject(org.omg.CosNaming.NameComponent n, org.omg.CORBA.Object obj, org.omg.CosNaming.BindingTypeHolder type)
          Bind an object into the current context.
protected  void debug(java.lang.String message)
          Log a line of debug output
abstract  void destroy()
          Destroy a context.
protected  java.lang.String encodeRFC2396Name(java.lang.String name)
          Perform RFC 2396 escape encoding of a name value.
protected  void escapeName(java.lang.String name, java.lang.StringBuffer out)
          Process a name or kind element of a NameComponent, adding escape characters for '.' or '/' characters that might appear in the name.
protected  org.omg.CosNaming.NameComponent[] extractSubName(org.omg.CosNaming.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, org.omg.CosNaming.BindingListHolder bl, org.omg.CosNaming.BindingIteratorHolder bi)
          Create a list of bound objects an contexts contained within this context.
protected  void logNameComponent(java.lang.String message, org.omg.CosNaming.NameComponent[] n)
          Log the name components passed in for a request.
protected  void nameToString(org.omg.CosNaming.NameComponent name, java.lang.StringBuffer out)
          Convert a NameComponent item into a string form, appending it to a StringBuffer.
abstract  org.omg.CosNaming.NamingContext new_context()
          Create a new context of the same type as the calling context.
 void rebind_context(org.omg.CosNaming.NameComponent[] n, org.omg.CosNaming.NamingContext nc)
          Rebind a context to a given name.
 void rebind(org.omg.CosNaming.NameComponent[] n, org.omg.CORBA.Object obj)
          Rebind an object to a given name.
 org.omg.CORBA.Object resolve_str(java.lang.String n)
          Resolve a bound object or context using a name in String form.
 org.omg.CORBA.Object resolve(org.omg.CosNaming.NameComponent[] n)
          Resolve an an entry in the context tree.
protected  org.omg.CosNaming.NamingContext resolveContext(org.omg.CosNaming.NameComponent name)
          Resolve a name to a context object stored that has already been stored in this context.
protected abstract  org.omg.CORBA.Object resolveObject(org.omg.CosNaming.NameComponent n, org.omg.CosNaming.BindingTypeHolder type)
          Resolve an object in this context (single level resolution).
 org.omg.CosNaming.NameComponent[] to_name(java.lang.String sn)
          Perform the reverse operation of the to_string() method, parsing a String context name into an array of NameComponents.
 java.lang.String to_string(org.omg.CosNaming.NameComponent[] n)
          Convert an array of NameComponents into the string form of a context name.
 java.lang.String to_url(java.lang.String addr, java.lang.String sn)
          Create a URL name for accessing a component by name.
 void unbind(org.omg.CosNaming.NameComponent[] n)
          Remove an entry from the context tree.
protected abstract  org.omg.CORBA.Object unbindObject(org.omg.CosNaming.NameComponent n)
          Unbind an object from the current context.
protected  void validateName(org.omg.CosNaming.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, _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 java.util.logging.Logger logger

nonEscaped

protected final java.lang.String nonEscaped
See Also:
Constant Field Values

orb

protected org.omg.CORBA.ORB orb

poa

protected org.omg.PortableServer.POA poa
Constructor Detail

NamingContextBase

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

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

bind

public void bind(org.omg.CosNaming.NameComponent[] n,
                 org.omg.CORBA.Object obj)
          throws org.omg.CosNaming.NamingContextPackage.NotFound,
                 org.omg.CosNaming.NamingContextPackage.CannotProceed,
                 org.omg.CosNaming.NamingContextPackage.InvalidName,
                 org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.NotFound
org.omg.CosNaming.NamingContextPackage.CannotProceed
org.omg.CosNaming.NamingContextPackage.InvalidName
org.omg.CosNaming.NamingContextPackage.AlreadyBound

rebind

public void rebind(org.omg.CosNaming.NameComponent[] n,
                   org.omg.CORBA.Object obj)
            throws org.omg.CosNaming.NamingContextPackage.NotFound,
                   org.omg.CosNaming.NamingContextPackage.CannotProceed,
                   org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.NotFound
org.omg.CosNaming.NamingContextPackage.CannotProceed
org.omg.CosNaming.NamingContextPackage.InvalidName
org.omg.CosNaming.NamingContextPackage.AlreadyBound

bind_context

public void bind_context(org.omg.CosNaming.NameComponent[] n,
                         org.omg.CosNaming.NamingContext nc)
                  throws org.omg.CosNaming.NamingContextPackage.NotFound,
                         org.omg.CosNaming.NamingContextPackage.CannotProceed,
                         org.omg.CosNaming.NamingContextPackage.InvalidName,
                         org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.NotFound
org.omg.CosNaming.NamingContextPackage.CannotProceed
org.omg.CosNaming.NamingContextPackage.InvalidName
org.omg.CosNaming.NamingContextPackage.AlreadyBound

rebind_context

public void rebind_context(org.omg.CosNaming.NameComponent[] n,
                           org.omg.CosNaming.NamingContext nc)
                    throws org.omg.CosNaming.NamingContextPackage.NotFound,
                           org.omg.CosNaming.NamingContextPackage.CannotProceed,
                           org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.NotFound
org.omg.CosNaming.NamingContextPackage.CannotProceed
org.omg.CosNaming.NamingContextPackage.InvalidName
org.omg.CosNaming.NamingContextPackage.AlreadyBound

resolve

public org.omg.CORBA.Object resolve(org.omg.CosNaming.NameComponent[] n)
                             throws org.omg.CosNaming.NamingContextPackage.NotFound,
                                    org.omg.CosNaming.NamingContextPackage.CannotProceed,
                                    org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.NotFound
org.omg.CosNaming.NamingContextPackage.CannotProceed
org.omg.CosNaming.NamingContextPackage.InvalidName
org.omg.CosNaming.NamingContextPackage.AlreadyBound

unbind

public void unbind(org.omg.CosNaming.NameComponent[] n)
            throws org.omg.CosNaming.NamingContextPackage.NotFound,
                   org.omg.CosNaming.NamingContextPackage.CannotProceed,
                   org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.NotFound
org.omg.CosNaming.NamingContextPackage.CannotProceed
org.omg.CosNaming.NamingContextPackage.InvalidName
org.omg.CosNaming.NamingContextPackage.AlreadyBound

bind_new_context

public org.omg.CosNaming.NamingContext bind_new_context(org.omg.CosNaming.NameComponent[] n)
                                                 throws org.omg.CosNaming.NamingContextPackage.NotFound,
                                                        org.omg.CosNaming.NamingContextPackage.AlreadyBound,
                                                        org.omg.CosNaming.NamingContextPackage.CannotProceed,
                                                        org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.NotFound
org.omg.CosNaming.NamingContextPackage.CannotProceed
org.omg.CosNaming.NamingContextPackage.InvalidName
org.omg.CosNaming.NamingContextPackage.AlreadyBound

to_string

public java.lang.String to_string(org.omg.CosNaming.NameComponent[] n)
                           throws org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.InvalidName

to_name

public org.omg.CosNaming.NameComponent[] to_name(java.lang.String sn)
                                          throws org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.InvalidName

to_url

public java.lang.String to_url(java.lang.String addr,
                               java.lang.String sn)
                        throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress,
                               org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextExtPackage.InvalidAddress
org.omg.CosNaming.NamingContextPackage.InvalidName

resolve_str

public org.omg.CORBA.Object resolve_str(java.lang.String n)
                                 throws org.omg.CosNaming.NamingContextPackage.NotFound,
                                        org.omg.CosNaming.NamingContextPackage.CannotProceed,
                                        org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.NotFound
org.omg.CosNaming.NamingContextPackage.CannotProceed
org.omg.CosNaming.NamingContextPackage.InvalidName

new_context

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

Returns:
A new NamingContext item.
Throws:
org.omg.CosNaming.NamingContextPackage.NotFound
org.omg.CORBA.SystemException

destroy

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

Throws:
org.omg.CosNaming.NamingContextPackage.NotEmpty

list

public abstract void list(int how_many,
                          org.omg.CosNaming.BindingListHolder bl,
                          org.omg.CosNaming.BindingIteratorHolder bi)
                   throws org.omg.CORBA.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:
org.omg.CORBA.SystemException

resolveObject

protected abstract org.omg.CORBA.Object resolveObject(org.omg.CosNaming.NameComponent n,
                                                      org.omg.CosNaming.BindingTypeHolder type)
                                               throws org.omg.CORBA.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:
org.omg.CORBA.SystemException

bindObject

protected abstract void bindObject(org.omg.CosNaming.NameComponent n,
                                   org.omg.CORBA.Object obj,
                                   org.omg.CosNaming.BindingTypeHolder type)
                            throws org.omg.CORBA.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:
org.omg.CORBA.SystemException

unbindObject

protected abstract org.omg.CORBA.Object unbindObject(org.omg.CosNaming.NameComponent n)
                                              throws org.omg.CORBA.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:
org.omg.CORBA.SystemException

resolveContext

protected org.omg.CosNaming.NamingContext resolveContext(org.omg.CosNaming.NameComponent name)
                                                  throws org.omg.CosNaming.NamingContextPackage.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:
org.omg.CosNaming.NamingContextPackage.NotFound

extractSubName

protected org.omg.CosNaming.NameComponent[] extractSubName(org.omg.CosNaming.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(org.omg.CosNaming.NameComponent[] n)
                     throws org.omg.CosNaming.NamingContextPackage.InvalidName
Perform common name validity checking.

Parameters:
n - The NameComponent array to check.
Throws:
org.omg.CosNaming.NamingContextPackage.InvalidName

nameToString

protected void nameToString(org.omg.CosNaming.NameComponent name,
                            java.lang.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(java.lang.String name,
                          java.lang.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 java.lang.String encodeRFC2396Name(java.lang.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(java.lang.String message)
Log a line of debug output

Parameters:
message - The message to log

logNameComponent

protected void logNameComponent(java.lang.String message,
                                org.omg.CosNaming.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.