geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jay D. McHugh" <>
Subject Re: Question on letting several EJB3 SLSB timer beans share one interface class
Date Thu, 15 May 2008 01:51:53 GMT
Hello again.

(This is a resend because I left out part of my first paragraph by accident)

Just in case someone else needs to do this.  And, I must say that it is 
probably almost always a bad thing to do.  In most cases, the need to 
have the exact same interface exposed on a range of classes that perform 
completely different functions should be rare.  I just happen to have a 
block of utility classes that do data cleanup for me.  They are too 
processor/disk intensive to be run all at the same time so I implemented 
them as a series of timer beans that chain together.  Since I may need 
to add or remove new processes at a later date - I wanted to have a 
generic interface to work with so that I could add/delete/swap the 
processes without having to worry about the exact action that the timer 
would be performing.

Here is how you would have several session bean classes that utilize the 
same interface class:

1) Create the one interface class.
2) Create the multiple bean classes implementing the interface class.

Here is where it gets interesting (not particularly interesting though)
3) Inject an instance of your bean using the following syntax:

@EJB(beanName="SpecificBeanImplementationClass") private 
GenericInterface specificBeanInstance;

That should have all been on one line, but it was too long so it 
auto-wrapped.  And of course the pretend names should be replaced with 
your particular class, interface, and instance names.

Maybe this might help someone else,


Jay McHugh wrote:
> (This will probably end up appearing twice eventually - sorry)
> Hello all,
> I have about 25 (currently - will probably increase over time) timer beans
> that really only need to expose the method to schedule them.
> But I haven't been able to figure out how to share one interface class and
> still be able to inject the correct, particular timer out of the 25
> different timer classes.
> Is this possible/has anyone done anything like this?
> Thanks,
> Jay

View raw message