You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/08/10 16:38:14 UTC
svn commit: r564607 [4/12] - in
/incubator/servicemix/trunk/core/servicemix-core/src:
main/java/org/apache/servicemix/ main/java/org/apache/servicemix/jbi/
main/java/org/apache/servicemix/jbi/framework/
main/java/org/apache/servicemix/jbi/framework/sup...
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanServerContext.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanServerContext.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanServerContext.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanServerContext.java Fri Aug 10 07:37:46 2007
@@ -33,9 +33,8 @@
import org.apache.servicemix.jbi.jmx.ConnectorServerFactoryBean;
import org.apache.servicemix.jbi.jmx.RmiRegistryFactoryBean;
-
/**
- *Wrapper around ActiveMQ ManagementContext. Re-use to build/find mbean server
+ * Wrapper around ActiveMQ ManagementContext. Re-use to build/find mbean server
*
* @version $Revision: 372580 $
*/
@@ -44,27 +43,40 @@
/**
* Default activemq domain
*/
- public static final String DEFAULT_DOMAIN="org.apache.activemq";
- private final static Log log=LogFactory.getLog(ManagementContext.class);
+ public static final String DEFAULT_DOMAIN = "org.apache.activemq";
+
+ private static final Log LOG = LogFactory.getLog(ManagementContext.class);
+
private MBeanServer beanServer;
- private String jmxDomainName=DEFAULT_DOMAIN;
- private boolean useMBeanServer=true;
- private boolean createMBeanServer=true;
- private boolean locallyCreateMBeanServer=false;
- private boolean createConnector=true;
- private boolean findTigerMbeanServer=false;
- private int connectorPort=1099;
- private String connectorPath="/jmxrmi";
- private AtomicBoolean started=new AtomicBoolean(false);
+
+ private String jmxDomainName = DEFAULT_DOMAIN;
+
+ private boolean useMBeanServer = true;
+
+ private boolean createMBeanServer = true;
+
+ private boolean locallyCreateMBeanServer;
+
+ private boolean createConnector = true;
+
+ private boolean findTigerMbeanServer;
+
+ private int connectorPort = 1099;
+
+ private String connectorPath = "/jmxrmi";
+
+ private AtomicBoolean started = new AtomicBoolean(false);
+
private ConnectorServerFactoryBean connectorServerFactoryBean;
+
private RmiRegistryFactoryBean rmiRegistryFactoryBean;
- public MBeanServerContext(){
+ public MBeanServerContext() {
this(null);
}
- public MBeanServerContext(MBeanServer server){
- this.beanServer=server;
+ public MBeanServerContext(MBeanServer server) {
+ this.beanServer = server;
}
public void start() throws IOException {
@@ -77,28 +89,28 @@
rmiRegistryFactoryBean.setPort(connectorPort);
rmiRegistryFactoryBean.afterPropertiesSet();
} catch (Exception e) {
- log.warn("Failed to start rmi registry: " + e.getMessage());
- if (log.isDebugEnabled()) {
- log.debug("Failed to start rmi registry", e);
+ LOG.warn("Failed to start rmi registry: " + e.getMessage());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Failed to start rmi registry", e);
}
}
try {
connectorServerFactoryBean = new ConnectorServerFactoryBean();
- //connectorServerFactoryBean.setDaemon(true);
+ // connectorServerFactoryBean.setDaemon(true);
connectorServerFactoryBean.setObjectName("connector:name=rmi");
- //connectorServerFactoryBean.setThreaded(true);
+ // connectorServerFactoryBean.setThreaded(true);
connectorServerFactoryBean.setServer(getMBeanServer());
String serviceUrl = "service:jmx:rmi:///jndi/rmi://localhost:" + connectorPort + connectorPath;
connectorServerFactoryBean.setServiceUrl(serviceUrl);
connectorServerFactoryBean.afterPropertiesSet();
} catch (Exception e) {
- log.warn("Failed to start jmx connector: " + e.getMessage());
- if (log.isDebugEnabled()) {
- log.debug("Failed to create jmx connector", e);
+ LOG.warn("Failed to start jmx connector: " + e.getMessage());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Failed to create jmx connector", e);
}
}
}
- }
+ }
}
public void stop() throws IOException {
@@ -107,9 +119,9 @@
try {
connectorServerFactoryBean.destroy();
} catch (Exception e) {
- log.warn("Failed to stop jmx connector: " + e.getMessage());
- if (log.isDebugEnabled()) {
- log.debug("Failed to stop jmx connector", e);
+ LOG.warn("Failed to stop jmx connector: " + e.getMessage());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Failed to stop jmx connector", e);
}
} finally {
connectorServerFactoryBean = null;
@@ -119,9 +131,9 @@
try {
rmiRegistryFactoryBean.destroy();
} catch (RemoteException e) {
- log.warn("Failed to stop rmi registry: " + e.getMessage());
- if (log.isDebugEnabled()) {
- log.debug("Failed to stop rmi registry", e);
+ LOG.warn("Failed to stop rmi registry: " + e.getMessage());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Failed to stop rmi registry", e);
}
} finally {
rmiRegistryFactoryBean = null;
@@ -140,7 +152,7 @@
/**
* @return Returns the jmxDomainName.
*/
- public String getJmxDomainName(){
+ public String getJmxDomainName() {
return jmxDomainName;
}
@@ -148,8 +160,8 @@
* @param jmxDomainName
* The jmxDomainName to set.
*/
- public void setJmxDomainName(String jmxDomainName){
- this.jmxDomainName=jmxDomainName;
+ public void setJmxDomainName(String jmxDomainName) {
+ this.jmxDomainName = jmxDomainName;
}
/**
@@ -157,9 +169,9 @@
*
* @return the MBeanServer
*/
- public MBeanServer getMBeanServer(){
- if(this.beanServer==null){
- this.beanServer=findMBeanServer();
+ public MBeanServer getMBeanServer() {
+ if (this.beanServer == null) {
+ this.beanServer = findMBeanServer();
}
return beanServer;
}
@@ -167,16 +179,16 @@
/**
* Set the MBeanServer
*
- * @param beanServer
+ * @param mbs
*/
- public void setMBeanServer(MBeanServer beanServer){
- this.beanServer=beanServer;
+ public void setMBeanServer(MBeanServer mbs) {
+ this.beanServer = mbs;
}
/**
* @return Returns the useMBeanServer.
*/
- public boolean isUseMBeanServer(){
+ public boolean isUseMBeanServer() {
return useMBeanServer;
}
@@ -184,14 +196,14 @@
* @param useMBeanServer
* The useMBeanServer to set.
*/
- public void setUseMBeanServer(boolean useMBeanServer){
- this.useMBeanServer=useMBeanServer;
+ public void setUseMBeanServer(boolean useMBeanServer) {
+ this.useMBeanServer = useMBeanServer;
}
/**
* @return Returns the createMBeanServer flag.
*/
- public boolean isCreateMBeanServer(){
+ public boolean isCreateMBeanServer() {
return createMBeanServer;
}
@@ -199,8 +211,8 @@
* @param enableJMX
* Set createMBeanServer.
*/
- public void setCreateMBeanServer(boolean enableJMX){
- this.createMBeanServer=enableJMX;
+ public void setCreateMBeanServer(boolean enableJMX) {
+ this.createMBeanServer = enableJMX;
}
public boolean isFindTigerMbeanServer() {
@@ -219,15 +231,16 @@
*
* @param type
* @param name
- * @return the JMX ObjectName of the MBean, or <code>null</code> if <code>customName</code> is invalid.
+ * @return the JMX ObjectName of the MBean, or <code>null</code> if
+ * <code>customName</code> is invalid.
*/
- public ObjectName createCustomComponentMBeanName(String type,String name){
- ObjectName result=null;
- String tmp=jmxDomainName+":"+"type="+sanitizeString(type)+",name="+sanitizeString(name);
- try{
- result=new ObjectName(tmp);
- }catch(MalformedObjectNameException e){
- log.error("Couldn't create ObjectName from: "+type+" , "+name);
+ public ObjectName createCustomComponentMBeanName(String type, String name) {
+ ObjectName result = null;
+ String tmp = jmxDomainName + ":" + "type=" + sanitizeString(type) + ",name=" + sanitizeString(name);
+ try {
+ result = new ObjectName(tmp);
+ } catch (MalformedObjectNameException e) {
+ LOG.error("Couldn't create ObjectName from: " + type + " , " + name);
}
return result;
}
@@ -238,12 +251,12 @@
* @param in
* @return sanitized String
*/
- private static String sanitizeString(String in){
- String result=null;
- if(in!=null){
- result=in.replace(':','_');
- result=result.replace('/','_');
- result=result.replace('\\','_');
+ private static String sanitizeString(String in) {
+ String result = null;
+ if (in != null) {
+ result = in.replace(':', '_');
+ result = result.replace('/', '_');
+ result = result.replace('\\', '_');
}
return result;
}
@@ -257,19 +270,19 @@
* @return the ObjectName
* @throws MalformedObjectNameException
*/
- public static ObjectName getSystemObjectName(String domainName,String containerName,Class theClass)
- throws MalformedObjectNameException,NullPointerException{
- String tmp=domainName+":"+"type="+theClass.getName()+",name="+getRelativeName(containerName,theClass);
+ public static ObjectName getSystemObjectName(String domainName, String containerName,
+ Class theClass) throws MalformedObjectNameException, NullPointerException {
+ String tmp = domainName + ":" + "type=" + theClass.getName() + ",name=" + getRelativeName(containerName, theClass);
return new ObjectName(tmp);
}
- private static String getRelativeName(String containerName,Class theClass){
- String name=theClass.getName();
- int index=name.lastIndexOf(".");
- if(index>=0&&(index+1)<name.length()){
- name=name.substring(index+1);
+ private static String getRelativeName(String containerName, Class theClass) {
+ String name = theClass.getName();
+ int index = name.lastIndexOf(".");
+ if (index >= 0 && (index + 1) < name.length()) {
+ name = name.substring(index + 1);
}
- return containerName+"."+name;
+ return containerName + "." + name;
}
/**
@@ -278,37 +291,37 @@
* @param name
* @throws JMException
*/
- public void unregisterMBean(ObjectName name) throws JMException{
- if(beanServer!=null&&beanServer.isRegistered(name)){
+ public void unregisterMBean(ObjectName name) throws JMException {
+ if (beanServer != null && beanServer.isRegistered(name)) {
beanServer.unregisterMBean(name);
}
}
- protected synchronized MBeanServer findMBeanServer(){
- MBeanServer result=null;
+ protected synchronized MBeanServer findMBeanServer() {
+ MBeanServer result = null;
// create the mbean server
- try{
- if(useMBeanServer){
+ try {
+ if (useMBeanServer) {
if (findTigerMbeanServer) {
result = findTigerMBeanServer();
}
if (result == null) {
// lets piggy back on another MBeanServer -
// we could be in an appserver!
- List list=MBeanServerFactory.findMBeanServer(null);
- if(list!=null&&list.size()>0){
- result=(MBeanServer) list.get(0);
+ List list = MBeanServerFactory.findMBeanServer(null);
+ if (list != null && list.size() > 0) {
+ result = (MBeanServer) list.get(0);
}
}
}
- if(result==null&&createMBeanServer){
- result=createMBeanServer();
+ if (result == null && createMBeanServer) {
+ result = createMBeanServer();
}
- }catch(NoClassDefFoundError e){
- log.error("Could not load MBeanServer",e);
- }catch(Throwable e){
+ } catch (NoClassDefFoundError e) {
+ LOG.error("Could not load MBeanServer", e);
+ } catch (Throwable e) {
// probably don't have access to system properties
- log.error("Failed to initialize MBeanServer",e);
+ LOG.error("Failed to initialize MBeanServer", e);
}
return result;
}
@@ -323,21 +336,17 @@
Object answer = method.invoke(null, new Object[0]);
if (answer instanceof MBeanServer) {
return (MBeanServer) answer;
+ } else {
+ LOG.warn("Could not cast: " + answer + " into an MBeanServer. There must be some classloader strangeness in town");
}
- else {
- log.warn("Could not cast: " + answer + " into an MBeanServer. There must be some classloader strangeness in town");
- }
+ } else {
+ LOG.warn("Method getPlatformMBeanServer() does not appear visible on type: " + type.getName());
}
- else {
- log.warn("Method getPlatformMBeanServer() does not appear visible on type: " + type.getName());
- }
- }
- catch (Exception e) {
- log.warn("Failed to call getPlatformMBeanServer() due to: " + e, e);
+ } catch (Exception e) {
+ LOG.warn("Failed to call getPlatformMBeanServer() due to: " + e, e);
}
- }
- else {
- log.trace("Class not found: " + name + " so probably running on Java 1.4");
+ } else {
+ LOG.trace("Class not found: " + name + " so probably running on Java 1.4");
}
return null;
}
@@ -345,12 +354,10 @@
private static Class loadClass(String name, ClassLoader loader) {
try {
return loader.loadClass(name);
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
try {
return Thread.currentThread().getContextClassLoader().loadClass(name);
- }
- catch (ClassNotFoundException e1) {
+ } catch (ClassNotFoundException e1) {
return null;
}
}
@@ -362,33 +369,33 @@
* @throws MalformedObjectNameException
* @throws IOException
*/
- protected MBeanServer createMBeanServer() throws MalformedObjectNameException,IOException{
- MBeanServer mbeanServer=MBeanServerFactory.createMBeanServer(jmxDomainName);
- locallyCreateMBeanServer=true;
+ protected MBeanServer createMBeanServer() throws MalformedObjectNameException, IOException {
+ MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(jmxDomainName);
+ locallyCreateMBeanServer = true;
return mbeanServer;
}
- public String getConnectorPath(){
+ public String getConnectorPath() {
return connectorPath;
}
- public void setConnectorPath(String connectorPath){
- this.connectorPath=connectorPath;
+ public void setConnectorPath(String connectorPath) {
+ this.connectorPath = connectorPath;
}
- public int getConnectorPort(){
+ public int getConnectorPort() {
return connectorPort;
}
- public void setConnectorPort(int connectorPort){
- this.connectorPort=connectorPort;
+ public void setConnectorPort(int connectorPort) {
+ this.connectorPort = connectorPort;
}
- public boolean isCreateConnector(){
+ public boolean isCreateConnector() {
return createConnector;
}
- public void setCreateConnector(boolean createConnector){
- this.createConnector=createConnector;
+ public void setCreateConnector(boolean createConnector) {
+ this.createConnector = createConnector;
}
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java Fri Aug 10 07:37:46 2007
@@ -21,6 +21,10 @@
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
import javax.jbi.JBIException;
import javax.management.JMException;
import javax.management.MBeanAttributeInfo;
@@ -28,14 +32,12 @@
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.jbi.container.EnvironmentContext;
import org.apache.servicemix.jbi.container.JBIContainer;
import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
/**
* Management Context applied to a ServiceMix container
@@ -47,12 +49,19 @@
* Default servicemix domain
*/
public static final String DEFAULT_DOMAIN = "org.apache.servicemix";
+
public static final String DEFAULT_CONNECTOR_PATH = "/jmxrmi";
+
public static final int DEFAULT_CONNECTOR_PORT = 1099;
- private final static Log log = LogFactory.getLog(ManagementContext.class);
- private Map<ObjectName, Object> beanMap = new ConcurrentHashMap<ObjectName, Object>();
+
+ private static final Log LOG = LogFactory.getLog(ManagementContext.class);
+
protected Map<String, ObjectName> systemServices = new ConcurrentHashMap<String, ObjectName>();
+
+ private Map<ObjectName, Object> beanMap = new ConcurrentHashMap<ObjectName, Object>();
+
private MBeanServerContext mbeanServerContext = new MBeanServerContext();
+
private ExecutorService executors;
/**
@@ -71,8 +80,6 @@
return "JMX Management";
}
-
-
/**
* Get the MBeanServer
*
@@ -81,16 +88,14 @@
public MBeanServer getMBeanServer() {
return mbeanServerContext.getMBeanServer();
}
-
+
/**
* @return the domain
*/
- public String getJmxDomainName(){
+ public String getJmxDomainName() {
return mbeanServerContext.getJmxDomainName();
}
-
-
/**
* @return Returns the useMBeanServer.
*/
@@ -99,12 +104,13 @@
}
/**
- * @param useMBeanServer The useMBeanServer to set.
+ * @param useMBeanServer
+ * The useMBeanServer to set.
*/
public void setUseMBeanServer(boolean useMBeanServer) {
mbeanServerContext.setUseMBeanServer(useMBeanServer);
}
-
+
/**
* @return Returns the createMBeanServer flag.
*/
@@ -113,12 +119,13 @@
}
/**
- * @param enableJMX Set createMBeanServer.
+ * @param enableJMX
+ * Set createMBeanServer.
*/
public void setCreateMBeanServer(boolean enableJMX) {
mbeanServerContext.setCreateMBeanServer(enableJMX);
}
-
+
public void setNamingPort(int portNum) {
mbeanServerContext.setConnectorPort(portNum);
}
@@ -126,11 +133,11 @@
public int getNamingPort() {
return mbeanServerContext.getConnectorPort();
}
-
+
public boolean isCreateJmxConnector() {
return mbeanServerContext.isCreateConnector();
}
-
+
public void setCreateJmxConnector(boolean createJmxConnector) {
mbeanServerContext.setCreateConnector(createJmxConnector);
}
@@ -140,10 +147,10 @@
*
* @param container
* @param server
- * @throws JBIException
-
+ * @throws JBIException
+ *
*/
- public void init(JBIContainer container, MBeanServer server) throws JBIException {
+ public void init(JBIContainer container, MBeanServer server) throws JBIException {
if (container.isEmbedded() && server == null) {
mbeanServerContext.setUseMBeanServer(false);
mbeanServerContext.setCreateMBeanServer(false);
@@ -152,12 +159,12 @@
try {
mbeanServerContext.start();
} catch (IOException e) {
- log.error("Failed to start mbeanServerContext", e);
+ LOG.error("Failed to start mbeanServerContext", e);
}
this.executors = Executors.newCachedThreadPool();
super.init(container);
}
-
+
protected Class<ManagementContextMBean> getServiceMBean() {
return ManagementContextMBean.class;
}
@@ -165,7 +172,8 @@
/**
* Start the item.
*
- * @exception JBIException if the item fails to start.
+ * @exception JBIException
+ * if the item fails to start.
*/
public void start() throws JBIException {
super.start();
@@ -174,16 +182,19 @@
/**
* Stop the item. This suspends current messaging activities.
*
- * @exception JBIException if the item fails to stop.
+ * @exception JBIException
+ * if the item fails to stop.
*/
public void stop() throws JBIException {
super.stop();
}
/**
- * Shut down the item. The releases resources, preparatory to uninstallation.
+ * Shut down the item. The releases resources, preparatory to
+ * uninstallation.
*
- * @exception JBIException if the item fails to shut down.
+ * @exception JBIException
+ * if the item fails to shut down.
*/
public void shutDown() throws JBIException {
super.shutDown();
@@ -193,13 +204,13 @@
try {
unregisterMBean(beans[i]);
} catch (Exception e) {
- log.debug("Could not unregister mbean", e);
+ LOG.debug("Could not unregister mbean", e);
}
}
- try{
+ try {
mbeanServerContext.stop();
- }catch(IOException e){
- log.debug("Failed to shutdown mbeanServerContext cleanly",e);
+ } catch (IOException e) {
+ LOG.debug("Failed to shutdown mbeanServerContext cleanly", e);
}
executors.shutdown();
}
@@ -216,7 +227,8 @@
/**
* Lookup a JBI Installable Component by its unique name.
*
- * @param componentName - is the name of the BC or SE.
+ * @param componentName -
+ * is the name of the BC or SE.
* @return the JMX object name of the component's LifeCycle MBean or null.
*/
public ObjectName getComponentByName(String componentName) {
@@ -232,11 +244,11 @@
public ObjectName[] getEngineComponents() {
return container.getRegistry().getEngineComponents();
}
-
+
/**
* @return an array of ObjectNames for all Pojo components
- */
- public ObjectName[] getPojoComponents(){
+ */
+ public ObjectName[] getPojoComponents() {
return container.getRegistry().getPojoComponents();
}
@@ -252,7 +264,8 @@
/**
* Lookup a system service by name.
*
- * @param serviceName - is the name of the system service
+ * @param serviceName -
+ * is the name of the system service
* @return the JMX object name of the service or null
*/
public ObjectName getSystemService(String serviceName) {
@@ -275,7 +288,8 @@
/**
* Check if a given JBI Installable Component is a Binding Component.
*
- * @param componentName - the unique name of the component
+ * @param componentName -
+ * the unique name of the component
* @return true if the component is a binding
*/
public boolean isBinding(String componentName) {
@@ -286,7 +300,8 @@
/**
* Check if a given JBI Component is a service engine.
*
- * @param componentName - the unique name of the component
+ * @param componentName -
+ * the unique name of the component
* @return true if the component is a service engine
*/
public boolean isEngine(String componentName) {
@@ -355,11 +370,13 @@
}
/**
- * Formulate and return the MBean ObjectName of a custom control MBean for a JBI component.
+ * Formulate and return the MBean ObjectName of a custom control MBean for a
+ * JBI component.
*
* @param type
* @param name
- * @return the JMX ObjectName of the MBean, or <code>null</code> if <code>customName</code> is invalid.
+ * @return the JMX ObjectName of the MBean, or <code>null</code> if
+ * <code>customName</code> is invalid.
*/
public ObjectName createCustomComponentMBeanName(String type, String name) {
Map<String, String> result = new LinkedHashMap<String, String>();
@@ -370,7 +387,6 @@
return createObjectName(result);
}
-
/**
* Create an ObjectName
*
@@ -381,10 +397,11 @@
Map<String, String> props = createObjectNameProps(provider);
return createObjectName(props);
}
-
+
/**
* Create an ObjectName
- * @param name
+ *
+ * @param name
*
* @return the ObjectName
*/
@@ -392,19 +409,19 @@
ObjectName result = null;
try {
result = new ObjectName(name);
- }
- catch (MalformedObjectNameException e) {
+ } catch (MalformedObjectNameException e) {
// shouldn't happen
String error = "Could not create ObjectName for " + name;
- log.error(error, e);
+ LOG.error(error, e);
throw new RuntimeException(error);
}
return result;
}
-
+
/**
* Create an ObjectName
- * @param domain
+ *
+ * @param domain
*
* @return the ObjectName
*/
@@ -422,32 +439,32 @@
ObjectName result = null;
try {
result = new ObjectName(sb.toString());
- }
- catch (MalformedObjectNameException e) {
+ } catch (MalformedObjectNameException e) {
// shouldn't happen
String error = "Could not create ObjectName for " + props;
- log.error(error, e);
+ LOG.error(error, e);
throw new RuntimeException(error);
}
return result;
}
-
+
/**
* Create an ObjectName
+ *
* @param props
* @return the ObjectName
*/
public ObjectName createObjectName(Map<String, String> props) {
return createObjectName(getJmxDomainName(), props);
}
-
+
/**
* Create a String used to create an ObjectName
*
* @param provider
* @return the ObjectName
*/
- public Map<String, String> createObjectNameProps(MBeanInfoProvider provider){
+ public Map<String, String> createObjectNameProps(MBeanInfoProvider provider) {
return createObjectNameProps(provider, false);
}
@@ -511,8 +528,7 @@
* @param description
* @throws JMException
*/
- public void registerMBean(ObjectName name, Object resource, Class interfaceMBean, String description)
- throws JMException {
+ public void registerMBean(ObjectName name, Object resource, Class interfaceMBean, String description) throws JMException {
if (mbeanServerContext.getMBeanServer() != null) {
Object mbean = MBeanBuilder.buildStandardMBean(resource, interfaceMBean, description, executors);
if (mbeanServerContext.getMBeanServer().isRegistered(name)) {
@@ -523,7 +539,6 @@
}
}
-
/**
* Retrive an System ObjectName
*
@@ -533,20 +548,18 @@
* @return the ObjectName
*/
public static ObjectName getSystemObjectName(String domainName, String containerName, Class interfaceType) {
- String tmp = domainName + ":ContainerName=" + containerName + ",Type=SystemService,Name=" + getSystemServiceName(interfaceType);
+ String tmp = domainName + ":ContainerName=" + containerName + ",Type=SystemService,Name=" + getSystemServiceName(interfaceType);
ObjectName result = null;
try {
result = new ObjectName(tmp);
- }
- catch (MalformedObjectNameException e) {
- log.error("Failed to build ObjectName:",e);
- }
- catch (NullPointerException e) {
- log.error("Failed to build ObjectName:",e);
+ } catch (MalformedObjectNameException e) {
+ LOG.error("Failed to build ObjectName:", e);
+ } catch (NullPointerException e) {
+ LOG.error("Failed to build ObjectName:", e);
}
return result;
}
-
+
public static String getSystemServiceName(Class interfaceType) {
String name = interfaceType.getName();
name = name.substring(name.lastIndexOf('.') + 1);
@@ -555,18 +568,16 @@
}
return name;
}
-
+
public static ObjectName getContainerObjectName(String domainName, String containerName) {
String tmp = domainName + ":ContainerName=" + containerName + ",Type=JBIContainer";
ObjectName result = null;
try {
result = new ObjectName(tmp);
- }
- catch (MalformedObjectNameException e) {
- log.debug("Unable to build ObjectName", e);
- }
- catch (NullPointerException e) {
- log.debug("Unable to build ObjectName", e);
+ } catch (MalformedObjectNameException e) {
+ LOG.debug("Unable to build ObjectName", e);
+ } catch (NullPointerException e) {
+ LOG.debug("Unable to build ObjectName", e);
}
return result;
}
@@ -586,23 +597,21 @@
throw new JBIException("A system service for the name " + name + " is already registered");
}
ObjectName objName = createObjectName(service);
- if (log.isDebugEnabled()) {
- log.debug("Registering system service: " + objName);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Registering system service: " + objName);
}
registerMBean(objName, service, interfaceType, service.getDescription());
systemServices.put(name, objName);
- }
- catch (MalformedObjectNameException e) {
+ } catch (MalformedObjectNameException e) {
throw new JBIException(e);
- }
- catch (JMException e) {
+ } catch (JMException e) {
throw new JBIException(e);
}
}
/**
* Unregister a System service
- *
+ *
* @param service
* @throws JBIException
*/
@@ -612,8 +621,8 @@
throw new JBIException("A system service for the name " + name + " is not registered");
}
ObjectName objName = systemServices.remove(name);
- if (log.isDebugEnabled()) {
- log.debug("Unregistering system service: " + objName);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Unregistering system service: " + objName);
}
unregisterMBean(objName);
}
@@ -625,11 +634,11 @@
* @throws JBIException
*/
public void unregisterMBean(ObjectName name) throws JBIException {
- try{
+ try {
mbeanServerContext.unregisterMBean(name);
beanMap.remove(name);
- }catch(JMException e){
- log.error("Failed to unregister mbean: " + name,e);
+ } catch (JMException e) {
+ LOG.error("Failed to unregister mbean: " + name, e);
throw new JBIException(e);
}
}
@@ -641,18 +650,16 @@
* @throws JBIException
*/
public void unregisterMBean(Object bean) throws JBIException {
- for (Iterator i = beanMap.entrySet().iterator();i.hasNext();) {
+ for (Iterator i = beanMap.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
if (entry.getValue() == bean) {
- ObjectName name = (ObjectName) entry.getKey();
- unregisterMBean(name);
+ ObjectName name = (ObjectName) entry.getKey();
+ unregisterMBean(name);
break;
}
}
}
-
-
/**
* Get an array of MBeanOperationInfo
*
@@ -660,26 +667,26 @@
* @throws JMException
*/
public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
- AttributeInfoHelper helper = new AttributeInfoHelper();
- helper.addAttribute(getObjectToManage(), "bindingComponents", "Get list of all binding components");
- helper.addAttribute(getObjectToManage(), "engineComponents", "Get list of all engine components");
+ AttributeInfoHelper helper = new AttributeInfoHelper();
+ helper.addAttribute(getObjectToManage(), "bindingComponents", "Get list of all binding components");
+ helper.addAttribute(getObjectToManage(), "engineComponents", "Get list of all engine components");
helper.addAttribute(getObjectToManage(), "pojoComponents", "Get list of all pojo components");
- helper.addAttribute(getObjectToManage(), "systemInfo", "Return current version");
- helper.addAttribute(getObjectToManage(), "systemServices", "Get list of system services");
- return AttributeInfoHelper.join(super.getAttributeInfos(), helper.getAttributeInfos());
+ helper.addAttribute(getObjectToManage(), "systemInfo", "Return current version");
+ helper.addAttribute(getObjectToManage(), "systemServices", "Get list of system services");
+ return AttributeInfoHelper.join(super.getAttributeInfos(), helper.getAttributeInfos());
}
public MBeanOperationInfo[] getOperationInfos() throws JMException {
- OperationInfoHelper helper = new OperationInfoHelper();
- ParameterHelper ph = helper.addOperation(getObjectToManage(), "getComponentByName", 1, "look up Component by name");
- ph.setDescription(0, "name", "Component name");
- ph = helper.addOperation(getObjectToManage(), "getSystemService", 1, "look up System service by name");
- ph.setDescription(0, "name", "System name");
- ph = helper.addOperation(getObjectToManage(), "isBinding", 1, "Is Component a binding Component?");
- ph.setDescription(0, "name", "Component name");
- ph = helper.addOperation(getObjectToManage(), "isEngine", 1, "Is Component a service engine?");
- ph.setDescription(0, "name", "Component name");
- return OperationInfoHelper.join(super.getOperationInfos(), helper.getOperationInfos());
- }
-
+ OperationInfoHelper helper = new OperationInfoHelper();
+ ParameterHelper ph = helper.addOperation(getObjectToManage(), "getComponentByName", 1, "look up Component by name");
+ ph.setDescription(0, "name", "Component name");
+ ph = helper.addOperation(getObjectToManage(), "getSystemService", 1, "look up System service by name");
+ ph.setDescription(0, "name", "System name");
+ ph = helper.addOperation(getObjectToManage(), "isBinding", 1, "Is Component a binding Component?");
+ ph.setDescription(0, "name", "Component name");
+ ph = helper.addOperation(getObjectToManage(), "isEngine", 1, "Is Component a service engine?");
+ ph.setDescription(0, "name", "Component name");
+ return OperationInfoHelper.join(super.getOperationInfos(), helper.getOperationInfos());
+ }
+
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContextMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContextMBean.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContextMBean.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContextMBean.java Fri Aug 10 07:37:46 2007
@@ -40,7 +40,7 @@
* @return the status
* @throws JBIException
*/
- public String startComponent(String componentName) throws JBIException;
+ String startComponent(String componentName) throws JBIException;
/**
* Stop a Component
@@ -49,7 +49,7 @@
* @return the status
* @throws JBIException
*/
- public String stopComponent(String componentName) throws JBIException;
+ String stopComponent(String componentName) throws JBIException;
/**
* Shutdown a Component
@@ -58,5 +58,5 @@
* @return the status
* @throws JBIException
*/
- public String shutDownComponent(String componentName) throws JBIException;
+ String shutDownComponent(String componentName) throws JBIException;
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/OperationInfoHelper.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/OperationInfoHelper.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/OperationInfoHelper.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/OperationInfoHelper.java Fri Aug 10 07:37:46 2007
@@ -16,13 +16,13 @@
*/
package org.apache.servicemix.jbi.management;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+
/**
* A Helper class to build an MBeanOperationInfo
*
@@ -110,15 +110,15 @@
Method result = null;
Method[] methods = theClass.getMethods();
if (methods != null) {
- for (int i = 0;i < methods.length;i++) {
+ for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equals(name) && methods[i].getParameterTypes().length == numParams) {
result = methods[i];
break;
}
}
- if (result == null){
- //do a less exact search
- for (int i = 0;i < methods.length;i++) {
+ if (result == null) {
+ // do a less exact search
+ for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equals(name)) {
result = methods[i];
break;
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ParameterHelper.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ParameterHelper.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ParameterHelper.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ParameterHelper.java Fri Aug 10 07:37:46 2007
@@ -25,19 +25,20 @@
*/
public class ParameterHelper {
private MBeanParameterInfo[] infos;
-
- ParameterHelper(MBeanParameterInfo[] infos){
+
+ ParameterHelper(MBeanParameterInfo[] infos) {
this.infos = infos;
}
-
+
/**
* Decorate a paramter
+ *
* @param index
* @param name
* @param description
*/
- public void setDescription(int index, String name,String description){
+ public void setDescription(int index, String name, String description) {
MBeanParameterInfo old = infos[index];
- infos[index] = new MBeanParameterInfo(name,old.getType(),description);
+ infos[index] = new MBeanParameterInfo(name, old.getType(), description);
}
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/DeployServiceAssemblyTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/DeployServiceAssemblyTask.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/DeployServiceAssemblyTask.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/DeployServiceAssemblyTask.java Fri Aug 10 07:37:46 2007
@@ -28,52 +28,52 @@
*/
public class DeployServiceAssemblyTask extends JbiTask {
- private String file; // archivePath to install
+ private String file; // archivePath to install
- private boolean deferExceptions = false;
+ private boolean deferExceptions;
- public boolean isDeferExceptions() {
- return deferExceptions;
- }
-
- public void setDeferExceptions(boolean deferExceptions) {
- this.deferExceptions = deferExceptions;
- }
-
- /**
- * @return Returns the archivePath.
- */
- public String getFile() {
- return file;
- }
-
- /**
- * @param file
- * The archivePath to set.
- */
- public void setFile(String file) {
- this.file = file;
- }
-
- /**
- * execute the task
- *
- * @throws BuildException
- */
- public void doExecute(AdminCommandsServiceMBean acs) throws Exception {
- if (file == null) {
- throw new BuildException("null file - file should be an archive");
- }
- if (!file.endsWith(".zip") && !file.endsWith(".jar")) {
- throw new BuildException("file: " + file + " is not an archive");
- }
- File archive = new File(file);
- String location = archive.getAbsolutePath();
- if (!archive.isFile()) {
- // if it's not a file, assume it's a url and pass it along
- location = file;
- }
- acs.deployServiceAssembly(location, deferExceptions);
- }
+ public boolean isDeferExceptions() {
+ return deferExceptions;
+ }
+
+ public void setDeferExceptions(boolean deferExceptions) {
+ this.deferExceptions = deferExceptions;
+ }
+
+ /**
+ * @return Returns the archivePath.
+ */
+ public String getFile() {
+ return file;
+ }
+
+ /**
+ * @param file
+ * The archivePath to set.
+ */
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ /**
+ * execute the task
+ *
+ * @throws BuildException
+ */
+ public void doExecute(AdminCommandsServiceMBean acs) throws Exception {
+ if (file == null) {
+ throw new BuildException("null file - file should be an archive");
+ }
+ if (!file.endsWith(".zip") && !file.endsWith(".jar")) {
+ throw new BuildException("file: " + file + " is not an archive");
+ }
+ File archive = new File(file);
+ String location = archive.getAbsolutePath();
+ if (!archive.isFile()) {
+ // if it's not a file, assume it's a url and pass it along
+ location = file;
+ }
+ acs.deployServiceAssembly(location, deferExceptions);
+ }
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/InstallComponentTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/InstallComponentTask.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/InstallComponentTask.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/InstallComponentTask.java Fri Aug 10 07:37:46 2007
@@ -34,110 +34,110 @@
*/
public class InstallComponentTask extends JbiTask {
- private String file; // file to install
+ private String file; // file to install
- private String paramsFile;
+ private String paramsFile;
- private List nestedParams;
+ private List nestedParams;
- private boolean deferExceptions = false;
+ private boolean deferExceptions;
- public boolean isDeferExceptions() {
- return deferExceptions;
- }
-
- public void setDeferExceptions(boolean deferExceptions) {
- this.deferExceptions = deferExceptions;
- }
-
- /**
- * @return Returns the file.
- */
- public String getFile() {
- return file;
- }
-
- /**
- * @param file
- * The file to set.
- */
- public void setFile(String file) {
- this.file = file;
- }
-
- public String getParams() {
- return paramsFile;
- }
-
- public void setParams(String paramsFile) {
- this.paramsFile = paramsFile;
- }
-
- public Param createParam() {
- Param p = new Param();
- if (nestedParams == null) {
- nestedParams = new ArrayList();
- }
- nestedParams.add(p);
- return p;
- }
-
- /**
- * execute the task
- *
- * @throws BuildException
- */
- public void doExecute(AdminCommandsServiceMBean acs) throws Exception {
- if (file == null) {
- throw new BuildException("null file - file should be an archive");
- }
- if (!file.endsWith(".zip") && !file.endsWith(".jar")) {
- throw new BuildException("file: " + file + " is not an archive");
- }
- File archive = new File(file);
- String location = archive.getAbsolutePath();
- if (!archive.isFile()) {
- // if it's not a file, assume it's a url and pass it along
- location = file;
- }
- Properties props = getProperties();
- acs.installComponent(location, props, deferExceptions);
- }
-
- private Properties getProperties() throws IOException {
- Properties props = new Properties();
- if (paramsFile != null) {
- props.load(new FileInputStream(paramsFile));
- }
- if (nestedParams != null) {
- for (Iterator iter = nestedParams.iterator(); iter.hasNext();) {
- Param p = (Param) iter.next();
- props.setProperty(p.getName(), p.getValue());
- }
- }
- return props;
- }
-
- public static class Param {
- private String name;
-
- private String value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
- }
+ public boolean isDeferExceptions() {
+ return deferExceptions;
+ }
+
+ public void setDeferExceptions(boolean deferExceptions) {
+ this.deferExceptions = deferExceptions;
+ }
+
+ /**
+ * @return Returns the file.
+ */
+ public String getFile() {
+ return file;
+ }
+
+ /**
+ * @param file
+ * The file to set.
+ */
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ public String getParams() {
+ return paramsFile;
+ }
+
+ public void setParams(String params) {
+ this.paramsFile = params;
+ }
+
+ public Param createParam() {
+ Param p = new Param();
+ if (nestedParams == null) {
+ nestedParams = new ArrayList();
+ }
+ nestedParams.add(p);
+ return p;
+ }
+
+ /**
+ * execute the task
+ *
+ * @throws BuildException
+ */
+ public void doExecute(AdminCommandsServiceMBean acs) throws Exception {
+ if (file == null) {
+ throw new BuildException("null file - file should be an archive");
+ }
+ if (!file.endsWith(".zip") && !file.endsWith(".jar")) {
+ throw new BuildException("file: " + file + " is not an archive");
+ }
+ File archive = new File(file);
+ String location = archive.getAbsolutePath();
+ if (!archive.isFile()) {
+ // if it's not a file, assume it's a url and pass it along
+ location = file;
+ }
+ Properties props = getProperties();
+ acs.installComponent(location, props, deferExceptions);
+ }
+
+ private Properties getProperties() throws IOException {
+ Properties props = new Properties();
+ if (paramsFile != null) {
+ props.load(new FileInputStream(paramsFile));
+ }
+ if (nestedParams != null) {
+ for (Iterator iter = nestedParams.iterator(); iter.hasNext();) {
+ Param p = (Param) iter.next();
+ props.setProperty(p.getName(), p.getValue());
+ }
+ }
+ return props;
+ }
+
+ public static class Param {
+ private String name;
+
+ private String value;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/InstallSharedLibraryTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/InstallSharedLibraryTask.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/InstallSharedLibraryTask.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/InstallSharedLibraryTask.java Fri Aug 10 07:37:46 2007
@@ -28,52 +28,52 @@
*/
public class InstallSharedLibraryTask extends JbiTask {
- private String file; // shared library URI to install
+ private String file; // shared library URI to install
- private boolean deferExceptions = false;
+ private boolean deferExceptions;
- public boolean isDeferExceptions() {
- return deferExceptions;
- }
-
- public void setDeferExceptions(boolean deferExceptions) {
- this.deferExceptions = deferExceptions;
- }
-
- /**
- * @return Returns the file.
- */
- public String getFile() {
- return file;
- }
-
- /**
- * @param file
- * The shared library URI to set.
- */
- public void setFile(String file) {
- this.file = file;
- }
-
- /**
- * execute the task
- *
- * @throws BuildException
- */
- public void doExecute(AdminCommandsServiceMBean acs) throws Exception {
- if (file == null) {
- throw new BuildException("null file - file should be an archive");
- }
- if (!file.endsWith(".zip") && !file.endsWith(".jar")) {
- throw new BuildException("file: " + file + " is not an archive");
- }
- File archive = new File(file);
- String location = archive.getAbsolutePath();
- if (!archive.isFile()) {
- // if it's not a file, assume it's a url and pass it along
- location = file;
- }
- acs.installSharedLibrary(location, deferExceptions);
- }
+ public boolean isDeferExceptions() {
+ return deferExceptions;
+ }
+
+ public void setDeferExceptions(boolean deferExceptions) {
+ this.deferExceptions = deferExceptions;
+ }
+
+ /**
+ * @return Returns the file.
+ */
+ public String getFile() {
+ return file;
+ }
+
+ /**
+ * @param file
+ * The shared library URI to set.
+ */
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ /**
+ * execute the task
+ *
+ * @throws BuildException
+ */
+ public void doExecute(AdminCommandsServiceMBean acs) throws Exception {
+ if (file == null) {
+ throw new BuildException("null file - file should be an archive");
+ }
+ if (!file.endsWith(".zip") && !file.endsWith(".jar")) {
+ throw new BuildException("file: " + file + " is not an archive");
+ }
+ File archive = new File(file);
+ String location = archive.getAbsolutePath();
+ if (!archive.isFile()) {
+ // if it's not a file, assume it's a url and pass it along
+ location = file;
+ }
+ acs.installSharedLibrary(location, deferExceptions);
+ }
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/JbiTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/JbiTask.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/JbiTask.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/JbiTask.java Fri Aug 10 07:37:46 2007
@@ -40,159 +40,184 @@
* @version $Revision$
*/
public abstract class JbiTask extends Task {
-
+
private String serverProtocol = "rmi";
+
private String host = "localhost";
+
private String containerName = JBIContainer.DEFAULT_NAME;
+
private String jmxDomainName = ManagementContext.DEFAULT_DOMAIN;
+
private int port = ManagementContext.DEFAULT_CONNECTOR_PORT;
+
private String jndiPath = ManagementContext.DEFAULT_CONNECTOR_PATH;
+
private String username;
+
private String password;
+
private boolean failOnError = true;
+
private JMXConnector jmxConnector;
-
-
+
/**
* Get the JMXServiceURL - built from the protocol used and host names
+ *
* @return the url
*/
public JMXServiceURL getServiceURL() throws MalformedURLException {
JMXServiceURL url = null;
- url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"
- + host + ":" + port + jndiPath);
+ url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + host + ":" + port + jndiPath);
return url;
}
-
+
/**
* Get a JMXConnector from a url
+ *
* @param url
* @return the JMXConnector
* @throws IOException
*/
- public JMXConnector getJMXConnector (JMXServiceURL url) throws IOException {
- String[] credentials = new String[] { getUsername(), getPassword() };
- Map<String,Object> environment = new HashMap<String,Object>();
+ public JMXConnector getJMXConnector(JMXServiceURL url) throws IOException {
+ String[] credentials = new String[] {getUsername(), getPassword() };
+ Map<String, Object> environment = new HashMap<String, Object>();
environment.put(JMXConnector.CREDENTIALS, credentials);
return JMXConnectorFactory.connect(url, environment);
}
-
+
/**
* initialize the connection
+ *
* @throws BuildException
*/
public void connect() throws IOException {
this.jmxConnector = getJMXConnector(getServiceURL());
}
-
-
+
/**
* close any internal remote connections
- *
+ *
*/
- public void close(){
- if (this.jmxConnector != null){
+ public void close() {
+ if (this.jmxConnector != null) {
try {
jmxConnector.close();
- }
- catch (IOException e) {
+ } catch (IOException e) {
log("Caught an error closing the jmxConnector" + e.getMessage(), Project.MSG_WARN);
}
}
}
-
-
+
/**
- * Get a servicemix internal system management instance, from it's class name
+ * Get a servicemix internal system management instance, from it's class
+ * name
+ *
* @param systemClass
* @return the object name
*/
- protected ObjectName getObjectName (Class systemClass){
+ protected ObjectName getObjectName(Class systemClass) {
return ManagementContext.getSystemObjectName(jmxDomainName, containerName, systemClass);
}
-
-
+
/**
* Get the AdminCommandsService
+ *
* @return the main administration service MBean
* @throws IOException
*/
- public AdminCommandsServiceMBean getAdminCommandsService() throws IOException{
+ public AdminCommandsServiceMBean getAdminCommandsService() throws IOException {
ObjectName objectName = getObjectName(AdminCommandsServiceMBean.class);
-
- return (AdminCommandsServiceMBean) MBeanServerInvocationHandler.newProxyInstance(jmxConnector.getMBeanServerConnection(), objectName,
- AdminCommandsServiceMBean.class, true);
+
+ return (AdminCommandsServiceMBean) MBeanServerInvocationHandler.newProxyInstance(jmxConnector.getMBeanServerConnection(),
+ objectName, AdminCommandsServiceMBean.class, true);
}
-
+
/**
* @return Returns the containerName.
*/
public String getContainerName() {
return containerName;
}
+
/**
- * @param containerName The containerName to set.
+ * @param containerName
+ * The containerName to set.
*/
public void setContainerName(String containerName) {
this.containerName = containerName;
}
+
/**
* @return Returns the jmxDomainName.
*/
public String getJmxDomainName() {
return jmxDomainName;
}
+
/**
- * @param jmxDomainName The jmxDomainName to set.
+ * @param jmxDomainName
+ * The jmxDomainName to set.
*/
public void setJmxDomainName(String jmxDomainName) {
this.jmxDomainName = jmxDomainName;
}
+
/**
* @return Returns the jndiPath.
*/
public String getJndiPath() {
return jndiPath;
}
+
/**
- * @param jndiPath The jndiPath to set.
+ * @param jndiPath
+ * The jndiPath to set.
*/
public void setJndiPath(String jndiPath) {
this.jndiPath = jndiPath;
}
+
/**
* @return Returns the namingHost.
*/
public String getHost() {
return host;
}
+
/**
- * @param host The namingHost to set.
+ * @param host
+ * The namingHost to set.
*/
public void setHost(String host) {
this.host = host;
}
+
/**
* @return Returns the namingPort.
*/
public int getPort() {
return port;
}
+
/**
- * @param port The namingPort to set.
+ * @param port
+ * The namingPort to set.
*/
public void setPort(int port) {
this.port = port;
}
-
+
/**
* @return Returns the serverProtocol.
*/
public String getServerProtocol() {
return serverProtocol;
}
+
/**
- * @param serverProtocol The serverProtocol to set.
+ * @param serverProtocol
+ * The serverProtocol to set.
*/
public void setServerProtocol(String serverProtocol) {
this.serverProtocol = serverProtocol;
@@ -206,7 +231,8 @@
}
/**
- * @param password The passwd to set.
+ * @param password
+ * The passwd to set.
*/
public void setPassword(String password) {
this.password = password;
@@ -220,12 +246,13 @@
}
/**
- * @param username The username to set.
+ * @param username
+ * The username to set.
*/
public void setUsername(String username) {
this.username = username;
}
-
+
/**
* @return Returns the failOnError.
*/
@@ -234,12 +261,13 @@
}
/**
- * @param failOnError The failOnError to set.
+ * @param failOnError
+ * The failOnError to set.
*/
public void setFailOnError(boolean failOnError) {
this.failOnError = failOnError;
}
-
+
/**
* execute the task
*
@@ -271,7 +299,7 @@
}
}
}
-
+
protected abstract void doExecute(AdminCommandsServiceMBean acs) throws Exception;
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListBindingComponentsTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListBindingComponentsTask.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListBindingComponentsTask.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListBindingComponentsTask.java Fri Aug 10 07:37:46 2007
@@ -17,20 +17,23 @@
package org.apache.servicemix.jbi.management.task;
import org.apache.servicemix.jbi.framework.AdminCommandsServiceMBean;
-import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
/**
* ListBindingComponentsTask
- *
- * @version $Revision:
+ *
+ * @version $Revision:
*/
public class ListBindingComponentsTask extends JbiTask {
-
+
private String sharedLibraryName;
+
private String serviceAssemblyName;
+
private String bindingComponentName;
+
private String state;
+
private String xmlOutput;
/**
@@ -41,14 +44,15 @@
}
/**
- * @param xmlOutput the xmlOutput to set
+ * @param xmlOutput
+ * the xmlOutput to set
*/
public void setXmlOutput(String xmlOutput) {
this.xmlOutput = xmlOutput;
}
/**
- *
+ *
* @return shared library name
*/
public String getSharedLibraryName() {
@@ -56,7 +60,7 @@
}
/**
- *
+ *
* @param sharedLibraryName
*/
public void setSharedLibraryName(String sharedLibraryName) {
@@ -64,7 +68,7 @@
}
/**
- *
+ *
* @return service assembly name
*/
public String getServiceAssemblyName() {
@@ -72,7 +76,7 @@
}
/**
- *
+ *
* @param serviceAssemblyName
*/
public void setServiceAssemblyName(String serviceAssemblyName) {
@@ -80,7 +84,7 @@
}
/**
- *
+ *
* @return binding component name
*/
public String getBindingComponentName() {
@@ -88,7 +92,7 @@
}
/**
- *
+ *
* @param bindingComponentName
*/
public void setBindingComponentName(String bindingComponentName) {
@@ -96,7 +100,7 @@
}
/**
- *
+ *
* @return component state
*/
public String getState() {
@@ -104,8 +108,9 @@
}
/**
- *
- * @param state Sets the component state
+ *
+ * @param state
+ * Sets the component state
*/
public void setState(String state) {
this.state = state;
@@ -123,5 +128,5 @@
}
log(result, Project.MSG_WARN);
}
-
+
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListServiceAssembliesTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListServiceAssembliesTask.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListServiceAssembliesTask.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListServiceAssembliesTask.java Fri Aug 10 07:37:46 2007
@@ -17,7 +17,6 @@
package org.apache.servicemix.jbi.management.task;
import org.apache.servicemix.jbi.framework.AdminCommandsServiceMBean;
-import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
/**
@@ -26,10 +25,13 @@
* @version $Revision: 379004 $
*/
public class ListServiceAssembliesTask extends JbiTask {
-
+
private String state;
+
private String componentName;
+
private String serviceAssemblyName;
+
private String xmlOutput;
/**
@@ -40,15 +42,15 @@
}
/**
- * @param xmlOutput the xmlOutput to set
+ * @param xmlOutput
+ * the xmlOutput to set
*/
public void setXmlOutput(String xmlOutput) {
this.xmlOutput = xmlOutput;
}
-
/**
- *
+ *
* @return the state
*/
public String getState() {
@@ -56,15 +58,16 @@
}
/**
- *
- * @param state Sets the state
+ *
+ * @param state
+ * Sets the state
*/
public void setState(String state) {
this.state = state;
}
/**
- *
+ *
* @return the component name
*/
public String getComponentName() {
@@ -72,15 +75,16 @@
}
/**
- *
- * @param componentName Sets the component name
+ *
+ * @param componentName
+ * Sets the component name
*/
public void setComponentName(String componentName) {
this.componentName = componentName;
}
/**
- *
+ *
* @return service assembly name
*/
public String getServiceAssemblyName() {
@@ -88,8 +92,9 @@
}
/**
- *
- * @param serviceAssemblynname Sets the service assembly name
+ *
+ * @param serviceAssemblynname
+ * Sets the service assembly name
*/
public void setServiceAssemblyName(String serviceAssemblynname) {
this.serviceAssemblyName = serviceAssemblynname;
@@ -107,5 +112,5 @@
}
log(result, Project.MSG_WARN);
}
-
+
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListServiceEnginesTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListServiceEnginesTask.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListServiceEnginesTask.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListServiceEnginesTask.java Fri Aug 10 07:37:46 2007
@@ -17,19 +17,21 @@
package org.apache.servicemix.jbi.management.task;
import org.apache.servicemix.jbi.framework.AdminCommandsServiceMBean;
-import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
/**
* ListServiceEnginesTask
- *
- * @version $Revision:
+ *
+ * @version $Revision:
*/
public class ListServiceEnginesTask extends JbiTask {
-
+
private String state;
+
private String serviceAssemblyName;
+
private String sharedLibraryName;
+
private String xmlOutput;
/**
@@ -40,15 +42,15 @@
}
/**
- * @param xmlOutput the xmlOutput to set
+ * @param xmlOutput
+ * the xmlOutput to set
*/
public void setXmlOutput(String xmlOutput) {
this.xmlOutput = xmlOutput;
}
-
/**
- *
+ *
* @return the state
*/
public String getState() {
@@ -56,15 +58,16 @@
}
/**
- *
- * @param state Sets the state
+ *
+ * @param state
+ * Sets the state
*/
public void setState(String state) {
this.state = state;
}
/**
- *
+ *
* @return service assembly name
*/
public String getServiceAssemblyName() {
@@ -72,15 +75,16 @@
}
/**
- *
- * @param serviceAssemblyName the service assembly name to set
+ *
+ * @param serviceAssemblyName
+ * the service assembly name to set
*/
public void setServiceAssemblyName(String serviceAssemblyName) {
this.serviceAssemblyName = serviceAssemblyName;
}
/**
- *
+ *
* @return The shared library name
*/
public String getSharedLibraryName() {
@@ -88,17 +92,17 @@
}
/**
- *
- * @param sharedLibraryName Sets the shared library name
+ *
+ * @param sharedLibraryName
+ * Sets the shared library name
*/
public void setSharedLibraryName(String sharedLibraryName) {
this.sharedLibraryName = sharedLibraryName;
}
-
/**
* execute the task
- *
+ *
* @throws BuildException
*/
public void doExecute(AdminCommandsServiceMBean acs) throws Exception {
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListSharedLibrariesTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListSharedLibrariesTask.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListSharedLibrariesTask.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListSharedLibrariesTask.java Fri Aug 10 07:37:46 2007
@@ -17,18 +17,19 @@
package org.apache.servicemix.jbi.management.task;
import org.apache.servicemix.jbi.framework.AdminCommandsServiceMBean;
-import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
/**
* ListSharedLibrariesTask
- *
- * @version $Revision:
+ *
+ * @version $Revision:
*/
public class ListSharedLibrariesTask extends JbiTask {
-
+
private String componentName;
+
private String sharedLibraryName;
+
private String xmlOutput;
/**
@@ -39,15 +40,15 @@
}
/**
- * @param xmlOutput the xmlOutput to set
+ * @param xmlOutput
+ * the xmlOutput to set
*/
public void setXmlOutput(String xmlOutput) {
this.xmlOutput = xmlOutput;
}
-
/**
- *
+ *
* @return component name
*/
public String getComponentName() {
@@ -55,15 +56,16 @@
}
/**
- *
- * @param componentName The component name to set
+ *
+ * @param componentName
+ * The component name to set
*/
public void setComponentName(String componentName) {
this.componentName = componentName;
}
/**
- *
+ *
* @return shared library name
*/
public String getSharedLibraryName() {
@@ -71,8 +73,9 @@
}
/**
- *
- * @param sharedLibraryName the shared library name to set
+ *
+ * @param sharedLibraryName
+ * the shared library name to set
*/
public void setSharedLibraryName(String sharedLibraryName) {
this.sharedLibraryName = sharedLibraryName;
@@ -80,7 +83,7 @@
/**
* execute the task
- *
+ *
* @throws BuildException
*/
public void doExecute(AdminCommandsServiceMBean acs) throws Exception {
@@ -90,5 +93,5 @@
}
log(result, Project.MSG_WARN);
}
-
+
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ShutDownComponentTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ShutDownComponentTask.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ShutDownComponentTask.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ShutDownComponentTask.java Fri Aug 10 07:37:46 2007
@@ -25,7 +25,7 @@
* @version $Revision$
*/
public class ShutDownComponentTask extends JbiTask {
-
+
private String name;
/**
@@ -36,7 +36,8 @@
}
/**
- * @param name The component name to set.
+ * @param name
+ * The component name to set.
*/
public void setName(String name) {
this.name = name;
@@ -53,5 +54,5 @@
}
acs.shutdownComponent(name);
}
-
+
}
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DefaultMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DefaultMarshaler.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DefaultMarshaler.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DefaultMarshaler.java Fri Aug 10 07:37:46 2007
@@ -16,19 +16,20 @@
*/
package org.apache.servicemix.jbi.messaging;
-import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.w3c.dom.Node;
-
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
+import org.w3c.dom.Node;
+
+import org.apache.servicemix.jbi.jaxp.StringSource;
+
/**
- * Default implementation of {@link PojoMarshaler} which will pass through String
- * objects as XML content, DOM objects or Stream objects, otherwise the payload
- * is stored in a message property.
+ * Default implementation of {@link PojoMarshaler} which will pass through
+ * String objects as XML content, DOM objects or Stream objects, otherwise the
+ * payload is stored in a message property.
*
* @version $Revision$
*/
@@ -50,8 +51,7 @@
public void marshal(MessageExchange exchange, NormalizedMessage message, Object body) throws MessagingException {
if (body instanceof Source) {
message.setContent((Source) body);
- }
- else {
+ } else {
message.setProperty(BODY, body);
Source content = asContent(message, body);
message.setContent(content);
@@ -83,12 +83,10 @@
protected Source asContent(NormalizedMessage message, Object body) {
if (body instanceof Source) {
return (Source) body;
- }
- else if (body instanceof String) {
+ } else if (body instanceof String) {
// lets assume String is the XML to send
return new StringSource((String) body);
- }
- else if (body instanceof Node) {
+ } else if (body instanceof Node) {
return new DOMSource((Node) body);
}
return null;