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

Reply via email to