admin@glassfish.java.net

Re: Invoking a command from a command

From: Amy Roh <amy.roh_at_oracle.com>
Date: Thu, 03 Jun 2010 13:59:39 -0700

Joe Di Pol wrote:
> Tim Quinn wrote:
>> I'm not sure if this is the "recommended" way, but it's what we've
>> done for DeployCommand.
>
> Thanks Tim, this is good info. I'll take a closer look at it.
>
> Just to clarify my Case #1. What I'm looking for is a way for
> command code in the DAS to execute another pre-existing command
> in the DAS -- for example start-cluster looping over the instances
> and calling start-instance for each instance.
>
> I see there is a CommandRunner (CommandRunnerImpl) -- maybe
> I should look at how AdminAdapter uses CommandRunner?

CreateHttpListener invokes CreateProtocol, etc. using CommandRunnder.
You might want to look at that.


Amy
>

>
> Joe
>
>>
>> Define a supplemental command using the annotations Vijay described
>> on the wiki page:
>>
>> http://wiki.glassfish.java.net/Wiki.jsp?page=CLIDeveloperGuide
>>
>> The supplemental command will be run after (by default) the command
>> it identifies in its @Supplemental annotation. Then have the
>> supplemental command do what it needs to. If you look at these
>> classes I recently checked in (deployment/admin module) you'll see
>> what's happening.
>>
>> DeployCommand - a few changes to populate a data structure shared
>> with the supplemental command; marked for DAS execution only
>>
>> PostDeployCommand - the supplemental command, also for DAS execution
>> only; uses some infrastructure classes to execute a separate, remote
>> command on the instances implied by the target.
>>
>> DeployCommandSupplementalInfo - the shared data structure class I
>> alluded to earlier
>>
>> InstanceDeployCommand - the non-DAS, instance-only command that is
>> run on the remote instances. (It's a no-op for the most part so far.)
>>
>> I think this approach will work well for your case 1. As used in the
>> deployment case the infrastructure will actually take care of
>> invoking the other remote command on the correct instances for you.
>>
>> For your case 2, why not refactor (as needed) the implementation of
>> the other local command so your first local command and the other
>> refactored local command just invoke the same common code?
>>
>> - Tim
>>
>> On Jun 3, 2010, at 3:00 PM, Joe Di Pol wrote:
>>
>>>
>>> I'm looking for a little push in the right direction.
>>> If there are existing commands that do this feel free
>>> to point me at them.
>>>
>>> Case 1
>>> ------
>>> I have a remote command that as part of it's processing
>>> wants to invoke another remote command. For example
>>> start-cluster will likely loop through the instances
>>> and call start-instance on each instance.
>>>
>>> What is the suggested way to have a remote command
>>> execute another remote command locally? Seems like I
>>> want a variation of enterprise.admin.cli.remote.RemoteCommand
>>> that operates directly on the command class (instead
>>> of remotely over HTTP).
>>>
>>> Case 2
>>> -------
>>> Same as Case 1 except I want to call a local command.
>>> For example start-instance may want to call
>>> start-local-instance if the instance is local to the DAS.
>>>
>>> Thanks,
>>>
>>> Joe
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
>>> <mailto:admin-unsubscribe_at_glassfish.dev.java.net>
>>> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>>> <mailto:admin-help_at_glassfish.dev.java.net>
>>>
>>
>>
>>
>> Oracle <http://www.oracle.com>
>> Tim Quinn | GlassFish | +1.847.604.9475
>> Oracle Software Development
>> Lake Forest, IL
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>