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/11/30 22:54:44 UTC
svn commit: r1208819 - in /karaf/trunk: ./ assemblies/features/framework/
assemblies/features/standard/src/main/feature/ management/mbeans/
management/mbeans/system/
management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/
mana...
Author: jbonofre
Date: Wed Nov 30 21:54:26 2011
New Revision: 1208819
URL: http://svn.apache.org/viewvc?rev=1208819&view=rev
Log:
[KARAF-963] Refactoring of the system module
Added:
karaf/trunk/system/
karaf/trunk/system/commands/
karaf/trunk/system/commands/NOTICE
- copied, changed from r1208815, karaf/trunk/management/mbeans/system/NOTICE
karaf/trunk/system/commands/pom.xml
- copied, changed from r1208815, karaf/trunk/shell/system/pom.xml
karaf/trunk/system/commands/src/
karaf/trunk/system/commands/src/main/
karaf/trunk/system/commands/src/main/java/
karaf/trunk/system/commands/src/main/java/org/
karaf/trunk/system/commands/src/main/java/org/apache/
karaf/trunk/system/commands/src/main/java/org/apache/karaf/
karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/
karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/
karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/Shutdown.java
- copied, changed from r1208815, karaf/trunk/shell/system/src/main/java/org/apache/karaf/shell/system/Shutdown.java
karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/StartLevel.java
- copied, changed from r1208815, karaf/trunk/shell/system/src/main/java/org/apache/karaf/shell/system/StartLevel.java
karaf/trunk/system/commands/src/main/resources/
karaf/trunk/system/commands/src/main/resources/OSGI-INF/
karaf/trunk/system/commands/src/main/resources/OSGI-INF/blueprint/
karaf/trunk/system/commands/src/main/resources/OSGI-INF/blueprint/system-commands.xml
- copied, changed from r1208815, karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml
karaf/trunk/system/commands/src/main/resources/OSGI-INF/bundle.info
karaf/trunk/system/core/
karaf/trunk/system/core/NOTICE
- copied, changed from r1208815, karaf/trunk/shell/system/NOTICE
karaf/trunk/system/core/pom.xml
- copied, changed from r1208815, karaf/trunk/management/mbeans/system/pom.xml
karaf/trunk/system/core/src/
karaf/trunk/system/core/src/main/
karaf/trunk/system/core/src/main/java/
karaf/trunk/system/core/src/main/java/org/
karaf/trunk/system/core/src/main/java/org/apache/
karaf/trunk/system/core/src/main/java/org/apache/karaf/
karaf/trunk/system/core/src/main/java/org/apache/karaf/system/
karaf/trunk/system/core/src/main/java/org/apache/karaf/system/SystemService.java
karaf/trunk/system/core/src/main/java/org/apache/karaf/system/internal/
karaf/trunk/system/core/src/main/java/org/apache/karaf/system/internal/SystemServiceImpl.java
karaf/trunk/system/core/src/main/resources/
karaf/trunk/system/core/src/main/resources/OSGI-INF/
karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/
karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/system-core.xml
- copied, changed from r1208815, karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml
karaf/trunk/system/core/src/main/resources/OSGI-INF/bundle.info
karaf/trunk/system/management/
karaf/trunk/system/management/NOTICE
- copied, changed from r1208815, karaf/trunk/management/mbeans/system/NOTICE
karaf/trunk/system/management/pom.xml
- copied, changed from r1208815, karaf/trunk/wrapper/commands/pom.xml
karaf/trunk/system/management/src/
karaf/trunk/system/management/src/main/
karaf/trunk/system/management/src/main/java/
karaf/trunk/system/management/src/main/java/org/
karaf/trunk/system/management/src/main/java/org/apache/
karaf/trunk/system/management/src/main/java/org/apache/karaf/
karaf/trunk/system/management/src/main/java/org/apache/karaf/system/
karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/
karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/SystemMBean.java
- copied, changed from r1208815, karaf/trunk/management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/SystemMBean.java
karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/internal/
karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/internal/SystemMBeanImpl.java
- copied, changed from r1208815, karaf/trunk/management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/internal/SystemMBeanImpl.java
karaf/trunk/system/management/src/main/resources/
karaf/trunk/system/management/src/main/resources/OSGI-INF/
karaf/trunk/system/management/src/main/resources/OSGI-INF/blueprint/
karaf/trunk/system/management/src/main/resources/OSGI-INF/blueprint/system-management.xml
- copied, changed from r1208815, karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml
karaf/trunk/system/management/src/main/resources/OSGI-INF/bundle.info
karaf/trunk/system/pom.xml
- copied, changed from r1208815, karaf/trunk/shell/pom.xml
Removed:
karaf/trunk/management/mbeans/system/NOTICE
karaf/trunk/management/mbeans/system/pom.xml
karaf/trunk/management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/SystemMBean.java
karaf/trunk/management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/internal/SystemMBeanImpl.java
karaf/trunk/management/mbeans/system/src/main/resources/OSGI-INF/blueprint/system-management.xml
karaf/trunk/management/mbeans/system/src/main/resources/OSGI-INF/bundle.info
karaf/trunk/shell/system/NOTICE
karaf/trunk/shell/system/pom.xml
karaf/trunk/shell/system/src/main/java/org/apache/karaf/shell/system/Shutdown.java
karaf/trunk/shell/system/src/main/java/org/apache/karaf/shell/system/StartLevel.java
karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml
karaf/trunk/shell/system/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/pom.xml
karaf/trunk/shell/pom.xml
karaf/trunk/wrapper/commands/pom.xml
Modified: karaf/trunk/assemblies/features/framework/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/framework/pom.xml?rev=1208819&r1=1208818&r2=1208819&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/framework/pom.xml (original)
+++ karaf/trunk/assemblies/features/framework/pom.xml Wed Nov 30 21:54:26 2011
@@ -139,8 +139,12 @@
<artifactId>org.apache.karaf.shell.services</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.system</artifactId>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>org.apache.karaf.system.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>org.apache.karaf.system.commands</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.karaf.shell</groupId>-->
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=1208819&r1=1208818&r2=1208819&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml (original)
+++ karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml Wed Nov 30 21:54:26 2011
@@ -229,7 +229,7 @@
<feature name="management" description="Provide a JMX MBeanServer and a set of MBeans in Karaf" version="${project.version}">
<bundle start-level="30">mvn:org.apache.karaf.management/org.apache.karaf.management.server/${project.version}</bundle>
- <bundle start-level="30">mvn:org.apache.karaf.management.mbeans/org.apache.karaf.management.mbeans.system/${project.version}</bundle>
+ <bundle start-level="30">mvn:org.apache.karaf.system/org.apache.karaf.system.management/${project.version}</bundle>
<bundle start-level="30">mvn:org.apache.karaf.management.mbeans/org.apache.karaf.management.mbeans.bundles/${project.version}</bundle>
<bundle start-level="30">mvn:org.apache.karaf.management.mbeans/org.apache.karaf.management.mbeans.services/${project.version}</bundle>
<bundle start-level="30">mvn:org.apache.karaf.management.mbeans/org.apache.karaf.management.mbeans.packages/${project.version}</bundle>
Modified: karaf/trunk/management/mbeans/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/management/mbeans/pom.xml?rev=1208819&r1=1208818&r2=1208819&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/pom.xml (original)
+++ karaf/trunk/management/mbeans/pom.xml Wed Nov 30 21:54:26 2011
@@ -36,7 +36,6 @@
<modules>
<module>bundles</module>
<module>services</module>
- <module>system</module>
<module>packages</module>
<module>config</module>
<module>dev</module>
Modified: karaf/trunk/manual/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/manual/pom.xml?rev=1208819&r1=1208818&r2=1208819&view=diff
==============================================================================
--- karaf/trunk/manual/pom.xml (original)
+++ karaf/trunk/manual/pom.xml Wed Nov 30 21:54:26 2011
@@ -222,8 +222,13 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.system</artifactId>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>org.apache.karaf.system.commands</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>org.apache.karaf.system.core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -247,6 +252,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.karaf.wrapper</groupId>
+ <artifactId>org.apache.karaf.wrapper.core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.karaf.admin</groupId>
<artifactId>org.apache.karaf.admin.command</artifactId>
<version>${project.version}</version>
Modified: karaf/trunk/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/pom.xml?rev=1208819&r1=1208818&r2=1208819&view=diff
==============================================================================
--- karaf/trunk/pom.xml (original)
+++ karaf/trunk/pom.xml Wed Nov 30 21:54:26 2011
@@ -40,11 +40,12 @@
<module>features</module>
<module>admin</module>
<module>deployer</module>
- <module>wrapper</module>
<module>shell</module>
<module>jaas</module>
<module>client</module>
<module>management</module>
+ <module>system</module>
+ <module>wrapper</module>
<module>webconsole</module>
<module>exception</module>
<module>scheduler</module>
@@ -417,8 +418,18 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.karaf.wrapper</groupId>
- <artifactId>org.apache.karaf.wrapper.core</artifactId>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>org.apache.karaf.system.commands</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>org.apache.karaf.system.core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>org.Apache.karaf.system.management</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -428,6 +439,11 @@
</dependency>
<dependency>
<groupId>org.apache.karaf.wrapper</groupId>
+ <artifactId>org.apache.karaf.wrapper.core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.wrapper</groupId>
<artifactId>org.apache.karaf.wrapper.management</artifactId>
<version>${project.version}</version>
</dependency>
@@ -453,11 +469,6 @@
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.system</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.log</artifactId>
<version>${project.version}</version>
</dependency>
Modified: karaf/trunk/shell/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/pom.xml?rev=1208819&r1=1208818&r2=1208819&view=diff
==============================================================================
--- karaf/trunk/shell/pom.xml (original)
+++ karaf/trunk/shell/pom.xml Wed Nov 30 21:54:26 2011
@@ -44,7 +44,6 @@
<module>obr</module>
<module>services</module>
<module>ssh</module>
- <module>system</module>
<module>web</module>
</modules>
Copied: karaf/trunk/system/commands/NOTICE (from r1208815, karaf/trunk/management/mbeans/system/NOTICE)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/commands/NOTICE?p2=karaf/trunk/system/commands/NOTICE&p1=karaf/trunk/management/mbeans/system/NOTICE&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
(empty)
Copied: karaf/trunk/system/commands/pom.xml (from r1208815, karaf/trunk/shell/system/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/commands/pom.xml?p2=karaf/trunk/system/commands/pom.xml&p1=karaf/trunk/shell/system/pom.xml&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/shell/system/pom.xml (original)
+++ karaf/trunk/system/commands/pom.xml Wed Nov 30 21:54:26 2011
@@ -10,7 +10,7 @@
(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
+ 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,
@@ -22,16 +22,18 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>shell</artifactId>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>system</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>org.apache.karaf.shell.system</artifactId>
+ <artifactId>org.apache.karaf.system.commands</artifactId>
<packaging>bundle</packaging>
- <name>Apache Karaf :: Shell :: System Commands</name>
- <description>This bundle provides shell commands to shutdown the Karaf container.</description>
+ <name>Apache Karaf :: System :: Shell Commands</name>
+ <description>
+ This bundle provides Karaf shell commands to manipulate system service (shutdown container, etc).
+ </description>
<properties>
<appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
@@ -39,32 +41,25 @@
<dependencies>
<dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>org.apache.karaf.system.core</artifactId>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</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>
@@ -78,10 +73,7 @@
<configuration>
<instructions>
<Import-Package>
- !${project.artifactId}*,
- org.apache.aries.blueprint,
- org.osgi.service.blueprint.container,
- org.osgi.service.blueprint.reflect,
+ org.apache.karaf.system,
org.apache.felix.service.command,
org.apache.karaf.shell.commands,
org.apache.karaf.shell.console,
Copied: karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/Shutdown.java (from r1208815, karaf/trunk/shell/system/src/main/java/org/apache/karaf/shell/system/Shutdown.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/Shutdown.java?p2=karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/Shutdown.java&p1=karaf/trunk/shell/system/src/main/java/org/apache/karaf/shell/system/Shutdown.java&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/shell/system/src/main/java/org/apache/karaf/shell/system/Shutdown.java (original)
+++ karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/Shutdown.java Wed Nov 30 21:54:26 2011
@@ -14,21 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.karaf.shell.system;
+package org.apache.karaf.system.commands;
import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.osgi.framework.Bundle;
-
-import java.util.Calendar;
-import java.util.GregorianCalendar;
+import org.apache.karaf.system.SystemService;
/**
- * Command to shut down Karaf
+ * Command to shut down Karaf container.
*/
-@Command(scope = "system", name = "shutdown", description = "Shuts Karaf down.")
+@Command(scope = "system", name = "shutdown", description = "Shutdown Karaf.")
public class Shutdown extends OsgiCommandSupport {
@Option(name = "-f", aliases = "--force", description = "Force the shutdown without confirmation message.", required = false, multiValued = false)
@@ -40,39 +37,15 @@ public class Shutdown extends OsgiComman
" to wait. The word now is an alias for +0.", required = false, multiValued = false)
String time;
- protected Object doExecute() throws Exception {
+ private SystemService systemService;
- long sleep = 0;
- if (time != null) {
- if (!time.equals("now")) {
- if (time.startsWith("+")) {
- // delay in number of minutes provided
- time = time.substring(1);
- try {
- sleep = Long.parseLong(time) * 60 * 1000;
- } catch (Exception e) {
- System.err.println("Invalid time argument.");
- return null;
- }
- } else {
- // try to parse the date in hh:mm
- String[] strings = time.split(":");
- if (strings.length != 2) {
- System.err.println("Invalid time argument.");
- return null;
- }
- GregorianCalendar currentDate = new GregorianCalendar();
- GregorianCalendar shutdownDate = new GregorianCalendar(currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DATE), Integer.parseInt(strings[0]), Integer.parseInt(strings[1]));
- if (shutdownDate.before(currentDate)) {
- shutdownDate.set(Calendar.DATE, shutdownDate.get(Calendar.DATE) + 1);
- }
- sleep = shutdownDate.getTimeInMillis() - currentDate.getTimeInMillis();
- }
- }
- }
+ public void setSystemService(SystemService systemService) {
+ this.systemService = systemService;
+ }
+ protected Object doExecute() throws Exception {
if (force) {
- this.shutdown(sleep);
+ systemService.shutdown(time);
return null;
}
@@ -95,27 +68,10 @@ public class Shutdown extends OsgiComman
}
String str = sb.toString();
if (str.equals("yes")) {
- this.shutdown(sleep);
+ systemService.shutdown(time);
}
return null;
}
}
- private void shutdown(final long sleep) {
- new Thread() {
- public void run() {
- try {
- if (sleep > 0) {
- System.err.println("Shutdown in " + sleep/1000/60 + " minute(s).");
- }
- Thread.sleep(sleep);
- Bundle bundle = getBundleContext().getBundle(0);
- bundle.stop();
- } catch (Exception e) {
- log.error("Error when shutting down", e);
- }
- }
- }.start();
- }
-
}
Copied: karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/StartLevel.java (from r1208815, karaf/trunk/shell/system/src/main/java/org/apache/karaf/shell/system/StartLevel.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/StartLevel.java?p2=karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/StartLevel.java&p1=karaf/trunk/shell/system/src/main/java/org/apache/karaf/shell/system/StartLevel.java&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/shell/system/src/main/java/org/apache/karaf/shell/system/StartLevel.java (original)
+++ karaf/trunk/system/commands/src/main/java/org/apache/karaf/system/commands/StartLevel.java Wed Nov 30 21:54:26 2011
@@ -14,44 +14,35 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.karaf.shell.system;
+package org.apache.karaf.system.commands;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.osgi.framework.ServiceReference;
+import org.apache.karaf.system.SystemService;
+/**
+ * Get/set the system start level.
+ */
@Command(scope = "system", name = "start-level", description = "Gets or sets the system start level.")
public class StartLevel extends OsgiCommandSupport {
@Argument(index = 0, name = "level", description = "The new system start level to set", required = false, multiValued = false)
Integer level;
+ private SystemService systemService;
+
+ public void setSystemService(SystemService systemService) {
+ this.systemService = systemService;
+ }
+
protected Object doExecute() throws Exception {
- // Get package admin service.
- ServiceReference ref = getBundleContext().getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName());
- if (ref == null) {
- System.out.println("StartLevel service is unavailable.");
- return null;
- }
- try {
- org.osgi.service.startlevel.StartLevel sl = (org.osgi.service.startlevel.StartLevel) getBundleContext().getService(ref);
- if (sl == null) {
- System.out.println("StartLevel service is unavailable.");
- return null;
- }
-
- if (level == null) {
- System.out.println("Level " + sl.getStartLevel());
- }
- else {
- sl.setStartLevel(level);
- }
- }
- finally {
- getBundleContext().ungetService(ref);
+ if (level == null) {
+ System.out.println("Level " + systemService.getStartLevel());
+ } else {
+ systemService.setStartLevel(level);
}
return null;
}
-}
\ No newline at end of file
+}
Copied: karaf/trunk/system/commands/src/main/resources/OSGI-INF/blueprint/system-commands.xml (from r1208815, karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/commands/src/main/resources/OSGI-INF/blueprint/system-commands.xml?p2=karaf/trunk/system/commands/src/main/resources/OSGI-INF/blueprint/system-commands.xml&p1=karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml (original)
+++ karaf/trunk/system/commands/src/main/resources/OSGI-INF/blueprint/system-commands.xml Wed Nov 30 21:54:26 2011
@@ -21,11 +21,17 @@
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
<command>
- <action class="org.apache.karaf.shell.system.Shutdown"/>
+ <action class="org.apache.karaf.system.commands.Shutdown">
+ <property name="systemService" ref="systemService"/>
+ </action>
</command>
<command>
- <action class="org.apache.karaf.shell.system.StartLevel"/>
+ <action class="org.apache.karaf.system.commands.StartLevel">
+ <property name="systemService" ref="systemService"/>
+ </action>
</command>
</command-bundle>
+ <reference id="systemService" interface="org.apache.karaf.system.SystemService"/>
+
</blueprint>
\ No newline at end of file
Added: karaf/trunk/system/commands/src/main/resources/OSGI-INF/bundle.info
URL: http://svn.apache.org/viewvc/karaf/trunk/system/commands/src/main/resources/OSGI-INF/bundle.info?rev=1208819&view=auto
==============================================================================
--- karaf/trunk/system/commands/src/main/resources/OSGI-INF/bundle.info (added)
+++ karaf/trunk/system/commands/src/main/resources/OSGI-INF/bundle.info Wed Nov 30 21:54:26 2011
@@ -0,0 +1,20 @@
+h1. Synopsis
+
+${project.name}
+
+${project.description}
+
+Maven URL:
+[mvn:${project.groupId}/${project.artifactId}/${project.version}]
+
+h1. Description
+
+This bundle contains all Karaf system shell commands.
+
+The following commands are available:
+* system:shutdown - Shutdown the Karaf container.
+* syste:start-level - Gets or sets the Karaf system start level.
+
+h1. See also
+
+Shutdown Karaf - section of the Karaf User Guide.
\ No newline at end of file
Copied: karaf/trunk/system/core/NOTICE (from r1208815, karaf/trunk/shell/system/NOTICE)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/core/NOTICE?p2=karaf/trunk/system/core/NOTICE&p1=karaf/trunk/shell/system/NOTICE&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
(empty)
Copied: karaf/trunk/system/core/pom.xml (from r1208815, karaf/trunk/management/mbeans/system/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/core/pom.xml?p2=karaf/trunk/system/core/pom.xml&p1=karaf/trunk/management/mbeans/system/pom.xml&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/system/pom.xml (original)
+++ karaf/trunk/system/core/pom.xml Wed Nov 30 21:54:26 2011
@@ -10,7 +10,7 @@
(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
+ 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,
@@ -22,19 +22,21 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.karaf.management.mbeans</groupId>
- <artifactId>mbeans</artifactId>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>system</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>org.apache.karaf.management.mbeans.system</artifactId>
+ <artifactId>org.apache.karaf.system.core</artifactId>
<packaging>bundle</packaging>
- <name>Apache Karaf :: Management :: MBeans :: System</name>
- <description>The System MBean bundle provides a JMX MBean to manipulate the Karaf system container.</description>
+ <name>Apache Karaf :: System :: Core</name>
+ <description>
+ This bundle provides services to manipulate the Karaf container itself (system).
+ </description>
<properties>
- <appendedResourcesDirectory>${basedir}/../../../etc/appended-resources/</appendedResourcesDirectory>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
</properties>
<dependencies>
@@ -43,18 +45,23 @@
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</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>
@@ -68,21 +75,14 @@
<configuration>
<instructions>
<Export-Package>
- org.apache.karaf.management.mbeans.system;version=${project.version}
+ org.apache.karaf.system;version=${project.version}
</Export-Package>
<Import-Package>
- !org.apache.karaf.management.mbeans.system,
- 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.system*,
*
</Import-Package>
<Private-Package>
- org.apache.karaf.management.mbeans.system.internal,
- !*
+ org.apache.karaf.system.internal
</Private-Package>
</instructions>
</configuration>
Added: karaf/trunk/system/core/src/main/java/org/apache/karaf/system/SystemService.java
URL: http://svn.apache.org/viewvc/karaf/trunk/system/core/src/main/java/org/apache/karaf/system/SystemService.java?rev=1208819&view=auto
==============================================================================
--- karaf/trunk/system/core/src/main/java/org/apache/karaf/system/SystemService.java (added)
+++ karaf/trunk/system/core/src/main/java/org/apache/karaf/system/SystemService.java Wed Nov 30 21:54:26 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.system;
+
+/**
+ * Describe a system service
+ */
+public interface SystemService {
+
+ /**
+ * Shutdown the Karaf container.
+ */
+ void shutdown() throws Exception;
+
+ /**
+ * Shutdown the Karaf container.
+ *
+ * @param time shutdown delay. The time argument can have different formats.
+ * First, it can be an abolute time in the format hh:mm, in which hh is the hour (1 or 2 digits) and mm
+ * is the minute of the hour (in two digits). Second, it can be in the format +m, in which m is the number of minutes
+ * to wait. The word now is an alias for +0.
+ */
+ void shutdown(String time) throws Exception;
+
+ /**
+ * Set the system start level.
+ *
+ * @param startLevel the new system start level.
+ */
+ void setStartLevel(int startLevel) throws Exception;
+
+ /**
+ * Get the system start level.
+ *
+ * @return the current system start level.
+ */
+ int getStartLevel() throws Exception;
+
+}
Added: karaf/trunk/system/core/src/main/java/org/apache/karaf/system/internal/SystemServiceImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/system/core/src/main/java/org/apache/karaf/system/internal/SystemServiceImpl.java?rev=1208819&view=auto
==============================================================================
--- karaf/trunk/system/core/src/main/java/org/apache/karaf/system/internal/SystemServiceImpl.java (added)
+++ karaf/trunk/system/core/src/main/java/org/apache/karaf/system/internal/SystemServiceImpl.java Wed Nov 30 21:54:26 2011
@@ -0,0 +1,131 @@
+/*
+* 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.system.internal;
+
+import org.apache.karaf.system.SystemService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+/**
+ * Implementation of the system service.
+ */
+public class SystemServiceImpl implements SystemService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SystemServiceImpl.class);
+
+ private BundleContext bundleContext;
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
+ public BundleContext getBundleContext() {
+ return this.bundleContext;
+ }
+
+ public void shutdown() throws Exception {
+ shutdown(null);
+ }
+
+ public void shutdown(String time) throws Exception {
+ long sleep = 0;
+ if (time != null) {
+ if (!time.equals("now")) {
+ if (time.startsWith("+")) {
+ // delay in number of minutes provided
+ time = time.substring(1);
+ try {
+ sleep = Long.parseLong(time) * 60 * 1000;
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Time " + time + " is not valid");
+ }
+ } else {
+ // try to parse the date in hh:mm
+ String[] strings = time.split(":");
+ if (strings.length != 2) {
+ throw new IllegalArgumentException("Time " + time + " is not valid");
+ }
+ GregorianCalendar currentDate = new GregorianCalendar();
+ GregorianCalendar shutdownDate = new GregorianCalendar(currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DATE), Integer.parseInt(strings[0]), Integer.parseInt(strings[1]));
+ if (shutdownDate.before(currentDate)) {
+ shutdownDate.set(Calendar.DATE, shutdownDate.get(Calendar.DATE) + 1);
+ }
+ sleep = shutdownDate.getTimeInMillis() - currentDate.getTimeInMillis();
+ }
+ }
+ }
+ shutdown(sleep);
+ }
+
+ private void shutdown(final long sleep) {
+ new Thread() {
+ public void run() {
+ try {
+ if (sleep > 0) {
+ LOGGER.info("Shutdown in " + sleep / 1000 / 60 + " minute(s)");
+ }
+ Thread.sleep(sleep);
+ Bundle bundle = getBundleContext().getBundle(0);
+ bundle.stop();
+ } catch (Exception e) {
+ LOGGER.error("Error when shutting down", e);
+ }
+ }
+ }.start();
+ }
+
+ public void setStartLevel(int startLevel) throws Exception {
+ // get start level service
+ ServiceReference ref = bundleContext.getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName());
+ if (ref == null) {
+ throw new IllegalStateException("StartLevel service is unavailable");
+ }
+ try {
+ org.osgi.service.startlevel.StartLevel startLevelService = (org.osgi.service.startlevel.StartLevel) bundleContext.getService(ref);
+ if (startLevelService == null) {
+ throw new IllegalStateException("StartLevel service is unavailable");
+ }
+ startLevelService.setStartLevel(startLevel);
+ } finally {
+ bundleContext.ungetService(ref);
+ }
+ }
+
+ public int getStartLevel() throws Exception {
+ // get start level service
+ ServiceReference ref = bundleContext.getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName());
+ if (ref == null) {
+ throw new IllegalStateException("StartLevel service is unavailable");
+ }
+ try {
+ org.osgi.service.startlevel.StartLevel startLevelService = (org.osgi.service.startlevel.StartLevel) bundleContext.getService(ref);
+ if (startLevelService == null) {
+ throw new IllegalStateException("StartLevel service is unavailable");
+ }
+ return startLevelService.getStartLevel();
+ } finally {
+ bundleContext.ungetService(ref);
+ }
+ }
+
+}
Copied: karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/system-core.xml (from r1208815, karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/system-core.xml?p2=karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/system-core.xml&p1=karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml (original)
+++ karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/system-core.xml Wed Nov 30 21:54:26 2011
@@ -19,13 +19,10 @@
-->
<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.shell.system.Shutdown"/>
- </command>
- <command>
- <action class="org.apache.karaf.shell.system.StartLevel"/>
- </command>
- </command-bundle>
+ <bean id="systemService" class="org.apache.karaf.system.internal.SystemServiceImpl">
+ <property name="bundleContext" ref="blueprintBundleContext"/>
+ </bean>
+
+ <service ref="systemService" interface="org.apache.karaf.system.SystemService"/>
</blueprint>
\ No newline at end of file
Added: karaf/trunk/system/core/src/main/resources/OSGI-INF/bundle.info
URL: http://svn.apache.org/viewvc/karaf/trunk/system/core/src/main/resources/OSGI-INF/bundle.info?rev=1208819&view=auto
==============================================================================
--- karaf/trunk/system/core/src/main/resources/OSGI-INF/bundle.info (added)
+++ karaf/trunk/system/core/src/main/resources/OSGI-INF/bundle.info Wed Nov 30 21:54:26 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 system service, which control the Karaf container.
+
+h1. See also
+
+Shutdown - section of the Karaf User Guide
Copied: karaf/trunk/system/management/NOTICE (from r1208815, karaf/trunk/management/mbeans/system/NOTICE)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/management/NOTICE?p2=karaf/trunk/system/management/NOTICE&p1=karaf/trunk/management/mbeans/system/NOTICE&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
(empty)
Copied: karaf/trunk/system/management/pom.xml (from r1208815, karaf/trunk/wrapper/commands/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/management/pom.xml?p2=karaf/trunk/system/management/pom.xml&p1=karaf/trunk/wrapper/commands/pom.xml&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/wrapper/commands/pom.xml (original)
+++ karaf/trunk/system/management/pom.xml Wed Nov 30 21:54:26 2011
@@ -22,17 +22,17 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.karaf.wrapper</groupId>
- <artifactId>wrapper</artifactId>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>system</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>org.apache.karaf.wrapper.commands</artifactId>
+ <artifactId>org.apache.karaf.system.management</artifactId>
<packaging>bundle</packaging>
- <name>Apache Karaf :: Wrapper :: Shell Commands</name>
+ <name>Apache Karaf :: System :: Management</name>
<description>
- This bundle provides Karaf shell commands to manipulate the OS service wrapper.
+ This bundle provides MBean to manipulate the system service.
</description>
<properties>
@@ -41,12 +41,8 @@
<dependencies>
<dependency>
- <groupId>org.apache.karaf.wrapper</groupId>
- <artifactId>org.apache.karaf.wrapper.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>org.apache.karaf.system.core</artifactId>
</dependency>
</dependencies>
@@ -73,16 +69,10 @@
<configuration>
<instructions>
<Import-Package>
- !org.apache.karaf.wrapper.internal,
- org.apache.karaf.wrapper,
+ !${project.artifactId}*,
javax.management,
- javax.management.loading,
- 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.management,
+ org.apache.karaf.system,
*
</Import-Package>
</instructions>
Copied: karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/SystemMBean.java (from r1208815, karaf/trunk/management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/SystemMBean.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/SystemMBean.java?p2=karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/SystemMBean.java&p1=karaf/trunk/management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/SystemMBean.java&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/SystemMBean.java (original)
+++ karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/SystemMBean.java Wed Nov 30 21:54:26 2011
@@ -14,13 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.karaf.management.mbeans.system;
+package org.apache.karaf.system.management;
/**
- * System MBean.
+ * Describe the system MBean.
*/
public interface SystemMBean {
void shutdown() throws Exception;
+ void shutdown(String time) throws Exception;
+
+ void setStartLevel(int startLevel) throws Exception;
+ int getStartLevel() throws Exception;
}
Copied: karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/internal/SystemMBeanImpl.java (from r1208815, karaf/trunk/management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/internal/SystemMBeanImpl.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/internal/SystemMBeanImpl.java?p2=karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/internal/SystemMBeanImpl.java&p1=karaf/trunk/management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/internal/SystemMBeanImpl.java&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/management/mbeans/system/src/main/java/org/apache/karaf/management/mbeans/system/internal/SystemMBeanImpl.java (original)
+++ karaf/trunk/system/management/src/main/java/org/apache/karaf/system/management/internal/SystemMBeanImpl.java Wed Nov 30 21:54:26 2011
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.karaf.management.mbeans.system.internal;
+package org.apache.karaf.system.management.internal;
-import org.apache.karaf.management.mbeans.system.SystemMBean;
-import org.osgi.framework.BundleContext;
+import org.apache.karaf.system.SystemService;
+import org.apache.karaf.system.management.SystemMBean;
import javax.management.NotCompliantMBeanException;
import javax.management.StandardMBean;
@@ -27,22 +27,34 @@ import javax.management.StandardMBean;
*/
public class SystemMBeanImpl extends StandardMBean implements SystemMBean {
- private BundleContext bundleContext;
+ private SystemService systemService;
public SystemMBeanImpl() throws NotCompliantMBeanException {
super(SystemMBean.class);
}
+ public void setSystemService(SystemService systemService) {
+ this.systemService = systemService;
+ }
+
+ public SystemService getSystemService() {
+ return this.systemService;
+ }
+
public void shutdown() throws Exception {
- bundleContext.getBundle(0).stop();
+ systemService.shutdown();
+ }
+
+ public void shutdown(String time) throws Exception {
+ systemService.shutdown(time);
}
- public BundleContext getBundleContext() {
- return this.bundleContext;
+ public void setStartLevel(int startLevel) throws Exception {
+ systemService.setStartLevel(startLevel);
}
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
+ public int getStartLevel() throws Exception {
+ return systemService.getStartLevel();
}
}
Copied: karaf/trunk/system/management/src/main/resources/OSGI-INF/blueprint/system-management.xml (from r1208815, karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/management/src/main/resources/OSGI-INF/blueprint/system-management.xml?p2=karaf/trunk/system/management/src/main/resources/OSGI-INF/blueprint/system-management.xml&p1=karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/shell/system/src/main/resources/OSGI-INF/blueprint/shell-system.xml (original)
+++ karaf/trunk/system/management/src/main/resources/OSGI-INF/blueprint/system-management.xml Wed Nov 30 21:54:26 2011
@@ -17,15 +17,24 @@
limitations under the License.
-->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="eager">
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
- <command>
- <action class="org.apache.karaf.shell.system.Shutdown"/>
- </command>
- <command>
- <action class="org.apache.karaf.shell.system.StartLevel"/>
- </command>
- </command-bundle>
+ <reference id="systemService" interface="org.apache.karaf.system.SystemService"/>
+
+ <reference id="mbeanService" interface="javax.management.MBeanServer">
+ <reference-listener ref="mbeanRegister" bind-method="registerMBeanServer" unbind-method="unregisterMBeanServer" />
+ </reference>
+
+ <bean id="systemMBean" class="org.apache.karaf.system.management.internal.SystemMBeanImpl">
+ <property name="systemService" ref="systemService" />
+ </bean>
+
+ <bean id="mbeanRegister" class="org.apache.karaf.management.MBeanRegistrer">
+ <property name="mbeans">
+ <map>
+ <entry value="org.apache.karaf:type=system,name=${karaf.name}" key-ref="systemMBean" />
+ </map>
+ </property>
+ </bean>
</blueprint>
\ No newline at end of file
Added: karaf/trunk/system/management/src/main/resources/OSGI-INF/bundle.info
URL: http://svn.apache.org/viewvc/karaf/trunk/system/management/src/main/resources/OSGI-INF/bundle.info?rev=1208819&view=auto
==============================================================================
--- karaf/trunk/system/management/src/main/resources/OSGI-INF/bundle.info (added)
+++ karaf/trunk/system/management/src/main/resources/OSGI-INF/bundle.info Wed Nov 30 21:54:26 2011
@@ -0,0 +1,25 @@
+h1. Synopsis
+
+${project.name}
+
+${project.description}
+
+Maven URL:
+[mvn:${project.groupId}/${project.artifactId}/${project.version}]
+
+h1. Description
+
+This bundle provides JMX MBeans related to the Karaf system service.
+
+In particular, a SystemMBean is provided that can be remotely administered using a JMX client (for instance
+JConsole).
+
+With this SystemMBean, you have the following operations available:
+* shutdown() - Shutdown the Karaf container.
+* shutdown(time) - Shutdown the Karaf container as a given time.
+* setStartLevel(startLevel) - Set the Karaf system start level.
+* getStartLevel() - Get the Karaf system start level.
+
+h1. See also
+
+Remote Management via JMX - in the Karaf User Guide.
Copied: karaf/trunk/system/pom.xml (from r1208815, karaf/trunk/shell/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/system/pom.xml?p2=karaf/trunk/system/pom.xml&p1=karaf/trunk/shell/pom.xml&r1=1208815&r2=1208819&rev=1208819&view=diff
==============================================================================
--- karaf/trunk/shell/pom.xml (original)
+++ karaf/trunk/system/pom.xml Wed Nov 30 21:54:26 2011
@@ -10,7 +10,7 @@
(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
+ 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,
@@ -28,25 +28,15 @@
<relativePath>../pom.xml</relativePath>
</parent>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>shell</artifactId>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>system</artifactId>
<packaging>pom</packaging>
- <name>Apache Karaf :: Shell</name>
+ <name>Apache Karaf :: System</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>system</module>
- <module>web</module>
+ <module>management</module>
</modules>
-</project>
-
+</project>
\ No newline at end of file
Modified: karaf/trunk/wrapper/commands/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/wrapper/commands/pom.xml?rev=1208819&r1=1208818&r2=1208819&view=diff
==============================================================================
--- karaf/trunk/wrapper/commands/pom.xml (original)
+++ karaf/trunk/wrapper/commands/pom.xml Wed Nov 30 21:54:26 2011
@@ -43,10 +43,12 @@
<dependency>
<groupId>org.apache.karaf.wrapper</groupId>
<artifactId>org.apache.karaf.wrapper.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>