dev@glassfish.java.net

Re: How to use _at_Param String targetName?

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Mon, 18 Oct 2010 16:12:37 -0500

  Most of the list commands that take a target, take the target as an
operand rather than an option.

Here is the beginning of the list-components command:

@Service(name="list-components")
@I18n("list.components")
@Scoped(PerLookup.class)
@ExecuteOn(value={RuntimeType.DAS})
@TargetType(value={CommandTarget.DOMAIN, CommandTarget.DAS,
CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER})
public class ListComponentsCommand implements AdminCommand {

     @Param(optional=true)
     String type = null;

     @Param(primary=true, optional=true)
     public String target = "server";

Looking at the differences, the @ExecuteOn should be only for the DAS -
there is no need to run list commands on instances.

list-components uses the name "target" for the field, rather than
targetName. Although I would expect your syntax to work, maybe that is
the problem.
Also, does the field need to be public?

Hope this helps.
Tom


On 10/18/2010 2:47 PM, Ken wrote:
> I've been working on modifying the iiop-listener commands to support
> --target.
> For example, I have modified list-iiop-listeners as follows:
>
> @Service(name="list-iiop-listeners")
> @Scoped(PerLookup.class)
> @I18n("list.iiop.listeners")
> @ExecuteOn(value={RuntimeType.DAS,RuntimeType.INSTANCE})
> @TargetType(value={CommandTarget.CLUSTER,CommandTarget.CONFIG,
> CommandTarget.DAS,CommandTarget.STANDALONE_INSTANCE }
> )
> public class ListIiopListeners implements AdminCommand {
>
> final private static LocalStringManagerImpl localStrings =
> new LocalStringManagerImpl(ListIiopListeners.class);
>
> @Param(name="target")
> String targetName ;
>
> @Inject
> Habitat habitat ;
>
>
> /**
> * Executes the command
> *
> * @param context information
> */
> @Override
> public void execute(AdminCommandContext context) {
> final ActionReport report = context.getActionReport();
> final Target targetUtil = habitat.getComponent(Target.class ) ;
> final Config config = targetUtil.getConfig(targetName) ;
> final IiopService iiopService = config.getIiopService();
>
> ...
> }
>
> But when I try to build, the built-in tests fail as follows:
>
> Running org.glassfish.orb.admin.cli.ListIiopListenersTest
> Oct 18, 2010 12:30:31 PM org.jvnet.hk2.component.InjectionManager inject
> INFO: Cannot inject java.lang.String
> org.glassfish.orb.admin.cli.ListIiopListeners.targetName into
> component org.glassfish.orb.admin.cli.ListIiopListeners_at_e8efc5
> Oct 18, 2010 12:30:31 PM com.sun.logging.LogDomains$1 log
> SEVERE: Cannot find targetName in list-iiop-listeners command model,
> file a bug
>
>
> So what am I missing? @Param String targetName (as documented on the
> wiki) fails in the same way.
>
> Thanks,
>
> Ken.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>