[jira] Updated: (OWB-369) Static ContextsService in ContextFactory causes wrong webContextService used for multiple applications

2010-05-10 Thread YING WANG (JIRA)

 [ 
https://issues.apache.org/jira/browse/OWB-369?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

YING WANG updated OWB-369:
--

Attachment: ContextFactory.patch

Thanks Gurkan, Joe.  With Gurkan's recent changes, my second app still fails. 
How are we going to handle static ContextService in ContextFactory? I have 
uploaded this patch to replace it with local variables in the class. It might 
not be optimized, but requires minimum code changes. Please help review. Thanks 
in advance.

 Static ContextsService in ContextFactory causes wrong webContextService used 
 for multiple applications
 --

 Key: OWB-369
 URL: https://issues.apache.org/jira/browse/OWB-369
 Project: OpenWebBeans
  Issue Type: Bug
Affects Versions: M4
Reporter: YING WANG
Assignee: YING WANG
 Fix For: 1.0.0

 Attachments: ContextFactory.patch


 To reproduce,
 Application A, which does not support conversation, installed and tested 
 without any issue. then stop and uninstalled.
 Application B, which support conversation, get installed and started.
 When test Application B, ApplicationA's contextService is used and causes 
 conversation scope is not found since it does not support conversation.
 The problem is because of static variable used for contextsService in 
 ContextFactory which is JVM-wide and only init once. While 
 supportConversation flag is application-wide property.
 Probably we need contextService  variable to be  classloader based instead of 
 static variable. or need some change to supportsConversation flag.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



RE: Need to switch to subclassing?

2010-05-10 Thread Mario Ivankovits
Hi!

I'd definitely would go the subclassing route.

The problem you describe here is one of my biggest concerns of how Spring's AOP 
works.
This is just not real AOP - it is dynamic proxy creation - not more, not less.

An average developer will never be able to figure out what is going wrong here.

I had this problem once too, the solution I used then was not to use (the 
implicit) this., but to 
use a reference to the service object (the proxy instance).
In your case this would mean you need to get access to the proxy and then call
thisProxy.importLegacyEmployees.
That way the call goes through the AOP layer ... but ... I'd consider it as 
nasty workaround.

Ciao,
Mario

-Original Message-
From: Mark Struberg [mailto:strub...@yahoo.de] 
Sent: Tuesday, May 11, 2010 7:30 AM
To: dev@openwebbeans.apache.org
Subject: Need to switch to 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() {
ListLegacyEmployee les;
while ((les = getNext100EmployeesFromLegacy()) != nul) {
  importLegacyEmployees(le);
}
  }

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

This would actually _not_ 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?

Sure, I could easily move the importLegacyEmployees() to an own service, but 
that would infringe classic OOP heavily imo.

Gurkan, what does the spec say here, I did find nothing. The old spec 
explicitly mentioned that we need to use subclassing, but I cannot find this 
anymore.

LieGrue,
strub