aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tjwat...@apache.org
Subject svn commit: r1606837 [11/27] - in /aries/branches/subsystemsR6: ./ application/ application/application-api/ application/application-bundle/ application/application-converters/ application/application-default-local-platform/ application/application-dep...
Date Mon, 30 Jun 2014 16:55:06 GMT
Modified: aries/branches/subsystemsR6/jmx/jmx-core-whiteboard/pom.xml
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core-whiteboard/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core-whiteboard/pom.xml (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core-whiteboard/pom.xml Mon Jun 30 16:54:57 2014
@@ -1,26 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
-    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.
+ 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.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
     <modelVersion>4.0.0</modelVersion>
+
     <parent>
         <groupId>org.apache.aries</groupId>
-        <artifactId>java5-parent</artifactId>
-        <version>1.0.0</version>
-        <relativePath />
+        <artifactId>parent</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 
     <groupId>org.apache.aries.jmx</groupId>
@@ -34,11 +39,11 @@
         used to register the MBeans.
     </description>
 
-     <scm>
-         <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-core-whiteboard</connection>
-         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-core-whiteboard</developerConnection>
-         <url>http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-core-whiteboard</url>
-     </scm>
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-core-whiteboard</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-core-whiteboard</developerConnection>
+        <url>http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-core-whiteboard</url>
+    </scm>
 
     <properties>
         <aries.osgi.activator>
@@ -61,6 +66,7 @@
             org.osgi.service.provisioning;version="[1.2,2)",
             org.osgi.service.useradmin;version="[1.1,2)"
         </aries.osgi.dynamic>
+        <lastReleaseVersion>1.1.1</lastReleaseVersion>
     </properties>
 
     <dependencies>
@@ -100,7 +106,6 @@
              <artifactId>junit</artifactId>
              <scope>test</scope>
         </dependency>
-
     </dependencies>
     
     <build>
@@ -108,7 +113,6 @@
             <plugin>
                 <groupId>org.apache.aries.versioning</groupId>
                 <artifactId>org.apache.aries.versioning.plugin</artifactId>
-                <version>0.1.0</version>
                 <executions>
                     <execution>
                         <id>default-verify</id>
@@ -116,9 +120,6 @@
                         <goals>
                             <goal>version-check</goal>
                         </goals>
-                        <configuration>
-                            <oldArtifact>org.apache.aries.jmx:org.apache.aries.jmx.core.whiteboard:1.1.0</oldArtifact>
-                        </configuration>
                     </execution>
                 </executions>
             </plugin>

Modified: aries/branches/subsystemsR6/jmx/jmx-core/pom.xml
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/pom.xml (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/pom.xml Mon Jun 30 16:54:57 2014
@@ -1,26 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
-    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.
+ 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.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
     <modelVersion>4.0.0</modelVersion>
+
     <parent>
         <groupId>org.apache.aries</groupId>
-        <artifactId>java5-parent</artifactId>
-        <version>1.0.0</version>
-        <relativePath />
+        <artifactId>parent</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 
     <groupId>org.apache.aries.jmx</groupId>
@@ -33,11 +38,11 @@
 		of the JMX Control specification
     </description>
 
-     <scm>
-         <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-core</connection>
-         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-core</developerConnection>
-         <url>http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-core</url>
-     </scm>
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-core</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-core</developerConnection>
+        <url>http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-core</url>
+    </scm>
 
     <properties>
         <aries.osgi.activator>
@@ -70,6 +75,7 @@
         <aries.osgi.import.service>
             javax.management.MBeanServer
         </aries.osgi.import.service>
+        <lastReleaseVersion>1.1.1</lastReleaseVersion>
     </properties>
 
     <dependencies>
@@ -81,7 +87,6 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
-            <version>4.3.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -105,15 +110,18 @@
              <artifactId>junit</artifactId>
              <scope>test</scope>
         </dependency>
-
     </dependencies>
 
     <build>
         <plugins>
             <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.aries.versioning</groupId>
                 <artifactId>org.apache.aries.versioning.plugin</artifactId>
-                <version>0.1.0</version>
                 <executions>
                     <execution>
                         <id>default-verify</id>
@@ -121,12 +129,10 @@
                         <goals>
                             <goal>version-check</goal>
                         </goals>
-                        <configuration>
-                            <oldArtifact>org.apache.aries.jmx:org.apache.aries.jmx.core:1.1.0</oldArtifact>
-                        </configuration>
                     </execution>
                 </executions>
             </plugin>
         </plugins>
     </build>
+
  </project>

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/AbstractCompendiumHandler.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/AbstractCompendiumHandler.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/AbstractCompendiumHandler.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/AbstractCompendiumHandler.java Mon Jun 30 16:54:57 2014
@@ -16,7 +16,8 @@
  */
 package org.apache.aries.jmx;
 
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.atomic.AtomicLong;
+
 import javax.management.StandardMBean;
 
 import org.apache.aries.jmx.agent.JMXAgentContext;
@@ -39,11 +40,12 @@ import org.osgi.util.tracker.ServiceTrac
  * 
  * @version $Rev$ $Date$
  */
+@SuppressWarnings({"rawtypes", "unchecked"})
 public abstract class AbstractCompendiumHandler extends ServiceTracker implements MBeanHandler {
 
     protected final JMXAgentContext agentContext;
     protected StandardMBean mbean;
-    protected Long trackedId;
+    protected final AtomicLong trackedId = new AtomicLong();
     
     /**
      * 
@@ -73,25 +75,19 @@ public abstract class AbstractCompendium
     public Object addingService(ServiceReference reference) {
         Logger logger = agentContext.getLogger();
         Object trackedService = null;
-        Long serviceId = (Long) reference.getProperty(Constants.SERVICE_ID);
+        long serviceId = (Long) reference.getProperty(Constants.SERVICE_ID);
         //API stipulates versions for compendium services with static ObjectName
         //This shouldn't happen but added as a consistency check
-        if (trackedId != null) {
-            String serviceDescription = getServiceDescription(reference);
-            logger.log(LogService.LOG_WARNING, "Detected secondary ServiceReference for [" + serviceDescription
-                    + "] with " + Constants.SERVICE_ID + " [" + serviceId + "] Only 1 instance will be JMX managed");
-        } else {
+        if (trackedId.compareAndSet(0, serviceId)) {
             logger.log(LogService.LOG_INFO, "Registering MBean with ObjectName [" + getName() + "] for service with "
                     + Constants.SERVICE_ID + " [" + serviceId + "]");
             trackedService = context.getService(reference);
             mbean = constructInjectMBean(trackedService);
-            ExecutorService executor = agentContext.getRegistrationExecutor();
-            executor.submit(new Runnable() {
-                public void run() {
-                    agentContext.registerMBean(AbstractCompendiumHandler.this);
-                }
-            });
-            trackedId = serviceId;
+            agentContext.registerMBean(AbstractCompendiumHandler.this);
+        } else {
+            String serviceDescription = getServiceDescription(reference);
+            logger.log(LogService.LOG_WARNING, "Detected secondary ServiceReference for [" + serviceDescription
+                    + "] with " + Constants.SERVICE_ID + " [" + serviceId + "] Only 1 instance will be JMX managed");
         }
         return trackedService;
     }
@@ -103,22 +99,16 @@ public abstract class AbstractCompendium
      */
     public void removedService(ServiceReference reference, Object service) {
         Logger logger = agentContext.getLogger();
-        Long serviceID = (Long) reference.getProperty(Constants.SERVICE_ID);
-        if (trackedId != null && !trackedId.equals(serviceID)) {
-            String serviceDescription = getServiceDescription(reference);
-            logger.log(LogService.LOG_WARNING, "ServiceReference for [" + serviceDescription + "] with "
-                    + Constants.SERVICE_ID + " [" + serviceID + "] is not currently JMX managed");
-        } else {
+        long serviceID = (Long) reference.getProperty(Constants.SERVICE_ID);
+        if (trackedId.compareAndSet(serviceID, 0)) {
             logger.log(LogService.LOG_INFO, "Unregistering MBean with ObjectName [" + getName() + "] for service with "
                     + Constants.SERVICE_ID + " [" + serviceID + "]"); 
-            ExecutorService executor = agentContext.getRegistrationExecutor();
-            executor.submit(new Runnable() {
-                public void run() {
-                    agentContext.unregisterMBean(AbstractCompendiumHandler.this);
-                }
-            });
-            trackedId = null;
+            agentContext.unregisterMBean(AbstractCompendiumHandler.this);
             context.ungetService(reference);
+        } else {
+            String serviceDescription = getServiceDescription(reference);
+            logger.log(LogService.LOG_WARNING, "ServiceReference for [" + serviceDescription + "] with "
+                    + Constants.SERVICE_ID + " [" + serviceID + "] is not currently JMX managed");
         }
     }
 
@@ -126,7 +116,7 @@ public abstract class AbstractCompendium
         String serviceDescription = (String) reference.getProperty(Constants.SERVICE_DESCRIPTION);
         if (serviceDescription == null) {
             Object obj = reference.getProperty(Constants.OBJECTCLASS);
-            if (obj instanceof String) {
+            if (obj instanceof String[]) {
                 StringBuilder sb = new StringBuilder();
                 for (String s : (String[]) obj) {
                     if (sb.length() > 0) {

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/Activator.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/Activator.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/Activator.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/Activator.java Mon Jun 30 16:54:57 2014
@@ -18,7 +18,6 @@ package org.apache.aries.jmx;
 
 import org.apache.aries.jmx.agent.JMXAgent;
 import org.apache.aries.jmx.agent.JMXAgentImpl;
-import org.apache.aries.jmx.agent.JMXAgentContext;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.log.LogService;
@@ -44,9 +43,7 @@ public class Activator implements Bundle
         //starting logger
         logger.open();
         logger.log(LogService.LOG_DEBUG, "Starting JMX OSGi bundle");
-        agent = new JMXAgentImpl(logger);
-        JMXAgentContext agentContext = new JMXAgentContext(context, agent, logger);
-        agent.setAgentContext(agentContext);
+        agent = new JMXAgentImpl(context, logger);
         agent.start();
     }
 

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/Logger.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/Logger.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/Logger.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/Logger.java Mon Jun 30 16:54:57 2014
@@ -29,18 +29,17 @@ import org.osgi.util.tracker.ServiceTrac
  * @see org.osgi.util.tracker.ServiceTracker
  * @version $Rev$ $Date$
  */
+@SuppressWarnings("rawtypes")
 public class Logger extends ServiceTracker implements LogService {
     
-    private String bundleLocation;
-
     /**
      * Constructs new Logger(ServiceTracker for LogService).
      * 
      * @param context bundle context.
      */
-    public Logger(BundleContext context) {
+    @SuppressWarnings("unchecked")
+	public Logger(BundleContext context) {
         super(context, LogService.class.getName(), null);
-        this.bundleLocation = context.getBundle().getLocation();
     }
 
     /**

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/MBeanServiceTracker.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/MBeanServiceTracker.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/MBeanServiceTracker.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/MBeanServiceTracker.java Mon Jun 30 16:54:57 2014
@@ -16,8 +16,6 @@
  */
 package org.apache.aries.jmx;
 
-import java.util.concurrent.ExecutorService;
-
 import javax.management.MBeanServer;
 
 import org.apache.aries.jmx.agent.JMXAgentContext;
@@ -32,6 +30,7 @@ import org.osgi.util.tracker.ServiceTrac
  * @see ServiceTracker
  * @version $Rev$ $Date$
  */
+@SuppressWarnings({"rawtypes", "unchecked"})
 public class MBeanServiceTracker extends ServiceTracker {
 
     private JMXAgentContext agentContext;
@@ -40,7 +39,7 @@ public class MBeanServiceTracker extends
      * Constructs new MBeanServiceTracker.
      * @param agentContext agent context.
      */
-    public MBeanServiceTracker(JMXAgentContext agentContext) {
+	public MBeanServiceTracker(JMXAgentContext agentContext) {
         super(agentContext.getBundleContext(), MBeanServer.class.getName(), null);
         this.agentContext = agentContext;
     }
@@ -51,19 +50,11 @@ public class MBeanServiceTracker extends
      * @see ServiceTracker#addingService(ServiceReference)
      */
     public Object addingService(final ServiceReference reference) {
-        final MBeanServer mbeanServer = (MBeanServer) context.getService(reference);
+        final MBeanServer mbeanServer = (MBeanServer) super.addingService(reference);
         Logger logger = agentContext.getLogger();
         logger.log(LogService.LOG_DEBUG, "Discovered MBean server " + mbeanServer);
-        ExecutorService executor = agentContext.getRegistrationExecutor();
-        executor.submit(new Runnable() {
-
-            public void run() {
-                agentContext.registerMBeans(mbeanServer);
-
-            }
-        });
-
-        return super.addingService(reference);
+        agentContext.registerMBeans(mbeanServer);
+        return mbeanServer;
     }
 
     /**
@@ -73,16 +64,10 @@ public class MBeanServiceTracker extends
      * @see ServiceTracker#removedService(ServiceReference, Object)
      */
     public void removedService(final ServiceReference reference, Object service) {
-        final MBeanServer mbeanServer = (MBeanServer) context.getService(reference);
+        final MBeanServer mbeanServer = (MBeanServer) service;
         Logger logger = agentContext.getLogger();
-        logger.log(LogService.LOG_DEBUG, "MBean server " + mbeanServer+ " is unregistered from SeviceRegistry");
-        ExecutorService executor = agentContext.getRegistrationExecutor();
-        executor.submit(new Runnable() {
-
-            public void run() {
-                agentContext.unregisterMBeans(mbeanServer);
-            }
-        });
+        logger.log(LogService.LOG_DEBUG, "MBean server " + mbeanServer+ " is unregistered from ServiceRegistry");
+        agentContext.unregisterMBeans(mbeanServer);
         super.removedService(reference, service);
     }
 

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgent.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgent.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgent.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgent.java Mon Jun 30 16:54:57 2014
@@ -16,8 +16,6 @@
  */
 package org.apache.aries.jmx.agent;
 
-import java.util.concurrent.ExecutorService;
-
 import javax.management.MBeanServer;
 
 import org.apache.aries.jmx.MBeanHandler;
@@ -62,34 +60,9 @@ public interface JMXAgent {
     void unregisterMBean(final MBeanHandler mBeanHandler);
 
     /**
-     * Unregisters MBean with all available MBeanServers.
-     * @param name of MBean to be unregistered.
-     * @deprecated
-     */
-    void unregisterMBean(final String name);
-
-    /**
      * Stops JMXAgent.
      * This method stops MBeanServiceTracker and all MBean handlers.
      */
     void stop();
 
-    /**
-     * Gets JMXAgentContext @see {@link JMXAgentContext}.
-     * @return JMXAgentContext instance.
-     */
-    JMXAgentContext getAgentContext();
-
-    /**
-     * Sets JMXAgentContext for this agent.
-     * @param agentContext JMXAgentContext instance created for this agent.
-     */
-    void setAgentContext(JMXAgentContext agentContext);
-
-    /**
-     * Gets registration {@link ExecutorService}.
-     * @return registration executor.
-     */
-    ExecutorService getRegistrationExecutor();
-
 }
\ No newline at end of file

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentContext.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentContext.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentContext.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentContext.java Mon Jun 30 16:54:57 2014
@@ -16,8 +16,6 @@
  */
 package org.apache.aries.jmx.agent;
 
-import java.util.concurrent.ExecutorService;
-
 import javax.management.MBeanServer;
 
 import org.apache.aries.jmx.Logger;
@@ -83,15 +81,6 @@ public class JMXAgentContext {
     }
 
     /**
-     * Delegates invocation to JMX agent.
-     * @see org.apache.aries.jmx.agent.JMXAgent#unregisterMBean(String)
-     * @deprecated
-     */
-    public void unregisterMBean(final String name) {
-        agent.unregisterMBean(name);
-    }
-
-    /**
      * Gets bundle context.
      * @return bundle context.
      */
@@ -107,11 +96,4 @@ public class JMXAgentContext {
         return logger;
     }
 
-    /**
-     * Delegates invocation to JMX agent.
-     * @see org.apache.aries.jmx.agent.JMXAgent#getRegistrationExecutor()
-     */
-    public ExecutorService getRegistrationExecutor() {
-        return agent.getRegistrationExecutor();
-    }
 }

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentImpl.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentImpl.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentImpl.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/agent/JMXAgentImpl.java Mon Jun 30 16:54:57 2014
@@ -16,11 +16,11 @@
  */
 package org.apache.aries.jmx.agent;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
+
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanRegistrationException;
@@ -30,7 +30,6 @@ import javax.management.NotCompliantMBea
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
 
-import org.apache.aries.jmx.JMXThreadFactory;
 import org.apache.aries.jmx.Logger;
 import org.apache.aries.jmx.MBeanHandler;
 import org.apache.aries.jmx.MBeanServiceTracker;
@@ -58,28 +57,26 @@ import org.osgi.util.tracker.ServiceTrac
  */
 public class JMXAgentImpl implements JMXAgent {
 
-    private ServiceTracker mbeanServiceTracker;
+    @SuppressWarnings("rawtypes")
+	private ServiceTracker mbeanServiceTracker;
     /**
      * {@link MBeanHandler} store.
      */
+    private List<MBeanServer> mbeanServers;
     private Map<MBeanHandler, Boolean> mbeansHandlers;
-    private JMXAgentContext agentContext;
+    private BundleContext context;
     private Logger logger;
 
     /**
-     * Registration {@link ExecutorService}.
-     */
-    private ExecutorService registrationExecutor;
-
-    /**
      * Constructs new JMXAgent.
      *
      * @param logger @see org.apache.aries.jmx.Logger
      */
-    public JMXAgentImpl(Logger logger) {
+    public JMXAgentImpl(BundleContext context, Logger logger) {
+        this.context = context;
         this.logger = logger;
+        this.mbeanServers = new ArrayList<MBeanServer>();
         this.mbeansHandlers = new HashMap<MBeanHandler, Boolean>();
-        this.registrationExecutor = Executors.newSingleThreadExecutor(new JMXThreadFactory("JMX OSGi Agent"));
     }
 
     /**
@@ -87,20 +84,22 @@ public class JMXAgentImpl implements JMX
      */
     public synchronized void start() {
         logger.log(LogService.LOG_INFO, "Starting JMX OSGi agent");
-        BundleContext bc = agentContext.getBundleContext();
-        MBeanHandler frameworkHandler = new FrameworkMBeanHandler(bc, logger);
+        // Initialize static handlers
+        // Those handlers do not track dependencies
+        JMXAgentContext agentContext = new JMXAgentContext(context, this, logger);
+        MBeanHandler frameworkHandler = new FrameworkMBeanHandler(agentContext);
         mbeansHandlers.put(frameworkHandler, Boolean.FALSE);
         frameworkHandler.open();
-        MBeanHandler bundleStateHandler = new BundleStateMBeanHandler(bc, logger);
+        MBeanHandler bundleStateHandler = new BundleStateMBeanHandler(agentContext);
         mbeansHandlers.put(bundleStateHandler, Boolean.FALSE);
         bundleStateHandler.open();
-        MBeanHandler revisionsStateHandler = new BundleWiringStateMBeanHandler(bc, logger);
+        MBeanHandler revisionsStateHandler = new BundleWiringStateMBeanHandler(agentContext);
         mbeansHandlers.put(revisionsStateHandler, Boolean.FALSE);
         revisionsStateHandler.open();
-        MBeanHandler serviceStateHandler = new ServiceStateMBeanHandler(bc, logger);
+        MBeanHandler serviceStateHandler = new ServiceStateMBeanHandler(agentContext);
         mbeansHandlers.put(serviceStateHandler, Boolean.FALSE);
         serviceStateHandler.open();
-        MBeanHandler packageStateHandler = new PackageStateMBeanHandler(bc, logger);
+        MBeanHandler packageStateHandler = new PackageStateMBeanHandler(agentContext);
         mbeansHandlers.put(packageStateHandler, Boolean.FALSE);
         packageStateHandler.open();
         MBeanHandler permissionAdminHandler = new PermissionAdminMBeanHandler(agentContext);
@@ -115,6 +114,7 @@ public class JMXAgentImpl implements JMX
         MBeanHandler provServiceHandler = new ProvisioningServiceMBeanHandler(agentContext);
         mbeansHandlers.put(provServiceHandler, Boolean.FALSE);
         provServiceHandler.open();
+        // Track mbean servers
         mbeanServiceTracker = new MBeanServiceTracker(agentContext);
         mbeanServiceTracker.open();
     }
@@ -124,7 +124,7 @@ public class JMXAgentImpl implements JMX
      */
     public synchronized void registerMBeans(final MBeanServer server) {
         for (MBeanHandler mbeanHandler : mbeansHandlers.keySet()) {
-            if (mbeansHandlers.get(mbeanHandler) == Boolean.FALSE) {
+            if (mbeansHandlers.get(mbeanHandler) == Boolean.TRUE) {
                 String name = mbeanHandler.getName();
                 StandardMBean mbean = mbeanHandler.getMbean();
                 if (mbean != null) {
@@ -132,7 +132,6 @@ public class JMXAgentImpl implements JMX
                         logger.log(LogService.LOG_INFO, "Registering " + mbean.getMBeanInterface().getName()
                                 + " to MBeanServer " + server + " with name " + name);
                         server.registerMBean(mbean, new ObjectName(name));
-                        mbeansHandlers.put(mbeanHandler, Boolean.TRUE);
                     } catch (InstanceAlreadyExistsException e) {
                         logger.log(LogService.LOG_ERROR, "MBean is already registered", e);
                     } catch (MBeanRegistrationException e) {
@@ -147,6 +146,7 @@ public class JMXAgentImpl implements JMX
                 }
             }
         }
+        mbeanServers.add(server);
     }
 
     /**
@@ -163,7 +163,6 @@ public class JMXAgentImpl implements JMX
                        logger.log(LogService.LOG_INFO, "Unregistering " + mbean.getMBeanInterface().getName()
                              + " to MBeanServer " + server + " with name " + name);
                        server.unregisterMBean(new ObjectName(name));
-                       mbeansHandlers.put(mBeanHandler, Boolean.FALSE);
                    }
                 } catch (MBeanRegistrationException e) {
                    logger.log(LogService.LOG_ERROR, "Can't unregister MBean", e);
@@ -178,22 +177,21 @@ public class JMXAgentImpl implements JMX
                 }
             }
         }
+        mbeanServers.remove(server);
     }
 
     /**
      * @see org.apache.aries.jmx.agent.JMXAgent#registerMBean(org.apache.aries.jmx.MBeanHandler)
      */
     public synchronized void registerMBean(final MBeanHandler mBeanHandler) {
-        Object[] servers = getMBeanServers();
-        for (Object server : servers) {
+        for (MBeanServer server : mbeanServers) {
             String name = mBeanHandler.getName();
             StandardMBean mbean = mBeanHandler.getMbean();
             try {
                 logger.log(LogService.LOG_INFO, "Registering " + mbean.getMBeanInterface().getName()
                         + " to MBeanServer " + server + " with name " + name);
-                ((MBeanServer) server).registerMBean(mbean, new ObjectName(name));
+                server.registerMBean(mbean, new ObjectName(name));
 
-                mbeansHandlers.put(mBeanHandler, Boolean.TRUE);
             } catch (InstanceAlreadyExistsException e) {
                 logger.log(LogService.LOG_ERROR, "MBean is already registered", e);
             } catch (MBeanRegistrationException e) {
@@ -209,45 +207,19 @@ public class JMXAgentImpl implements JMX
                 return;
             }
         }
+        mbeansHandlers.put(mBeanHandler, Boolean.TRUE);
     }
 
     /**
      * @see org.apache.aries.jmx.agent.JMXAgent#unregisterMBean(org.apache.aries.jmx.MBeanHandler)
      */
     public synchronized void unregisterMBean(final MBeanHandler mBeanHandler) {
-        Object[] servers = getMBeanServers();
-        for (Object server : servers) {
+        for (MBeanServer server : mbeanServers) {
             String name = mBeanHandler.getName();
             try {
                 logger.log(LogService.LOG_INFO, "Unregistering mbean " + " to MBeanServer " + server + " with name "
                         + name);
-                ((MBeanServer) server).unregisterMBean(new ObjectName(name));
-                mbeansHandlers.put(mBeanHandler, Boolean.FALSE);
-            } catch (MBeanRegistrationException e) {
-                logger.log(LogService.LOG_ERROR, "Can't register MBean", e);
-            } catch (InstanceNotFoundException e) {
-                logger.log(LogService.LOG_ERROR, "MBean doesn't exist in the repository", e);
-            } catch (MalformedObjectNameException e) {
-                logger.log(LogService.LOG_ERROR, "Try to register with no valid objectname, Stopping registration", e);
-                return;
-            } catch (NullPointerException e) {
-                logger.log(LogService.LOG_ERROR, "Name of objectname can't be null, Stopping registration", e);
-                return;
-            }
-
-        }
-    }
-
-    /**
-     * @see org.apache.aries.jmx.agent.JMXAgent#unregisterMBean(java.lang.String)
-     */
-    public synchronized void unregisterMBean(final String name) {
-        Object[] servers = getMBeanServers();
-        for (Object server : servers) {
-            try {
-                logger.log(LogService.LOG_INFO, "Unregistering mbean " + " to MBeanServer " + server + " with name "
-                        + name);
-                ((MBeanServer) server).unregisterMBean(new ObjectName(name));
+                server.unregisterMBean(new ObjectName(name));
             } catch (MBeanRegistrationException e) {
                 logger.log(LogService.LOG_ERROR, "Can't register MBean", e);
             } catch (InstanceNotFoundException e) {
@@ -260,6 +232,7 @@ public class JMXAgentImpl implements JMX
                 return;
             }
         }
+        mbeansHandlers.put(mBeanHandler, Boolean.FALSE);
     }
 
     /**
@@ -273,45 +246,6 @@ public class JMXAgentImpl implements JMX
                 mBeanHandler.close();
             }
         }
-        if (registrationExecutor != null && !registrationExecutor.isShutdown()) {
-            registrationExecutor.shutdown();
-            try {
-                registrationExecutor.awaitTermination(5 * 60, TimeUnit.SECONDS);
-            } catch (InterruptedException e) {
-                logger.log(LogService.LOG_WARNING, "Interrupted while waiting for executor shutdown", e);
-            }
-        }
-    }
-
-    /**
-     * @see org.apache.aries.jmx.agent.JMXAgent#getAgentContext()
-     */
-    public JMXAgentContext getAgentContext() {
-        return agentContext;
-    }
-
-    /**
-     * @see org.apache.aries.jmx.agent.JMXAgent#setAgentContext(org.apache.aries.jmx.agent.JMXAgentContext)
-     */
-    public void setAgentContext(JMXAgentContext agentContext) {
-        this.agentContext = agentContext;
-    }
-
-    /**
-     * Gets all MBeanServers from MBeanServiceTracker.
-     *
-     * @return array of MBean servers.
-     */
-    private Object[] getMBeanServers() {
-        Object[] servers = mbeanServiceTracker.getServices();
-        return servers != null ? servers : new Object[0];
-    }
-
-    /**
-     * @see org.apache.aries.jmx.agent.JMXAgent#getRegistrationExecutor()
-     */
-    public ExecutorService getRegistrationExecutor() {
-        return registrationExecutor;
     }
 
 }

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/cm/ConfigurationAdmin.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/cm/ConfigurationAdmin.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/cm/ConfigurationAdmin.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/cm/ConfigurationAdmin.java Mon Jun 30 16:54:57 2014
@@ -172,7 +172,6 @@ public class ConfigurationAdmin implemen
     /**
      * @see org.osgi.jmx.service.cm.ConfigurationAdminMBean#getPropertiesForLocation(java.lang.String, java.lang.String)
      */
-    @SuppressWarnings("unchecked")
     public TabularData getPropertiesForLocation(String pid, String location) throws IOException {
         if (pid == null || pid.length() < 1) {
             throw new IOException("Argument pid cannot be null or empty");
@@ -227,7 +226,7 @@ public class ConfigurationAdmin implemen
         Dictionary<String, Object> configurationProperties = new Hashtable<String, Object>();
         Collection<CompositeData> compositeData = (Collection<CompositeData>) configurationTable.values();
         for (CompositeData row: compositeData) {
-            PropertyData<? extends Class> propertyData = PropertyData.from(row);
+            PropertyData<? extends Class<?>> propertyData = PropertyData.from(row);
             configurationProperties.put(propertyData.getKey(), propertyData.getValue());
         }
         Configuration config = configurationAdmin.getConfiguration(pid, location);

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleData.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleData.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleData.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleData.java Mon Jun 30 16:54:57 2014
@@ -84,6 +84,7 @@ import org.osgi.service.startlevel.Start
  *
  * @version $Rev$ $Date$
  */
+@SuppressWarnings("deprecation")
 public class BundleData {
 
     /**
@@ -190,7 +191,6 @@ public class BundleData {
         super();
     }
 
-    @SuppressWarnings("unchecked")
     public BundleData(BundleContext localBundleContext, Bundle bundle, PackageAdmin packageAdmin, StartLevel startLevel) {
         if (bundle == null) {
             throw new IllegalArgumentException("Argument bundle cannot be null");

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java Mon Jun 30 16:54:57 2014
@@ -82,7 +82,8 @@ public class GroupData extends UserData 
      * @param members basic members.
      * @param requiredMembers required members.
      */
-    public GroupData(String name, Dictionary properties, Dictionary credentials, String[] members, String[] requiredMembers) {
+    @SuppressWarnings("rawtypes")
+	public GroupData(String name, Dictionary properties, Dictionary credentials, String[] members, String[] requiredMembers) {
         super(name, Role.GROUP, properties, credentials);
         this.members = (members == null) ? new String[0] : members;
         this.requiredMembers = (requiredMembers == null) ? new String[0] : requiredMembers;

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/PackageData.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/PackageData.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/PackageData.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/PackageData.java Mon Jun 30 16:54:57 2014
@@ -38,6 +38,7 @@ import org.osgi.service.packageadmin.Exp
  * 
  * @version $Rev$ $Date$
  */
+@SuppressWarnings("deprecation")
 public class PackageData {
 
     /**

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java Mon Jun 30 16:54:57 2014
@@ -83,7 +83,8 @@ public class RoleData {
      * @param type role type.
      * @param properties role properties.
      */
-    public RoleData(String name, int type, Dictionary properties) {
+    @SuppressWarnings("rawtypes")
+	public RoleData(String name, int type, Dictionary properties) {
         this.name = name;
         this.type = type;
 

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleStateMBeanHandler.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleStateMBeanHandler.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleStateMBeanHandler.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleStateMBeanHandler.java Mon Jun 30 16:54:57 2014
@@ -23,6 +23,7 @@ import javax.management.StandardMBean;
 
 import org.apache.aries.jmx.Logger;
 import org.apache.aries.jmx.MBeanHandler;
+import org.apache.aries.jmx.agent.JMXAgentContext;
 import org.apache.aries.jmx.util.ObjectNameUtils;
 import org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean;
 import org.osgi.framework.BundleContext;
@@ -43,6 +44,7 @@ import org.osgi.service.startlevel.Start
  */
 public class BundleStateMBeanHandler implements MBeanHandler {
 
+    private JMXAgentContext agentContext;
     private Logger logger;
     private String name;
     private StandardMBean mbean;
@@ -52,9 +54,10 @@ public class BundleStateMBeanHandler imp
     private ServiceReference startLevelRef;
 
 
-    public BundleStateMBeanHandler(BundleContext bundleContext, Logger logger) {
-        this.bundleContext = bundleContext;
-        this.logger = logger;
+    public BundleStateMBeanHandler(JMXAgentContext agentContext) {
+        this.agentContext = agentContext;
+        this.bundleContext = agentContext.getBundleContext();
+        this.logger = agentContext.getLogger();
         this.name = ObjectNameUtils.createFullObjectName(bundleContext, OBJECTNAME);
     }
 
@@ -72,6 +75,7 @@ public class BundleStateMBeanHandler imp
         } catch (NotCompliantMBeanException e) {
             logger.log(LogService.LOG_ERROR, "Failed to instantiate MBean for " + BundleStateMBean.class.getName(), e);
         }
+        agentContext.registerMBean(this);
     }
 
     /**
@@ -93,6 +97,7 @@ public class BundleStateMBeanHandler imp
      * @see org.apache.aries.jmx.MBeanHandler#close()
      */
     public void close() {
+        agentContext.unregisterMBean(this);
         if (packageAdminRef != null) {
             try {
                 bundleContext.ungetService(packageAdminRef);

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/FrameworkMBeanHandler.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/FrameworkMBeanHandler.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/FrameworkMBeanHandler.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/FrameworkMBeanHandler.java Mon Jun 30 16:54:57 2014
@@ -21,6 +21,7 @@ import javax.management.StandardMBean;
 
 import org.apache.aries.jmx.Logger;
 import org.apache.aries.jmx.MBeanHandler;
+import org.apache.aries.jmx.agent.JMXAgentContext;
 import org.apache.aries.jmx.util.ObjectNameUtils;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -40,6 +41,7 @@ import org.osgi.service.startlevel.Start
  */
 public class FrameworkMBeanHandler implements MBeanHandler {
 
+    private JMXAgentContext agentContext;
     private String name;
     private StandardMBean mbean;
     private BundleContext context;
@@ -48,13 +50,13 @@ public class FrameworkMBeanHandler imple
     /**
      * Constructs new FrameworkMBeanHandler.
      *
-     * @param context bundle context of JMX bundle.
-     * @param logger @see {@link Logger}.
+     * @param agentContext agent context
      */
-    public FrameworkMBeanHandler(BundleContext context, Logger logger) {
-        this.context = context;
+    public FrameworkMBeanHandler(JMXAgentContext agentContext) {
+        this.agentContext = agentContext;
+        this.context = agentContext.getBundleContext();
+        this.logger = agentContext.getLogger();
         this.name = ObjectNameUtils.createFullObjectName(context, FrameworkMBean.OBJECTNAME);
-        this.logger = logger;
     }
 
     /**
@@ -78,13 +80,14 @@ public class FrameworkMBeanHandler imple
         } catch (NotCompliantMBeanException e) {
             logger.log(LogService.LOG_ERROR, "Not compliant MBean", e);
         }
+        agentContext.registerMBean(this);
     }
 
     /**
      * @see org.apache.aries.jmx.MBeanHandler#close()
      */
     public void close() {
-        //not used
+        agentContext.unregisterMBean(this);
     }
 
     /**

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/PackageStateMBeanHandler.java Mon Jun 30 16:54:57 2014
@@ -21,6 +21,7 @@ import javax.management.StandardMBean;
 
 import org.apache.aries.jmx.Logger;
 import org.apache.aries.jmx.MBeanHandler;
+import org.apache.aries.jmx.agent.JMXAgentContext;
 import org.apache.aries.jmx.util.ObjectNameUtils;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -39,6 +40,7 @@ import org.osgi.service.packageadmin.Pac
  */
 public class PackageStateMBeanHandler implements MBeanHandler {
 
+    private JMXAgentContext agentContext;
     private String name;
     private StandardMBean mbean;
     private BundleContext context;
@@ -46,14 +48,12 @@ public class PackageStateMBeanHandler im
 
     /**
      * Constructs new PackageStateMBeanHandler.
-S     *
-     * @param context bundle context of JMX bundle.
-     * @param logger @see {@link Logger}.
      */
-    public PackageStateMBeanHandler(BundleContext context, Logger logger) {
-        this.context = context;
+    public PackageStateMBeanHandler(JMXAgentContext agentContext) {
+        this.agentContext = agentContext;
+        this.context = agentContext.getBundleContext();
+        this.logger = agentContext.getLogger();
         this.name = ObjectNameUtils.createFullObjectName(context, PackageStateMBean.OBJECTNAME);
-        this.logger = logger;
     }
 
     /**
@@ -75,13 +75,14 @@ S     *
         } catch (NotCompliantMBeanException e) {
             logger.log(LogService.LOG_ERROR, "Not compliant MBean", e);
         }
+        agentContext.registerMBean(this);
     }
 
     /**
      * @see org.apache.aries.jmx.MBeanHandler#close()
      */
     public void close() {
-        //not used
+        agentContext.unregisterMBean(this);
     }
 
     /**

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceStateMBeanHandler.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceStateMBeanHandler.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceStateMBeanHandler.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceStateMBeanHandler.java Mon Jun 30 16:54:57 2014
@@ -23,6 +23,7 @@ import javax.management.StandardMBean;
 
 import org.apache.aries.jmx.Logger;
 import org.apache.aries.jmx.MBeanHandler;
+import org.apache.aries.jmx.agent.JMXAgentContext;
 import org.apache.aries.jmx.util.ObjectNameUtils;
 import org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean;
 import org.osgi.framework.BundleContext;
@@ -40,6 +41,7 @@ import org.osgi.service.log.LogService;
  */
 public class ServiceStateMBeanHandler implements MBeanHandler {
 
+    private JMXAgentContext agentContext;
     private String name;
     private StandardMBean mbean;
     private ServiceState serviceStateMBean;
@@ -47,9 +49,10 @@ public class ServiceStateMBeanHandler im
     private Logger logger;
 
 
-    public ServiceStateMBeanHandler(BundleContext bundleContext, Logger logger) {
-        this.bundleContext = bundleContext;
-        this.logger = logger;
+    public ServiceStateMBeanHandler(JMXAgentContext agentContext) {
+        this.agentContext = agentContext;
+        this.bundleContext = agentContext.getBundleContext();
+        this.logger = agentContext.getLogger();
         this.name = ObjectNameUtils.createFullObjectName(bundleContext, OBJECTNAME);
     }
 
@@ -63,6 +66,7 @@ public class ServiceStateMBeanHandler im
         } catch (NotCompliantMBeanException e) {
             logger.log(LogService.LOG_ERROR, "Failed to instantiate MBean for " + ServiceStateMBean.class.getName(), e);
         }
+        agentContext.registerMBean(this);
     }
 
     /**
@@ -83,6 +87,7 @@ public class ServiceStateMBeanHandler im
      * @see org.apache.aries.jmx.MBeanHandler#close()
      */
     public void close() {
+        agentContext.unregisterMBean(this);
        // ensure dispatcher is shutdown even if postDeRegister is not honored
        if (serviceStateMBean != null) {
            serviceStateMBean.shutDownDispatcher();

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanHandler.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanHandler.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanHandler.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanHandler.java Mon Jun 30 16:54:57 2014
@@ -21,6 +21,7 @@ import javax.management.StandardMBean;
 
 import org.apache.aries.jmx.Logger;
 import org.apache.aries.jmx.MBeanHandler;
+import org.apache.aries.jmx.agent.JMXAgentContext;
 import org.apache.aries.jmx.util.ObjectNameUtils;
 import org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean;
 import org.osgi.framework.BundleContext;
@@ -28,6 +29,8 @@ import org.osgi.jmx.framework.wiring.Bun
 import org.osgi.service.log.LogService;
 
 public class BundleWiringStateMBeanHandler implements MBeanHandler {
+
+    private JMXAgentContext agentContext;
     private final String name;
     private final BundleContext bundleContext;
     private final Logger logger;
@@ -35,9 +38,10 @@ public class BundleWiringStateMBeanHandl
     private StandardMBean mbean;
     private BundleWiringState revisionsStateMBean;
 
-    public BundleWiringStateMBeanHandler(BundleContext bundleContext, Logger logger) {
-        this.bundleContext = bundleContext;
-        this.logger = logger;
+    public BundleWiringStateMBeanHandler(JMXAgentContext agentContext) {
+        this.agentContext = agentContext;
+        this.bundleContext = agentContext.getBundleContext();
+        this.logger = agentContext.getLogger();
         this.name = ObjectNameUtils.createFullObjectName(bundleContext, BundleWiringStateMBean.OBJECTNAME);
     }
 
@@ -51,6 +55,7 @@ public class BundleWiringStateMBeanHandl
         } catch (NotCompliantMBeanException e) {
             logger.log(LogService.LOG_ERROR, "Failed to instantiate MBean for " + BundleWiringStateMBean.class.getName(), e);
         }
+        agentContext.registerMBean(this);
     }
 
     /* (non-Javadoc)
@@ -65,7 +70,7 @@ public class BundleWiringStateMBeanHandl
      * @see org.apache.aries.jmx.MBeanHandler#close()
      */
     public void close() {
-        // not used
+        agentContext.unregisterMBean(this);
     }
 
     /* (non-Javadoc)

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/CompendiumHandlerTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/CompendiumHandlerTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/CompendiumHandlerTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/CompendiumHandlerTest.java Mon Jun 30 16:54:57 2014
@@ -55,6 +55,9 @@ public class CompendiumHandlerTest {
         Object service = new Object();
 
         ServiceReference reference = mock(ServiceReference.class);
+        when(reference.getProperty(Constants.SERVICE_ID)).thenReturn(1L);
+        when(reference.getProperty(Constants.OBJECTCLASS)).thenReturn("the class");
+
         BundleContext bundleContext = mock(BundleContext.class);
         when(bundleContext.getProperty(Constants.FRAMEWORK_UUID)).thenReturn("some-uuid");
         when(bundleContext.getService(reference)).thenReturn(service);
@@ -64,17 +67,12 @@ public class CompendiumHandlerTest {
         JMXAgentContext agentContext = mock(JMXAgentContext.class);
         when(agentContext.getBundleContext()).thenReturn(bundleContext);
         when(agentContext.getLogger()).thenReturn(agentLogger);
-        ExecutorService executor = Executors.newSingleThreadExecutor();
-        when(agentContext.getRegistrationExecutor()).thenReturn(executor);
 
         AbstractCompendiumHandler concreteHandler = new CompendiumHandler(agentContext, "org.osgi.service.Xxx");
         target = spy(concreteHandler);
 
         target.addingService(reference);
 
-        executor.shutdown();
-        executor.awaitTermination(2, TimeUnit.SECONDS);
-
         //service only got once
         verify(bundleContext).getService(reference);
         //template method is invoked
@@ -89,26 +87,24 @@ public class CompendiumHandlerTest {
 
         Object service = new Object();
         ServiceReference reference = mock(ServiceReference.class);
+        when(reference.getProperty(Constants.SERVICE_ID)).thenReturn(1L);
+        when(reference.getProperty(Constants.OBJECTCLASS)).thenReturn("the class");
 
         BundleContext bundleContext = mock(BundleContext.class);
         Logger agentLogger = mock(Logger.class);
         JMXAgentContext agentContext = mock(JMXAgentContext.class);
         when(agentContext.getBundleContext()).thenReturn(bundleContext);
         when(agentContext.getLogger()).thenReturn(agentLogger);
-        ExecutorService executor = Executors.newSingleThreadExecutor();
-        when(agentContext.getRegistrationExecutor()).thenReturn(executor);
 
         AbstractCompendiumHandler concreteHandler = new CompendiumHandler(agentContext, "org.osgi.service.Xxx");
         target = spy(concreteHandler);
+        target.trackedId.set(1);
 
         String name = "osgi.compendium:service=xxx,version=1.0";
         doReturn(name).when(target).getName();
 
         target.removedService(reference, service);
 
-        executor.shutdown();
-        executor.awaitTermination(2, TimeUnit.SECONDS);
-
         //service unget
         verify(bundleContext).ungetService(reference);
         //unregister is invoked on context

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanHandlerTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanHandlerTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanHandlerTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanHandlerTest.java Mon Jun 30 16:54:57 2014
@@ -22,6 +22,8 @@ import static org.mockito.Mockito.verify
 import static org.mockito.Mockito.when;
 
 import org.apache.aries.jmx.Logger;
+import org.apache.aries.jmx.agent.JMXAgent;
+import org.apache.aries.jmx.agent.JMXAgentContext;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -59,7 +61,10 @@ public class BundleStateMBeanHandlerTest
         when(context.getServiceReference(StartLevel.class.getName())).thenReturn(startLevelRef);
         when(context.getService(startLevelRef)).thenReturn(startLevel);
 
-        BundleStateMBeanHandler handler = new BundleStateMBeanHandler(context, logger);
+        JMXAgent agent = mock(JMXAgent.class);
+        JMXAgentContext agentContext = new JMXAgentContext(context, agent, logger);
+
+        BundleStateMBeanHandler handler = new BundleStateMBeanHandler(agentContext);
         handler.open();
 
         assertNotNull(handler.getMbean());

Modified: aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanHandlerTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanHandlerTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanHandlerTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanHandlerTest.java Mon Jun 30 16:54:57 2014
@@ -21,6 +21,8 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import org.apache.aries.jmx.Logger;
+import org.apache.aries.jmx.agent.JMXAgent;
+import org.apache.aries.jmx.agent.JMXAgentContext;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -46,7 +48,10 @@ public class ServiceStateMBeanHandlerTes
         when(mockSystemBundle.getSymbolicName()).thenReturn("the.sytem.bundle");
         when(context.getBundle(0)).thenReturn(mockSystemBundle);
 
-        ServiceStateMBeanHandler handler = new ServiceStateMBeanHandler(context, logger);
+        JMXAgent agent = mock(JMXAgent.class);
+        JMXAgentContext agentContext = new JMXAgentContext(context, agent, logger);
+
+        ServiceStateMBeanHandler handler = new ServiceStateMBeanHandler(agentContext);
         handler.open();
 
         assertNotNull(handler.getMbean());

Modified: aries/branches/subsystemsR6/jmx/jmx-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-itests/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-itests/pom.xml (original)
+++ aries/branches/subsystemsR6/jmx/jmx-itests/pom.xml Mon Jun 30 16:54:57 2014
@@ -1,26 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
-    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.
+ 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.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
     <modelVersion>4.0.0</modelVersion>
+
     <parent>
         <groupId>org.apache.aries</groupId>
-        <artifactId>java5-parent</artifactId>
-        <version>1.0.0</version>
-        <relativePath />
+        <artifactId>parent</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 
     <groupId>org.apache.aries.jmx</groupId>
@@ -32,23 +37,42 @@
        Integration tests for the JMX component (using the standalone composite jmx-bundle)
     </description>
 
-     <scm>
-         <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-itests</connection>
-         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-itests</developerConnection>
-         <url>http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-itests</url>
-     </scm>
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-itests</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-itests</developerConnection>
+        <url>http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-itests</url>
+    </scm>
+     
+     <properties>
+        <exam.version>3.4.0</exam.version>
+        <url.version>1.6.0</url.version>
+    </properties>
 
     <dependencies>
+    	<!-- 
         <dependency>
             <groupId>org.apache.aries.jmx</groupId>
             <artifactId>org.apache.aries.jmx</artifactId>
-            <version>1.1.0</version>
+            <version>1.1.2-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+         -->
+         <dependency>
+            <groupId>org.apache.aries.jmx</groupId>
+            <artifactId>org.apache.aries.jmx.api</artifactId>
+            <version>1.1.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jmx</groupId>
+            <artifactId>org.apache.aries.jmx.core</artifactId>
+            <version>1.1.2-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.jmx</groupId>
             <artifactId>org.apache.aries.jmx.blueprint</artifactId>
-            <version>1.1.0</version>
+            <version>1.1.2-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -56,17 +80,13 @@
             <artifactId>org.apache.aries.jmx.whiteboard</artifactId>
             <version>1.1.0-SNAPSHOT</version>
         </dependency>
+        <!-- 
         <dependency>
             <groupId>org.apache.aries.jmx</groupId>
             <artifactId>org.apache.aries.jmx.core.whiteboard</artifactId>
-            <version>1.1.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
-            <version>4.3.0</version>
-            <scope>provided</scope>
+            <version>1.1.2-SNAPSHOT</version>
         </dependency>
+        -->
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
@@ -75,9 +95,9 @@
         <dependency>
           <groupId>org.apache.aries.testsupport</groupId>
           <artifactId>org.apache.aries.testsupport.unit</artifactId>
-          <version>1.0.0</version>
+          <version>2.0.0-SNAPSHOT</version>
           <scope>test</scope>
-        </dependency>        
+        </dependency>       
         <dependency>
             <groupId>org.apache.aries.blueprint</groupId>
             <artifactId>org.apache.aries.blueprint.sample</artifactId>
@@ -99,19 +119,19 @@
         <dependency>
             <groupId>org.apache.aries.proxy</groupId>
             <artifactId>org.apache.aries.proxy</artifactId>
-            <version>1.0.0</version>
+            <version>1.0.2-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.ow2.asm</groupId>
-            <artifactId>asm-all</artifactId>
-            <version>4.0</version>
+            <artifactId>asm-debug-all</artifactId>
+            <version>5.0.3</version>
             <scope>test</scope>
         </dependency>
         <dependency>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.configadmin</artifactId>
-                <version>1.2.4</version>
+                <version>1.8.0</version>
                 <exclusions>
                     <exclusion>
                         <groupId>org.apache.felix</groupId>
@@ -135,41 +155,77 @@
             <version>1.0.0</version>
             <scope>test</scope>
         </dependency>
+        
+		<!-- pax exam -->
         <dependency>
-            <groupId>org.ops4j.pax.logging</groupId>
-            <artifactId>pax-logging-api</artifactId>
-            <scope>test</scope>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.7</version>
         </dependency>
         <dependency>
-            <groupId>org.ops4j.pax.logging</groupId>
-            <artifactId>pax-logging-service</artifactId>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>${exam.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam</artifactId>
+            <artifactId>pax-exam-container-forked</artifactId>
+            <version>${exam.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-junit</artifactId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${exam.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-container-default</artifactId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${exam.version}</version>
             <scope>test</scope>
         </dependency>
-		<dependency>
-			<groupId>org.ops4j.pax.swissbox</groupId>
-			<artifactId>pax-swissbox-tinybundles</artifactId>
-			<scope>test</scope>
-		</dependency>
         <dependency>
             <groupId>org.ops4j.pax.url</groupId>
-            <artifactId>pax-url-mvn</artifactId>
+            <artifactId>pax-url-aether</artifactId>
+            <version>${url.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <version>0.9.29</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>0.9.29</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.tinybundles</groupId>
+            <artifactId>tinybundles</artifactId>
+            <version>2.0.0</version>
+            <exclusions>
+            	<exclusion>
+            		<artifactId>org.osgi.core</artifactId>
+            		<groupId>org.osgi</groupId>
+            	</exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse</groupId>
+            <artifactId>org.eclipse.osgi</artifactId>
+            <version>3.8.0.v20120529-1548</version>
         </dependency>
-    </dependencies>
+   </dependencies>
 
     <build>
         <plugins>
@@ -192,14 +248,6 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
                     <forkMode>pertest</forkMode>
-                    <excludes>
-                        <exclude>**/*$*</exclude>
-                        <exclude>**/Abstract*.java</exclude>
-                    </excludes>
-                    <includes>
-                        <include>**/Test*.java</include>
-                        <include>**/*Test.java</include>
-                    </includes>
                 </configuration>
             </plugin>
         </plugins>

Modified: aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java (original)
+++ aries/branches/subsystemsR6/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java Mon Jun 30 16:54:57 2014
@@ -17,106 +17,197 @@
 package org.apache.aries.jmx;
 
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
 import java.util.Set;
 
+import javax.inject.Inject;
 import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
 import javax.management.MBeanServerInvocationHandler;
 import javax.management.ObjectName;
 
-import org.junit.After;
-import org.junit.Before;
+import org.apache.aries.jmx.test.MbeanServerActivator;
 import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
 
 /**
  * @version $Rev$ $Date$
  */
-@RunWith(JUnit4TestRunner.class)
-public class AbstractIntegrationTest extends org.apache.aries.itest.AbstractIntegrationTest {
-
-    ServiceRegistration registration;
-    ServiceReference reference;
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public abstract class AbstractIntegrationTest extends org.apache.aries.itest.AbstractIntegrationTest {
+    protected ServiceReference reference;
+    
+    @Inject
     protected MBeanServer mbeanServer;
 
-    @Before
-    public void setUp() throws Exception {
-        mbeanServer = MBeanServerFactory.createMBeanServer();
-
-        registration = bundleContext.registerService(MBeanServer.class
-                .getCanonicalName(), mbeanServer, null);
-
-        String key = MBeanServer.class.getCanonicalName();
-        System.out.println(key);
-
-        reference = bundleContext.getServiceReference(key);
-        assertNotNull(reference);
-        MBeanServer mbeanService = (MBeanServer) bundleContext.getService(reference);
-        assertNotNull(mbeanService);
-
-        doSetUp();
-    }
-
-    /**
-     * A hook for subclasses.
-     *
-     * @throws Exception
-     */
-    protected void doSetUp() throws Exception {}
+	public Option baseOptions() {
+        String localRepo = System.getProperty("maven.repo.local");
+        if (localRepo == null) {
+            localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+        }
+        return composite(
+                junitBundles(),
+                // this is how you set the default log level when using pax
+                // logging (logProfile)
+                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+                when(localRepo != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo))
+         );
+    }
+
+	protected Option jmxRuntime() {
+		return composite(
+				baseOptions(),
+				mavenBundle("org.osgi", "org.osgi.compendium").versionAsInProject(),
+				mavenBundle("org.apache.aries", "org.apache.aries.util").versionAsInProject(),
+				mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject(),
+                mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx").version("1.1.2-SNAPSHOT"),
+                mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.core.whiteboard").version("1.1.2-SNAPSHOT"),
+				mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.api").versionAsInProject(),
+				mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.whiteboard").versionAsInProject(),
+				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
+				mbeanServerBundle()
+				);
+	}
+
+	protected Option mbeanServerBundle() {
+		return provision(bundle()
+		        .add(MbeanServerActivator.class)
+		        .set(Constants.BUNDLE_ACTIVATOR, MbeanServerActivator.class.getName())
+		        .build(withBnd()));
+	}
+	
+	protected Option bundlea() {
+		return provision(bundle()
+		        .add(org.apache.aries.jmx.test.bundlea.Activator.class)
+		        .add(org.apache.aries.jmx.test.bundlea.api.InterfaceA.class)
+		        .add(org.apache.aries.jmx.test.bundlea.impl.A.class)
+		        .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundlea")
+		        .set(Constants.BUNDLE_VERSION, "2.0.0")
+		        .set(Constants.EXPORT_PACKAGE, "org.apache.aries.jmx.test.bundlea.api;version=2.0.0")
+		        .set(Constants.IMPORT_PACKAGE,
+		                "org.osgi.framework;version=1.5.0,org.osgi.util.tracker,org.apache.aries.jmx.test.bundleb.api;version=1.1.0;resolution:=optional" +
+		                ",org.osgi.service.cm")
+		        .set(Constants.BUNDLE_ACTIVATOR,
+		                org.apache.aries.jmx.test.bundlea.Activator.class.getName())
+		        .build(withBnd()));
+	}
+    
+	protected Option bundleb() {
+		return provision(bundle()
+		        .add(org.apache.aries.jmx.test.bundleb.Activator.class)
+		        .add(org.apache.aries.jmx.test.bundleb.api.InterfaceB.class)
+		        .add(org.apache.aries.jmx.test.bundleb.api.MSF.class)
+		        .add(org.apache.aries.jmx.test.bundleb.impl.B.class)
+		        .set(Constants.BUNDLE_SYMBOLICNAME,"org.apache.aries.jmx.test.bundleb")
+		        .set(Constants.BUNDLE_VERSION, "1.0.0")
+		        .set(Constants.EXPORT_PACKAGE,"org.apache.aries.jmx.test.bundleb.api;version=1.1.0")
+		        .set(Constants.IMPORT_PACKAGE,"org.osgi.framework;version=1.5.0,org.osgi.util.tracker," +
+		        		"org.osgi.service.cm,org.apache.aries.jmx.test.fragmentc")
+		        .set(Constants.BUNDLE_ACTIVATOR,
+		                org.apache.aries.jmx.test.bundleb.Activator.class.getName())
+		        .build(withBnd()));
+	}
+    
+	protected Option fragmentc() {
+		return streamBundle(bundle()
+		        .add(org.apache.aries.jmx.test.fragmentc.C.class)
+		        .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.fragc")
+		        .set(Constants.FRAGMENT_HOST, "org.apache.aries.jmx.test.bundlea")
+		        .set(Constants.EXPORT_PACKAGE, "org.apache.aries.jmx.test.fragmentc")
+		        .build(withBnd())).noStart();
+	}
+	
+	protected Option bundled() {
+		return provision(bundle()
+		        .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundled")
+		        .set(Constants.BUNDLE_VERSION, "3.0.0")
+		        .set(Constants.REQUIRE_BUNDLE, "org.apache.aries.jmx.test.bundlea;bundle-version=2.0.0")
+		        .build(withBnd()));
+	}
+	
+	protected Option bundlee() {
+		return provision(bundle()
+		        .set(Constants.BUNDLE_SYMBOLICNAME, "org.apache.aries.jmx.test.bundlee")
+		        .set(Constants.BUNDLE_DESCRIPTION, "%desc")
+		        .add("OSGI-INF/l10n/bundle.properties", getBundleProps("desc", "Description"))
+		        .add("OSGI-INF/l10n/bundle_nl.properties", getBundleProps("desc", "Omschrijving"))
+		        .build(withBnd()));
+	}
 
-    @After
-    public void tearDown() throws Exception {
-        bundleContext.ungetService(reference);
-        //plainRegistration.unregister();
+    private InputStream getBundleProps(String key, String value) {
+        try {
+            Properties p = new Properties();
+            p.put(key, value);
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            p.store(baos, "");
+            return new ByteArrayInputStream(baos.toByteArray());
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
     }
-
-    protected ObjectName waitForMBean(ObjectName name) throws Exception {
-        return waitForMBean(name, 10);
+	
+    protected ObjectName waitForMBean(String name) {
+        return waitForMBean(name, 20);
     }
 
-    protected ObjectName waitForMBean(ObjectName name, int timeoutInSeconds) throws Exception {
+    protected ObjectName waitForMBean(String name, int timeoutInSeconds) {
         int i=0;
         while (true) {
-            ObjectName queryName = new ObjectName(name.toString() + ",*");
+            ObjectName queryName;
+			try {
+				queryName = new ObjectName(name.toString() + ",*");
+			} catch (Exception e) {
+				throw new IllegalArgumentException("Invalid name " + name, e);
+			}
             Set<ObjectName> result = mbeanServer.queryNames(queryName, null);
             if (result.size() > 0)
                 return result.iterator().next();
 
-            if (i == timeoutInSeconds)
-                throw new Exception(name + " mbean is not available after waiting " + timeoutInSeconds + " seconds");
+            if (i == timeoutInSeconds * 10)
+                throw new RuntimeException(name + " mbean is not available after waiting " + timeoutInSeconds + " seconds");
 
             i++;
-            Thread.sleep(1000);
+            try {
+				Thread.sleep(100);
+			} catch (InterruptedException e) {
+			}
         }
     }
 
-    @SuppressWarnings("unchecked")
     protected <T> T getMBean(String name, Class<T> type) {
-        ObjectName objectName = null;
-        try {
-            objectName = new ObjectName(name + ",*");
-        } catch (Exception e) {
-            fail(e.toString());
-        }
-        assertNotNull(mbeanServer);
-        assertNotNull(objectName);
-
-        Set<ObjectName> names = mbeanServer.queryNames(objectName, null);
-        if (names.size() == 0) {
-            fail("Object name not found: " + objectName);
-        }
-
-        T mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, names.iterator().next(),
-                type, false);
-        return mbean;
+        ObjectName objectName = waitForMBean(name);
+        return getMBean(objectName, type);
     }
 
     protected <T> T getMBean(ObjectName objectName, Class<T> type) {
-        T mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, type, false);
-        return mbean;
+        return MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, type, false);
+    }
+    
+    protected Bundle getBundleByName(String symName) {
+    	Bundle b = context().getBundleByName(symName);
+        assertNotNull("Bundle " + symName + "should be installed", b);
+        return b;
     }
 }
\ No newline at end of file



Mime
View raw message