geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: Question on letting several EJB3 SLSB timer beans share one interface class
Date Tue, 20 May 2008 17:23:31 GMT
Good post, Jay!

On May 14, 2008, at 6:51 PM, Jay D. McHugh wrote:

> 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.

Just a note that having several beans share the same business  
interface isn't a bad thing to do by any stretch.

Also to note that with 2.1.1 you should be able to do quite a lot more  
with subclassing than you could previously.  Not sure if that helps  
your exact scenario, but thought it might be a good addition to the  
thread.

-David

> 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
>
> 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
>


Mime
View raw message