dev@glassfish.java.net

ShoutOut

From: Byron Nevins <byron.nevins_at_oracle.com>
Date: Sat, 06 Nov 2010 21:36:49 -0700
Here is a Shout Out for Vijay Ramachandran.  He added this VERY handy class that does a lot of nasty tedious logic that you don't want to do.

Say you have been given an argument by the user that somehow represents one or more server instances.  You want to give the user a break and let him or her give you the name of an instance, or the name of a cluster, or the name of a config element.
Transforming that name into a List of Server objects can be done with just a few lines:

import org.glassfish.internal.api.Target;

@Inject
private Target targetHelper;

List<Server> list = targetHelper.getInstances("someName");

If you want to get a list of all instances:

List<Server> list = targetHelper.getAllInstances();

caveat:  The code specifically filters out the Domain Administration Server.
-- 
Byron Nevins  -  Oracle Corporation
Home: 650-359-1290
Cell: 650-784-4123
Sierra: 209-295-2188