Skip to content

Commit

Permalink
KARAF-1786 - Fix serialization issues in scr plugin
Browse files Browse the repository at this point in the history
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
splatch committed Aug 30, 2012
1 parent 00bd37b commit f44b86f
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 25 deletions.
2 changes: 1 addition & 1 deletion osgi/scr/pom.xml
Expand Up @@ -61,7 +61,7 @@
</Import-Package> </Import-Package>
<Export-Package></Export-Package> <Export-Package></Export-Package>
<Private-Package>org.apache.karaf.webconsole.osgi.scr*,</Private-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> </instructions>
</configuration> </configuration>
</plugin> </plugin>
Expand Down
Expand Up @@ -34,24 +34,20 @@ public class ScrColumn extends AbstractColumn<Bundle> {


private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;


private ScrService scr; public ScrColumn(String title) {

public ScrColumn(ScrService scr, String title) {
super(of(title)); super(of(title));
this.scr = scr;
} }


public void populateItem(Item<ICellPopulator<Bundle>> cellItem, String componentId, IModel<Bundle> rowModel) { public void populateItem(Item<ICellPopulator<Bundle>> cellItem, String componentId, IModel<Bundle> rowModel) {
if (scr == null) { ScrService scr = ScrComponent.getScrService();
return;
}


Component[] components = scr.getComponents(rowModel.getObject()); Component[] components = null;
if (components != null) { if (scr == null || (components = scr.getComponents(rowModel.getObject())) == null) {
cellItem.add(new ScrColumnPanel(componentId, components));
} else {
// no scr for this bundle // no scr for this bundle
cellItem.add(new Label(componentId)); cellItem.add(new Label(componentId));
return;
} }

cellItem.add(new ScrColumnPanel(componentId, components));
} }
} }
Expand Up @@ -16,8 +16,6 @@
*/ */
package org.apache.karaf.webconsole.osgi.scr; package org.apache.karaf.webconsole.osgi.scr;


import static org.apache.wicket.model.Model.of;

import org.apache.felix.scr.Component; import org.apache.felix.scr.Component;
import org.apache.wicket.MarkupContainer; import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.WebMarkupContainer;
Expand All @@ -35,7 +33,7 @@ public class ScrColumnPanel extends Panel {
public ScrColumnPanel(String id, Component[] components) { public ScrColumnPanel(String id, Component[] components) {
super(id); super(id);


RepeatingView view = new RepeatingView("components", of(components)); RepeatingView view = new RepeatingView("components");


for (Component component : components) { for (Component component : components) {
MarkupContainer container = new WebMarkupContainer(view.newChildId()); MarkupContainer container = new WebMarkupContainer(view.newChildId());
Expand Down
Expand Up @@ -23,10 +23,10 @@
/** /**
* Scr column provider, creates a dedicated column. * Scr column provider, creates a dedicated column.
*/ */
public class ScrColumnProvider extends ScrComponent implements IColumnProvider { public class ScrColumnProvider implements IColumnProvider {


public IColumn<Bundle> getColumn() { public IColumn<Bundle> getColumn() {
return new ScrColumn(scr, "SCR"); return new ScrColumn("SCR");
} }


} }
Expand Up @@ -24,14 +24,18 @@
*/ */
public class ScrComponent { public class ScrComponent {


protected ScrService scr; static protected ScrService scr;


public void bind(ScrService service) { public void bind(ScrService service) {
this.scr = service; scr = service;
} }


public void unbind(ScrService service) { public void unbind(ScrService service) {
this.scr = null; scr = null;
}

public static ScrService getScrService() {
return scr;
} }


} }
Expand Up @@ -17,6 +17,7 @@


package org.apache.karaf.webconsole.osgi.scr; 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.behavior.CssBehavior;
import org.apache.karaf.webconsole.core.panel.CssImagePanel; import org.apache.karaf.webconsole.core.panel.CssImagePanel;
import org.apache.karaf.webconsole.osgi.core.spi.IDecorationProvider; import org.apache.karaf.webconsole.osgi.core.spi.IDecorationProvider;
Expand All @@ -27,10 +28,11 @@
/** /**
* A decoration provider which add scr icon in first column of bundles. * 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) { public Panel getDecoration(String componentId, IModel<Bundle> model) {
Bundle bundle = model.getObject(); Bundle bundle = model.getObject();
ScrService scr = ScrComponent.getScrService();


if (scr == null || scr.getComponents(bundle) == null) { if (scr == null || scr.getComponents(bundle) == null) {
return null; return null;
Expand Down
1 change: 0 additions & 1 deletion osgi/scr/src/main/resources/OSGI-INF/column.xml
Expand Up @@ -22,5 +22,4 @@
<provide interface="org.apache.karaf.webconsole.osgi.core.spi.IColumnProvider"/> <provide interface="org.apache.karaf.webconsole.osgi.core.spi.IColumnProvider"/>
</service> </service>


<reference name="ScrService" cardinality="1..1" interface="org.apache.felix.scr.ScrService" policy="static" bind="bind" unbind="unbind" />
</scr:component> </scr:component>
22 changes: 22 additions & 0 deletions osgi/scr/src/main/resources/OSGI-INF/component.xml
@@ -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>
1 change: 0 additions & 1 deletion osgi/scr/src/main/resources/OSGI-INF/decoration.xml
Expand Up @@ -22,5 +22,4 @@
<provide interface="org.apache.karaf.webconsole.osgi.core.spi.IDecorationProvider"/> <provide interface="org.apache.karaf.webconsole.osgi.core.spi.IDecorationProvider"/>
</service> </service>


<reference name="ScrService" cardinality="1..1" interface="org.apache.felix.scr.ScrService" policy="static" bind="bind" unbind="unbind" />
</scr:component> </scr:component>
Expand Up @@ -16,8 +16,8 @@
*/ */


.scr { .scr {
background: url("scr.gif"); background: url("scr.png");
width: 16px; width: 13px;
height: 16px; height: 16px;
display: block; display: block;
} }
Binary file not shown.
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.