jrunx.kernel
Class JRunServiceDeployer

jrunx.kernel.ServiceAdapter
  |
  +--jrunx.kernel.DeploymentService
        |
        +--jrunx.kernel.JRunServiceDeployer
All Implemented Interfaces:
DeploymentServiceMBean, JRunServiceDeployerMBean, javax.naming.Referenceable, java.lang.Runnable, java.io.Serializable, Service, ServiceMBean

public class JRunServiceDeployer
extends DeploymentService
implements JRunServiceDeployerMBean, java.lang.Runnable

ServiceDeployer deploys MBeans based on the jrun.xml file for a given JRun server and manages the lifecycle of all those services as well. This is the core internal service of the server, and is created and invoked programmatically by the JRun.java bootstrap class. ,br> It is itself also a JRun service, and may be manipulated via the MBeanServer or the JMC.

See Also:
Serialized Form

Field Summary
static java.lang.String LIFECYCLE_DESTROY
           
static java.lang.String LIFECYCLE_INIT
           
static java.lang.String LIFECYCLE_START
           
static java.lang.String LIFECYCLE_STOP
           
static java.lang.String OBJECT_NAME
           
 
Fields inherited from class jrunx.kernel.ServiceAdapter
DEFAULT_DEACTIVATED, DEFAULT_DOMAIN, DOMAIN_NAME_SEPARATOR, DOMAIN_NAME_SUFFIX, domainName, jndiBindable, LOGGER_CACHE_TIME, SCHEDULER_SERVICE, SECURITY_MANAGER, server, status, TRANSACTION_MANAGER
 
Fields inherited from interface jrunx.kernel.Service
INITIALIZED, STARTED, STARTING, STOPPED, STOPPING, UNINITIALIZED
 
Constructor Summary
JRunServiceDeployer()
           
 
Method Summary
 void addEventListener(ServerEventListener listener, java.lang.Object handback)
          Adds a ServerEventListener
 void addService(java.lang.String oname)
          Add a service to the deployer that didn't exist in jrun.xml
 void addService(java.lang.String oname, int pos)
          Add a service in a specific position in the ordered services that didn't exist in jrun.xml.
 void addService(java.lang.String oname, java.lang.Integer pos)
          Necessary because JMX server invocations can only handle Objects, no primitives.
static java.util.List buildAttributes(java.util.Vector attrs, java.util.Properties serverProps, javax.management.MBeanServer server)
          Given a list of attributes, build the list of properties to set on a given object
protected static java.lang.Object buildObject(DocumentElement attrElement, java.util.Properties serverProps, javax.management.MBeanServer server)
          Builds an object using the attributes from the given DocumentElement
 void deployServices(DocumentElement parent, java.util.Vector elementTree)
           
 void deployServices(java.util.Vector elementTree)
           
 void destroyServices()
          Destroy all service in reverse order in which they appear in jrun.xml.
 java.util.Set findAllObjectInstances()
          Retrieve an unordered Set of ObjectNames for all Services.
 Service findService(java.lang.String name)
           
protected  void fireEvent(ServerEvent event)
          Fires a server event to all my listeners
static ServerEvent getServerStatus()
           
static int getServiceStatus(javax.management.MBeanServer server, javax.management.ObjectName serviceName)
          Gets the current service status for the given object
 int getServiceStatus(java.lang.String serviceName)
           
 void initServices()
          Init all service in the order in which they appear in jrun.xml.
static void invokeOnServices(ServiceAdapter parent, java.util.ArrayList list, java.lang.String method)
          Invokes the given method name on all of the services listed.
static boolean isServiceDeactivated(javax.management.MBeanServer server, javax.management.ObjectName serviceName)
          Checks if the given service is deactivated
 void removedEventListener(ServerEventListener listener)
          Removes a ServerEventListener
 void run()
          Shutdown event starts the Thread, Thread is not running beforehand.
static void setProperties(java.lang.Object o, java.util.List list)
          Sets the properties on an arbitrary bean.
static void setServiceStatus(javax.management.MBeanServer server, javax.management.ObjectName serviceName, int status)
          Sets the current service status for the given object
 void shutdownServices()
           
 void startServices()
          Start all service in the order in which they appear in jrun.xml.
 void stopServices()
          Stop all service in reverse order in which they appear in jrun.xml.
 
Methods inherited from class jrunx.kernel.DeploymentService
getURL, loadServices, parseDescriptorURL, setURL, start
 
Methods inherited from class jrunx.kernel.ServiceAdapter
bind, destroy, findObjectInstance, findObjectInstance, findObjectInstance, getBindToJNDI, getDeactivated, getDomainName, getDomainSearchPath, getJRunService, getLogger, getName, getParentService, getReference, getResourceManager, getServerName, getServerProperties, getStatus, init, invokeMethod, isInPartition, isPartition, lookup, postDeregister, postRegister, preDeregister, preRegister, requestServer, scheduleRunnable, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, stop, toString, unbind, unscheduleRunnable, updateStatus
 
Methods inherited from interface jrunx.kernel.DeploymentServiceMBean
getURL, loadServices, setURL
 
Methods inherited from interface jrunx.kernel.ServiceMBean
bind, getBindToJNDI, getDeactivated, getDomainName, getJRunService, getLogger, getName, getParentService, getServerName, requestServer, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, unbind
 
Methods inherited from interface jrunx.kernel.Service
destroy, getStatus, init, start, stop, updateStatus
 

Field Detail

OBJECT_NAME

public static final java.lang.String OBJECT_NAME

LIFECYCLE_INIT

public static final java.lang.String LIFECYCLE_INIT

LIFECYCLE_START

public static final java.lang.String LIFECYCLE_START

LIFECYCLE_STOP

public static final java.lang.String LIFECYCLE_STOP

LIFECYCLE_DESTROY

public static final java.lang.String LIFECYCLE_DESTROY
Constructor Detail

JRunServiceDeployer

public JRunServiceDeployer()
Method Detail

deployServices

public void deployServices(java.util.Vector elementTree)
                    throws java.lang.Exception
Overrides:
deployServices in class DeploymentService

getServerStatus

public static ServerEvent getServerStatus()

deployServices

public void deployServices(DocumentElement parent,
                           java.util.Vector elementTree)

addService

public void addService(java.lang.String oname)
Add a service to the deployer that didn't exist in jrun.xml
Specified by:
addService in interface JRunServiceDeployerMBean

addService

public void addService(java.lang.String oname,
                       java.lang.Integer pos)
Necessary because JMX server invocations can only handle Objects, no primitives.
Specified by:
addService in interface JRunServiceDeployerMBean

addService

public void addService(java.lang.String oname,
                       int pos)
Add a service in a specific position in the ordered services that didn't exist in jrun.xml.

run

public void run()
Shutdown event starts the Thread, Thread is not running beforehand.
Specified by:
run in interface java.lang.Runnable

shutdownServices

public void shutdownServices()
Specified by:
shutdownServices in interface JRunServiceDeployerMBean

initServices

public void initServices()
                  throws java.lang.Exception
Init all service in the order in which they appear in jrun.xml.
Specified by:
initServices in interface JRunServiceDeployerMBean

startServices

public void startServices()
                   throws java.lang.Exception
Start all service in the order in which they appear in jrun.xml.
Specified by:
startServices in interface JRunServiceDeployerMBean

stopServices

public void stopServices()
                  throws java.lang.Exception
Stop all service in reverse order in which they appear in jrun.xml.
Specified by:
stopServices in interface JRunServiceDeployerMBean

destroyServices

public void destroyServices()
                     throws java.lang.Exception
Destroy all service in reverse order in which they appear in jrun.xml.
Specified by:
destroyServices in interface JRunServiceDeployerMBean

getServiceStatus

public int getServiceStatus(java.lang.String serviceName)
Specified by:
getServiceStatus in interface JRunServiceDeployerMBean

findService

public Service findService(java.lang.String name)
                    throws ServiceException

findAllObjectInstances

public java.util.Set findAllObjectInstances()
Retrieve an unordered Set of ObjectNames for all Services.

setServiceStatus

public static void setServiceStatus(javax.management.MBeanServer server,
                                    javax.management.ObjectName serviceName,
                                    int status)
                             throws java.lang.Exception
Sets the current service status for the given object
Parameters:
server - The MBeanServer
serviceName - The ObjectName of the service
status - The status to set

getServiceStatus

public static int getServiceStatus(javax.management.MBeanServer server,
                                   javax.management.ObjectName serviceName)
                            throws java.lang.Exception
Gets the current service status for the given object
Parameters:
server - The MBeanServer
serviceName - The ObjectName of the service

isServiceDeactivated

public static boolean isServiceDeactivated(javax.management.MBeanServer server,
                                           javax.management.ObjectName serviceName)
                                    throws java.lang.Exception
Checks if the given service is deactivated
Parameters:
server - The MBeanServer
serviceName - The ObjectName of the service

invokeOnServices

public static void invokeOnServices(ServiceAdapter parent,
                                    java.util.ArrayList list,
                                    java.lang.String method)
Invokes the given method name on all of the services listed.
Parameters:
parent - The ServiceAdapter parent of the services
list - The list of services
method - The name of the method to invoke. The method must have a void signature.

buildAttributes

public static java.util.List buildAttributes(java.util.Vector attrs,
                                             java.util.Properties serverProps,
                                             javax.management.MBeanServer server)
                                      throws java.lang.Exception
Given a list of attributes, build the list of properties to set on a given object
Parameters:
attr - The list of attributes
serverProps - Any server properties that may be referenced as dynamic variables
server - The current MBean server
Returns:
A List of AttributeHolder objects

buildObject

protected static java.lang.Object buildObject(DocumentElement attrElement,
                                              java.util.Properties serverProps,
                                              javax.management.MBeanServer server)
                                       throws java.lang.Exception
Builds an object using the attributes from the given DocumentElement
Parameters:
type - The DocumentElement that describes the object
serverProps - Any server properties that may be referenced as dynamic variables
server - The current MBean server
Returns:
The initialized object

setProperties

public static void setProperties(java.lang.Object o,
                                 java.util.List list)
                          throws java.lang.Exception
Sets the properties on an arbitrary bean. Uses BeanInfo to gather the list of valid write methods.
Parameters:
o - The object to set properties on
list - The list of AttributeHolder objects

addEventListener

public void addEventListener(ServerEventListener listener,
                             java.lang.Object handback)
Description copied from interface: JRunServiceDeployerMBean
Adds a ServerEventListener
Specified by:
addEventListener in interface JRunServiceDeployerMBean
Following copied from interface: jrunx.kernel.JRunServiceDeployerMBean
Parameters:
listener - The listener
handback - An object to handback to the listener when an event occurs

removedEventListener

public void removedEventListener(ServerEventListener listener)
Description copied from interface: JRunServiceDeployerMBean
Removes a ServerEventListener
Specified by:
removedEventListener in interface JRunServiceDeployerMBean
Following copied from interface: jrunx.kernel.JRunServiceDeployerMBean
Parameters:
listener - The listener

fireEvent

protected void fireEvent(ServerEvent event)
Fires a server event to all my listeners


Copyright � 2002 Macromedia Corporation. All Rights Reserved.