[jboss-user] [JBoss Seam] - Re: Component abstraction*

jacob.orshalick do-not-reply at jboss.com
Wed Dec 12 13:24:36 EST 2007


anonymous wrote : I would like to create, if possible of course, an interface as a component. And use this to control the tasks of my business process. Depending on the implementation of such interface that is deployed, actions would behave differently. 

It is not possible to directly define an interface as a Seam component, but it is possible to have your components implement a common interface and refer to that interface where your component is used.  This is definitely recommended to allow differing implementations to be swapped out as you describe.

Thus, if you have a component:

...
  | @Name("hookComponent")
  | public class HookComponentImpl implements HookComponent {
  | ...

You tie your use of the component to the interface just like you would when injecting an SFSB:

...
  | @Name("commonComponent")
  | public class CommonComponent {
  | ...
  | @In HookComponent hookComponent;
  | ...

Here Seam will inject an instance of HookComponentImpl as it is the component registered in the context but this could easily be swapped out through a number of approaches (deploying a specific application instance as you describe, install precedence, configuration through components.xml, etc).  Hope that helps.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112328#4112328

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4112328



More information about the jboss-user mailing list