geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Dillon <ja...@coredevelopers.net>
Subject Re: Beginning Twiddle Docs
Date Thu, 04 Sep 2003 07:09:37 GMT
Hi.  I am "the twiddle guys" ;-)

Just looked over the docs in the wiki and have two comments.

First, use Twiddle as the entry point for running commands.  The 
easiest way yo add a new command is to define the command in 
etc/twiddle.conf, or if they are geronimo specific in 
etc/twiddle/geronimo.conf

Then you can simply (not well formed java):

<snip>

import org.apache.geronimo.twiddle.Twiddle;
import org.apache.geronimo.twiddle.config.ConfigurationReader;

// Initialize Twiddle

Twiddle twiddle = new Twiddle();
ConfigurationReader reader = new ConfigurationReader();
twiddle.configure(reader.read(new URL(Twiddle.getHomeURL(), 
"etc/twiddle.conf")));

// Execute a command as defined in twiddle.conf (or included files)

int result = twiddle.execute("some/command", new String[] { "my", 
"args" });

</snip>

or if you like you can bind the commands by hand:

<snip>

import org.apache.geronimo.twiddle.config.CommandConfig;
import org.apache.geronimo.twiddle.command.CommandInfo;

// ...

Twiddle twiddle = new Twiddle();

CommandConfig config = new CommandConfig();
config.setName("some/command");
config.setCode("some.class.SomeCommand");
CommandInfo info = new CommandInfo(config, twiddle.getClassWorld());
twiddle.getCommandContainer().addCommandInfo(info);

// Execute the command
int result = twiddle.execute("some/command", new String[] { "my", 
"args" });

</snip>

Note that this process will be stream-lined in the future as I add the 
interactive console bits and refactor how ClassWorlds is used.

But overall the point is to use Twiddle as the facade to the system and 
not invoke commands directly.

Second, in the example command, you System.out.println()... which is 
bad.  You should use the streams passed into the command context using 
getWriter().  Todo this ya need to invoke through Twiddle as it will 
setup the CommandContext, though I must admit that this needs to be 
improved.

The reason for this is to make it hook up to an interactive console, 
which may be running io over a socket and not system.  Also it will 
allow for command pipelining and so on.

Plz do not use System.{in|out|err} from commands.

I will update the wiki to this effect, but wanted to reply to your 
message.

Also, if people are going to be configuring commands directly then 
should probably add a CommandBuilder to streamline all of this.  I was 
going on the assumption that the config files would be used to handle 
these details, but could just be might lack of insight into other uses 
;-)

I am almost finished with some cruft removal and build system 
modifications and will be getting back to twiddle very soon.

Glad to see people are going to make use of it ;-)

--jason


On Thursday, September 4, 2003, at 12:20  PM, Matt Kurjanowicz wrote:

> Hi there,
> In my efforts to learn the twiddle system for a JMX console, I've put
> some introductory docs up on the wiki about creating and running 
> Twiddle
> Commands.  This is *very* basic, and I'm sure will be out of date soon
> (as the Twiddle guys get the CLI up and running.), but it's a start.
>
> I will continue to work on little code snippets and documentation as I
> learn the system (from an outsider's perspective).  If you are actively
> developing what I'm writing about, _please_ contribute because I'm sure
> that I'll make gross mistakes.
>
> Also, as I work on JMX Console CLI, I'll get stuff like this up about
> JMX and how it relates to/works with Geronimo.
>
> To see them, go to the wiki at:
> http://nagoya.apache.org/wiki/apachewiki.cgi?ApacheJ2EE/Twiddle
>
> Thanks again,
> Matt
>


Mime
View raw message