On Nov 30, 2009, at 3:08 AM, Sergiu Dumitriu wrote:

> On 11/29/2009 11:56 PM, fmancinelli (SVN) wrote:
>> Author: fmancinelli
>> Date: 2009-11-29 23:56:23 +0100 (Sun, 29 Nov 2009)
>> New Revision: 25362
>>
>> Added:
>>    contrib/people/fmancinelli/
>>    contrib/people/fmancinelli/xwiki-command/
>>    contrib/people/fmancinelli/xwiki-command/README.txt
>>    contrib/people/fmancinelli/xwiki-command/pom.xml
>>    contrib/people/fmancinelli/xwiki-command/src/
>>    contrib/people/fmancinelli/xwiki-command/src/main/
>>    contrib/people/fmancinelli/xwiki-command/src/main/java/
>>    contrib/people/fmancinelli/xwiki-command/src/main/java/META-INF/
>>    contrib/people/fmancinelli/xwiki-command/src/main/java/META-INF/ 
>> MANIFEST.MF
>>    contrib/people/fmancinelli/xwiki-command/src/main/java/org/
>>    contrib/people/fmancinelli/xwiki-command/src/main/java/org/xwiki/
>>    contrib/people/fmancinelli/xwiki-command/src/main/java/org/xwiki/ 
>> command/
>>    contrib/people/fmancinelli/xwiki-command/src/main/java/org/xwiki/ 
>> command/Command.java
>>    contrib/people/fmancinelli/xwiki-command/src/main/java/org/xwiki/ 
>> command/CommandResource.java
>>    contrib/people/fmancinelli/xwiki-command/src/main/java/org/xwiki/ 
>> command/commands/
>>    contrib/people/fmancinelli/xwiki-command/src/main/java/org/xwiki/ 
>> command/commands/LS.java
>>    contrib/people/fmancinelli/xwiki-command/src/main/resources/
>>    contrib/people/fmancinelli/xwiki-command/src/main/resources/META- 
>> INF/
>>    contrib/people/fmancinelli/xwiki-command/src/main/resources/META- 
>> INF/components.txt
>> Log:
>> [Initial import] A proof of concept for a "command line" XWiki  
>> interface based on HTTP.
>>
>>
>> Added: contrib/people/fmancinelli/xwiki-command/README.txt
>> ===================================================================
>> --- contrib/people/fmancinelli/xwiki-command/ 
>> README.txt                           (rev 0)
>> +++ contrib/people/fmancinelli/xwiki-command/README.txt      2009-11-29  
>> 22:56:23 UTC (rev 25362)
>> @@ -0,0 +1,9 @@
>> +This module adds a resource to the XWiki REST subsystem for  
>> executing commands.
>> +This resource accepts text/plain POSTs containing a command line  
>> and sends back
>> +responses in text/plain containing the result of the execution of  
>> the command.
>> +
>> +A simple "ls" command which lists the spaces in a wiki is provided.
>> +
>> +Clients can send commands using cURL in this way:
>> +
>> +curl -d "ls" -H "Content-type: text/plain" 
>> http://localhost:8080/xwiki/rest/command
>>
>> Added: contrib/people/fmancinelli/xwiki-command/src/main/java/org/ 
>> xwiki/command/Command.java
>> ===================================================================
>> --- contrib/people/fmancinelli/xwiki-command/src/main/java/org/ 
>> xwiki/command/Command.java                           (rev 0)
>> +++ contrib/people/fmancinelli/xwiki-command/src/main/java/org/ 
>> xwiki/command/Command.java   2009-11-29 22:56:23 UTC (rev 25362)
>> @@ -0,0 +1,28 @@
>> +package org.xwiki.command;
>> +
>> +import org.xwiki.component.annotation.ComponentRole;
>> +import org.xwiki.component.manager.ComponentManager;
>> +
>> +/**
>> + *<p>
>> + * This is the command interface. Each command should implement  
>> this interface and be annotated with a @Component
>> + * annotation for declaring its name. Don't forget to add the FQN  
>> of the command in the META-INF/components.txt
>> + * otherwise it will not be visible.
>> + *</p>
>> + */
>> +...@componentrole
>> +public interface Command
>> +{
>> +    /**
>> +     *<p>
>> +     * Execute the command
>> +     *</p>
>> +     *
>> +     * @param componentManager The XWiki component manager for  
>> looking up the XWiki components needed for executing the
>> +     *            command.
>> +     * @param arguments The arguments extracted from the command  
>> line.
>> +     * @return A String containing the result of the execution of  
>> the command.
>> +     * @throws Exception
>> +     */
>
> Why do you pass the component manager around? Each component
> implementation can declare a dependency on ComponentManager if it  
> needs it.

I agree it's an implementation details. Even if not using Components,  
it should be passed in the constructor.

-Vincent

>
>> +    String execute(ComponentManager componentManager, String...  
>> arguments) throws Exception;
>> +}

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to