Permalink
Browse files

KARAF-1786 - Fix serialization issues in scr plugin

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
  • Loading branch information...
1 parent 00bd37b commit f44b86f56f52e8a0302670cdc03d672a8269edba @splatch splatch committed Aug 30, 2012
View
@@ -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>
@@ -34,24 +34,20 @@
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));
}
}
@@ -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 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());
@@ -23,10 +23,10 @@
/**
* 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");
}
}
@@ -24,14 +24,18 @@
*/
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;
}
}
@@ -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 @@
/**
* 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;
@@ -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>
@@ -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>
@@ -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>
@@ -16,8 +16,8 @@
*/
.scr {
- background: url("scr.gif");
- width: 16px;
+ background: url("scr.png");
+ width: 13px;
height: 16px;
display: block;
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f44b86f

Please sign in to comment.