You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2011/06/02 17:52:56 UTC
svn commit: r1130614 - in /activemq/activemq-apollo/trunk: ./ apollo-boot/
apollo-boot/src/ apollo-boot/src/main/ apollo-boot/src/main/java/
apollo-boot/src/main/java/org/ apollo-boot/src/main/java/org/apache/
apollo-boot/src/main/java/org/apache/activ...
Author: chirino
Date: Thu Jun 2 15:52:55 2011
New Revision: 1130614
URL: http://svn.apache.org/viewvc?rev=1130614&view=rev
Log:
Adding a new boot module which helps simplify discovering the correct apollo class path.
Added:
activemq/activemq-apollo/trunk/apollo-boot/
activemq/activemq-apollo/trunk/apollo-boot/pom.xml
activemq/activemq-apollo/trunk/apollo-boot/src/
activemq/activemq-apollo/trunk/apollo-boot/src/main/
activemq/activemq-apollo/trunk/apollo-boot/src/main/java/
activemq/activemq-apollo/trunk/apollo-boot/src/main/java/org/
activemq/activemq-apollo/trunk/apollo-boot/src/main/java/org/apache/
activemq/activemq-apollo/trunk/apollo-boot/src/main/java/org/apache/activemq/
activemq/activemq-apollo/trunk/apollo-boot/src/main/java/org/apache/activemq/apollo/
activemq/activemq-apollo/trunk/apollo-boot/src/main/java/org/apache/activemq/apollo/boot/
activemq/activemq-apollo/trunk/apollo-boot/src/main/java/org/apache/activemq/apollo/boot/Boot.java
Modified:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/JettyWebServer.scala
activemq/activemq-apollo/trunk/apollo-distro/pom.xml
activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml
activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo
activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo.cmd
activemq/activemq-apollo/trunk/pom.xml
Added: activemq/activemq-apollo/trunk/apollo-boot/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-boot/pom.xml?rev=1130614&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-boot/pom.xml (added)
+++ activemq/activemq-apollo/trunk/apollo-boot/pom.xml Thu Jun 2 15:52:55 2011
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-project</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-boot</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>${project.artifactId}</name>
+
+</project>
Added: activemq/activemq-apollo/trunk/apollo-boot/src/main/java/org/apache/activemq/apollo/boot/Boot.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-boot/src/main/java/org/apache/activemq/apollo/boot/Boot.java?rev=1130614&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-boot/src/main/java/org/apache/activemq/apollo/boot/Boot.java (added)
+++ activemq/activemq-apollo/trunk/apollo-boot/src/main/java/org/apache/activemq/apollo/boot/Boot.java Thu Jun 2 15:52:55 2011
@@ -0,0 +1,110 @@
+/**
+ * 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.activemq.apollo.boot;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.*;
+
+/**
+ * <p>
+ * A main class which setups up a classpath and then passes
+ * execution off to another main class
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public class Boot {
+
+ public static void main(String[] args) throws Throwable, NoSuchMethodException, IllegalAccessException {
+ LinkedList<String> argList = new LinkedList<String>(Arrays.asList(args));
+ if( argList.isEmpty() ) {
+ System.err.println("Usage "+Boot.class.getName()+" <bootdir>(:<bootdir>)* <main-class> <arg>*");
+ System.err.println();
+ System.err.println("Mising <bootdir>");
+ System.exit(2);
+ }
+ String[] bootdirs = argList.removeFirst().split(":");
+
+ if( argList.isEmpty() ) {
+ System.err.println("Usage "+Boot.class.getName()+" <bootdir>(:<bootdir>)* <main-class> <arg>*");
+ System.err.println();
+ System.err.println("Mising <main-class>");
+ System.exit(2);
+ }
+ String mainClass = argList.removeFirst();
+ String[] mainArgs = argList.toArray(new String[argList.size()]);
+
+ ArrayList<URL> urls = new ArrayList<URL>();
+
+ for(String dir:bootdirs) {
+ dir = dir.trim();
+ if( dir.isEmpty() ) {
+ continue;
+ }
+
+ File bootdir = new File(dir);
+ if( bootdir.isDirectory() ) {
+
+ // Find the jar files in the directory..
+ ArrayList<File> files = new ArrayList<File>();
+ for( File f : bootdir.listFiles() ) {
+ if( f.getName().endsWith(".jar") || f.getName().endsWith(".zip") ) {
+ files.add(f);
+ }
+ }
+ // Sort the list by file name..
+ Collections.sort(files, new Comparator<File>() {
+ public int compare(File file, File file1) {
+ return file.getName().compareTo(file1.getName());
+ }
+ });
+
+ for( File f : files ) {
+ add(urls, f);
+ }
+
+ } else if( bootdir.isFile() ) {
+ add(urls, bootdir);
+ }
+ }
+
+ // Now setup our classloader..
+ URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
+ Class<?> clazz = loader.loadClass(mainClass);
+ Method method = clazz.getMethod("main", args.getClass());
+ try {
+ method.invoke(null, (Object)mainArgs);
+ } catch (InvocationTargetException e) {
+ throw e.getTargetException();
+ }
+
+ }
+
+ static private void add(ArrayList<URL> urls, File file) {
+ try {
+ urls.add(file.toURI().toURL());
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/JettyWebServer.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/JettyWebServer.scala?rev=1130614&r1=1130613&r2=1130614&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/JettyWebServer.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/JettyWebServer.scala Thu Jun 2 15:52:55 2011
@@ -220,6 +220,7 @@ class JettyWebServer(val broker:Broker)
var context = new WebAppContext
context.setContextPath(prefix)
context.setWar(webapp.getCanonicalPath)
+ context.setClassLoader(Broker.class_loader)
if( broker.tmp !=null ) {
context.setTempDirectory(broker.tmp)
}
@@ -228,41 +229,11 @@ class JettyWebServer(val broker:Broker)
}
- def secured(handler:Handler) = {
- handler
-// if( config.authentication!=null && config.acl!=null ) {
-// val security_handler = new ConstraintSecurityHandler
-// val login_service = new JAASLoginService(config.authentication.domain)
-// val role_class_names:List[String] = config.authentication.acl_principal_kinds().toList
-//
-// login_service.setRoleClassNames(role_class_names.toArray)
-// security_handler.setLoginService(login_service)
-// security_handler.setIdentityService(new DefaultIdentityService)
-// security_handler.setAuthenticator(new BasicAuthenticator)
-//
-// val cm = new ConstraintMapping
-// val c = new org.eclipse.jetty.http.security.Constraint()
-// c.setName("BASIC")
-// val admins:Set[PrincipalDTO] = config.acl.admins.toSet ++ config.acl.monitors.toSet
-// c.setRoles(admins.map(_.allow).toArray)
-// c.setAuthenticate(true)
-// cm.setConstraint(c)
-// cm.setPathSpec("/*")
-// cm.setMethod("GET")
-// security_handler.addConstraintMapping(cm)
-//
-// security_handler.setHandler(handler)
-// security_handler
-// } else {
-// handler
-// }
- }
-
val context_list = new HandlerList
contexts.values.foreach(context_list.addHandler(_))
server = new Server
- server.setHandler(secured(context_list))
+ server.setHandler(context_list)
server.setConnectors(connectors.values.toArray)
server.start
Modified: activemq/activemq-apollo/trunk/apollo-distro/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/pom.xml?rev=1130614&r1=1130613&r2=1130614&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/pom.xml Thu Jun 2 15:52:55 2011
@@ -32,6 +32,11 @@
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-boot</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
<artifactId>apollo-cli</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml?rev=1130614&r1=1130613&r2=1130614&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml Thu Jun 2 15:52:55 2011
@@ -66,8 +66,20 @@
</includes>
<excludes>
<exclude>org.apache.activemq:apollo-web:pom</exclude>
+ <exclude>org.apache.activemq:apollo-boot</exclude>
</excludes>
</dependencySet>
+
+ <dependencySet>
+ <outputDirectory>/lib</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
+ <unpack>false</unpack>
+ <useTransitiveDependencies>false</useTransitiveDependencies>
+ <includes>
+ <include>org.apache.activemq:apollo-boot</include>
+ </includes>
+ </dependencySet>
+
</dependencySets>
<fileSets>
Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo?rev=1130614&r1=1130613&r2=1130614&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo Thu Jun 2 15:52:55 2011
@@ -101,21 +101,18 @@ if [ ! -x "$JAVACMD" ] ; then
exit 1
fi
-CLASSPATH=""
+CLASSPATH="${APOLLO_HOME}/lib/apollo-boot.jar"
if [ ! -z "$APOLLO_BASE" ] ; then
- CLASSPATH="${APOLLO_BASE}/etc"
+ CLASSPATH="${APOLLO_BASE}/etc:${CLASSPATH}"
+fi
+
+BOOTDIRS="${APOLLO_HOME}/lib"
+if [ ! -z "$APOLLO_BASE" ] ; then
+ BOOTDIRS="${APOLLO_BASE}/lib:${BOOTDIRS}"
fi
-if [ -d "${APOLLO_HOME}/lib/patches" ] ; then
- for f in "${APOLLO_HOME}/lib/patches"/*.jar; do
- CLASSPATH="$CLASSPATH:$f"
- done
-fi
-for f in "${APOLLO_HOME}/lib"/*.jar; do
- CLASSPATH="$CLASSPATH:$f"
-done
JUL_CONFIG_FILE="${APOLLO_HOME}/etc/jul.properties"
-
+
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
APOLLO_HOME=`cygpath --windows "$APOLLO_HOME"`
@@ -155,4 +152,4 @@ fi
# Attempt to bump up the ulimit
ulimit -n 100000 > /dev/null 2> /dev/null
-${EXEC} "$JAVACMD" ${JVM_FLAGS} ${SYSTEM_PROPS} -classpath "${CLASSPATH}" org.apache.activemq.apollo.cli.Apollo $@
+${EXEC} "$JAVACMD" ${JVM_FLAGS} ${SYSTEM_PROPS} -classpath "${CLASSPATH}" org.apache.activemq.apollo.boot.Boot ${BOOTDIRS} org.apache.activemq.apollo.cli.Apollo $@
Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo.cmd
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo.cmd?rev=1130614&r1=1130613&r2=1130614&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo.cmd (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo.cmd Thu Jun 2 15:52:55 2011
@@ -47,10 +47,11 @@ echo.
:RUN_JAVA
-set CLASSPATH=
-if NOT "x%APOLLO_BASE%" == "x" set CLASSPATH=%APOLLO_BASE%\etc
+set CLASSPATH=%APOLLO_HOME%\lib\apollo-boot.jar
+if NOT "x%APOLLO_BASE%" == "x" set CLASSPATH=%APOLLO_BASE%\etc;%CLASSPATH%
-for %%i in ("%APOLLO_HOME%\lib\*.jar") do call :ADD_CLASSPATH %%i
+set BOOTDIRS=%APOLLO_HOME%\lib
+if NOT "x%APOLLO_BASE%" == "x" set BOOTDIRS=%APOLLO_BASE%\lib:%BOOTDIRS%
if "%JVM_FLAGS%" == "" set JVM_FLAGS=-server -Xmx1G
@@ -59,7 +60,7 @@ if "x%APOLLO_OPTS%" == "x" goto noAPOLLO
:noAPOLLO_OPTS
if "x%APOLLO_DEBUG%" == "x" goto noDEBUG
- set JVM_FLAGS=%JVM_FLAGS% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspEND=n,address=5005
+ set JVM_FLAGS=%JVM_FLAGS% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
:noDEBUG
if "x%APOLLO_PROFILE%" == "x" goto noPROFILE
@@ -78,7 +79,7 @@ if NOT "x%APOLLO_BASE%" == "x" set JVM_F
set JVM_FLAGS=%JVM_FLAGS% -Djava.util.logging.config.file="%JUL_CONFIG_FILE%"
set JVM_FLAGS=%JVM_FLAGS% -classpath "%CLASSPATH%"
-"%_JAVACMD%" %JVM_FLAGS% org.apache.activemq.apollo.cli.Apollo %*
+"%_JAVACMD%" %JVM_FLAGS% org.apache.activemq.apollo.boot.Boot %BOOTDIRS% org.apache.activemq.apollo.cli.Apollo %*
:END
endlocal
Modified: activemq/activemq-apollo/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/pom.xml?rev=1130614&r1=1130613&r2=1130614&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/pom.xml (original)
+++ activemq/activemq-apollo/trunk/pom.xml Thu Jun 2 15:52:55 2011
@@ -157,6 +157,7 @@
</distributionManagement>
<modules>
+ <module>apollo-boot</module>
<module>apollo-scala</module>
<module>apollo-util</module>
<module>apollo-transport</module>