Return-Path: Delivered-To: apmail-avalon-cvs-archive@www.apache.org Received: (qmail 19031 invoked from network); 7 Aug 2004 15:26:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 7 Aug 2004 15:26:22 -0000 Received: (qmail 43984 invoked by uid 500); 7 Aug 2004 15:26:13 -0000 Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 43898 invoked by uid 500); 7 Aug 2004 15:26:13 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 43835 invoked by uid 99); 7 Aug 2004 15:26:12 -0000 X-ASF-Spam-Status: No, hits=-2.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Sat, 07 Aug 2004 08:26:12 -0700 Received: (qmail 18964 invoked by uid 65534); 7 Aug 2004 15:26:10 -0000 Date: 7 Aug 2004 15:26:10 -0000 Message-ID: <20040807152610.18959.qmail@minotaur.apache.org> From: niclas@apache.org To: cvs@avalon.apache.org Subject: svn commit: rev 36065 - in avalon/trunk/planet/facilities/console: api/src/main/org/apache/avalon/facilities/console blocks/default commands/src/main/org/apache/avalon/facilities/console/commands impl/src/main/org/apache/avalon/facilities/console/impl X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: niclas Date: Sat Aug 7 08:26:09 2004 New Revision: 36065 Added: avalon/trunk/planet/facilities/console/commands/src/main/org/apache/avalon/facilities/console/commands/ListCmd.java (contents, props changed) avalon/trunk/planet/facilities/console/commands/src/main/org/apache/avalon/facilities/console/commands/SelectCmd.java (contents, props changed) Modified: avalon/trunk/planet/facilities/console/api/src/main/org/apache/avalon/facilities/console/CommandInterpreter.java avalon/trunk/planet/facilities/console/blocks/default/build.xml avalon/trunk/planet/facilities/console/impl/src/main/org/apache/avalon/facilities/console/impl/CommandInterpreterImpl.java Log: Added select and list commands. Modified: avalon/trunk/planet/facilities/console/api/src/main/org/apache/avalon/facilities/console/CommandInterpreter.java ============================================================================== --- avalon/trunk/planet/facilities/console/api/src/main/org/apache/avalon/facilities/console/CommandInterpreter.java (original) +++ avalon/trunk/planet/facilities/console/api/src/main/org/apache/avalon/facilities/console/CommandInterpreter.java Sat Aug 7 08:26:09 2004 @@ -25,6 +25,6 @@ ContainmentModel getCurrentContainer(); - void setCurrentNode( ContainmentModel node ); + void setCurrentContainer( ContainmentModel node ); } Modified: avalon/trunk/planet/facilities/console/blocks/default/build.xml ============================================================================== --- avalon/trunk/planet/facilities/console/blocks/default/build.xml (original) +++ avalon/trunk/planet/facilities/console/blocks/default/build.xml Sat Aug 7 08:26:09 2004 @@ -41,8 +41,14 @@ + + + + Added: avalon/trunk/planet/facilities/console/commands/src/main/org/apache/avalon/facilities/console/commands/ListCmd.java ============================================================================== --- (empty file) +++ avalon/trunk/planet/facilities/console/commands/src/main/org/apache/avalon/facilities/console/commands/ListCmd.java Sat Aug 7 08:26:09 2004 @@ -0,0 +1,117 @@ +/* + * Copyright 1997-2004 Apache Software Foundation + * + * Licensed 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.avalon.facilities.console.commands; + +import java.io.IOException; +import java.io.BufferedReader; +import java.io.BufferedWriter; + +import org.apache.avalon.composition.model.ComponentModel; +import org.apache.avalon.composition.model.ContainmentModel; +import org.apache.avalon.composition.model.DeploymentModel; + +import org.apache.avalon.facilities.console.CommandInterpreter; +import org.apache.avalon.facilities.console.Console; +import org.apache.avalon.facilities.console.ConsoleCommand; + +import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.ContextException; +import org.apache.avalon.framework.context.Contextualizable; + +import org.apache.avalon.framework.service.Serviceable; +import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.service.ServiceManager; + +/** + * @avalon.component name="console-showmodel" lifestyle="singleton" + * @avalon.service type="org.apache.avalon.facilities.console.ConsoleCommand" + */ +public class ListCmd + implements ConsoleCommand, Serviceable, Contextualizable +{ + String LINE = + "\n-----------------------------------------------------------"; + + private String m_Name; + + public String getName() + { + return m_Name; + } + + public String getDescription() + { + String str = "usage: " + m_Name + " (path)\n\nDisplays the composition model."; + return str; + } + + /** + * Contextulaization of the listener by the container during + * which we are supplied with the root composition model for + * the application. + * + * @param ctx the supplied listener context + * + * @exception ContextException if a contextualization error occurs + * + * @avalon.entry key="urn:avalon:name" + * type="java.lang.String" + */ + public void contextualize( Context ctx ) + throws ContextException + { + m_Name = (String) ctx.get( "urn:avalon:name" ); + } + + /** + * @avalon.dependency type="org.apache.avalon.facilities.console.Console" + * key="console" + */ + public void service( ServiceManager man ) + throws ServiceException + { + Console console = (Console) man.lookup( "console" ); + console.addCommand( this ); + } + + public void execute( CommandInterpreter intp, BufferedReader input, BufferedWriter output, String[] arguments ) + throws Exception + { + output.newLine(); + ContainmentModel current = intp.getCurrentContainer(); + String path; + if( arguments.length == 0 ) + path = current.getPath(); + else + path = arguments[0]; + + DeploymentModel model = current.getModel( path ); + if( model instanceof ContainmentModel ) + { + DeploymentModel[] models = ((ContainmentModel) model).getModels(); + for( int i=0; i 0 ) + { + ContainmentModel current = intp.getCurrentContainer(); + DeploymentModel dm = current.getModel( arguments[0] ); + if( dm instanceof ContainmentModel ) + { + intp.setCurrentContainer( (ContainmentModel) dm ); + } + else + { + output.write( "Not a container: " + arguments[0] ); + output.newLine(); + } + } + output.newLine(); + output.flush(); + } +} Modified: avalon/trunk/planet/facilities/console/impl/src/main/org/apache/avalon/facilities/console/impl/CommandInterpreterImpl.java ============================================================================== --- avalon/trunk/planet/facilities/console/impl/src/main/org/apache/avalon/facilities/console/impl/CommandInterpreterImpl.java (original) +++ avalon/trunk/planet/facilities/console/impl/src/main/org/apache/avalon/facilities/console/impl/CommandInterpreterImpl.java Sat Aug 7 08:26:09 2004 @@ -72,7 +72,7 @@ return m_CurrentNode; } - public void setCurrentNode( ContainmentModel node ) + public void setCurrentContainer( ContainmentModel node ) { m_CurrentNode = node; } @@ -131,6 +131,8 @@ private String waitForCommandLine() throws IOException { + getOutput().write( "[" + m_Socket.getLocalAddress() + " " + m_CurrentNode.getPath() + "]$ " ); + getOutput().flush(); String cmdline = m_Input.readLine().trim(); return cmdline; } --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org