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

osgi/blueprint/src/main/java/org/apache/karaf/webconsole/osgi/blueprint/bundle/BlueprintColumn.java [new file with mode: 0644]
osgi/blueprint/src/main/java/org/apache/karaf/webconsole/osgi/blueprint/bundle/BlueprintColumnProvider.java
osgi/blueprint/src/main/java/org/apache/karaf/webconsole/osgi/blueprint/bundle/BlueprintPanel.java [new file with mode: 0644]
osgi/blueprint/src/main/java/org/apache/karaf/webconsole/osgi/blueprint/details/MetadataModel.java
osgi/blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml
osgi/blueprint/src/main/resources/org/apache/karaf/webconsole/osgi/blueprint/bundle/BlueprintPanel.html [new file with mode: 0644]

diff --git a/osgi/blueprint/src/main/java/org/apache/karaf/webconsole/osgi/blueprint/bundle/BlueprintColumn.java b/osgi/blueprint/src/main/java/org/apache/karaf/webconsole/osgi/blueprint/bundle/BlueprintColumn.java
new file mode 100644 (file)
index 0000000..787cc2c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.karaf.webconsole.osgi.blueprint.bundle;
+
+import static org.apache.wicket.model.Model.of;
+
+import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.IModel;
+import org.osgi.framework.Bundle;
+
+/**
+ * Column representing items blueprint state.
+ */
+class BlueprintColumn extends AbstractColumn<Bundle> {
+
+    private static final long serialVersionUID = 1L;
+
+    public BlueprintColumn() {
+        super(of("Blueprint"));
+    }
+
+    public void populateItem(Item<ICellPopulator<Bundle>> cellItem, String componentId, IModel<Bundle> rowModel) {
+        cellItem.add(new BlueprintPanel(componentId, rowModel));
+    }
+}
\ No newline at end of file
index 2ab809a..430dc78 100644 (file)
  */
 package org.apache.karaf.webconsole.osgi.blueprint.bundle;
 
-import org.apache.karaf.webconsole.osgi.blueprint.BlueprintState;
-import org.apache.karaf.webconsole.osgi.blueprint.IBlueprintBundleStateTracker;
 import org.apache.karaf.webconsole.osgi.core.spi.IColumnProvider;
-import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
 import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.repeater.Item;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
 import org.osgi.framework.Bundle;
 
 /**
@@ -33,25 +25,8 @@ import org.osgi.framework.Bundle;
  */
 public class BlueprintColumnProvider implements IColumnProvider {
 
-    private IBlueprintBundleStateTracker tracker;
-
-    public BlueprintColumnProvider(IBlueprintBundleStateTracker tracker) {
-        this.tracker = tracker;
-    }
-
-    @SuppressWarnings("serial")
     public IColumn<Bundle> getColumn() {
-        return new AbstractColumn<Bundle>(Model.of("Blueprint")) {
-            public void populateItem(Item<ICellPopulator<Bundle>> cellItem, String componentId, IModel<Bundle> rowModel) {
-                Bundle bundle = rowModel.getObject();
-                BlueprintState state = tracker.getState(bundle);
-                if (state != null) {
-                    cellItem.add(new Label(componentId, state.name()));
-                } else {
-                    cellItem.add(new Label(componentId));
-                }
-            }
-        };
+        return new BlueprintColumn();
     }
 
 }
diff --git a/osgi/blueprint/src/main/java/org/apache/karaf/webconsole/osgi/blueprint/bundle/BlueprintPanel.java b/osgi/blueprint/src/main/java/org/apache/karaf/webconsole/osgi/blueprint/bundle/BlueprintPanel.java
new file mode 100644 (file)
index 0000000..e5dbd56
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.karaf.webconsole.osgi.blueprint.bundle;
+
+import org.apache.karaf.webconsole.osgi.blueprint.BlueprintState;
+import org.apache.karaf.webconsole.osgi.blueprint.IBlueprintBundleStateTracker;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.ops4j.pax.wicket.api.PaxWicketBean;
+import org.osgi.framework.Bundle;
+
+public class BlueprintPanel extends Panel {
+
+    private static final long serialVersionUID = 1L;
+
+    @PaxWicketBean(name = "tracker")
+    private IBlueprintBundleStateTracker tracker;
+
+    public BlueprintPanel(String componentId, IModel<Bundle> model) {
+        super(componentId, model);
+
+        Bundle bundle = model.getObject();
+        BlueprintState state = tracker.getState(bundle);
+        if (state != null) {
+            add(new Label("state", state.name()));
+        } else {
+            add(new Label("state"));
+        }
+    }
+
+}
index b4bf6fb..f1fbb23 100644 (file)
@@ -66,5 +66,6 @@ class MetadataModel extends LoadableDetachableModel<List<ComponentMetadata>> {
         if (reference != null) {
             context.ungetService(reference);
         }
+        reference = null;
     }
-}
\ No newline at end of file
+}
index 8a7ccbb..79f91fc 100644 (file)
 
     <bean id="provider" class="org.apache.karaf.webconsole.osgi.blueprint.navigation.BlueprintNavigationProvider" />
 
-    <bean id="tracker" class="org.apache.karaf.webconsole.osgi.blueprint.BlueprintBundleStateTracker" />
+    <bean id="trackerBean" class="org.apache.karaf.webconsole.osgi.blueprint.BlueprintBundleStateTracker" />
 
     <service auto-export="interfaces">
-        <bean class="org.apache.karaf.webconsole.osgi.blueprint.bundle.BlueprintActionProvider">
-            <argument ref="trackerService" />
-        </bean>
+        <bean class="org.apache.karaf.webconsole.osgi.blueprint.bundle.BlueprintActionProvider" />
     </service>
 
     <service auto-export="interfaces">
-        <bean class="org.apache.karaf.webconsole.osgi.blueprint.bundle.BlueprintColumnProvider">
-            <argument ref="trackerService" />
-        </bean>
+        <bean class="org.apache.karaf.webconsole.osgi.blueprint.bundle.BlueprintColumnProvider" />
     </service>
 
     <service auto-export="interfaces">
         <bean class="org.apache.karaf.webconsole.osgi.blueprint.bundle.BlueprintDecorationProvider">
-            <argument ref="trackerService" />
+            <argument ref="tracker" />
         </bean>
     </service>
 
-    <service ref="tracker" auto-export="interfaces" />
+    <reference id="tracker" interface="org.apache.karaf.webconsole.osgi.blueprint.IBlueprintBundleStateTracker" availability="optional" />
+
+    <service ref="trackerBean" auto-export="interfaces" />
 
-    <reference id="trackerService" interface="org.apache.karaf.webconsole.osgi.blueprint.IBlueprintBundleStateTracker"
-        availability="optional" />
 
 </blueprint>
diff --git a/osgi/blueprint/src/main/resources/org/apache/karaf/webconsole/osgi/blueprint/bundle/BlueprintPanel.html b/osgi/blueprint/src/main/resources/org/apache/karaf/webconsole/osgi/blueprint/bundle/BlueprintPanel.html
new file mode 100644 (file)
index 0000000..8fffc63
--- /dev/null
@@ -0,0 +1,20 @@
+<?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.
+-->
+<wicket:panel xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+    <span wicket:id="state" />
+</wicket:panel>
\ No newline at end of file