com.infoengine.au
Class NamingService

java.lang.Object
  extended bycom.infoengine.au.NamingService
All Implemented Interfaces:
PropertyListener

public class NamingService
extends Object
implements PropertyListener

This class provides a registry that associates Info*Engine services with their network addresses and/or implementation classes. It obtains information from static property files and/or network resources accessed via HTTP or LDAP. Standalone applications should use one of its static factory methods at startup time to initialize the registry.


Field Summary
private  int cacheTTL
           
private static String DEFAULT_NS_NAME
           
private static String DEFAULT_SOCKET_FACTORY
           
private  String directoryProvider
           
private static IEProperties ieProperties
           
private  String localHost
           
private static Hashtable localServices
           
private  String namingServiceName
           
private static String NS_NS
           
private  String propertySource
           
private static String RESOURCE
           
private  ObjectServiceCache serviceCache
           
private  Vector serviceDNs
           
private  String serviceDomainBase
           
private  String serviceName
           
private  String serviceSearchBase
           
private  Hashtable socketFactories
           
private static String VMNAME
           
 
Constructor Summary
protected NamingService()
          Protected constructor.
 
Method Summary
private static NamingService _getInstance()
           
private static NamingService _getInstance(boolean create)
           
private static void _registered()
           
static void addService(String serviceName, ObjectDestination dest)
          Adds an entry to the service registry.
private static Socket createSocket(String serviceName, String host, int port)
           
static Enumeration getAllAddresses(String serviceName)
          Return all of the registry entries associated with a named service.
static Socket getConnection(String serviceName)
          Returns a socket connected to a named service.
static String getDirectoryProvider()
          Returns the URI of the directory service provider currently being used by the naming service.
static String getDomainBase()
          Returns the directory service domain base currently being used by the naming service.
static IEProperties getIEProperties()
          Obtain, and create if necessary, the IEProperties object used by this JVM.
static NamingService getInstance()
          Return the naming service instance most recently created by one of the static factory methods.
private static String getLocalHost()
           
static String getLocalServiceDN(String serviceName)
          Returns the distinguished name of the directory entry registered for a local service.
 Properties getProperties()
          Returns the properties object currently being used by the NamingService instance.
static String getPropertySource()
          Returns the URI specifying the source of the configuration properties currently being used by the naming service.
static String getSearchBase()
          Returns the directory service search base currently being used by the naming service.
static ObjectDestination getService(String serviceName)
          Return one of the registry entries associated with a named service.
private static void getServiceDNs()
          Finds the distinguished names of all directory entries that match the name of this virtual machine.
static Enumeration getServicePropertyNames(String serviceName)
          Returns an enumeration of the service-specific property names defined for a specific service.
static String getVMName()
          Returns the name currently set for this virtual machine.
protected  void initialize(String propPrefix)
          Initializes the naming service instance.
static boolean isLocalService(String dn)
          Determines whether a specific directory distinguished name references a service registered in this virtual machine.
static void main(String[] args)
          When initiated via command line, the naming service operates as a utility that can initiate other programs defined by naming service launch properties.
static NamingService newInstance()
          Return a naming service instance with an uninitialized registry.
static NamingService newInstance(String resource)
          Return a naming service instance providing access to a registry that is initialized from a static properties file and/or a network resource obtained using HTTP or LDAP.
static NamingService newInstance(String serviceName, Properties props)
          Deprecated.  
static NamingService newInstance(String serviceName, String resource)
          Return a naming service instance providing access to a registry that is initialized from a static properties file and/or a network resource obtained using HTTP or LDAP.
static NamingService newInstance(String serviceName, String resource, String[] args)
          Return a naming service instance providing access to a registry that is initialized from a static properties file and/or a network resource obtained using HTTP or LDAP.
 void refreshProperties()
           
static void registerLocalService(String serviceName, String dn)
          Registers a service name and the distinguished name of its directory entry as a local service.
 void reinitialize()
           
static void setGlobalProperties()
          Sets global properties for the VM based upon the VM name.
static void setGlobalProperties(String propPrefix)
          Deprecated.  
private static void setProperties(String[] args, String resource)
          Updates the System Properties object by adding properties defined in a String array plus properties defined in a specified resource.
static void setVMName(String name)
          Set the name of this virtual machine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SOCKET_FACTORY

private static final String DEFAULT_SOCKET_FACTORY
See Also:
Constant Field Values

DEFAULT_NS_NAME

private static final String DEFAULT_NS_NAME
See Also:
Constant Field Values

NS_NS

private static final String NS_NS
See Also:
Constant Field Values

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

VMNAME

private static final String VMNAME
See Also:
Constant Field Values

cacheTTL

private int cacheTTL

directoryProvider

private String directoryProvider

localHost

private String localHost

namingServiceName

private String namingServiceName

propertySource

private String propertySource

serviceCache

private ObjectServiceCache serviceCache

serviceDNs

private Vector serviceDNs

serviceDomainBase

private String serviceDomainBase

serviceSearchBase

private String serviceSearchBase

socketFactories

private Hashtable socketFactories

serviceName

private String serviceName

ieProperties

private static IEProperties ieProperties

localServices

private static Hashtable localServices
Constructor Detail

NamingService

protected NamingService()
Protected constructor. This should be used only by subclasses that really know what they're doing. Other applications and classes should use the static factory methods to obtain naming service instances.

Method Detail

_registered

private static void _registered()

_getInstance

private static NamingService _getInstance()

_getInstance

private static NamingService _getInstance(boolean create)

newInstance

public static NamingService newInstance()
Return a naming service instance with an uninitialized registry.

Returns:
A naming service instance.

newInstance

public static NamingService newInstance(String resource)
                                 throws IOException,
                                        FileNotFoundException,
                                        MalformedURLException,
                                        NamingServiceException
Return a naming service instance providing access to a registry that is initialized from a static properties file and/or a network resource obtained using HTTP or LDAP.

Parameters:
resource - A file pathname or file URL referencing a property file in the local file system, or an HTTP or LDAP URL referencing a network resource containing property definitions.
Returns:
A naming service instance.
Throws:
IOException - if an I/O error prevents properties from being accessed or read.
FileNotFoundException - if a specified property file or network resource does not exist.
MalformedURLException - if an HTTP or LDAP URL has incorrect syntax.
NamingServiceException - if no service-specific properties are defined.

newInstance

public static NamingService newInstance(String serviceName,
                                        String resource)
                                 throws IOException,
                                        FileNotFoundException,
                                        MalformedURLException,
                                        NamingServiceException
Return a naming service instance providing access to a registry that is initialized from a static properties file and/or a network resource obtained using HTTP or LDAP.

Parameters:
serviceName - The name of the naming service itself. This name is used as the prefix of property names defined in a property file or network property resource.
resource - A file pathname or file URL referencing a property file in the local file system, or an HTTP or LDAP URL referencing a network resource containing property definitions.
Returns:
A naming service instance.
Throws:
IOException - if an I/O error prevents properties from being accessed or read.
FileNotFoundException - if a specified property file or network resource does not exist.
MalformedURLException - if an HTTP or LDAP URL has incorrect syntax.
NamingServiceException - if no service-specific properties are defined.

newInstance

public static NamingService newInstance(String serviceName,
                                        String resource,
                                        String[] args)
                                 throws IOException,
                                        FileNotFoundException,
                                        MalformedURLException,
                                        NamingServiceException
Return a naming service instance providing access to a registry that is initialized from a static properties file and/or a network resource obtained using HTTP or LDAP.

Parameters:
serviceName - The name of the naming service itself. This name is used as the prefix of property names defined in a property file or network property resource.
resource - A file pathname or file URL referencing a property file in the local file system, or an HTTP or LDAP URL referencing a network resource containing property definitions.
args - An array of String arguments, usually passed from a command line to the main method of a program.
Returns:
A naming service instance.
Throws:
IOException - if an I/O error prevents properties from being accessed or read.
FileNotFoundException - if a specified property file or network resource does not exist.
MalformedURLException - if an HTTP or LDAP URL has incorrect syntax.
NamingServiceException - if no service-specific properties are defined.

newInstance

public static NamingService newInstance(String serviceName,
                                        Properties props)
                                 throws NamingServiceException
Deprecated.  

Return a naming service instance providing access to a registry that is initialized from a Properties object.

Parameters:
serviceName - The name of the naming service itself. This name is used as the prefix of property names defined in a Properties object.
props - The Properties object from which to initialize the registry.
Returns:
A naming service instance.
Throws:
NamingServiceException - if no service-specific properties are defined.

setVMName

public static void setVMName(String name)
Set the name of this virtual machine. The virtual machine name is used as a key to search the registry for the distinguished name associated with this virtual machine. The distinguished name is used in determining whether services are configured to run in-process or out-of-process. This is accomplished by comparing the distinguished name of the virtual machine against the ptcCoresidentService attribute values registered for a service. If a match is found, the service is configured to run in-process.

Parameters:
name - The new name to set for the virtual machine.

getVMName

public static String getVMName()
Returns the name currently set for this virtual machine.

Returns:
The current name of the virtual machine, or null if a name has not been set.

getInstance

public static NamingService getInstance()
Return the naming service instance most recently created by one of the static factory methods.

Returns:
The most recently created naming service instance.

getDirectoryProvider

public static String getDirectoryProvider()
Returns the URI of the directory service provider currently being used by the naming service. This is usually a URI with a format such as: ldap://hostname

Returns:
The URI of the current directory service provider, or null if a directory service provider is not currently being used.

getSearchBase

public static String getSearchBase()
Returns the directory service search base currently being used by the naming service. This is usually the distinguished name of a directory entry that establishes the root of a subtree containing Info*Engine service entries such as entries describing adapters and task processors.

Returns:
The current directory service search base.

getDomainBase

public static String getDomainBase()
Returns the directory service domain base currently being used by the naming service. This is usually the distinguished name of a directory entry that establishes the root of a subtree containing Info*Engine service entries such as entries describing adapters and task processors. This subtree is comprised of domain entries that use dc (domain component) as their naming attribute.

Returns:
The current directory service domain base.

getPropertySource

public static String getPropertySource()
Returns the URI specifying the source of the configuration properties currently being used by the naming service.

Returns:
The URI of the current configuration properties source.

getServicePropertyNames

public static Enumeration getServicePropertyNames(String serviceName)
Returns an enumeration of the service-specific property names defined for a specific service.

Parameters:
serviceName - The name of the service for which to return property names
Returns:
The enumeration of property names

getService

public static ObjectDestination getService(String serviceName)
                                    throws NamingServiceException
Return one of the registry entries associated with a named service. If a service has more than one registry entry, one is picked at random and returned.

Parameters:
serviceName - The name of the service.
Returns:
The registry entry of the service.
Throws:
NamingServiceException - if the service is unknown or some other exception prevents it from being looked up.

registerLocalService

public static void registerLocalService(String serviceName,
                                        String dn)
Registers a service name and the distinguished name of its directory entry as a local service. A local service is a service that is running in this JVM.

Parameters:
serviceName - The name of the local service.
dn - The distinguished name of the directory entry that describes the service.

getLocalServiceDN

public static String getLocalServiceDN(String serviceName)
Returns the distinguished name of the directory entry registered for a local service.

Parameters:
serviceName - The name of the local service.
Returns:
The distinguished name of the directory entry that describes the service, or null if the service is not registered as a local service.

isLocalService

public static boolean isLocalService(String dn)
                              throws NamingServiceException
Determines whether a specific directory distinguished name references a service registered in this virtual machine.

Parameters:
dn - The distinguished name to test.
Returns:
true if the distinguished references a service registered in this virtual machine.
Throws:
NamingServiceException - if it can not be determined whether or not a distinguished name matches a locally registered service.

getServiceDNs

private static void getServiceDNs()
                           throws NamingServiceException
Finds the distinguished names of all directory entries that match the name of this virtual machine.

Throws:
NamingServiceException

getAllAddresses

public static Enumeration getAllAddresses(String serviceName)
                                   throws NamingServiceException
Return all of the registry entries associated with a named service.

Parameters:
serviceName - The name of the service for which to return all registry entries.
Returns:
The enumeration of the service's registry entries.
Throws:
NamingServiceException - if the service is unknown or some other exception prevents it from being looked up.

getConnection

public static Socket getConnection(String serviceName)
                            throws NamingServiceException
Returns a socket connected to a named service.

Parameters:
serviceName - The name of the service to which a network connection is requested.
Returns:
A socket that is connected to the named service.
Throws:
NamingServiceException - if the specified service name is unknown or a network connection can not be established to the service.

addService

public static void addService(String serviceName,
                              ObjectDestination dest)
Adds an entry to the service registry.

Parameters:
serviceName - The name of the service for which to add a registry entry.
dest - The registry entry.

setGlobalProperties

public static void setGlobalProperties()
Sets global properties for the VM based upon the VM name.


setGlobalProperties

public static void setGlobalProperties(String propPrefix)
Deprecated.  

Sets global properties for the VM based upon a service-specific property name prefix.

Parameters:
propPrefix - The property name prefix of service-specific properties.

reinitialize

public void reinitialize()
                  throws NamingServiceException
Throws:
NamingServiceException

initialize

protected void initialize(String propPrefix)
                   throws NamingServiceException
Initializes the naming service instance.

Parameters:
propPrefix - The property name prefix of the instance.
Throws:
NamingServiceException

getLocalHost

private static String getLocalHost()

createSocket

private static Socket createSocket(String serviceName,
                                   String host,
                                   int port)
                            throws Exception
Throws:
Exception

setProperties

private static void setProperties(String[] args,
                                  String resource)
                           throws IOException
Updates the System Properties object by adding properties defined in a String array plus properties defined in a specified resource. The resource may be a local file or a network resource accessed via an HTTP or LDAP URL.

Parameters:
args - A String array containing name=value pairs.
resource - The pathname of a local file, or an HTTP or LDAP URL reference a network resource that defines properties.
Throws:
IOException - if an I/O error prevents the resource from being accessed or read.

getProperties

public Properties getProperties()
Returns the properties object currently being used by the NamingService instance.

Returns:
The properties object.

getIEProperties

public static IEProperties getIEProperties()
Obtain, and create if necessary, the IEProperties object used by this JVM.

Returns:
The current IEProperties object

main

public static void main(String[] args)
When initiated via command line, the naming service operates as a utility that can initiate other programs defined by naming service launch properties.


refreshProperties

public void refreshProperties()
Specified by:
refreshProperties in interface PropertyListener