org.jboss.ha.framework.server
Class HAPartitionLocator

java.lang.Object
  extended by org.jboss.ha.framework.server.HAPartitionLocator

public class HAPartitionLocator
extends Object

Service Locator utility for locating an HAPartition. Maintains an internal registry of partitions, and if it cannot find a partition there, will attempt to find it in JNDI using a standard naming pattern.

Version:
$Revision: 1.1 $
Author:
Brian Stansberry

Field Summary
static String JNDI_CONTEXT_NAME
          Name of the standard JNDI context under which HAPartitions are bound
 
Constructor Summary
protected HAPartitionLocator()
          Allow subclasses to create a new HAPartitionLocator.
 
Method Summary
 void deregisterHAPartition(HAPartition partition)
          Deregister a partition from this locator.
protected  HAPartition findInJndi(String partitionName, Hashtable jndiProperties)
          Find the given partition in JNDI under a standard binding.
protected  HAPartition findInRegistry(String partitionName)
          Find the given partition in the local registry.
 HAPartition getHAPartition(String partitionName, Hashtable jndiProperties)
          Locates and returns the HAPartition whose partition name matches the given partitionName.
static HAPartitionLocator getHAPartitionLocator()
          Gets the
static String getStandardJndiBinding(String partitionName)
          Appends the partition name to JNDI_CONTEXT_NAME; e.g.
 void registerHAPartition(HAPartition partition)
          Register a partition with this locator.
protected static void setSharedInstance(HAPartitionLocator shared)
          Allows replacement of the default implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JNDI_CONTEXT_NAME

public static final String JNDI_CONTEXT_NAME
Name of the standard JNDI context under which HAPartitions are bound

See Also:
Constant Field Values
Constructor Detail

HAPartitionLocator

protected HAPartitionLocator()
Allow subclasses to create a new HAPartitionLocator.

Method Detail

getHAPartitionLocator

public static HAPartitionLocator getHAPartitionLocator()
Gets the

Returns:
the shared HAPartitionLocator; will not be null

getStandardJndiBinding

public static final String getStandardJndiBinding(String partitionName)
Appends the partition name to JNDI_CONTEXT_NAME; e.g. /HAPartition/DefaultPartition.

Parameters:
partitionName - the name of the partition
Returns:
a string representing the standard name under which a partition is bound in JNDI.

setSharedInstance

protected static void setSharedInstance(HAPartitionLocator shared)
Allows replacement of the default implementation.

Parameters:
shared - the locator to use. Cannot be null.

getHAPartition

public HAPartition getHAPartition(String partitionName,
                                  Hashtable jndiProperties)
Locates and returns the HAPartition whose partition name matches the given partitionName.

Parameters:
partitionName - the name of the partition. Cannot be null.
jndiProperties - any naming properties to pass to new InitialContext() if JNDI lookup is needed.
Returns:
the partition. Will not return null
Throws:
IllegalStateException - if no matching partition can be found

registerHAPartition

public void registerHAPartition(HAPartition partition)
Register a partition with this locator.

Parameters:
partition - the partition

deregisterHAPartition

public void deregisterHAPartition(HAPartition partition)
Deregister a partition from this locator.

Parameters:
partition - the partition

findInRegistry

protected HAPartition findInRegistry(String partitionName)
Find the given partition in the local registry.

Parameters:
partitionName - the name of the partition. Cannot be null.
Returns:
the partition, or null

findInJndi

protected HAPartition findInJndi(String partitionName,
                                 Hashtable jndiProperties)
                          throws NamingException
Find the given partition in JNDI under a standard binding.

Parameters:
partitionName - the name of the partition. Cannot be null.
Returns:
the partition, or null
Throws:
NamingException - if there is a problem with the naming context. Will not throw NameNotFoundException; if not found, will return null.
See Also:
getStandardJndiBinding(String)


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.