You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2004/10/19 17:11:59 UTC
cvs commit: ws-axis/java/src/org/apache/axis/management/jmx ServiceAdministrator.java ServiceAdministratorMBean.java
dims 2004/10/19 08:11:59
Modified: java/src/org/apache/axis/transport/http AxisServlet.java
Added: java/src/org/apache/axis/management ServiceAdmin.java
java/src/org/apache/axis/management/jmx
ServiceAdministrator.java
ServiceAdministratorMBean.java
Log:
Fix for (AXIS-1424) Ability to Start/Stop Services via JMX
from Brian Dillon (brian.dillon@fineos.com)
Revision Changes Path
1.182 +9 -1 ws-axis/java/src/org/apache/axis/transport/http/AxisServlet.java
Index: AxisServlet.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
retrieving revision 1.181
retrieving revision 1.182
diff -u -r1.181 -r1.182
--- AxisServlet.java 14 Oct 2004 21:10:51 -0000 1.181
+++ AxisServlet.java 19 Oct 2004 15:11:58 -0000 1.182
@@ -44,6 +44,7 @@
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.SimpleTargetedChain;
+import org.apache.axis.management.ServiceAdmin;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ServiceDesc;
@@ -180,8 +181,15 @@
}
initQueryStringHandlers();
- }
+ // Setup the service admin
+ try {
+ ServiceAdmin.setEngine(this.getEngine());
+ } catch (AxisFault af) {
+ exceptionLog.info("Exception setting AxisEngine on ServiceAdmin " +
+ af);
+ }
+ }
/**
1.1 ws-axis/java/src/org/apache/axis/management/ServiceAdmin.java
Index: ServiceAdmin.java
===================================================================
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.axis.management;
import org.apache.axis.AxisFault;
import org.apache.axis.ConfigurationException;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.server.AxisServer;
import javax.xml.namespace.QName;
import java.util.HashMap;
import java.util.Iterator;
/**
* The ServiceControl Object is responsible for starting and
* stopping specific services
*
* @author bdillon
* @version 1.0
*/
public class ServiceAdmin {
//Singleton AxisServer for Management
static private AxisServer axisServer = null;
/**
* Start the Service
*
* @param serviceName
* @throws AxisFault ConfigurationException
*/
static public void startService(String serviceName)
throws AxisFault, ConfigurationException {
AxisServer server = getEngine();
try {
SOAPService service = server.getConfig().getService(
new QName("", serviceName));
service.start();
} catch (ConfigurationException configException) {
if (configException.getContainedException() instanceof AxisFault) {
throw (AxisFault) configException.getContainedException();
} else {
throw configException;
}
}
}
/**
* Stop the Service
*
* @param serviceName
* @throws AxisFault ConfigurationException
*/
static public void stopService(String serviceName)
throws AxisFault, ConfigurationException {
AxisServer server = getEngine();
try {
SOAPService service = server.getConfig().getService(
new QName("", serviceName));
service.stop();
} catch (ConfigurationException configException) {
if (configException.getContainedException() instanceof AxisFault) {
throw (AxisFault) configException.getContainedException();//Throw Axis fault if ist. of
} else {
throw configException;
}
}
}
/**
* List all registered services
*
* @return Map of Services (SOAPService objects, Key is the ServiceName)
* @throws AxisFault ConfigurationException
*/
static public HashMap listServices()
throws AxisFault, ConfigurationException {
AxisServer server = getEngine();
HashMap serviceMap = new HashMap();
Iterator iter; // get list of ServiceDesc objects
try {
iter = server.getConfig().getDeployedServices();
} catch (ConfigurationException configException) {
if (configException.getContainedException() instanceof AxisFault) {
throw (AxisFault) configException.getContainedException();//Throw Axis fault if inst. of
} else {
throw configException;
}
}
while (iter.hasNext()) {
ServiceDesc sd = (ServiceDesc) iter.next();
String name = sd.getName();
System.out.println("Service Name is : " + name);
SOAPService service = server.getConfig().getService(
new QName("", name));
serviceMap.put(name, service);
}
return serviceMap;
}
/**
* Get the singleton engine for this management object
*
* @return
* @throws AxisFault
*/
static public AxisServer getEngine() throws AxisFault {
if (axisServer == null) {
//Throw a could not get AxisEngine Exception
throw new AxisFault(
"Unable to locate AxisEngine for ServiceAdmin Object");
}
return axisServer;
}
/**
* Set the singleton engine
* @param axisSrv
*/
static public void setEngine(AxisServer axisSrv) {
ServiceAdmin.axisServer = axisSrv;
}
}
1.1 ws-axis/java/src/org/apache/axis/management/jmx/ServiceAdministrator.java
Index: ServiceAdministrator.java
===================================================================
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.axis.management.jmx;
import org.apache.axis.AxisFault;
import org.apache.axis.ConfigurationException;
import java.util.HashMap;
/**
* The ServiceAdmininstrator MBean exposes the
* org.apache.axis.management.ServiceAdmin object
*
* @author bdillon
* @version 1.0
*/
public class ServiceAdministrator implements ServiceAdministratorMBean {
/**
* CTR
*/
public ServiceAdministrator() {
}
/**
* Start the Service
*
* @param serviceName
* @throws AxisFault ConfigurationException
*/
public void startService(String serviceName)
throws AxisFault, ConfigurationException {
org.apache.axis.management.ServiceAdmin.startService(serviceName);
}
/**
* Stop the Service
*
* @param serviceName
* @throws AxisFault ConfigurationException
*/
public void stopService(String serviceName)
throws AxisFault, ConfigurationException {
org.apache.axis.management.ServiceAdmin.stopService(serviceName);
}
/**
* List all registered services
*
* @return Map of Services (SOAPService objects, Key is the ServiceName)
* @throws AxisFault ConfigurationException
*/
public HashMap listServices()
throws AxisFault, ConfigurationException {
return org.apache.axis.management.ServiceAdmin.listServices();
}
}
1.1 ws-axis/java/src/org/apache/axis/management/jmx/ServiceAdministratorMBean.java
Index: ServiceAdministratorMBean.java
===================================================================
/*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.axis.management.jmx;
import org.apache.axis.AxisFault;
import org.apache.axis.ConfigurationException;
import java.util.HashMap;
/**
* The ServiceAdministrator MBean exposes the
* org.apache.axis.management.ServiceAdmin object
*
* @author bdillon
* @version 1.0
*/
public interface ServiceAdministratorMBean {
/**
* Start the Service
*
* @param serviceName
* @throws AxisFault ConfigurationException
*/
public void startService(String serviceName) throws AxisFault,
ConfigurationException;
/**
* Stop the Service
*
* @param serviceName
* @throws AxisFault ConfigurationException
*/
public void stopService(String serviceName) throws AxisFault,
ConfigurationException;
/**
* List all registered services
*
* @return Map of Services (SOAPService objects, Key is the ServiceName)
* @throws AxisFault,ConfigurationException
*
*/
public HashMap listServices() throws AxisFault, ConfigurationException;
}