8 Replies Latest reply on Nov 27, 2005 10:54 PM by gavin.king

    Proposal for Configuration Redesign

    gavin.king

      Currently, configuration of Seam components (which includes configuration of Seam itself, via the built-in components, and configuration of user components) works via merging together properties found in the seam.properties file and the web.xml file.

      I did it this way because it was the simplest possible thing that could work at the time. However, I'm now revisiting this decision. I've remembered that of course Java EE already provides a configuration mechanism for session beans (namely, environment entries defined in the deployment descriptor, together with the @Resource annotation), so configuration of a component looks like this:

      @Stateless
      @Name("myLogger")
      public class MyLoggerBean implements MyLogger {
       @Resource String logFilename;
       ...
      }
      
      <ejb-jar>
       <enterprise-beans>
       <session>
       <ejb-name>MyLoggerBean</ejb-name>
       <env-entry>
       <env-entry-name>logFilename</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>mylog.txt</env-entry-value>
       </env-entry>
       </session>
       </enterprise-beans>
      </ejb-jar>


      The extra-nice thing about this approach is that env-entries are available via either injection, or via dynamic lookup from JNDI.

      Obviously, I lean toward using the spec-defined mechanisms as much as possible. I've got a problem here, however, since plain JavaBeans components, especially the built-in seam components, are not Java EE 5 components, and so they don't have a component environment.

      What I'm thinking to do is replace seam.properties with a seam.xml file patterned after the Java EE 5 approach, which looks something like this:

      @Name("myLogger")
      public class MyLoggerBean {
       @Resource String logFilename;
       ...
      }
      
      <seam-archive>
       <java-beans>
       <bean>
       <name>MyLoggerBean</name>
       <env-entry>
       <env-entry-name>logFilename</env-entry-name>
       <env-entry-value>mylog.txt</env-entry-value>
       </env-entry>
       </bean>
       </java-beans>
      </seam-archive>


      My initial thought was to create some kind of java:comp namespace in JNDI even for JavaBeans components, but this is probably going to be a lot more trouble than it is worth, given that we have to wrestle with things like TomCat's read-only JNDI tree (ick). So, I'll probably just keep the config information internally in a built-in component.

      What do you guys think of this proposal?

        • 1. Re: Proposal for Configuration Redesign
          maxandersen

          do we have to duplicate the "tag"-frenzy of jee ?

          • 2. Re: Proposal for Configuration Redesign
            gavin.king

             

            "max.andersen@jboss.com" wrote:
            do we have to duplicate the "tag"-frenzy of jee ?


            Well, I guess consistency is a Good Thing here?

            I mean, I agree that the spec XML is way verbose, but I guess people don't spend a lot of time writing config files...

            • 3. Re: Proposal for Configuration Redesign
              gavin.king

              P.S. I'm really trying to get some feedback from users on this...

              • 4. Re: Proposal for Configuration Redesign
                marius.oancea

                @Resource is a nice think and will be nice to use your ideea. Ad plain javaobjects problem ... hmm. Maybe we could "simulate" @Resource somohow.

                R/W JNDI in tomcat yes is a pain. So avoid it.

                I cannot give a really valuable feedback but I only wanted to tell you that i like your idea.

                • 5. Re: Proposal for Configuration Redesign
                  bill.burke

                  You can still have an ENC for your SEAM beans within Tomcat. Just create your own seam:comp using JBoss Naming within Tomcat's tree. The only problem is that you need a way to push/pop the correct ENC for the bean which means a proxy to the bean probably.

                  Why not just use EJBs instead of your own bean types? What is the purpose of your bean types?

                  FYI, I had proposed to Linda like 6 months ago this java-bean syntax you're describing above. It never got anywhere and I got the same old "there is not enough time" bs speech.

                  BTW, your env-entry-name is incorrect. It should be "FQN-of-class/logFilename"

                  • 6. Re: Proposal for Configuration Redesign
                    drapierwim

                    I'm still a newbie when it comes to the JBoss AS stuff and all extras, for now I think that .xml is 'hell' every time I need to edit or use one I'm having a lot off STRESS.
                    The thing I like about the seam project for now is that you have your AS with the seam jar file and
                    your rolling. Also not to forget the good documentation with some basic example applications and a nice clean forum.

                    For me personally those .xml or .properties should be used as less as possible so if your project could live without that it would be great, otherwise .properties or .xml stay's the same

                    For the moment I'm using 20% of my time building the problem domain and the other 80% goes to setting up things and solving problems that comes from third party stuff. Maybe one day it will be the other way arround.

                    Hope my answer helps a bit, also thanks for your previuos and future replies, Cheers

                    • 7. Re: Proposal for Configuration Redesign
                      gavin.king

                       


                      For me personally those .xml or .properties should be used as less as possible so if your project could live without that it would be great, otherwise .properties or .xml stay's the same


                      Certainly everyone always tries to avoid config parameters as much as possible, but sometimes you need them, and I'm trying to find the path of least resistence here.

                      • 8. Re: Proposal for Configuration Redesign
                        gavin.king

                         

                        "bill.burke@jboss.com" wrote:
                        BTW, your env-entry-name is incorrect. It should be "FQN-of-class/logFilename"


                        I don't understand why. It is already scoped to "MyLoggerBean", the name of the seam component....