diff --git a/activemq-bootstrap/pom.xml b/activemq-bootstrap/pom.xml
index 6aecaaca7a..85687e702d 100644
--- a/activemq-bootstrap/pom.xml
+++ b/activemq-bootstrap/pom.xml
@@ -61,6 +61,14 @@
io.airlift
airline
+
+ com.sun.winsw
+ winsw
+ 1.9
+ bin
+ exe
+ test
+
junit
junit
@@ -102,6 +110,36 @@
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.2
+
+
+ unpack
+ process-resources
+
+ copy
+
+
+
+
+ com.sun.winsw
+ winsw
+ 1.9
+ bin
+ exe
+ ${basedir}/target/classes/org/apache/activemq/cli/commands/bin
+ activemq-service.exe
+
+
+
+
+
+
+
diff --git a/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Create.java b/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Create.java
index 1a30a84219..49f7164bdf 100644
--- a/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Create.java
+++ b/activemq-bootstrap/src/main/java/org/apache/activemq/cli/commands/Create.java
@@ -97,24 +97,7 @@ public class Create implements Action
host = directory.getName();
}
- new File(directory, "bin").mkdirs();
- new File(directory, "etc").mkdirs();
- new File(directory, "log").mkdirs();
- new File(directory, "tmp").mkdirs();
- new File(directory, "data").mkdirs();
-
- write("bin/activemq", null, true);
- makeExec("bin/activemq");
-
- write("bin/activemq.cmd", null, false);
- write("bin/activemq-service", null, true);
- makeExec("bin/activemq-service");
-
- write("etc/logging.properties", null, false);
- write("etc/bootstrap.xml", null, false);
-
HashMap filters = new HashMap();
-
String replicatedSettings = "";
if (replicated)
{
@@ -149,15 +132,37 @@ public class Create implements Action
filters.put("${activemq.instance}", path(directory, false));
filters.put("${java.home}", path(System.getProperty("java.home"), false));
- write("etc/activemq.profile", filters, true);
- makeExec("etc/activemq.profile");
+ new File(directory, "bin").mkdirs();
+ new File(directory, "etc").mkdirs();
+ new File(directory, "log").mkdirs();
+ new File(directory, "tmp").mkdirs();
+ new File(directory, "data").mkdirs();
- write("etc/activemq.profile.cmd", filters, false);
+
+ if (IS_WINDOWS)
+ {
+ write("bin/activemq.cmd", null, false);
+ write("bin/activemq-service.exe");
+ write("bin/activemq-service.xml", filters, false);
+ write("etc/activemq.profile.cmd", filters, false);
+ }
+
+ if (!IS_WINDOWS || IS_CYGWIN)
+ {
+ write("bin/activemq", null, true);
+ makeExec("bin/activemq");
+ write("bin/activemq-service", null, true);
+ makeExec("bin/activemq-service");
+ write("etc/activemq.profile", filters, true);
+ makeExec("etc/activemq.profile");
+ }
+
+ write("etc/logging.properties", null, false);
+ write("etc/bootstrap.xml", null, false);
write("etc/activemq-configuration.xml", filters, false);
write("etc/activemq-roles.properties", null, false);
write("etc/activemq-users.properties", null, false);
-
context.out.println("");
context.out.println("You can now start the broker by executing: ");
context.out.println("");
@@ -189,15 +194,16 @@ public class Create implements Action
}
}
-// if ( IS_WINDOWS ) {
-//
-// context.out.println("Or you can setup the broker as Windows service and run it in the background:");
-// context.out.println("");
-// context.out.println(String.format(" \"%s\" install", path(service,true)));
-// context.out.println(String.format(" \"%s\" start", path(service, true)));
-// context.out.println("");
-//
-// }
+ if (IS_WINDOWS)
+ {
+
+ context.out.println("Or you can setup the broker as Windows service and run it in the background:");
+ context.out.println("");
+ context.out.println(String.format(" \"%s\" install", path(service, true)));
+ context.out.println(String.format(" \"%s\" start", path(service, true)));
+ context.out.println("");
+
+ }
return null;
}
@@ -282,8 +288,9 @@ public class Create implements Action
return new String(out.toByteArray(), "UTF-8");
}
- private void write(String source, File target) throws IOException
+ private void write(String source) throws IOException
{
+ File target = new File(directory, source);
if (target.exists() && !force)
{
throw new RuntimeException(String.format("The file '%s' already exists. Use --force to overwrite.", target));
diff --git a/activemq-bootstrap/src/main/resources/org/apache/activemq/cli/commands/bin/activemq-service.xml b/activemq-bootstrap/src/main/resources/org/apache/activemq/cli/commands/bin/activemq-service.xml
new file mode 100644
index 0000000000..fa815aae66
--- /dev/null
+++ b/activemq-bootstrap/src/main/resources/org/apache/activemq/cli/commands/bin/activemq-service.xml
@@ -0,0 +1,59 @@
+
+
+
+ activemq-${host}
+ ActiveMQ: ${host}
+ Apache ActiveMQ is a reliable messaging broker
+
+ ${activemq.instance}\log
+ roll
+
+ "${java.home}\bin\java.exe"
+ -XX:+UseParallelGC
+ -XX:+AggressiveOpts
+ -XX:+UseFastAccessorMethods
+ -Xms512M
+ -Xmx1024M
+
+
+
+ -classpath
+ "${activemq.home}\lib\activemq-boot.jar"
+ "-Dactivemq.home=${activemq.home}"
+ "-Dactivemq.instance=${activemq.instance}"
+ "-Ddata.dir=${activemq.instance}/data"
+ -Djava.util.logging.manager=org.jboss.logmanager.LogManager
+ "-Dlogging.configuration=file:${activemq.instance}\etc\logging.properties"
+
+
+
+
+ org.apache.activemq.boot.ActiveMQ
+
+ run
+
+
\ No newline at end of file