axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hemap...@apache.org
Subject svn commit: r225454 - in /webservices/axis/trunk/archive/java/scratch/jmx-front: ./ src/ src/org/ src/org/apache/ src/org/apache/axis2/ src/org/apache/axis2/management/ src/org/apache/axis2/management/manager/ src/org/apache/axis2/management/mbeans/
Date Wed, 27 Jul 2005 05:21:19 GMT
Author: hemapani
Date: Tue Jul 26 22:21:07 2005
New Revision: 225454

URL: http://svn.apache.org/viewcvs?rev=225454&view=rev
Log:
check in the jmx-front for axis2 behalf of Chathura

Added:
    webservices/axis/trunk/archive/java/scratch/jmx-front/
    webservices/axis/trunk/archive/java/scratch/jmx-front/src/
    webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/
    webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/
    webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/
    webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/
    webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/manager/
    webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/manager/JMXManager.java
    webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/
    webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/Axis2Manager.java
    webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/Axis2ManagerMBean.java

Added: webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/manager/JMXManager.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/manager/JMXManager.java?rev=225454&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/manager/JMXManager.java
(added)
+++ webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/manager/JMXManager.java
Tue Jul 26 22:21:07 2005
@@ -0,0 +1,77 @@
+package org.apache.axis2.management.manager;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.engine.AxisFault;
+import org.apache.axis2.management.mbeans.Axis2Manager;
+
+import java.io.PrintWriter;
+import java.io.FileOutputStream;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+import javax.management.*;
+import javax.management.remote.*;
+import java.util.*;
+import java.net.*;
+
+public class JMXManager{
+
+	private ConfigurationContext configContext;
+
+	JMXConnectorServer cs;
+
+	public JMXManager(ConfigurationContext configContext){
+		this.configContext = configContext;
+	}
+
+
+	public void startMBeanServer() throws AxisFault{
+
+
+		 try{
+			initMBeans();
+		 }catch(Exception e){
+			throw new AxisFault(e.getMessage());
+		 }
+
+	}
+
+
+	public void initMBeans() throws Exception{
+
+			Registry reg=null;
+			String domain = "Axis2";
+
+
+			try {
+				if( reg==null )
+	       			reg=LocateRegistry.createRegistry(9995);
+	       	 } catch(Exception e) {
+	          		throw new AxisFault(e.getMessage());
+	       	 }
+
+
+			// try to find existing MBeanServers. If there are no MBeanServers create a new one for
Axis2
+			MBeanServer mbs = null;
+			if (MBeanServerFactory.findMBeanServer(null).size() > 0) {
+				mbs = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
+			} else {
+				mbs = MBeanServerFactory.createMBeanServer();
+			}
+
+
+			String axis2ManagerNameStr = domain+":type=management.Manager,index=1";
+			ObjectName axis2ManagerName = ObjectName.getInstance(axis2ManagerNameStr);
+
+			Axis2Manager axis2Manager = new Axis2Manager(configContext.getAxisConfiguration());
+			mbs.registerMBean(axis2Manager, axis2ManagerName);
+
+
+			JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9995/axis2");
+			cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
+			cs.start();
+
+	}
+
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/Axis2Manager.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/Axis2Manager.java?rev=225454&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/Axis2Manager.java
(added)
+++ webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/Axis2Manager.java
Tue Jul 26 22:21:07 2005
@@ -0,0 +1,239 @@
+package org.apache.axis2.management.mbeans;
+
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisConfigurationImpl;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.description.ModuleDescription;
+import org.apache.axis2.description.OperationDescription;
+import org.apache.axis2.engine.Phase;
+import org.apache.axis2.engine.AxisFault;
+
+import javax.xml.namespace.QName;
+import java.util.*;
+
+public class Axis2Manager implements Axis2ManagerMBean{
+
+	private AxisConfiguration axisConfig;
+
+	public Axis2Manager(AxisConfiguration axisConfig){
+		this.axisConfig = axisConfig;
+	}
+
+	public String[] getServices(){
+
+		String[] services = null;
+
+		// get the service list
+		HashMap serviceMap = axisConfig.getServices();
+		if(serviceMap!=null && !serviceMap.isEmpty()){
+			Collection serviceCollection = serviceMap.values();
+
+			// add name of each service to a string array
+			services = new String[serviceCollection.size()];
+
+			int i=0;
+			for(Iterator iterator=serviceCollection.iterator(); iterator.hasNext();){
+				ServiceDescription axisService = (ServiceDescription)iterator.next();
+				String serviceName = axisService.getName().getLocalPart();
+
+				services[i] = serviceName;
+				i++;
+			}
+
+		}
+
+		return services;
+	}
+
+
+	public String[] getFaultyServices(){
+
+		String[] faultyServices = null;
+
+		Hashtable faultyServicesTable = axisConfig.getFaulytServices();
+		if(faultyServicesTable != null && faultyServicesTable.size() > 0){
+
+			faultyServices = new String[faultyServicesTable.size()];
+			Enumeration eFaultyServices = faultyServicesTable.keys();
+
+			int i=0;
+			while (eFaultyServices.hasMoreElements()) {
+				String faultyServiceName = (String)eFaultyServices.nextElement();
+				faultyServices[i] = faultyServiceName;
+				i++;
+			}
+		}
+
+		return faultyServices;
+	}
+
+
+	public String[] getModules(){
+
+		String[] modules = null;
+		ArrayList moduleList = new ArrayList();
+
+		// get the module list
+		HashMap moduleMap = ((AxisConfigurationImpl)axisConfig).getModules();
+		if(moduleMap!=null && !moduleMap.isEmpty()){
+			Collection moduleCollection = moduleMap.values();
+
+			modules = new String[moduleCollection.size()];
+			int i=0;
+			for(Iterator iterator=moduleCollection.iterator(); iterator.hasNext();){
+				ModuleDescription axisModule = (ModuleDescription)iterator.next();
+				String moduleName = axisModule.getName().getLocalPart();
+
+				modules[i] = moduleName;
+				i++;
+			}
+
+		}
+
+		return modules;
+	}
+
+
+	public String[] getFaultyModules(){
+
+		String[] faultyModules = null;
+
+		Hashtable faultyModulesTable = axisConfig.getFaulytModules();
+		if(faultyModulesTable != null && faultyModulesTable.size() > 0){
+
+			faultyModules = new String[faultyModulesTable.size()];
+			Enumeration eFaultyModules = faultyModulesTable.keys();
+
+			int i = 0;
+			while (eFaultyModules.hasMoreElements()) {
+				String faultyModuleName = (String) eFaultyModules.nextElement();
+				faultyModules[i] = faultyModuleName;
+				i++;
+			}
+		}
+
+		return faultyModules;
+	}
+
+
+	public String[] getGloballyEngagedModules(){
+
+		String[] modules = null;
+		Collection engagedModuleCollection = ((AxisConfigurationImpl)axisConfig).getEngadgedModules();
+
+		if(engagedModuleCollection != null && engagedModuleCollection.size() > 0) {
+
+			modules = new String[engagedModuleCollection.size()];
+
+			int i = 0;
+			for(Iterator iterator=engagedModuleCollection.iterator(); iterator.hasNext();){
+				QName axisModule = (QName) iterator.next();
+                String moduleName = axisModule.getLocalPart();
+
+				modules[i] = moduleName;
+				i++;
+			}
+		}
+
+		return modules;
+	}
+
+
+	public String[] getPhases(){
+
+		ArrayList phaseList = axisConfig.getInPhasesUptoAndIncludingPostDispatch();
+		String[] phases = new String[phaseList.size()];
+
+		for(int i=0; i<phaseList.size(); i++){
+			Phase phase = (Phase)phaseList.get(i);
+			phases[i] = phase.getPhaseName();
+		}
+
+		return phases;
+	}
+
+
+	public String[] getOperations (String serviceName) throws Exception{
+
+		String[] operations = null;
+
+		HashMap operationsMap = axisConfig.getService(new QName(serviceName)).getOperations();
+
+		if(operationsMap !=null && !operationsMap.isEmpty()){
+
+			Collection operationsCollection = operationsMap.values();
+			operations = new String[operationsCollection.size()];
+
+			int i = 0;
+			for(Iterator iterator=operationsCollection.iterator(); iterator.hasNext();){
+				OperationDescription operationDesc = (OperationDescription)iterator.next();
+
+				operations[i] = operationDesc.getName().getLocalPart();
+				i++;
+			}
+		}
+
+		return operations;
+	}
+
+
+	public String engageModuleGlobally(String moduleName){
+
+		String info = "";
+
+		try{
+			axisConfig.engageModule(new QName(moduleName));
+			info = "Module: " + moduleName + " globally enagaged successfully.";
+		}
+		catch(AxisFault axisFault){
+			info = "Module: " + moduleName + " failed to engage globally.";
+		}
+
+		return info;
+	}
+
+
+	public String engageModuleToService(String moduleName, String serviceName){
+
+		String info = "";
+
+		if ( moduleName != null && serviceName != null) {
+
+			try {
+
+				axisConfig.getService(new QName(serviceName)).engageModule(axisConfig.getModule(new QName(moduleName)));
+				info = "Module " + moduleName + " is successfully engaged to the service " + serviceName;
+
+			} catch (AxisFault axisFault) {
+
+				info = "Failed to engage the module " + moduleName + " to the service " + serviceName;
+			}
+        }
+
+		return info;
+	}
+
+
+	public String engageModuleToOperation(String moduleName, String serviceName, String operationName){
+
+		String info = "";
+
+		if ( moduleName != null && serviceName != null && operationName != null)
{
+			try {
+				OperationDescription operation = axisConfig.getService(new QName(serviceName)).getOperation(new
QName(operationName));
+				operation.engageModule(axisConfig.getModule(new QName(moduleName)));
+
+				info = moduleName + " module engaged to the operation Successfully";
+
+			} catch (AxisFault axisFault) {
+				info = info = "Failed to engage the module " + moduleName + " to the operation " + operationName;
+			}
+        }
+
+		return info;
+
+	}
+
+
+
+}
\ No newline at end of file

Added: webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/Axis2ManagerMBean.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/Axis2ManagerMBean.java?rev=225454&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/Axis2ManagerMBean.java
(added)
+++ webservices/axis/trunk/archive/java/scratch/jmx-front/src/org/apache/axis2/management/mbeans/Axis2ManagerMBean.java
Tue Jul 26 22:21:07 2005
@@ -0,0 +1,37 @@
+/*
+ * Created on Jun 29, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis2.management.mbeans;
+
+/**
+ * @author CEkanayake
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public interface Axis2ManagerMBean {
+
+	public String[] getServices();
+
+	public String[] getFaultyServices();
+
+	public String[] getModules();
+
+	public String[] getFaultyModules();
+
+	public String[] getGloballyEngagedModules();
+
+	public String[] getPhases();
+
+	public String[] getOperations(String serviceName) throws Exception;
+
+	public String engageModuleGlobally(String moduleName);
+
+	public String engageModuleToService(String moduleName, String serviceName);
+
+	public String engageModuleToOperation(String moduleName, String serviceName, String operationName);
+
+}



Mime
View raw message