3 Replies Latest reply on Oct 13, 2006 8:51 AM by adrian.brock

    Interacting with class properties rather than instances?

    starksm64

      Do we have a notion of being able to configure class properties rather than instance properties? An example usage is to externalize the current org.jboss.virtual.plugins.context.jar.JarUtils jarSuffixes:

       <bean name="JARUtils" class="org.jboss.virtual.plugins.context.jar.JarUtils" static="true">
       <property name="jarSuffixes">
       <set elementClass="java.lang.String">
       <value>.zip</value>
       <value>.ear</value>
       <value>.jar</value>
       <value>.rar</value>
       <value>.war</value>
       <value>.sar</value>
       <value>.har</value>
       <value>.aop</value>
       <value>.deployer</value>
       </set>
       </property>
       </bean>
      
      


      This has actually been externalized by the JARStructure deployer, so this example can be handled there.


        • 1. Re: Interacting with class properties rather than instances?
          alesj

          Not that I know of.

          Even that static="true" is currently unsupported.

           <xsd:complexType name="beanType">
           ...
           </xsd:sequence>
           <xsd:attribute name="name" type="xsd:string" use="optional"/>
           <xsd:attribute name="class" type="xsd:token" use="optional"/>
           <xsd:attribute name="mode" type="controllerModeType" use="optional"/>
           </xsd:complexType>
          


          Maybe we could rewrite JarUtils to be used as singleton:

          public class JarUtils
          {
           /** The jar suffixes */
           private Set<String> jarSuffixes = new CopyOnWriteArraySet<String>();
          
           private static JarUtils instance = new JarUtils();
          
           public static JarUtils getInstance()
           {
           return instance;
           }
          
           /**
           * Sets the jar suffixes
           *
           * @param suffix the suffix
           * @return true when added
           * @throws IllegalArgumentException for a null suffix
           */
           public void setJarSuffixes(Set<String> suffixes)
           {
           if (suffixes == null)
           throw new IllegalArgumentException("Null suffix");
           jarSuffixes = suffixes;
           }
          
           /**
           * Add a jar suffix
           *
           * @param suffix the suffix
           * @return true when added
           * @throws IllegalArgumentException for a null suffix
           */
           public static boolean addJarSuffix(String suffix)
           {
           if (suffix == null)
           throw new IllegalArgumentException("Null suffix");
           return instance.jarSuffixes.add(suffix);
           }
          
           /**
           * Remove a jar suffix
           *
           * @param suffix the suffix
           * @return true when removed
           * @throws IllegalArgumentException for a null suffix
           */
           public static boolean removeJarSuffix(String suffix)
           {
           if (suffix == null)
           throw new IllegalArgumentException("Null suffix");
           return instance.jarSuffixes.remove(suffix);
           }
          
           ...
          
           <bean name="jarUtils" class="org.jboss.virtual.plugins.context.jar.JarUtils">
           <constructor factoryClass="org.jboss.virtual.plugins.context.jar.JarUtils" factoryMethod="getInstance" />
           <property name="jarSuffixes">
           <set elementClass="java.lang.String">
           <value>.zip</value>
           <value>.ear</value>
           <value>.jar</value>
           <value>.rar</value>
           <value>.war</value>
           <value>.sar</value>
           <value>.har</value>
           <value>.aop</value>
           <value>.deployer</value>
           </set>
           </property>
           </bean>
          


          Or simply use it as a bean defined in some top level deployment - and simply injected into dependent beans.



          • 2. Re: Interacting with class properties rather than instances?
            starksm64

            There already is a bean that can be used for this in jboss5 (JARStructure deployer) so I don't have an immeadiate issue to resolve. This was more of a question on whether the mc supported class properties.

            • 3. Re: Interacting with class properties rather than instances?

              "Do we have a notion of being able to configure class properties rather than instance properties?"

              No, because I don't want the JBossMC metadata turning into
              scripting language. :-)