Pull up fix for CONNECTORS-544 from trunk.
git-svn-id: https://svn.apache.org/repos/asf/manifoldcf/branches/release-1.0-branch@1391104 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index 52ef7c7..5faca97 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,6 +3,11 @@
======================= 1.0 =====================
+CONNECTORS-544: Add missing materials to combined service war.
+Also include a way of easily invoking it from the single-process example
+directory.
+(Karl Wright)
+
CONNECTORS-540: Multi-process proprietary webapps run not properly
running the start-webapps.sh.
(Shinichiro Abe)
diff --git a/framework/build.xml b/framework/build.xml
index 2c49e0f..bb78465 100644
--- a/framework/build.xml
+++ b/framework/build.xml
@@ -556,7 +556,7 @@
<jar destfile="build/webapp/crawler-ui-proprietary/WEB-INF/lib/mcf-crawler-ui.jar" basedir="build/crawler-ui/classes"/>
</target>
- <target name="webapp-combined-service" depends="compile-combined-service,jar-core,jar-ui-core,jar-agents,jar-pull-agent">
+ <target name="webapp-combined-service" depends="compile-combined-service,jar-core,jar-ui-core,jar-agents,jar-pull-agent,jar-api-servlet,jar-authority-servlet">
<mkdir dir="build/webapp/combined-service/WEB-INF/lib"/>
<copy todir="build/webapp/combined-service/WEB-INF/lib">
<fileset dir="../lib">
@@ -587,6 +587,8 @@
<include name="mcf-agents.jar"/>
<include name="mcf-pull-agent.jar"/>
<include name="mcf-ui-core.jar"/>
+ <include name="mcf-api-servlet.jar"/>
+ <include name="mcf-authority-servlet.jar"/>
</fileset>
</copy>
<mkdir dir="build/webapp/combined-service/WEB-INF/jsp"/>
@@ -601,7 +603,7 @@
<jar destfile="build/webapp/combined-service/WEB-INF/lib/mcf-combined-service.jar" basedir="build/combined-service/classes"/>
</target>
- <target name="webapp-combined-service-proprietary" depends="compile-combined-service,jar-core,jar-ui-core,jar-agents,jar-pull-agent">
+ <target name="webapp-combined-service-proprietary" depends="compile-combined-service,jar-core,jar-ui-core,jar-agents,jar-pull-agent,jar-api-servlet,jar-authority-servlet">
<mkdir dir="build/webapp/combined-service-proprietary/WEB-INF/lib"/>
<copy todir="build/webapp/combined-service-proprietary/WEB-INF/lib">
<fileset dir="../lib">
@@ -639,6 +641,8 @@
<include name="mcf-agents.jar"/>
<include name="mcf-pull-agent.jar"/>
<include name="mcf-ui-core.jar"/>
+ <include name="mcf-api-servlet.jar"/>
+ <include name="mcf-authority-servlet.jar"/>
</fileset>
</copy>
<mkdir dir="build/webapp/combined-service-proprietary/WEB-INF/jsp"/>
diff --git a/framework/example-singleprocess-common/setclasspath.bat b/framework/example-singleprocess-common/setclasspath.bat
new file mode 100644
index 0000000..9d25ce6
--- /dev/null
+++ b/framework/example-singleprocess-common/setclasspath.bat
@@ -0,0 +1,16 @@
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements. See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+set CLASSPATH=%CLASSPATH%;.\lib\%1
diff --git a/framework/example-singleprocess-common/start-combined.bat b/framework/example-singleprocess-common/start-combined.bat
new file mode 100644
index 0000000..adab6a1
--- /dev/null
+++ b/framework/example-singleprocess-common/start-combined.bat
@@ -0,0 +1,28 @@
+@echo off
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements. See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+rem check that JAVA_HOME is set, and that the current directory is correct
+if not exist "%JAVA_HOME%\bin\java.exe" goto nojavahome
+
+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.jettyrunner.ManifoldCFCombinedJettyRunner
+goto done
+:nojavahome
+echo Environment variable JAVA_HOME is not set properly.
+goto done
+:done
diff --git a/framework/example-singleprocess-common/start-combined.sh b/framework/example-singleprocess-common/start-combined.sh
new file mode 100755
index 0000000..1a36c74
--- /dev/null
+++ b/framework/example-singleprocess-common/start-combined.sh
@@ -0,0 +1,42 @@
+#!/bin/bash -e
+
+# 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.
+
+if [[ $OSTYPE == "cygwin" ]] ; then
+ PATHSEP=";"
+else
+ PATHSEP=":"
+fi
+
+#Make sure environment variables are properly set
+if [ -e "$JAVA_HOME"/bin/java ] ; then
+
+ CLASSPATH=""
+ for filename in $(ls -1 ./lib) ; do
+ if [ -n "$CLASSPATH" ] ; then
+ CLASSPATH="$CLASSPATH""$PATHSEP"./lib/"$filename"
+ else
+ CLASSPATH=./lib/"$filename"
+ fi
+ done
+
+ "$JAVA_HOME"/bin/java -cp "$CLASSPATH" org.apache.manifoldcf.jettyrunner.ManifoldCFCombinedJettyRunner
+ exit $?
+
+else
+ echo "Environment variable JAVA_HOME is not properly set." 1>&2
+ exit 1
+fi
diff --git a/framework/example-singleprocess-proprietary/properties.xml b/framework/example-singleprocess-proprietary/properties.xml
index 106594b..92fd5b7 100644
--- a/framework/example-singleprocess-proprietary/properties.xml
+++ b/framework/example-singleprocess-proprietary/properties.xml
@@ -23,6 +23,8 @@
<property name="org.apache.manifoldcf.apiservicewarpath" value="../web/war/mcf-api-service.war"/>
<property name="org.apache.manifoldcf.usejettyparentclassloader" value="true"/>
<property name="org.apache.manifoldcf.jettyport" value="8345"/>
+ <!-- Point to the combined war in case we start the single-process example that way -->
+ <property name="org.apache.manifoldcf.combinedwarpath" value="../web/war/mcf-combined-service.war"/>
<!-- 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="."/>
diff --git a/framework/example-singleprocess/properties.xml b/framework/example-singleprocess/properties.xml
index cbc811e..9f11a73 100644
--- a/framework/example-singleprocess/properties.xml
+++ b/framework/example-singleprocess/properties.xml
@@ -23,6 +23,8 @@
<property name="org.apache.manifoldcf.apiservicewarpath" value="../web/war/mcf-api-service.war"/>
<property name="org.apache.manifoldcf.usejettyparentclassloader" value="true"/>
<property name="org.apache.manifoldcf.jettyport" value="8345"/>
+ <!-- Point to the combined war in case we start the single-process example that way -->
+ <property name="org.apache.manifoldcf.combinedwarpath" value="../web/war/mcf-combined-service.war"/>
<!-- 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="."/>
diff --git a/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFCombinedJettyRunner.java b/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFCombinedJettyRunner.java
new file mode 100644
index 0000000..6ae7174
--- /dev/null
+++ b/framework/jetty-runner/src/main/java/org/apache/manifoldcf/jettyrunner/ManifoldCFCombinedJettyRunner.java
@@ -0,0 +1,197 @@
+/**
+ * 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.manifoldcf.jettyrunner;
+
+import java.io.*;
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.crawler.system.*;
+import org.apache.manifoldcf.crawler.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.server.handler.ContextHandlerCollection;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.eclipse.jetty.server.Connector;
+
+/**
+ * Run ManifoldCF with jetty.
+ *
+ */
+public class ManifoldCFCombinedJettyRunner
+{
+
+ public static final String _rcsid = "@(#)$Id$";
+
+ public static final String combinedWarPathProperty = "org.apache.manifoldcf.combinedwarpath";
+ public static final String jettyPortProperty = "org.apache.manifoldcf.jettyport";
+
+ protected Server server;
+
+ public ManifoldCFCombinedJettyRunner( int port, String combinedWarPath )
+ {
+ server = new Server( port );
+ server.setStopAtShutdown( true );
+
+ // Initialize the servlets
+ ContextHandlerCollection contexts = new ContextHandlerCollection();
+ server.setHandler(contexts);
+ WebAppContext mcfCombined = new WebAppContext(combinedWarPath,"/mcf");
+ mcfCombined.setParentLoaderPriority(false);
+ contexts.addHandler(mcfCombined);
+ }
+
+ public void start()
+ throws ManifoldCFException
+ {
+ if(!server.isRunning() )
+ {
+ try
+ {
+ server.start();
+ }
+ catch (Exception e)
+ {
+ throw new ManifoldCFException("Couldn't start: "+e.getMessage(),e);
+ }
+ }
+ }
+
+ public void stop()
+ throws ManifoldCFException
+ {
+ if( server.isRunning() )
+ {
+ try
+ {
+ server.stop();
+ }
+ catch (Exception e)
+ {
+ throw new ManifoldCFException("Couldn't stop: "+e.getMessage(),e);
+ }
+ try
+ {
+ server.join();
+ }
+ catch (InterruptedException e)
+ {
+ throw new ManifoldCFException(e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+ }
+ }
+ }
+
+ /**
+ * Returns the Local Port of the first Connector found for the jetty Server.
+ * @return the port number.
+ */
+ public int getLocalPort()
+ throws ManifoldCFException
+ {
+ Connector[] conns = server.getConnectors();
+ if (0 == conns.length) {
+ throw new ManifoldCFException("Jetty Server has no Connectors");
+ }
+ return conns[0].getLocalPort();
+ }
+
+ /**
+ * A main class that starts jetty+mcf
+ */
+ public static void main( String[] args )
+ {
+ if (args.length != 2 && args.length != 1 && args.length != 0)
+ {
+ System.err.println("Usage: ManifoldCFCombinedJettyRunner [<port> [<combined-war-path>]]");
+ System.exit(1);
+ }
+
+
+ // Ready to begin in earnest...
+ if (System.getProperty(ManifoldCF.lcfConfigFileProperty) == null)
+ System.setProperty(ManifoldCF.lcfConfigFileProperty,"./properties.xml");
+ try
+ {
+ ManifoldCF.initializeEnvironment();
+ IThreadContext tc = ThreadContextFactory.make();
+
+ // Grab the parameters which locate the wars and describe how we work with Jetty
+ File combinedWarPath = ManifoldCF.getFileProperty(combinedWarPathProperty);
+ int jettyPort = ManifoldCF.getIntProperty(jettyPortProperty,8347);
+ 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 == 2)
+ {
+ combinedWarPath = new File(args[1]);
+ }
+ else
+ {
+ if (combinedWarPath == null)
+ throw new ManifoldCFException("The property '"+combinedWarPathProperty+"' must be set");
+ }
+
+ System.err.println("Starting jetty...");
+
+ // Create a jetty instance
+ ManifoldCFCombinedJettyRunner jetty = new ManifoldCFCombinedJettyRunner(jettyPort,combinedWarPath.toString());
+ // This will register a shutdown hook as well.
+ jetty.start();
+
+ System.err.println("Jetty started.");
+
+ // Go to sleep until interrupted.
+ while (true)
+ {
+ try
+ {
+ Thread.sleep(5000);
+ continue;
+ }
+ catch (InterruptedException e)
+ {
+ break;
+ }
+ }
+ }
+ catch (ManifoldCFException e)
+ {
+ if (Logging.root != null)
+ Logging.root.error("Exception: "+e.getMessage(),e);
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+
+}
+
+