You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@batchee.apache.org by rm...@apache.org on 2014/01/18 21:35:39 UTC
[2/2] git commit: creating a zip of batchee cli
creating a zip of batchee cli
Project: http://git-wip-us.apache.org/repos/asf/incubator-batchee/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-batchee/commit/e4cc8e39
Tree: http://git-wip-us.apache.org/repos/asf/incubator-batchee/tree/e4cc8e39
Diff: http://git-wip-us.apache.org/repos/asf/incubator-batchee/diff/e4cc8e39
Branch: refs/heads/master
Commit: e4cc8e391f730c35f3b13b69d5fd292a9869d4a5
Parents: 349bccf
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Sat Jan 18 21:35:58 2014 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Sat Jan 18 21:35:58 2014 +0100
----------------------------------------------------------------------
.../loader/DefaultJobXMLLoaderService.java | 1 -
tools/cli/pom.xml | 35 +
tools/cli/src/main/assembly/bin.xml | 94 ++
.../java/org/apache/batchee/cli/BatchEECLI.java | 2 +
.../org/apache/batchee/cli/command/Names.java | 112 ++
tools/cli/src/main/resources/META-INF/LICENSE | 1545 ++++++++++++++++++
tools/cli/src/main/resources/META-INF/NOTICE | 4 +
.../cli/src/main/resources/META-INF/NOTICE.txt | 4 -
tools/cli/src/main/resources/batchee | 80 +
9 files changed, 1872 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/e4cc8e39/jbatch/src/main/java/org/apache/batchee/container/services/loader/DefaultJobXMLLoaderService.java
----------------------------------------------------------------------
diff --git a/jbatch/src/main/java/org/apache/batchee/container/services/loader/DefaultJobXMLLoaderService.java b/jbatch/src/main/java/org/apache/batchee/container/services/loader/DefaultJobXMLLoaderService.java
index a14377b..280c530 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/services/loader/DefaultJobXMLLoaderService.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/services/loader/DefaultJobXMLLoaderService.java
@@ -38,7 +38,6 @@ public class DefaultJobXMLLoaderService implements JobXMLLoaderService {
}
-
private static String loadJobFromBatchJobs(final String id) {
final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
final String relativePath = PREFIX + id + ".xml";
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/e4cc8e39/tools/cli/pom.xml
----------------------------------------------------------------------
diff --git a/tools/cli/pom.xml b/tools/cli/pom.xml
index 18e264c..3c408e1 100644
--- a/tools/cli/pom.xml
+++ b/tools/cli/pom.xml
@@ -105,6 +105,13 @@
</dependencies>
<build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -129,6 +136,8 @@
<exclude>org.junit:*</exclude>
<exclude>org.hamcrest:*</exclude>
<exclude>com.github.stefanbirkner:*</exclude>
+ <exclude>commons-logging:*</exclude>
+ <exclude>aopalliance:*</exclude>
</excludes>
</artifactSet>
<transformers>
@@ -140,6 +149,32 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2.2</version>
+ <executions>
+ <execution>
+ <id>assembly-bin-distributions</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>src/main/assembly/bin.xml</descriptor>
+ </descriptors>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.batchee.cli.BatchEECLI</mainClass>
+ </manifest>
+ </archive>
+ <finalName>apache-batchee-${project.version}</finalName>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/e4cc8e39/tools/cli/src/main/assembly/bin.xml
----------------------------------------------------------------------
diff --git a/tools/cli/src/main/assembly/bin.xml b/tools/cli/src/main/assembly/bin.xml
new file mode 100644
index 0000000..21f3dcc
--- /dev/null
+++ b/tools/cli/src/main/assembly/bin.xml
@@ -0,0 +1,94 @@
+<?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.
+-->
+<assembly>
+ <id>bin</id>
+ <formats>
+ <format>tar.gz</format>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>${project.basedir}/target/classes</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>LICENSE</include>
+ <include>NOTICE</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/target/classes</directory>
+ <outputDirectory>bin/</outputDirectory>
+ <includes>
+ <include>batchee</include>
+ </includes>
+ <lineEnding>unix</lineEnding>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <dependencySet>
+ <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
+ <outputDirectory>lib</outputDirectory>
+ <scope>runtime</scope>
+ <excludes>
+ <exclude>org.springframework:*</exclude>
+ <exclude>org.apache.geronimo.specs:geronimo-ejb_3.1_spec</exclude>
+ <exclude>org.apache.deltaspike.cdictrl:deltaspike-cdictrl-api</exclude>
+ <exclude>org.testng:*</exclude>
+ <exclude>org.junit:*</exclude>
+ <exclude>org.hamcrest:*</exclude>
+ <exclude>commons-logging:*</exclude>
+ <exclude>aopalliance:*</exclude>
+ <exclude>com.github.stefanbirkner:*</exclude>
+ </excludes>
+ </dependencySet>
+ <dependencySet>
+ <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
+ <outputDirectory>lib</outputDirectory>
+ <scope>provided</scope>
+ <excludes>
+ <exclude>org.springframework:*</exclude>
+ <exclude>org.apache.geronimo.specs:geronimo-ejb_3.1_spec</exclude>
+ <exclude>org.apache.deltaspike.cdictrl:deltaspike-cdictrl-api</exclude>
+ <exclude>org.testng:*</exclude>
+ <exclude>org.junit:*</exclude>
+ <exclude>org.hamcrest:*</exclude>
+ <exclude>commons-logging:*</exclude>
+ <exclude>aopalliance:*</exclude>
+ <exclude>com.github.stefanbirkner:*</exclude>
+ </excludes>
+ </dependencySet>
+ <dependencySet>
+ <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
+ <outputDirectory>lib</outputDirectory>
+ <scope>compile</scope>
+ <excludes>
+ <exclude>org.springframework:*</exclude>
+ <exclude>org.apache.geronimo.specs:geronimo-ejb_3.1_spec</exclude>
+ <exclude>org.apache.deltaspike.cdictrl:deltaspike-cdictrl-api</exclude>
+ <exclude>org.testng:*</exclude>
+ <exclude>org.junit:*</exclude>
+ <exclude>org.hamcrest:*</exclude>
+ <exclude>commons-logging:*</exclude>
+ <exclude>aopalliance:*</exclude>
+ <exclude>com.github.stefanbirkner:*</exclude>
+ </excludes>
+ </dependencySet>
+ </dependencySets>
+</assembly>
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/e4cc8e39/tools/cli/src/main/java/org/apache/batchee/cli/BatchEECLI.java
----------------------------------------------------------------------
diff --git a/tools/cli/src/main/java/org/apache/batchee/cli/BatchEECLI.java b/tools/cli/src/main/java/org/apache/batchee/cli/BatchEECLI.java
index f472b26..245f776 100644
--- a/tools/cli/src/main/java/org/apache/batchee/cli/BatchEECLI.java
+++ b/tools/cli/src/main/java/org/apache/batchee/cli/BatchEECLI.java
@@ -22,6 +22,7 @@ import io.airlift.command.ParseException;
import org.apache.batchee.cli.command.Abandon;
import org.apache.batchee.cli.command.Executions;
import org.apache.batchee.cli.command.Instances;
+import org.apache.batchee.cli.command.Names;
import org.apache.batchee.cli.command.Restart;
import org.apache.batchee.cli.command.Running;
import org.apache.batchee.cli.command.Start;
@@ -34,6 +35,7 @@ public class BatchEECLI {
.withDescription("the stupid content tracker")
.withDefaultCommand(Help.class)
.withCommands(Help.class,
+ Names.class,
Start.class, Restart.class,
Status.class, Running.class,
Stop.class, Abandon.class,
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/e4cc8e39/tools/cli/src/main/java/org/apache/batchee/cli/command/Names.java
----------------------------------------------------------------------
diff --git a/tools/cli/src/main/java/org/apache/batchee/cli/command/Names.java b/tools/cli/src/main/java/org/apache/batchee/cli/command/Names.java
new file mode 100644
index 0000000..46100ee
--- /dev/null
+++ b/tools/cli/src/main/java/org/apache/batchee/cli/command/Names.java
@@ -0,0 +1,112 @@
+/*
+ * 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.batchee.cli.command;
+
+import io.airlift.command.Command;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@Command(name = "names", description = "list known batches")
+public class Names extends JobOperatorCommand {
+ @Override
+ public void doRun() {
+ final Set<String> names = operator().getJobNames();
+ info("");
+ info("names");
+ info("-----");
+ if (names != null) {
+ for (final String name : names) {
+ info(name);
+ }
+ }
+
+ // try to find not yet started jobs
+ final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ final Enumeration<URL> resources;
+ try {
+ resources = loader.getResources("META-INF/batch-jobs");
+ } catch (final IOException e) {
+ return;
+ }
+ while (resources.hasMoreElements()) {
+ final URL url = resources.nextElement();
+ final File file = toFile(url);
+
+ if (file != null) {
+ if (file.isDirectory()) {
+ findInDirectory(file);
+ } else {
+ findInJar(file);
+ }
+ }
+ }
+ }
+
+ private void findInJar(final File file) {
+ final Pattern pattern = Pattern.compile("META\\-INF/batch-jobs/\\(*\\).xml");
+ final JarFile jar;
+ try {
+ jar = new JarFile(file);
+ } catch (final IOException e) {
+ return;
+ }
+ final Enumeration<JarEntry> entries = jar.entries();
+ while (entries.hasMoreElements()) {
+ final JarEntry entry = entries.nextElement();
+ final Matcher matcher = pattern.matcher(entry.getName());
+ if (matcher.matches()) {
+ info(matcher.group(1) + "*");
+ }
+ }
+ }
+
+ private void findInDirectory(final File file) {
+ final String[] batches = file.list(new FilenameFilter() {
+ @Override
+ public boolean accept(final File dir, final String name) {
+ return name.endsWith(".xml");
+ }
+ });
+ if (batches != null) {
+ for (final String batch : batches) {
+ info(batch + "*");
+ }
+ }
+ }
+
+ private static File toFile(final URL url) {
+ final File file;
+ final String externalForm = url.toExternalForm();
+ if ("jar".equals(url.getProtocol())) {
+ file = new File(externalForm.substring("jar:".length(), externalForm.lastIndexOf('!')));
+ } else if ("file".equals(url.getProtocol())) {
+ file = new File(externalForm.substring("file:".length()));
+ } else {
+ file = null;
+ }
+ return file;
+ }
+}