Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Applying aspect in Facade EJB

Marco, thank you again for your help.
Actually I'm going to create the reference in the ejbCreate() method and not in setSessionContext().

Regards,
Rafael.




On 2/13/07, Marco Mistroni <mmistroni@xxxxxxxxx> wrote:
Hi Rafael,

always the same ref (since the app server takes ejb's from its pool) in every method call.

yes but it is *ALWAYS* the same EJB, LocalSearchBO, no matter how many EJB of htat type are in the pool.
For reference, check EJB lifecycle in J2EE spec..

so if you need it all the time, why don't you look it up in setSessionContext() method.. so that hte lookup is done once for the whole lifetime of your EJBs?

You don' tneed to use Aspect here......and you don't need to remove the ejb if you are going to use it all the time...
even if it is local, it is expensive to lookup EJBs all the time (unless the lookup depends on parameters supplied by the clent, i have never seen this happening but it can happen), so what you want here is to get a reference to your LocalSearchBO in the setSessionContext of your EJB

hth
 marco


 

So, the findXXXX method obtains a reference to an local EJB, makes a call to a method of that EJB, and  then destroys it.

I tried writing an aspect using @AspectJ style without success.

Re



On 2/13/07, Marco Mistroni < mmistroni@xxxxxxxxx> wrote:
Hi,
my 2 cents here
well, yes you can do it wiht ASpectJ..

But

why would you want to go thru the expensive process of obtaining a reference of an EJB (i am ASSUMING, reading the code, that since no particular parameters are passed to  createLocalSearchBORef();the LOcalSearchBORef is always the same..)  for the sole purpose of removing it at the end of the method?


hth
 marco

On 2/13/07, Rafael Martony < rmartony@xxxxxxxxx> wrote:
Hi everyone, I'm new to aspects and I'm trying to apply this exciting technology in our project.

I have a Facade EJB that contains several methods like these:

public List<XXXX> findXXXX(SearchCriteria searchCriteria, SortCriteria sortCriteria) throws BusinessException, RuleValidationException {
        LocalSearchBO localSearchBORef = null;
        try {
            localSearchBORef = createLocalSearchBORef(); // obtains a local EJB reference
            return localSearchBORef.findKeyXXXX(searchCriteria, sortCriteria);
        } finally {
            removeEJB(localSearchBORef);
        }
}

I want to write an aspect to eliminate the need of writing of removeEJB (and the try-finally sentences) on every method.
Is it possible to do that with an aspect?

One possibility is to define localSearchBORef in the class having synchronized access to that field. But I think there's a better solution.


Any help would be appreciated, regards,
Rafael.

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top