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 2012/09/11 16:23:19 UTC
svn commit: r1383427 - in /karaf/trunk/system:
command/src/main/java/org/apache/karaf/system/commands/
command/src/main/resources/OSGI-INF/blueprint/
core/src/main/java/org/apache/karaf/system/
core/src/main/java/org/apache/karaf/system/internal/ core/...
Author: jbonofre
Date: Tue Sep 11 14:23:18 2012
New Revision: 1383427
URL: http://svn.apache.org/viewvc?rev=1383427&view=rev
Log:
[KARAF-1806] Add version attribute in system command and MBean
Added:
karaf/trunk/system/command/src/main/java/org/apache/karaf/system/commands/Version.java
Modified:
karaf/trunk/system/command/src/main/resources/OSGI-INF/blueprint/system-commands.xml
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/SystemServiceImpl.java
karaf/trunk/system/core/src/main/java/org/apache/karaf/system/management/SystemMBean.java
karaf/trunk/system/core/src/main/java/org/apache/karaf/system/management/internal/System.java
karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/system-core.xml
Added: karaf/trunk/system/command/src/main/java/org/apache/karaf/system/commands/Version.java
URL: http://svn.apache.org/viewvc/karaf/trunk/system/command/src/main/java/org/apache/karaf/system/commands/Version.java?rev=1383427&view=auto
==============================================================================
--- karaf/trunk/system/command/src/main/java/org/apache/karaf/system/commands/Version.java (added)
+++ karaf/trunk/system/command/src/main/java/org/apache/karaf/system/commands/Version.java Tue Sep 11 14:23:18 2012
@@ -0,0 +1,29 @@
+/*
+ * 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.commands;
+
+import org.apache.karaf.shell.commands.Command;
+
+@Command(scope = "system", name = "version", description = "Display the instance version")
+public class Version extends AbstractSystemAction {
+
+ protected Object doExecute() throws Exception {
+ System.out.println(systemService.getVersion());
+ return null;
+ }
+
+}
Modified: karaf/trunk/system/command/src/main/resources/OSGI-INF/blueprint/system-commands.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/system/command/src/main/resources/OSGI-INF/blueprint/system-commands.xml?rev=1383427&r1=1383426&r2=1383427&view=diff
==============================================================================
--- karaf/trunk/system/command/src/main/resources/OSGI-INF/blueprint/system-commands.xml (original)
+++ karaf/trunk/system/command/src/main/resources/OSGI-INF/blueprint/system-commands.xml Tue Sep 11 14:23:18 2012
@@ -36,6 +36,11 @@
</action>
</command>
<command>
+ <action class="org.apache.karaf.system.commands.Version">
+ <property name="systemService" ref="systemService"/>
+ </action>
+ </command>
+ <command>
<action class="org.apache.karaf.system.commands.FrameworkOptions" >
<property name="systemService" ref="systemService"/>
</action>
Modified: 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=1383427&r1=1383426&r2=1383427&view=diff
==============================================================================
--- karaf/trunk/system/core/src/main/java/org/apache/karaf/system/SystemService.java (original)
+++ karaf/trunk/system/core/src/main/java/org/apache/karaf/system/SystemService.java Tue Sep 11 14:23:18 2012
@@ -69,13 +69,22 @@ public interface SystemService {
int getStartLevel() throws Exception;
/**
+ * Get the version of the current Karaf instance
+ *
+ * @return instance version
+ */
+ String getVersion();
+
+ /**
* Get the name of the current Karaf instance
+ *
* @return instance name
*/
String getName();
/**
- * Set the name of the Karaf instance
+ * Set the name of the Karaf instance
+ *
* @param name new instance name
*/
void setName(String name);
Modified: 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=1383427&r1=1383426&r2=1383427&view=diff
==============================================================================
--- karaf/trunk/system/core/src/main/java/org/apache/karaf/system/internal/SystemServiceImpl.java (original)
+++ karaf/trunk/system/core/src/main/java/org/apache/karaf/system/internal/SystemServiceImpl.java Tue Sep 11 14:23:18 2012
@@ -146,6 +146,11 @@ public class SystemServiceImpl implement
}
@Override
+ public String getVersion() {
+ return System.getProperty("karaf.version");
+ }
+
+ @Override
public String getName() {
return bundleContext.getProperty("karaf.name");
}
Modified: karaf/trunk/system/core/src/main/java/org/apache/karaf/system/management/SystemMBean.java
URL: http://svn.apache.org/viewvc/karaf/trunk/system/core/src/main/java/org/apache/karaf/system/management/SystemMBean.java?rev=1383427&r1=1383426&r2=1383427&view=diff
==============================================================================
--- karaf/trunk/system/core/src/main/java/org/apache/karaf/system/management/SystemMBean.java (original)
+++ karaf/trunk/system/core/src/main/java/org/apache/karaf/system/management/SystemMBean.java Tue Sep 11 14:23:18 2012
@@ -64,4 +64,11 @@ public interface SystemMBean {
*/
void setName(String name) throws Exception;
+ /**
+ * Get the version of the current Karaf instance.
+ *
+ * @return the current Karaf instance version.
+ */
+ String getVersion();
+
}
Modified: karaf/trunk/system/core/src/main/java/org/apache/karaf/system/management/internal/System.java
URL: http://svn.apache.org/viewvc/karaf/trunk/system/core/src/main/java/org/apache/karaf/system/management/internal/System.java?rev=1383427&r1=1383426&r2=1383427&view=diff
==============================================================================
--- karaf/trunk/system/core/src/main/java/org/apache/karaf/system/management/internal/System.java (original)
+++ karaf/trunk/system/core/src/main/java/org/apache/karaf/system/management/internal/System.java Tue Sep 11 14:23:18 2012
@@ -94,4 +94,9 @@ public class System extends StandardMBea
this.systemService.setName(name);
}
+ @Override
+ public String getVersion() {
+ return this.systemService.getVersion();
+ }
+
}
Modified: karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/system-core.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/system-core.xml?rev=1383427&r1=1383426&r2=1383427&view=diff
==============================================================================
--- karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/system-core.xml (original)
+++ karaf/trunk/system/core/src/main/resources/OSGI-INF/blueprint/system-core.xml Tue Sep 11 14:23:18 2012
@@ -37,4 +37,5 @@
<entry key="jmx.objectname" value="org.apache.karaf:type=system,name=${karaf.name}"/>
</service-properties>
</service>
+
</blueprint>
\ No newline at end of file