admin@glassfish.java.net

ConfigSupport.createChildOf: inappropriate children of ConfigBeans?

From: Lloyd L Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Fri, 14 Mar 2008 16:46:41 -0700

What prevents this code from adding some random config as a child, one
that is not an @Element of the config?

It seems related to my issue of knowing what the legal child
interfaces are when creating a child:

     /**
      * Creates a new child of a parent configured object
      *
      * @param parent the parent configured object
      * @param type type of the child
      * @return new child instance of the provided type
      * @throws TransactionFailure if the child cannot be created
      */
      public static <T extends ConfigBeanProxy> T createChildOf(Object
parent, Class<T> type) throws TransactionFailure {
          if (parent==null) {
              throw new IllegalArgumentException("parent cannot be
null");
          }
          try {
              WriteableView bean =
WriteableView
.class.cast(Proxy.getInvocationHandler(Proxy.class.cast(parent)));
              return bean.allocateProxy(type);
          } catch (ClassCastException e) {
              throw new TransactionFailure("Must use a locked parent
config object for instantiating new config object", e);
          }


      }



---
Lloyd L Chambers
lloyd.chambers_at_sun.com
Sun Microsystems, Inc