felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vvalc...@apache.org
Subject svn commit: r1610409 - in /felix/trunk/webconsole-plugins/ds: ./ src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ src/main/resources/OSGI-INF/l10n/
Date Mon, 14 Jul 2014 13:35:26 GMT
Author: vvalchev
Date: Mon Jul 14 13:35:25 2014
New Revision: 1610409

URL: http://svn.apache.org/r1610409
Log:
Fixed FELIX-3140 : Display link for component id within the bundle details and service details
view
https://issues.apache.org/jira/browse/FELIX-3140

Added:
    felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/InfoProvider.java
  (with props)
Modified:
    felix/trunk/webconsole-plugins/ds/pom.xml
    felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Activator.java
    felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle.properties
    felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle_bg.properties

Modified: felix/trunk/webconsole-plugins/ds/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/pom.xml?rev=1610409&r1=1610408&r2=1610409&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/ds/pom.xml (original)
+++ felix/trunk/webconsole-plugins/ds/pom.xml Mon Jul 14 13:35:25 2014
@@ -96,7 +96,7 @@
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.webconsole</artifactId>
-            <version>3.1.0</version>
+            <version>4.2.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Activator.java?rev=1610409&r1=1610408&r2=1610409&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Activator.java
(original)
+++ felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Activator.java
Mon Jul 14 13:35:25 2014
@@ -36,6 +36,7 @@ public class Activator implements Bundle
 
     private SimpleWebConsolePlugin plugin;
     private ServiceRegistration printerRegistration;
+    private ServiceRegistration infoRegistration;
 
     /**
      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
@@ -77,8 +78,10 @@ public class Activator implements Bundle
         if (plugin == null)
         {
             this.plugin = plugin = new WebConsolePlugin().register(context);
+            final Object service = context.getService(reference);
             printerRegistration = context.registerService(ConfigurationPrinter.SERVICE,
-                new ComponentConfigurationPrinter(context.getService(reference)), null);
+                new ComponentConfigurationPrinter(service), null);
+            infoRegistration = new InfoProvider(context.getBundle(), service).register(context);
         }
 
         return context.getService(reference);
@@ -104,6 +107,13 @@ public class Activator implements Bundle
                 reg.unregister();
                 printerRegistration = null;
             }
+            // unregister info provider too
+            reg = infoRegistration;
+            if (reg != null)
+            {
+                reg.unregister();
+                infoRegistration = null;
+            }
         }
 
     }

Added: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/InfoProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/InfoProvider.java?rev=1610409&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/InfoProvider.java
(added)
+++ felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/InfoProvider.java
Mon Jul 14 13:35:25 2014
@@ -0,0 +1,98 @@
+/*
+ * 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.felix.webconsole.plugins.ds.internal;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.felix.scr.Component;
+import org.apache.felix.scr.ScrService;
+import org.apache.felix.webconsole.bundleinfo.BundleInfo;
+import org.apache.felix.webconsole.bundleinfo.BundleInfoProvider;
+import org.apache.felix.webconsole.bundleinfo.BundleInfoType;
+import org.apache.felix.webconsole.i18n.LocalizationHelper;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+class InfoProvider implements BundleInfoProvider
+{
+
+    private final LocalizationHelper localization;
+
+    private final ScrService scrService;
+
+    InfoProvider(Bundle bundle, Object scrService)
+    {
+        this.scrService = (ScrService) scrService;
+        localization = new LocalizationHelper(bundle);
+    }
+
+    /**
+     * @see org.apache.felix.webconsole.bundleinfo.BundleInfoProvider#getName(java.util.Locale)
+     */
+    public String getName(Locale locale)
+    {
+        return localization.getResourceBundle(locale).getString("info.name"); //$NON-NLS-1$;;
+    }
+
+    /**
+    * @see org.apache.felix.webconsole.bundleinfo.BundleInfoProvider#getBundleInfo(org.osgi.framework.Bundle,
+    *      java.lang.String, java.util.Locale)
+    */
+    public BundleInfo[] getBundleInfo(Bundle bundle, String webConsoleRoot, Locale locale)
+    {
+
+        final Component[] components = scrService.getComponents(bundle);
+        if (null == components || components.length == 0)
+        {
+            return NO_INFO;
+        }
+
+        BundleInfo[] ret = new BundleInfo[components.length];
+        for (int i = 0; i < components.length; i++)
+        {
+            ret[i] = toInfo(components[i], webConsoleRoot, locale);
+        }
+        return ret;
+    }
+
+    private BundleInfo toInfo(Component component, String webConsoleRoot, Locale locale)
+    {
+        final ResourceBundle bundle = localization.getResourceBundle(locale);
+        final String state = ComponentConfigurationPrinter.toStateString(component.getState());
+        final String name = component.getName();
+        final String descr = bundle.getString("info.descr"); //$NON-NLS-1$;
+        String key = bundle.getString("info.key"); //$NON-NLS-1$;
+        // Component #{0} {1}, state {2}
+        key = MessageFormat.format(key, new Object[] { String.valueOf(component.getId()),
//
+                name != null ? name : "", //$NON-NLS-1$
+                state, //
+        });
+        return new BundleInfo(key, webConsoleRoot + "/components/" + component.getId(), //$NON-NLS-1$
+            BundleInfoType.LINK, descr);
+    }
+
+    ServiceRegistration register(BundleContext context)
+    {
+        return context.registerService(BundleInfoProvider.class.getName(), this, null);
+    }
+
+}

Propchange: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/InfoProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle.properties
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle.properties?rev=1610409&r1=1610408&r2=1610409&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle.properties (original)
+++ felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle.properties Mon
Jul 14 13:35:25 2014
@@ -47,3 +47,6 @@ scr.serv=Services
 scr.title.actions=Actions
 scr.title.status=Status
 scr.title.name=Name
+info.name=Declarative Service Components
+info.key=Component #{0} {1}, state {2}
+info.descr=This Declarative Service Component is provided by the bundle. Click to see more
details in "Components" plugin.

Modified: felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle_bg.properties?rev=1610409&r1=1610408&r2=1610409&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
(original)
+++ felix/trunk/webconsole-plugins/ds/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
Mon Jul 14 13:35:25 2014
@@ -47,3 +47,6 @@ scr.serv=Услуги
 scr.title.actions=Действия
 scr.title.status=Статус
 scr.title.name=Име
+info.name=Компоненти
+info.key=Компонент #{0} {1}, статус {2}
+info.descr=Този компонент се предоставя
от текущият бъндъл. Кликнете
за повече детайли в "Компоненти"
плъгина.



Mime
View raw message