KARAF-1786 - Fix serialization issues in scr plugin
authorŁukasz Dywicki <ldywicki@apache.org>
Thu, 30 Aug 2012 19:59:51 +0000 (19:59 +0000)
committerŁukasz Dywicki <ldywicki@apache.org>
Thu, 30 Aug 2012 19:59:51 +0000 (19:59 +0000)
Signed-off-by: Lukasz Dywicki <luke@code-house.org>
git-svn-id: https://svn.apache.org/repos/asf/karaf/webconsole/trunk@1379104 13f79535-47bb-0310-9956-ffa450edef68

12 files changed:
osgi/scr/pom.xml
osgi/scr/src/main/java/org/apache/karaf/webconsole/osgi/scr/ScrColumn.java
osgi/scr/src/main/java/org/apache/karaf/webconsole/osgi/scr/ScrColumnPanel.java
osgi/scr/src/main/java/org/apache/karaf/webconsole/osgi/scr/ScrColumnProvider.java
osgi/scr/src/main/java/org/apache/karaf/webconsole/osgi/scr/ScrComponent.java
osgi/scr/src/main/java/org/apache/karaf/webconsole/osgi/scr/ScrDecorationProvider.java
osgi/scr/src/main/resources/OSGI-INF/column.xml
osgi/scr/src/main/resources/OSGI-INF/component.xml [new file with mode: 0644]
osgi/scr/src/main/resources/OSGI-INF/decoration.xml
osgi/scr/src/main/resources/org/apache/karaf/webconsole/osgi/scr/decorator.css
osgi/scr/src/main/resources/org/apache/karaf/webconsole/osgi/scr/scr.gif [deleted file]
osgi/scr/src/main/resources/org/apache/karaf/webconsole/osgi/scr/scr.png [new file with mode: 0644]

index 140fb42..7b2da6b 100644 (file)
@@ -61,7 +61,7 @@
                         </Import-Package>
                         <Export-Package></Export-Package>
                         <Private-Package>org.apache.karaf.webconsole.osgi.scr*,</Private-Package>
-                        <Service-Component>OSGI-INF/column.xml,OSGI-INF/decoration.xml</Service-Component>
+                        <Service-Component>OSGI-INF/column.xml,OSGI-INF/decoration.xml,OSGI-INF/component.xml</Service-Component>
                     </instructions>
                 </configuration>
             </plugin>
index 88052d6..44dfb53 100644 (file)
@@ -34,24 +34,20 @@ public class ScrColumn extends AbstractColumn<Bundle> {
 
     private static final long serialVersionUID = 1L;
 
-    private ScrService scr;
-
-    public ScrColumn(ScrService scr, String title) {
+    public ScrColumn(String title) {
         super(of(title));
-        this.scr = scr;
     }
 
     public void populateItem(Item<ICellPopulator<Bundle>> cellItem, String componentId, IModel<Bundle> rowModel) {
-        if (scr == null) {
-            return;
-        }
+        ScrService scr = ScrComponent.getScrService();
 
-        Component[] components = scr.getComponents(rowModel.getObject());
-        if (components != null) {
-            cellItem.add(new ScrColumnPanel(componentId, components));
-        } else {
+        Component[] components = null;
+        if (scr == null || (components = scr.getComponents(rowModel.getObject())) == null) {
             // no scr for this bundle
             cellItem.add(new Label(componentId));
+            return;
         }
+
+        cellItem.add(new ScrColumnPanel(componentId, components));
     }
 }
\ No newline at end of file
index e1dafba..6b613ed 100644 (file)
@@ -16,8 +16,6 @@
  */
 package org.apache.karaf.webconsole.osgi.scr;
 
-import static org.apache.wicket.model.Model.of;
-
 import org.apache.felix.scr.Component;
 import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.markup.html.WebMarkupContainer;
@@ -35,7 +33,7 @@ public class ScrColumnPanel extends Panel {
     public ScrColumnPanel(String id, Component[] components) {
         super(id);
 
-        RepeatingView view = new RepeatingView("components", of(components));
+        RepeatingView view = new RepeatingView("components");
 
         for (Component component : components) {
             MarkupContainer container = new WebMarkupContainer(view.newChildId());
index 29cd5c4..b4bdd3e 100644 (file)
@@ -23,10 +23,10 @@ import org.osgi.framework.Bundle;
 /**
  * Scr column provider, creates a dedicated column.
  */
-public class ScrColumnProvider extends ScrComponent implements IColumnProvider {
+public class ScrColumnProvider implements IColumnProvider {
 
     public IColumn<Bundle> getColumn() {
-        return new ScrColumn(scr, "SCR");
+        return new ScrColumn("SCR");
     }
 
 }
index 3dd735f..02a728b 100644 (file)
@@ -24,14 +24,18 @@ import org.apache.felix.scr.ScrService;
  */
 public class ScrComponent {
 
-    protected ScrService scr;
+    static protected ScrService scr;
 
     public void bind(ScrService service) {
-        this.scr = service;
+        scr = service;
     }
 
     public void unbind(ScrService service) {
-        this.scr = null;
+        scr = null;
+    }
+
+    public static ScrService getScrService() {
+        return scr;
     }
 
 }
\ No newline at end of file
index 24760de..2f03339 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.apache.karaf.webconsole.osgi.scr;
 
+import org.apache.felix.scr.ScrService;
 import org.apache.karaf.webconsole.core.behavior.CssBehavior;
 import org.apache.karaf.webconsole.core.panel.CssImagePanel;
 import org.apache.karaf.webconsole.osgi.core.spi.IDecorationProvider;
@@ -27,10 +28,11 @@ import org.osgi.framework.Bundle;
 /**
  * A decoration provider which add scr icon in first column of bundles.
  */
-public class ScrDecorationProvider extends ScrComponent implements IDecorationProvider {
+public class ScrDecorationProvider implements IDecorationProvider {
 
     public Panel getDecoration(String componentId, IModel<Bundle> model) {
         Bundle bundle = model.getObject();
+        ScrService scr = ScrComponent.getScrService();
 
         if (scr == null || scr.getComponents(bundle) == null) {
             return null;
index d9f006d..9db45e7 100644 (file)
@@ -22,5 +22,4 @@
       <provide interface="org.apache.karaf.webconsole.osgi.core.spi.IColumnProvider"/>
    </service>
 
-   <reference name="ScrService" cardinality="1..1" interface="org.apache.felix.scr.ScrService" policy="static" bind="bind" unbind="unbind" />
 </scr:component>
diff --git a/osgi/scr/src/main/resources/OSGI-INF/component.xml b/osgi/scr/src/main/resources/OSGI-INF/component.xml
new file mode 100644 (file)
index 0000000..8bfaf85
--- /dev/null
@@ -0,0 +1,22 @@
+<?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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="scr-component">
+   <implementation class="org.apache.karaf.webconsole.osgi.scr.ScrComponent" />
+
+   <reference name="ScrService" cardinality="1..1" interface="org.apache.felix.scr.ScrService" policy="static" bind="bind" unbind="unbind" />
+</scr:component>
index b60a1bd..f988316 100644 (file)
@@ -22,5 +22,4 @@
       <provide interface="org.apache.karaf.webconsole.osgi.core.spi.IDecorationProvider"/>
    </service>
 
-   <reference name="ScrService" cardinality="1..1" interface="org.apache.felix.scr.ScrService" policy="static" bind="bind" unbind="unbind" />
 </scr:component>
index 477ab9f..1e900c1 100644 (file)
@@ -16,8 +16,8 @@
  */
 
 .scr {
-    background: url("scr.gif");
-    width: 16px;
+    background: url("scr.png");
+    width: 13px;
     height: 16px;
     display: block;
 }
\ No newline at end of file
diff --git a/osgi/scr/src/main/resources/org/apache/karaf/webconsole/osgi/scr/scr.gif b/osgi/scr/src/main/resources/org/apache/karaf/webconsole/osgi/scr/scr.gif
deleted file mode 100644 (file)
index cc9cbea..0000000
Binary files a/osgi/scr/src/main/resources/org/apache/karaf/webconsole/osgi/scr/scr.gif and /dev/null differ
diff --git a/osgi/scr/src/main/resources/org/apache/karaf/webconsole/osgi/scr/scr.png b/osgi/scr/src/main/resources/org/apache/karaf/webconsole/osgi/scr/scr.png
new file mode 100644 (file)
index 0000000..5ce0d2c
Binary files /dev/null and b/osgi/scr/src/main/resources/org/apache/karaf/webconsole/osgi/scr/scr.png differ