dev@glassfish.java.net

NotNull vs Element(required=true)

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Mon, 19 Jul 2010 12:11:37 -0400

What's the difference between these (in
com.sun.enterprise.config.serverbeans.Config.java) *supposed* to be?

1)
     @Element(required=true)
     GroupManagementService getGroupManagementService();

2)
     @Element
     @NotNull
     GroupManagementService getGroupManagementService();

I can try them both, but what is the difference *supposed* to be? We
have default values for all children in the group-management-service
element, but suddenly we're not seeing the element in domain.xml at
all and are getting NPEs in the code. It worked until a couple days
ago, and we didn't change anything. By "worked" I mean the element was
present in the config element of domain.xml as <group-management-
service/>.

FWIW, attempt 1 above still fails. Still getting null from
config.getGroupManagementService() and I don't see the element in
domain.xml (does required=true do anything?).

Also, attempt 2 above does the same thing. This is related to issue
12719 and we don't know what magic in config-api is needed to fix it
besides manually adding everything in the create-cluster decorator and
abandoning defaults/notnulls.

For defaults, we have defaults and elements like this in
com.sun.enterprise.config.serverbeans.GroupManagementService:

     @Attribute (defaultValue="5000")
     @Min(value=1000)
     @Max(value=120000)
     String getGroupDiscoveryTimeoutInMillis();

and:

     @Element //(required=true)
     @NotNull
     FailureDetection getFailureDetection();

FailureDetection has its own defaults that we also need.

Thanks,
Bobby