You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/03/06 12:19:07 UTC
svn commit: r1297428 -
/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Author: rmannibucau
Date: Tue Mar 6 11:19:07 2012
New Revision: 1297428
URL: http://svn.apache.org/viewvc?rev=1297428&view=rev
Log:
multiple persistence.xml can be found in a webapp but getresourcesmap return maximum one persistence.xml so hacking to let it work
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1297428&r1=1297427&r2=1297428&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java Tue Mar 6 11:19:07 2012
@@ -201,11 +201,25 @@ public class DeploymentLoader implements
final AppModule appModule = new AppModule(getOpenEJBClassLoader(baseUrl), file.getAbsolutePath(), new Application(), true);
addWebModule(appModule, baseUrl, getOpenEJBClassLoader(baseUrl), getContextRoot(), getModuleName());
- final Map<String, URL> otherDD;
+ final Map<String, Object> otherDD = new HashMap<String, Object>();
final WebModule webModule = appModule.getWebModules().iterator().next();
final List<URL> urls = webModule.getScannableUrls();
final ResourceFinder finder = new ResourceFinder("", urls.toArray(new URL[urls.size()]));
- otherDD = getDescriptors(finder, false);
+ otherDD.putAll(getDescriptors(finder, false));
+
+ // "persistence.xml" is done separately since we mange alist of url and not s single url
+ try {
+ final List<URL> persistenceXmls = finder.findAll(ddDir + "persistence.xml");
+ if (persistenceXmls.size() > 1) {
+ final URL old = (URL) otherDD.get("persistence.xml");
+ if (old != null && !persistenceXmls.contains(old)) {
+ persistenceXmls.add(old);
+ }
+ otherDD.put("persistence.xml", persistenceXmls);
+ }
+ } catch (IOException e) {
+ // ignored
+ }
addWebPersistenceDD("persistence.xml", otherDD, appModule);
addWebPersistenceDD("persistence-fragment.xml", otherDD, appModule);
@@ -246,7 +260,7 @@ public class DeploymentLoader implements
}
}
- private void addWebPersistenceDD(final String name, final Map<String, URL> otherDD, final AppModule appModule) {
+ private void addWebPersistenceDD(final String name, final Map<String, Object> otherDD, final AppModule appModule) {
if (otherDD.containsKey(name)) {
List<URL> persistenceUrls = (List<URL>) appModule.getAltDDs().get(name);
if (persistenceUrls == null) {
@@ -255,9 +269,16 @@ public class DeploymentLoader implements
}
if (otherDD.containsKey(name)) {
- final URL otherUrl = otherDD.get(name);
- if (!persistenceUrls.contains(otherUrl)) {
- persistenceUrls.add(otherUrl);
+ final Object otherUrl = otherDD.get(name);
+ if (otherUrl instanceof URL && !persistenceUrls.contains(otherUrl)) {
+ persistenceUrls.add((URL) otherUrl);
+ } else if (otherUrl instanceof List) {
+ final List<URL> otherList = (List<URL>) otherDD.get(name);
+ for (URL url : otherList) {
+ if (!persistenceUrls.contains(url)) {
+ persistenceUrls.add(url);
+ }
+ }
}
}
}
Re: svn commit: r1297428 - /openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Posted by David Blevins <da...@gmail.com>.
I swear I thought we supported that. Humm..
We should definitely add a unit test. A very big thing to be missing if that's the case. Sounds like we also need a bug JIRA.
-David
On Mar 9, 2012, at 1:51 AM, Romain Manni-Bucau wrote:
> take a webapp, 2 jar with a persistence.xml. It was taking into account
> only one of both.
>
> - Romain
>
>
> 2012/3/9 David Blevins <da...@gmail.com>
>
>> What issue does this fix?
>>
>> -David
>>
>> On Mar 6, 2012, at 5:19 AM, rmannibucau@apache.org wrote:
>>
>>> Author: rmannibucau
>>> Date: Tue Mar 6 11:19:07 2012
>>> New Revision: 1297428
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1297428&view=rev
>>> Log:
>>> multiple persistence.xml can be found in a webapp but getresourcesmap
>> return maximum one persistence.xml so hacking to let it work
>>>
>>> Modified:
>>>
>> openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
>>>
>>> Modified:
>> openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
>>> URL:
>> http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1297428&r1=1297427&r2=1297428&view=diff
>>>
>> ==============================================================================
>>> ---
>> openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
>> (original)
>>> +++
>> openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
>> Tue Mar 6 11:19:07 2012
>>> @@ -201,11 +201,25 @@ public class DeploymentLoader implements
>>> final AppModule appModule = new
>> AppModule(getOpenEJBClassLoader(baseUrl), file.getAbsolutePath(), new
>> Application(), true);
>>> addWebModule(appModule, baseUrl,
>> getOpenEJBClassLoader(baseUrl), getContextRoot(), getModuleName());
>>>
>>> - final Map<String, URL> otherDD;
>>> + final Map<String, Object> otherDD = new HashMap<String,
>> Object>();
>>> final WebModule webModule =
>> appModule.getWebModules().iterator().next();
>>> final List<URL> urls = webModule.getScannableUrls();
>>> final ResourceFinder finder = new ResourceFinder("",
>> urls.toArray(new URL[urls.size()]));
>>> - otherDD = getDescriptors(finder, false);
>>> + otherDD.putAll(getDescriptors(finder, false));
>>> +
>>> + // "persistence.xml" is done separately since we mange
>> alist of url and not s single url
>>> + try {
>>> + final List<URL> persistenceXmls =
>> finder.findAll(ddDir + "persistence.xml");
>>> + if (persistenceXmls.size() > 1) {
>>> + final URL old = (URL)
>> otherDD.get("persistence.xml");
>>> + if (old != null &&
>> !persistenceXmls.contains(old)) {
>>> + persistenceXmls.add(old);
>>> + }
>>> + otherDD.put("persistence.xml", persistenceXmls);
>>> + }
>>> + } catch (IOException e) {
>>> + // ignored
>>> + }
>>>
>>> addWebPersistenceDD("persistence.xml", otherDD,
>> appModule);
>>> addWebPersistenceDD("persistence-fragment.xml", otherDD,
>> appModule);
>>> @@ -246,7 +260,7 @@ public class DeploymentLoader implements
>>> }
>>> }
>>>
>>> - private void addWebPersistenceDD(final String name, final
>> Map<String, URL> otherDD, final AppModule appModule) {
>>> + private void addWebPersistenceDD(final String name, final
>> Map<String, Object> otherDD, final AppModule appModule) {
>>> if (otherDD.containsKey(name)) {
>>> List<URL> persistenceUrls = (List<URL>)
>> appModule.getAltDDs().get(name);
>>> if (persistenceUrls == null) {
>>> @@ -255,9 +269,16 @@ public class DeploymentLoader implements
>>> }
>>>
>>> if (otherDD.containsKey(name)) {
>>> - final URL otherUrl = otherDD.get(name);
>>> - if (!persistenceUrls.contains(otherUrl)) {
>>> - persistenceUrls.add(otherUrl);
>>> + final Object otherUrl = otherDD.get(name);
>>> + if (otherUrl instanceof URL &&
>> !persistenceUrls.contains(otherUrl)) {
>>> + persistenceUrls.add((URL) otherUrl);
>>> + } else if (otherUrl instanceof List) {
>>> + final List<URL> otherList = (List<URL>)
>> otherDD.get(name);
>>> + for (URL url : otherList) {
>>> + if (!persistenceUrls.contains(url)) {
>>> + persistenceUrls.add(url);
>>> + }
>>> + }
>>> }
>>> }
>>> }
>>>
>>>
>>>
>>
>>
Re: svn commit: r1297428 - /openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Posted by Romain Manni-Bucau <rm...@gmail.com>.
take a webapp, 2 jar with a persistence.xml. It was taking into account
only one of both.
- Romain
2012/3/9 David Blevins <da...@gmail.com>
> What issue does this fix?
>
> -David
>
> On Mar 6, 2012, at 5:19 AM, rmannibucau@apache.org wrote:
>
> > Author: rmannibucau
> > Date: Tue Mar 6 11:19:07 2012
> > New Revision: 1297428
> >
> > URL: http://svn.apache.org/viewvc?rev=1297428&view=rev
> > Log:
> > multiple persistence.xml can be found in a webapp but getresourcesmap
> return maximum one persistence.xml so hacking to let it work
> >
> > Modified:
> >
> openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
> >
> > Modified:
> openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
> > URL:
> http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1297428&r1=1297427&r2=1297428&view=diff
> >
> ==============================================================================
> > ---
> openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
> (original)
> > +++
> openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
> Tue Mar 6 11:19:07 2012
> > @@ -201,11 +201,25 @@ public class DeploymentLoader implements
> > final AppModule appModule = new
> AppModule(getOpenEJBClassLoader(baseUrl), file.getAbsolutePath(), new
> Application(), true);
> > addWebModule(appModule, baseUrl,
> getOpenEJBClassLoader(baseUrl), getContextRoot(), getModuleName());
> >
> > - final Map<String, URL> otherDD;
> > + final Map<String, Object> otherDD = new HashMap<String,
> Object>();
> > final WebModule webModule =
> appModule.getWebModules().iterator().next();
> > final List<URL> urls = webModule.getScannableUrls();
> > final ResourceFinder finder = new ResourceFinder("",
> urls.toArray(new URL[urls.size()]));
> > - otherDD = getDescriptors(finder, false);
> > + otherDD.putAll(getDescriptors(finder, false));
> > +
> > + // "persistence.xml" is done separately since we mange
> alist of url and not s single url
> > + try {
> > + final List<URL> persistenceXmls =
> finder.findAll(ddDir + "persistence.xml");
> > + if (persistenceXmls.size() > 1) {
> > + final URL old = (URL)
> otherDD.get("persistence.xml");
> > + if (old != null &&
> !persistenceXmls.contains(old)) {
> > + persistenceXmls.add(old);
> > + }
> > + otherDD.put("persistence.xml", persistenceXmls);
> > + }
> > + } catch (IOException e) {
> > + // ignored
> > + }
> >
> > addWebPersistenceDD("persistence.xml", otherDD,
> appModule);
> > addWebPersistenceDD("persistence-fragment.xml", otherDD,
> appModule);
> > @@ -246,7 +260,7 @@ public class DeploymentLoader implements
> > }
> > }
> >
> > - private void addWebPersistenceDD(final String name, final
> Map<String, URL> otherDD, final AppModule appModule) {
> > + private void addWebPersistenceDD(final String name, final
> Map<String, Object> otherDD, final AppModule appModule) {
> > if (otherDD.containsKey(name)) {
> > List<URL> persistenceUrls = (List<URL>)
> appModule.getAltDDs().get(name);
> > if (persistenceUrls == null) {
> > @@ -255,9 +269,16 @@ public class DeploymentLoader implements
> > }
> >
> > if (otherDD.containsKey(name)) {
> > - final URL otherUrl = otherDD.get(name);
> > - if (!persistenceUrls.contains(otherUrl)) {
> > - persistenceUrls.add(otherUrl);
> > + final Object otherUrl = otherDD.get(name);
> > + if (otherUrl instanceof URL &&
> !persistenceUrls.contains(otherUrl)) {
> > + persistenceUrls.add((URL) otherUrl);
> > + } else if (otherUrl instanceof List) {
> > + final List<URL> otherList = (List<URL>)
> otherDD.get(name);
> > + for (URL url : otherList) {
> > + if (!persistenceUrls.contains(url)) {
> > + persistenceUrls.add(url);
> > + }
> > + }
> > }
> > }
> > }
> >
> >
> >
>
>
Re: svn commit: r1297428 - /openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Posted by David Blevins <da...@gmail.com>.
What issue does this fix?
-David
On Mar 6, 2012, at 5:19 AM, rmannibucau@apache.org wrote:
> Author: rmannibucau
> Date: Tue Mar 6 11:19:07 2012
> New Revision: 1297428
>
> URL: http://svn.apache.org/viewvc?rev=1297428&view=rev
> Log:
> multiple persistence.xml can be found in a webapp but getresourcesmap return maximum one persistence.xml so hacking to let it work
>
> Modified:
> openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
>
> Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
> URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1297428&r1=1297427&r2=1297428&view=diff
> ==============================================================================
> --- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java (original)
> +++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java Tue Mar 6 11:19:07 2012
> @@ -201,11 +201,25 @@ public class DeploymentLoader implements
> final AppModule appModule = new AppModule(getOpenEJBClassLoader(baseUrl), file.getAbsolutePath(), new Application(), true);
> addWebModule(appModule, baseUrl, getOpenEJBClassLoader(baseUrl), getContextRoot(), getModuleName());
>
> - final Map<String, URL> otherDD;
> + final Map<String, Object> otherDD = new HashMap<String, Object>();
> final WebModule webModule = appModule.getWebModules().iterator().next();
> final List<URL> urls = webModule.getScannableUrls();
> final ResourceFinder finder = new ResourceFinder("", urls.toArray(new URL[urls.size()]));
> - otherDD = getDescriptors(finder, false);
> + otherDD.putAll(getDescriptors(finder, false));
> +
> + // "persistence.xml" is done separately since we mange alist of url and not s single url
> + try {
> + final List<URL> persistenceXmls = finder.findAll(ddDir + "persistence.xml");
> + if (persistenceXmls.size() > 1) {
> + final URL old = (URL) otherDD.get("persistence.xml");
> + if (old != null && !persistenceXmls.contains(old)) {
> + persistenceXmls.add(old);
> + }
> + otherDD.put("persistence.xml", persistenceXmls);
> + }
> + } catch (IOException e) {
> + // ignored
> + }
>
> addWebPersistenceDD("persistence.xml", otherDD, appModule);
> addWebPersistenceDD("persistence-fragment.xml", otherDD, appModule);
> @@ -246,7 +260,7 @@ public class DeploymentLoader implements
> }
> }
>
> - private void addWebPersistenceDD(final String name, final Map<String, URL> otherDD, final AppModule appModule) {
> + private void addWebPersistenceDD(final String name, final Map<String, Object> otherDD, final AppModule appModule) {
> if (otherDD.containsKey(name)) {
> List<URL> persistenceUrls = (List<URL>) appModule.getAltDDs().get(name);
> if (persistenceUrls == null) {
> @@ -255,9 +269,16 @@ public class DeploymentLoader implements
> }
>
> if (otherDD.containsKey(name)) {
> - final URL otherUrl = otherDD.get(name);
> - if (!persistenceUrls.contains(otherUrl)) {
> - persistenceUrls.add(otherUrl);
> + final Object otherUrl = otherDD.get(name);
> + if (otherUrl instanceof URL && !persistenceUrls.contains(otherUrl)) {
> + persistenceUrls.add((URL) otherUrl);
> + } else if (otherUrl instanceof List) {
> + final List<URL> otherList = (List<URL>) otherDD.get(name);
> + for (URL url : otherList) {
> + if (!persistenceUrls.contains(url)) {
> + persistenceUrls.add(url);
> + }
> + }
> }
> }
> }
>
>
>