Skip to content
Commits on Source (7)
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.4
Ant-Version: Apache Ant 1.9.6
Created-By: 1.7.0_80-b15 (Oracle Corporation)
Specification-Title: Eclipse Persistence Services Source
Specification-Vendor: Eclipse.org - EclipseLink Project
Specification-Version: 2.6.5
Specification-Version: 2.6.6
Implementation-Title: org.eclipse.persistence
Implementation-Vendor: Eclipse.org - EclipseLink Project
Implementation-Version: 2.6.5.v20170607-b3d05bd
Release-Designation: EclipseLink 2.6.5
Implementation-Version: 2.6.6.v20181219-80f4920114
Release-Designation: EclipseLink 2.6.6
#Source Bundle Localization
#Wed Jun 07 00:33:59 EDT 2017
#Wed Dec 19 08:26:19 EST 2018
bundleVendor=Eclipse.org - EclipseLink Project
bundleName=EclipseLink Core Source
......@@ -83,7 +83,7 @@
classpathref="classpath"
access="public"
defaultexcludes="yes"
source="${source}">
source="7">
<packageset
dir="${dir.src}"
excludesfile="${dir.debian}/excludesfiles/javadoc">
......
eclipselink (2.6.6-1) unstable; urgency=medium
* Team upload.
* New upstream release
- Updated the Maven poms
* Fixed the generation of the javadoc
* Depend on libjaxrs-api-java instead of libjsr311-api-java
* Standards-Version updated to 4.3.0
-- Emmanuel Bourg <ebourg@apache.org> Mon, 31 Dec 2018 17:53:20 +0100
eclipselink (2.6.5-4) unstable; urgency=medium
* Team upload.
......
......@@ -7,10 +7,10 @@ usr/share/java/aspectjtools.jar
usr/share/java/ant.jar
usr/share/java/sdo-api.jar
usr/share/java/cdi-api.jar
usr/share/java/jsr311-api.jar
usr/share/java/servlet-api-3.1.jar
usr/share/java/javax.mail.jar
usr/share/java/jaxb-xjc.jar
usr/share/java/jaxrs-api.jar
usr/share/java/javax.json.jar
usr/share/java/codemodel.jar
usr/share/java/xsom.jar
......
......@@ -16,14 +16,14 @@ Build-Depends:
libgeronimo-jta-1.1-spec-java,
libgeronimo-validation-1.1-spec-java,
libjaxb-java (>= 2.3),
libjaxrs-api-java,
libjpa-2.1-spec-java,
libjsonp-java,
libjsr311-api-java,
libmail-java,
libsdo-api-java,
libservlet3.1-java,
maven-repo-helper
Standards-Version: 4.2.1
Standards-Version: 4.3.0
Vcs-Git: https://salsa.debian.org/java-team/eclipselink.git
Vcs-Browser: https://salsa.debian.org/java-team/eclipselink
Homepage: http://www.eclipse.org/eclipselink/
......@@ -37,9 +37,9 @@ Depends:
libgeronimo-jta-1.1-spec-java,
libgeronimo-validation-1.1-spec-java,
libjaxb-java (>= 2.3),
libjaxrs-api-java,
libjpa-2.1-spec-java,
libjsonp-java,
libjsr311-api-java,
libmail-java,
${misc:Depends}
Recommends: aspectj, libsdo-api-java
......
......@@ -3,10 +3,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.5</version>
<version>2.6.6</version>
<packaging>jar</packaging>
<name>EclipseLink (non-OSGi)</name>
<description>EclipseLink build based upon Git transaction b3d05bd</description>
<description>EclipseLink build based upon Git transaction 80f4920114</description>
<url>http://www.eclipse.org/eclipselink</url>
<organization>
<name>Eclipse.org - EclipseLink Project</name>
......
......@@ -3,10 +3,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
<version>2.6.5</version>
<version>2.6.6</version>
<packaging>jar</packaging>
<name>EclipseLink Hermes JPQL Parser</name>
<description>EclipseLink build based upon Git transaction b3d05bd</description>
<description>EclipseLink build based upon Git transaction 80f4920114</description>
<url>http://www.eclipse.org/eclipselink</url>
<organization>
<name>Eclipse.org - EclipseLink Project</name>
......
......@@ -3,10 +3,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.6.5</version>
<version>2.6.6</version>
<packaging>jar</packaging>
<name>EclipseLink JPA Modelgen (non-OSGi)</name>
<description>EclipseLink build based upon Git transaction b3d05bd</description>
<description>EclipseLink build based upon Git transaction 80f4920114</description>
<url>http://www.eclipse.org/eclipselink</url>
<organization>
<name>Eclipse.org - EclipseLink Project</name>
......
#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
export JAVA_HOME=/usr/lib/jvm/default-java
%:
......@@ -22,3 +24,8 @@ override_dh_auto_install:
override_dh_auto_clean:
ant -f debian/build.xml clean
mh_clean
get-orig-pom:
wget http://repo1.maven.org/maven2/org/eclipse/persistence/eclipselink/${DEB_VERSION_UPSTREAM}/eclipselink-${DEB_VERSION_UPSTREAM}.pom -O debian/poms/eclipselink.pom
wget http://repo1.maven.org/maven2/org/eclipse/persistence/org.eclipse.persistence.jpa.jpql/${DEB_VERSION_UPSTREAM}/org.eclipse.persistence.jpa.jpql-${DEB_VERSION_UPSTREAM}.pom -O debian/poms/org.eclipse.persistence.jpa.jpql.pom
wget http://repo1.maven.org/maven2/org/eclipse/persistence/org.eclipse.persistence.jpa.modelgen.processor/${DEB_VERSION_UPSTREAM}/org.eclipse.persistence.jpa.modelgen.processor-${DEB_VERSION_UPSTREAM}.pom -O debian/poms/org.eclipse.persistence.jpa.modelgen.processor.pom
......@@ -138,7 +138,6 @@ public class Version {
case v1_8:
JDK_VERSION = JDK_1_8;
break;
case v1_9:
case v9_0:
JDK_VERSION = JDK_1_9;
break;
......@@ -229,7 +228,7 @@ public class Version {
* when we do not run on Java SE 1.9.
*/
public static boolean isJDK19() {
return JavaSEPlatform.is(JavaSEPlatform.v9_0) || JavaSEPlatform.is(JavaSEPlatform.v1_9);
return JavaSEPlatform.is(JavaSEPlatform.v9_0);
}
public static void printVersion ( ) {
......
......@@ -32,13 +32,13 @@ public class Version {
// This will be used by all product components and included in exceptions.
private static String product = "Eclipse Persistence Services";
// A three part version number (major.minor.service)
private static final String version = "2.6.5";
private static final String version = "2.6.6";
// A string that describes this build i.e.( vYYYYMMDD-HHMM, etc.)
private static final String qualifier = "v20170607-b3d05bd";
private static final String qualifier = "v20181219-80f4920114";
// Should be in the format YYYYMMDD
private static final String buildDate = "20170607";
private static final String buildDate = "20181219";
// Should be in the format HHMM
private static final String buildTime = "0028";
private static final String buildTime = "0826";
// revision of source from the repository
private static final String buildRevision = "NA";
// Typically SNAPSHOT, Milestone name (M1,M2,etc), or RELEASE
......@@ -138,7 +138,6 @@ public class Version {
case v1_8:
JDK_VERSION = JDK_1_8;
break;
case v1_9:
case v9_0:
JDK_VERSION = JDK_1_9;
break;
......@@ -229,7 +228,7 @@ public class Version {
* when we do not run on Java SE 1.9.
*/
public static boolean isJDK19() {
return JavaSEPlatform.is(JavaSEPlatform.v9_0) || JavaSEPlatform.is(JavaSEPlatform.v1_9);
return JavaSEPlatform.is(JavaSEPlatform.v9_0);
}
public static void printVersion ( ) {
......
/*******************************************************************************
* Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2017 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
......@@ -9,10 +9,12 @@
*
* Contributors:
* Oracle - initial API and implementation from Oracle TopLink
* 12/14/2017-2.6.6 Tomas Kraus
* - 291546: Performance degradation due to usage of Vector in DescriptorEventManager
******************************************************************************/
package org.eclipse.persistence.descriptors;
import java.util.Vector;
import java.util.List;
/**
* <p><b>Purpose</b>: Provides an empty implementation of DescriptorEventListener.
......@@ -29,7 +31,8 @@ public class DescriptorEventAdapter implements DescriptorEventListener {
public void aboutToDelete(DescriptorEvent event) {}
public boolean isOverriddenEvent(DescriptorEvent event, Vector eventManagers) {
@Override
public boolean isOverriddenEvent(DescriptorEvent event, List<DescriptorEventManager> eventManagers) {
return false;
}
......
/*******************************************************************************
* Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2017 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
......@@ -9,10 +9,13 @@
*
* Contributors:
* Oracle - initial API and implementation from Oracle TopLink
* 12/14/2017-2.6.6 Tomas Kraus
* - 291546: Performance degradation due to usage of Vector in DescriptorEventManager
******************************************************************************/
package org.eclipse.persistence.descriptors;
import java.util.*;
import java.util.EventListener;
import java.util.List;
/**
* <p><b>Purpose</b>: Used to support Java event listener event model on descriptors.
......@@ -34,14 +37,14 @@ public interface DescriptorEventListener extends EventListener {
* This event can be used to amend an object's delete row.
*/
// CR#2660080 was missing aboutToDelete
public void aboutToDelete(DescriptorEvent event);
void aboutToDelete(DescriptorEvent event);
/**
* This event is raised before a new object is inserted to the database.
* The object's row has already been built and is accessible from the event.
* This event can be used to amend an object's insert row.
*/
public void aboutToInsert(DescriptorEvent event);
void aboutToInsert(DescriptorEvent event);
/**
* This event is raised before an object is updated in the database.
......@@ -49,19 +52,19 @@ public interface DescriptorEventListener extends EventListener {
* The object's row has already been built and is accessible from the event.
* This event can be used to amend an object's update row.
*/
public void aboutToUpdate(DescriptorEvent event);
void aboutToUpdate(DescriptorEvent event);
/**
* Implementers should define this method if they need or want to restrict
* the calling of inherited events.
*/
public boolean isOverriddenEvent(DescriptorEvent event, Vector eventManagers);
boolean isOverriddenEvent(DescriptorEvent event, List<DescriptorEventManager> eventManagers);
/**
* This event is raised after an object is built from its row on a read operation.
* This event can be used to initialize non-persistent or non-mapped state in the object.
*/
public void postBuild(DescriptorEvent event);
void postBuild(DescriptorEvent event);
/**
* This event is raised after an object is cloned into a unit of work.
......@@ -69,17 +72,17 @@ public interface DescriptorEventListener extends EventListener {
* The event source/object is the unit of work clone,
* the event originalObject is the original object from the session cache.
*/
public void postClone(DescriptorEvent event);
void postClone(DescriptorEvent event);
/**
* This event is raised after an object is deleted from the database.
*/
public void postDelete(DescriptorEvent event);
void postDelete(DescriptorEvent event);
/**
* This event is raised after an object is inserted to the database.
*/
public void postInsert(DescriptorEvent event);
void postInsert(DescriptorEvent event);
/**
* This event is raised after an object is merged from a unit of work into its parent.
......@@ -87,46 +90,46 @@ public interface DescriptorEventListener extends EventListener {
* The event source/object is the parent session object that was merged into,
* the event originalObject is the unit of work clone that was merged from.
*/
public void postMerge(DescriptorEvent event);
void postMerge(DescriptorEvent event);
/**
* This event is raised after an object is refreshed from its row on a refresh operation.
* This event can be used to initialize non-persistent or non-mapped state in the object.
*/
public void postRefresh(DescriptorEvent event);
void postRefresh(DescriptorEvent event);
/**
* This event is raised after an object updated in the database.
* This event is only raised for objects that had changes and were updated.
*/
public void postUpdate(DescriptorEvent event);
void postUpdate(DescriptorEvent event);
/**
* This event is raised after an object is inserted or updated in the database.
* This event is only raised for new objects or objects that had changes and were updated.
*/
public void postWrite(DescriptorEvent event);
void postWrite(DescriptorEvent event);
/**
* This event is raised before an object is deleted from the database.
*/
public void preDelete(DescriptorEvent event);
void preDelete(DescriptorEvent event);
/**
* This event is raised before an object is inserted to the database.
*/
public void preInsert(DescriptorEvent event);
void preInsert(DescriptorEvent event);
/**
* This event is only raised by the EntityManager. It is raised when the
* create operation is initiated on an object.
*/
public void prePersist(DescriptorEvent event);
void prePersist(DescriptorEvent event);
/**
* This event is raised when the remove operation is initiated on an object.
*/
public void preRemove(DescriptorEvent event);
void preRemove(DescriptorEvent event);
/**
* This event is raised for all existing objects written or committed in a unit of work.
......@@ -134,7 +137,7 @@ public interface DescriptorEventListener extends EventListener {
* so the object may still be modified by the event.
* If the object has no changes, it will not be updated in a unit of work.
*/
public void preUpdate(DescriptorEvent event);
void preUpdate(DescriptorEvent event);
/**
* This event is raised before an object is updated regardless if the object
......@@ -143,7 +146,7 @@ public interface DescriptorEventListener extends EventListener {
* event. For objects that have database changes, an aboutToUpdate will also
* be triggered.
*/
public void preUpdateWithChanges(DescriptorEvent event);
void preUpdateWithChanges(DescriptorEvent event);
/**
* This event is raised for all new or existing objects written or committed in a unit of work.
......@@ -151,5 +154,5 @@ public interface DescriptorEventListener extends EventListener {
* so the object may still be modified by the event.
* If the object is existing and has no changes, it will not be updated in a unit of work.
*/
public void preWrite(DescriptorEvent event);
void preWrite(DescriptorEvent event);
}
/*******************************************************************************
* Copyright (c) 1998, 2014 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2018 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
......@@ -12,6 +12,8 @@
* Markus Karg - allow arguments to be specified multiple times in argumentIndices
* 05/07/2009-1.1.1 Dave Brosius
* - 263904: [PATCH] ExpressionOperator doesn't compare arrays correctly
* 01/23/2018-2.6 Will Dazey
* - 530214: trim operation should not bind parameters
******************************************************************************/
package org.eclipse.persistence.expressions;
......@@ -3041,6 +3043,7 @@ public class ExpressionOperator implements Serializable {
exOperator.printsAs(v);
exOperator.bePrefix();
exOperator.setNodeClass(ClassConstants.FunctionExpression_Class);
exOperator.setIsBindingSupported(false);
return exOperator;
}
......
......@@ -12,56 +12,21 @@
******************************************************************************/
package org.eclipse.persistence.internal.descriptors;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import org.eclipse.persistence.exceptions.DescriptorException;
import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
import org.eclipse.persistence.internal.security.PrivilegedGetClassLoaderForClass;
import org.eclipse.persistence.internal.security.PrivilegedGetClassLoaderFromCurrentThread;
import org.eclipse.persistence.internal.weaving.WeaverLogger;
import org.eclipse.persistence.logging.SessionLog;
/**
* Used with weaving to access attributes without using reflection.
*/
public class PersistenceObjectAttributeAccessor extends InstanceVariableAttributeAccessor {
/** Cache logger finest level settings. */
private final boolean shouldLogFinest;
public PersistenceObjectAttributeAccessor(String attributeName) {
this.attributeName = attributeName.intern();
// PERF: Cache weaver logger finest level settings. It won't allow to change logger settings on the fly
// but it's less evil than evaluating it with every single getter/setter call.
shouldLogFinest = WeaverLogger.shouldLog(SessionLog.FINEST);
}
/**
* Returns the value of the attribute on the specified object.
*/
public Object getAttributeValueFromObject(Object object) {
if (shouldLogFinest) {
ClassLoader contextClassLoader;
ClassLoader objectClassLoader;
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
try {
contextClassLoader = AccessController.doPrivileged(
new PrivilegedGetClassLoaderFromCurrentThread());
objectClassLoader = AccessController.doPrivileged(
new PrivilegedGetClassLoaderForClass(object.getClass()));
} catch (PrivilegedActionException ex) {
throw (RuntimeException) ex.getCause();
}
} else {
contextClassLoader = Thread.currentThread().getContextClassLoader();
objectClassLoader = object.getClass().getClassLoader();
}
WeaverLogger.log(SessionLog.FINEST, "weaving_call_persistence_get",
object.getClass().getName(),
Integer.toHexString(System.identityHashCode(contextClassLoader)),
Integer.toHexString(System.identityHashCode(objectClassLoader)));
}
return ((PersistenceObject)object)._persistence_get(this.attributeName);
}
......@@ -78,27 +43,6 @@ public class PersistenceObjectAttributeAccessor extends InstanceVariableAttribut
* Sets the value of the instance variable in the object to the value.
*/
public void setAttributeValueInObject(Object object, Object value) {
if (shouldLogFinest) {
ClassLoader contextClassLoader;
ClassLoader objectClassLoader;
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
try {
contextClassLoader = AccessController.doPrivileged(
new PrivilegedGetClassLoaderFromCurrentThread());
objectClassLoader = AccessController.doPrivileged(
new PrivilegedGetClassLoaderForClass(object.getClass()));
} catch (PrivilegedActionException ex) {
throw (RuntimeException) ex.getCause();
}
} else {
contextClassLoader = Thread.currentThread().getContextClassLoader();
objectClassLoader = object.getClass().getClassLoader();
}
WeaverLogger.log(SessionLog.FINEST, "weaving_call_persistence_set",
object.getClass().getName(),
Integer.toHexString(System.identityHashCode(contextClassLoader)),
Integer.toHexString(System.identityHashCode(objectClassLoader)));
}
((PersistenceObject)object)._persistence_set(this.attributeName, value);
}
}
/*******************************************************************************
* Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation from Oracle TopLink
******************************************************************************/
package org.eclipse.persistence.internal.helper;
import java.sql.SQLException;
import java.util.regex.Pattern;
import java.util.concurrent.ConcurrentHashMap;
/**
* INTERNAL:
* Implements operations specific to JDK 1.5
*/
public class JDK15Platform implements JDKPlatform {
/**
* PERF: The like expression compiled Pattern objects are cached
* to avoid re-compilation on every usage.
*/
protected static ConcurrentHashMap patternCache = new ConcurrentHashMap();
/**
* PERF: The regular expression compiled Pattern objects are cached
* to avoid re-compilation on every usage.
*/
protected static ConcurrentHashMap regexpPatternCache = new ConcurrentHashMap();
/**
* INTERNAL:
* An implementation of in memory queries with Like which uses the
* regular expression framework.
*/
public Boolean conformLike(Object left, Object right) {
if ((left == null) && (right == null)) {
return Boolean.TRUE;
} else if ((left == null) || (right == null)) {
return Boolean.FALSE;
}
left = String.valueOf(left);
right = String.valueOf(right);
// PERF: First check the pattern cache for the pattern.
// Note that the original string is the key, to avoid having to translate it first.
Pattern pattern = (Pattern)patternCache.get(right);
if (pattern == null) {
// Bug 3936427 - Replace regular expression reserved characters with escaped version of those characters
// For instance replace ? with \?
String convertedRight = Helper.convertLikeToRegex((String)right);
pattern = Pattern.compile(convertedRight);
// Ensure cache does not grow beyond 100.
if (patternCache.size() > 100) {
patternCache.remove(patternCache.keySet().iterator().next());
}
patternCache.put(right, pattern);
}
boolean match = pattern.matcher((String)left).matches();
if (match) {
return Boolean.TRUE;
} else {
return Boolean.FALSE;
}
}
/**
* INTERNAL:
* An implementation of in memory queries with Regexp which uses the
* regular expression framework.
*/
public Boolean conformRegexp(Object left, Object right) {
if ((left == null) && (right == null)) {
return Boolean.TRUE;
} else if ((left == null) || (right == null)) {
return Boolean.FALSE;
}
left = String.valueOf(left);
right = String.valueOf(right);
// PERF: First check the pattern cache for the pattern.
// Note that the original string is the key, to avoid having to translate it first.
Pattern pattern = (Pattern)regexpPatternCache.get(right);
if (pattern == null) {
pattern = Pattern.compile((String)right);
// Ensure cache does not grow beyond 100.
if (regexpPatternCache.size() > 100) {
regexpPatternCache.remove(regexpPatternCache.keySet().iterator().next());
}
regexpPatternCache.put(right, pattern);
}
boolean match = pattern.matcher((String)left).matches();
if (match) {
return Boolean.TRUE;
} else {
return Boolean.FALSE;
}
}
/**
* Indicates whether the passed object implements java.sql.SQLXML introduced in jdk 1.6
*/
public boolean isSQLXML(Object object) {
return false;
}
/**
* Casts the passed object to SQLXML and calls getString and free methods
*/
public String getStringAndFreeSQLXML(Object sqlXml) throws SQLException {
return null;
}
}
/*******************************************************************************
* Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* ailitchev - 2010/08/19
* Bug 322960 - TWO TESTS IN CUSTOMFEATURESJUNITTESTSUITE FAILED WITH 11.2.0.2 DRIVER
******************************************************************************/
package org.eclipse.persistence.internal.helper;
import java.sql.SQLException;
import java.sql.SQLXML;
/**
* INTERNAL:
* Implements operations specific to JDK 1.6
*/
public class JDK16Platform extends JDK15Platform {
/**
* Indicates whether the passed object implements java.sql.SQLXML introduced in jdk 1.6
*/
public boolean isSQLXML(Object object) {
return (object instanceof SQLXML);
}
/**
* Casts the passed object to SQLXML and calls getString and free methods
*/
public String getStringAndFreeSQLXML(Object sqlXml) throws SQLException {
String str = ((SQLXML)sqlXml).getString();
((SQLXML)sqlXml).free();
return str;
}
}
/*******************************************************************************
* Copyright (c) 1998, 2015 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2017 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
......@@ -9,17 +9,17 @@
*
* Contributors:
* Oracle - initial API and implementation from Oracle TopLink
* ailitchev - 2010/08/19
* Bug 322960 - TWO TESTS IN CUSTOMFEATURESJUNITTESTSUITE FAILED WITH 11.2.0.2 DRIVER
* Tomas Kraus - 2017/10/11
* Bug 525854 - Fix Java SE platform detection and clean up platform code
******************************************************************************/
package org.eclipse.persistence.internal.helper;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.sql.SQLException;
import org.eclipse.persistence.Version;
import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
import org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass;
import org.eclipse.persistence.internal.security.PrivilegedClassForName;
import java.sql.SQLXML;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
/**
* INTERNAL:
......@@ -30,61 +30,75 @@ import org.eclipse.persistence.internal.security.PrivilegedClassForName;
* @author Tom Ware
*/
public class JavaPlatform {
protected static JDKPlatform platform = null;
/**
* INTERNAL:
* Get the version of JDK being used from the Version class.
* @return JDKPlatform a platform appropriate for the version of JDK being used.
* PERF: The like expression compiled Pattern objects are cached
* to avoid re-compilation on every usage.
*/
protected static JDKPlatform getPlatform() {
if (platform == null) {
if (JavaSEPlatform.CURRENT.atLeast(JavaSEPlatform.v1_6)) {
try {
Class platformClass = null;
// use class.forName() to avoid loading the JDK 1.6 class unless it is needed.
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
platformClass = AccessController.doPrivileged(new PrivilegedClassForName("org.eclipse.persistence.internal.helper.JDK16Platform"));
} catch (PrivilegedActionException exception) {
}
} else {
platformClass = org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName("org.eclipse.persistence.internal.helper.JDK16Platform");
}
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
platform = (JDKPlatform)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(platformClass));
} catch (PrivilegedActionException exception) {
}
} else {
platform = (JDKPlatform)PrivilegedAccessHelper.newInstanceFromClass(platformClass);
}
} catch (Exception exception) {
}
}
if (platform == null) {
platform = new JDK15Platform();
}
}
return platform;
}
private static final ConcurrentHashMap patternCache = new ConcurrentHashMap();
/**
* PERF: The regular expression compiled Pattern objects are cached
* to avoid re-compilation on every usage.
*/
private static final ConcurrentHashMap regexpPatternCache = new ConcurrentHashMap();
/**
* INTERNAL:
* Conform an expression which uses the operator "like" for an in-memory query
* @return Boolean (TRUE, FALSE, null == unknown)
* An implementation of in memory queries with Like which uses the
* regular expression framework.
*/
public static Boolean conformLike(Object left, Object right) {
return getPlatform().conformLike(left, right);
if ((left == null) && (right == null)) {
return Boolean.TRUE;
} else if ((left == null) || (right == null)) {
return Boolean.FALSE;
}
left = String.valueOf(left);
right = String.valueOf(right);
// PERF: First check the pattern cache for the pattern.
// Note that the original string is the key, to avoid having to translate it first.
Pattern pattern = (Pattern)patternCache.get(right);
if (pattern == null) {
// Bug 3936427 - Replace regular expression reserved characters with escaped version of those characters
// For instance replace ? with \?
String convertedRight = Helper.convertLikeToRegex((String)right);
pattern = Pattern.compile(convertedRight);
// Ensure cache does not grow beyond 100.
if (patternCache.size() > 100) {
patternCache.remove(patternCache.keySet().iterator().next());
}
patternCache.put(right, pattern);
}
return pattern.matcher((String)left).matches();
}
/**
* INTERNAL:
* Conform an expression which uses the operator "regexp" for an in-memory query
* @return Boolean (TRUE, FALSE, null == unknown)
* An implementation of in memory queries with Regexp which uses the
* regular expression framework.
*/
public static Boolean conformRegexp(Object left, Object right) {
return getPlatform().conformRegexp(left, right);
if ((left == null) && (right == null)) {
return Boolean.TRUE;
} else if ((left == null) || (right == null)) {
return Boolean.FALSE;
}
left = String.valueOf(left);
right = String.valueOf(right);
// PERF: First check the pattern cache for the pattern.
// Note that the original string is the key, to avoid having to translate it first.
Pattern pattern = (Pattern)regexpPatternCache.get(right);
if (pattern == null) {
pattern = Pattern.compile((String)right);
// Ensure cache does not grow beyond 100.
if (regexpPatternCache.size() > 100) {
regexpPatternCache.remove(regexpPatternCache.keySet().iterator().next());
}
regexpPatternCache.put(right, pattern);
}
return pattern.matcher((String)left).matches();
}
/**
......@@ -92,7 +106,7 @@ public class JavaPlatform {
* Indicates whether the passed object implements java.sql.SQLXML introduced in jdk 1.6
*/
public static boolean isSQLXML(Object object) {
return getPlatform().isSQLXML(object);
return (object instanceof SQLXML);
}
/**
......@@ -100,6 +114,9 @@ public class JavaPlatform {
* Casts the passed object to SQLXML and calls getString and free methods
*/
public static String getStringAndFreeSQLXML(Object sqlXml) throws SQLException {
return getPlatform().getStringAndFreeSQLXML(sqlXml);
String str = ((SQLXML)sqlXml).getString();
((SQLXML)sqlXml).free();
return str;
}
}