org.jboss.remoting.detection.jndi
Class JNDIDetector

java.lang.Object
  extended by org.jboss.remoting.detection.AbstractDetector
      extended by org.jboss.remoting.detection.jndi.JNDIDetector
All Implemented Interfaces:
javax.management.MBeanRegistration, AbstractDetectorMBean, Detector, JNDIDetectorMBean

public class JNDIDetector
extends AbstractDetector
implements JNDIDetectorMBean

This is a remoting detector for the remoting package which uses a JNDI server to maintain the registeries for remote invoker servers (stored as Detection messages). This detector is intended to be used in conjuntion with an external JNDI server that is already running. This is done by passing all the information needed to connect to the remote JNDI server via the setter methods. This can also be done within the jboss-service.xml. An example of the entry is as follows:

<mbean code="org.jboss.remoting.detection.jndi.JNDIDetector" name="jboss.remoting:service=Detector,transport=jndi">
<attribute name="Port">5555</attribute>
<attribute name="Host">foo.bar.com</attribute>
<attribute name="ContextFactory">org.jnp.interfaces.NamingContextFactory</attribute>
<attribute name="URLPackage">org.jboss.naming:org.jnp.interfaces</attribute>
</mbean>

Note: The above xml is for the JBoss JNP JNDI server, and has not be tested (just an example).

Be aware that just because this detector is stopped (and the entry removed from the JNDI server) remote JNDIDetectors may not recognize that the invoker servers are not available. This is because once remote invoker servers (connectors) are detected, they will be pinged directly to determine if they are no longer available. However, no new JNDIDetectors will detect your server once stopped. Also, please note that currently the detection registries are bound at the root context and not a sub context (which is on the todo list, but you know how that goes).

Important to also note that if any of the above attributes are set once the detector has started, they will not be used in connecting to the JNDI server until the detector is stopped and re-started (they do not change the JNDI server connection dynamically).

Author:
Tom Elrod

Field Summary
static java.lang.String DETECTION_SUBCONTEXT_NAME
           
protected  org.jboss.logging.Logger log
           
 
Fields inherited from class org.jboss.remoting.detection.AbstractDetector
mbeanserver, networkRegistry, objectName, registryObjectName
 
Constructor Summary
JNDIDetector()
           
JNDIDetector(java.util.Map config)
           
 
Method Summary
protected  void forceHeartbeat()
          Used to force detection messages to be sent by remoting servers and consumed by detector and registered with network registry.
 int getCleanDetectionNumber()
          Gets the number of detection iterations before manually pinging remote server to make sure still alive.
 java.lang.String getContextFactory()
          The context factory string used when connecting to the JNDI server
 java.lang.String getHost()
          Gets the host to use when connecting to JNDI server
 int getPort()
          Gets the port used to connect to the JNDI Server.
 java.lang.String getSubContextName()
          Gets the sub context name under which detection messages will be bound and looked up.
 java.lang.String getURLPackage()
          The url package string used when connecting to JNDI server
protected  void heartbeat()
          Creates connection to JNDI server (which should have already happened in start() method) and will begin checking for remote servers as well as registering itself so will be visible by remote detectors.
 void setCleanDetectionNumber(int cleanDetectionNumber)
          Sets the number of detection iterations before manually pinging remote server to make sure still alive.
 void setContextFactory(java.lang.String contextFactory)
          The context factory string to use when connecting to the JNDI server.
 void setHost(java.lang.String host)
          Sets the host to use when connecting to JNDI server
 void setPort(int port)
          Sets the port to use when connecting to JNDI server
 void setSubContextName(java.lang.String subContextName)
          Sets the sub context name under which detection messages will be bound and looked up.
 void setURLPackage(java.lang.String urlPackage)
          The url package string to use when connecting to the JNDI server.
 void start()
          Will establish the connection to the JNDI server and start detection of other servers.
 void stop()
          called by the MBeanServer to stop the mbean lifecycle
 
Methods inherited from class org.jboss.remoting.detection.AbstractDetector
checkInvokerServer, createDetection, detect, forceDetection, getConfiguration, getDefaultTimeDelay, getHeartbeatDelay, getHeartbeatPeriod, getHeartbeatTimeDelay, getPingerDelay, getPingerPeriod, isRemoteDetection, postDeregister, postRegister, preDeregister, preRegister, setConfiguration, setDefaultTimeDelay, setHeartbeatTimeDelay, startHeartbeat, startPinger, stopHeartbeat, stopPinger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.remoting.detection.AbstractDetectorMBean
getConfiguration, getDefaultTimeDelay, getHeartbeatTimeDelay, setConfiguration, setDefaultTimeDelay, setHeartbeatTimeDelay
 
Methods inherited from interface javax.management.MBeanRegistration
postDeregister, postRegister, preDeregister, preRegister
 

Field Detail

DETECTION_SUBCONTEXT_NAME

public static final java.lang.String DETECTION_SUBCONTEXT_NAME
See Also:
Constant Field Values

log

protected final org.jboss.logging.Logger log
Constructor Detail

JNDIDetector

public JNDIDetector()

JNDIDetector

public JNDIDetector(java.util.Map config)
Method Detail

getPort

public int getPort()
Gets the port used to connect to the JNDI Server.

Specified by:
getPort in interface JNDIDetectorMBean
Returns:

setPort

public void setPort(int port)
Sets the port to use when connecting to JNDI server

Specified by:
setPort in interface JNDIDetectorMBean
Parameters:
port -

getHost

public java.lang.String getHost()
Gets the host to use when connecting to JNDI server

Specified by:
getHost in interface JNDIDetectorMBean
Returns:

setHost

public void setHost(java.lang.String host)
Sets the host to use when connecting to JNDI server

Specified by:
setHost in interface JNDIDetectorMBean
Parameters:
host -

getContextFactory

public java.lang.String getContextFactory()
The context factory string used when connecting to the JNDI server

Specified by:
getContextFactory in interface JNDIDetectorMBean
Returns:

setSubContextName

public void setSubContextName(java.lang.String subContextName)
Sets the sub context name under which detection messages will be bound and looked up.

Parameters:
subContextName -

getSubContextName

public java.lang.String getSubContextName()
Gets the sub context name under which detection messages will be bound and looked up.

Returns:

setContextFactory

public void setContextFactory(java.lang.String contextFactory)
The context factory string to use when connecting to the JNDI server. Should be a qualified class name for JNDI client.

Specified by:
setContextFactory in interface JNDIDetectorMBean
Parameters:
contextFactory -

getURLPackage

public java.lang.String getURLPackage()
The url package string used when connecting to JNDI server

Specified by:
getURLPackage in interface JNDIDetectorMBean
Returns:

setURLPackage

public void setURLPackage(java.lang.String urlPackage)
The url package string to use when connecting to the JNDI server.

Specified by:
setURLPackage in interface JNDIDetectorMBean
Parameters:
urlPackage -

start

public void start()
           throws java.lang.Exception
Will establish the connection to the JNDI server and start detection of other servers.

Specified by:
start in interface Detector
Overrides:
start in class AbstractDetector
Throws:
java.lang.Exception

heartbeat

protected void heartbeat()
Creates connection to JNDI server (which should have already happened in start() method) and will begin checking for remote servers as well as registering itself so will be visible by remote detectors.

Specified by:
heartbeat in class AbstractDetector

forceHeartbeat

protected void forceHeartbeat()
Description copied from class: AbstractDetector
Used to force detection messages to be sent by remoting servers and consumed by detector and registered with network registry.

Specified by:
forceHeartbeat in class AbstractDetector

getCleanDetectionNumber

public int getCleanDetectionNumber()
Gets the number of detection iterations before manually pinging remote server to make sure still alive.

Specified by:
getCleanDetectionNumber in interface JNDIDetectorMBean
Returns:

setCleanDetectionNumber

public void setCleanDetectionNumber(int cleanDetectionNumber)
Sets the number of detection iterations before manually pinging remote server to make sure still alive. This is needed since remote server could crash and yet still have an entry in the JNDI server, thus making it appear that it is still there.

Specified by:
setCleanDetectionNumber in interface JNDIDetectorMBean
Parameters:
cleanDetectionNumber -

stop

public void stop()
          throws java.lang.Exception
Description copied from class: AbstractDetector
called by the MBeanServer to stop the mbean lifecycle

Specified by:
stop in interface Detector
Overrides:
stop in class AbstractDetector
Throws:
java.lang.Exception


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.