Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/META-INF/MANIFEST.MF1
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/jpt_eclipselink_core.properties13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/JptEclipseLinkCoreMessages.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/libval/EclipseLinkUserLibraryValidator.java71
4 files changed, 4 insertions, 115 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/META-INF/MANIFEST.MF
index d832b6577d..18c8ef5b29 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/META-INF/MANIFEST.MF
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/META-INF/MANIFEST.MF
@@ -18,6 +18,7 @@ Require-Bundle: org.eclipse.core.commands;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jdt.launching;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jem.util;bundle-version="[2.0.100,3.0.0)",
org.eclipse.jpt.common.core;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jpt.common.eclipselink.core;bundle-version="[1.0.0,2.0.0)",
org.eclipse.jpt.jpa.core;bundle-version="[3.0.0,4.0.0)",
org.eclipse.jpt.jpa.db;bundle-version="[2.0.0,3.0.0)",
org.eclipse.jpt.common.utility;bundle-version="[2.0.0,3.0.0)",
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/jpt_eclipselink_core.properties b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/jpt_eclipselink_core.properties
deleted file mode 100644
index a0173b3f3b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/jpt_eclipselink_core.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-################################################################################
-# Copyright (c) 2010 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.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-
-EclipseLinkLibraryValidator_noEclipseLinkVersion=Selected libraries do not include required EclipseLink annotation classes.
-EclipseLinkLibraryValidator_multipleEclipseLinkVersions=There are multiple versions of EclipseLink in selected libraries.
-EclipseLinkLibraryValidator_improperEclipseLinkVersion=EclipseLink version does not meet platform requirements.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/JptEclipseLinkCoreMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/JptEclipseLinkCoreMessages.java
deleted file mode 100644
index 64f77b9e03..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/JptEclipseLinkCoreMessages.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.core.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Localized messages used by Dali eclipselink core.
- */
-public class JptEclipseLinkCoreMessages
-{
- public static String EclipseLinkLibraryValidator_noEclipseLinkVersion;
- public static String EclipseLinkLibraryValidator_multipleEclipseLinkVersions;
- public static String EclipseLinkLibraryValidator_improperEclipseLinkVersion;
-
-
- private static final String BUNDLE_NAME = "jpt_eclipselink_core"; //$NON-NLS-1$
- private static final Class<?> BUNDLE_CLASS = JptEclipseLinkCoreMessages.class;
- static {
- NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
- }
-
- private JptEclipseLinkCoreMessages() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/libval/EclipseLinkUserLibraryValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/libval/EclipseLinkUserLibraryValidator.java
index 973fb5817d..01eb730c10 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/libval/EclipseLinkUserLibraryValidator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/libval/EclipseLinkUserLibraryValidator.java
@@ -12,21 +12,13 @@ package org.eclipse.jpt.jpa.eclipselink.core.internal.libval;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ToolFactory;
-import org.eclipse.jdt.core.util.IClassFileReader;
-import org.eclipse.jdt.core.util.IFieldInfo;
import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.common.core.libval.LibraryValidator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.eclipselink.core.internal.libval.EclipseLinkLibValUtil;
import org.eclipse.jpt.jpa.core.internal.libprov.JpaUserLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription;
-import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.JptEclipseLinkCoreMessages;
import org.eclipse.jpt.jpa.eclipselink.core.platform.EclipseLinkPlatform;
import org.eclipse.osgi.service.resolver.VersionRange;
-import org.osgi.framework.Version;
/**
* Library validator for EclipseLink user libraries.
@@ -38,16 +30,12 @@ import org.osgi.framework.Version;
public class EclipseLinkUserLibraryValidator
implements LibraryValidator {
- private final static String VERSION_CLASS_PATH = "org/eclipse/persistence/Version.class"; //$NON-NLS-1$
-
- private final static String VERSION_FIELD_NAME = "version"; //$NON-NLS-1$
-
-
public IStatus validate(JptLibraryProviderInstallOperationConfig config) {
JpaUserLibraryProviderInstallOperationConfig jpaConfig
= (JpaUserLibraryProviderInstallOperationConfig) config;
JpaPlatformDescription platform = jpaConfig.getJpaPlatform();
Set<VersionRange> versionRanges = new HashSet<VersionRange>();
+
if (EclipseLinkPlatform.VERSION_1_0.equals(platform)) {
versionRanges.add(new VersionRange("[1.0, 3.0)")); //$NON-NLS-1$
}
@@ -63,60 +51,7 @@ public class EclipseLinkUserLibraryValidator
else if (EclipseLinkPlatform.VERSION_2_1.equals(platform)) {
versionRanges.add(new VersionRange("[2.1, 3.0)")); //$NON-NLS-1$
}
- return validate(jpaConfig, versionRanges);
- }
-
- protected IStatus validate(
- JpaUserLibraryProviderInstallOperationConfig config, Set<VersionRange> versionRanges) {
-
- Version version = null;
- for (IClasspathEntry cpe : config.resolve()) {
- String versionString = null;
- if (cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- IClassFileReader classReader =
- ToolFactory.createDefaultClassFileReader(
- cpe.getPath().toFile().getAbsolutePath(), VERSION_CLASS_PATH, IClassFileReader.FIELD_INFOS);
- if (classReader != null) {
- for (IFieldInfo field : classReader.getFieldInfos()) {
- if (StringTools.stringsAreEqual(field.getName(), VERSION_FIELD_NAME.toCharArray())) {
- try {
- versionString = field.getConstantValueAttribute().getConstantValue().getStringValue();
- }
- catch (Exception e) {
- // potentially a bit could go wrong with that last line, but if any
- // assumptions aren't met, there's no value
- }
- break;
- }
- }
- }
- if (versionString != null) {
- if (version != null) {
- return new Status(
- IStatus.ERROR, JptJpaEclipseLinkCorePlugin.PLUGIN_ID,
- JptEclipseLinkCoreMessages.EclipseLinkLibraryValidator_multipleEclipseLinkVersions);
- }
- else {
- version = new Version(versionString);
- }
- }
- }
- }
-
- if (version == null) {
- return new Status(
- IStatus.ERROR, JptJpaEclipseLinkCorePlugin.PLUGIN_ID,
- JptEclipseLinkCoreMessages.EclipseLinkLibraryValidator_noEclipseLinkVersion);
- }
-
- for (VersionRange versionRange : versionRanges) {
- if (! versionRange.isIncluded(version)) {
- return new Status(
- IStatus.ERROR, JptJpaEclipseLinkCorePlugin.PLUGIN_ID,
- JptEclipseLinkCoreMessages.EclipseLinkLibraryValidator_improperEclipseLinkVersion);
- }
- }
- return Status.OK_STATUS;
+ return EclipseLinkLibValUtil.validate(jpaConfig.resolve(), versionRanges);
}
}

Back to the top