incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awojtun...@apache.org
Subject svn commit: r885604 - in /incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx: agent/JMXAgentImpl.java framework/PackageStateMBeanHandler.java
Date Mon, 30 Nov 2009 22:47:29 GMT
Author: awojtuniak
Date: Mon Nov 30 22:47:29 2009
New Revision: 885604

URL: http://svn.apache.org/viewvc?rev=885604&view=rev
Log:
ARIES-50 added PackageStateMBean handler

Added:
    incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java
  (with props)
Modified:
    incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentImpl.java

Modified: incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentImpl.java?rev=885604&r1=885603&r2=885604&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentImpl.java
(original)
+++ incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentImpl.java
Mon Nov 30 22:47:29 2009
@@ -34,6 +34,7 @@
 import org.apache.aries.jmx.MBeanHandler;
 import org.apache.aries.jmx.MBeanServiceTracker;
 import org.apache.aries.jmx.framework.FrameworkMBeanHandler;
+import org.apache.aries.jmx.framework.PackageStateMBeanHandler;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.log.LogService;
 import org.osgi.util.tracker.ServiceTracker;
@@ -82,6 +83,9 @@
         MBeanHandler frameworkHandler = new FrameworkMBeanHandler(bc, logger);
         frameworkHandler.open();
         mbeansHandlers.add(frameworkHandler);
+        MBeanHandler packageStateHandler = new PackageStateMBeanHandler(bc, logger);
+        packageStateHandler.open();
+        mbeansHandlers.add(packageStateHandler);
         mbeanServiceTracker = new MBeanServiceTracker(agentContext);
         mbeanServiceTracker.open();
     }

Added: incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java?rev=885604&view=auto
==============================================================================
--- incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java
(added)
+++ incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java
Mon Nov 30 22:47:29 2009
@@ -0,0 +1,94 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.aries.jmx.framework;
+
+import javax.management.NotCompliantMBeanException;
+import javax.management.StandardMBean;
+
+import org.apache.aries.jmx.Logger;
+import org.apache.aries.jmx.MBeanHandler;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.jmx.framework.PackageStateMBean;
+import org.osgi.service.log.LogService;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * <p>
+ * <tt>PackageStateMBeanHandler</tt> represents MBeanHandler which
+ * holding information about {@link PackageStateMBean}.</p>
+ * 
+ * @see MBeanHandler
+ *
+ * @version $Rev$ $Date$
+ */
+public class PackageStateMBeanHandler implements MBeanHandler {
+
+    private String name;
+    private StandardMBean mbean;
+    private BundleContext context;
+    private Logger logger;
+
+    /**
+     * Constructs new PackageStateMBeanHandler.
+     * 
+     * @param context bundle context of JMX bundle.
+     * @param logger @see {@link Logger}.
+     */
+    public PackageStateMBeanHandler(BundleContext context, Logger logger) {
+        this.context = context;
+        this.name = PackageStateMBean.OBJECTNAME;
+        this.logger = logger;
+    }
+
+    /**
+     * @see org.apache.aries.jmx.MBeanHandler#getMbean()
+     */
+    public StandardMBean getMbean() {
+        return mbean;
+    }
+
+    /**
+     * @see org.apache.aries.jmx.MBeanHandler#open()
+     */
+    public void open() {
+        ServiceReference adminRef = context.getServiceReference(PackageAdmin.class.getCanonicalName());
+        PackageAdmin packageAdmin = (PackageAdmin) context.getService(adminRef);
+        PackageStateMBean packageState = new PackageState(context, packageAdmin);
+        try {
+            mbean = new StandardMBean(packageState, PackageStateMBean.class);
+        } catch (NotCompliantMBeanException e) {
+            logger.log(LogService.LOG_ERROR, "Not compliant MBean", e);
+        }
+    }
+
+    /**
+     * @see org.apache.aries.jmx.MBeanHandler#close()
+     */
+    public void close() {
+        //not used
+    }
+
+    /**
+     * @see org.apache.aries.jmx.MBeanHandler#getName()
+     */
+    public String getName() {
+        return name;
+    }
+
+
+}

Propchange: incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java
------------------------------------------------------------------------------
    svn:keywords = Revision Date



Mime
View raw message