You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/03/05 23:37:09 UTC
svn commit: r1297259 - in
/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli:
CliRunnable.java command/DeployedAppCommand.java
Author: rmannibucau
Date: Mon Mar 5 22:37:08 2012
New Revision: 1297259
URL: http://svn.apache.org/viewvc?rev=1297259&view=rev
Log:
adding apps command to print deployed apps
Added:
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/DeployedAppCommand.java
Modified:
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java
Modified: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java?rev=1297259&r1=1297258&r2=1297259&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java (original)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java Mon Mar 5 22:37:08 2012
@@ -36,16 +36,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.TreeMap;
public class CliRunnable implements Runnable {
private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB_SERVER, CliRunnable.class);
- public static final String SERVICE_FOLDER = "META-INF/org/apache/openejb/server";
- public static final String SERVICE_FILE = "commands.xml";
-
private static final String BRANDING_FILE = "branding.properties";
private static final String WELCOME_KEY_PREFIX = "welcome_";
private static final String WELCOME_COMMON_KEY = WELCOME_KEY_PREFIX + "common";
@@ -63,7 +60,7 @@ public class CliRunnable implements Runn
private static final Properties PROPERTIES = new Properties();
private static final boolean tomee;
- private static Map<String, Class<?>> COMMANDS = new HashMap<String, Class<?>>();
+ private static final Map<String, Class<?>> COMMANDS = new TreeMap<String, Class<?>>();
private static final OpenEJBScripter scripter = new OpenEJBScripter();
static {
@@ -219,7 +216,7 @@ public class CliRunnable implements Runn
}
if (cmdClass != null) {
- ObjectRecipe recipe = new ObjectRecipe(cmdClass);
+ final ObjectRecipe recipe = new ObjectRecipe(cmdClass);
recipe.setProperty("streamManager", streamManager);
recipe.setProperty("command", line);
recipe.setProperty("scripter", scripter);
Added: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/DeployedAppCommand.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/DeployedAppCommand.java?rev=1297259&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/DeployedAppCommand.java (added)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/DeployedAppCommand.java Mon Mar 5 22:37:08 2012
@@ -0,0 +1,47 @@
+/*
+ * 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.openejb.server.cli.command;
+
+import org.apache.openejb.AppContext;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+@Command(name = "apps", usage = "apps", description = "list deployed applications")
+public class DeployedAppCommand extends PathCommand {
+ @Override
+ public void execute(final String cmd) {
+ streamManager.writeOut("Deployed applications:");
+ final List<AppContext> apps = new ArrayList<AppContext>(SystemInstance.get()
+ .getComponent(ContainerSystem.class).getAppContexts());
+ Collections.sort(apps, new AppContextComparable());
+ for (AppContext appContext : apps) {
+ streamManager.writeOut(" - " + appContext.getId());
+ }
+ }
+
+ private class AppContextComparable implements Comparator<AppContext> {
+ @Override
+ public int compare(final AppContext o1, final AppContext o2) {
+ return o1.getId().compareTo(o2.getId());
+ }
+ }
+}