openejb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: Resolve datasource from the application name
Date Thu, 19 Nov 2009 03:20:19 GMT

On Nov 16, 2009, at 5:21 AM, Luis Fernando Planella Gonzalez wrote:

> Well, assuming that my assumptions are right, I've patched AutoConfig
> to use the first WebModule's root context name as a guess to the
> DataSource name.
> I've attached the patch, as well as complete files for AutoConfig and
> AutoConfigPersistenceUnitsTest in
> https://issues.apache.org/jira/browse/OPENEJB-1027
> As this is my first code contribution to OpenEJB. So, please, correct
> me if I did anything wrong...
> Feedbacks are appreciated.

This is a great start, thanks!  I've gone ahead and committed it.

Would be great to get the other searches in there described in  
OPENEJB-1027 such as linking based on the persistence unit name, etc.   
I'm not sure the code is setup to make this easy now because the  
getResourceId() method is perhaps too aggressive -- it always finds an  
id no matter what -- but but at a high level it seems like something  
like this would be really cool.

     List<String> strings = new ArrayList<String>();
     strings.add(jtaDataSourceName);
     strings.add(persistenceUnitName);
     strings.add(moduleName);
     strings.add(applicationName);

     String resourceId;

     for (String string : strings) {
         resourceId = getResourceId(string);

         if (resourceId != null) break;
     }

     // use the resourceId ....

That's the high level thought at least.  Lot's of ways that could be  
rolled out with the existing code.  Maybe we just change  
getResourceId() so that the 'String resourceId' is actually a var-arg  
and move it to the end of the signature.  Or something.

Open to ideas.

And just as a side note, you're under no obligation to keep working on  
this, but you're doing great and we can always use the help! :)

-David


Mime
View raw message