You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/04/10 16:16:14 UTC
[52/59] [abbrv] git commit: [KARAF-2852] Merge web/core and
web/command
[KARAF-2852] Merge web/core and web/command
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/2b7e96df
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/2b7e96df
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/2b7e96df
Branch: refs/heads/master
Commit: 2b7e96df01ae4a1dc56b8e47d0bb915b38aa741b
Parents: 04afd90
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Thu Apr 10 09:59:42 2014 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Apr 10 16:02:58 2014 +0200
----------------------------------------------------------------------
.../standard/src/main/feature/feature.xml | 1 -
web/NOTICE | 71 +++++++
web/command/NOTICE | 71 -------
web/command/pom.xml | 105 ----------
.../org/apache/karaf/web/commands/List.java | 70 -------
.../org/apache/karaf/web/commands/Start.java | 46 -----
.../org/apache/karaf/web/commands/Stop.java | 46 -----
.../src/main/resources/OSGI-INF/bundle.info | 21 --
web/core/NOTICE | 71 -------
web/core/pom.xml | 106 ----------
.../java/org/apache/karaf/web/WebBundle.java | 79 -------
.../apache/karaf/web/WebContainerService.java | 59 ------
.../web/internal/WebContainerServiceImpl.java | 205 -------------------
.../karaf/web/internal/WebEventHandler.java | 40 ----
.../karaf/web/internal/osgi/Activator.java | 55 -----
.../apache/karaf/web/management/WebMBean.java | 70 -------
.../web/management/internal/WebMBeanImpl.java | 116 -----------
.../src/main/resources/OSGI-INF/bundle.info | 16 --
web/pom.xml | 89 +++++++-
.../java/org/apache/karaf/web/WebBundle.java | 79 +++++++
.../apache/karaf/web/WebContainerService.java | 59 ++++++
.../org/apache/karaf/web/commands/List.java | 70 +++++++
.../org/apache/karaf/web/commands/Start.java | 46 +++++
.../org/apache/karaf/web/commands/Stop.java | 46 +++++
.../web/internal/WebContainerServiceImpl.java | 205 +++++++++++++++++++
.../karaf/web/internal/WebEventHandler.java | 40 ++++
.../karaf/web/internal/osgi/Activator.java | 55 +++++
.../apache/karaf/web/management/WebMBean.java | 70 +++++++
.../web/management/internal/WebMBeanImpl.java | 116 +++++++++++
web/src/main/resources/OSGI-INF/bundle.info | 16 ++
30 files changed, 954 insertions(+), 1185 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/assemblies/features/standard/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/standard/src/main/feature/feature.xml b/assemblies/features/standard/src/main/feature/feature.xml
index b6f8dea..fb3dd93 100644
--- a/assemblies/features/standard/src/main/feature/feature.xml
+++ b/assemblies/features/standard/src/main/feature/feature.xml
@@ -177,7 +177,6 @@
<feature>http</feature>
<feature>pax-war</feature>
<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.command/${project.version}</bundle>
</feature>
<feature name="jetty" version="8.1.9.v20130131" resolver="(obr)">
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/NOTICE
----------------------------------------------------------------------
diff --git a/web/NOTICE b/web/NOTICE
new file mode 100644
index 0000000..b70f1f9
--- /dev/null
+++ b/web/NOTICE
@@ -0,0 +1,71 @@
+Apache Karaf
+Copyright 2010-2014 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2010).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+OW2 (http://www.ow2.org/).
+Licensed under the BSD License.
+
+This product includes software developed at
+OPS4J (http://www.ops4j.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+Eclipse Foundation (http://www.eclipse.org/).
+Licensed under the EPL.
+
+This product includes software written by
+Antony Lesuisse.
+Licensed under Public Domain.
+
+
+II. Used Software
+
+This product uses software developed at
+FUSE Source (http://www.fusesource.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+AOP Alliance (http://aopalliance.sourceforge.net/).
+Licensed under the Public Domain.
+
+This product uses software developed at
+Tanuki Software (http://www.tanukisoftware.com/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+Jasypt (http://jasypt.sourceforge.net/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+JLine (http://jline.sourceforge.net).
+Licensed under the BSD License.
+
+This product uses software developed at
+SLF4J (http://www.slf4j.org/).
+Licensed under the MIT License.
+
+This product uses software developed at
+SpringSource (http://www.springsource.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software from http://www.json.org.
+Copyright (c) 2002 JSON.org
+
+
+III. License Summary
+- Apache License 2.0
+- BSD License
+- EPL License
+- MIT License
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/command/NOTICE
----------------------------------------------------------------------
diff --git a/web/command/NOTICE b/web/command/NOTICE
deleted file mode 100644
index b70f1f9..0000000
--- a/web/command/NOTICE
+++ /dev/null
@@ -1,71 +0,0 @@
-Apache Karaf
-Copyright 2010-2014 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-OW2 (http://www.ow2.org/).
-Licensed under the BSD License.
-
-This product includes software developed at
-OPS4J (http://www.ops4j.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-Eclipse Foundation (http://www.eclipse.org/).
-Licensed under the EPL.
-
-This product includes software written by
-Antony Lesuisse.
-Licensed under Public Domain.
-
-
-II. Used Software
-
-This product uses software developed at
-FUSE Source (http://www.fusesource.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-AOP Alliance (http://aopalliance.sourceforge.net/).
-Licensed under the Public Domain.
-
-This product uses software developed at
-Tanuki Software (http://www.tanukisoftware.com/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-Jasypt (http://jasypt.sourceforge.net/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-JLine (http://jline.sourceforge.net).
-Licensed under the BSD License.
-
-This product uses software developed at
-SLF4J (http://www.slf4j.org/).
-Licensed under the MIT License.
-
-This product uses software developed at
-SpringSource (http://www.springsource.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software from http://www.json.org.
-Copyright (c) 2002 JSON.org
-
-
-III. License Summary
-- Apache License 2.0
-- BSD License
-- EPL License
-- MIT License
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/command/pom.xml
----------------------------------------------------------------------
diff --git a/web/command/pom.xml b/web/command/pom.xml
deleted file mode 100644
index f053ab7..0000000
--- a/web/command/pom.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.web</groupId>
- <artifactId>web</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>org.apache.karaf.web.command</artifactId>
- <packaging>bundle</packaging>
- <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>
- </properties>
-
- <dependencies>
- <dependency>
- <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.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf</groupId>
- <artifactId>org.apache.karaf.util</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.info</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>
- !org.apache.karaf.web.commands
- </Export-Package>
- <Private-Package>
- org.apache.karaf.web.commands
- </Private-Package>
- <Karaf-Commands>*</Karaf-Commands>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/command/src/main/java/org/apache/karaf/web/commands/List.java
----------------------------------------------------------------------
diff --git a/web/command/src/main/java/org/apache/karaf/web/commands/List.java b/web/command/src/main/java/org/apache/karaf/web/commands/List.java
deleted file mode 100644
index a862a45..0000000
--- a/web/command/src/main/java/org/apache/karaf/web/commands/List.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.api.action.Action;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Reference;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.karaf.shell.support.table.Col;
-import org.apache.karaf.shell.support.table.ShellTable;
-import org.apache.karaf.web.WebBundle;
-import org.apache.karaf.web.WebContainerService;
-
-@Command(scope = "web", name = "list", description = "Lists details for war bundles.")
-@Service
-public class List implements Action {
-
- @Option(name = "--no-format", description = "Disable table rendered output", required = false, multiValued = false)
- boolean noFormat;
-
- @Reference
- private WebContainerService webContainerService;
-
- public void setWebContainerService(WebContainerService webContainerService) {
- this.webContainerService = webContainerService;
- }
-
- @Override
- public Object execute() throws Exception {
- ShellTable table = new ShellTable();
- table.column(new Col("ID"));
- table.column(new Col("State"));
- table.column(new Col("Web-State"));
- table.column(new Col("Level"));
- table.column(new Col("Web-ContextPath"));
- table.column(new Col("Name"));
-
- java.util.List<WebBundle> webBundles = webContainerService.list();
- if (webBundles != null && !webBundles.isEmpty()) {
- for (WebBundle webBundle : webBundles) {
- table.addRow().addContent(
- webBundle.getBundleId(),
- webBundle.getState(),
- webBundle.getWebState(),
- webBundle.getLevel(),
- webBundle.getContextPath(),
- webBundle.getName());
- }
-
- }
- table.print(System.out, !noFormat);
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/command/src/main/java/org/apache/karaf/web/commands/Start.java
----------------------------------------------------------------------
diff --git a/web/command/src/main/java/org/apache/karaf/web/commands/Start.java b/web/command/src/main/java/org/apache/karaf/web/commands/Start.java
deleted file mode 100644
index 41d6634..0000000
--- a/web/command/src/main/java/org/apache/karaf/web/commands/Start.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.api.action.Action;
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Reference;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.karaf.web.WebContainerService;
-
-@Command(scope = "web", name = "start", description = "Start the web context of given bundles.")
-@Service
-public class Start implements Action {
-
- @Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = true, multiValued = true)
- java.util.List<Long> ids;
-
- @Reference
- private WebContainerService webContainerService;
-
- public void setWebContainerService(WebContainerService webContainerService) {
- this.webContainerService = webContainerService;
- }
-
- @Override
- public Object execute() throws Exception {
- webContainerService.start(ids);
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/command/src/main/java/org/apache/karaf/web/commands/Stop.java
----------------------------------------------------------------------
diff --git a/web/command/src/main/java/org/apache/karaf/web/commands/Stop.java b/web/command/src/main/java/org/apache/karaf/web/commands/Stop.java
deleted file mode 100644
index 76fd141..0000000
--- a/web/command/src/main/java/org/apache/karaf/web/commands/Stop.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.api.action.Action;
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Reference;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.karaf.web.WebContainerService;
-
-@Command(scope = "web", name = "stop", description = "Stop the web context of given bundles.")
-@Service
-public class Stop implements Action {
-
- @Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = true, multiValued = true)
- java.util.List<Long> ids;
-
- @Reference
- private WebContainerService webContainerService;
-
- public void setWebContainerService(WebContainerService webContainerService) {
- this.webContainerService = webContainerService;
- }
-
- @Override
- public Object execute() throws Exception {
- webContainerService.stop(ids);
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/command/src/main/resources/OSGI-INF/bundle.info
----------------------------------------------------------------------
diff --git a/web/command/src/main/resources/OSGI-INF/bundle.info b/web/command/src/main/resources/OSGI-INF/bundle.info
deleted file mode 100644
index 6acb144..0000000
--- a/web/command/src/main/resources/OSGI-INF/bundle.info
+++ /dev/null
@@ -1,21 +0,0 @@
-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
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/core/NOTICE
----------------------------------------------------------------------
diff --git a/web/core/NOTICE b/web/core/NOTICE
deleted file mode 100644
index b70f1f9..0000000
--- a/web/core/NOTICE
+++ /dev/null
@@ -1,71 +0,0 @@
-Apache Karaf
-Copyright 2010-2014 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-OW2 (http://www.ow2.org/).
-Licensed under the BSD License.
-
-This product includes software developed at
-OPS4J (http://www.ops4j.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-Eclipse Foundation (http://www.eclipse.org/).
-Licensed under the EPL.
-
-This product includes software written by
-Antony Lesuisse.
-Licensed under Public Domain.
-
-
-II. Used Software
-
-This product uses software developed at
-FUSE Source (http://www.fusesource.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-AOP Alliance (http://aopalliance.sourceforge.net/).
-Licensed under the Public Domain.
-
-This product uses software developed at
-Tanuki Software (http://www.tanukisoftware.com/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-Jasypt (http://jasypt.sourceforge.net/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-JLine (http://jline.sourceforge.net).
-Licensed under the BSD License.
-
-This product uses software developed at
-SLF4J (http://www.slf4j.org/).
-Licensed under the MIT License.
-
-This product uses software developed at
-SpringSource (http://www.springsource.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software from http://www.json.org.
-Copyright (c) 2002 JSON.org
-
-
-III. License Summary
-- Apache License 2.0
-- BSD License
-- EPL License
-- MIT License
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/core/pom.xml
----------------------------------------------------------------------
diff --git a/web/core/pom.xml b/web/core/pom.xml
deleted file mode 100644
index a6ec17e..0000000
--- a/web/core/pom.xml
+++ /dev/null
@@ -1,106 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.web</groupId>
- <artifactId>web</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>org.apache.karaf.web.core</artifactId>
- <packaging>bundle</packaging>
- <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>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-spi</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf</groupId>
- <artifactId>org.apache.karaf.util</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.info</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.karaf.web,
- org.apache.karaf.web.management
- </Export-Package>
- <Private-Package>
- org.apache.karaf.web.internal,
- org.apache.karaf.web.internal.osgi,
- org.apache.karaf.web.management.internal,
- org.apache.karaf.util.tracker
- </Private-Package>
- <Bundle-Activator>
- org.apache.karaf.web.internal.osgi.Activator
- </Bundle-Activator>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/core/src/main/java/org/apache/karaf/web/WebBundle.java
----------------------------------------------------------------------
diff --git a/web/core/src/main/java/org/apache/karaf/web/WebBundle.java b/web/core/src/main/java/org/apache/karaf/web/WebBundle.java
deleted file mode 100644
index 484495d..0000000
--- a/web/core/src/main/java/org/apache/karaf/web/WebBundle.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/core/src/main/java/org/apache/karaf/web/WebContainerService.java
----------------------------------------------------------------------
diff --git a/web/core/src/main/java/org/apache/karaf/web/WebContainerService.java b/web/core/src/main/java/org/apache/karaf/web/WebContainerService.java
deleted file mode 100644
index 989817b..0000000
--- a/web/core/src/main/java/org/apache/karaf/web/WebContainerService.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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;
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/core/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java
----------------------------------------------------------------------
diff --git a/web/core/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java b/web/core/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java
deleted file mode 100644
index 4affc8f..0000000
--- a/web/core/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * 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.framework.startlevel.BundleStartLevel;
-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 WebEventHandler webEventHandler;
- private WarManager warManager;
-
- private static final Logger LOGGER = LoggerFactory.getLogger(WebContainerServiceImpl.class);
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- 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 = bundle.adapt(BundleStartLevel.class).getStartLevel();
- 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 ";
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/core/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java
----------------------------------------------------------------------
diff --git a/web/core/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java b/web/core/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java
deleted file mode 100644
index 01ef52e..0000000
--- a/web/core/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/core/src/main/java/org/apache/karaf/web/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/web/core/src/main/java/org/apache/karaf/web/internal/osgi/Activator.java b/web/core/src/main/java/org/apache/karaf/web/internal/osgi/Activator.java
deleted file mode 100644
index e5bcfe1..0000000
--- a/web/core/src/main/java/org/apache/karaf/web/internal/osgi/Activator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.osgi;
-
-import org.apache.karaf.util.tracker.BaseActivator;
-import org.apache.karaf.web.WebContainerService;
-import org.apache.karaf.web.internal.WebContainerServiceImpl;
-import org.apache.karaf.web.internal.WebEventHandler;
-import org.apache.karaf.web.management.internal.WebMBeanImpl;
-import org.ops4j.pax.web.service.spi.WarManager;
-import org.ops4j.pax.web.service.spi.WebListener;
-
-public class Activator extends BaseActivator {
-
- @Override
- protected void doOpen() throws Exception {
- trackService(WarManager.class);
- }
-
- @Override
- protected void doStart() throws Exception {
- WarManager warManager = getTrackedService(WarManager.class);
- if (warManager == null) {
- return;
- }
-
- WebEventHandler webEventHandler = new WebEventHandler();
- register(WebListener.class, webEventHandler);
-
- WebContainerServiceImpl webContainerService = new WebContainerServiceImpl();
- webContainerService.setBundleContext(bundleContext);
- webContainerService.setWarManager(warManager);
- webContainerService.setWebEventHandler(webEventHandler);
- register(WebContainerService.class, webContainerService);
-
- WebMBeanImpl webMBean = new WebMBeanImpl();
- webMBean.setWebContainerService(webContainerService);
- registerMBean(webMBean, "type=web");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/core/src/main/java/org/apache/karaf/web/management/WebMBean.java
----------------------------------------------------------------------
diff --git a/web/core/src/main/java/org/apache/karaf/web/management/WebMBean.java b/web/core/src/main/java/org/apache/karaf/web/management/WebMBean.java
deleted file mode 100644
index 5c6df22..0000000
--- a/web/core/src/main/java/org/apache/karaf/web/management/WebMBean.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.management;
-
-import javax.management.MBeanException;
-import javax.management.openmbean.TabularData;
-import java.util.List;
-
-/**
- * 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 MBeanException;
-
- /**
- * Start web context of the given web bundle (identified by ID).
- *
- * @param bundleId the bundle ID.
- * @throws MBeanException
- */
- void start(Long bundleId) throws MBeanException;
-
- /**
- * 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 MBeanException;
-
- /**
- * Stop web context of the given web bundle (identified by ID).
- *
- * @param bundleId the bundle ID.
- * @throws MBeanException
- */
- void stop(Long bundleId) throws MBeanException;
-
- /**
- * Stop 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 stop failure
- */
- void stop(List<Long> bundleIds) throws MBeanException;
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/core/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java
----------------------------------------------------------------------
diff --git a/web/core/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java b/web/core/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java
deleted file mode 100644
index f1a81bb..0000000
--- a/web/core/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.management.internal;
-
-import org.apache.karaf.web.WebBundle;
-import org.apache.karaf.web.WebContainerService;
-import org.apache.karaf.web.management.WebMBean;
-
-import javax.management.MBeanException;
-import javax.management.NotCompliantMBeanException;
-import javax.management.StandardMBean;
-import javax.management.openmbean.*;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Implementation of the Web MBean.
- */
-public class WebMBeanImpl extends StandardMBean implements WebMBean {
-
- private WebContainerService webContainerService;
-
- public WebMBeanImpl() throws NotCompliantMBeanException {
- super(WebMBean.class);
- }
-
- public void setWebContainerService(WebContainerService webContainerService) {
- this.webContainerService = webContainerService;
- }
-
- public TabularData getWebBundles() throws MBeanException {
- try {
- CompositeType webType = new CompositeType("Web Bundle", "An OSGi Web bundle",
- 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.LONG, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.STRING, SimpleType.STRING});
- TabularType tableType = new TabularType("Web Bundles", "Table of web bundles", webType,
- new String[]{"ID"});
- TabularData table = new TabularDataSupport(tableType);
- for (WebBundle webBundle : webContainerService.list()) {
- try {
- CompositeData data = new CompositeDataSupport(webType,
- 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);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return table;
- } catch (Exception e) {
- throw new MBeanException(null, e.getMessage());
- }
- }
-
- public void start(Long bundleId) throws MBeanException {
- try {
- List<Long> list = new ArrayList<Long>();
- list.add(bundleId);
- webContainerService.start(list);
- } catch (Exception e) {
- throw new MBeanException(null, e.getMessage());
- }
- }
-
- public void start(List<Long> bundleIds) throws MBeanException {
- try {
- webContainerService.start(bundleIds);
- } catch (Exception e) {
- throw new MBeanException(null, e.getMessage());
- }
- }
-
- public void stop(Long bundleId) throws MBeanException {
- try {
- List<Long> list = new ArrayList<Long>();
- list.add(bundleId);
- webContainerService.stop(list);
- } catch (Exception e) {
- throw new MBeanException(null, e.getMessage());
- }
- }
-
- public void stop(List<Long> bundleIds) throws MBeanException {
- try {
- webContainerService.stop(bundleIds);
- } catch (Exception e) {
- throw new MBeanException(null, e.getMessage());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/core/src/main/resources/OSGI-INF/bundle.info
----------------------------------------------------------------------
diff --git a/web/core/src/main/resources/OSGI-INF/bundle.info b/web/core/src/main/resources/OSGI-INF/bundle.info
deleted file mode 100644
index 650fee9..0000000
--- a/web/core/src/main/resources/OSGI-INF/bundle.info
+++ /dev/null
@@ -1,16 +0,0 @@
-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
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/pom.xml
----------------------------------------------------------------------
diff --git a/web/pom.xml b/web/pom.xml
index 6284a5c..037ee5f 100644
--- a/web/pom.xml
+++ b/web/pom.xml
@@ -29,13 +29,86 @@
</parent>
<groupId>org.apache.karaf.web</groupId>
- <artifactId>web</artifactId>
- <packaging>pom</packaging>
- <name>Apache Karaf :: Web</name>
-
- <modules>
- <module>core</module>
- <module>command</module>
- </modules>
+ <artifactId>org.apache.karaf.web.core</artifactId>
+ <packaging>bundle</packaging>
+ <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>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-spi</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.util</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.karaf.web,
+ org.apache.karaf.web.management
+ </Export-Package>
+ <Private-Package>
+ org.apache.karaf.web.commands,
+ org.apache.karaf.web.internal,
+ org.apache.karaf.web.internal.osgi,
+ org.apache.karaf.web.management.internal,
+ org.apache.karaf.util.tracker
+ </Private-Package>
+ <Bundle-Activator>
+ org.apache.karaf.web.internal.osgi.Activator
+ </Bundle-Activator>
+ <Karaf-Commands>*</Karaf-Commands>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/src/main/java/org/apache/karaf/web/WebBundle.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/karaf/web/WebBundle.java b/web/src/main/java/org/apache/karaf/web/WebBundle.java
new file mode 100644
index 0000000..484495d
--- /dev/null
+++ b/web/src/main/java/org/apache/karaf/web/WebBundle.java
@@ -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;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/src/main/java/org/apache/karaf/web/WebContainerService.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/karaf/web/WebContainerService.java b/web/src/main/java/org/apache/karaf/web/WebContainerService.java
new file mode 100644
index 0000000..989817b
--- /dev/null
+++ b/web/src/main/java/org/apache/karaf/web/WebContainerService.java
@@ -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;
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/src/main/java/org/apache/karaf/web/commands/List.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/karaf/web/commands/List.java b/web/src/main/java/org/apache/karaf/web/commands/List.java
new file mode 100644
index 0000000..a862a45
--- /dev/null
+++ b/web/src/main/java/org/apache/karaf/web/commands/List.java
@@ -0,0 +1,70 @@
+/*
+ * 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.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.Col;
+import org.apache.karaf.shell.support.table.ShellTable;
+import org.apache.karaf.web.WebBundle;
+import org.apache.karaf.web.WebContainerService;
+
+@Command(scope = "web", name = "list", description = "Lists details for war bundles.")
+@Service
+public class List implements Action {
+
+ @Option(name = "--no-format", description = "Disable table rendered output", required = false, multiValued = false)
+ boolean noFormat;
+
+ @Reference
+ private WebContainerService webContainerService;
+
+ public void setWebContainerService(WebContainerService webContainerService) {
+ this.webContainerService = webContainerService;
+ }
+
+ @Override
+ public Object execute() throws Exception {
+ ShellTable table = new ShellTable();
+ table.column(new Col("ID"));
+ table.column(new Col("State"));
+ table.column(new Col("Web-State"));
+ table.column(new Col("Level"));
+ table.column(new Col("Web-ContextPath"));
+ table.column(new Col("Name"));
+
+ java.util.List<WebBundle> webBundles = webContainerService.list();
+ if (webBundles != null && !webBundles.isEmpty()) {
+ for (WebBundle webBundle : webBundles) {
+ table.addRow().addContent(
+ webBundle.getBundleId(),
+ webBundle.getState(),
+ webBundle.getWebState(),
+ webBundle.getLevel(),
+ webBundle.getContextPath(),
+ webBundle.getName());
+ }
+
+ }
+ table.print(System.out, !noFormat);
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/src/main/java/org/apache/karaf/web/commands/Start.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/karaf/web/commands/Start.java b/web/src/main/java/org/apache/karaf/web/commands/Start.java
new file mode 100644
index 0000000..41d6634
--- /dev/null
+++ b/web/src/main/java/org/apache/karaf/web/commands/Start.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.web.commands;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.web.WebContainerService;
+
+@Command(scope = "web", name = "start", description = "Start the web context of given bundles.")
+@Service
+public class Start implements Action {
+
+ @Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = true, multiValued = true)
+ java.util.List<Long> ids;
+
+ @Reference
+ private WebContainerService webContainerService;
+
+ public void setWebContainerService(WebContainerService webContainerService) {
+ this.webContainerService = webContainerService;
+ }
+
+ @Override
+ public Object execute() throws Exception {
+ webContainerService.start(ids);
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/src/main/java/org/apache/karaf/web/commands/Stop.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/karaf/web/commands/Stop.java b/web/src/main/java/org/apache/karaf/web/commands/Stop.java
new file mode 100644
index 0000000..76fd141
--- /dev/null
+++ b/web/src/main/java/org/apache/karaf/web/commands/Stop.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.web.commands;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.web.WebContainerService;
+
+@Command(scope = "web", name = "stop", description = "Stop the web context of given bundles.")
+@Service
+public class Stop implements Action {
+
+ @Argument(index = 0, name = "ids", description = "The list of bundle IDs separated by whitespaces", required = true, multiValued = true)
+ java.util.List<Long> ids;
+
+ @Reference
+ private WebContainerService webContainerService;
+
+ public void setWebContainerService(WebContainerService webContainerService) {
+ this.webContainerService = webContainerService;
+ }
+
+ @Override
+ public Object execute() throws Exception {
+ webContainerService.stop(ids);
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java b/web/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java
new file mode 100644
index 0000000..4affc8f
--- /dev/null
+++ b/web/src/main/java/org/apache/karaf/web/internal/WebContainerServiceImpl.java
@@ -0,0 +1,205 @@
+/*
+ * 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.framework.startlevel.BundleStartLevel;
+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 WebEventHandler webEventHandler;
+ private WarManager warManager;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(WebContainerServiceImpl.class);
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
+ 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 = bundle.adapt(BundleStartLevel.class).getStartLevel();
+ 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 ";
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java b/web/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java
new file mode 100644
index 0000000..01ef52e
--- /dev/null
+++ b/web/src/main/java/org/apache/karaf/web/internal/WebEventHandler.java
@@ -0,0 +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.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);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/src/main/java/org/apache/karaf/web/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/karaf/web/internal/osgi/Activator.java b/web/src/main/java/org/apache/karaf/web/internal/osgi/Activator.java
new file mode 100644
index 0000000..e5bcfe1
--- /dev/null
+++ b/web/src/main/java/org/apache/karaf/web/internal/osgi/Activator.java
@@ -0,0 +1,55 @@
+/*
+ * 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.osgi;
+
+import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.web.WebContainerService;
+import org.apache.karaf.web.internal.WebContainerServiceImpl;
+import org.apache.karaf.web.internal.WebEventHandler;
+import org.apache.karaf.web.management.internal.WebMBeanImpl;
+import org.ops4j.pax.web.service.spi.WarManager;
+import org.ops4j.pax.web.service.spi.WebListener;
+
+public class Activator extends BaseActivator {
+
+ @Override
+ protected void doOpen() throws Exception {
+ trackService(WarManager.class);
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ WarManager warManager = getTrackedService(WarManager.class);
+ if (warManager == null) {
+ return;
+ }
+
+ WebEventHandler webEventHandler = new WebEventHandler();
+ register(WebListener.class, webEventHandler);
+
+ WebContainerServiceImpl webContainerService = new WebContainerServiceImpl();
+ webContainerService.setBundleContext(bundleContext);
+ webContainerService.setWarManager(warManager);
+ webContainerService.setWebEventHandler(webEventHandler);
+ register(WebContainerService.class, webContainerService);
+
+ WebMBeanImpl webMBean = new WebMBeanImpl();
+ webMBean.setWebContainerService(webContainerService);
+ registerMBean(webMBean, "type=web");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b7e96df/web/src/main/java/org/apache/karaf/web/management/WebMBean.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/karaf/web/management/WebMBean.java b/web/src/main/java/org/apache/karaf/web/management/WebMBean.java
new file mode 100644
index 0000000..5c6df22
--- /dev/null
+++ b/web/src/main/java/org/apache/karaf/web/management/WebMBean.java
@@ -0,0 +1,70 @@
+/*
+ * 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.management;
+
+import javax.management.MBeanException;
+import javax.management.openmbean.TabularData;
+import java.util.List;
+
+/**
+ * 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 MBeanException;
+
+ /**
+ * Start web context of the given web bundle (identified by ID).
+ *
+ * @param bundleId the bundle ID.
+ * @throws MBeanException
+ */
+ void start(Long bundleId) throws MBeanException;
+
+ /**
+ * 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 MBeanException;
+
+ /**
+ * Stop web context of the given web bundle (identified by ID).
+ *
+ * @param bundleId the bundle ID.
+ * @throws MBeanException
+ */
+ void stop(Long bundleId) throws MBeanException;
+
+ /**
+ * Stop 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 stop failure
+ */
+ void stop(List<Long> bundleIds) throws MBeanException;
+
+}