Index: src/main/java/org/apache/karaf/shell/dev/DumpProperties.java =================================================================== --- src/main/java/org/apache/karaf/shell/dev/DumpProperties.java (revisione 0) +++ src/main/java/org/apache/karaf/shell/dev/DumpProperties.java (copia locale) @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.karaf.shell.dev; + +import java.io.File; +import java.io.PrintStream; +import java.text.SimpleDateFormat; +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.Properties; +import java.util.Set; +import java.util.Vector; + +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.gogo.commands.Option; +import org.apache.karaf.shell.console.OsgiCommandSupport; +import org.osgi.framework.Constants; + +/** + * A command to restart karaf + */ +@Command(scope = "dev", name = "dump-properties", description = "Print all the properties on the console") +public class DumpProperties extends OsgiCommandSupport { + + @Option(name = "-f", aliases = { "--file-dump" }, description = "Dump everything to file") + private boolean dumpToFile; + + @Option(name = "-u", aliases = { "--show-unset" }, description = "Show unset properties with value unset") + private boolean unset; + + @Override + protected Object doExecute() throws Exception { + Properties props = (Properties) System.getProperties().clone(); + + String def = null; + if ( unset ) { + def = "unset"; + } + + setProperty(props, Constants.FRAMEWORK_BEGINNING_STARTLEVEL, def); + setProperty(props, Constants.FRAMEWORK_BOOTDELEGATION, def); + setProperty(props, Constants.FRAMEWORK_BUNDLE_PARENT, def); + setProperty(props, Constants.FRAMEWORK_BUNDLE_PARENT_APP, def); + setProperty(props, Constants.FRAMEWORK_BUNDLE_PARENT_BOOT, def); + setProperty(props, Constants.FRAMEWORK_BUNDLE_PARENT_EXT, def); + setProperty(props, Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK, def); + setProperty(props, Constants.FRAMEWORK_EXECPERMISSION, def); + setProperty(props, Constants.FRAMEWORK_EXECUTIONENVIRONMENT, def); + setProperty(props, Constants.FRAMEWORK_LANGUAGE, def); + setProperty(props, Constants.FRAMEWORK_LIBRARY_EXTENSIONS, def); + setProperty(props, Constants.FRAMEWORK_OS_NAME, def); + setProperty(props, Constants.FRAMEWORK_OS_VERSION, def); + setProperty(props, Constants.FRAMEWORK_PROCESSOR, def); + setProperty(props, Constants.FRAMEWORK_SECURITY, def); + setProperty(props, Constants.FRAMEWORK_SECURITY_OSGI, def); + setProperty(props, Constants.FRAMEWORK_STORAGE, def); + setProperty(props, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT, def); + setProperty(props, Constants.FRAMEWORK_SYSTEMPACKAGES, def); + setProperty(props, Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, def); + setProperty(props, Constants.FRAMEWORK_VENDOR, def); + setProperty(props, Constants.FRAMEWORK_VERSION, def); + setProperty(props, Constants.FRAMEWORK_WINDOWSYSTEM, def); + + setProperty(props, Constants.SUPPORTS_BOOTCLASSPATH_EXTENSION, def); + setProperty(props, Constants.SUPPORTS_FRAMEWORK_EXTENSION, def); + setProperty(props, Constants.SUPPORTS_FRAMEWORK_FRAGMENT, def); + setProperty(props, Constants.SUPPORTS_FRAMEWORK_REQUIREBUNDLE, def); + + + if (dumpToFile ) { + PrintStream ps = new PrintStream( + new File( + bundleContext.getProperty("karaf.data"), + "dump-properties-"+System.currentTimeMillis()+".properties" + ) + ); + ps.println("#Dump of the System and OSGi properties with the command dev:dump-properties"); + ps.println("#Dump execute at "+ new SimpleDateFormat().format(new Date())); + printOrderedProperties(props, ps); + ps.flush(); + ps.close(); + } else { + System.out.println("Dumping OSGi and System properties"); + printOrderedProperties(props, System.out); + } + + return null; + } + + private void printOrderedProperties(Properties props, PrintStream out) { + Set keys = props.keySet(); + Vector order = new Vector(keys.size()); + for (Iterator i = keys.iterator(); i.hasNext();) { + Object str = (Object) i.next(); + order.add((String) str); + } + Collections.sort(order); + for (Iterator i = order.iterator(); i.hasNext();) { + String key = (String) i.next(); + out.println(key+"="+props.getProperty(key)); + } + } + + private void setProperty(Properties props, String key, String def) { + String val = bundleContext.getProperty(key); + if ( val == null && def != null) { + props.setProperty(key, def); + } else if ( val != null ) { + props.setProperty(key, val); + } + } +} Proprietà modificate su: src/main/java/org/apache/karaf/shell/dev/DumpProperties.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Date Author Id Revision HeadURL \ No newline at end of property Index: src/main/resources/OSGI-INF/blueprint/shell-dev.xml =================================================================== --- src/main/resources/OSGI-INF/blueprint/shell-dev.xml (revisione 1523208) +++ src/main/resources/OSGI-INF/blueprint/shell-dev.xml (copia locale) @@ -40,6 +40,9 @@ + + +