8 Replies Latest reply on Aug 8, 2012 2:18 AM by nishant_k123

    Seam component especification

    Thyago Schleuss Newbie

      I have a seam 2 projet with a LoginManager from other lib defined on components.xml
      How i can do it with seam 3 ??


      here is the code on seam 2 project, thi class is not on my current seam 3 projets,
      it is from other jar, but exists on classpath:


      <component class="br.com.tiny.sso.LoginManager" name="loginManager" scope="session" >
           <property name="webserviceURL">https://localhost:8090/services/v1_0_0/</property>
           <property name="keystore">/certs/certs.jks</property>
           <property name="keystorePassword">password</property>
           <property name="updateTimeInterval">3600</property>
      </component>



        • 1. Re: Seam component especification
          MIklos Piklos Newbie

          Make a simple producer class like so:




          public class LoginManagerProducer
          
             @Produces
             @SessionScoped
             public LoginManager getLoginManager(){
              LoginManager l = new LoginManager();
              l.setKeystore('/certs/certs.jks');
              l.setKeystorePassword('password');
              ....
              return l;
             }
          



          • 2. Re: Seam component especification
            Thyago Schleuss Newbie

            Thanks!
            Seam 3 have great new features,
            but others such as components.xml and pages.xml
            were not good.

            • 3. Re: Seam component especification
              Thyago Schleuss Newbie

              Other question, theres any way to set this values from seam-beans.xml ??
              For example, i'm create LoginProducerManager but i'm want to do it more dynamic
              like this, but it doensn't work.



              My producer class:



              public class LoginManagerProducer {
                   
                   @Produces
                   @SessionScoped
                   private LoginManager loginManager = new LoginManager();
              }






              My seam-bean.xml



              <producer:LoginManagerProducer>
                   <ee:replaces/>
                   <producer:loginManager>
                        <ee:modifies>
                             <ee:Named>loginManager</ee:Named>
                             <sso:setWebserviceURL>https://localhost:8090/services/v1_0_0/</sso:setWebserviceURL>
                             <sso:setKeystore>/certs/certs.jks</sso:setKeystore>
                             <sso:setKeystorePassword>password</sso:setKeystorePassword>
                             <sso:setUpdateTimeInterval>3600</sso:setUpdateTimeInterval>
                        </ee:modifies>
                   </producer:loginManager>
              </producer:LoginManagerProducer>






              • 4. Re: Seam component especification
                MIklos Piklos Newbie

                Just by reading the example in the documentation of seam-config  i think something like this should work:




                <producer:LoginManagerProducer>
                
                  <s:replaces>
                
                  <producer:loginManager>
                    <s:Produces/>
                    <producer:setWebserviceURL>https://localhost:8090/services/v1_0_0/</producer:setWebserviceURL>
                    <producer:setKeystore>/certs/certs.jks</producer:setKeystore>
                    <producer:setKeystorePassword>password</producer:setKeystorePassword>
                    <producer:setUpdateTimeInterval>3600</producer:setUpdateTimeInterval>
                  </producer:loginManager>
                
                </producer:LoginManagerProducer>
                


                Play a bit with it and yell if you have any problems.


                Good luck.

                • 5. Re: Seam component especification
                  MIklos Piklos Newbie

                  So ok, after a bit more looking at your example, i think that this should work:




                  package com.some.package;
                  
                  import ...
                  
                  public class LoginManagerProducer
                  
                     private String keystore;
                     private String keystorePassword;
                     private String webserviceURL;
                     private Integer updateTimeInterval;
                  
                     @Produces
                     @SessionScoped
                     public LoginManager getLoginManager(){
                      LoginManager l = new LoginManager();
                      l.setKeystore(keystore);
                      l.setKeystorePassword(keystorePassword);
                      ....
                      return l;
                     }
                  





                         
                   ...
                  xmlns:a="urn:java:com.some.package"  
                  ...    
                          <a:LoginManagerProducer>
                             <s:modifies />
                             <a:keystore>/certs/certs.jks</a:keystore>
                             <a:updateTimeInterval>13</a:updateTimeInterval>
                             <a:skeystorePassword>password</a:keystorePassword>
                                   <a:webserviceURL>https://localhost:8090/services/v1_0_0/</a:webserviceURL>
                       </a:LoginManagerProducer>



                  • 6. Re: Seam component especification
                    Thyago Schleuss Newbie

                    Yeah, the second option worked perfectly! Thanks.
                    I was trying to change the second-level object direct,
                    like first option, but i think it is not possible.


                    Thanks again, i could understand how it works.

                    • 7. Re: Seam component especification
                      nishant_k123 Newbie

                      it appears that when the bean is specified in the seam-beans.xml, the @postConstruct method is not called.

                       

                      I have several instances of the same class specified in the seam-beans.xml with a different @Named (using <s:Named value="abc"/>). but it appears that the post construct on these instances are not called even though they are created correctly.

                       

                      Anyone else notice this ?

                      • 8. Re: Seam component especification
                        nishant_k123 Newbie

                        I also noticed that none of the injection seems to happen for a bean created via the seam-beans.xml. Is this by design that the post construct and injection get ignored for beans created via seam-beans.xml. or is there something i am missing entirely ?>