You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/12/17 13:15:27 UTC

svn commit: r604849 - in /servicemix/smx4/runtime/trunk: ./ bundles/ant/ bundles/aopalliance/ bundles/asm/ bundles/cglib/ bundles/mina/ bundles/xstream/ main/ main/src/main/java/org/apache/servicemix/runtime/main/

Author: gnodet
Date: Mon Dec 17 04:15:26 2007
New Revision: 604849

URL: http://svn.apache.org/viewvc?rev=604849&view=rev
Log:
Fix junit use, fix main due do latest felix changes, revert to pax-logging 0.9.8 until RC is fixed

Modified:
    servicemix/smx4/runtime/trunk/bundles/ant/pom.xml
    servicemix/smx4/runtime/trunk/bundles/aopalliance/pom.xml
    servicemix/smx4/runtime/trunk/bundles/asm/pom.xml
    servicemix/smx4/runtime/trunk/bundles/cglib/pom.xml
    servicemix/smx4/runtime/trunk/bundles/mina/pom.xml
    servicemix/smx4/runtime/trunk/bundles/xstream/pom.xml
    servicemix/smx4/runtime/trunk/main/pom.xml
    servicemix/smx4/runtime/trunk/main/src/main/java/org/apache/servicemix/runtime/main/Main.java
    servicemix/smx4/runtime/trunk/pom.xml

Modified: servicemix/smx4/runtime/trunk/bundles/ant/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/bundles/ant/pom.xml?rev=604849&r1=604848&r2=604849&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/bundles/ant/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/bundles/ant/pom.xml Mon Dec 17 04:15:26 2007
@@ -71,6 +71,12 @@
             <version>${pkgVersion}</version>
             <optional>true</optional>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

Modified: servicemix/smx4/runtime/trunk/bundles/aopalliance/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/bundles/aopalliance/pom.xml?rev=604849&r1=604848&r2=604849&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/bundles/aopalliance/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/bundles/aopalliance/pom.xml Mon Dec 17 04:15:26 2007
@@ -49,6 +49,12 @@
             <version>${pkgVersion}</version>
             <optional>true</optional>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

Modified: servicemix/smx4/runtime/trunk/bundles/asm/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/bundles/asm/pom.xml?rev=604849&r1=604848&r2=604849&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/bundles/asm/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/bundles/asm/pom.xml Mon Dec 17 04:15:26 2007
@@ -49,6 +49,12 @@
             <version>${pkgVersion}</version>
             <optional>true</optional>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

Modified: servicemix/smx4/runtime/trunk/bundles/cglib/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/bundles/cglib/pom.xml?rev=604849&r1=604848&r2=604849&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/bundles/cglib/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/bundles/cglib/pom.xml Mon Dec 17 04:15:26 2007
@@ -55,6 +55,12 @@
             <version>${pkgVersion}</version>
             <optional>true</optional>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

Modified: servicemix/smx4/runtime/trunk/bundles/mina/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/bundles/mina/pom.xml?rev=604849&r1=604848&r2=604849&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/bundles/mina/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/bundles/mina/pom.xml Mon Dec 17 04:15:26 2007
@@ -86,6 +86,12 @@
             <version>${pkgVersion}</version>
             <optional>true</optional>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

Modified: servicemix/smx4/runtime/trunk/bundles/xstream/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/bundles/xstream/pom.xml?rev=604849&r1=604848&r2=604849&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/bundles/xstream/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/bundles/xstream/pom.xml Mon Dec 17 04:15:26 2007
@@ -60,6 +60,12 @@
             <version>${pkgVersion}</version>
             <optional>true</optional>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

Modified: servicemix/smx4/runtime/trunk/main/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/main/pom.xml?rev=604849&r1=604848&r2=604849&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/main/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/main/pom.xml Mon Dec 17 04:15:26 2007
@@ -67,6 +67,12 @@
           </exclusions>
         </dependency>
         -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

Modified: servicemix/smx4/runtime/trunk/main/src/main/java/org/apache/servicemix/runtime/main/Main.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/main/src/main/java/org/apache/servicemix/runtime/main/Main.java?rev=604849&r1=604848&r2=604849&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/main/src/main/java/org/apache/servicemix/runtime/main/Main.java (original)
+++ servicemix/smx4/runtime/trunk/main/src/main/java/org/apache/servicemix/runtime/main/Main.java Mon Dec 17 04:15:26 2007
@@ -30,9 +30,11 @@
 import org.apache.felix.framework.cache.BundleCache;
 import org.apache.felix.framework.util.StringMap;
 import org.apache.servicemix.runtime.main.spi.MainService;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.startlevel.StartLevel;
 
 /**
  * <p>
@@ -45,41 +47,44 @@
  * the framework.
  * </p>
 **/
-public class Main implements MainService
+public class Main implements MainService, BundleActivator
 {
     /**
      * The default name used for the system properties file.
-    **/
+     **/
     public static final String SYSTEM_PROPERTIES_FILE_NAME = "system.properties";
     /**
      * The default name used for the configuration properties file.
-    **/
+     **/
     public static final String CONFIG_PROPERTIES_FILE_NAME = "config.properties";
     /**
      * The default name used for the startup properties file.
-    **/
+     **/
     public static final String STARTUP_PROPERTIES_FILE_NAME = "startup.properties";
-    /*
+    /**
+     * The property name prefix for the launcher's auto-install property.
+     **/
+    public static final String PROPERTY_AUTO_INSTALL = "felix.auto.install";
+    /**
      * The property for auto-discovering the bundles 
      */
     public static final String PROPERTY_AUTO_START = "felix.auto.start";
-    /*
+    /**
      * The system property for specifying the ServiceMix home directory.  The home directory
      * hold the binary install of ServiceMix.
      */
     public static final String PROP_SERVICEMIX_HOME = "servicemix.home";
-    /*
+    /**
      * The environment variable for specifying the ServiceMix home directory.  The home directory
      * hold the binary install of ServiceMix.
      */
     public static final String ENV_SERVICEMIX_HOME = "SERVICEMIX_HOME";
-    
-    /*
+    /**
      * The system property for specifying the ServiceMix base directory.  The base directory
      * holds the configuration and data for a ServiceMix instance.
      */
     public static final String PROP_SERVICEMIX_BASE = "servicemix.base";
-    /*
+    /**
      * The environment variable for specifying the ServiceMix base directory.  The base directory
      * holds the configuration and data for a ServiceMix instance.
      */
@@ -88,6 +93,7 @@
 
     private File servicemixHome;
     private File servicemixBase;
+    private static Properties m_configProps = null;
     private static Felix m_felix = null;
 	private final String[] args;
 	private int exitCode;
@@ -96,6 +102,26 @@
 		this.args = args;
 	}
 
+   /**
+     * Used to instigate auto-install and auto-start configuration
+     * property processing via a custom framework activator during
+     * framework startup.
+     * @param context The system bundle context.
+     **/
+    public void start(BundleContext context)
+    {
+        Main.processAutoProperties(context);
+    }
+
+    /**
+     * Currently does nothing as part of framework shutdown.
+     * @param context The system bundle context.
+     **/
+    public void stop(BundleContext context)
+    {
+        // Do nothing.
+    }
+
 	/**
      * <p>
      * This method performs the main task of constructing an framework instance
@@ -190,13 +216,13 @@
         main.loadSystemProperties();
 
         // Read configuration properties.
-        Properties configProps = main.loadConfigProperties();
+        m_configProps = main.loadConfigProperties();
 
         // Copy framework properties from the system properties.
-        Main.copySystemProperties(configProps);
+        Main.copySystemProperties(m_configProps);
 
-        String profileName = configProps.getProperty(BundleCache.CACHE_PROFILE_PROP);
-        String profileDirName = configProps.getProperty(BundleCache.CACHE_PROFILE_DIR_PROP);
+        String profileName = m_configProps.getProperty(BundleCache.CACHE_PROFILE_PROP);
+        String profileDirName = m_configProps.getProperty(BundleCache.CACHE_PROFILE_DIR_PROP);
 
         // A profile directory or name must be specified.
         if ((profileDirName == null) && (profileName.length() == 0))
@@ -222,11 +248,12 @@
         };        
     	List<BundleActivator> activations = new ArrayList<BundleActivator>();
         activations.add(activator);
+        activations.add(main);
         
         try
         {
             // Start up the OSGI framework
-            m_felix = new Felix(new StringMap(configProps, false), activations);
+            m_felix = new Felix(new StringMap(m_configProps, false), activations);
             m_felix.start();
         }
         catch (Exception ex)
@@ -336,7 +363,221 @@
     	return rc;
 	}
 
+    /**
+     * <p>
+     * Processes the auto-install and auto-start properties from the
+     * specified configuration properties.
+     */
+    private static void processAutoProperties(BundleContext context)
+    {
+        // Retrieve the Start Level service, since it will be needed
+        // to set the start level of the installed bundles.
+        StartLevel sl = (StartLevel) context.getService(
+            context.getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName()));
+
+        // The auto-install property specifies a space-delimited list of
+        // bundle URLs to be automatically installed into each new profile;
+        // the start level to which the bundles are assigned is specified by
+        // appending a ".n" to the auto-install property name, where "n" is
+        // the desired start level for the list of bundles.
+        for (Iterator i = m_configProps.keySet().iterator(); i.hasNext(); )
+        {
+            String key = (String) i.next();
+
+            // Ignore all keys that are not the auto-install property.
+            if (!key.startsWith(PROPERTY_AUTO_INSTALL))
+            {
+                continue;
+            }
+
+            // If the auto-install property does not have a start level,
+            // then assume it is the default bundle start level, otherwise
+            // parse the specified start level.
+            int startLevel = sl.getInitialBundleStartLevel();
+            if (!key.equals(PROPERTY_AUTO_INSTALL))
+            {
+                try
+                {
+                    startLevel = Integer.parseInt(key.substring(key.lastIndexOf('.') + 1));
+                }
+                catch (NumberFormatException ex)
+                {
+                    System.err.println("Invalid property: " + key);
+                }
+            }
+
+            StringTokenizer st = new StringTokenizer(m_configProps.getProperty(key), "\" ",true);
+            if (st.countTokens() > 0)
+            {
+                String location = null;
+                do
+                {
+                    location = nextLocation(st);
+                    if (location != null)
+                    {
+                        try
+                        {
+                            Bundle b = context.installBundle(location, null);
+                            sl.setBundleStartLevel(b, startLevel);
+                        }
+                        catch (Exception ex)
+                        {
+                            System.err.println("Auto-properties install: " + ex);
+                        }
+                    }
+                }
+                while (location != null);
+            }
+        }
+
+        // The auto-start property specifies a space-delimited list of
+        // bundle URLs to be automatically installed and started into each
+        // new profile; the start level to which the bundles are assigned
+        // is specified by appending a ".n" to the auto-start property name,
+        // where "n" is the desired start level for the list of bundles.
+        // The following code starts bundles in two passes, first it installs
+        // them, then it starts them.
+        for (Iterator i = m_configProps.keySet().iterator(); i.hasNext(); )
+        {
+            String key = (String) i.next();
+
+            // Ignore all keys that are not the auto-start property.
+            if (!key.startsWith(PROPERTY_AUTO_START))
+            {
+                continue;
+            }
+
+            // If the auto-start property does not have a start level,
+            // then assume it is the default bundle start level, otherwise
+            // parse the specified start level.
+            int startLevel = sl.getInitialBundleStartLevel();
+            if (!key.equals(PROPERTY_AUTO_START))
+            {
+                try
+                {
+                    startLevel = Integer.parseInt(key.substring(key.lastIndexOf('.') + 1));
+                }
+                catch (NumberFormatException ex)
+                {
+                    System.err.println("Invalid property: " + key);
+                }
+            }
+
+            StringTokenizer st = new StringTokenizer(m_configProps.getProperty(key), "\" ",true);
+            if (st.countTokens() > 0)
+            {
+                String location = null;
+                do
+                {
+                    location = nextLocation(st);
+                    if (location != null)
+                    {
+                        try
+                        {
+                            Bundle b = context.installBundle(location, null);
+                            sl.setBundleStartLevel(b, startLevel);
+                        }
+                        catch (Exception ex)
+                        {
+                            System.err.println("Auto-properties install:" + ex);
+                        }
+                    }
+                }
+                while (location != null);
+            }
+        }
+
+        // Now loop through and start the installed bundles.
+        for (Iterator i = m_configProps.keySet().iterator(); i.hasNext(); )
+        {
+            String key = (String) i.next();
+            if (key.startsWith(PROPERTY_AUTO_START))
+            {
+                StringTokenizer st = new StringTokenizer(m_configProps.getProperty(key), "\" ",true);
+                if (st.countTokens() > 0)
+                {
+                    String location = null;
+                    do
+                    {
+                        location = nextLocation(st);
+                        if (location != null)
+                        {
+                            // Installing twice just returns the same bundle.
+                            try
+                            {
+                                Bundle b = context.installBundle(location, null);
+                                if (b != null)
+                                {
+                                    b.start();
+                                }
+                            }
+                            catch (Exception ex)
+                            {
+                                System.err.println("Auto-properties start: " + ex);
+                            }
+                        }
+                    }
+                    while (location != null);
+                }
+            }
+        }
+    }
+
+    private static String nextLocation(StringTokenizer st)
+    {
+        String retVal = null;
+
+        if (st.countTokens() > 0)
+        {
+            String tokenList = "\" ";
+            StringBuffer tokBuf = new StringBuffer(10);
+            String tok = null;
+            boolean inQuote = false;
+            boolean tokStarted = false;
+            boolean exit = false;
+            while ((st.hasMoreTokens()) && (!exit))
+            {
+                tok = st.nextToken(tokenList);
+                if (tok.equals("\""))
+                {
+                    inQuote = ! inQuote;
+                    if (inQuote)
+                    {
+                        tokenList = "\"";
+                    }
+                    else
+                    {
+                        tokenList = "\" ";
+                    }
+
+                }
+                else if (tok.equals(" "))
+                {
+                    if (tokStarted)
+                    {
+                        retVal = tokBuf.toString();
+                        tokStarted=false;
+                        tokBuf = new StringBuffer(10);
+                        exit = true;
+                    }
+                }
+                else
+                {
+                    tokStarted = true;
+                    tokBuf.append(tok.trim());
+                }
+            }
 
+            // Handle case where end of token stream and
+            // still got data
+            if ((!exit) && (tokStarted))
+            {
+                retVal = tokBuf.toString();
+            }
+        }
+
+        return retVal;
+    }
 
 	/**
      * <p>

Modified: servicemix/smx4/runtime/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/pom.xml?rev=604849&r1=604848&r2=604849&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/pom.xml Mon Dec 17 04:15:26 2007
@@ -78,7 +78,7 @@
       <jline.version>0.9.93</jline.version>
       <log4j.version>1.2.14</log4j.version>
       <mina.version>1.1.6-r602102</mina.version>
-      <pax.logging.version>1.0-RC1</pax.logging.version>
+      <pax.logging.version>0.9.8</pax.logging.version>
       <spring.osgi.version>1.0-m3</spring.osgi.version>
       <spring.version>2.5</spring.version>
       <xstream.version>1.2.2</xstream.version>
@@ -229,6 +229,45 @@
               </plugin>
           </plugins>
       </pluginManagement>
+      <plugins>
+          <plugin>
+              <artifactId>maven-remote-resources-plugin</artifactId>
+              <version>1.0-beta-2</version>
+              <dependencies>
+				  <!--
+                  <dependency>
+                      <groupId>org.apache.cxf</groupId>
+                      <artifactId>cxf-buildtools</artifactId>
+                      <version>${project.version}</version>
+                  </dependency>
+                  -->
+              </dependencies>
+              <executions>
+                  <execution>
+                      <goals>
+                          <goal>process</goal>
+                      </goals>
+                      <configuration>
+                          <resourceBundles>
+	<!--
+                              <resourceBundle>org.apache:apache-incubator-disclaimer-resource-bundle:1.1</resourceBundle>
+-->
+                              <resourceBundle>org.apache:apache-jar-resource-bundle:1.3</resourceBundle>
+                          </resourceBundles>
+<!--
+                          <supplementalModels>
+                              <supplementalModel>notice-supplements.xml</supplementalModel>
+                          </supplementalModels>
+-->
+                          <properties>
+                              <addLicense>true</addLicense>
+                              <projectName>Apache ServiceMix</projectName>
+                          </properties>
+                      </configuration>
+                  </execution>
+              </executions>
+          </plugin>
+      </plugins>
   </build>
 
   <reporting>