[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/management/jmxmp JMXMPJobConnecto
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-25 19:30:03
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/management/jmxmp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26476/jmxmp Added Files: JMXMPJobConnectorServerHelper.java RepositoryJMXMPJobConnectorServerHelper.java Log Message: no message --- NEW FILE: RepositoryJMXMPJobConnectorServerHelper.java --- package org.jmonks.batchserver.framework.management.jmxmp; import javax.management.remote.JMXServiceURL; import org.apache.log4j.Logger; import org.jmonks.batchserver.framework.JobContext; /** * <p> * This connector server is based on JMX Messaging protocol and uses the framework * reposiotry as the lookup location to register and unregister the JMX Service URL. * </p> * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public class RepositoryJMXMPJobConnectorServerHelper extends JMXMPJobConnectorServerHelper { private static Logger logger=Logger.getLogger(RepositoryJMXMPJobConnectorServerHelper.class); /** * @see org.jmonks.batchserver.framework.management.JobConnectorServerHelper@init(java.util.Map) */ protected void init(java.util.Map configProps) { logger.trace("Entering init") ; /** * Because this uses the repository defined for this framework as the * lookup location, this implementation does not require any properties * in configuration file to initialize the lookup location. */ logger.trace("Exiting init") ; } /** * Registers the jmx service url with the given job name in the repository * defined for this framework. * * @param jobName Name of the job to be used in the registration. * @param jmxServiceURL JMX service url identifies the connector server * where all the manager and montiro mbeans are configured. * * @return Returns true, if it successfully registred in repository, false, otherwise. * * @throws IllegalArgumentException If job name paramter is null. */ public boolean registerServiceURL(String jobName,JMXServiceURL jmxServiceURL) { logger.trace("Entering registerServiceURL") ; if(jobName==null) throw new IllegalArgumentException("job name cannot be null to registerd jmx service url."); boolean registered=JobContext.getReposiotry().registerJobMgmtMntrInfo(jobName, jmxServiceURL.toString()); logger.debug(jobName + " with the service url " + jmxServiceURL.toString() + " registered in repository = " + registered); logger.trace("Exiting registerServiceURL") ; return registered; } /** * Unregisters the jmx service url registered in repository with the given * job name. * * @param jobName Name of the job the service URL registered with. * * @return Returns true, if it successfully unregistered, false otherwise. * * @throws IllegalArgumentException If job name paramter is null. */ public boolean unregisterServiceURL(String jobName) { logger.trace("Entering unregisterServiceURL") ; if(jobName==null) throw new IllegalArgumentException("job name cannot be null to unregister the service url."); boolean unregistered=JobContext.getReposiotry().unregisterJobMgmtMntrInfo(jobName); logger.debug(jobName + " mgmt and mntr information unregistered = " + unregistered); logger.trace("Exiting unregisterServiceURL") ; return unregistered; } } --- NEW FILE: JMXMPJobConnectorServerHelper.java --- /* * JMXMPJobConnectorServerHelper.java * * Created on March 22, 2006, 9:27 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.framework.management.jmxmp; import java.net.MalformedURLException; import javax.management.remote.JMXServiceURL; import org.apache.log4j.Logger; import org.jmonks.batchserver.framework.management.JobConnectorServerHelper; /** * <p> * JMXMPJobConnectorServerHelper creates the JMX Service URL based on the JMX Messaging * protocol and leaves the lookup location details to the class going to implement this * abstract class. The machine the job being run will be used as the host name and * the port will be selected automatically by the JMX connector server factory. * </p> * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public abstract class JMXMPJobConnectorServerHelper extends JobConnectorServerHelper { private static Logger logger=Logger.getLogger(JMXMPJobConnectorServerHelper.class); /** * JMX Messaging Protocol URL to be used to create the connector server. */ private static final String JMXMP_SERVICE_URL = "service:jmx:jmxmp://"; /** * Creates the JMX Service URL based on JMX Messaging protocol. This does * not defined the host name and port name in the URL. So, the machine job * being run will be used as the host and port will be automatically choosen. * * @return Returns the JMX Service URL, null, if it cannot create the URL. */ public JMXServiceURL getServiceURL() { JMXServiceURL serviceURL=null; try { serviceURL=new JMXServiceURL(JMXMPJobConnectorServerHelper.JMXMP_SERVICE_URL); } catch(MalformedURLException exception) { exception.printStackTrace(); logger.error(exception.getMessage(), exception); } return serviceURL; } } |