dev@glassfish.java.net

Re: List of ConfigBeans

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Tue, 25 Oct 2011 10:03:17 -0400

Pardon my ignorance about getAllTypes and getAllByType, but would the following code force modules to load that hadn't been loaded yet? In other words, does this code fetch all the config beans that have already been loaded, or would it fetch every possible config bean. (A side effect of the latter case is that the code would perform a domain upgrade.) Maybe you need to do a get() on the bean to actually create it?

Thanks,
Bobby

On Oct 24, 2011, at 10:25 PM, Tom Mueller wrote:

> Here's one way to do it:
>
> Iterator<String> types = habitat.getAllTypes();
> String t;
> while (types.hasNext()) {
> t = types.next();
> if (t == null) continue;
> try {
> Class tclass = Class.forName(t);
> if (tclass != null && ConfigBeanProxy.class.isAssignableFrom(tclass)) {
> report.addSubActionsReport().setMessage("Objects of type: " + t);
> for (Object o : habitat.getAllByType(tclass)) {
> report.addSubActionsReport().setMessage(" " + o.hashCode());
> }
> }
> } catch (ClassNotFoundException cnfe) {
> continue;
> }
> }
>
> Tom
>
>
> On 10/24/2011 3:22 PM, Jason Lee wrote:
>> I need to get a list of all of the ConfigBeans in the system. How do I coax that list from the Habitat? I've tried getAllByContract() and getAllByType() (and their various cousins) with no success. My only thought left is to get the Domain then walk down the tree, but I'm hoping there's a nicer way than that. Anyone? :)
>>