Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/META-INF/MANIFEST.MF3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/src/org/eclipse/jpt/jpa/eclipselink/core/ddlgen/Main.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java50
3 files changed, 58 insertions, 33 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/META-INF/MANIFEST.MF
index c1ce439fe4..079058f613 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/META-INF/MANIFEST.MF
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Bundle-SymbolicName: org.eclipse.jpt.jpa.eclipselink.core.ddlgen;singleton:=true
Bundle-Version: 2.0.100.qualifier
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.jpt.jpa.eclipselink.core;bundle-version="[2.0.0,3.0.0)"
+Require-Bundle: org.eclipse.jpt.jpa.eclipselink.core;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.persistence.core;bundle-version="[2.4.0,3.0.0)"
Import-Package: javax.persistence
Export-Package: org.eclipse.jpt.jpa.eclipselink.core.ddlgen
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/src/org/eclipse/jpt/jpa/eclipselink/core/ddlgen/Main.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/src/org/eclipse/jpt/jpa/eclipselink/core/ddlgen/Main.java
index 3fd03400c8..6a4e5af92a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/src/org/eclipse/jpt/jpa/eclipselink/core/ddlgen/Main.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core.ddlgen/src/org/eclipse/jpt/jpa/eclipselink/core/ddlgen/Main.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2007, 2011 Oracle. All rights reserved.
+* Copyright (c) 2007, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -19,6 +19,8 @@ import java.util.Set;
import java.util.Map.Entry;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.dynamic.DynamicClassLoader;
/**
* This class creates a EclipseLink <code>EntityManagerFactory</code>,
@@ -29,6 +31,8 @@ import javax.persistence.Persistence;
* Current command-line arguments:
* [-pu puName] - persistence unit name
* [-p propertiesFilePath] - properties for EclipseLink EntityManager
+ * [-debug] - debug mode
+ * [-dynamic] - use the org.eclipse.persistence.dynamic.DynamicClassLoader
*
* Example of a properties file:
* eclipselink.jdbc.bind-parameters=false
@@ -49,7 +53,7 @@ import javax.persistence.Persistence;
public class Main
{
protected EntityManagerFactory emf;
- private Map<String, String> eclipseLinkProperties;
+ private Map<String, Object> eclipseLinkProperties;
private String eclipseLinkPropertiesPath;
private boolean isDebugMode;
@@ -86,22 +90,30 @@ public class Main
}
private void initializeWith(String[] args) {
-
this.eclipseLinkPropertiesPath = this.getEclipseLinkPropertiesPath(args);
this.eclipseLinkProperties = this.getProperties(this.eclipseLinkPropertiesPath);
+ this.setDynamicClassLoaderProperty(args);
this.isDebugMode = this.getDebugMode(args);
}
-
- private void dispose() {
+ private void setDynamicClassLoaderProperty(String[] args) {
+ if (this.getEclipseLinkDynamic(args)) {
+ this.eclipseLinkProperties.put(PersistenceUnitProperties.CLASSLOADER, this.buildDynamicClassLoader());
+ }
+ }
+
+ private ClassLoader buildDynamicClassLoader() {
+ return new DynamicClassLoader(Thread.currentThread().getContextClassLoader());
+ }
+
+ private void dispose() {
if( ! this.isDebugMode) {
new File(this.eclipseLinkPropertiesPath).delete();
}
}
- private Map<String, String> getProperties(String eclipseLinkPropertiesPath) {
-
+ private Map<String, Object> getProperties(String eclipseLinkPropertiesPath) {
Set<Entry<Object, Object>> propertiesSet = null;
try {
propertiesSet = this.loadEclipseLinkProperties(eclipseLinkPropertiesPath);
@@ -110,15 +122,14 @@ public class Main
throw new RuntimeException("Missing: " + eclipseLinkPropertiesPath, e); //$NON-NLS-1$
}
- Map<String, String> properties = new HashMap<String, String>();
+ Map<String, Object> properties = new HashMap<String, Object>();
for(Entry<Object, Object> property : propertiesSet) {
- properties.put((String)property.getKey(), (String)property.getValue());
+ properties.put((String) property.getKey(), property.getValue());
}
return properties;
}
private Set<Entry<Object, Object>> loadEclipseLinkProperties(String eclipseLinkPropertiesPath) throws IOException {
-
FileInputStream stream = new FileInputStream(eclipseLinkPropertiesPath);
Properties properties = new Properties();
@@ -130,20 +141,21 @@ public class Main
// ********** argument queries **********
private String getPUName(String[] args) {
-
return this.getArgumentValue("-pu", args); //$NON-NLS-1$
}
private String getEclipseLinkPropertiesPath(String[] args) {
-
return this.getArgumentValue("-p", args); //$NON-NLS-1$
}
private boolean getDebugMode(String[] args) {
-
return this.argumentExists("-debug", args); //$NON-NLS-1$
}
+ private boolean getEclipseLinkDynamic(String[] args) {
+ return this.argumentExists("-dynamic", args); //$NON-NLS-1$
+ }
+
private String getArgumentValue(String argument, String[] args) {
for (int i = 0; i < args.length; i++) {
String arg = args[i];
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java
index f6cd283a41..b860b4e77f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java
@@ -39,6 +39,7 @@ import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXmlEnumValue;
import org.eclipse.jpt.jpa.core.internal.JptCoreMessages;
import org.eclipse.jpt.jpa.db.ConnectionProfile;
+import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Connection;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Customization;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.DdlGenerationType;
@@ -62,10 +63,11 @@ public abstract class AbstractEclipseLinkDDLGenerator extends AbstractJptGenerat
public static final String TRUE = "true"; //$NON-NLS-1$
public static final String FALSE = "false"; //$NON-NLS-1$
public static final String NONE = "NONE"; //$NON-NLS-1$
+ private static final String DYNAMIC_PROGRAM_ARGUMENT = "-dynamic"; //$NON-NLS-1$
- private final String puName;
- private final JpaProject jpaProject;
- private final OutputMode outputMode;
+ protected final String puName;
+ protected final JpaProject jpaProject;
+ protected final OutputMode outputMode;
// ********** constructors **********
@@ -115,15 +117,38 @@ public abstract class AbstractEclipseLinkDDLGenerator extends AbstractJptGenerat
}
// ********** Setting Launch Configuration **********
-
+
@Override
protected void specifyProgramArguments() {
StringBuffer programArguments = new StringBuffer();
+ this.appendProgramArguments(programArguments);
+ this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
+ }
+
+ // ********** Main arguments **********
+
+ protected void appendProgramArguments(StringBuffer programArguments) {
this.appendPuNameArgument(programArguments);
this.appendPropertiesFileArgument(programArguments);
this.appendDebugArgument(programArguments);
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
+ this.appendDynamicArgument(programArguments);
+ }
+
+ private void appendPuNameArgument(StringBuffer sb) {
+ sb.append(" -pu \""); //$NON-NLS-1$
+ sb.append(this.puName);
+ sb.append("\""); //$NON-NLS-1$
+ }
+
+ private void appendPropertiesFileArgument(StringBuffer sb) {
+ sb.append(" -p \""); //$NON-NLS-1$
+ sb.append(this.projectLocation).append("/").append(PROPERTIES_FILE_NAME).append("\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ protected void appendDynamicArgument(StringBuffer sb) {
+ if (JptJpaEclipseLinkCorePlugin.nodeIsEclipseLinkVersionCompatible(this.jpaProject, JptJpaEclipseLinkCorePlugin.ECLIPSELINK_PLATFORM_VERSION_2_1)) {
+ sb.append(' ').append(DYNAMIC_PROGRAM_ARGUMENT);
+ }
}
@Override
@@ -329,19 +354,6 @@ public abstract class AbstractEclipseLinkDDLGenerator extends AbstractJptGenerat
return (cp == null) ? "" : cp.getDriverJarList(); //$NON-NLS-1$
}
- // ********** Main arguments **********
-
- private void appendPuNameArgument(StringBuffer sb) {
- sb.append(" -pu \""); //$NON-NLS-1$
- sb.append(this.puName);
- sb.append("\""); //$NON-NLS-1$
- }
-
- private void appendPropertiesFileArgument(StringBuffer sb) {
- sb.append(" -p \""); //$NON-NLS-1$
- sb.append(this.projectLocation).append("/").append(PROPERTIES_FILE_NAME).append("\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
// ********** Queries **********

Back to the top