ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1478717 - in /ace/trunk: org.apache.ace.launcher/src/org/apache/ace/launcher/Main.java org.apache.ace.managementagent/src/org/apache/ace/managementagent/Activator.java run-target/target.bndrun
Date Fri, 03 May 2013 10:35:38 GMT
Author: bramk
Date: Fri May  3 10:35:38 2013
New Revision: 1478717

URL: http://svn.apache.org/r1478717
Log:
ACE-323 Formatting / License header

Modified:
    ace/trunk/org.apache.ace.launcher/src/org/apache/ace/launcher/Main.java
    ace/trunk/org.apache.ace.managementagent/src/org/apache/ace/managementagent/Activator.java
    ace/trunk/run-target/target.bndrun

Modified: ace/trunk/org.apache.ace.launcher/src/org/apache/ace/launcher/Main.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.launcher/src/org/apache/ace/launcher/Main.java?rev=1478717&r1=1478716&r2=1478717&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.launcher/src/org/apache/ace/launcher/Main.java (original)
+++ ace/trunk/org.apache.ace.launcher/src/org/apache/ace/launcher/Main.java Fri May  3 10:35:38
2013
@@ -42,47 +42,48 @@ import org.osgi.framework.launch.Framewo
  */
 public class Main {
 
-	private static class AdditionalBundlesOption extends KeyValueArgument {
+    private static class AdditionalBundlesOption extends KeyValueArgument {
         private final List<String> m_additionalBundleActivators;
-        
-		public AdditionalBundlesOption() {
-			super("bundle");
-			
-			m_additionalBundleActivators = new ArrayList<String>();
-		}
-		
-		/**
-		 * @return the additionalBundleActivators
-		 */
-		public List<String> getAdditionalBundleActivators() {
-			return new ArrayList<String>(m_additionalBundleActivators);
-		}
-
-		@Override
-		public String getDescription() {
-			return "bundle: adds an additional bundle to be started with this management agent: bundle=my.fully.qualified.BundleActivator";
-		}
-
-		@Override
-		protected void doHandle(String value) {
-			if (!"".equals(value.trim()) && !m_additionalBundleActivators.contains(value))
{
-				m_additionalBundleActivators.add(value);
-			}
-		}
+
+        public AdditionalBundlesOption() {
+            super("bundle");
+
+            m_additionalBundleActivators = new ArrayList<String>();
+        }
+
+        /**
+         * @return the additionalBundleActivators
+         */
+        public List<String> getAdditionalBundleActivators() {
+            return new ArrayList<String>(m_additionalBundleActivators);
+        }
+
+        @Override
+        public String getDescription() {
+            return "bundle: adds an additional bundle to be started with this management
agent: bundle=my.fully.qualified.BundleActivator";
+        }
+
+        @Override
+        protected void doHandle(String value) {
+            if (!"".equals(value.trim()) && !m_additionalBundleActivators.contains(value))
{
+                m_additionalBundleActivators.add(value);
+            }
+        }
     }
 
     private interface Argument {
         String getDescription();
+
         void handle(String argument);
     }
-    
+
     private static class FrameworkOption extends KeyValueArgument {
-    	private Properties m_properties = new Properties();
-    	
-		public FrameworkOption() {
-			super("fwOption");
-		}
-		
+        private Properties m_properties = new Properties();
+
+        public FrameworkOption() {
+            super("fwOption");
+        }
+
         public String getDescription() {
             return "fwOption: sets framework options for the OSGi framework to be created.
This argument may be repeated";
         }
@@ -103,12 +104,12 @@ public class Main {
     }
 
     private static abstract class KeyValueArgument implements Argument {
-    	protected final String m_key;
-    	
-		public KeyValueArgument(String key) {
-			m_key = key;
-		}
-    	
+        protected final String m_key;
+
+        public KeyValueArgument(String key) {
+            m_key = key;
+        }
+
         public void handle(String argument) {
             Pattern pattern = Pattern.compile(m_key + "=(.*)");
             Matcher m = pattern.matcher(argument);
@@ -121,60 +122,63 @@ public class Main {
     }
 
     private static class SystemPropertyArgument extends KeyValueArgument {
-    	private final String m_description;
-    	
-		public SystemPropertyArgument(String key, String description) {
-			super(key);
-			m_description = description;
-		}
-		
-		@Override
-		public String getDescription() {
-			return m_key + ": " + m_description;
-		}
-		
-		@Override
-		protected void doHandle(String value) {
-			System.setProperty(m_key, value);
-		}
+        private final String m_description;
+
+        public SystemPropertyArgument(String key, String description) {
+            super(key);
+            m_description = description;
+        }
+
+        @Override
+        public String getDescription() {
+            return m_key + ": " + m_description;
+        }
+
+        @Override
+        protected void doHandle(String value) {
+            System.setProperty(m_key, value);
+        }
     }
 
     private static final boolean m_quiet = Boolean.parseBoolean(System.getProperty("quiet",
"false"));
 
-	/**
+    /**
      * MAIN ENTRY POINT
      * 
-     * @param args the command line arguments, never <code>null</code>.
-     * @throws Exception in case of errors.
+     * @param args
+     *            the command line arguments, never <code>null</code>.
+     * @throws Exception
+     *             in case of errors.
      */
     public static void main(String[] args) throws Exception {
         new Main(args).run();
     }
-    
+
     private final FrameworkOption m_fwOptionHandler;
     private final AdditionalBundlesOption m_additionalBundleHandler;
 
-	/**
+    /**
      * Creates a new {@link Main} instance.
      * 
-     * @param args the command line arguments, never <code>null</code>.
+     * @param args
+     *            the command line arguments, never <code>null</code>.
      */
     public Main(String[] args) {
-    	m_additionalBundleHandler = new AdditionalBundlesOption();
-    	m_fwOptionHandler = new FrameworkOption();
-    	
+        m_additionalBundleHandler = new AdditionalBundlesOption();
+        m_fwOptionHandler = new FrameworkOption();
+
         final List<Argument> arguments = new ArrayList<Argument>();
 
-    	Argument agents = new SystemPropertyArgument("agents", "configures multiple management
agents: agent-id,identification,discovery[;agent-id,identification,discovery]*");
+        Argument agents = new SystemPropertyArgument("agents", "configures multiple management
agents: agent-id,identification,discovery[;agent-id,identification,discovery]*");
         Argument auth = new SystemPropertyArgument("auth", "point to the properties file
containing the authentication credentials for a certain subsystem: <dir/file/url>");
         Argument discovery = new SystemPropertyArgument("discovery", "sets the ACE server
to connect to");
         Argument identification = new SystemPropertyArgument("id(?:entification)?", "sets
the target ID to use") {
-        	@Override
-        	protected void doHandle(String value) {
-        		System.setProperty("identification", value);
-        	}
+            @Override
+            protected void doHandle(String value) {
+                System.setProperty("identification", value);
+            }
         };
-    	Argument help = new Argument() {
+        Argument help = new Argument() {
             public String getDescription() {
                 return "help: prints this help message";
             }
@@ -188,29 +192,30 @@ public class Main {
         };
 
         arguments.addAll(Arrays.asList(agents, auth, discovery, identification, m_additionalBundleHandler,
m_fwOptionHandler, help));
-        
+
         for (String arg : args) {
             for (Argument argument : arguments) {
                 argument.handle(arg);
             }
         }
     }
-    
+
     public void run() throws Exception {
         Map frameworkProperties = createFrameworkProperties();
         FrameworkFactory factory = createFrameworkFactory();
-        
+
         Framework framework = factory.newFramework(frameworkProperties);
 
-		framework.start();
+        framework.start();
 
-		try {
-		    framework.waitForStop(0);
-		} finally {
-		    System.exit(0);
-		}
+        try {
+            framework.waitForStop(0);
+        }
+        finally {
+            System.exit(0);
+        }
     }
-    
+
     /**
      * @param extraSystemPackages
      * @return
@@ -235,20 +240,21 @@ public class Main {
      * @return
      */
     private FrameworkFactory createFrameworkFactory() {
-    	try {
-			Class<?> clazz = Class.forName("org.apache.felix.framework.FrameworkFactory");
-			return (FrameworkFactory) clazz.newInstance();
-		} catch (Exception e) {
-    		throw new RuntimeException("Failed to create framework factory?!", e);
-		}
+        try {
+            Class<?> clazz = Class.forName("org.apache.felix.framework.FrameworkFactory");
+            return (FrameworkFactory) clazz.newInstance();
+        }
+        catch (Exception e) {
+            throw new RuntimeException("Failed to create framework factory?!", e);
+        }
     }
 
     /**
-	 * @return
-	 * @throws Exception
-	 */
-	private Map createFrameworkProperties() throws Exception {
-		String[] extraSystemPackageArray = {
+     * @return
+     * @throws Exception
+     */
+    private Map createFrameworkProperties() throws Exception {
+        String[] extraSystemPackageArray = {
             "org.osgi.service.deploymentadmin;version=\"1.0\"",
             "org.osgi.service.deploymentadmin.spi;version=\"1.0\"",
             "org.osgi.service.cm;version=\"1.3\"",
@@ -266,66 +272,68 @@ public class Main {
         frameworkProperties.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, getExtraSystemPackages(extraSystemPackageArray));
         frameworkProperties.putAll(m_fwOptionHandler.getProperties());
 
-		return frameworkProperties;
-	}
-    
+        return frameworkProperties;
+    }
+
     /**
-	 * @return
-	 * @throws IOException
-	 */
-	private List<String> getAdditionalBundleActivators() throws IOException {
-		List<String> bundleActivators = m_additionalBundleHandler.getAdditionalBundleActivators();
-		
-		// The actual management agent itself...
-		bundleActivators.add(0, "org.apache.ace.managementagent.Activator");
-
-    	// Pull in all the additional mentioned bundles on the classpath...
-    	ClassLoader cl = Thread.currentThread().getContextClassLoader();
-    	Enumeration<URL> resources = cl.getResources("META-INF/MANIFEST.MF");
-    	while (resources.hasMoreElements()) {
-    		URL resource = resources.nextElement();
-    		try {
-				Manifest mf = new Manifest(resource.openStream());
-				String bundleActivator = mf.getMainAttributes().getValue(Constants.BUNDLE_ACTIVATOR);
-				if (bundleActivator != null) {
-					bundleActivators.add(bundleActivator);
-				}
-			} catch (Exception e) {
-				System.err.println("Failed to read resource: " + resource + "!\nPossible reason: " +
e);
-			}
-    	}
-		return bundleActivators;
-	}
-    
+     * @return
+     * @throws IOException
+     */
+    private List<String> getAdditionalBundleActivators() throws IOException {
+        List<String> bundleActivators = m_additionalBundleHandler.getAdditionalBundleActivators();
+
+        // The actual management agent itself...
+        bundleActivators.add(0, "org.apache.ace.managementagent.Activator");
+
+        // Pull in all the additional mentioned bundles on the classpath...
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        Enumeration<URL> resources = cl.getResources("META-INF/MANIFEST.MF");
+        while (resources.hasMoreElements()) {
+            URL resource = resources.nextElement();
+            try {
+                Manifest mf = new Manifest(resource.openStream());
+                String bundleActivator = mf.getMainAttributes().getValue(Constants.BUNDLE_ACTIVATOR);
+                if (bundleActivator != null) {
+                    bundleActivators.add(bundleActivator);
+                }
+            }
+            catch (Exception e) {
+                System.err.println("Failed to read resource: " + resource + "!\nPossible
reason: " + e);
+            }
+        }
+        return bundleActivators;
+    }
+
     /**
      * @return
      * @throws Exception
      */
     private List<Object> getSystemBundleActivators() throws Exception {
-    	ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
 
-    	List<Object> result = new ArrayList<Object>();
+        List<Object> result = new ArrayList<Object>();
 
-    	List<String> bundleActivators = getAdditionalBundleActivators();
-    	for (String bundleActivator : bundleActivators) {
-    		try {
-				Object instance = cl.loadClass(bundleActivator).newInstance();
-				if (!m_quiet) {
-					System.out.println("Adding additional bundle activator: " + bundleActivator);
-				}
-				result.add(instance);
-			} catch (Exception e) {
-				System.err.println("Failed to add bundle activator: " + bundleActivator + "!\nPossible
reason: " + e);
-			}
-    	}
+        List<String> bundleActivators = getAdditionalBundleActivators();
+        for (String bundleActivator : bundleActivators) {
+            try {
+                Object instance = cl.loadClass(bundleActivator).newInstance();
+                if (!m_quiet) {
+                    System.out.println("Adding additional bundle activator: " + bundleActivator);
+                }
+                result.add(instance);
+            }
+            catch (Exception e) {
+                System.err.println("Failed to add bundle activator: " + bundleActivator +
"!\nPossible reason: " + e);
+            }
+        }
 
-    	return result;
+        return result;
     }
 
     private void showHelp(List<Argument> arguments) {
         System.out.println("Apache ACE Launcher\n"
-                + "Usage:\n"
-                + "  java -jar ace-launcher.jar [identification=<id>] [discovery=<ace-server>]
[options...]");
+            + "Usage:\n"
+            + "  java -jar ace-launcher.jar [identification=<id>] [discovery=<ace-server>]
[options...]");
 
         System.out.println("All known options are:");
         for (Argument argument : arguments) {
@@ -333,7 +341,7 @@ public class Main {
         }
 
         System.out.println("Example:\n"
-                + "  java -jar ace-launcher.jar identification=MyTarget discovery=http://provisioning.company.com:8080
"
-                + "fwOption=org.osgi.framework.system.packages.extra=sun.misc,com.sun.management");
+            + "  java -jar ace-launcher.jar identification=MyTarget discovery=http://provisioning.company.com:8080
"
+            + "fwOption=org.osgi.framework.system.packages.extra=sun.misc,com.sun.management");
     }
 }

Modified: ace/trunk/org.apache.ace.managementagent/src/org/apache/ace/managementagent/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.managementagent/src/org/apache/ace/managementagent/Activator.java?rev=1478717&r1=1478716&r2=1478717&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.managementagent/src/org/apache/ace/managementagent/Activator.java
(original)
+++ ace/trunk/org.apache.ace.managementagent/src/org/apache/ace/managementagent/Activator.java
Fri May  3 10:35:38 2013
@@ -1,10 +1,27 @@
+/*
+ * 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.ace.managementagent;
 
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
 import java.util.Dictionary;
-import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Properties;
 
@@ -35,7 +52,7 @@ public class Activator extends Dependenc
         new org.apache.felix.deploymentadmin.Activator(),
         new org.apache.felix.eventadmin.impl.Activator()
     };
-    
+
     private volatile ConfigurationAdmin m_config;
 
     /**
@@ -85,7 +102,7 @@ public class Activator extends Dependenc
                 .setService(ConfigurationAdmin.class)
                 .setRequired(true)));
     }
-    
+
     /**
      * Called by the dependency manager when the configuration admin service becomes available.
      */
@@ -111,7 +128,7 @@ public class Activator extends Dependenc
                 // a=name, b=id, c=url
                 String[] definitions = agents.split(";");
                 StringBuffer instances = new StringBuffer();
-                
+
                 for (String definition : definitions) {
                     String[] args = definition.split(",");
                     if (args.length != 3) {
@@ -121,9 +138,9 @@ public class Activator extends Dependenc
                     String ma = args[0];
                     String id = args[1];
                     String url = args[2];
-                    
+
                     boolean isFileUrl = "file".equals((new URL(url)).getProtocol());
-                    
+
                     configureFactory("org.apache.ace.identification.property.factory", "ma",
ma, "targetID", id);
                     configureFactory("org.apache.ace.discovery.property.factory", "ma", ma,
"serverURL", url);
                     // if discovery points to the local filesystem, it's no use trying to
sync the audit log
@@ -136,8 +153,8 @@ public class Activator extends Dependenc
                     configure("org.apache.ace.scheduler", "ma=" + ma + ";name=auditlog",
syncInterval);
                     instances.append(
                         "  Instance     : " + ma + "\n" +
-                        "    Target ID  : " + id + "\n" +
-                        "    Server     : " + url + "\n");
+                            "    Target ID  : " + id + "\n" +
+                            "    Server     : " + url + "\n");
                 }
 
                 if (!m_quiet) {
@@ -151,7 +168,7 @@ public class Activator extends Dependenc
                 String server = System.getProperty("discovery", "http://localhost:8080");
                 String targetId = System.getProperty("identification", "defaultTargetID");
                 boolean isFileUrl = "file".equals((new URL(server)).getProtocol());
-                
+
                 configure("org.apache.ace.discovery.property", "serverURL", server);
                 configure("org.apache.ace.identification.property", "targetID", targetId);
                 if (!isFileUrl) {
@@ -209,7 +226,7 @@ public class Activator extends Dependenc
             conf.update(properties);
         }
     }
-    
+
     private void configureAuth(String factoryPid, String value) throws IOException {
         try {
             File file = new File(value);
@@ -231,14 +248,14 @@ public class Activator extends Dependenc
             System.err.println("Invalid authentication properties for " + value + " (" +
e.getMessage() + ")");
         }
     }
-    
+
     private Properties loadProperties(String factoryPID, File f) throws IOException {
         return loadProperties(factoryPID, f.toURI().toURL());
     }
-    
+
     private Properties loadProperties(String factoryPID, URL url) throws IOException {
         Configuration conf = m_config.createFactoryConfiguration(factoryPID, null);
-        
+
         Properties props = new Properties();
         props.load(url.openStream());
         conf.update((Dictionary<String, ?>) ((Hashtable) props));

Modified: ace/trunk/run-target/target.bndrun
URL: http://svn.apache.org/viewvc/ace/trunk/run-target/target.bndrun?rev=1478717&r1=1478716&r2=1478717&view=diff
==============================================================================
--- ace/trunk/run-target/target.bndrun (original)
+++ ace/trunk/run-target/target.bndrun Fri May  3 10:35:38 2013
@@ -4,7 +4,7 @@
 	org.apache.felix.gogo.runtime,\
 	org.apache.felix.gogo.shell,\
 	org.apache.ace.managementagent;version=latest
--runvm: -Dlog=true -Didentification=target-1 -Ddiscovery=http://localhost:8080
+-runvm: -Dlog=true -Didentification=target-1 -Ddiscovery=http://localhost:8080 -Dquiet=true
-Dsyncinterval=10000
 -runproperties: \
 	org.apache.felix.log.storeDebug=true,\
 	org.apache.felix.eventadmin.Timeout=0,\



Mime
View raw message