3 Replies Latest reply on Jan 15, 2014 12:07 PM by kcbabo

    Strange feature in switchtyard.xml

    l.sroka

      Hello, i have reference in my xml to some @named bean eg.

      <sca:reference name="UserManagementService"

                  multiplicity="0..1"

                  promote="RegistrationPageBean/UserManagementService">

                  <sca:interface.java

                      interface="com.asb.soa.user.management.UserManagementService" />

                  <sca:binding.sca sy:targetNamespace="urn:com.asb.soa" />

              </sca:reference>

              <sca:component name="RegistrationPageBean">

                  <bean:implementation.bean class="com.asb.atsp.page.RegistrationPageBean" />

                  <sca:reference name="UserManagementService">

                      <sca:interface.java

                          interface="com.asb.soa.user.management.UserManagementService" />

                  </sca:reference>

              </sca:component>

       

       

      And this strange part begins in my other @name bean eg. ProfileBean

      there i have put

      @Named
      @RequestScoped
      public class MyAoipProfilePageBean implements Serializable {
          private static final long serialVersionUID = 5304355490768143798L;

          @Inject
          @Reference
          private UserManagementService userManager;

      reference like above. And guess ? I works !!! without puting this @named beand into swtichyard.xml as another <sca:component>

      Does any one have observe this ? Is this bug or feature

        • 1. Re: Strange feature in switchtyard.xml
          kcbabo

          If a CDI bean references another CDI bean, then CDI will automatically wire those together.

          • 2. Re: Strange feature in switchtyard.xml
            l.sroka

            Is this mean that i should not put my @named PageBean in switchyard.xml if i already have put in switchyard.xml other bean (like RegistrationPageBean) ?

            • 3. Re: Strange feature in switchtyard.xml
              kcbabo

              It's really up to you if you want to define this interaction in switchyard.xml.  As I mentioned in an earlier post, Injection between two CDI beans happens whether SwitchYard is involved or not.  Possible reason why you might want to include the definition in switchyard.xml anyway:

               

              1) You want to document the relationship between service components in your application model.

              2) You anticipate that the relationship may change at some point in the future.  For example, if the consumer CDI bean needs to switch to a provider different than another CDI Bean (e.g. a remote web service).

              1 of 1 people found this helpful