admin@glassfish.java.net

Seeking Guidance

From: Byron Nevins <byron.nevins_at_oracle.com>
Date: Thu, 15 Apr 2010 13:53:35 -0700

Jerome, Bill

I'm about to change a bunch of classes that assume the current server's
name is "server".

BEFORE:
  @Param(optional=true)
     String target = SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME;

AFTER:
// add implements PostConstruct if necessary

@Inject
private ServerEnvironment env;

@Param(optional=true)
   String target;

public void postConstruct() {
    if(target == null)
        target = env.getInstanceName();
}

===============================

I'm doing the more complicated postConstruct() technique because I don't
think I can get away with doing the following with 100% certainty.

@Inject
private ServerEnvironment env;

@Param(optional=true)
   String target = env.getInstanceName();

=================================

Is it guaranteed that the above will work (i.e. order of evaluation by
HK2)?
This is my injection solution. I normally would just use the
old-fashioned way of setting a system-wide final String with the
instance's name.

What do you recommend?


-- 
Byron Nevins  -  Oracle Corporation
Home: 650-359-1290
Cell: 650-784-4123
Sierra: 209-295-2188