[weld-dev] interceptors expected to be implemented via proxying or via subclassing?

Gurkan Erdogdu gurkanerdogdu at yahoo.com
Tue May 11 03:09:58 EDT 2010


Hello;

This is just not related with JSR-299 specification, because interceptors and their behaviors are defined in the interceptor specifications. So all interceptor related things in other specifications (for example : in EJB specifications) must be behave the same.

What JSR-299 specification says that Dependent Scoped Beans is not required to be proxied, but this is not related with using "Java Proxies" to do interception working. (Spec defines proxy for getting bean instance directly for dependent beans, not getting some proxy instance that is necessary for normal scoped beans).

For interception works on a container side on a calling method, you have to use container specific business interface while calling business method.  This is also discussed on OpenEJB group (http://openejb.979440.n4.nabble.com/Possible-OPENEJB-Bug-with-Interceptors-td982087.html) and David Blevins explained it.

Thanks;

--Gurkan


________________________________
From: Mark Struberg <struberg at yahoo.de>
To: weld-dev at lists.jboss.org
Sent: Tue, May 11, 2010 9:24:51 AM
Subject: [weld-dev] interceptors expected to be implemented via proxying or via subclassing?

Hi!

There is a subtle difference between implementing interceptors via proxy or via subclasses.

I have the following service which imports data from a legacy system into my db. Since commits are very performance intense, they should get imported in packages of 100. So I'll get 100 'Employees' from my legacy system and then call a @Transactional method to store them in my own database.

public void ImportService() {
  public void importEmployee() {
    List<LegacyEmployee> les;
    while ((les = getNext100EmployeesFromLegacy()) != nul) {
      importLegacyEmployees(le);
    }
  }

  @Transactional
  protected importLegacyEmployees(List<LegacyEmployee> les) {
    for (LegacyEmployee le: les) {
      employeeService.store(le);
    }
  }
}

This would actually _not_ work when using proxies for the interceptor handling, because calling a method on an own class doesn't invoke the proxyhandler.

So is this expected to work?

I remember that the old spec explicitly says that we need to use subclassing, but cannot find this paragraph anymore. So what does the spec require us to do? And what is Weld going to do?

txs and LieGrue,
strub



      
_______________________________________________
weld-dev mailing list
weld-dev at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/weld-dev


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20100511/5fbc4cea/attachment.html 


More information about the weld-dev mailing list