You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2008/01/22 15:24:57 UTC
svn commit: r614204 [1/3] - in /incubator/sling/trunk/osgi/console-web: ./
src/main/java/org/apache/sling/osgi/console/web/
src/main/java/org/apache/sling/osgi/console/web/internal/
src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ s...
Author: fmeschbe
Date: Tue Jan 22 06:24:42 2008
New Revision: 614204
URL: http://svn.apache.org/viewvc?rev=614204&view=rev
Log:
SLING-184 Reorganize and minimize dependencies
Added:
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/ConfigurationPrinter.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BaseManagementPlugin.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/SlingManagerActivator.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/AbstractScrPlugin.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/AjaxConfigManagerAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxConfigManagerAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ComponentConfigurationPrinter.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ComponentRenderAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ComponentRenderAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ConfigManager.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigManager.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ConfigManagerBase.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigManagerBase.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxBundleDetailsAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/BundleAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/BundleListRender.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleListRender.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/InstallAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/InstallAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/RefreshPackagesAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/RefreshPackagesAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/SetStartLevelAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/SetStartLevelAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/StartAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/StartAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/StopAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/StopAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/UninstallAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/UninstallAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/UpdateAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/UpdateAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/misc/
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/misc/AssemblyListRender.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AssemblyListRender.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/misc/ConfigurationRender.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigurationRender.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/obr/
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/obr/AbstractObrPlugin.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/obr/BundleRepositoryRender.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleRepositoryRender.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/obr/InstallFromRepoAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/InstallFromRepoAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/obr/RefreshRepoAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/RefreshRepoAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/servlet/
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/servlet/ConfigurationListener.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/servlet/Logger.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/servlet/SlingHttpContext.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/servlet/SlingManager.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/GCAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/GCAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/ShutdownAction.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ShutdownAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/ShutdownRender.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ShutdownRender.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/system/VMStatRender.java
- copied, changed from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/VMStatRender.java
Removed:
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/SlingHttpContext.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/SlingManager.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxBundleDetailsAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxConfigManagerAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AssemblyListRender.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleListRender.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleRepositoryRender.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ComponentRenderAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigManager.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigManagerBase.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigurationRender.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/GCAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/InstallAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/InstallFromRepoAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/RefreshPackagesAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/RefreshRepoAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/SetStartLevelAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ShutdownAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ShutdownRender.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/StartAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/StopAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/UninstallAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/UpdateAction.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/VMStatRender.java
Modified:
incubator/sling/trunk/osgi/console-web/pom.xml
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/Action.java
incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/Render.java
Modified: incubator/sling/trunk/osgi/console-web/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/pom.xml?rev=614204&r1=614203&r2=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/pom.xml (original)
+++ incubator/sling/trunk/osgi/console-web/pom.xml Tue Jan 22 06:24:42 2008
@@ -52,6 +52,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
+ <version>1.0.3-SNAPSHOT</version>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
@@ -59,7 +60,14 @@
<extensions>true</extensions>
<configuration>
<instructions>
+ <Bundle-Activator>
+ org.apache.sling.osgi.console.web.internal.SlingManagerActivator
+ </Bundle-Activator>
+ <Export-Package>
+ org.apache.sling.osgi.console.web,
+ </Export-Package>
<Private-Package>
+ !org.apache.sling.osgi.console.web,
org.apache.sling.osgi.console.web.*,
<!-- File Upload functionality -->
@@ -72,11 +80,15 @@
org.apache.commons.io.filefilter,
org.apache.commons.io.output,
+ <!-- Required for JSON data transfer -->
+ org.apache.sling.commons.json,
+
<!-- Import/Export-Package parsing -->
org.apache.felix.bundlerepository
</Private-Package>
<Import-Package>
- org.apache.felix.*;resolution:=optional,*
+ org.apache.sling.*; org.apache.felix.*;
+ org.osgi.service.obr;resolution:=optional,*
</Import-Package>
</instructions>
</configuration>
@@ -117,7 +129,7 @@
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.json</artifactId>
<version>2.0.0-incubator-SNAPSHOT</version>
- <scope>provided</scope>
+ <scope>compile</scope>
</dependency>
<dependency>
Modified: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/Action.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/Action.java?rev=614204&r1=614203&r2=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/Action.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/Action.java Tue Jan 22 06:24:42 2008
@@ -24,11 +24,13 @@
public interface Action {
+ static final String SERVICE = Action.class.getName();
+
/**
* The name of a request attribute, which may be set by performAction if
* redirecting.
*/
- public static final String ATTR_REDIRECT_PARAMETERS= "redirectParameters";
+ static final String ATTR_REDIRECT_PARAMETERS= "redirectParameters";
String getName();
Added: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/ConfigurationPrinter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/ConfigurationPrinter.java?rev=614204&view=auto
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/ConfigurationPrinter.java (added)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/ConfigurationPrinter.java Tue Jan 22 06:24:42 2008
@@ -0,0 +1,31 @@
+/*
+ * 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.sling.osgi.console.web;
+
+import java.io.PrintWriter;
+
+public interface ConfigurationPrinter {
+
+ static final String SERVICE = ConfigurationPrinter.class.getName();
+
+ String getTitle();
+
+ void printConfiguration(PrintWriter printWriter);
+
+}
Modified: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/Render.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/Render.java?rev=614204&r1=614203&r2=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/Render.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/Render.java Tue Jan 22 06:24:42 2008
@@ -27,6 +27,8 @@
*/
public interface Render {
+ static final String SERVICE = Action.class.getName();
+
String getName();
String getLabel();
Added: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BaseManagementPlugin.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BaseManagementPlugin.java?rev=614204&view=auto
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BaseManagementPlugin.java (added)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BaseManagementPlugin.java Tue Jan 22 06:24:42 2008
@@ -0,0 +1,74 @@
+/*
+ * 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.sling.osgi.console.web.internal;
+
+import org.apache.sling.osgi.console.web.internal.servlet.Logger;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.startlevel.StartLevel;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class BaseManagementPlugin {
+
+ private BundleContext bundleContext;
+ private Logger log;
+
+ private ServiceTracker startLevelService;
+
+ private ServiceTracker packageAdmin;
+
+ protected BaseManagementPlugin() {
+ }
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
+ public void setLogger(Logger log) {
+ this.log = log;
+ }
+
+ protected BundleContext getBundleContext() {
+ return bundleContext;
+ }
+
+ protected Logger getLog() {
+ return log;
+ }
+
+ protected StartLevel getStartLevel() {
+ if (startLevelService == null) {
+ startLevelService = new ServiceTracker(getBundleContext(),
+ StartLevel.class.getName(), null);
+ startLevelService.open();
+ }
+ return (StartLevel) startLevelService.getService();
+ }
+
+ protected PackageAdmin getPackageAdmin() {
+ if (packageAdmin == null) {
+ packageAdmin = new ServiceTracker(getBundleContext(),
+ PackageAdmin.class.getName(), null);
+ packageAdmin.open();
+ }
+ return (PackageAdmin) packageAdmin.getService();
+ }
+
+
+}
Added: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/SlingManagerActivator.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/SlingManagerActivator.java?rev=614204&view=auto
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/SlingManagerActivator.java (added)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/SlingManagerActivator.java Tue Jan 22 06:24:42 2008
@@ -0,0 +1,39 @@
+/*
+ * 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.sling.osgi.console.web.internal;
+
+import org.apache.sling.osgi.console.web.internal.servlet.SlingManager;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class SlingManagerActivator implements BundleActivator {
+
+ private SlingManager slingManager;
+
+ public void start(BundleContext bundleContext) {
+ slingManager = new SlingManager(bundleContext);
+ }
+
+ public void stop(BundleContext arg0) {
+ if (slingManager != null) {
+ slingManager.dispose();
+ }
+ }
+
+}
Added: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/AbstractScrPlugin.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/AbstractScrPlugin.java?rev=614204&view=auto
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/AbstractScrPlugin.java (added)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/AbstractScrPlugin.java Tue Jan 22 06:24:42 2008
@@ -0,0 +1,44 @@
+/*
+ * 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.sling.osgi.console.web.internal.compendium;
+
+import org.apache.felix.scr.ScrService;
+import org.apache.sling.osgi.console.web.internal.BaseManagementPlugin;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class AbstractScrPlugin extends BaseManagementPlugin {
+
+ private ServiceTracker scrServiceTracker;
+
+ protected ScrService getScrService() {
+ if (scrServiceTracker == null) {
+ try {
+ scrServiceTracker = new ServiceTracker(getBundleContext(),
+ ScrService.class.getName(), null);
+ scrServiceTracker.open();
+ } catch (Throwable t) {
+ // missing ScrService class ??
+ return null;
+ }
+ }
+
+ return (ScrService) scrServiceTracker.getService();
+ }
+
+}
Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/AjaxConfigManagerAction.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxConfigManagerAction.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/AjaxConfigManagerAction.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/AjaxConfigManagerAction.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxConfigManagerAction.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxConfigManagerAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/AjaxConfigManagerAction.java Tue Jan 22 06:24:42 2008
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.compendium;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -29,7 +29,6 @@
import java.util.StringTokenizer;
import java.util.Vector;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -48,11 +47,7 @@
/**
* The <code>AjaxConfigManagerAction</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.reference interface="org.osgi.service.cm.ConfigurationAdmin" name="configurationAdmin"
- * @scr.reference interface="org.osgi.service.metatype.MetaTypeService" name="metaTypeService"
- * @scr.service
+ *
*/
public class AjaxConfigManagerAction extends ConfigManagerBase implements
Action {
@@ -69,16 +64,16 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.sling.manager.web.internal.Action#performAction(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
public boolean performAction(HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
+ HttpServletResponse response) throws IOException {
// should actually apply the configuration before redirecting
if (request.getParameter("apply") != null) {
- return this.applyConfiguration(request, response);
+ return applyConfiguration(request);
}
JSONObject result = new JSONObject();
@@ -116,7 +111,8 @@
Configuration config = null;
try {
- Configuration[] configs = ca.listConfigurations("(" + Constants.SERVICE_PID + "="+ pid + ")");
+ Configuration[] configs = ca.listConfigurations("("
+ + Constants.SERVICE_PID + "=" + pid + ")");
if (configs != null && configs.length > 0) {
config = configs[0];
}
@@ -139,7 +135,6 @@
props = this.mergeWithMetaType(props, ocd, json);
-
if (props != null) {
JSONObject properties = new JSONObject();
for (Enumeration<?> pe = props.keys(); pe.hasMoreElements();) {
@@ -229,14 +224,14 @@
if (ad[i].getCardinality() == 0) {
// scalar
if (value instanceof Vector) {
- value = ((Vector) value).get(0);
+ value = ((Vector<?>) value).get(0);
} else if (value.getClass().isArray()) {
value = Array.get(value, 0);
}
entry.put("value", value);
} else {
if (value instanceof Vector) {
- value = new JSONArray((Vector) value);
+ value = new JSONArray((Vector<?>) value);
} else if (value.getClass().isArray()) {
value = new JSONArray(
Arrays.asList((Object[]) value));
@@ -294,8 +289,8 @@
json.put("bundleLocation", location);
}
- private boolean applyConfiguration(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
+ private boolean applyConfiguration(HttpServletRequest request)
+ throws IOException {
ConfigurationAdmin ca = this.getConfigurationAdmin();
if (ca == null) {
@@ -321,11 +316,13 @@
if (props == null) {
props = new Hashtable<String, Object>();
}
- props.put("sling.context", request.getParameter("sling.context"));
+ props.put("sling.context",
+ request.getParameter("sling.context"));
config.update(props);
}
-// request.setAttribute(ATTR_REDIRECT_PARAMETERS, "pid=" + config.getPid());
+ // request.setAttribute(ATTR_REDIRECT_PARAMETERS, "pid=" +
+ // config.getPid());
return true;
}
@@ -350,7 +347,8 @@
props = new Hashtable<String, Object>();
}
- Map<String, AttributeDefinition> adMap = this.getAttributeDefinitionMap(config, null);
+ Map<String, AttributeDefinition> adMap = this.getAttributeDefinitionMap(
+ config, null);
if (adMap != null) {
StringTokenizer propTokens = new StringTokenizer(propertyList,
",");
@@ -398,7 +396,7 @@
config.update(props);
}
-// request.setAttribute(ATTR_REDIRECT_PARAMETERS, "pid=" + pid);
+ // request.setAttribute(ATTR_REDIRECT_PARAMETERS, "pid=" + pid);
return true;
}
Added: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ComponentConfigurationPrinter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ComponentConfigurationPrinter.java?rev=614204&view=auto
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ComponentConfigurationPrinter.java (added)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ComponentConfigurationPrinter.java Tue Jan 22 06:24:42 2008
@@ -0,0 +1,168 @@
+/*
+ * 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.sling.osgi.console.web.internal.compendium;
+
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Iterator;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.apache.felix.scr.Component;
+import org.apache.felix.scr.Reference;
+import org.apache.felix.scr.ScrService;
+import org.apache.sling.osgi.console.web.ConfigurationPrinter;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class ComponentConfigurationPrinter extends AbstractScrPlugin implements
+ ConfigurationPrinter {
+
+ private ServiceRegistration registration;
+
+ @Override
+ public void setBundleContext(BundleContext bundleContext) {
+ super.setBundleContext(bundleContext);
+
+ registration = bundleContext.registerService(
+ ConfigurationPrinter.SERVICE, this, null);
+ }
+
+ public String getTitle() {
+ return "Declarative Services Components";
+ }
+
+ public void printConfiguration(PrintWriter pw) {
+ ScrService scrService = getScrService();
+ if (scrService != null) {
+ Component[] components = scrService.getComponents();
+
+ if (components == null || components.length == 0) {
+
+ pw.println(" No Components Registered");
+
+ } else {
+
+ // order components by id
+ TreeMap<Long, Component> componentMap = new TreeMap<Long, Component>();
+ for (Component component : components) {
+ componentMap.put(component.getId(), component);
+ }
+
+ // render components
+ for (Component component : componentMap.values()) {
+ component(pw, component);
+ }
+ }
+ } else {
+ pw.println(" Apache Felix Declarative Service not installed");
+ }
+ }
+
+ private void component(PrintWriter pw, Component component) {
+
+ pw.print(component.getId());
+ pw.print("=[");
+ pw.print(component.getName());
+ pw.println("]");
+
+ pw.println(" Bundle" + component.getBundle().getSymbolicName() + " ("
+ + component.getBundle().getBundleId() + ")");
+ pw.println(" State="
+ + ComponentRenderAction.toStateString(component.getState()));
+ pw.println(" DefaultState="
+ + (component.isDefaultEnabled() ? "enabled" : "disabled"));
+ pw.println(" Activation="
+ + (component.isImmediate() ? "immediate" : "delayed"));
+
+ listServices(pw, component);
+ listReferences(pw, component);
+ listProperties(pw, component);
+
+ pw.println();
+ }
+
+ private void listServices(PrintWriter pw, Component component) {
+ String[] services = component.getServices();
+ if (services == null) {
+ return;
+ }
+
+ pw.println(" ServiceType="
+ + (component.isServiceFactory() ? "service factory" : "service"));
+
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < services.length; i++) {
+ if (i > 0) {
+ buf.append(", ");
+ }
+ buf.append(services[i]);
+ }
+
+ pw.println(" Services=" + buf);
+ }
+
+ private void listReferences(PrintWriter pw, Component component) {
+ Reference[] refs = component.getReferences();
+ if (refs != null) {
+ for (int i = 0; i < refs.length; i++) {
+
+ pw.println(" Reference=" + refs[i].getName() + ", "
+ + (refs[i].isSatisfied() ? "Satisfied" : "Unsatisfied"));
+
+ pw.println(" Service Name: " + refs[i].getServiceName());
+
+ if (refs[i].getTarget() != null) {
+ pw.println(" Target Filter: " + refs[i].getTarget());
+ }
+
+ pw.println(" Multiple: "
+ + (refs[i].isMultiple() ? "multiple" : "single"));
+ pw.println(" Optional: "
+ + (refs[i].isOptional() ? "optional" : "mandatory"));
+ pw.println(" Policy: "
+ + (refs[i].isStatic() ? "static" : "dynamic"));
+
+ }
+ }
+ }
+
+ private void listProperties(PrintWriter pw, Component component) {
+ @SuppressWarnings("unchecked")
+ Dictionary<String, Object> props = component.getProperties();
+ if (props != null) {
+
+ pw.println(" Properties=");
+ TreeSet<String> keys = new TreeSet<String>(
+ Collections.list(props.keys()));
+ for (Iterator<String> ki = keys.iterator(); ki.hasNext();) {
+ String key = ki.next();
+ Object value = props.get(key);
+ if (value.getClass().isArray()) {
+ value = Arrays.asList((Object[]) value);
+ }
+ pw.println(" " + key + "=" + value);
+ }
+ }
+
+ }
+
+}
Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ComponentRenderAction.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ComponentRenderAction.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ComponentRenderAction.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ComponentRenderAction.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ComponentRenderAction.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ComponentRenderAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ComponentRenderAction.java Tue Jan 22 06:24:42 2008
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.compendium;
import java.io.IOException;
import java.io.PrintWriter;
@@ -25,7 +25,6 @@
import java.util.TreeMap;
import java.util.TreeSet;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -37,15 +36,10 @@
import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.osgi.console.web.Action;
import org.apache.sling.osgi.console.web.Render;
-import org.osgi.service.log.LogService;
+import org.apache.sling.osgi.console.web.internal.Util;
-/**
- * The <code>ComponentRenderAction</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.service
- */
-public class ComponentRenderAction implements Render, Action {
+public class ComponentRenderAction extends AbstractScrPlugin implements Render,
+ Action {
public static final String NAME = "components";
@@ -61,12 +55,6 @@
public static final String OPERATION_DISABLE = "disable";
- /** @scr.reference */
- private ScrService scrService;
-
- /** @scr.reference */
- private LogService log;
-
public String getName() {
return NAME;
}
@@ -76,19 +64,25 @@
}
public boolean performAction(HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
- long componentId = getComponentId(request);
- Component component = scrService.getComponent(componentId);
-
- if (component != null) {
- String op = request.getParameter(OPERATION);
- if (OPERATION_DETAILS.equals(op)) {
- return sendAjaxDetails(component, response);
- } else if (OPERATION_ENABLE.equals(op)) {
- component.enable();
- } else if (OPERATION_DISABLE.equals(op)) {
- component.disable();
+ HttpServletResponse response) throws IOException {
+
+ ScrService scrService = getScrService();
+ if (scrService != null) {
+
+ long componentId = getComponentId(request);
+ Component component = scrService.getComponent(componentId);
+
+ if (component != null) {
+ String op = request.getParameter(OPERATION);
+ if (OPERATION_DETAILS.equals(op)) {
+ return sendAjaxDetails(component, response);
+ } else if (OPERATION_ENABLE.equals(op)) {
+ component.enable();
+ } else if (OPERATION_DISABLE.equals(op)) {
+ component.disable();
+ }
}
+
}
return true;
@@ -107,38 +101,46 @@
this.tableHeader(pw);
- Component[] components = scrService.getComponents();
- if (components == null || components.length == 0) {
+ ScrService scrService = getScrService();
+ if (scrService == null) {
pw.println("<tr class='content'>");
- pw.println("<td class='content' colspan='5'>No " + this.getLabel()
- + " installed currently</td>");
+ pw.println("<td class='content' colspan='5'>Apache Felix Declarative Service required for this function</td>");
pw.println("</tr>");
-
} else {
+ Component[] components = scrService.getComponents();
+ if (components == null || components.length == 0) {
+ pw.println("<tr class='content'>");
+ pw.println("<td class='content' colspan='5'>No "
+ + this.getLabel() + " installed currently</td>");
+ pw.println("</tr>");
+
+ } else {
+
+ // order components by id
+ TreeMap<String, Component> componentMap = new TreeMap<String, Component>();
+ for (Component component : components) {
+ componentMap.put(component.getName(), component);
+ }
- // order components by id
- TreeMap<String, Component> componentMap = new TreeMap<String, Component>();
- for (Component component : components) {
- componentMap.put(component.getName(), component);
- }
+ // render components
+ long previousComponent = -1;
+ for (Component component : componentMap.values()) {
+ if (previousComponent >= 0) {
+ // prepare for injected table information row
+ pw.println("<tr id='component" + previousComponent
+ + "'></tr>");
+ }
+
+ component(pw, component);
+
+ previousComponent = component.getId();
+ }
- // render components
- long previousComponent = -1;
- for (Component component : componentMap.values()) {
if (previousComponent >= 0) {
// prepare for injected table information row
pw.println("<tr id='component" + previousComponent
+ "'></tr>");
}
-
- component(pw, component);
-
- previousComponent = component.getId();
- }
-
- if (previousComponent >= 0) {
- // prepare for injected table information row
- pw.println("<tr id='component" + previousComponent + "'></tr>");
}
}
@@ -237,7 +239,7 @@
}
private boolean sendAjaxDetails(Component component,
- HttpServletResponse response) throws IOException, ServletException {
+ HttpServletResponse response) throws IOException {
JSONObject result = null;
try {
if (component != null) {
@@ -326,7 +328,8 @@
Dictionary<String, Object> props = component.getProperties();
if (props != null) {
StringBuffer buf = new StringBuffer();
- TreeSet<String> keys = new TreeSet<String>(Collections.list(props.keys()));
+ TreeSet<String> keys = new TreeSet<String>(
+ Collections.list(props.keys()));
for (Iterator<String> ki = keys.iterator(); ki.hasNext();) {
String key = ki.next();
buf.append(key).append(" = ");
@@ -358,7 +361,7 @@
}
}
- private String toStateString(int state) {
+ static String toStateString(int state) {
switch (state) {
case Component.STATE_DISABLED:
return "disabled";
@@ -395,10 +398,6 @@
// no bundleId or wrong format
return -1;
- }
-
- protected void log(String message, Throwable t) {
- log.log(LogService.LOG_ERROR, message, t);
}
}
Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ConfigManager.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigManager.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ConfigManager.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ConfigManager.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigManager.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigManager.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ConfigManager.java Tue Jan 22 06:24:42 2008
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.compendium;
import java.io.IOException;
import java.io.PrintWriter;
@@ -29,6 +29,8 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.sling.osgi.console.web.Render;
+import org.apache.sling.osgi.console.web.internal.Util;
+import org.apache.sling.osgi.console.web.internal.core.SetStartLevelAction;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
@@ -39,11 +41,6 @@
/**
* The <code>ConfigManager</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.reference interface="org.osgi.service.cm.ConfigurationAdmin" name="configurationAdmin"
- * @scr.reference interface="org.osgi.service.metatype.MetaTypeService" name="metaTypeService"
- * @scr.service
*/
public class ConfigManager extends ConfigManagerBase implements Render {
Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ConfigManagerBase.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigManagerBase.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ConfigManagerBase.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ConfigManagerBase.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigManagerBase.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/ConfigManagerBase.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/compendium/ConfigManagerBase.java Tue Jan 22 06:24:42 2008
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.compendium;
import java.util.HashMap;
import java.util.Locale;
@@ -22,39 +22,51 @@
import javax.servlet.http.HttpServletRequest;
+import org.apache.sling.osgi.console.web.internal.BaseManagementPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.component.ComponentContext;
import org.osgi.service.metatype.AttributeDefinition;
import org.osgi.service.metatype.MetaTypeInformation;
import org.osgi.service.metatype.MetaTypeService;
import org.osgi.service.metatype.ObjectClassDefinition;
+import org.osgi.util.tracker.ServiceTracker;
/**
* The <code>ConfigManagerBase</code> TODO
+ *
*/
-abstract class ConfigManagerBase {
+abstract class ConfigManagerBase extends BaseManagementPlugin {
- private BundleContext bundleContext;
+ private ServiceTracker configurationAdmin;
- /** @scr.reference */
- private ConfigurationAdmin configurationAdmin;
+ private ServiceTracker metaTypeService;
- /** @scr.reference */
- private MetaTypeService metaTypeService;
-
- protected BundleContext getBundleContext() {
- return this.bundleContext;
+ public void setBundleContext(BundleContext bundleContext) {
+ super.setBundleContext(bundleContext);
+
+ configurationAdmin = new ServiceTracker(bundleContext, ConfigurationAdmin.class.getName(), null);
+ configurationAdmin.open();
+ metaTypeService = new ServiceTracker(bundleContext, MetaTypeService.class.getName(), null);
+ metaTypeService.open();
}
-
+
+ public void destroy() {
+ if (configurationAdmin != null) {
+ configurationAdmin.close();
+ }
+ if (metaTypeService != null) {
+ metaTypeService.close();
+ }
+ }
+
protected ConfigurationAdmin getConfigurationAdmin() {
- return this.configurationAdmin;
+ return (ConfigurationAdmin) configurationAdmin.getService();
}
protected MetaTypeService getMetaTypeService() {
- return this.metaTypeService;
+ return (MetaTypeService) metaTypeService.getService();
}
protected Map<String, Bundle> getMetadataPids() {
@@ -62,7 +74,7 @@
MetaTypeService mts = this.getMetaTypeService();
if (mts != null) {
Bundle[] bundles = this.getBundleContext().getBundles();
- for (int i=0; i < bundles.length; i++) {
+ for (int i = 0; i < bundles.length; i++) {
MetaTypeInformation mti = mts.getMetaTypeInformation(bundles[i]);
if (mti != null) {
String[] pidList = mti.getPids();
@@ -80,14 +92,16 @@
// if the configuration is not bound, search in the bundles
if (config.getBundleLocation() == null) {
- ObjectClassDefinition ocd = this.getObjectClassDefinition(config.getPid(), locale);
+ ObjectClassDefinition ocd = this.getObjectClassDefinition(
+ config.getPid(), locale);
if (ocd != null) {
return ocd;
}
// if none, check whether there might be one for the factory PID
if (config.getFactoryPid() != null) {
- return this.getObjectClassDefinition(config.getFactoryPid(), locale);
+ return this.getObjectClassDefinition(config.getFactoryPid(),
+ locale);
}
}
@@ -98,14 +112,17 @@
MetaTypeInformation mti = mts.getMetaTypeInformation(bundle);
if (mti != null) {
// try OCD by PID first
- ObjectClassDefinition ocd = mti.getObjectClassDefinition(config.getPid(), locale);
+ ObjectClassDefinition ocd = mti.getObjectClassDefinition(
+ config.getPid(), locale);
if (ocd != null) {
return ocd;
}
- // if none, check whether there might be one for the factory PID
+ // if none, check whether there might be one for the factory
+ // PID
if (config.getFactoryPid() != null) {
- return mti.getObjectClassDefinition(config.getFactoryPid(), locale);
+ return mti.getObjectClassDefinition(
+ config.getFactoryPid(), locale);
}
}
}
@@ -131,11 +148,13 @@
return null;
}
- protected ObjectClassDefinition getObjectClassDefinition(String pid, String locale) {
+ protected ObjectClassDefinition getObjectClassDefinition(String pid,
+ String locale) {
Bundle[] bundles = this.getBundleContext().getBundles();
- for (int i=0; i < bundles.length; i++) {
+ for (int i = 0; i < bundles.length; i++) {
try {
- ObjectClassDefinition ocd = this.getObjectClassDefinition(bundles[i], pid, locale);
+ ObjectClassDefinition ocd = this.getObjectClassDefinition(
+ bundles[i], pid, locale);
if (ocd != null) {
return ocd;
}
@@ -146,8 +165,10 @@
return null;
}
- protected Map<String, AttributeDefinition> getAttributeDefinitionMap(Configuration config, String locale) {
- ObjectClassDefinition ocd = this.getObjectClassDefinition(config, locale);
+ protected Map<String, AttributeDefinition> getAttributeDefinitionMap(
+ Configuration config, String locale) {
+ ObjectClassDefinition ocd = this.getObjectClassDefinition(config,
+ locale);
if (ocd != null) {
AttributeDefinition[] ad = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
if (ad != null) {
@@ -188,29 +209,4 @@
}
}
- //--------- SCR Integration -----------------------------------------------
-
- protected void activate(ComponentContext context) {
- this.bundleContext = context.getBundleContext();
- }
-
- protected void deactivate(ComponentContext context) {
- this.bundleContext = null;
- }
-
- protected void bindConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
- this.configurationAdmin = configurationAdmin;
- }
-
- protected void unbindConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
- this.configurationAdmin = null;
- }
-
- protected void bindMetaTypeService(MetaTypeService metaTypeService) {
- this.metaTypeService = metaTypeService;
- }
-
- protected void unbindMetaTypeService(MetaTypeService metaTypeService) {
- this.metaTypeService = null;
- }
}
Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxBundleDetailsAction.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxBundleDetailsAction.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/AjaxBundleDetailsAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/AjaxBundleDetailsAction.java Tue Jan 22 06:24:42 2008
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.core;
import java.io.IOException;
import java.util.ArrayList;
@@ -28,7 +28,6 @@
import java.util.StringTokenizer;
import java.util.TreeMap;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -40,32 +39,20 @@
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.component.ComponentConstants;
-import org.osgi.service.component.ComponentContext;
import org.osgi.service.packageadmin.ExportedPackage;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.service.startlevel.StartLevel;
-/**
- * The <code>AjaxBundleDetailsAction</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.service
- */
public class AjaxBundleDetailsAction extends BundleAction {
public static final String NAME = "ajaxBundleDetails";
- /** @scr.reference */
- private StartLevel startLevelService;
-
- /** @scr.reference */
- private PackageAdmin packageAdmin;
-
// bootdelegation property entries. wildcards are converted to package
// name prefixes. whether an entry is a wildcard or not is set as a flag
// in the bootPkgWildcards array.
@@ -77,6 +64,28 @@
// see #activate and #isBootDelegated
private boolean[] bootPkgWildcards;
+ @Override
+ public void setBundleContext(BundleContext bundleContext) {
+ super.setBundleContext(bundleContext);
+
+ // bootdelegation property parsing from Apache Felix R4SearchPolicyCore
+ String bootDelegation = bundleContext.getProperty(Constants.FRAMEWORK_BOOTDELEGATION);
+ bootDelegation = (bootDelegation == null) ? "java.*" : bootDelegation
+ + ",java.*";
+ StringTokenizer st = new StringTokenizer(bootDelegation, " ,");
+ bootPkgs = new String[st.countTokens()];
+ bootPkgWildcards = new boolean[bootPkgs.length];
+ for (int i = 0; i < bootPkgs.length; i++) {
+ bootDelegation = st.nextToken();
+ if (bootDelegation.endsWith("*")) {
+ bootPkgWildcards[i] = true;
+ bootDelegation = bootDelegation.substring(0,
+ bootDelegation.length() - 1);
+ }
+ bootPkgs[i] = bootDelegation;
+ }
+ }
+
public String getName() {
return NAME;
}
@@ -91,7 +100,7 @@
* @see org.apache.sling.manager.web.internal.Action#performAction(javax.servlet.http.HttpServletRequest)
*/
public boolean performAction(HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
+ HttpServletResponse response) throws IOException {
JSONObject result = null;
try {
long bundleId = getBundleId(request);
@@ -140,14 +149,16 @@
}
private Integer getStartLevel(Bundle bundle) {
- if (startLevelService == null) {
- return null;
- }
-
- return new Integer(startLevelService.getBundleStartLevel(bundle));
+ StartLevel sl = getStartLevel();
+ return (sl != null) ? sl.getBundleStartLevel(bundle) : null;
}
private void listImportExport(JSONArray props, Bundle bundle) {
+ PackageAdmin packageAdmin = getPackageAdmin();
+ if (packageAdmin == null) {
+ return;
+ }
+
ExportedPackage[] exports = packageAdmin.getExportedPackages(bundle);
if (exports != null && exports.length > 0) {
// do alphabetical sort
@@ -240,15 +251,18 @@
// collect import packages first
final Map<String, ExportedPackage> candidates = new HashMap<String, ExportedPackage>();
- ExportedPackage[] exports = packageAdmin.getExportedPackages((Bundle) null);
- if (exports != null && exports.length > 0) {
-
- for (int i = 0; i < exports.length; i++) {
- final ExportedPackage ep = exports[i];
-
- R4Import imp = imports.get(ep.getName());
- if (imp != null && imp.isSatisfied(toR4Export(ep))) {
- candidates.put(ep.getName(), ep);
+ PackageAdmin packageAdmin = getPackageAdmin();
+ if (packageAdmin != null) {
+ ExportedPackage[] exports = packageAdmin.getExportedPackages((Bundle) null);
+ if (exports != null && exports.length > 0) {
+
+ for (int i = 0; i < exports.length; i++) {
+ final ExportedPackage ep = exports[i];
+
+ R4Import imp = imports.get(ep.getName());
+ if (imp != null && imp.isSatisfied(toR4Export(ep))) {
+ candidates.put(ep.getName(), ep);
+ }
}
}
}
@@ -442,29 +456,4 @@
new R4Attribute[] { version });
}
- // ---------- SCR integration ----------------------------------------------
-
- protected void activate(ComponentContext context) {
-
- super.activate(context);
-
- // bootdelegation property parsing from Apache Felix R4SearchPolicyCore
- String bootDelegation = context.getBundleContext().getProperty(
- Constants.FRAMEWORK_BOOTDELEGATION);
- bootDelegation = (bootDelegation == null) ? "java.*" : bootDelegation
- + ",java.*";
- StringTokenizer st = new StringTokenizer(bootDelegation, " ,");
- bootPkgs = new String[st.countTokens()];
- bootPkgWildcards = new boolean[bootPkgs.length];
- for (int i = 0; i < bootPkgs.length; i++) {
- bootDelegation = st.nextToken();
- if (bootDelegation.endsWith("*")) {
- bootPkgWildcards[i] = true;
- bootDelegation = bootDelegation.substring(0,
- bootDelegation.length() - 1);
- }
- bootPkgs[i] = bootDelegation;
- }
-
- }
}
Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/BundleAction.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleAction.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/BundleAction.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/BundleAction.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleAction.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/BundleAction.java Tue Jan 22 06:24:42 2008
@@ -14,30 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.core;
import javax.servlet.http.HttpServletRequest;
import org.apache.sling.osgi.console.web.Action;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.log.LogService;
-
-/**
- * The <code>BundleAction</code> TODO
- *
- * @scr.reference name="log" interface="org.osgi.service.log.LogService"
- */
-abstract class BundleAction implements Action {
+import org.apache.sling.osgi.console.web.internal.BaseManagementPlugin;
- private BundleContext bundleContext;
-
- private LogService log;
-
- protected BundleContext getBundleContext() {
- return this.bundleContext;
- }
+abstract class BundleAction extends BaseManagementPlugin implements Action {
protected long getBundleId(HttpServletRequest request) {
String bundleIdPar = request.getParameter(BundleListRender.BUNDLE_ID);
@@ -53,25 +37,4 @@
return -1;
}
- protected void log(Bundle bundle, String message, Throwable t) {
- this.log.log(LogService.LOG_ERROR, message, t);
- }
-
- //--------- SCR Integration -----------------------------------------------
-
- protected void activate(ComponentContext context) {
- this.bundleContext = context.getBundleContext();
- }
-
- protected void deactivate(ComponentContext context) {
- this.bundleContext = null;
- }
-
- protected void bindLog(LogService logService) {
- this.log = logService;
- }
-
- protected void unbindLog(LogService logService) {
- this.log = null;
- }
}
Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/BundleListRender.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleListRender.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/BundleListRender.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/BundleListRender.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleListRender.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/BundleListRender.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/BundleListRender.java Tue Jan 22 06:24:42 2008
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.core;
import java.io.IOException;
import java.io.PrintWriter;
@@ -29,22 +29,18 @@
import org.apache.sling.osgi.assembly.installer.InstallerService;
import org.apache.sling.osgi.assembly.installer.Resource;
import org.apache.sling.osgi.console.web.Render;
+import org.apache.sling.osgi.console.web.internal.BaseManagementPlugin;
+import org.apache.sling.osgi.console.web.internal.Util;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.startlevel.StartLevel;
+import org.osgi.util.tracker.ServiceTracker;
/**
* The <code>BundleListRender</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.reference name="installerService"
- * interface="org.apache.sling.osgi.assembly.installer.InstallerService"
- * @scr.service
*/
-public class BundleListRender implements Render {
+public class BundleListRender extends BaseManagementPlugin implements Render {
public static final String NAME = "list";
@@ -52,12 +48,25 @@
public static final String BUNDLE_ID = "bundleId";
- private BundleContext bundleContext;
+ private static final String INSTALLER_SERVICE_NAME = "org.apache.sling.osgi.assembly.installer.InstallerService";
- /** @scr.reference */
- private StartLevel startLevel;
+ // track the optional installer service manually
+ private ServiceTracker installerService;
- private BundleRepositoryAdmin repoAdmin;
+ public void setBundleContext(BundleContext bundleContext) {
+ super.setBundleContext(bundleContext);
+
+ installerService = new ServiceTracker(bundleContext,
+ INSTALLER_SERVICE_NAME, null);
+ installerService.open();
+ }
+
+ // protected void deactivate(ComponentContext context) {
+ // if (installerService != null) {
+ // installerService.close();
+ // installerService = null;
+ // }
+ // }
/*
* (non-Javadoc)
@@ -135,16 +144,8 @@
this.footer(pw);
}
- protected BundleContext getBundleContext() {
- return this.bundleContext;
- }
-
- protected StartLevel getStartLevelService() {
- return this.startLevel;
- }
-
protected Bundle[] getBundles() {
- return this.bundleContext.getBundles();
+ return getBundleContext().getBundles();
}
private void header(PrintWriter pw) {
@@ -253,7 +254,7 @@
}
private void installForm(PrintWriter pw) {
- int startLevel = this.getStartLevelService().getInitialBundleStartLevel();
+ int startLevel = getStartLevel().getInitialBundleStartLevel();
pw.println("<form method='post' enctype='multipart/form-data'>");
pw.println("<tr class='content'>");
@@ -306,6 +307,12 @@
private boolean hasUpdates(Bundle bundle) {
+ // no updates if there is no installer service
+ Object isObject = installerService.getService();
+ if (isObject == null) {
+ return false;
+ }
+
// don't care for bundles with no symbolic name
if (bundle.getSymbolicName() == null) {
return false;
@@ -314,7 +321,8 @@
Version bundleVersion = Version.parseVersion((String) bundle.getHeaders().get(
Constants.BUNDLE_VERSION));
- for (Iterator<Resource> ri = this.repoAdmin.getResources(); ri.hasNext();) {
+ BundleRepositoryAdmin repoAdmin = ((InstallerService) isObject).getBundleRepositoryAdmin();
+ for (Iterator<Resource> ri = repoAdmin.getResources(); ri.hasNext();) {
Resource res = ri.next();
if (bundle.getSymbolicName().equals(res.getSymbolicName())) {
if (res.getVersion().compareTo(bundleVersion) > 0) {
@@ -343,32 +351,6 @@
}
return name;
}
-
- // --------- SCR Integration -----------------------------------------------
-
- protected void activate(ComponentContext context) {
- this.bundleContext = context.getBundleContext();
- }
-
- protected void deactivate(ComponentContext context) {
- this.bundleContext = null;
- }
-
- protected void bindInstallerService(InstallerService installerService) {
- this.repoAdmin = installerService.getBundleRepositoryAdmin();
- }
-
- protected void unbindInstallerService(InstallerService installerService) {
- this.repoAdmin = null;
- }
-
- protected void bindStartLevel(StartLevel startLevel) {
- this.startLevel = startLevel;
- }
-
- protected void unbindStartLevel(StartLevel startLevel) {
- this.startLevel = null;
- }
// ---------- inner classes ------------------------------------------------
@@ -386,7 +368,7 @@
} else if (b2.getBundleId() == 0) {
return 1;
}
-
+
// compare the symbolic names
int snComp = getName(b1).compareToIgnoreCase(getName(b2));
if (snComp != 0) {
@@ -402,7 +384,7 @@
if (vComp != 0) {
return vComp;
}
-
+
// same version ? Not really, but then, we compare by bundle id
if (b1.getBundleId() < b2.getBundleId()) {
return -1;
Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/InstallAction.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/InstallAction.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/InstallAction.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/InstallAction.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/InstallAction.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/InstallAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/InstallAction.java Tue Jan 22 06:24:42 2008
@@ -14,33 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.core;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import java.util.Map;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
-import org.apache.sling.osgi.assembly.installer.Installer;
-import org.apache.sling.osgi.assembly.installer.InstallerService;
+import org.apache.sling.osgi.console.web.internal.Util;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
+import org.osgi.service.log.LogService;
+import org.osgi.service.startlevel.StartLevel;
/**
* The <code>InstallAction</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.service
*/
public class InstallAction extends BundleAction {
@@ -54,9 +50,6 @@
public static final String FIELD_BUNDLEFILE = "bundlefile";
- /** @scr.reference */
- private InstallerService installerService;
-
public String getName() {
return NAME;
}
@@ -67,11 +60,11 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.sling.manager.web.internal.Action#performAction(javax.servlet.http.HttpServletRequest)
*/
public boolean performAction(HttpServletRequest request,
- HttpServletResponse response) throws ServletException {
+ HttpServletResponse response) {
// get the uploaded data
@SuppressWarnings("unchecked")
@@ -81,7 +74,8 @@
}
FileItem startItem = this.getFileItem(params, FIELD_START, true);
- FileItem startLevelItem = this.getFileItem(params, FIELD_STARTLEVEL, true);
+ FileItem startLevelItem = this.getFileItem(params, FIELD_STARTLEVEL,
+ true);
FileItem bundleItem = this.getFileItem(params, FIELD_BUNDLEFILE, false);
// don't care any more if not bundle item
@@ -114,7 +108,8 @@
this.installBundle(bundleLocation, tmpFile, startLevel, start);
} catch (Exception e) {
- this.log(null, "Problem accessing uploaded bundle file", e);
+ getLog().log(LogService.LOG_ERROR,
+ "Problem accessing uploaded bundle file", e);
} finally {
if (tmpFile != null) {
tmpFile.delete();
@@ -124,7 +119,8 @@
return true;
}
- private FileItem getFileItem(Map<String, FileItem[]> params, String name, boolean isFormField) {
+ private FileItem getFileItem(Map<String, FileItem[]> params, String name,
+ boolean isFormField) {
FileItem[] items = params.get(name);
if (items != null) {
for (int i = 0; i < items.length; i++) {
@@ -138,8 +134,8 @@
return null;
}
- private void installBundle(String location, File bundleFile, int startLevel,
- boolean start) {
+ private void installBundle(String location, File bundleFile,
+ int startLevel, boolean start) {
if (bundleFile != null) {
// try to get the bundle name, fail if none
@@ -161,26 +157,22 @@
}
}
- Installer installer = this.installerService.getInstaller();
try {
// stream will be closed by update or installBundle
InputStream bundleStream = new FileInputStream(bundleFile);
if (newBundle != null) {
// update existing bundle, to not set startlevel or start
- this.updateBackground(newBundle, bundleFile, bundleStream);
+ updateBackground(newBundle, bundleFile, bundleStream);
} else {
- // non-existing bundle is installed
- URL source = bundleFile.toURI().toURL();
- installer.addBundle(location, source, startLevel);
- installer.install(start);
+
+ installBackground(bundleFile, location, startLevel, start);
+
}
} catch (Throwable t) {
- this.log(null, "Failed to install bundle " + symbolicName
+ getLog().log(LogService.LOG_ERROR, "Failed to install bundle " + symbolicName
+ " (Location:" + location + ")", t);
- } finally {
- installer.dispose();
}
}
}
@@ -210,8 +202,10 @@
return null;
}
- private void updateBackground(final Bundle bundle, final File bundleFile, final InputStream bundleStream) {
- Thread t = new Thread("Background Update") {
+ private void installBackground(final File bundleFile,
+ final String location, final int startlevel, final boolean doStart) {
+
+ Thread t = new Thread("Background Install " + bundleFile) {
public void run() {
// wait some time for the request to settle
try {
@@ -221,11 +215,31 @@
}
// now deploy the resolved bundles
+ InputStream fin = null;
try {
- bundle.update(bundleStream);
+ fin = new FileInputStream(bundleFile);
+ Bundle bundle = getBundleContext().installBundle(location,
+ fin);
+
+ StartLevel sl = getStartLevel();
+ if (sl != null) {
+ sl.setBundleStartLevel(bundle, startlevel);
+ }
+
+ if (doStart) {
+ bundle.start();
+ }
+ } catch (IOException ioe) {
+ // TODO: log
} catch (BundleException be) {
// TODO: log
} finally {
+ if (fin != null) {
+ try {
+ fin.close();
+ } catch (IOException ignore) {
+ }
+ }
bundleFile.delete();
}
}
@@ -235,11 +249,31 @@
t.start();
}
- protected void bindInstallerService(InstallerService installerService) {
- this.installerService = installerService;
- }
+ private void updateBackground(final Bundle bundle, final File bundleFile,
+ final InputStream bundleStream) {
+ Thread t = new Thread("Background Update" + bundle.getSymbolicName()
+ + " (" + bundle.getBundleId() + ")") {
+ public void run() {
+ // wait some time for the request to settle
+ try {
+ sleep(500L);
+ } catch (InterruptedException ie) {
+ // don't care
+ }
- protected void unbindInstallerService(InstallerService installerService) {
- this.installerService = null;
+ // now deploy the resolved bundles
+ try {
+ bundle.update(bundleStream);
+ } catch (BundleException be) {
+ // TODO: log
+ } finally {
+ bundleFile.delete();
+ }
+ }
+ };
+
+ t.setDaemon(true); // make a daemon thread (detach from current thread)
+ t.start();
}
+
}
Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/RefreshPackagesAction.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/RefreshPackagesAction.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/RefreshPackagesAction.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/RefreshPackagesAction.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/RefreshPackagesAction.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/RefreshPackagesAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/RefreshPackagesAction.java Tue Jan 22 06:24:42 2008
@@ -14,26 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.core;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.osgi.service.packageadmin.PackageAdmin;
-
/**
* The <code>RefreshPackagesAction</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.service
*/
public class RefreshPackagesAction extends BundleAction {
public static final String NAME = "refreshPackages";
- public static final String LABEL = "Refresh Packages";
- /** @scr.reference */
- private PackageAdmin packageAdmin;
+ public static final String LABEL = "Refresh Packages";
public String getName() {
return NAME;
@@ -43,22 +36,18 @@
return LABEL;
}
- /* (non-Javadoc)
- * @see org.apache.sling.manager.web.internal.Action#performAction(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.sling.manager.web.internal.Action#performAction(javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
*/
public boolean performAction(HttpServletRequest request,
HttpServletResponse response) {
- this.packageAdmin.refreshPackages(null);
+ getPackageAdmin().refreshPackages(null);
return true;
}
- protected void bindPackageAdmin(PackageAdmin packageAdmin) {
- this.packageAdmin = packageAdmin;
- }
-
- protected void unbindPackageAdmin(PackageAdmin packageAdmin) {
- this.packageAdmin = null;
- }
}
Copied: incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/SetStartLevelAction.java (from r613401, incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/SetStartLevelAction.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/SetStartLevelAction.java?p2=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/SetStartLevelAction.java&p1=incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/SetStartLevelAction.java&r1=613401&r2=614204&rev=614204&view=diff
==============================================================================
--- incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/SetStartLevelAction.java (original)
+++ incubator/sling/trunk/osgi/console-web/src/main/java/org/apache/sling/osgi/console/web/internal/core/SetStartLevelAction.java Tue Jan 22 06:24:42 2008
@@ -14,27 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.osgi.console.web.internal;
+package org.apache.sling.osgi.console.web.internal.core;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.sling.osgi.console.web.Action;
+import org.apache.sling.osgi.console.web.internal.BaseManagementPlugin;
import org.osgi.service.startlevel.StartLevel;
/**
- * The <code>GCAction</code> TODO
- *
- * @scr.component metatype="false"
- * @scr.service
+ * The <code>SetStartLevelAction</code> TODO
*/
-public class SetStartLevelAction implements Action {
+public class SetStartLevelAction extends BaseManagementPlugin implements Action {
public static final String NAME = "setStartLevel";
- public static final String LABEL = "Set Start Level";
- /** @scr.reference */
- private StartLevel startLevel;
+ public static final String LABEL = "Set Start Level";
public String getName() {
return NAME;
@@ -44,19 +40,25 @@
return LABEL;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.sling.manager.web.internal.Action#performAction(javax.servlet.http.HttpServletRequest)
*/
- public boolean performAction(HttpServletRequest request, HttpServletResponse response) {
-
- int bundleSL = this.getParameterInt(request, "bundleStartLevel");
- if (bundleSL > 0 && bundleSL != this.startLevel.getInitialBundleStartLevel()) {
- this.startLevel.setInitialBundleStartLevel(bundleSL);
- }
+ public boolean performAction(HttpServletRequest request,
+ HttpServletResponse response) {
- int systemSL = this.getParameterInt(request, "systemStartLevel");
- if (systemSL > 0 && systemSL != this.startLevel.getStartLevel()) {
- this.startLevel.setStartLevel(systemSL);
+ StartLevel sl = getStartLevel();
+ if (sl != null) {
+ int bundleSL = this.getParameterInt(request, "bundleStartLevel");
+ if (bundleSL > 0 && bundleSL != sl.getInitialBundleStartLevel()) {
+ sl.setInitialBundleStartLevel(bundleSL);
+ }
+
+ int systemSL = this.getParameterInt(request, "systemStartLevel");
+ if (systemSL > 0 && systemSL != sl.getStartLevel()) {
+ sl.setStartLevel(systemSL);
+ }
}
return true;
@@ -72,13 +74,4 @@
return -1;
}
- //--------- SCR -----------------------------------------------------------
-
- protected void bindStartLevel(StartLevel startLevel) {
- this.startLevel = startLevel;
- }
-
- protected void unbindStartLevel(StartLevel startLevel) {
- this.startLevel = null;
- }
}