You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by jg...@apache.org on 2006/01/25 11:34:12 UTC

svn commit: r372189 - in /incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task: JbiTask.java ListComponentTask.java ListEnginesTask.java ListLibrariesTask.java

Author: jgapuz
Date: Wed Jan 25 02:32:12 2006
New Revision: 372189

URL: http://svn.apache.org/viewcvs?rev=372189&view=rev
Log:
- added for Servicemix Ant Task.

Added:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListComponentTask.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListEnginesTask.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListLibrariesTask.java
Modified:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/JbiTask.java

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/JbiTask.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/JbiTask.java?rev=372189&r1=372188&r2=372189&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/JbiTask.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/JbiTask.java Wed Jan 25 02:32:12 2006
@@ -157,13 +157,12 @@
      * @throws IOException
      */
     public ManagementContextMBean getManagementContext() throws IOException{
-        ObjectName objectName = getObjectName(AdminServiceMBean.class);
+        ObjectName objectName = getObjectName(ManagementContext.class);
         
         return (ManagementContextMBean) MBeanServerInvocationHandler.newProxyInstance(jmxConnector.getMBeanServerConnection(), objectName,
                 ManagementContextMBean.class, true);
     }
-    
-    
+
     /**
      * @return Returns the containerName.
      */

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListComponentTask.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListComponentTask.java?rev=372189&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListComponentTask.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListComponentTask.java Wed Jan 25 02:32:12 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2005-2006 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.servicemix.jbi.management.task;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.management.ManagementContextMBean;
+import org.apache.tools.ant.BuildException;
+
+import javax.management.ObjectName;
+import java.io.IOException;
+
+/**
+ * ListComponentTask
+ *
+ * @version
+ */
+public class ListComponentTask extends JbiTask {
+    private static final Log log = LogFactory.getLog(DeployedAssembliesTask.class);
+
+    /**
+     * execute the task
+     * 
+     * @throws BuildException
+     */
+    public void execute() throws BuildException {
+        try {
+            ManagementContextMBean is = getManagementContext();
+            ObjectName[] objName = is.getBindingComponents();
+
+            StringBuffer buffer = new StringBuffer();
+            buffer.append("<?xml version='1.0'?>\n");
+            buffer.append("<component-info-list xmlns='http://java.sun.com/xml/ns/jbi/component-info-list' version='1.0'>\n");
+
+            if (objName != null) {
+                for (int i = 0; i < objName.length; i++) {
+                    buffer.append("\t<component-info>");
+                    buffer.append(" <name>" + objName[i].getKeyProperty("name") + "</name>");
+                    buffer.append("\t</component-info>\n");
+                }
+            }
+            buffer.append("</component-info-list>");
+            System.out.println(buffer.toString());
+
+        } catch (IOException e) {
+            log.error("Caught an exception getting deployed service units", e);
+            throw new BuildException("exception " + e);
+        } catch (Exception e) {
+            log.error("Caught an exception getting deployed service units", e);
+            throw new BuildException("exception " + e);
+        }
+    }
+}

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListEnginesTask.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListEnginesTask.java?rev=372189&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListEnginesTask.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListEnginesTask.java Wed Jan 25 02:32:12 2006
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2005-2006 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.servicemix.jbi.management.task;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.management.ManagementContextMBean;
+import org.apache.tools.ant.BuildException;
+
+import javax.management.ObjectName;
+import java.io.IOException;
+
+/**
+ * ListEnginesTask
+ *
+ * @version
+ */
+public class ListEnginesTask extends JbiTask {
+    private static final Log log = LogFactory.getLog(ListEnginesTask.class);
+
+    /**
+     * execute the task
+     *
+     * @throws BuildException
+     */
+    public void execute() throws BuildException {
+        try {
+            ManagementContextMBean is = getManagementContext();
+            ObjectName[] objName = is.getEngineComponents();
+
+            StringBuffer buffer = new StringBuffer();
+            buffer.append("<?xml version='1.0'?>\n");
+            buffer.append("<component-info-list xmlns='http://java.sun.com/xml/ns/jbi/component-info-list' version='1.0'>\n");
+
+            if (objName != null) {
+                for (int i = 0; i < objName.length; i++) {
+                    buffer.append("\t<component-info");
+                    buffer.append(" type='service-engine'>\n");
+                    buffer.append(" <name>" + objName[i].getKeyProperty("name") + "</name>");
+                    buffer.append("\t</component-info>\n");
+                }
+            }
+            buffer.append("</component-info-list>");
+            System.out.println(buffer.toString());
+
+        } catch (IOException e) {
+            log.error("Caught an exception getting deployed assemblies", e);
+            throw new BuildException(e);
+
+        } catch (Exception e) {
+            log.error("Caught an exception getting deployed assemblies", e);
+            throw new BuildException("exception " + e);
+        }
+
+    }
+
+}

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListLibrariesTask.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListLibrariesTask.java?rev=372189&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListLibrariesTask.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/task/ListLibrariesTask.java Wed Jan 25 02:32:12 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2005-2006 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.servicemix.jbi.management.task;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tools.ant.BuildException;
+import org.apache.servicemix.jbi.management.ManagementContextMBean;
+import org.apache.servicemix.jbi.management.task.JbiTask;
+import org.apache.servicemix.jbi.management.task.DeployedAssembliesTask;
+
+import javax.management.ObjectName;
+import java.io.IOException;
+
+/**
+ * ListLibrariesTask
+ *
+ * @version 
+ */
+public class ListLibrariesTask extends JbiTask {
+    private static final Log log = LogFactory.getLog(DeployedAssembliesTask.class);
+
+    /**
+     * execute the task
+     *
+     * @throws BuildException
+     */
+    public void execute() throws BuildException {
+        try {
+
+            ManagementContextMBean is = getManagementContext();
+            ObjectName[] objName = is.getSystemServices();
+
+            StringBuffer buffer = new StringBuffer();
+            buffer.append("<?xml version='1.0'?>\n");
+            buffer.append("<component-info-list xmlns='http://java.sun.com/xml/ns/jbi/component-info-list' version='1.0'>\n");
+
+            if (objName != null) {
+                for (int i = 0; i < objName.length; i++) {
+                    buffer.append("\t<component-info>");
+                    buffer.append(" <name>" + objName[i].getKeyProperty("name") + "</name>");
+                    buffer.append("\t</component-info>\n");
+                }
+            }
+            buffer.append("</component-info-list>");
+            System.out.println(buffer.toString());
+
+        } catch (IOException e) {
+            log.error("Caught an exception getting deployed assemblies", e);
+            throw new BuildException(e);
+        }
+    }
+}