You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by bu...@apache.org on 2002/12/05 06:40:27 UTC

DO NOT REPLY [Bug 15099] New: - MX4JSystemManager.java

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15099>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15099

MX4JSystemManager.java

           Summary: MX4JSystemManager.java
           Product: Avalon
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Phoenix
        AssignedTo: avalon-phoenix-dev@jakarta.apache.org
        ReportedBy: geb@263.net


in MX4JSystemManager.java's initialize(), there is a call for 
MBeanServer.invoke to start mx4j's HTTP adapter and RMI adapter, but there is 
no such call to stop these adapters. so when CLIMain is called by service 
warpper, such as DaemonLauncher.java, and if there is no System.exit() after 
stop the Embeddor, the execution will not stop because the adapter thread is 
still run.

I modified MX4JSystemManager a little bit. below is modified part of it

public void initialize()
        throws Exception
{
        super.initialize();
}

public void start()
        throws Exception
{
	super.start();
	final MBeanServer server = getMBeanServer();
	startHttpAdaptor(server);
	if (m_rmi) startRMIAdaptor(server);
}

public void stop()
        throws Exception
{
	super.stop();
	// stop the server
	final MBeanServer server = getMBeanServer();
	stopHttpAdaptor(server);
	if (m_rmi) stopRMIAdaptor(server);
}

private void startHttpAdaptor(final MBeanServer server)
        throws Exception
{
	final ObjectName adaptorName = new ObjectName("Http:name=HttpAdaptor");
	server.createMBean("mx4j.adaptor.http.HttpAdaptor", adaptorName, null);
	server.setAttribute(adaptorName, new Attribute("Host", m_host));
	server.setAttribute(adaptorName, new Attribute("Port", new Integer
(m_port)));

	configureProcessor(server, adaptorName);
	if (m_username != null) configureAuthentication(server, adaptorName);
	server.invoke(adaptorName, "start", null, null);

	getLogger().debug("MX4J HTTP listener port: " + m_port);
}

private void startRMIAdaptor(final MBeanServer server)
        throws Exception
{
	System.setProperty("java.naming.factory.initial", m_namingFactory);

	// Create and start the naming service
	final ObjectName naming = new ObjectName("Naming:type=rmiregistry");
	server.createMBean("mx4j.tools.naming.NamingService", naming, null);
	server.invoke(naming, "start", null, null);

	// Create the JRMP adaptor
	final ObjectName adaptor = new ObjectName("Adaptor:protocol=JRMP");
	server.createMBean("mx4j.adaptor.rmi.jrmp.JRMPAdaptor", adaptor, null);
	JRMPAdaptorMBean mbean = (JRMPAdaptorMBean) StandardMBeanProxy.create
(JRMPAdaptorMBean.class, server, adaptor);
	// Set the JNDI name with which will be registered
	mbean.setJNDIName("jrmp");
	// Register the JRMP adaptor in JNDI and start it
	mbean.start();
}

private void stopHttpAdaptor(final MBeanServer server)
        throws Exception
{
	// stop the HTTP adaptor
	final ObjectName adaptorName = new ObjectName("Http:name=HttpAdaptor");
	server.invoke(adaptorName, "stop", null, null);
}

private void stopRMIAdaptor(final MBeanServer server)
        throws Exception
{
	// stop the JRMP adaptor
	final ObjectName adaptor = new ObjectName("Adaptor:protocol=JRMP");
	server.invoke(adaptor, "stop", null, null);

	// stop the naming service
	final ObjectName naming = new ObjectName("Naming:type=rmiregistry");
	server.invoke(naming, "stop", null, null);
}

private void configureProcessor(final MBeanServer server, final ObjectName 
adaptorName)
        throws Exception
{
	final ObjectName processorName = new ObjectName
("Http:name=XSLTProcessor");
	server.createMBean("mx4j.adaptor.http.XSLTProcessor", processorName, 
null);
	server.setAttribute(adaptorName, new Attribute("ProcessorName", 
processorName));
	server.setAttribute(processorName, new Attribute("UseCache", 
Boolean.FALSE));
	if (m_stylesheetDir != null) server.setAttribute(processorName, new 
Attribute("File", m_stylesheetDir));
}

private void configureAuthentication(final MBeanServer server, final ObjectName 
adaptorName)
        throws InstanceNotFoundException, MBeanException, ReflectionException, 
AttributeNotFoundException, InvalidAttributeValueException
{
	// add user names
	server.invoke(adaptorName, "addAuthorization", new Object[]{m_username, 
m_password}, new String[]{"java.lang.String", "java.lang.String"});
	// use basic authentication
	server.setAttribute(adaptorName, new Attribute
("AuthenticationMethod", "basic"));
}

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>