mirror of https://github.com/apache/openjpa.git
fix formatting by replacing tabs with spaces. also allow non-JDK5 profile to support JDK6+ and comment out unused antrun plugin.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@780046 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
49596dc4e6
commit
0fa4a0c965
|
@ -50,63 +50,64 @@
|
|||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<!-- =============================================================== -->
|
||||
<!-- Compiling with JDK5 compiler excludes classes that explicitly -->
|
||||
<!-- import and use JDK6 classes/packages for annotation processing -->
|
||||
<!-- =============================================================== -->
|
||||
<id>jdk5-compiler</id>
|
||||
<profile>
|
||||
<!-- =========================================================== -->
|
||||
<!-- Compiling with JDK5 excludes classes that explicitly import -->
|
||||
<!-- and use JDK6 classes/packages for annotation processing -->
|
||||
<!-- =========================================================== -->
|
||||
<activation>
|
||||
<jdk>1.5</jdk>
|
||||
</activation>
|
||||
<id>jdk5-compiler</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/AnnotationProcessor6.java</exclude>
|
||||
<exclude>**/SourceAnnotationHandler.java</exclude>
|
||||
<exclude>**/CompileTimeLogger.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<activation>
|
||||
<jdk>1.5</jdk>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<!-- =========================================================== -->
|
||||
<!-- Compiling with JDK6 compiler packages a META-INF/services -->
|
||||
<!-- file for our annotation processor -->
|
||||
<!-- =========================================================== -->
|
||||
<id>jdk6-compiler</id>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/AnnotationProcessor6.java</exclude>
|
||||
<exclude>**/SourceAnnotationHandler.java</exclude>
|
||||
<exclude>**/CompileTimeLogger.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<!-- =========================================================== -->
|
||||
<!-- Compiling with JDK6+ compiler packages a META-INF/services -->
|
||||
<!-- file for our annotation processor -->
|
||||
<!-- =========================================================== -->
|
||||
<activation>
|
||||
<jdk>[1.6,)</jdk>
|
||||
</activation>
|
||||
<id>jdk6-compiler</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>process-classes</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<!-- echo file="${basedir}/src/main/resources/META-INF/services/javax.annotation.processing.Processor"
|
||||
message="org.apache.openjpa.persistence.meta.AnnotationProcessor6"/ -->
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<activation>
|
||||
<jdk>1.6</jdk>
|
||||
</activation>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
<!--
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>process-classes</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<echo file="${basedir}/src/main/resources/META-INF/services/javax.annotation.processing.Processor"
|
||||
message="org.apache.openjpa.persistence.meta.AnnotationProcessor6"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
-->
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -57,6 +57,8 @@ import org.apache.openjpa.lib.meta.XMLMetaDataParser;
|
|||
import org.apache.openjpa.lib.meta.XMLVersionParser;
|
||||
import org.apache.openjpa.lib.util.J2DoPrivHelper;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
import org.apache.openjpa.persistence.validation.ValidatorImpl;
|
||||
import org.apache.openjpa.validation.Validator;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
@ -164,6 +166,13 @@ public class PersistenceProductDerivation
|
|||
Compatibility compatibility = conf.getCompatibilityInstance();
|
||||
compatibility.setFlushBeforeDetach(true);
|
||||
compatibility.setCopyOnDetach(true);
|
||||
} else {
|
||||
System.out.println("********* Creating ValidatorImpl **********");
|
||||
if (!conf.getValidationMode().equalsIgnoreCase("NONE")) {
|
||||
Validator val = new ValidatorImpl(
|
||||
conf.getValidationFactoryInstance(),
|
||||
conf.getValidationMode());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -101,9 +101,13 @@ public class ValidatorImpl extends AbstractValidator {
|
|||
*/
|
||||
public ValidatorImpl(Object validatorFactory,
|
||||
String mode) {
|
||||
if (validatorFactory != null && validatorFactory instanceof
|
||||
ValidatorFactory) {
|
||||
_validatorFactory = (ValidatorFactory)validatorFactory;
|
||||
if (validatorFactory != null) {
|
||||
if (validatorFactory instanceof ValidatorFactory) {
|
||||
_validatorFactory = (ValidatorFactory)validatorFactory;
|
||||
} else {
|
||||
// TODO: Add a localized exception
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
} else {
|
||||
_validatorFactory = getDefaultValidatorFactory();
|
||||
}
|
||||
|
@ -161,7 +165,17 @@ public class ValidatorImpl extends AbstractValidator {
|
|||
* @return returns true if validating for this particular event
|
||||
*/
|
||||
public boolean isValidating(Integer event) {
|
||||
return _validationGroups.get(event) != null;
|
||||
return (hasValidator() && (_validationGroups.get(event) != null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a Validator was created by the ValidatorFactory
|
||||
* and validation can be used.
|
||||
*
|
||||
* @return returns true if ValidatorFactory returned a Validator
|
||||
*/
|
||||
public boolean hasValidator() {
|
||||
return (_validator != null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,8 +289,12 @@ public class ValidatorImpl extends AbstractValidator {
|
|||
|
||||
// Get the default validator factory
|
||||
private ValidatorFactory getDefaultValidatorFactory() {
|
||||
ValidatorFactory factory =
|
||||
Validation.buildDefaultValidatorFactory();
|
||||
ValidatorFactory factory = null;
|
||||
try {
|
||||
factory = Validation.buildDefaultValidatorFactory();
|
||||
} catch (javax.validation.ValidationException e) {
|
||||
// no validation providers found
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue