Added openjpa-all module which will manually create an openjpa-all-VERSION.jar file that aggregates all the other openja-*.jar files; fixed Configurations.java to provide more information when a missing services resource is caused by a deeper exception

git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@441318 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Marc Prud'hommeaux 2006-09-08 01:24:18 +00:00
parent 1e5d09ce2f
commit 812e184e89
6 changed files with 152 additions and 29 deletions

91
openjpa-all/pom.xml Normal file
View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>openjpa-all</artifactId>
<packaging>jar</packaging>
<name>OpenJPA Aggregate Jar</name>
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>0.9.0-incubating-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<!--
Manually build an aggregate jar of all the other
openjpa-* jars using ant. We cannot use the assembly
plugin, since it doesn't provide support for appending
multiple same-named files to each other (which is
required for correctly aggregating services files).
-->
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>build-single-jar</id>
<phase>package</phase>
<configuration>
<tasks>
<unjar overwrite="false"
dest="${basedir}/target/classes">
<fileset dir="${basedir}/..">
<include name="*/target/openjpa-*.jar"/>
</fileset>
</unjar>
<!--
need to manually concatinate the services
resources so they are aggregated
-->
<macrodef name="aggregate-file">
<attribute name="servicename"/>
<sequential>
<echo>Building service: @{servicename}</echo>
<concat destfile="${basedir}/target/classes/META-INF/services/@{servicename}">
<fileset dir="${basedir}/.." includes="*/src/main/resources/META-INF/services/@{servicename}"/>
</concat>
</sequential>
</macrodef>
<aggregate-file servicename="org.apache.openjpa.conf.ProductDerivation"/>
<aggregate-file servicename="javax.persistence.spi.PersistenceProvider"/>
<aggregate-file servicename="org.apache.openjpa.kernel.exps.ExpressionParser"/>
<aggregate-file servicename="org.apache.openjpa.lib.conf.ConfigurationProvider"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!--
create enhancer pre-main attribute
copied from openjpa-kernel-5/pom.xml
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Premain-Class>
org.apache.openjpa.enhance.PCEnhancerAgent</Premain-Class>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-persistence-jdbc</artifactId>
<version>${pom.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -18,8 +18,10 @@ package org.apache.openjpa.lib.conf;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.Properties; import java.util.Properties;
@ -30,6 +32,7 @@ import javax.naming.NamingException;
import org.apache.commons.lang.exception.NestableRuntimeException; import org.apache.commons.lang.exception.NestableRuntimeException;
import org.apache.openjpa.lib.log.Log; import org.apache.openjpa.lib.log.Log;
import org.apache.openjpa.lib.util.JavaVersions;
import org.apache.openjpa.lib.util.Localizer; import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.lib.util.Options; import org.apache.openjpa.lib.util.Options;
import org.apache.openjpa.lib.util.ParseException; import org.apache.openjpa.lib.util.ParseException;
@ -466,36 +469,40 @@ public class Configurations {
(ConfigurationProvider.class, loader); (ConfigurationProvider.class, loader);
ConfigurationProvider provider = null; ConfigurationProvider provider = null;
int providerCount = 0; int providerCount = 0;
StringBuffer errs = null; List errs = null;
for (int i = 0; i < impls.length; i++) { for (int i = 0; i < impls.length; i++) {
provider = newProvider(impls[i]);
if (provider == null)
continue;
providerCount++;
try { try {
provider = (ConfigurationProvider) impls[i].newInstance();
if (provider == null)
continue;
providerCount++;
if ((globals && provider.loadGlobals(loader)) if ((globals && provider.loadGlobals(loader))
|| (!globals && provider.loadDefaults(loader))) || (!globals && provider.loadDefaults(loader)))
return provider; return provider;
} catch (MissingResourceException mre) { } catch (MissingResourceException mre) {
throw mre; throw mre;
} catch (Exception e) { } catch (Throwable t) {
if (errs == null) (errs == null ? errs = new ArrayList() : errs).add(t);
errs = new StringBuffer();
else
errs.append(", ");
errs.append(e.toString());
} }
} }
String type = (globals) ? "globals" : "defaults"; String type = (globals) ? "globals" : "defaults";
MissingResourceException ex = null;
if (errs != null) if (errs != null)
throw new MissingResourceException(errs.toString(), ex = new MissingResourceException(errs.toString(),
Configurations.class.getName(), type); Configurations.class.getName(), type);
if (providerCount == 0) else if (providerCount == 0)
throw new MissingResourceException(_loc.get ("no-providers", ex = new MissingResourceException(_loc.get ("no-providers",
ConfigurationProvider.class.getName()).getMessage(), ConfigurationProvider.class.getName()).getMessage(),
Configurations.class.getName(), type); Configurations.class.getName(), type);
if (ex != null)
throw (MissingResourceException) JavaVersions.initCause(ex,
errs.size() == 0 ? null : (Throwable) errs.get(0));
return null; return null;
} }

View File

@ -1,2 +1,6 @@
Thanks! Thank you for downloading this incubator release of OpenJPA. For
documentation and project information, please see:
http://incubator.apache.org/openjpa/

View File

@ -12,6 +12,7 @@
<include>NOTICE*</include> <include>NOTICE*</include>
</includes> </includes>
</fileSet> </fileSet>
<!--
<fileSet> <fileSet>
<directory>licenses</directory> <directory>licenses</directory>
<outputDirectory>/lib</outputDirectory> <outputDirectory>/lib</outputDirectory>
@ -31,6 +32,7 @@
<directory>target/examples</directory> <directory>target/examples</directory>
<outputDirectory>/examples</outputDirectory> <outputDirectory>/examples</outputDirectory>
</fileSet> </fileSet>
-->
</fileSets> </fileSets>
<dependencySets> <dependencySets>
<dependencySet> <dependencySet>
@ -65,30 +67,43 @@
<!-- optional --> <!-- optional -->
<exclude>junit:junit</exclude> <exclude>junit:junit</exclude>
<!-- these are placed in the modules/ directory -->
<exclude>org.apache.openjpa:openjpa-all</exclude>
<exclude>org.apache.openjpa:openjpa-lib</exclude>
<exclude>org.apache.openjpa:openjpa-kernel</exclude>
<exclude>org.apache.openjpa:openjpa-kernel-4</exclude>
<exclude>org.apache.openjpa:openjpa-kernel-5</exclude>
<exclude>org.apache.openjpa:openjpa-jdbc</exclude>
<exclude>org.apache.openjpa:openjpa-jdbc-5</exclude>
<exclude>org.apache.openjpa:openjpa-persistence</exclude>
<exclude>org.apache.openjpa:openjpa-persistence-jdbc</exclude>
<exclude>org.apache.openjpa:openjpa-xmlstore</exclude>
</excludes> </excludes>
</dependencySet> </dependencySet>
<!--
<dependencySet> <dependencySet>
<outputDirectory>/optional</outputDirectory> <outputDirectory>/modules</outputDirectory>
<unpack>false</unpack> <unpack>false</unpack>
<scope>runtime</scope>
<includes> <includes>
<include>org.apache.derby:derby</include> <include>org.apache.openjpa:openjpa-lib</include>
<include>org.apache.openjpa:openjpa-kernel</include>
<include>org.apache.openjpa:openjpa-kernel-4</include>
<include>org.apache.openjpa:openjpa-kernel-5</include>
<include>org.apache.openjpa:openjpa-jdbc</include>
<include>org.apache.openjpa:openjpa-jdbc-5</include>
<include>org.apache.openjpa:openjpa-persistence</include>
<include>org.apache.openjpa:openjpa-persistence-jdbc</include>
<include>org.apache.openjpa:openjpa-xmlstore</include>
</includes> </includes>
</dependencySet> </dependencySet>
-->
<!-- <dependencySet>
<dependencySet>
<outputDirectory>/</outputDirectory> <outputDirectory>/</outputDirectory>
<unpack>false</unpack> <unpack>false</unpack>
<scope>runtime</scope>
<includes> <includes>
<include>org.apache.openjpa:openjpa-all</include> <include>org.apache.openjpa:openjpa-all</include>
</includes> </includes>
</dependencySet> </dependencySet>
-->
</dependencySets> </dependencySets>
</assembly> </assembly>

View File

@ -12,7 +12,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>openjpa-project</artifactId> <artifactId>openjpa-project</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>OpenJPA Project</name> <name>OpenJPA Distribution</name>
<parent> <parent>
<groupId>org.apache.openjpa</groupId> <groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId> <artifactId>openjpa</artifactId>
@ -78,7 +78,7 @@
<id>bin</id> <id>bin</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>assembly</goal> <goal>attached</goal>
</goals> </goals>
<configuration> <configuration>
<descriptor>assembly.xml</descriptor> <descriptor>assembly.xml</descriptor>
@ -91,7 +91,7 @@
<id>sources</id> <id>sources</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>assembly</goal> <goal>attached</goal>
</goals> </goals>
<configuration> <configuration>
<descriptor>source-assembly.xml</descriptor> <descriptor>source-assembly.xml</descriptor>
@ -134,6 +134,11 @@
<!-- need to explicitly list dependencies for assembly to work --> <!-- need to explicitly list dependencies for assembly to work -->
<dependencies> <dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-all</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.openjpa</groupId> <groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-lib</artifactId> <artifactId>openjpa-lib</artifactId>

View File

@ -86,6 +86,7 @@
<module>openjpa-kernel</module> <module>openjpa-kernel</module>
<module>openjpa-jdbc</module> <module>openjpa-jdbc</module>
<module>openjpa-xmlstore</module> <module>openjpa-xmlstore</module>
<module>openjpa-all</module>
<module>openjpa-project</module> <module>openjpa-project</module>
</modules> </modules>
<profiles> <profiles>