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 2013/11/25 14:27:45 UTC
svn commit: r1545265 - in /karaf/trunk/web/core/src/main:
java/org/apache/karaf/web/management/
java/org/apache/karaf/web/management/internal/ resources/OSGI-INF/blueprint/
Author: jbonofre
Date: Mon Nov 25 13:27:45 2013
New Revision: 1545265
URL: http://svn.apache.org/r1545265
Log:
[KARAF-2264] Rename Web to WebMBeanImpl and wrap exceptions as MBeanException
Added:
karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java
Removed:
karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/internal/Web.java
Modified:
karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/WebMBean.java
karaf/trunk/web/core/src/main/resources/OSGI-INF/blueprint/web-core.xml
Modified: karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/WebMBean.java
URL: http://svn.apache.org/viewvc/karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/WebMBean.java?rev=1545265&r1=1545264&r2=1545265&view=diff
==============================================================================
--- karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/WebMBean.java (original)
+++ karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/WebMBean.java Mon Nov 25 13:27:45 2013
@@ -16,11 +16,12 @@
*/
package org.apache.karaf.web.management;
+import javax.management.MBeanException;
import javax.management.openmbean.TabularData;
import java.util.List;
/**
- * Describe the web MBean.
+ * Describe the Web MBean.
*/
public interface WebMBean {
@@ -30,7 +31,7 @@ public interface WebMBean {
* @return a tabular data of web bundles.
* @throws Exception in case of lookup failure.
*/
- TabularData getWebBundles() throws Exception;
+ TabularData getWebBundles() throws MBeanException;
/**
* Start web context of the given web bundles (identified by ID).
@@ -39,7 +40,7 @@ public interface WebMBean {
* TODO use a BundleSelector service
* @throws Exception in case of start failure.
*/
- void start(List<Long> bundleIds) throws Exception;
+ void start(List<Long> bundleIds) throws MBeanException;
/**
* Stop web contact of the given web bundles (identified by ID).
@@ -48,6 +49,6 @@ public interface WebMBean {
* TODO use a BundleSelector service
* @throws Exception in case of stop failure
*/
- void stop(List<Long> bundleIds) throws Exception;
+ void stop(List<Long> bundleIds) throws MBeanException;
}
Added: karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java?rev=1545265&view=auto
==============================================================================
--- karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java (added)
+++ karaf/trunk/web/core/src/main/java/org/apache/karaf/web/management/internal/WebMBeanImpl.java Mon Nov 25 13:27:45 2013
@@ -0,0 +1,95 @@
+/*
+ * 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.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(List<Long> bundleIds) throws MBeanException {
+ try {
+ webContainerService.start(bundleIds);
+ } 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());
+ }
+ }
+
+}
Modified: 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=1545265&r1=1545264&r2=1545265&view=diff
==============================================================================
--- karaf/trunk/web/core/src/main/resources/OSGI-INF/blueprint/web-core.xml (original)
+++ karaf/trunk/web/core/src/main/resources/OSGI-INF/blueprint/web-core.xml Mon Nov 25 13:27:45 2013
@@ -38,7 +38,7 @@
<service ref="webContainerService" interface="org.apache.karaf.web.WebContainerService"/>
- <bean id="webMBean" class="org.apache.karaf.web.management.internal.Web">
+ <bean id="webMBean" class="org.apache.karaf.web.management.internal.WebMBeanImpl">
<property name="webContainerService" ref="webContainerService"/>
</bean>