You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2011/12/03 09:03:53 UTC
svn commit: r1209847 - in /karaf/trunk: ./ assemblies/features/framework/
assemblies/features/standard/src/main/feature/ management/mbeans/
management/mbeans/web/
management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/
management/mb...
Author: jbonofre
Date: Sat Dec 3 08:03:50 2011
New Revision: 1209847
URL: http://svn.apache.org/viewvc?rev=1209847&view=rev
Log:
[KARAF-963] Refactoring of the web service
Added:
karaf/trunk/web/
karaf/trunk/web/commands/
karaf/trunk/web/commands/NOTICE
- copied, changed from r1209838, karaf/trunk/management/mbeans/web/NOTICE
karaf/trunk/web/commands/pom.xml
- copied, changed from r1209838, karaf/trunk/management/mbeans/web/pom.xml
karaf/trunk/web/commands/src/
karaf/trunk/web/commands/src/main/
karaf/trunk/web/commands/src/main/java/
karaf/trunk/web/commands/src/main/java/org/
karaf/trunk/web/commands/src/main/java/org/apache/
karaf/trunk/web/commands/src/main/java/org/apache/karaf/
karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/
karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/
karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/List.java
karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/Start.java
- copied, changed from r1209838, karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebUnDeploymentCommand.java
karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/Stop.java
- copied, changed from r1209838, karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebDeploymentCommand.java
karaf/trunk/web/commands/src/main/resources/
karaf/trunk/web/commands/src/main/resources/OSGI-INF/
karaf/trunk/web/commands/src/main/resources/OSGI-INF/blueprint/
karaf/trunk/web/commands/src/main/resources/OSGI-INF/blueprint/web-commands.xml
karaf/trunk/web/commands/src/main/resources/OSGI-INF/bundle.info
karaf/trunk/web/core/
karaf/trunk/web/core/NOTICE
- copied, changed from r1209838, karaf/trunk/shell/web/NOTICE
karaf/trunk/web/core/pom.xml
- copied, changed from r1209838, karaf/trunk/shell/web/pom.xml
karaf/trunk/web/core/src/
karaf/trunk/web/core/src/main/
karaf/trunk/web/core/src/main/java/
karaf/trunk/web/core/src/main/java/org/
karaf/trunk/web/core/src/main/java/org/apache/
karaf/trunk/web/core/src/main/java/org/apache/karaf/
karaf/trunk/web/core/src/main/java/org/apache/karaf/web/
karaf/trunk/web/core/src/main/java/org/apache/karaf/web/WebBundle.java
karaf/trunk/web/core/src/main/java/org/apache/karaf/web/WebContainerService.java
karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/
karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java
karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java
- copied, changed from r1209838, karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebEventHandler.java
karaf/trunk/web/core/src/main/resources/
karaf/trunk/web/core/src/main/resources/OSGI-INF/
karaf/trunk/web/core/src/main/resources/OSGI-INF/blueprint/
karaf/trunk/web/core/src/main/resources/OSGI-INF/blueprint/web-core.xml
karaf/trunk/web/core/src/main/resources/OSGI-INF/bundle.info
karaf/trunk/web/management/
karaf/trunk/web/management/NOTICE
- copied, changed from r1209838, karaf/trunk/management/mbeans/web/NOTICE
karaf/trunk/web/management/pom.xml
- copied, changed from r1209838, karaf/trunk/management/mbeans/web/pom.xml
karaf/trunk/web/management/src/
karaf/trunk/web/management/src/main/
karaf/trunk/web/management/src/main/java/
karaf/trunk/web/management/src/main/java/org/
karaf/trunk/web/management/src/main/java/org/apache/
karaf/trunk/web/management/src/main/java/org/apache/karaf/
karaf/trunk/web/management/src/main/java/org/apache/karaf/web/
karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/
karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/WebMBean.java
- copied, changed from r1209838, karaf/trunk/management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/WebMBean.java
karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/internal/
karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java
- copied, changed from r1209838, karaf/trunk/management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/internal/WebMBeanImpl.java
karaf/trunk/web/management/src/main/resources/
karaf/trunk/web/management/src/main/resources/OSGI-INF/
karaf/trunk/web/management/src/main/resources/OSGI-INF/blueprint/
karaf/trunk/web/management/src/main/resources/OSGI-INF/blueprint/web-management.xml
karaf/trunk/web/management/src/main/resources/OSGI-INF/bundle.info
- copied, changed from r1209838, karaf/trunk/management/mbeans/web/src/main/resources/OSGI-INF/bundle.info
karaf/trunk/web/pom.xml
- copied, changed from r1209838, karaf/trunk/shell/pom.xml
Removed:
karaf/trunk/management/mbeans/web/NOTICE
karaf/trunk/management/mbeans/web/pom.xml
karaf/trunk/management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/WebMBean.java
karaf/trunk/management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/internal/WebMBeanImpl.java
karaf/trunk/management/mbeans/web/src/main/resources/OSGI-INF/blueprint/web-management.xml
karaf/trunk/management/mbeans/web/src/main/resources/OSGI-INF/bundle.info
karaf/trunk/shell/web/NOTICE
karaf/trunk/shell/web/pom.xml
karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebDeploymentCommand.java
karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebEventHandler.java
karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebListCommand.java
karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebManagerCommand.java
karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebUnDeploymentCommand.java
karaf/trunk/shell/web/src/main/resources/OSGI-INF/blueprint/shell-web.xml
karaf/trunk/shell/web/src/main/resources/OSGI-INF/bundle.info
Modified:
karaf/trunk/assemblies/features/framework/pom.xml
karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml
karaf/trunk/management/mbeans/pom.xml
karaf/trunk/manual/pom.xml
karaf/trunk/manual/src/main/webapp/users-guide/deployer.conf
karaf/trunk/pom.xml
karaf/trunk/shell/pom.xml
Modified: karaf/trunk/assemblies/features/framework/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/framework/pom.xml?rev=1209847&r1=1209846&r2=1209847&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/framework/pom.xml (original)
+++ karaf/trunk/assemblies/features/framework/pom.xml Sat Dec 3 08:03:50 2011
@@ -235,16 +235,6 @@
<artifactId>org.apache.servicemix.bundles.asm</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-jexl</artifactId>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>region</artifactId>
<version>1.0.0.v20110506</version>
Modified: karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml?rev=1209847&r1=1209846&r2=1209847&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml (original)
+++ karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml Sat Dec 3 08:03:50 2011
@@ -93,11 +93,12 @@
org.ops4j.pax.url.war.importPaxLoggingPackages=true
</config>
<feature>http-whiteboard</feature>
- <bundle start-level="30">mvn:org.apache.karaf.shell/org.apache.karaf.shell.web/${project.version}</bundle>
- <bundle start-level="30">mvn:org.apache.karaf.management.mbeans/org.apache.karaf.management.mbeans.web/${project.version}</bundle>
<bundle start-level="30">mvn:org.ops4j.pax.web/pax-web-extender-war/${pax.web.version}</bundle>
<bundle start-level="30">mvn:org.ops4j.pax.web/pax-web-deployer/${pax.web.version}</bundle>
<bundle start-level="30">mvn:org.ops4j.pax.url/pax-url-war/${pax.url.version}</bundle>
+ <bundle start-level="30">mvn:org.apache.karaf.web/org.apache.karaf.web.core/${project.version}</bundle>
+ <bundle start-level="30">mvn:org.apache.karaf.web/org.apache.karaf.web.commands/${project.version}</bundle>
+ <bundle start-level="30">mvn:org.apache.karaf.web/org.apache.karaf.web.management/${project.version}</bundle>
</feature>
<feature name="kar" description="Provide KAR (Karaf Archive) artifacts support" version="${project.version}" resolver="(obr)">
Modified: karaf/trunk/management/mbeans/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/management/mbeans/pom.xml?rev=1209847&r1=1209846&r2=1209847&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/pom.xml (original)
+++ karaf/trunk/management/mbeans/pom.xml Sat Dec 3 08:03:50 2011
@@ -42,7 +42,6 @@
<module>http</module>
<module>log</module>
<module>obr</module>
- <module>web</module>
</modules>
</project>
\ No newline at end of file
Modified: karaf/trunk/manual/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/manual/pom.xml?rev=1209847&r1=1209846&r2=1209847&view=diff
==============================================================================
--- karaf/trunk/manual/pom.xml (original)
+++ karaf/trunk/manual/pom.xml Sat Dec 3 08:03:50 2011
@@ -242,8 +242,13 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.web</artifactId>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>org.apache.karaf.web.commands</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>org.apache.karaf.web.core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Modified: karaf/trunk/manual/src/main/webapp/users-guide/deployer.conf
URL: http://svn.apache.org/viewvc/karaf/trunk/manual/src/main/webapp/users-guide/deployer.conf?rev=1209847&r1=1209846&r2=1209847&view=diff
==============================================================================
--- karaf/trunk/manual/src/main/webapp/users-guide/deployer.conf (original)
+++ karaf/trunk/manual/src/main/webapp/users-guide/deployer.conf Sat Dec 3 08:03:50 2011
@@ -80,7 +80,8 @@ Installing bundle mvn:org.ops4j.pax.web/
Installing bundle mvn:org.ops4j.pax.web/pax-web-spi/1.0.0
Installing bundle mvn:org.ops4j.pax.web/pax-web-runtime/1.0.0
Installing bundle mvn:org.ops4j.pax.web/pax-web-jetty/1.0.0
-Installing bundle mvn:org.apache.karaf.shell/org.apache.karaf.shell.web/2.99.99-SNAPSHOT
+Installing bundle mvn:org.apache.karaf.web/org.apache.karaf.web.core/3.0.0-SNAPSHOT
+Installing bundle mvn:org.apache.karaf.web/org.apache.karaf.web.commands/3.0.0-SNAPSHOT
Installing bundle mvn:org.ops4j.pax.web/pax-web-jsp/1.0.0
Installing bundle mvn:org.ops4j.pax.web/pax-web-extender-war/1.0.0
Installing bundle mvn:org.ops4j.pax.web/pax-web-extender-whiteboard/1.0.0
Modified: karaf/trunk/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/pom.xml?rev=1209847&r1=1209846&r2=1209847&view=diff
==============================================================================
--- karaf/trunk/pom.xml (original)
+++ karaf/trunk/pom.xml Sat Dec 3 08:03:50 2011
@@ -46,6 +46,7 @@
<module>client</module>
<module>management</module>
<module>system</module>
+ <module>web</module>
<module>wrapper</module>
<module>webconsole</module>
<module>exception</module>
@@ -443,7 +444,17 @@
</dependency>
<dependency>
<groupId>org.apache.karaf.system</groupId>
- <artifactId>org.Apache.karaf.system.management</artifactId>
+ <artifactId>org.apache.karaf.system.management</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>org.apache.karaf.web.commands</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>org.apache.karaf.web.core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Modified: karaf/trunk/shell/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/pom.xml?rev=1209847&r1=1209846&r2=1209847&view=diff
==============================================================================
--- karaf/trunk/shell/pom.xml (original)
+++ karaf/trunk/shell/pom.xml Sat Dec 3 08:03:50 2011
@@ -44,7 +44,6 @@
<module>obr</module>
<module>services</module>
<module>ssh</module>
- <module>web</module>
</modules>
</project>
Copied: karaf/trunk/web/commands/NOTICE (from r1209838, karaf/trunk/management/mbeans/web/NOTICE)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/commands/NOTICE?p2=karaf/trunk/web/commands/NOTICE&p1=karaf/trunk/management/mbeans/web/NOTICE&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
(empty)
Copied: karaf/trunk/web/commands/pom.xml (from r1209838, karaf/trunk/management/mbeans/web/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/commands/pom.xml?p2=karaf/trunk/web/commands/pom.xml&p1=karaf/trunk/management/mbeans/web/pom.xml&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/web/pom.xml (original)
+++ karaf/trunk/web/commands/pom.xml Sat Dec 3 08:03:50 2011
@@ -22,38 +22,46 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.karaf.management.mbeans</groupId>
- <artifactId>mbeans</artifactId>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>web</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>org.apache.karaf.management.mbeans.web</artifactId>
+ <artifactId>org.apache.karaf.web.commands</artifactId>
<packaging>bundle</packaging>
- <name>Apache Karaf :: Management :: MBeans :: Web</name>
- <description>The Web MBean bundle provides a JMX MBean to manipulate to manipulate web application bundles.</description>
+ <name>Apache Karaf :: Web :: Commands</name>
+ <description>
+ This bundle provides Karaf shell commands to manipulate the WebContainer service.
+ </description>
<properties>
- <appendedResourcesDirectory>${basedir}/../../../etc/appended-resources/</appendedResourcesDirectory>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
</properties>
<dependencies>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>org.apache.karaf.web.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
- <directory>src/main/resources</directory>
+ <directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
- <directory>src/main/resources</directory>
+ <directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.info</include>
@@ -66,23 +74,18 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Export-Package>
- org.apache.karaf.management.mbeans.web;version=${project.version}
- </Export-Package>
<Import-Package>
- !org.apache.karaf.management.mbeans.system,
+ org.apache.karaf.web,
javax.management,
javax.management.loading,
org.apache.aries.blueprint,
org.osgi.service.blueprint.container,
org.osgi.service.blueprint.reflect,
- org.apache.karaf.management;version=${project.version},
+ org.apache.felix.service.command,
+ org.apache.karaf.shell.commands,
+ org.apache.karaf.shell.console,
*
</Import-Package>
- <Private-Package>
- org.apache.karaf.management.mbeans.web.internal,
- !*
- </Private-Package>
</instructions>
</configuration>
</plugin>
Added: karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/List.java
URL: http://svn.apache.org/viewvc/karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/List.java?rev=1209847&view=auto
==============================================================================
--- karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/List.java (added)
+++ karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/List.java Sat Dec 3 08:03:50 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.web.commands;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.karaf.web.WebBundle;
+import org.apache.karaf.web.WebContainerService;
+
+@Command(scope = "web", name = "list", description = "Lists details for war bundles.")
+public class List extends OsgiCommandSupport {
+
+ private WebContainerService webContainerService;
+
+ public void setWebContainerService(WebContainerService webContainerService) {
+ this.webContainerService = webContainerService;
+ }
+
+ public Object doExecute() throws Exception {
+ java.util.List<WebBundle> webBundles = webContainerService.list();
+ if (webBundles != null && !webBundles.isEmpty()) {
+ String headers = String.format("%d4 %s6 %s6 %s6 %d4 %s30 %s30", "ID", "State", "Web-State", "Level", "Web-ContextPath", "Name");
+ System.out.println(headers);
+ for (WebBundle webBundle : webBundles) {
+ String display = String.format("%d4 %s6 %s6 %s6 %d4 %s30 %s30",
+ webBundle.getBundleId(),
+ webBundle.getState(),
+ webBundle.getWebState(),
+ webBundle.getLevel(),
+ webBundle.getContextPath(),
+ webBundle.getName());
+ System.out.println(display);
+ }
+
+ }
+ return null;
+ }
+
+}
Copied: karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/Start.java (from r1209838, karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebUnDeploymentCommand.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/Start.java?p2=karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/Start.java&p1=karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebUnDeploymentCommand.java&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
--- karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebUnDeploymentCommand.java (original)
+++ karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/Start.java Sat Dec 3 08:03:50 2011
@@ -1,33 +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.shell.web;
-
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Command;
-
-@Command(scope = "web", name = "undeploy", description = "Stops/undeploys the web context of the given bundle id.")
-public class WebUnDeploymentCommand extends WebManagerCommand {
-
- @Override
- protected void doExecute(List<Long> bundleIds) throws Exception {
- for (Long bundleId : bundleIds) {
- getWarManager().stop(bundleId);
- }
- }
-
-}
+/*
+ * 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.web.commands;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.karaf.web.WebContainerService;
+
+@Command(scope = "web", name = "start", description = "Start the web context of given bundles.")
+public class Start extends OsgiCommandSupport {
+
+ @Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = true, multiValued = true)
+ java.util.List<Long> ids;
+
+ private WebContainerService webContainerService;
+
+ public void setWebContainerService(WebContainerService webContainerService) {
+ this.webContainerService = webContainerService;
+ }
+
+ public Object doExecute() throws Exception {
+ webContainerService.start(ids);
+ return null;
+ }
+
+}
Copied: karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/Stop.java (from r1209838, karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebDeploymentCommand.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/Stop.java?p2=karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/Stop.java&p1=karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebDeploymentCommand.java&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
--- karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebDeploymentCommand.java (original)
+++ karaf/trunk/web/commands/src/main/java/org/apache/karaf/web/commands/Stop.java Sat Dec 3 08:03:50 2011
@@ -1,33 +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.shell.web;
-
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Command;
-
-@Command(scope = "web", name = "deploy", description = "Starts/deploys the web context of the given bundle id.")
-public class WebDeploymentCommand extends WebManagerCommand {
-
-
- @Override
- protected void doExecute(List<Long> bundleIds) throws Exception {
- for (Long bundleId : bundleIds) {
- getWarManager().start(bundleId, null);
- }
- }
-}
+/*
+ * 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.web.commands;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.karaf.web.WebContainerService;
+
+@Command(scope = "web", name = "stop", description = "Stop the web context of given bundles.")
+public class Stop extends OsgiCommandSupport {
+
+ @Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = true, multiValued = true)
+ java.util.List<Long> ids;
+
+ private WebContainerService webContainerService;
+
+ public void setWebContainerService(WebContainerService webContainerService) {
+ this.webContainerService = webContainerService;
+ }
+
+ public Object doExecute() throws Exception {
+ webContainerService.stop(ids);
+ return null;
+ }
+
+}
Added: karaf/trunk/web/commands/src/main/resources/OSGI-INF/blueprint/web-commands.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/web/commands/src/main/resources/OSGI-INF/blueprint/web-commands.xml?rev=1209847&view=auto
==============================================================================
--- karaf/trunk/web/commands/src/main/resources/OSGI-INF/blueprint/web-commands.xml (added)
+++ karaf/trunk/web/commands/src/main/resources/OSGI-INF/blueprint/web-commands.xml Sat Dec 3 08:03:50 2011
@@ -0,0 +1,42 @@
+<?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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
+
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+ <command>
+ <action class="org.apache.karaf.web.commands.List">
+ <property name="webContainerService" ref="webContainerService"/>
+ </action>
+ </command>
+ <command>
+ <action class="org.apache.karaf.web.commands.Start">
+ <property name="webContainerService" ref="webContainerService"/>
+ </action>
+ </command>
+ <command>
+ <action class="org.apache.karaf.web.commands.Stop">
+ <property name="webContainerService" ref="webContainerService"/>
+ </action>
+ </command>
+ </command-bundle>
+
+ <reference id="webContainerService" interface="org.apache.karaf.web.WebContainerService"/>
+
+</blueprint>
\ No newline at end of file
Added: karaf/trunk/web/commands/src/main/resources/OSGI-INF/bundle.info
URL: http://svn.apache.org/viewvc/karaf/trunk/web/commands/src/main/resources/OSGI-INF/bundle.info?rev=1209847&view=auto
==============================================================================
--- karaf/trunk/web/commands/src/main/resources/OSGI-INF/bundle.info (added)
+++ karaf/trunk/web/commands/src/main/resources/OSGI-INF/bundle.info Sat Dec 3 08:03:50 2011
@@ -0,0 +1,21 @@
+h1. Synopsis
+
+${project.name}
+
+${project.description}
+
+Maven URL:
+[mvn:${project.groupId}/${project.artifactId}/${project.version}]
+
+h1. Description
+
+This bundle contains all Karaf shell commands related to the web container.
+
+The following commands are available:
+* web:list - List detail information about web bundles.
+* web:start - Start the web context for the given web bundles.
+* web:stop - Stop the web context for the given web bundles.
+
+h1. See also
+
+Web Container - section of the Karaf User Guide.
\ No newline at end of file
Copied: karaf/trunk/web/core/NOTICE (from r1209838, karaf/trunk/shell/web/NOTICE)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/core/NOTICE?p2=karaf/trunk/web/core/NOTICE&p1=karaf/trunk/shell/web/NOTICE&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
(empty)
Copied: karaf/trunk/web/core/pom.xml (from r1209838, karaf/trunk/shell/web/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/core/pom.xml?p2=karaf/trunk/web/core/pom.xml&p1=karaf/trunk/shell/web/pom.xml&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
--- karaf/trunk/shell/web/pom.xml (original)
+++ karaf/trunk/web/core/pom.xml Sat Dec 3 08:03:50 2011
@@ -22,16 +22,18 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>shell</artifactId>
- <groupId>org.apache.karaf.shell</groupId>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>web</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>org.apache.karaf.shell.web</artifactId>
+ <artifactId>org.apache.karaf.web.core</artifactId>
<packaging>bundle</packaging>
- <name>Apache Karaf :: Shell :: Web Commands</name>
- <description>This bundle provides Karaf shell commands to manipulate web application bundles.</description>
+ <name>Apache Karaf :: Web :: Core</name>
+ <description>
+ This bundle provide the core service to manipulate the web container/bundles.
+ </description>
<properties>
<appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
@@ -39,28 +41,19 @@
<dependencies>
<dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.utils</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.ops4j.pax.web</groupId>
<artifactId>pax-web-spi</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.karaf</groupId>
- <artifactId>org.apache.karaf.util</artifactId>
- <scope>compile</scope>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
@@ -86,29 +79,22 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
+ <Export-Package>
+ org.apache.karaf.web;version=${project.version}
+ </Export-Package>
<Import-Package>
- !${project.artifactId}*,
- org.apache.aries.blueprint,
- org.osgi.service.blueprint.container,
- org.osgi.service.blueprint.reflect,
- org.apache.felix.service.command,
- org.apache.karaf.shell.commands,
- org.apache.karaf.shell.console,
+ !org.apache.karaf.web*,
+ org.ops4j.pax.web*,
+ org.slf4j,
*
</Import-Package>
<Private-Package>
- org.apache.felix.utils.version,
- org.apache.felix.utils.manifest,
- org.apache.karaf.util,
- !*
+ org.apache.karaf.web.internal
</Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
-</project>
+</project>
\ No newline at end of file
Added: karaf/trunk/web/core/src/main/java/org/apache/karaf/web/WebBundle.java
URL: http://svn.apache.org/viewvc/karaf/trunk/web/core/src/main/java/org/apache/karaf/web/WebBundle.java?rev=1209847&view=auto
==============================================================================
--- karaf/trunk/web/core/src/main/java/org/apache/karaf/web/WebBundle.java (added)
+++ karaf/trunk/web/core/src/main/java/org/apache/karaf/web/WebBundle.java Sat Dec 3 08:03:50 2011
@@ -0,0 +1,79 @@
+/*
+ * 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.web;
+
+/**
+ * Container for WebBundle information.
+ */
+public class WebBundle {
+
+ private long bundleId;
+ private String name;
+ private int level;
+ private String state;
+ private String webState;
+ private String contextPath;
+
+ public long getBundleId() {
+ return bundleId;
+ }
+
+ public void setBundleId(long bundleId) {
+ this.bundleId = bundleId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getWebState() {
+ return webState;
+ }
+
+ public void setWebState(String webState) {
+ this.webState = webState;
+ }
+
+ public String getContextPath() {
+ return contextPath;
+ }
+
+ public void setContextPath(String contextPath) {
+ this.contextPath = contextPath;
+ }
+
+}
Added: karaf/trunk/web/core/src/main/java/org/apache/karaf/web/WebContainerService.java
URL: http://svn.apache.org/viewvc/karaf/trunk/web/core/src/main/java/org/apache/karaf/web/WebContainerService.java?rev=1209847&view=auto
==============================================================================
--- karaf/trunk/web/core/src/main/java/org/apache/karaf/web/WebContainerService.java (added)
+++ karaf/trunk/web/core/src/main/java/org/apache/karaf/web/WebContainerService.java Sat Dec 3 08:03:50 2011
@@ -0,0 +1,59 @@
+/*
+ * 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.web;
+
+import java.util.List;
+
+/**
+ * Describe the WebContainer service.
+ */
+public interface WebContainerService {
+
+ /**
+ * List of web bundles deployed in the web container.
+ *
+ * @return the list of web bundles.
+ * @throws Exception in case of listing failure.
+ */
+ List<WebBundle> list() throws Exception;
+
+ /**
+ * Get a string representation of the web state of a bundle (identified by id).
+ *
+ * @param bundleId the bundle ID.
+ * @return the string representation of the bundle web state.
+ * @throws Exception in case of "mapping" failure.
+ */
+ String state(long bundleId) throws Exception;
+
+ /**
+ * Start the web context of given bundles (identified by an ID).
+ *
+ * @param bundleIds the list of bundle IDs (TODO use a BundleSelector service).
+ * @throws Exception in case of deploy failure.
+ */
+ void start(List<Long> bundleIds) throws Exception;
+
+ /**
+ * Stop the web context of given bundles (identified by an ID).
+ *
+ * @param bundleIds the list of bundle IDs (TODO use a BundleSelector service).
+ * @throws Exception in case of undeploy failure.
+ */
+ void stop(List<Long> bundleIds) throws Exception;
+
+}
Added: karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java?rev=1209847&view=auto
==============================================================================
--- karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java (added)
+++ karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java Sat Dec 3 08:03:50 2011
@@ -0,0 +1,213 @@
+/*
+ * 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.web.internal;
+
+import org.apache.karaf.web.WebBundle;
+import org.apache.karaf.web.WebContainerService;
+import org.ops4j.pax.web.service.spi.WarManager;
+import org.ops4j.pax.web.service.spi.WebEvent;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.service.startlevel.StartLevel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Implementation of the WebContainer service.
+ */
+public class WebContainerServiceImpl implements WebContainerService {
+
+ private BundleContext bundleContext;
+ private StartLevel startLevelService;
+ private WebEventHandler webEventHandler;
+ private WarManager warManager;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(WebContainerServiceImpl.class);
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
+ public void setStartLevelService(StartLevel startLevelService) {
+ this.startLevelService = startLevelService;
+ }
+
+ public void setWebEventHandler(WebEventHandler webEventHandler) {
+ this.webEventHandler = webEventHandler;
+ }
+
+ public void setWarManager(WarManager warManager) {
+ this.warManager = warManager;
+ }
+
+ public List<WebBundle> list() throws Exception {
+ Bundle[] bundles = bundleContext.getBundles();
+ Map<Long, WebEvent> bundleEvents = webEventHandler.getBundleEvents();
+ List<WebBundle> webBundles = new ArrayList<WebBundle>();
+ if (bundles != null) {
+ for (Bundle bundle : bundles) {
+ // first check if the bundle is a web bundle
+ String contextPath = (String) bundle.getHeaders().get("Web-ContextPath");
+ if (contextPath == null) {
+ contextPath = (String) bundle.getHeaders().get("Webapp-Context"); // this one used by pax-web but is deprecated
+ }
+ if (contextPath == null) {
+ // the bundle is not a web bundle
+ continue;
+ }
+
+ WebBundle webBundle = new WebBundle();
+ contextPath.trim();
+
+ // get the bundle name
+ String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
+ // if there is no name, then default to symbolic name
+ name = (name == null) ? bundle.getSymbolicName() : name;
+ // if there is no symbolic name, resort to location
+ name = (name == null) ? bundle.getLocation() : name;
+ // get the bundle version
+ String version = (String) bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+ name = ((version != null)) ? name + " (" + version + ")" : name;
+ long bundleId = bundle.getBundleId();
+ int level = -1;
+ if (startLevelService != null) {
+ level = startLevelService.getBundleStartLevel(bundle);
+ }
+ if (!contextPath.startsWith("/")) {
+ contextPath = "/" + contextPath;
+ }
+
+ webBundle.setBundleId(bundleId);
+ webBundle.setName(name);
+ webBundle.setContextPath(contextPath);
+ webBundle.setLevel(level);
+ webBundle.setState(getStateString(bundle));
+ webBundle.setWebState(state(bundle.getBundleId()));
+
+ webBundles.add(webBundle);
+ }
+ }
+
+ return webBundles;
+ }
+
+ public void start(List<Long> bundleIds) throws Exception {
+ if (bundleIds != null && !bundleIds.isEmpty()) {
+ for (long bundleId : bundleIds) {
+ if (webEventHandler.getBundleEvents().containsKey(bundleId)) {
+ WebEvent webEvent = webEventHandler.getBundleEvents().get(bundleId);
+ Bundle bundle = webEvent.getBundle();
+ if (bundle != null) {
+ // deploy
+ warManager.start(bundleId, null);
+ } else {
+ System.out.println("Bundle ID " + bundleId + " is invalid");
+ LOGGER.warn("Bundle ID {} is invalid", bundleId);
+ }
+ }
+ }
+ }
+ }
+
+ public void stop(List<Long> bundleIds) throws Exception {
+ if (bundleIds != null && !bundleIds.isEmpty()) {
+ for (long bundleId : bundleIds) {
+ if (webEventHandler.getBundleEvents().containsKey(bundleId)) {
+ WebEvent webEvent = webEventHandler.getBundleEvents().get(bundleId);
+ Bundle bundle = webEvent.getBundle();
+ if (bundle != null) {
+ // deploy
+ warManager.stop(bundleId);
+ } else {
+ System.out.println("Bundle ID " + bundleId + " is invalid");
+ LOGGER.warn("Bundle ID {} is invalid", bundleId);
+ }
+ }
+ }
+ }
+ }
+
+ public String state(long bundleId) {
+
+ Map<Long, WebEvent> bundleEvents = webEventHandler.getBundleEvents();
+ String topic = "Unknown ";
+
+ if (bundleEvents.containsKey(bundleId)) {
+ WebEvent webEvent = bundleEvents.get(bundleId);
+
+ switch(webEvent.getType()) {
+ case WebEvent.DEPLOYING:
+ topic = "Deploying ";
+ break;
+ case WebEvent.DEPLOYED:
+ topic = "Deployed ";
+ break;
+ case WebEvent.UNDEPLOYING:
+ topic = "Undeploying";
+ break;
+ case WebEvent.UNDEPLOYED:
+ topic = "Undeployed ";
+ break;
+ case WebEvent.FAILED:
+ topic = "Failed ";
+ break;
+ case WebEvent.WAITING:
+ topic = "Waiting ";
+ break;
+ default:
+ topic = "Failed ";
+ }
+ }
+
+ while (topic.length() < 11) {
+ topic += " ";
+ }
+
+ return topic;
+ }
+
+ /**
+ * Return a string representation of the bundle state.
+ *
+ * TODO use an util method provided by bundle core
+ *
+ * @param bundle the target bundle.
+ * @return the string representation of the state
+ */
+ private String getStateString(Bundle bundle) {
+ int state = bundle.getState();
+ if (state == Bundle.ACTIVE) {
+ return "Active ";
+ } else if (state == Bundle.INSTALLED) {
+ return "Installed ";
+ } else if (state == Bundle.RESOLVED) {
+ return "Resolved ";
+ } else if (state == Bundle.STARTING) {
+ return "Starting ";
+ } else if (state == Bundle.STOPPING) {
+ return "Stopping ";
+ } else {
+ return "Unknown ";
+ }
+ }
+
+}
Copied: karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java (from r1209838, karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebEventHandler.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java?p2=karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java&p1=karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebEventHandler.java&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
--- karaf/trunk/shell/web/src/main/java/org/apache/karaf/shell/web/WebEventHandler.java (original)
+++ karaf/trunk/web/core/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java Sat Dec 3 08:03:50 2011
@@ -1,40 +1,40 @@
-/*
- * 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.shell.web;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.ops4j.pax.web.service.spi.WebEvent;
-import org.ops4j.pax.web.service.spi.WebListener;
-
-/**
- * Class implementing {@link WebListener} service to retrieve {@link WebEvent}
- */
-public class WebEventHandler implements WebListener {
-
- private final Map<Long, WebEvent> bundleEvents = new HashMap<Long, WebEvent>();
-
- public Map<Long, WebEvent> getBundleEvents() {
- return bundleEvents;
- }
-
- public void webEvent(WebEvent event) {
- getBundleEvents().put(event.getBundle().getBundleId(), event);
- }
-
-}
+/*
+ * 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.web.internal;
+
+import org.ops4j.pax.web.service.spi.WebEvent;
+import org.ops4j.pax.web.service.spi.WebListener;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Class implementing {@link WebListener} service to retrieve {@link WebEvent}.
+ */
+public class WebEventHandler implements WebListener {
+
+ private final Map<Long, WebEvent> bundleEvents = new HashMap<Long, WebEvent>();
+
+ public Map<Long, WebEvent> getBundleEvents() {
+ return bundleEvents;
+ }
+
+ public void webEvent(WebEvent event) {
+ getBundleEvents().put(event.getBundle().getBundleId(), event);
+ }
+
+}
Added: karaf/trunk/web/core/src/main/resources/OSGI-INF/blueprint/web-core.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/web/core/src/main/resources/OSGI-INF/blueprint/web-core.xml?rev=1209847&view=auto
==============================================================================
--- karaf/trunk/web/core/src/main/resources/OSGI-INF/blueprint/web-core.xml (added)
+++ karaf/trunk/web/core/src/main/resources/OSGI-INF/blueprint/web-core.xml Sat Dec 3 08:03:50 2011
@@ -0,0 +1,40 @@
+<?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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
+
+ <reference id="startLevelService" interface="org.osgi.service.startlevel.StartLevel" availability="optional" />
+
+ <reference id="warManager" interface="org.ops4j.pax.web.service.spi.WarManager" />
+
+ <bean id="webEventHandler" class="org.apache.karaf.web.internal.WebEventHandler" />
+ <service id="webListener"
+ interface="org.ops4j.pax.web.service.spi.WebListener"
+ ref="webEventHandler" />
+
+ <bean id="webContainerService" class="org.apache.karaf.web.internal.WebContainerServiceImpl">
+ <property name="bundleContext" ref="blueprintBundleContext"/>
+ <property name="startLevelService" ref="startLevelService"/>
+ <property name="webEventHandler" ref="webEventHandler"/>
+ <property name="warManager" ref="warManager"/>
+ </bean>
+
+ <service ref="webContainerService" interface="org.apache.karaf.web.WebContainerService"/>
+
+</blueprint>
\ No newline at end of file
Added: karaf/trunk/web/core/src/main/resources/OSGI-INF/bundle.info
URL: http://svn.apache.org/viewvc/karaf/trunk/web/core/src/main/resources/OSGI-INF/bundle.info?rev=1209847&view=auto
==============================================================================
--- karaf/trunk/web/core/src/main/resources/OSGI-INF/bundle.info (added)
+++ karaf/trunk/web/core/src/main/resources/OSGI-INF/bundle.info Sat Dec 3 08:03:50 2011
@@ -0,0 +1,16 @@
+h1. Synopsis
+
+${project.name}
+
+${project.description}
+
+Maven URL:
+[mvn:${project.groupId}/${project.artifactId}/${project.version}]
+
+h1. Description
+
+This bundle provides support of the WebContainer service, which allows to manipulate the Karaf embedded web container.
+
+h1. See also
+
+Web Container - section of the Karaf User Guide
Copied: karaf/trunk/web/management/NOTICE (from r1209838, karaf/trunk/management/mbeans/web/NOTICE)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/management/NOTICE?p2=karaf/trunk/web/management/NOTICE&p1=karaf/trunk/management/mbeans/web/NOTICE&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
(empty)
Copied: karaf/trunk/web/management/pom.xml (from r1209838, karaf/trunk/management/mbeans/web/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/management/pom.xml?p2=karaf/trunk/web/management/pom.xml&p1=karaf/trunk/management/mbeans/web/pom.xml&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/web/pom.xml (original)
+++ karaf/trunk/web/management/pom.xml Sat Dec 3 08:03:50 2011
@@ -22,38 +22,40 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.karaf.management.mbeans</groupId>
- <artifactId>mbeans</artifactId>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>web</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>org.apache.karaf.management.mbeans.web</artifactId>
+ <artifactId>org.apache.karaf.web.management</artifactId>
<packaging>bundle</packaging>
- <name>Apache Karaf :: Management :: MBeans :: Web</name>
- <description>The Web MBean bundle provides a JMX MBean to manipulate to manipulate web application bundles.</description>
+ <name>Apache Karaf :: Web :: Management</name>
+ <description>
+ This bundle provides management MBeans to manipulator the web container service.
+ </description>
<properties>
- <appendedResourcesDirectory>${basedir}/../../../etc/appended-resources/</appendedResourcesDirectory>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
</properties>
<dependencies>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>org.apache.karaf.web.core</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
- <directory>src/main/resources</directory>
+ <directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
- <directory>src/main/resources</directory>
+ <directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.info</include>
@@ -66,23 +68,13 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Export-Package>
- org.apache.karaf.management.mbeans.web;version=${project.version}
- </Export-Package>
<Import-Package>
- !org.apache.karaf.management.mbeans.system,
+ !${project.artifactId}*,
javax.management,
- javax.management.loading,
- org.apache.aries.blueprint,
- org.osgi.service.blueprint.container,
- org.osgi.service.blueprint.reflect,
- org.apache.karaf.management;version=${project.version},
+ org.apache.karaf.management,
+ org.apache.karaf.web,
*
</Import-Package>
- <Private-Package>
- org.apache.karaf.management.mbeans.web.internal,
- !*
- </Private-Package>
</instructions>
</configuration>
</plugin>
Copied: karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/WebMBean.java (from r1209838, karaf/trunk/management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/WebMBean.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/WebMBean.java?p2=karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/WebMBean.java&p1=karaf/trunk/management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/WebMBean.java&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/WebMBean.java (original)
+++ karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/WebMBean.java Sat Dec 3 08:03:50 2011
@@ -14,15 +14,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.karaf.management.mbeans.web;
+package org.apache.karaf.web.management;
import javax.management.openmbean.TabularData;
+import java.util.List;
/**
- * Web MBean.
+ * Describe the web MBean.
*/
public interface WebMBean {
+ /**
+ * Return the list of web bundles.
+ *
+ * @return a tabular data of web bundles.
+ * @throws Exception in case of lookup failure.
+ */
TabularData getWebBundles() throws Exception;
+ /**
+ * Start web context of the given web bundles (identified by ID).
+ *
+ * @param bundleIds the list of bundle IDs.
+ * TODO use a BundleSelector service
+ * @throws Exception in case of start failure.
+ */
+ void start(List<Long> bundleIds) throws Exception;
+
+ /**
+ * Stop web contact of the given web bundles (identified by ID).
+ *
+ * @param bundleIds the list of bundle IDs.
+ * TODO use a BundleSelector service
+ * @throws Exception in case of stop failure
+ */
+ void stop(List<Long> bundleIds) throws Exception;
+
}
Copied: karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java (from r1209838, karaf/trunk/management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/internal/WebMBeanImpl.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java?p2=karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java&p1=karaf/trunk/management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/internal/WebMBeanImpl.java&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/web/src/main/java/org/apache/karaf/management/mbeans/web/internal/WebMBeanImpl.java (original)
+++ karaf/trunk/web/management/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java Sat Dec 3 08:03:50 2011
@@ -1,6 +1,5 @@
/*
* 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
@@ -15,67 +14,66 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.karaf.management.mbeans.web.internal;
+package org.apache.karaf.web.management.internal;
-import org.apache.karaf.management.mbeans.web.WebMBean;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
+import org.apache.karaf.web.WebBundle;
+import org.apache.karaf.web.WebContainerService;
+import org.apache.karaf.web.management.WebMBean;
import javax.management.NotCompliantMBeanException;
import javax.management.StandardMBean;
import javax.management.openmbean.*;
+import java.util.List;
/**
- * Web MBean implementation.
+ * Implementation of the web MBean.
*/
public class WebMBeanImpl extends StandardMBean implements WebMBean {
-
- private BundleContext bundleContext;
-
+
+ private WebContainerService webContainerService;
+
public WebMBeanImpl() throws NotCompliantMBeanException {
super(WebMBean.class);
}
+ public void setWebContainerService(WebContainerService webContainerService) {
+ this.webContainerService = webContainerService;
+ }
+
public TabularData getWebBundles() throws Exception {
CompositeType webType = new CompositeType("Web Bundle", "An OSGi Web bundle",
- new String[]{ "ID", "Name", "Context" },
- new String[]{ "ID of the bundle", "Name of the bundle", "Web Context" },
+ new String[]{ "ID", "State", "Web-State", "Level", "Web-ContextPath", "Name" },
+ new String[]{ "ID of the bundle",
+ "OSGi state of the bundle",
+ "Web state of the bundle",
+ "Start level of the bundle",
+ "Web context path",
+ "Name of the bundle" },
new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING });
TabularType tableType = new TabularType("Web Bundles", "Table of web bundles", webType,
new String[]{ "ID" });
TabularData table = new TabularDataSupport(tableType);
- for (Bundle bundle : bundleContext.getBundles()) {
- String webContext = (String) bundle.getHeaders().get("Web-ContextPath");
- if (webContext == null)
- webContext = (String) bundle.getHeaders().get("Webapp-Context");
- if (webContext == null)
- continue;
-
- webContext.trim();
- if (!webContext.startsWith("/")) {
- webContext = "/" + webContext;
- }
-
- String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
- name = (name == null) ? bundle.getSymbolicName() : name;
- // If there is no symbolic name, resort to location.
- name = (name == null) ? bundle.getLocation() : name;
-
+ for (WebBundle webBundle : webContainerService.list()) {
+
CompositeData data = new CompositeDataSupport(webType,
- new String[]{ "ID", "Name", "Context"},
- new Object[]{ bundle.getBundleId(), name, webContext });
+ new String[]{ "ID", "State", "Web-State", "Level", "Web-ContextPath", "Name"},
+ new Object[]{ webBundle.getBundleId(),
+ webBundle.getState(),
+ webBundle.getWebState(),
+ webBundle.getLevel(),
+ webBundle.getContextPath(),
+ webBundle.getName() });
table.put(data);
}
return table;
+ }
+
+ public void start(List<Long> bundleIds) throws Exception {
+ webContainerService.start(bundleIds);
}
-
- public BundleContext getBundleContext() {
- return this.bundleContext;
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
+
+ public void stop(List<Long> bundleIds) throws Exception {
+ webContainerService.stop(bundleIds);
}
-
+
}
Added: karaf/trunk/web/management/src/main/resources/OSGI-INF/blueprint/web-management.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/web/management/src/main/resources/OSGI-INF/blueprint/web-management.xml?rev=1209847&view=auto
==============================================================================
--- karaf/trunk/web/management/src/main/resources/OSGI-INF/blueprint/web-management.xml (added)
+++ karaf/trunk/web/management/src/main/resources/OSGI-INF/blueprint/web-management.xml Sat Dec 3 08:03:50 2011
@@ -0,0 +1,44 @@
+<?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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <!-- Reference to the MBean Server -->
+ <reference id="mbeanServer" interface="javax.management.MBeanServer">
+ <reference-listener ref="mbeanRegistrer" bind-method="registerMBeanServer" unbind-method="unregisterMBeanServer"/>
+ </reference>
+
+ <!-- Reference to the WebContainerService -->
+ <reference id="webContainerService" interface="org.apache.karaf.web.WebContainerService"/>
+
+ <!-- Web MBean -->
+ <bean id="webMBean" class="org.apache.karaf.web.management.internal.WebMBeanImpl">
+ <property name="webContainerService" ref="webContainerService"/>
+ </bean>
+
+ <!-- MBean Registrer -->
+ <bean id="mbeanRegistrer" class="org.apache.karaf.management.MBeanRegistrer">
+ <property name="mbeans">
+ <map>
+ <entry value="org.apache.karaf:type=web,name=${karaf.name}" key-ref="webMBean"/>
+ </map>
+ </property>
+ </bean>
+
+</blueprint>
\ No newline at end of file
Copied: karaf/trunk/web/management/src/main/resources/OSGI-INF/bundle.info (from r1209838, karaf/trunk/management/mbeans/web/src/main/resources/OSGI-INF/bundle.info)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/management/src/main/resources/OSGI-INF/bundle.info?p2=karaf/trunk/web/management/src/main/resources/OSGI-INF/bundle.info&p1=karaf/trunk/management/mbeans/web/src/main/resources/OSGI-INF/bundle.info&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/web/src/main/resources/OSGI-INF/bundle.info (original)
+++ karaf/trunk/web/management/src/main/resources/OSGI-INF/bundle.info Sat Dec 3 08:03:50 2011
@@ -12,7 +12,9 @@ h1. Description
The Web MBean management bundle exposes a Web MBean that can be used with any JMX client (for instance JConsole).
The Web MBean allows quite the same action that can be performed using web:* commands:
- * list()
+ * list() - list detailed information about web bundles
+ * start(bundleIds) - start the web context of the given web bundles
+ * stop(bundleIds) - stop the web context of the given web bundles
h1. See also
Copied: karaf/trunk/web/pom.xml (from r1209838, karaf/trunk/shell/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/web/pom.xml?p2=karaf/trunk/web/pom.xml&p1=karaf/trunk/shell/pom.xml&r1=1209838&r2=1209847&rev=1209847&view=diff
==============================================================================
--- karaf/trunk/shell/pom.xml (original)
+++ karaf/trunk/web/pom.xml Sat Dec 3 08:03:50 2011
@@ -28,24 +28,15 @@
<relativePath>../pom.xml</relativePath>
</parent>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>shell</artifactId>
+ <groupId>org.apache.karaf.web</groupId>
+ <artifactId>web</artifactId>
<packaging>pom</packaging>
- <name>Apache Karaf :: Shell</name>
+ <name>Apache Karaf :: Web</name>
<modules>
+ <module>core</module>
<module>commands</module>
- <module>console</module>
- <module>bundles</module>
- <module>config</module>
- <module>dev</module>
- <module>http</module>
- <module>log</module>
- <module>obr</module>
- <module>services</module>
- <module>ssh</module>
- <module>web</module>
+ <module>management</module>
</modules>
-</project>
-
+</project>
\ No newline at end of file