dev@glassfish.java.net

Re: List of ConfigBeans

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Mon, 24 Oct 2011 21:25:06 -0500

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? :)
>