Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Merging FCREPO-593
Browse files Browse the repository at this point in the history
  • Loading branch information
barmintor committed Dec 15, 2009
1 parent 5699a84 commit f55d8e9
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 10 deletions.
14 changes: 14 additions & 0 deletions fcrepo-installer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@
<classifier>utilities-main</classifier>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-server</artifactId>
<classifier>cli-loader-main</classifier>
<version>${project.version}</version>
</dependency>
</dependencies>

</profile>
Expand Down Expand Up @@ -216,6 +223,13 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-server</artifactId>
<classifier>cli-loader-main</classifier>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-webapp-imagemanip</artifactId>
Expand Down
10 changes: 10 additions & 0 deletions fcrepo-installer/src/main/resources/assemblies/fedora-home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@
<fileSet>
<directory>../fcrepo-server/src/main/resources/scripts/bat/server</directory>
<outputDirectory>/server/bin</outputDirectory>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>../fcrepo-server/src/main/resources/scripts/sh/server</directory>
<outputDirectory>/server/bin</outputDirectory>
<fileMode>0755</fileMode>
<filtered>true</filtered>
</fileSet>

<fileSet>
Expand Down Expand Up @@ -346,6 +348,14 @@
<outputDirectory>/client/fedora-client-messaging</outputDirectory>
</dependencySet>

<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<includes>
<include>org.fcrepo:fcrepo-server:jar:cli-loader-main:*</include>
</includes>
<outputDirectory>/server/bin</outputDirectory>
</dependencySet>

</dependencySets>

</assembly>
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@
<outputDirectory>/lib</outputDirectory>
</dependencySet>

<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<includes>
<include>org.fcrepo:fcrepo-server:jar:cli-loader-main:*</include>
</includes>
<outputDirectory>/server/bin</outputDirectory>
</dependencySet>

<dependencySet>
<includes>
<include>org.fcrepo:fcrepo-server:jar:utilities-main:*</include>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# These name=value mappings are used to filter resources in the fedora-home assembly.

# Used for client commandline scripts:
# Used for client and server commandline scripts:
fedora-client-jar=fcrepo-client-admin-${project.version}.jar
fedora-cli-loader-jar=fcrepo-server-${project.version}-cli-loader-main.jar
33 changes: 30 additions & 3 deletions fcrepo-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,33 @@
</includes>
</configuration>
</execution>


<execution>
<id>cli-loader-main</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>

<configuration>
<classifier>cli-loader-main</classifier>

<archive>
<manifest>
<mainClass>fedora.server.utilities.rebuild.cli.CLILoader</mainClass>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>

<manifestEntries>
<Version>${buildNumber}</Version>
<Build>${timestamp}</Build>
</manifestEntries>
</archive>
<includes>
<include>fedora/server/utilities/rebuild/cli/**</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>

Expand Down Expand Up @@ -277,9 +303,10 @@
</descriptors>
</configuration>
</execution>

</executions>
</plugin>

</plugin>

</plugins>

Expand Down Expand Up @@ -508,7 +535,7 @@
<artifactId>commons-dbcp</artifactId>
<version>1.2.1</version>
</dependency>

<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package fedora.server.utilities.rebuild.cli;

import java.io.File;

import java.lang.reflect.Method;

import java.net.URL;
import java.net.URLClassLoader;


/**
* A proxy for various command-line entry-points.
* It addresses the following problems with Mavenized builds:
* Java 5 doesn't support wildcard classpath entries.
* Windows has a length limitation for command arguments that prevents building a classpath.
* The endorsed standards override allows specification of a directory, but classes loaded
* thus cannot use calls to .getClassLoader() to load resources.
*
* @see fedora.server.utilities.rebuild.Rebuild
* @see java.lang.Class#getClassLoader()
*
* @author Benjamin Armintor
*/
public class CLILoader
extends URLClassLoader {
public CLILoader(URL [] paths){
super(paths);
}

public CLILoader(URL[] paths , ClassLoader parent) {
super(paths, parent);
}

/**
* {@link CLILoader#main(String[])} assumes access to a system property
* ("fedora.web.inf.lib") that refers to a directory containing all the
* jar libraries needed to invoke the main class.
* Usage:
* args[0]: <name of main class to be invoked>
* args[1:n] : remaining arguments to be passed to class indicated in args[0]
*/
public static void main(String[] args) {
try {
if (args.length == 0){
System.err.println("No main class specified.");
System.err.println("usage: CLILoader <fedora main class> <options>");
System.exit(1);
}

String webInfLib = System.getProperty("fedora.web.inf.lib");
if (webInfLib == null){
System.err.println("fedora.web.inf.lib not defined");
System.exit(1);
}
File webInfLibDir = new File(webInfLib);
if (!webInfLibDir.exists()){
System.err.println("path specified by fedora.web.inf.lib doesn't exist");
System.exit(1);
}
if (!webInfLibDir.isDirectory()){
System.err.println("path specified by fedora.web.inf.lib not a directory");
System.exit(1);
}
String [] paths = webInfLibDir.list();
URL[] urls = new URL[paths.length];
for (int i = 0; i < paths.length; i++){
urls[i] = new File(webInfLibDir,paths[i]).toURI().toURL();
}
CLILoader loader = new CLILoader(urls);
Thread.currentThread().setContextClassLoader(loader); // necessary to find XML API libraries
Class<?> rebuild = loader.findClass(args[0]);
Method main = rebuild.getMethod("main",new Class<?>[]{String[].class});
String [] modArgs = new String[args.length - 1];
if (args.length > 1){
System.arraycopy(args, 1, modArgs, 0, modArgs.length);
}
main.invoke(rebuild,new Object[]{modArgs});
}
catch (Exception e){
System.err.println("Error executing main class: " + e.toString());
e.printStackTrace();
System.exit(1);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ set JAVA="%JAVA_HOME%\bin\java"
:gotJava

set COMMON="%CATALINA_HOME%\common"
set CP="%WEBINF%\classes"
set OPTS=-Djava.endorsed.dirs="%WEBINF%\lib;%COMMON%\endorsed;%COMMON%\lib"
set CP="%FEDORA_HOME%\server\bin\${fedora-cli-loader-jar};%WEBINF%\classes"
set OPTS=-Djava.endorsed.dirs="%COMMON%\endorsed;%COMMON%\lib"
set OPTS=%OPTS% -Djavax.net.ssl.trustStore="%FEDORA_HOME%\server\truststore"
set OPTS=%OPTS% -Djavax.net.ssl.trustStorePassword=tomcat
set OPTS=%OPTS% -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
Expand All @@ -56,5 +56,6 @@ set OPTS=%OPTS% -Dorg.apache.commons.logging.LogFactory=org.apache.commons.loggi
set OPTS=%OPTS% -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4jLogger
set OPTS=%OPTS% -Dcom.sun.xacml.PolicySchema="%FEDORA_HOME%\server\xsd\cs-xacml-schema-policy-01.xsd"
set OPTS=%OPTS% -Dfedora.home="%FEDORA_HOME%"
set OPTS=%OPTS% -Dfedora.web.inf.lib="%WEBINF%\lib%"

%JAVA% -server -Xmn64m -Xms256m -Xmx256m -cp %CP% %OPTS% %*
%JAVA% -server -Xmn64m -Xms256m -Xmx256m -cp %CP% %OPTS% fedora.server.utilities.rebuild.cli.CLILoader %*
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ execWithCmdlineArgs() {
execWithTheseArgs() {
common="$CATALINA_HOME"/common
exec_cmd="exec \"$java\" -server -Xmn64m -Xms256m -Xmx256m \
-cp \"$webinf\"/classes \
-Djava.endorsed.dirs=\"$webinf\"/lib:\"$common\"/endorsed:\"$common\"/lib \
-cp \"$webinf\"/classes:\"$FEDORA_HOME\"/server/bin/${fedora-cli-loader-jar} \
-Djava.endorsed.dirs=\"$common\"/endorsed:\"$common\"/lib \
-Djavax.net.ssl.trustStore=\"$FEDORA_HOME\"/server/truststore \
-Djavax.net.ssl.trustStorePassword=tomcat \
-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl \
Expand All @@ -66,7 +66,8 @@ execWithTheseArgs() {
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4jLogger \
-Dcom.sun.xacml.PolicySchema=\"$FEDORA_HOME\"/server/xsd/cs-xacml-schema-policy-01.xsd \
-Dfedora.home=\"$FEDORA_HOME\" \
$1 $2"
-Dfedora.web.inf.lib=\"$webinf\"/lib \
fedora.server.utilities.rebuild.cli.CLILoader $1 $2"
eval $exec_cmd
return $?
}

0 comments on commit f55d8e9

Please sign in to comment.