incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1242749 - in /incubator/lcf/trunk/framework: ./ core/src/main/java/org/apache/manifoldcf/core/system/ example-multiprocess/ example-singleprocess/ jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ multiprocess-jetty-runner/
Date Fri, 10 Feb 2012 11:52:20 GMT
Author: kwright
Date: Fri Feb 10 11:52:19 2012
New Revision: 1242749

URL: http://svn.apache.org/viewvc?rev=1242749&view=rev
Log:
Part of CONNECTORS-327.  Refactor the way we start Jetty so we can get the location of the
war files out of properties.xml.

Removed:
    incubator/lcf/trunk/framework/multiprocess-jetty-runner/
Modified:
    incubator/lcf/trunk/framework/build.xml
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
    incubator/lcf/trunk/framework/example-multiprocess/properties.xml
    incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat
    incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh
    incubator/lcf/trunk/framework/example-singleprocess/properties.xml
    incubator/lcf/trunk/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFJettyRunner.java

Modified: incubator/lcf/trunk/framework/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/build.xml?rev=1242749&r1=1242748&r2=1242749&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/build.xml (original)
+++ incubator/lcf/trunk/framework/build.xml Fri Feb 10 11:52:19 2012
@@ -82,7 +82,6 @@
             <fileset dir="ui-core/src/main/java" includes="**/*.java"/>
             <fileset dir="script-engine/src/main/java" includes="**/*.java"/>
             <fileset dir="jetty-runner/src/main/java" includes="**/*.java"/>
-            <fileset dir="multiprocess-jetty-runner/src/main/java" includes="**/*.java"/>
         </javadoc>
     </target>
     
@@ -139,17 +138,6 @@
         </javac>
     </target>
 
-    <target name="compile-multiprocess-jetty-runner" depends="compile-core,compile-agents">
-        <mkdir dir="build/multiprocess-jetty-runner/classes"/>
-        <javac srcdir="multiprocess-jetty-runner/src/main/java" destdir="build/multiprocess-jetty-runner/classes"
target="1.5" source="1.5" debug="true" debuglevel="lines,vars,source">
-            <classpath>
-                 <fileset dir="../lib"> 
-                    <include name="jetty*.jar"/> 
-                </fileset>
-            </classpath>
-        </javac>
-    </target>
-
     <target name="compile-script-engine" depends="compile-core">
         <mkdir dir="build/script-engine/classes"/>
         <javac srcdir="script-engine/src/main/java" destdir="build/script-engine/classes"
target="1.5" source="1.5" debug="true" debuglevel="lines,vars,source">
@@ -247,11 +235,6 @@
         <jar destfile="build/jar/mcf-jetty-runner.jar" basedir="build/jetty-runner/classes"/>
     </target>
 
-    <target name="jar-multiprocess-jetty-runner" depends="compile-multiprocess-jetty-runner">
-        <mkdir dir="build/jar"/>
-        <jar destfile="build/jar/mcf-multiprocess-jetty-runner.jar" basedir="build/multiprocess-jetty-runner/classes"/>
-    </target>
-
     <target name="jar-script-engine" depends="compile-script-engine">
         <mkdir dir="build/jar"/>
         <jar destfile="build/jar/mcf-script-engine.jar" basedir="build/script-engine/classes"/>
@@ -469,7 +452,7 @@
         <mkdir dir="dist/multiprocess-example/syncharea"/>
     </target>
 
-    <target name="multi-process-example" depends="jar-multiprocess-jetty-runner,multi-wars,multi-processes">
+    <target name="multi-process-example" depends="jar-core,jar-agents,jar-pull-agent,jar-jetty-runner,multi-wars,multi-processes">
         <mkdir dir="dist/multiprocess-example"/>
         <copy todir="dist/multiprocess-example">
             <fileset dir="example-multiprocess">
@@ -481,8 +464,19 @@
         </copy>
         <mkdir dir="dist/multiprocess-example/lib"/>
         <copy todir="dist/multiprocess-example/lib">
+            <fileset dir="../build/jar">
+                <include name="json.jar"/>
+            </fileset>
+            <fileset dir="../lib">
+                <include name="commons-logging*.jar"/>
+                <include name="log4j*.jar"/>
+            </fileset>
             <fileset dir="build/jar">
-                <include name="mcf-multiprocess-jetty-runner.jar"/>
+                <include name="mcf-core.jar"/>
+                <include name="mcf-ui-core.jar"/>
+                <include name="mcf-agents.jar"/>
+                <include name="mcf-pull-agent.jar"/>
+                <include name="mcf-jetty-runner.jar"/>
             </fileset>
             <fileset dir="../lib">
                 <include name="jetty*.jar"/>

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java?rev=1242749&r1=1242748&r2=1242749&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
Fri Feb 10 11:52:19 2012
@@ -330,6 +330,21 @@ public class ManifoldCF
     return resolvePath(value);
   }
   
+  /** Read a boolean property
+  */
+  public static boolean getBooleanProperty(String s, boolean defaultValue)
+    throws ManifoldCFException
+  {
+    String value = getProperty(s);
+    if (value == null)
+      return defaultValue;
+    if (value.equals("true") || value.equals("yes"))
+      return true;
+    if (value.equals("false") || value.equals("no"))
+      return false;
+    throw new ManifoldCFException("Illegal property value for boolean property '"+s+"': '"+value+"'");
+  }
+  
   /** Read an integer propert, either from the system properties, or from the local configuration
file.
   */
   public static int getIntProperty(String s, int defaultValue)

Modified: incubator/lcf/trunk/framework/example-multiprocess/properties.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/example-multiprocess/properties.xml?rev=1242749&r1=1242748&r2=1242749&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/example-multiprocess/properties.xml (original)
+++ incubator/lcf/trunk/framework/example-multiprocess/properties.xml Fri Feb 10 11:52:19
2012
@@ -17,6 +17,12 @@
 -->
 
 <configuration>
+  <!-- Point to the wars and configure Jetty -->
+  <property name="org.apache.manifoldcf.crawleruiwarpath" value="./web/war/mcf-crawler-ui.war"/>
+  <property name="org.apache.manifoldcf.authorityservicewarpath" value="./web/war/mcf-authority-service.war"/>
+  <property name="org.apache.manifoldcf.apiservicewarpath" value="./web/war/mcf-api-service.war"/>
+  <property name="org.apache.manifoldcf.usejettyparentclassloader" value="false"/>
+  <property name="org.apache.manifoldcf.jettyport" value="8345"/>
   <!-- Point to the synchronization area -->
   <property name="org.apache.manifoldcf.synchdirectory" value="./syncharea"/>
   <!-- Select HSQLDB as the database implementation, and specify multiprocess access -->

Modified: incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat?rev=1242749&r1=1242748&r2=1242749&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat (original)
+++ incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat Fri Feb 10 11:52:19
2012
@@ -20,7 +20,7 @@ if not exist "%JAVA_HOME%\bin\java.exe" 
 set CLASSPATH=.
 for %%f in (lib/*) do call setclasspath.bat %%f
 rem invoke java with the jetty class
-"%JAVA_HOME%\bin\java" -cp "%CLASSPATH%" org.apache.manifoldcf.multiprocessjettyrunner.MCFMultiprocessJettyRunner
+"%JAVA_HOME%\bin\java" -cp "%CLASSPATH%" org.apache.manifoldcf.jettyrunner.ManifoldCFJettyRunner
 goto done
 :nojavahome
 echo Environment variable JAVA_HOME is not set properly.

Modified: incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh?rev=1242749&r1=1242748&r2=1242749&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh (original)
+++ incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh Fri Feb 10 11:52:19
2012
@@ -33,7 +33,7 @@ if [ -e "$JAVA_HOME"/bin/java ] ; then
         fi
     done
 
-    "%JAVA_HOME%"/bin/java -cp "$CLASSPATH" org.apache.manifoldcf.multiprocessjettyrunner.MCFMultiprocessJettyRunner
+    "%JAVA_HOME%"/bin/java -cp "$CLASSPATH" org.apache.manifoldcf.jettyrunner.ManifoldCFJettyRunner
     exit $?
         
 else

Modified: incubator/lcf/trunk/framework/example-singleprocess/properties.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/example-singleprocess/properties.xml?rev=1242749&r1=1242748&r2=1242749&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/example-singleprocess/properties.xml (original)
+++ incubator/lcf/trunk/framework/example-singleprocess/properties.xml Fri Feb 10 11:52:19
2012
@@ -17,6 +17,12 @@
 -->
 
 <configuration>
+  <!-- Point to the wars and configure Jetty -->
+  <property name="org.apache.manifoldcf.crawleruiwarpath" value="./war/mcf-crawler-ui.war"/>
+  <property name="org.apache.manifoldcf.authorityservicewarpath" value="./war/mcf-authority-service.war"/>
+  <property name="org.apache.manifoldcf.apiservicewarpath" value="./war/mcf-api-service.war"/>
+  <property name="org.apache.manifoldcf.usejettyparentclassloader" value="true"/>
+  <property name="org.apache.manifoldcf.jettyport" value="8345"/>
   <!-- Select Derby as the database implementation, and specify where the database will
be stored -->
   <property name="org.apache.manifoldcf.databaseimplementationclass" value="org.apache.manifoldcf.core.database.DBInterfaceDerby"/>
   <property name="org.apache.manifoldcf.derbydatabasepath" value="."/>

Modified: incubator/lcf/trunk/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFJettyRunner.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFJettyRunner.java?rev=1242749&r1=1242748&r2=1242749&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFJettyRunner.java
(original)
+++ incubator/lcf/trunk/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFJettyRunner.java
Fri Feb 10 11:52:19 2012
@@ -47,26 +47,36 @@ public class ManifoldCFJettyRunner
 
   public static final String _rcsid = "@(#)$Id: ManifoldCFJettyRunner.java 989983 2010-08-27
00:10:12Z kwright $";
 
+  public static final String crawlerUIWarPathProperty = "org.apache.manifoldcf.crawleruiwarpath";
+  public static final String authorityServiceWarPathProperty = "org.apache.manifoldcf.authorityservicewarpath";
+  public static final String apiServiceWarPathProperty = "org.apache.manifoldcf.apiservicewarpath";
+  public static final String useJettyParentClassLoaderProperty = "org.apache.manifoldcf.usejettyparentclassloader";
+  public static final String jettyPortProperty = "org.apache.manifoldcf.jettyport";
+  
   public static final String agentShutdownSignal = org.apache.manifoldcf.agents.AgentRun.agentShutdownSignal;
   
   protected Server server;
   
-  public ManifoldCFJettyRunner( int port, String crawlerWarPath, String authorityServiceWarPath,
String apiWarPath )
+  public ManifoldCFJettyRunner( int port, String crawlerWarPath, String authorityServiceWarPath,
String apiWarPath, boolean useParentLoader )
   {
     server = new Server( port );    
     server.setStopAtShutdown( true );
     
     // Initialize the servlets
     WebAppContext lcfCrawlerUI = new WebAppContext(crawlerWarPath,"/mcf-crawler-ui");
-    // This will cause jetty to ignore all of the framework and jdbc jars in the war, which
is what we want.
-    lcfCrawlerUI.setParentLoaderPriority(true);
+    // This can cause jetty to ignore all of the framework and jdbc jars in the war, which
is what we
+    // want in the single-process case.
+    lcfCrawlerUI.setParentLoaderPriority(useParentLoader);
     server.addHandler(lcfCrawlerUI);
     WebAppContext lcfAuthorityService = new WebAppContext(authorityServiceWarPath,"/mcf-authority-service");
-    // This will cause jetty to ignore all of the framework and jdbc jars in the war, which
is what we want.
-    lcfAuthorityService.setParentLoaderPriority(true);
+    // This can cause jetty to ignore all of the framework and jdbc jars in the war, which
is what we
+    // want in the single-process case.
+    lcfAuthorityService.setParentLoaderPriority(useParentLoader);
     server.addHandler(lcfAuthorityService);
     WebAppContext lcfApi = new WebAppContext(apiWarPath,"/mcf-api-service");
-    lcfApi.setParentLoaderPriority(true);
+    // This can cause jetty to ignore all of the framework and jdbc jars in the war, which
is what we
+    // want in the single-process case.
+    lcfApi.setParentLoaderPriority(useParentLoader);
     server.addHandler(lcfApi);
   }
 
@@ -162,29 +172,6 @@ public class ManifoldCFJettyRunner
       System.exit(1);
     }
 
-    int jettyPort = 8345;
-    if (args.length > 0)
-    {
-      try
-      {
-        jettyPort = Integer.parseInt(args[0]);
-      }
-      catch (NumberFormatException e)
-      {
-        e.printStackTrace(System.err);
-        System.exit(1);
-      }
-    }
-    
-    String crawlerWarPath = "war/mcf-crawler-ui.war";
-    String authorityserviceWarPath = "war/mcf-authority-service.war";
-    String apiWarPath = "war/mcf-api-service.war";
-    if (args.length == 4)
-    {
-      crawlerWarPath = args[1];
-      authorityserviceWarPath = args[2];
-      apiWarPath = args[3];
-    }
     
     // Ready to begin in earnest...
     if (System.getProperty(ManifoldCF.lcfConfigFileProperty) == null)
@@ -194,31 +181,86 @@ public class ManifoldCFJettyRunner
       ManifoldCF.initializeEnvironment();
       IThreadContext tc = ThreadContextFactory.make();
 
-      // Clear the agents shutdown signal.
-      ILockManager lockManager = LockManagerFactory.make(tc);
-      lockManager.clearGlobalFlag(agentShutdownSignal);
-      
-      // Do the basic initialization of the database and its schema
-      ManifoldCF.createSystemDatabase(tc);
-      
-      ManifoldCF.installTables(tc);
-      
-      org.apache.manifoldcf.crawler.system.ManifoldCF.registerThisAgent(tc);
-      
-      ManifoldCF.reregisterAllConnectors(tc);
+      // Grab the parameters which locate the wars and describe how we work with Jetty
+      File crawlerWarPath = ManifoldCF.getFileProperty(crawlerUIWarPathProperty);
+      File authorityserviceWarPath = ManifoldCF.getFileProperty(authorityServiceWarPathProperty);
+      File apiWarPath = ManifoldCF.getFileProperty(apiServiceWarPathProperty);
+      boolean useParentClassLoader = ManifoldCF.getBooleanProperty(useJettyParentClassLoaderProperty,true);
+      int jettyPort = ManifoldCF.getIntProperty(jettyPortProperty,8345);
+      if (args.length > 0)
+      {
+        try
+        {
+          jettyPort = Integer.parseInt(args[0]);
+        }
+        catch (NumberFormatException e)
+        {
+          throw new ManifoldCFException("Illegal value for jetty port argument: "+e.getMessage(),e);
+        }
+      }
+      if (args.length == 4)
+      {
+        crawlerWarPath = new File(args[1]);
+        authorityserviceWarPath = new File(args[2]);
+        apiWarPath = new File(args[3]);
+      }
+      else
+      {
+        if (crawlerWarPath == null)
+          throw new ManifoldCFException("The property '"+crawlerUIWarPathProperty+"' must
be set");
+        if (authorityserviceWarPath == null)
+          throw new ManifoldCFException("The property '"+authorityServiceWarPathProperty+"'
must be set");
+        if (apiWarPath == null)
+          throw new ManifoldCFException("The property '"+apiServiceWarPathProperty+"' must
be set");
+      }
+      
+      if (useParentClassLoader)
+      {
+        // Clear the agents shutdown signal.
+        ILockManager lockManager = LockManagerFactory.make(tc);
+        lockManager.clearGlobalFlag(agentShutdownSignal);
+        
+        // Do the basic initialization of the database and its schema
+        ManifoldCF.createSystemDatabase(tc);
+        
+        ManifoldCF.installTables(tc);
+        
+        org.apache.manifoldcf.crawler.system.ManifoldCF.registerThisAgent(tc);
+        
+        ManifoldCF.reregisterAllConnectors(tc);
+      }
       
       System.err.println("Starting jetty...");
       
       // Create a jetty instance
-      ManifoldCFJettyRunner jetty = new ManifoldCFJettyRunner(jettyPort,crawlerWarPath,authorityserviceWarPath,apiWarPath);
+      ManifoldCFJettyRunner jetty = new ManifoldCFJettyRunner(jettyPort,crawlerWarPath.toString(),authorityserviceWarPath.toString(),apiWarPath.toString(),useParentClassLoader);
       // This will register a shutdown hook as well.
       jetty.start();
 
       System.err.println("Jetty started.");
 
-      System.err.println("Starting crawler...");
-      runAgents(tc);
-      System.err.println("Shutting down crawler...");
+      if (useParentClassLoader)
+      {
+        System.err.println("Starting crawler...");
+        runAgents(tc);
+        System.err.println("Shutting down crawler...");
+      }
+      else
+      {
+        // Go to sleep until interrupted.
+        while (true)
+        {
+          try
+          {
+            Thread.sleep(5000);
+            continue;
+          }
+          catch (InterruptedException e)
+          {
+            break;
+          }
+        }
+      }
     }
     catch (ManifoldCFException e)
     {



Mime
View raw message