incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awojtun...@apache.org
Subject svn commit: r900527 - /incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/Framework.java
Date Mon, 18 Jan 2010 20:01:19 GMT
Author: awojtuniak
Date: Mon Jan 18 20:01:18 2010
New Revision: 900527

URL: http://svn.apache.org/viewvc?rev=900527&view=rev
Log:
ARIES-30 refactoring FrameworkMBean to use FrameworkUtils.

Modified:
    incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/Framework.java

Modified: incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/Framework.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/Framework.java?rev=900527&r1=900526&r2=900527&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/Framework.java
(original)
+++ incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/framework/Framework.java
Mon Jan 18 20:01:18 2010
@@ -24,6 +24,7 @@
 
 import org.apache.aries.jmx.codec.BatchActionResult;
 import org.apache.aries.jmx.codec.BatchInstallResult;
+import org.apache.aries.jmx.util.FrameworkUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -164,7 +165,7 @@
      * @see org.osgi.jmx.framework.FrameworkMBean#refreshPackages(long)
      */
     public void refreshPackages(long bundleIdentifier) throws IOException {
-        Bundle bundle = getBundle(bundleIdentifier);
+        Bundle bundle = FrameworkUtils.resolveBundle(context, bundleIdentifier);
         packageAdmin.refreshPackages(new Bundle[] { bundle });
 
     }
@@ -190,7 +191,7 @@
      * @see org.osgi.jmx.framework.FrameworkMBean#resolveBundle(long)
      */
     public boolean resolveBundle(long bundleIdentifier) throws IOException {
-        Bundle bundle = getBundle(bundleIdentifier);
+        Bundle bundle = FrameworkUtils.resolveBundle(context, bundleIdentifier);
         return packageAdmin.resolveBundles(new Bundle[] { bundle });
     }
 
@@ -203,7 +204,7 @@
          }
         Bundle[] bundles = new Bundle[bundleIdentifiers.length];
         for (int i = 0; i < bundleIdentifiers.length; i++) {
-            bundles[i] = getBundle(bundleIdentifiers[i]);
+            bundles[i] = FrameworkUtils.resolveBundle(context, bundleIdentifiers[i]);
         }
 
         return packageAdmin.resolveBundles(bundles);
@@ -226,7 +227,7 @@
      * @see org.osgi.jmx.framework.FrameworkMBean#setBundleStartLevel(long, int)
      */
     public void setBundleStartLevel(long bundleIdentifier, int newlevel) throws IOException
{
-        Bundle bundle = getBundle(bundleIdentifier);
+        Bundle bundle = FrameworkUtils.resolveBundle(context, bundleIdentifier);
         startLevel.setBundleStartLevel(bundle, newlevel);
 
     }
@@ -283,7 +284,7 @@
      * @see org.osgi.jmx.framework.FrameworkMBean#startBundle(long)
      */
     public void startBundle(long bundleIdentifier) throws IOException {
-        Bundle bundle = getBundle(bundleIdentifier);
+        Bundle bundle = FrameworkUtils.resolveBundle(context, bundleIdentifier);
         if (bundle != null) {
             try {
                 bundle.start();
@@ -314,7 +315,7 @@
      * @see org.osgi.jmx.framework.FrameworkMBean#stopBundle(long)
      */
     public void stopBundle(long bundleIdentifier) throws IOException {
-        Bundle bundle = getBundle(bundleIdentifier);
+        Bundle bundle = FrameworkUtils.resolveBundle(context, bundleIdentifier);
         if (bundle != null) {
             try {
                 bundle.stop();
@@ -345,7 +346,7 @@
      * @see org.osgi.jmx.framework.FrameworkMBean#uninstallBundle(long)
      */
     public void uninstallBundle(long bundleIdentifier) throws IOException {
-        Bundle bundle = getBundle(bundleIdentifier);
+        Bundle bundle = FrameworkUtils.resolveBundle(context, bundleIdentifier);
         if (bundle != null) {
             try {
                 bundle.uninstall();
@@ -377,7 +378,7 @@
      * @see org.osgi.jmx.framework.FrameworkMBean#updateBundle(long)
      */
     public void updateBundle(long bundleIdentifier) throws IOException {
-        Bundle bundle = getBundle(bundleIdentifier);
+        Bundle bundle = FrameworkUtils.resolveBundle(context, bundleIdentifier);
 
         try {
             bundle.update();
@@ -391,7 +392,7 @@
      * @see org.osgi.jmx.framework.FrameworkMBean#updateBundle(long, java.lang.String)
      */
     public void updateBundle(long bundleIdentifier, String url) throws IOException {
-        Bundle bundle = getBundle(bundleIdentifier);
+        Bundle bundle = FrameworkUtils.resolveBundle(context, bundleIdentifier);;
         InputStream inputStream = null;
         try {
             inputStream = createStream(url);
@@ -451,7 +452,7 @@
      * @see org.osgi.jmx.framework.FrameworkMBean#updateFramework()
      */
     public void updateFramework() throws IOException {
-        Bundle bundle = getBundle(0);
+        Bundle bundle = FrameworkUtils.resolveBundle(context, 0);
         try {
             bundle.update();
         } catch (BundleException be) {
@@ -475,19 +476,5 @@
         System.arraycopy(bundleIdentifiers, i + 1, remaining, 0, remaining.length);
         return new BatchActionResult(completed, t.toString(), remaining, bundleIdentifiers[i]).toCompositeData();
     }
-    
-    /**
-     * Gets bundle with provided bundleId.
-     * 
-     * @param bundleIdentifier bundle id.
-     * @return {@link Bundle} instance.
-     */
-    private Bundle getBundle(long bundleIdentifier) {
-        Bundle bundle = context.getBundle(bundleIdentifier);
-        if (bundle != null) {
-            return bundle;
-        }
-        throw new IllegalArgumentException("Can't find bundle with id " + bundleIdentifier);
-    }
 
 }



Mime
View raw message