Updated Branches: refs/heads/trunk 6e623f80c -> 0debf2173
http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/0debf217/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Helper.scala ---------------------------------------------------------------------- diff --git a/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Helper.scala b/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Helper.scala deleted file mode 100644 index 52bd913..0000000 --- a/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Helper.scala +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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.cli.commands - -import org.fusesource.jansi.Ansi -import org.fusesource.jansi.Ansi.Attribute._ -import java.io.{OutputStream, InputStream, File} - -/** - * <p> - * </p> - * - * @author <a href="http://hiramchirino.com">Hiram Chirino</a> - */ -object Helper { - - def ansi= new Ansi() - - class Failure(msg:String, e:Throwable) extends RuntimeException(msg, e) { - def this(msg:String) = this(msg,null) - } - - def error(value:Any) = throw new Failure(value.toString) - - def bold(v:String) = ansi.a(INTENSITY_BOLD).a(v).reset - -} - - http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/0debf217/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Run.scala ---------------------------------------------------------------------- diff --git a/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Run.scala b/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Run.scala deleted file mode 100644 index a790302..0000000 --- a/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Run.scala +++ /dev/null @@ -1,179 +0,0 @@ -/** - * 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.cli.commands - -import org.apache.felix.gogo.commands.{Action, Option => option, Argument => argument, Command => command} -import org.apache.activemq.apollo.broker.{Broker, ConfigStore} -import org.apache.activemq.apollo.util.FileSupport._ -import org.apache.activemq.apollo.cli.Apollo -import org.apache.felix.service.command.CommandSession -import org.fusesource.hawtdispatch._ -import org.apache.activemq.apollo.util.{FileMonitor, ServiceControl} -import org.apache.log4j.PropertyConfigurator -import java.io.{FileInputStream, File} -import java.util.logging.LogManager -import org.apache.activemq.apollo.dto.BrokerDTO -import scala.collection.mutable.ListBuffer -import java.lang.Thread.UncaughtExceptionHandler -import java.lang.Throwable -import java.security.{Security, Provider} -import scala._ -import scala.AnyRef - -/** - * The apollo run command - */ -@command(scope="apollo", name = "run", description = "runs the broker instance") -class Run extends Action { - - def system_dir(name:String) = { - val base_value = System.getProperty(name) - if( base_value==null ) { - sys.error("The the %s system property is not set.".format(name)) - } - val file = new File(base_value) - if( !file.isDirectory ) { - sys.error("The the %s system property is not set to valid directory path %s".format(name, base_value)) - } - file - } - - def execute(session: CommandSession):AnyRef = { - - try { - - // - // Install an UncaughtExceptionHandler so that all exceptions get properly logged. - val exception_handler = new UncaughtExceptionHandler { - def uncaughtException(t: Thread, error: Throwable) { - Broker.warn(error) - } - } - Thread.setDefaultUncaughtExceptionHandler(exception_handler) - getGlobalQueue().sync(Thread.currentThread().setUncaughtExceptionHandler(exception_handler)) - - val base = system_dir("apollo.base") - val etc: File = base / "etc" - - val log4j_config = etc / "log4j.properties" - PropertyConfigurator.configure(log4j_config.getCanonicalPath) - - val conf = etc / "apollo.xml" - - if( !conf.exists ) { - sys.error("Configuration file'%s' does not exist.\n\nTry creating a broker instance using the 'apollo create' command.".format(conf)); - } - - if( System.getProperty("java.security.auth.login.config")==null ) { - val login_config = etc / "login.config" - if( login_config.exists ) { - System.setProperty("java.security.auth.login.config", login_config.getCanonicalPath) - } - } - - val tmp = base / "tmp" - tmp.mkdirs - - Apollo.print_banner(session.getConsole) - - def println(value:String) = session.getConsole.println(value) - - // Load the configs and start the brokers up. - println("Loading configuration file '%s'.".format(conf)) - - // Use bouncycastle if it's installed. - try { - var loader: ClassLoader = getClass.getClassLoader - var clazz: Class[_] = loader.loadClass("org.bouncycastle.jce.provider.BouncyCastleProvider") - val bouncycastle_provider = clazz.newInstance().asInstanceOf[Provider] - Security.insertProviderAt(bouncycastle_provider, 2) - Broker.info("Loaded the Bouncy Castle security provider.") - } catch { - case e:Throwable => // ignore, we can live without bouncycastle - } - - val broker = new Broker() - - val validation_messages = ListBuffer[String]() - try { - broker.config = ConfigStore.load(conf, validation_messages += _) - } finally { - if( !validation_messages.isEmpty && broker.config.validation != "hide") { - Broker.warn("") - Broker.warn("Broker configuration file failed the following validations:") - validation_messages.foreach{ v => - Broker.warn("") - Broker.warn(" "+v) - } - Broker.warn("") - } - } - - if( broker.config.validation == "strict" && !validation_messages.isEmpty) { - Broker.error("Strict validation was configured, shutting down") - return null - } - - broker.tmp = tmp - broker.start(NOOP) - - val broker_config_monitor = new FileMonitor(conf,broker.dispatch_queue { - broker.console_log.info("Reloading configuration file '%s'.".format(conf)) - broker.update(ConfigStore.load(conf, x=> broker.console_log.info(x) ), ^{ - }) - }) - val log4j_config_monitor = new FileMonitor(log4j_config, { - PropertyConfigurator.configure(log4j_config.getCanonicalPath) - }) - - var jul_config = etc / "jul.properties" - val jul_config_monitor = if ( jul_config.exists()) { - new FileMonitor(jul_config, { - using(new FileInputStream(jul_config)) { is => - LogManager.getLogManager.readConfiguration(is) - } - }) - } else { - null - } - - if(jul_config_monitor!=null) jul_config_monitor.start(NOOP) - log4j_config_monitor.start(NOOP) - broker_config_monitor.start(NOOP) - - Runtime.getRuntime.addShutdownHook(new Thread(){ - override def run: Unit = { - var services = List(log4j_config_monitor, broker_config_monitor, broker) - if(jul_config_monitor!=null) - services ::= jul_config_monitor - ServiceControl.stop(services, "stopping broker") - } - }) - - // wait forever... broker will system exit. - this.synchronized { - this.wait - } - - } catch { - case x:Helper.Failure=> - sys.error(x.getMessage) - } - null - } - -} http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/0debf217/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/StoreExport.scala ---------------------------------------------------------------------- diff --git a/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/StoreExport.scala b/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/StoreExport.scala deleted file mode 100644 index 4a0cb7e..0000000 --- a/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/StoreExport.scala +++ /dev/null @@ -1,99 +0,0 @@ -package org.apache.activemq.apollo.cli.commands - -/** - * 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. - */ -import org.apache.felix.gogo.commands.{Action, Option => option, Argument => argument, Command => command} -import org.apache.activemq.apollo.util.FileSupport._ -import org.apache.activemq.apollo.dto.VirtualHostDTO -import org.apache.activemq.apollo.util._ -import org.apache.felix.service.command.CommandSession -import org.apache.activemq.apollo.broker.ConfigStore -import java.io._ -import org.apache.activemq.apollo.broker.store.StoreFactory - -/** - * The apollo stop command - */ -@command(scope="apollo", name = "store-export", description = "exports the contents of a broker message store") -class StoreExport extends Action { - - object StoreExport extends Log - - @option(name = "--conf", description = "The Apollo configuration file.") - var conf: File = _ - - @option(name = "--virtual-host", description = "The id of the virtual host to export, if not specified, the default virtual host is selected.") - var host: String = _ - - @argument(name = "file", description = "The compressed tar file to hold the exported data", index=0, required=true) - var file:File = _ - - def execute(session: CommandSession):AnyRef = { - import Helper._ - - try { - - val base = system_dir("apollo.base") - - if( conf == null ) { - conf = base / "etc" / "apollo.xml" - } - - if( !conf.exists ) { - error("Configuration file'%s' does not exist.\n\nTry creating a broker instance using the 'apollo create' command.".format(conf)); - } - - val config = ConfigStore.load(conf, session.getConsole.println _) - - val hosts = collection.JavaConversions.collectionAsScalaIterable(config.virtual_hosts).toArray - val vho:Option[VirtualHostDTO] = if( host==null ) { - hosts.headOption - } else { - hosts.filter( _.id == host ).headOption - } - - val vh = vho.getOrElse(error("Could find host to export")) - if( vh.store == null ) { - error("The virtual host '%s' does not have a store configured.".format(vh.id)) - } - - val store = StoreFactory.create(vh.store) - if( store==null ) { - error("Could not create the store.") - } - - session.getConsole.println("Starting store: "+store) - ServiceControl.start(store, "store startup") - - session.getConsole.println("Exporting... (this might take a while)") - using( new BufferedOutputStream(new FileOutputStream(file)) ) { os=> - sync_cb[Option[String]] { cb => - store.export_data(os, cb) - }.foreach(error _) - } - ServiceControl.stop(store, "store stop"); - session.getConsole.println("Done. Export located at: "+file) - - } catch { - case x:Failure=> - error(x.getMessage) - } - null - } - - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/0debf217/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/StoreImport.scala ---------------------------------------------------------------------- diff --git a/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/StoreImport.scala b/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/StoreImport.scala deleted file mode 100644 index a47a6b2..0000000 --- a/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/StoreImport.scala +++ /dev/null @@ -1,101 +0,0 @@ -package org.apache.activemq.apollo.cli.commands - -/** - * 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. - */ -import org.apache.felix.gogo.commands.{Action, Option => option, Argument => argument, Command => command} -import org.apache.activemq.apollo.util.FileSupport._ -import org.apache.activemq.apollo.dto.VirtualHostDTO -import org.apache.activemq.apollo.util._ -import org.apache.felix.service.command.CommandSession -import org.apache.activemq.apollo.broker.ConfigStore -import org.apache.activemq.apollo.broker.store.{ImportStreamManager, StoreFactory} -import java.io.{FileInputStream, BufferedInputStream, File} - - -/** - * The apollo stop command - */ -@command(scope="apollo", name = "store-import", description = "imports a previously exported message store") -class StoreImport extends Action { - - object StoreImport extends Log - - @option(name = "--conf", description = "The Apollo configuration file.") - var conf: File = _ - - @option(name = "--virtual-host", description = "The id of the virtual host to import into, if not specified, the default virtual host is selected.") - var host: String = _ - - @argument(name = "file", description = "The compressed tar file the contains that data for the import", index=0, required=true) - var file:File = _ - - def execute(session: CommandSession):AnyRef = { - import Helper._ - - try { - - val base = system_dir("apollo.base") - - if( conf == null ) { - conf = base / "etc" / "apollo.xml" - } - - if( !conf.exists ) { - error("Configuration file'%s' does not exist.\n\nTry creating a broker instance using the 'apollo create' command.".format(conf)); - } - - val config = ConfigStore.load(conf, session.getConsole.println _) - - val hosts = collection.JavaConversions.collectionAsScalaIterable(config.virtual_hosts).toArray - val vho:Option[VirtualHostDTO] = if( host==null ) { - hosts.headOption - } else { - hosts.filter( _.id == host ).headOption - } - - val vh = vho.getOrElse(error("Could find host to export")) - if( vh.store == null ) { - error("The virtual host '%s' does not have a store configured.".format(vh.id)) - } - - val store = StoreFactory.create(vh.store) - if( store==null ) { - error("Could not create the store.") - } - - session.getConsole.println("Starting store: "+store) - ServiceControl.start(store, "store startup") - - session.getConsole.println("Importing: "+file) - using( new BufferedInputStream(new FileInputStream(file)) ) { is => - sync_cb[Option[String]] { cb => - store.import_data(is, cb) - }.foreach(error _) - } - - ServiceControl.stop(store, "store stop"); - session.getConsole.println("Done.") - - } catch { - case x:Failure=> - error(x.getMessage) - } - null - } - - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/0debf217/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Version.scala ---------------------------------------------------------------------- diff --git a/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Version.scala b/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Version.scala deleted file mode 100644 index bdc8110..0000000 --- a/apollo-cli/src/main/scala/org/apache/activemq/apollo/commands/Version.scala +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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.cli.commands - -import org.apache.felix.gogo.commands.{Action, Option => option, Argument => argument, Command => command} -import org.apache.activemq.apollo.broker.Broker -import org.apache.felix.service.command.CommandSession -/** - * The apollo run command - */ -@command(scope="apollo", name = "--version", description = "Displays the broker version") -class Version extends Action { - - def execute(session: CommandSession):AnyRef = { - session.getConsole.println(Broker.version) - null - } - -} http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/0debf217/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ApolloIDERunner.scala ---------------------------------------------------------------------- diff --git a/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ApolloIDERunner.scala b/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ApolloIDERunner.scala index 607aac5..7d2482c 100644 --- a/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ApolloIDERunner.scala +++ b/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ApolloIDERunner.scala @@ -65,7 +65,7 @@ object ApolloIDERunner { println("Press Enter To Shutdown") println("=======================") - new Apollo().run(Array("run")) + new Apollo().run(System.in, System.out, System.err, Array("run")) System.in.read println("=============") println("Shutting down") http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/0debf217/apollo-distro/pom.xml ---------------------------------------------------------------------- diff --git a/apollo-distro/pom.xml b/apollo-distro/pom.xml index 8c9e5ab..bb0830b 100644 --- a/apollo-distro/pom.xml +++ b/apollo-distro/pom.xml @@ -143,12 +143,6 @@ </dependency> <dependency> - <groupId>org.apache.karaf.shell</groupId> - <artifactId>org.apache.karaf.shell.console</artifactId> - <version>${karaf-version}</version> - </dependency> - - <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>${jersey-version}</version> http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/0debf217/apollo-distro/src/main/descriptors/common-bin.xml ---------------------------------------------------------------------- diff --git a/apollo-distro/src/main/descriptors/common-bin.xml b/apollo-distro/src/main/descriptors/common-bin.xml index e21e5dc..ba242ff 100644 --- a/apollo-distro/src/main/descriptors/common-bin.xml +++ b/apollo-distro/src/main/descriptors/common-bin.xml @@ -87,8 +87,10 @@ <include>log4j:log4j</include> <!-- Implements the cli shell --> - <include>org.apache.karaf.shell:org.apache.karaf.shell.console</include> - + <include>io.airlift:airline</include> + <include>javax.inject:javax.inject</include> + <include>org.fusesource.jansi:jansi</include> + <!-- for the AMQP protocol impl --> <include>org.apache.qpid:proton-api</include> <include>org.apache.qpid:proton</include> http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/0debf217/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ApolloApplication.scala ---------------------------------------------------------------------- diff --git a/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ApolloApplication.scala b/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ApolloApplication.scala index 99561f1..843d2e9 100644 --- a/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ApolloApplication.scala +++ b/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ApolloApplication.scala @@ -52,7 +52,7 @@ class ApolloApplication extends Filter { create.host_security_config = "" create.home = null println("Generating broker instance directory at: "+create.base) - create.run() + create.run(System.out, System.err) } if( !conf.exists ) { http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/0debf217/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index e08d2cd..43914f9 100755 --- a/pom.xml +++ b/pom.xml @@ -135,13 +135,15 @@ <!-- osgi stuff --> <osgi-version>4.2.0</osgi-version> - <karaf-version>2.2.2</karaf-version> + <jansi-version>1.11</jansi-version> + <airline-version>0.6</airline-version> <features-maven-plugin-version>2.1.0</features-maven-plugin-version> <osgi.fragment.host>${project.groupId}.apollo-broker</osgi.fragment.host> <mvnplugins-version>1.15</mvnplugins-version> <qpid-proton-version>0.3.0-fuse-2</qpid-proton-version> <qpid-jms-version>0.20</qpid-jms-version> + </properties> <prerequisites>
