Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2010-09-28 16:25:35 -0400
committerpfullbright2010-09-28 16:25:35 -0400
commit93d1a2dd781c87ac229d4bc53e0d7939f0ad20b5 (patch)
tree0fa70257dbe0beb0335024741af2f5500a1d3d70
parent616188beafa4ac7996dd85fed14edd3c81b6eeee (diff)
downloadwebtools.dali-93d1a2dd781c87ac229d4bc53e0d7939f0ad20b5.tar.gz
webtools.dali-93d1a2dd781c87ac229d4bc53e0d7939f0ad20b5.tar.xz
webtools.dali-93d1a2dd781c87ac229d4bc53e0d7939f0ad20b5.zip
library validation
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/META-INF/MANIFEST.MF3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/schema/libraryValidators.exsd154
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java82
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/FacetVersionPropertyTester.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java120
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaLibraryProviderConstants.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/RuntimeChangedListener.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaLibraryProviderInstallOperationConfig.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaOsgiBundlesLibraryProviderInstallOperationConfig.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaUserLibraryProviderInstallOperationConfig.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/LegacyJpaLibraryProviderDetector.java (renamed from jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/LegacyJpaLibraryProviderDetector.java)4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/LegacyJpaLibraryProviderUninstallOperation.java (renamed from jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/LegacyJpaLibraryProviderInstallOperation.java)6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/LibraryProviderPropertyTester.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/AbstractOsgiBundlesLibraryValidator.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/GenericEclipseLinkBundlesLibraryValidator.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/GenericJpaUserLibraryValidator.java (renamed from jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/KeyClassesValidator.java)69
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/LibraryValidatorConfig.java97
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/LibraryValidatorManager.java149
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/libval/LibraryValidator.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF3
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml163
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/jpt_eclipselink_core.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/JptEclipseLinkCoreMessages.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/libval/EclipseLinkEclipseLinkBundlesLibraryValidator.java102
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/libval/EclipseLinkUserLibraryValidator.java122
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/utility/EclipseLinkLibraryValidator.java141
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java80
30 files changed, 1177 insertions, 470 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.core/META-INF/MANIFEST.MF
index 48d02f78da..eb4527cb88 100644
--- a/jpa/plugins/org.eclipse.jpt.core/META-INF/MANIFEST.MF
+++ b/jpa/plugins/org.eclipse.jpt.core/META-INF/MANIFEST.MF
@@ -64,6 +64,8 @@ Export-Package: org.eclipse.jpt.core,
org.eclipse.jpt.core.internal.jpa2.resource.java;x-internal:=true,
org.eclipse.jpt.core.internal.jpa2.resource.java.binary;x-internal:=true,
org.eclipse.jpt.core.internal.jpa2.resource.java.source;x-internal:=true,
+ org.eclipse.jpt.core.internal.libprov,
+ org.eclipse.jpt.core.internal.libval,
org.eclipse.jpt.core.internal.operations;
x-friends:="org.eclipse.jpt.jaxb.ui",
org.eclipse.jpt.core.internal.platform,
@@ -90,6 +92,7 @@ Export-Package: org.eclipse.jpt.core,
org.eclipse.jpt.core.jpa2.context.persistence.connection,
org.eclipse.jpt.core.jpa2.context.persistence.options,
org.eclipse.jpt.core.jpa2.resource.java,
+ org.eclipse.jpt.core.libval,
org.eclipse.jpt.core.platform,
org.eclipse.jpt.core.resource,
org.eclipse.jpt.core.resource.java,
diff --git a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
index f8ec27c48c..47d23fe423 100644
--- a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
@@ -48,7 +48,9 @@ UPDATE_JOB_NAME=Update JPA project: ''{0}''
PLATFORM_ID_DOES_NOT_EXIST=No JPA platform exists for the id: ''{0}''. The JPA project was not created for project ''{1}''. Ensure that the platform''s plugin has been added to this Eclipse installation.
DALI_EVENT_HANDLER_THREAD_NAME=Dali Event Handler
PREFERENCES_FLUSH_JOB_NAME=Flush Preferences: {0}
-KEY_CLASSES_VALIDATOR__CLASS_NOT_FOUND=The class ''{0}'' is required to be in the selected libraries.
+USER_LIBRARY_VALIDATOR__CLASS_NOT_FOUND=The class ''{0}'' is required to be in the selected libraries.
+OSGI_BUNDLES_LIBRARY_VALIDATOR__BUNDLE_NOT_FOUND=The bundle ''{0}'' could not be found.
+OSGI_BUNDLES_LIBRARY_VALIDATOR__IMPROPER_BUNDLE_VERSION=The version of bundle ''{0}'' does not meet platform requirements.
GENERATION_CREATING_LAUNCH_CONFIG_TASK=Creating launch configuration
GENERATION_SAVING_LAUNCH_CONFIG_TASK=Saving launch config
GENERATION_LAUNCHING_CONFIG_TASK=Launching config
diff --git a/jpa/plugins/org.eclipse.jpt.core/schema/libraryValidators.exsd b/jpa/plugins/org.eclipse.jpt.core/schema/libraryValidators.exsd
new file mode 100644
index 0000000000..63bcec5fc0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/schema/libraryValidators.exsd
@@ -0,0 +1,154 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.jpt.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.jpt.core" id="libraryValidators" name="Library Validators"/>
+ </appInfo>
+ <documentation>
+ Used to provide custom library validation to JPA project configuration.
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="libraryValidator" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="libraryValidator">
+ <annotation>
+ <documentation>
+ Declares a library validator. See &lt;samp&gt;org.eclipse.jpt.core.libval.LibraryValidator&lt;/samp&gt; for more information on library validators.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="enablement" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ A unique identifier for the declared library validator.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The implementation class, which implements &lt;samp&gt;org.eclipse.jpt.core.libval.LibraryValidator&lt;/samp&gt;.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.jpt.core.libval.LibraryValidator"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ JPT 3.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ &lt;br&gt;
+&lt;p&gt;
+The following example is the included generic library validator, which is used for user library validation for projects of the generic JPA platform group.
+&lt;p&gt;
+&lt;pre&gt;
+&lt;extension
+ point=&quot;org.eclipse.jpt.core.libraryValidators&quot;&gt;
+ &lt;libraryValidator
+ id=&quot;genericUserLibraryValidator&quot;
+ class=&quot;org.eclipse.jpt.core.internal.libval.GenericJpaUserLibraryValidator&quot;&gt;
+ &lt;enablement&gt;
+ &lt;with variable=&quot;libraryProvider&quot;&gt;
+ &lt;test property=&quot;org.eclipse.jpt.core.extendsId&quot; value=&quot;jpa-user-library-provider&quot;/&gt;
+ &lt;/with&gt;
+ &lt;/enablement&gt;
+ &lt;/libraryValidator&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ &lt;p&gt;
+The contributed resource locator class must implement &lt;code&gt;org.eclipse.jpt.core.resource.ResourceLocator&lt;/code&gt;.
+&lt;p&gt;
+The enablement variables include:
+&lt;ul&gt;
+&lt;li&gt;&quot;libraryProvider&quot; which gives the current ILibraryProvider.&lt;/li&gt;
+&lt;li&gt;&quot;jpaPlatform&quot; which gives the current JpaPlatformDescription.&lt;/li&gt;
+&lt;/ul&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ &lt;p&gt;The org.eclipse.jpt.core plug-in provides the following library validators:
+&lt;ul&gt;
+&lt;li&gt;genericUserLibraryValidator&lt;/li&gt;
+&lt;li&gt;genericEclipselinkBundlesLibraryValidator&lt;/li&gt;
+&lt;/ul&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ 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
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
index 8b77fbaff3..5bce843d99 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
@@ -30,9 +30,12 @@ import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.core.internal.JptCoreMessages;
+import org.eclipse.jpt.core.internal.libprov.JptLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.internal.libval.LibraryValidatorManager;
import org.eclipse.jpt.core.internal.platform.JpaPlatformManagerImpl;
import org.eclipse.jpt.core.internal.prefs.JpaPreferenceInitializer;
import org.eclipse.jpt.core.internal.resource.ResourceLocatorManager;
+import org.eclipse.jpt.core.libval.LibraryValidator;
import org.eclipse.jpt.core.platform.GenericPlatform;
import org.eclipse.jpt.core.platform.JpaPlatformDescription;
import org.eclipse.jpt.core.platform.JpaPlatformManager;
@@ -42,7 +45,9 @@ import org.eclipse.jst.j2ee.internal.J2EEConstants;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.osgi.framework.BundleContext;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
@@ -211,7 +216,8 @@ public class JptCorePlugin extends Plugin {
/**
* Web projects have some special exceptions.
*/
- public static final String WEB_PROJECT_FACET_ID = IModuleConstants.JST_WEB_MODULE;
+ public static final IProjectFacet WEB_FACET
+ = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_WEB_MODULE);
public static final IPath DEFAULT_PERSISTENCE_XML_RUNTIME_PATH = new Path("META-INF/persistence.xml"); //$NON-NLS-1$
@@ -283,21 +289,26 @@ public class JptCorePlugin extends Plugin {
* Return whether the specified Eclipse project has a Web facet.
*/
public static boolean projectHasWebFacet(IProject project) {
- return projectHasFacet(project, WEB_PROJECT_FACET_ID);
+ return projectHasFacet(project, WEB_FACET);
}
/**
* Checked exceptions bite.
*/
- private static boolean projectHasFacet(IProject project, String facetId) {
+ private static boolean projectHasFacet(IProject project, IProjectFacet facet) {
try {
- return FacetedProjectFramework.hasProjectFacet(project, facetId);
+ return FacetedProjectFramework.hasProjectFacet(project, facet.getId());
} catch (CoreException ex) {
log(ex); // problems reading the project metadata - assume facet doesn't exist - return 'false'
return false;
}
}
+ public static Iterable<LibraryValidator> getLibraryValidators(
+ JptLibraryProviderInstallOperationConfig config) {
+ return LibraryValidatorManager.instance().getLibraryValidators(config);
+ }
+
public static ResourceLocator getResourceLocator(IProject project) {
return ResourceLocatorManager.instance().getResourceLocator(project);
}
@@ -363,6 +374,15 @@ public class JptCorePlugin extends Plugin {
public static IEclipsePreferences getWorkspacePreferences() {
return getPreferences(new InstanceScope());
}
+
+ /**
+ * Set the workspace preference.
+ */
+ public static void setWorkspacePreference(String preferenceKey, String preferenceValue) {
+ IEclipsePreferences prefs = getWorkspacePreferences();
+ prefs.put(preferenceKey, preferenceValue);
+ flush(prefs);
+ }
/**
* Return the Dali preferences for the specified Eclipse project.
@@ -370,7 +390,30 @@ public class JptCorePlugin extends Plugin {
public static IEclipsePreferences getProjectPreferences(IProject project) {
return getPreferences(new ProjectScope(project));
}
-
+
+ /**
+ * Set the project preference
+ */
+ public static void setProjectPreference(IProject project, String preferenceKey, String preferenceValue) {
+ IEclipsePreferences prefs = getProjectPreferences(project);
+ if (preferenceValue == null) {
+ prefs.remove(preferenceKey);
+ }
+ else {
+ prefs.put(preferenceKey, preferenceValue);
+ }
+ flush(prefs);
+ }
+
+ /**
+ * Set the project preference
+ */
+ public static void setProjectPreference(IProject project, String preferenceKey, boolean preferenceValue) {
+ IEclipsePreferences prefs = getProjectPreferences(project);
+ prefs.putBoolean(preferenceKey, preferenceValue);
+ flush(prefs);
+ }
+
/**
* Return the Dali preferences for the specified context.
*/
@@ -436,7 +479,6 @@ public class JptCorePlugin extends Plugin {
* Set the default JPA platform ID for creating new JPA projects
*/
public static void setDefaultJpaPlatformId(String jpaFacetVersion, String platformId) {
- IEclipsePreferences prefs = getWorkspacePreferences();
String preferenceKey = null;
if (JpaFacet.VERSION_1_0.getVersionString().equals(jpaFacetVersion)) {
preferenceKey = DEFAULT_JPA_PLATFORM_1_0_PREF_KEY;
@@ -447,8 +489,7 @@ public class JptCorePlugin extends Plugin {
else {
throw new IllegalArgumentException("Illegal JPA facet version: " + jpaFacetVersion); //$NON-NLS-1$
}
- prefs.put(preferenceKey, platformId);
- flush(prefs);
+ setWorkspacePreference(preferenceKey, platformId);
}
/**
@@ -457,14 +498,20 @@ public class JptCorePlugin extends Plugin {
public static String getJpaPlatformId(IProject project) {
return getProjectPreferences(project).get(JPA_PLATFORM_PREF_KEY, GenericPlatform.VERSION_1_0.getId());
}
+
+ /**
+ * Return the JPA platform description associated with the specified Eclipse project.
+ */
+ public static JpaPlatformDescription getJpaPlatformDescription(IProject project) {
+ String jpaPlatformId = getJpaPlatformId(project);
+ return getJpaPlatformManager().getJpaPlatform(jpaPlatformId);
+ }
/**
* Set the JPA platform ID associated with the specified Eclipse project.
*/
public static void setJpaPlatformId(IProject project, String jpaPlatformId) {
- IEclipsePreferences prefs = getProjectPreferences(project);
- prefs.put(JPA_PLATFORM_PREF_KEY, jpaPlatformId);
- flush(prefs);
+ setProjectPreference(project, JPA_PLATFORM_PREF_KEY, jpaPlatformId);
}
/**
@@ -488,9 +535,7 @@ public class JptCorePlugin extends Plugin {
* Eclipse project.
*/
public static void setDiscoverAnnotatedClasses(IProject project, boolean discoverAnnotatedClasses) {
- IEclipsePreferences prefs = getProjectPreferences(project);
- prefs.putBoolean(DISCOVER_ANNOTATED_CLASSES, discoverAnnotatedClasses);
- flush(prefs);
+ setProjectPreference(project, DISCOVER_ANNOTATED_CLASSES, discoverAnnotatedClasses);
}
/**
@@ -506,14 +551,7 @@ public class JptCorePlugin extends Plugin {
* specified Eclipse project.
*/
public static void setMetamodelSourceFolderName(IProject project, String metamodelSourceFolderName) {
- IEclipsePreferences prefs = getProjectPreferences(project);
- if (metamodelSourceFolderName == null) {
- prefs.remove(METAMODEL_SOURCE_FOLDER_NAME);
- }
- else {
- prefs.put(METAMODEL_SOURCE_FOLDER_NAME, metamodelSourceFolderName);
- }
- flush(prefs);
+ setProjectPreference(project, METAMODEL_SOURCE_FOLDER_NAME, metamodelSourceFolderName);
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java
index 5da79b0510..ba2d5831eb 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java
@@ -11,10 +11,8 @@ package org.eclipse.jpt.core.internal;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.Vector;
import org.eclipse.core.resources.IFile;
@@ -49,7 +47,6 @@ import org.eclipse.jpt.core.JpaResourceModel;
import org.eclipse.jpt.core.JpaResourceModelListener;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.context.JpaRootContextNode;
-import org.eclipse.jpt.core.internal.facet.JpaLibraryProviderConstants;
import org.eclipse.jpt.core.internal.resource.java.binary.BinaryPersistentTypeCache;
import org.eclipse.jpt.core.internal.resource.java.source.SourceCompilationUnit;
import org.eclipse.jpt.core.internal.utility.PlatformTools;
@@ -1331,15 +1328,12 @@ public abstract class AbstractJpaProject
}
protected void validateLibraryProvider(List<IMessage> messages) {
- Map<String, Object> enablementVariables = new HashMap<String, Object>();
- enablementVariables.put(JpaLibraryProviderConstants.EXPR_VAR_JPA_PLATFORM, getJpaPlatform().getId());
-
try {
ILibraryProvider libraryProvider = LibraryProviderFramework.getCurrentProvider(getProject(), JpaFacet.FACET);
IFacetedProject facetedProject = ProjectFacetsManager.create(getProject());
IProjectFacetVersion facetVersion = facetedProject.getInstalledVersion(JpaFacet.FACET);
if (! libraryProvider.isEnabledFor(
- facetedProject, facetVersion, enablementVariables)) {
+ facetedProject, facetVersion)) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/FacetVersionPropertyTester.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/FacetVersionPropertyTester.java
deleted file mode 100644
index 714a7464d3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/FacetVersionPropertyTester.java
+++ /dev/null
@@ -1,36 +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.core.internal;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.wst.common.project.facet.core.IGroup;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-
-public class FacetVersionPropertyTester
- extends PropertyTester {
-
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if (! property.equals("group")) { //$NON-NLS-1$
- return false;
- }
-
- if (! (receiver instanceof IProjectFacetVersion) || ! (expectedValue instanceof String)) {
- return false;
- }
-
- IGroup group = ProjectFacetsManager.getGroup((String) expectedValue);
- if (group == null) {
- return false;
- }
-
- return group.getMembers().contains((IProjectFacetVersion) receiver);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
index 882e010ec9..f1bfa5e358 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
@@ -56,7 +56,9 @@ public class JptCoreMessages {
public static String PLATFORM_ID_DOES_NOT_EXIST;
public static String DALI_EVENT_HANDLER_THREAD_NAME;
public static String PREFERENCES_FLUSH_JOB_NAME;
- public static String KEY_CLASSES_VALIDATOR__CLASS_NOT_FOUND;
+ public static String USER_LIBRARY_VALIDATOR__CLASS_NOT_FOUND;
+ public static String OSGI_BUNDLES_LIBRARY_VALIDATOR__BUNDLE_NOT_FOUND;
+ public static String OSGI_BUNDLES_LIBRARY_VALIDATOR__IMPROPER_BUNDLE_VERSION;
public static String GENERATION_CREATING_LAUNCH_CONFIG_TASK;
public static String GENERATION_SAVING_LAUNCH_CONFIG_TASK;
public static String GENERATION_LAUNCHING_CONFIG_TASK;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java
index 558f2ef6a5..59a3449985 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java
@@ -10,16 +10,16 @@
*******************************************************************************/
package org.eclipse.jpt.core.internal.facet;
+import java.util.ArrayList;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jpt.core.JpaFacet;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.internal.JptCoreMessages;
+import org.eclipse.jpt.core.internal.libprov.JpaLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.core.platform.JpaPlatformDescription;
import org.eclipse.jpt.db.Catalog;
import org.eclipse.jpt.db.ConnectionProfile;
@@ -33,8 +33,10 @@ import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
+import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener;
import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
@@ -82,7 +84,7 @@ public abstract class JpaFacetDataModelProvider
public Set<String> getPropertyNames() {
@SuppressWarnings("unchecked") Set<String> propertyNames = super.getPropertyNames();
propertyNames.add(RUNTIME);
- propertyNames.add(PLATFORM_ID);
+ propertyNames.add(PLATFORM);
propertyNames.add(LIBRARY_PROVIDER_DELEGATE);
propertyNames.add(CONNECTION);
propertyNames.add(CONNECTION_ACTIVE);
@@ -110,8 +112,8 @@ public abstract class JpaFacetDataModelProvider
return (IRuntime) this.getProperty(RUNTIME);
}
- protected String getPlatformId() {
- return (String) this.getProperty(PLATFORM_ID);
+ protected JpaPlatformDescription getPlatform() {
+ return (JpaPlatformDescription) getProperty(PLATFORM);
}
protected LibraryInstallDelegate getLibraryInstallDelegate() {
@@ -174,8 +176,8 @@ public abstract class JpaFacetDataModelProvider
if (propertyName.equals(RUNTIME)) {
return null;
}
- if (propertyName.equals(PLATFORM_ID)) {
- return getDefaultPlatformId();
+ if (propertyName.equals(PLATFORM)) {
+ return getDefaultPlatform();
}
if (propertyName.equals(LIBRARY_PROVIDER_DELEGATE)) {
return getDefaultLibraryProvider();
@@ -208,12 +210,16 @@ public abstract class JpaFacetDataModelProvider
return super.getDefaultProperty(propertyName);
}
- protected abstract String getDefaultPlatformId();
+ protected abstract JpaPlatformDescription getDefaultPlatform();
protected LibraryInstallDelegate getDefaultLibraryProvider() {
- // delegate itself changes, not the instance of delegate
+ // delegate itself changes only when facet version changes
if (this.defaultLibraryProvider == null) {
- this.defaultLibraryProvider = this.buildDefaultLibraryProvider();
+ this.defaultLibraryProvider = buildDefaultLibraryProvider();
+ }
+ else if (! this.defaultLibraryProvider.getProjectFacetVersion().equals(getProjectFacetVersion())) {
+ this.defaultLibraryProvider.dispose();
+ this.defaultLibraryProvider = buildDefaultLibraryProvider();
}
return defaultLibraryProvider;
}
@@ -227,20 +233,17 @@ public abstract class JpaFacetDataModelProvider
if (pfv == null) {
return null;
}
- LibraryInstallDelegate lp = new LibraryInstallDelegate(fpjwc, pfv, this.buildEnablementVariables());
- lp.addListener(this.buildLibraryProviderListener());
+ LibraryInstallDelegate lp = new LibraryInstallDelegate(fpjwc, pfv);
+ lp.addListener(buildLibraryProviderListener());
return lp;
}
- protected Map<String, Object> buildEnablementVariables() {
- Map<String, Object> enablementVariables = new HashMap<String, Object>();
- enablementVariables.put(JpaLibraryProviderConstants.EXPR_VAR_JPA_PLATFORM, this.getPlatformId());
- return enablementVariables;
- }
-
protected IPropertyChangeListener buildLibraryProviderListener() {
return new IPropertyChangeListener() {
public void propertyChanged(String property, Object oldValue, Object newValue ) {
+ if (LibraryInstallDelegate.PROP_AVAILABLE_PROVIDERS.equals(property)) {
+ adjustLibraryProviders();
+ }
JpaFacetDataModelProvider.this.getDataModel().notifyPropertyChange(
LIBRARY_PROVIDER_DELEGATE, IDataModel.VALUE_CHG);
}
@@ -287,8 +290,8 @@ public abstract class JpaFacetDataModelProvider
//no-op
}
else if (propertyName.equals(FACET_VERSION)) {
- this.model.notifyPropertyChange(PLATFORM_ID, IDataModel.DEFAULT_CHG);
- resetLibraryProviderEnablementContext();
+ adjustLibraryProviders();
+ this.model.notifyPropertyChange(PLATFORM, IDataModel.DEFAULT_CHG);
this.model.notifyPropertyChange(LIBRARY_PROVIDER_DELEGATE, IDataModel.DEFAULT_CHG);
}
else if (propertyName.equals(RUNTIME)) {
@@ -301,8 +304,8 @@ public abstract class JpaFacetDataModelProvider
this.model.notifyPropertyChange(DISCOVER_ANNOTATED_CLASSES, IDataModel.DEFAULT_CHG);
this.model.notifyPropertyChange(LIST_ANNOTATED_CLASSES, IDataModel.DEFAULT_CHG);
}
- else if (propertyName.equals(PLATFORM_ID)) {
- resetLibraryProviderEnablementContext();
+ else if (propertyName.equals(PLATFORM)) {
+ adjustLibraryProviders();
}
else if (propertyName.equals(CONNECTION)) {
this.setBooleanProperty(CONNECTION_ACTIVE, this.connectionIsActive());
@@ -382,13 +385,29 @@ public abstract class JpaFacetDataModelProvider
return ((Boolean) propertyValue).booleanValue();
}
- protected void resetLibraryProviderEnablementContext() {
+ protected void adjustLibraryProviders() {
LibraryInstallDelegate lid = this.getLibraryInstallDelegate();
- if (lid != null) {
- // may be null while model is being built up
- // ... or in tests
- lid.setEnablementContextVariable(JpaLibraryProviderConstants.EXPR_VAR_JPA_PLATFORM, getPlatformId());
+ if (lid != null) {
+ List<JpaLibraryProviderInstallOperationConfig> jpaConfigs
+ = new ArrayList<JpaLibraryProviderInstallOperationConfig>();
+ // add the currently selected one first
+ JpaLibraryProviderInstallOperationConfig currentJpaConfig = null;
+ LibraryProviderOperationConfig config = lid.getLibraryProviderOperationConfig();
+ if (config instanceof JpaLibraryProviderInstallOperationConfig) {
+ currentJpaConfig = (JpaLibraryProviderInstallOperationConfig) config;
+ jpaConfigs.add(currentJpaConfig);
+ }
+ for (ILibraryProvider lp : lid.getLibraryProviders()) {
+ config = lid.getLibraryProviderOperationConfig(lp);
+ if (config instanceof JpaLibraryProviderInstallOperationConfig
+ && ! config.equals(currentJpaConfig)) {
+ jpaConfigs.add((JpaLibraryProviderInstallOperationConfig) config);
+ }
+ }
+ for (JpaLibraryProviderInstallOperationConfig jpaConfig : jpaConfigs) {
+ jpaConfig.setJpaPlatform(getPlatform());
}
+ }
}
@@ -396,7 +415,7 @@ public abstract class JpaFacetDataModelProvider
@Override
public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) {
- if (propertyName.equals(PLATFORM_ID)) {
+ if (propertyName.equals(PLATFORM)) {
return this.buildValidPlatformDescriptors();
}
if (propertyName.equals(CONNECTION)) {
@@ -413,30 +432,25 @@ public abstract class JpaFacetDataModelProvider
}
protected DataModelPropertyDescriptor[] buildValidPlatformDescriptors() {
- Iterable<String> validPlatformIds = buildValidPlatformIds();
+ Iterable<JpaPlatformDescription> validPlatformDescriptions = buildValidPlatformDescriptions();
Iterable<DataModelPropertyDescriptor> validPlatformDescriptors =
- new TransformationIterable<String, DataModelPropertyDescriptor>(validPlatformIds) {
+ new TransformationIterable<JpaPlatformDescription, DataModelPropertyDescriptor>(validPlatformDescriptions) {
@Override
- protected DataModelPropertyDescriptor transform(String platformId) {
- return JpaFacetDataModelProvider.this.buildPlatformIdDescriptor(platformId);
+ protected DataModelPropertyDescriptor transform(JpaPlatformDescription desc) {
+ return buildPlatformDescriptor(desc);
}
};
return ArrayTools.sort(ArrayTools.array(validPlatformDescriptors, EMPTY_DMPD_ARRAY), DESCRIPTOR_COMPARATOR);
}
- protected Iterable<String> buildValidPlatformIds() {
- return new TransformationIterable<JpaPlatformDescription, String>(
- new FilteringIterable<JpaPlatformDescription>(JptCorePlugin.getJpaPlatformManager().getJpaPlatforms()) {
- @Override
- protected boolean accept(JpaPlatformDescription o) {
- return o.supportsJpaFacetVersion(getProjectFacetVersion());
- }
- }) {
- @Override
- protected String transform(JpaPlatformDescription o) {
- return o.getId();
- }
- };
+ protected Iterable<JpaPlatformDescription> buildValidPlatformDescriptions() {
+ return new FilteringIterable<JpaPlatformDescription>(
+ JptCorePlugin.getJpaPlatformManager().getJpaPlatforms()) {
+ @Override
+ protected boolean accept(JpaPlatformDescription o) {
+ return o.supportsJpaFacetVersion(getProjectFacetVersion());
+ }
+ };
}
protected static final Comparator<DataModelPropertyDescriptor> DESCRIPTOR_COMPARATOR =
@@ -518,8 +532,8 @@ public abstract class JpaFacetDataModelProvider
*/
@Override
public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) {
- if (propertyName.equals(PLATFORM_ID)) {
- return buildPlatformIdDescriptor(this.getPlatformId());
+ if (propertyName.equals(PLATFORM)) {
+ return buildPlatformDescriptor(this.getPlatform());
}
if (propertyName.equals(CONNECTION)) {
return buildConnectionDescriptor(this.getConnectionName());
@@ -527,8 +541,8 @@ public abstract class JpaFacetDataModelProvider
return super.getPropertyDescriptor(propertyName);
}
- protected DataModelPropertyDescriptor buildPlatformIdDescriptor(String platformId) {
- return new DataModelPropertyDescriptor(platformId, this.getPlatformLabel(platformId));
+ protected DataModelPropertyDescriptor buildPlatformDescriptor(JpaPlatformDescription platform) {
+ return new DataModelPropertyDescriptor(platform, platform.getLabel());
}
protected String getPlatformLabel(String platformId) {
@@ -612,8 +626,8 @@ public abstract class JpaFacetDataModelProvider
@Override
public IStatus validate(String propertyName) {
- if (propertyName.equals(PLATFORM_ID)) {
- return this.validatePlatformId();
+ if (propertyName.equals(PLATFORM)) {
+ return this.validatePlatform();
}
if (propertyName.equals(LIBRARY_PROVIDER_DELEGATE)) {
return this.getLibraryInstallDelegate().validate();
@@ -636,8 +650,8 @@ public abstract class JpaFacetDataModelProvider
return super.validate(propertyName);
}
- protected IStatus validatePlatformId() {
- return (this.getPlatformId() == null) ? PLATFORM_NOT_SPECIFIED_STATUS : OK_STATUS;
+ protected IStatus validatePlatform() {
+ return (this.getPlatform() == null) ? PLATFORM_NOT_SPECIFIED_STATUS : OK_STATUS;
}
protected IStatus validateConnection() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaLibraryProviderConstants.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaLibraryProviderConstants.java
deleted file mode 100644
index 626ae91738..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaLibraryProviderConstants.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.core.internal.facet;
-
-public interface JpaLibraryProviderConstants
-{
- public static final String EXPR_VAR_JPA_PLATFORM
- = "jpaPlatform"; //$NON-NLS-1$
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/RuntimeChangedListener.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/RuntimeChangedListener.java
index ae647c45e0..f9d47036a0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/RuntimeChangedListener.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/RuntimeChangedListener.java
@@ -1,7 +1,14 @@
+/*******************************************************************************
+ * 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.core.internal.facet;
-import java.util.HashMap;
-import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -25,9 +32,7 @@ public class RuntimeChangedListener
}
IProjectFacetVersion pfv = fpb.getProjectFacetVersion(JpaFacet.FACET);
if (pfv != null) {
- Map<String, Object> enablementVariables = new HashMap<String, Object>();
- enablementVariables.put(JpaLibraryProviderConstants.EXPR_VAR_JPA_PLATFORM, getJpaPlatformId(fpb.getProject()));
- LibraryInstallDelegate lp = new LibraryInstallDelegate(fpb, pfv, enablementVariables);
+ LibraryInstallDelegate lp = new LibraryInstallDelegate(fpb, pfv);
try {
lp.execute(new NullProgressMonitor());
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaLibraryProviderInstallOperationConfig.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaLibraryProviderInstallOperationConfig.java
new file mode 100644
index 0000000000..d8e252be15
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaLibraryProviderInstallOperationConfig.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.core.internal.libprov;
+
+import org.eclipse.jpt.core.platform.JpaPlatformDescription;
+
+
+public interface JpaLibraryProviderInstallOperationConfig
+ extends JptLibraryProviderInstallOperationConfig {
+
+ public static final String PROP_JPA_PLATFORM = "JPA_PLATFORM"; //$NON-NLS-1$
+
+ JpaPlatformDescription getJpaPlatform();
+
+ void setJpaPlatform(JpaPlatformDescription jpaPlatform);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaOsgiBundlesLibraryProviderInstallOperationConfig.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaOsgiBundlesLibraryProviderInstallOperationConfig.java
new file mode 100644
index 0000000000..21113fa7d2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaOsgiBundlesLibraryProviderInstallOperationConfig.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.core.internal.libprov;
+
+import org.eclipse.jpt.core.platform.JpaPlatformDescription;
+
+public class JpaOsgiBundlesLibraryProviderInstallOperationConfig
+ extends JptOsgiBundlesLibraryProviderInstallOperationConfig
+ implements JpaLibraryProviderInstallOperationConfig {
+
+ private JpaPlatformDescription jpaPlatform;
+
+
+ public JpaOsgiBundlesLibraryProviderInstallOperationConfig() {
+ super();
+ }
+
+ public JpaPlatformDescription getJpaPlatform() {
+ return this.jpaPlatform;
+ }
+
+ public void setJpaPlatform(JpaPlatformDescription jpaPlatform) {
+ JpaPlatformDescription old = this.jpaPlatform;
+ this.jpaPlatform = jpaPlatform;
+ notifyListeners(PROP_JPA_PLATFORM, old, jpaPlatform);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaUserLibraryProviderInstallOperationConfig.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaUserLibraryProviderInstallOperationConfig.java
new file mode 100644
index 0000000000..91defe2d08
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/JpaUserLibraryProviderInstallOperationConfig.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.core.internal.libprov;
+
+import org.eclipse.jpt.core.platform.JpaPlatformDescription;
+
+public class JpaUserLibraryProviderInstallOperationConfig
+ extends JptUserLibraryProviderInstallOperationConfig
+ implements JpaLibraryProviderInstallOperationConfig {
+
+ private JpaPlatformDescription jpaPlatform;
+
+
+ public JpaUserLibraryProviderInstallOperationConfig() {
+ super();
+ }
+
+
+ public JpaPlatformDescription getJpaPlatform() {
+ return this.jpaPlatform;
+ }
+
+ public void setJpaPlatform(JpaPlatformDescription jpaPlatform) {
+ JpaPlatformDescription old = this.jpaPlatform;
+ this.jpaPlatform = jpaPlatform;
+ notifyListeners(PROP_JPA_PLATFORM, old, jpaPlatform);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/LegacyJpaLibraryProviderDetector.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/LegacyJpaLibraryProviderDetector.java
index 5a299415fb..398ddce2ce 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/LegacyJpaLibraryProviderDetector.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/LegacyJpaLibraryProviderDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * Copyright (c) 2009, 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
@@ -8,7 +8,7 @@
* Contributors:
* Oracle - initial API and implementation
*******************************************************************************/
-package org.eclipse.jpt.core.internal.facet;
+package org.eclipse.jpt.core.internal.libprov;
import org.eclipse.core.resources.IProject;
import org.eclipse.jpt.core.JpaFacet;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/LegacyJpaLibraryProviderInstallOperation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/LegacyJpaLibraryProviderUninstallOperation.java
index 2b286e642d..a6dc73b030 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/LegacyJpaLibraryProviderInstallOperation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/LegacyJpaLibraryProviderUninstallOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * Copyright (c) 2009, 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
@@ -8,14 +8,14 @@
* Contributors:
* Oracle - initial API and implementation
*******************************************************************************/
-package org.eclipse.jpt.core.internal.facet;
+package org.eclipse.jpt.core.internal.libprov;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperation;
import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
-public class LegacyJpaLibraryProviderInstallOperation
+public class LegacyJpaLibraryProviderUninstallOperation
extends LibraryProviderOperation
{
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/LibraryProviderPropertyTester.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/LibraryProviderPropertyTester.java
new file mode 100644
index 0000000000..6dbd6295fc
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libprov/LibraryProviderPropertyTester.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.core.internal.libprov;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
+
+public class LibraryProviderPropertyTester
+ extends PropertyTester {
+
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (! (property.equals("id") || property.equals("extendsId")) //$NON-NLS-1$
+ || ! (receiver instanceof ILibraryProvider)
+ || ! (expectedValue instanceof String)) {
+ return false;
+ }
+
+ ILibraryProvider libraryProvider = (ILibraryProvider) receiver;
+
+ if (property.equals("id")) {
+ return libraryProvider.getId().equals(expectedValue);
+ }
+ else if (property.equals("extendsId")) {
+ while (libraryProvider != null) {
+ if (libraryProvider.getId().equals(expectedValue)) {
+ return true;
+ }
+ libraryProvider = libraryProvider.getBaseProvider();
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/AbstractOsgiBundlesLibraryValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/AbstractOsgiBundlesLibraryValidator.java
new file mode 100644
index 0000000000..c9b7f4e704
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/AbstractOsgiBundlesLibraryValidator.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.core.internal.libval;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jpt.core.JptCorePlugin;
+import org.eclipse.jpt.core.internal.JptCoreMessages;
+import org.eclipse.jpt.core.internal.libprov.JpaOsgiBundlesLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.libval.LibraryValidator;
+import org.eclipse.jst.common.project.facet.core.libprov.osgi.BundleReference;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.eclipse.osgi.util.NLS;
+import org.osgi.framework.Bundle;
+
+public abstract class AbstractOsgiBundlesLibraryValidator
+ implements LibraryValidator {
+
+ protected IStatus validate(
+ JpaOsgiBundlesLibraryProviderInstallOperationConfig config,
+ Map<String, VersionRange[]> bundleVersionRanges) {
+
+ Map<String, Bundle> bundles = new HashMap<String, Bundle>();
+
+ for (BundleReference bundleRef : config.getBundleReferences()) {
+ for (String bundleName : bundleVersionRanges.keySet()) {
+ // if we've gotten here, the bundle references are resolvable
+ if (bundleRef.getBundle().getSymbolicName().equals(bundleName)) {
+ bundles.put(bundleName, bundleRef.getBundle());
+ }
+ }
+ }
+
+ for (String bundleName : bundleVersionRanges.keySet()) {
+ if (bundles.get(bundleName) == null) {
+ String message
+ = NLS.bind(JptCoreMessages.OSGI_BUNDLES_LIBRARY_VALIDATOR__BUNDLE_NOT_FOUND, bundleName);
+ return new Status(IStatus.ERROR, JptCorePlugin.PLUGIN_ID, message);
+ }
+ }
+
+ for (String bundleName : bundleVersionRanges.keySet()) {
+ Bundle bundle = bundles.get(bundleName);
+ for (VersionRange versionRange : bundleVersionRanges.get(bundleName)) {
+ if (! versionRange.isIncluded(bundle.getVersion())) {
+ String message
+ = NLS.bind(JptCoreMessages.OSGI_BUNDLES_LIBRARY_VALIDATOR__IMPROPER_BUNDLE_VERSION, bundleName);
+ return new Status(IStatus.ERROR, JptCorePlugin.PLUGIN_ID, message);
+ }
+ }
+ }
+
+ return Status.OK_STATUS;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/GenericEclipseLinkBundlesLibraryValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/GenericEclipseLinkBundlesLibraryValidator.java
new file mode 100644
index 0000000000..9f09cecf35
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/GenericEclipseLinkBundlesLibraryValidator.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.core.internal.libval;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jpt.core.JpaFacet;
+import org.eclipse.jpt.core.internal.libprov.JpaOsgiBundlesLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.internal.libprov.JptLibraryProviderInstallOperationConfig;
+import org.eclipse.osgi.service.resolver.VersionRange;
+
+public class GenericEclipseLinkBundlesLibraryValidator
+ extends AbstractOsgiBundlesLibraryValidator {
+
+ public IStatus validate(JptLibraryProviderInstallOperationConfig config) {
+ JpaOsgiBundlesLibraryProviderInstallOperationConfig jpaConfig
+ = (JpaOsgiBundlesLibraryProviderInstallOperationConfig) config;
+ Map<String, VersionRange[]> bundleVersionRanges = new HashMap<String, VersionRange[]>();
+ String bundleName = "javax.persistence";
+ VersionRange[] versionRanges = new VersionRange[0];
+ if (config.getProjectFacetVersion().equals(JpaFacet.VERSION_1_0)) {
+ versionRanges = new VersionRange[] {new VersionRange("[1.0, 3.0)")};
+ }
+ else if (config.getProjectFacetVersion().equals(JpaFacet.VERSION_2_0)) {
+ versionRanges = new VersionRange[] {new VersionRange("[2.0, 3.0)")};
+ }
+ bundleVersionRanges.put(bundleName, versionRanges);
+ return validate(jpaConfig, bundleVersionRanges);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/KeyClassesValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/GenericJpaUserLibraryValidator.java
index a16f50d426..3a8813b223 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/KeyClassesValidator.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/GenericJpaUserLibraryValidator.java
@@ -1,17 +1,13 @@
/*******************************************************************************
- * 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
+ * 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 - ongoing maintenance
- *
- * Originally copied from
- * {@link org.eclipse.jst.common.project.facet.core.libprov.user.KeyClassesValidator}
+ * Oracle - initial API and implementation
*******************************************************************************/
-package org.eclipse.jpt.core.internal.utility;
+package org.eclipse.jpt.core.internal.libval;
import static org.eclipse.jst.common.project.facet.core.internal.FacetedProjectFrameworkJavaPlugin.PLUGIN_ID;
import java.io.File;
@@ -19,7 +15,6 @@ import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
@@ -27,37 +22,41 @@ import java.util.zip.ZipFile;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jpt.core.JpaFacet;
import org.eclipse.jpt.core.internal.JptCoreMessages;
-import org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryProviderInstallOperationConfig;
-import org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryValidator;
+import org.eclipse.jpt.core.internal.libprov.JpaUserLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.internal.libprov.JptLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.libval.LibraryValidator;
import org.eclipse.osgi.util.NLS;
-/**
- * This class differs from the original in that it does not give an error if multiple instances of
- * a class are discovered
- */
-public class KeyClassesValidator
- extends UserLibraryValidator
-{
- private final Set<String> classFileNames = new HashSet<String>();
-
- private final Map<String,String> classFileNameToClassName = new HashMap<String,String>();
+public class GenericJpaUserLibraryValidator
+ implements LibraryValidator {
-
- @Override
- public void init(final List<String> params) {
- for (String className : params) {
- String classFileName = className.replace('.', '/') + ".class";
- this.classFileNames.add(classFileName);
- this.classFileNameToClassName.put(classFileName, className);
+ public IStatus validate(JptLibraryProviderInstallOperationConfig config) {
+ JpaUserLibraryProviderInstallOperationConfig jpaConfig
+ = (JpaUserLibraryProviderInstallOperationConfig) config;
+ Set<String> classNames = new HashSet<String>();
+ classNames.add("javax.persistence.Entity");
+ if (config.getProjectFacetVersion().compareTo(JpaFacet.VERSION_2_0) >= 0) {
+ classNames.add("javax.persistence.ElementCollection");
}
+ return validate(jpaConfig, classNames);
}
- @Override
- public IStatus validate( final UserLibraryProviderInstallOperationConfig config ) {
+ protected IStatus validate(
+ JpaUserLibraryProviderInstallOperationConfig config, Set<String> classNames) {
+
+ Set<String> classFileNames = new HashSet<String>();
+ Map<String,String> classFileNameToClassName = new HashMap<String,String>();
+ for (String className : classNames) {
+ String classFileName = className.replace('.', '/') + ".class";
+ classFileNames.add(classFileName);
+ classFileNameToClassName.put(classFileName, className);
+ }
+
final Map<String,Integer> classAppearanceCounts = new HashMap<String,Integer>();
- for (String classFileName : this.classFileNames) {
+ for (String classFileName : classFileNames) {
classAppearanceCounts.put(classFileName, 0);
}
@@ -100,9 +99,9 @@ public class KeyClassesValidator
if (count == 0) {
final String classFileName = entry.getKey();
- final String className = this.classFileNameToClassName.get(classFileName);
+ final String className = classFileNameToClassName.get(classFileName);
final String message =
- NLS.bind(JptCoreMessages.KEY_CLASSES_VALIDATOR__CLASS_NOT_FOUND, className);
+ NLS.bind(JptCoreMessages.USER_LIBRARY_VALIDATOR__CLASS_NOT_FOUND, className);
return new Status(IStatus.ERROR, PLUGIN_ID, message);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/LibraryValidatorConfig.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/LibraryValidatorConfig.java
new file mode 100644
index 0000000000..979becf9ad
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/LibraryValidatorConfig.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.core.internal.libval;
+
+import static org.eclipse.jst.common.project.facet.core.internal.FacetedProjectFrameworkJavaPlugin.log;
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jpt.core.internal.XPointUtil;
+import org.eclipse.jpt.core.internal.libprov.JptLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.libval.LibraryValidator;
+
+public class LibraryValidatorConfig {
+
+ public static final String CONFIG_EXPR_VAR = "config"; //$NON-NLS-1$
+ public static final String LIBRARY_PROVIDER_EXPR_VAR = "libraryProvider"; //$NON-NLS-1$
+
+
+ private String id;
+ private String pluginId;
+ private String className;
+ private Expression enablementCondition;
+
+
+ LibraryValidatorConfig() {
+ super();
+ }
+
+
+ public String getId() {
+ return this.id;
+ }
+
+ void setId(String id) {
+ this.id = id;
+ }
+
+ public String getPluginId() {
+ return this.pluginId;
+ }
+
+ void setPluginId(String pluginId) {
+ this.pluginId = pluginId;
+ }
+
+ public String getClassName() {
+ return this.className;
+ }
+
+ void setClassName(String className) {
+ this.className = className;
+ }
+
+ public Expression getEnablementCondition() {
+ return this.enablementCondition;
+ }
+
+ void setEnablementCondition(Expression enablementCondition) {
+ this.enablementCondition = enablementCondition;
+ }
+
+ public LibraryValidator getLibraryValidator() {
+ return XPointUtil.instantiate(
+ this.pluginId, LibraryValidatorManager.QUALIFIED_EXTENSION_POINT_ID,
+ this.className, LibraryValidator.class);
+ }
+
+ public boolean isEnabledFor(JptLibraryProviderInstallOperationConfig config) {
+ EvaluationContext evalContext = new EvaluationContext(null, config);
+ evalContext.setAllowPluginActivation(true);
+ evalContext.addVariable(CONFIG_EXPR_VAR, config);
+ evalContext.addVariable(LIBRARY_PROVIDER_EXPR_VAR, config.getLibraryProvider());
+
+ if (this.enablementCondition != null) {
+ try {
+ EvaluationResult evalResult = this.enablementCondition.evaluate(evalContext);
+
+ if (evalResult == EvaluationResult.FALSE) {
+ return false;
+ }
+ }
+ catch (CoreException e) {
+ log(e);
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/LibraryValidatorManager.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/LibraryValidatorManager.java
new file mode 100644
index 0000000000..316519df69
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/libval/LibraryValidatorManager.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * 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.core.internal.libval;
+
+import static org.eclipse.jpt.core.internal.XPointUtil.*;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.ExpressionConverter;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jpt.core.JptCorePlugin;
+import org.eclipse.jpt.core.internal.XPointUtil.XPointException;
+import org.eclipse.jpt.core.internal.libprov.JptLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.libval.LibraryValidator;
+import org.eclipse.jpt.utility.internal.KeyedSet;
+import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
+import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
+
+public class LibraryValidatorManager {
+
+ public static final String EXTENSION_POINT_ID = "libraryValidators";
+ public static final String QUALIFIED_EXTENSION_POINT_ID = JptCorePlugin.PLUGIN_ID_ + EXTENSION_POINT_ID;
+ public static final String LIBRARY_VALIDATOR_ELEMENT = "libraryValidator";
+ public static final String ID_ATTRIBUTE = "id";
+ public static final String CLASS_ATTRIBUTE = "class";
+ public static final String ENABLEMENT_ELEMENT = "enablement";
+
+
+ private static LibraryValidatorManager INSTANCE = new LibraryValidatorManager();
+
+
+ public static LibraryValidatorManager instance() {
+ return INSTANCE;
+ }
+
+
+ private KeyedSet<String, LibraryValidatorConfig> libraryValidatorConfigs;
+
+
+ private LibraryValidatorManager() {
+ this.libraryValidatorConfigs = new KeyedSet<String, LibraryValidatorConfig>();
+ readExtensions();
+ }
+
+
+ /**
+ * Return the {@link LibraryValidator}s
+ */
+ public Iterable<LibraryValidator> getLibraryValidators(final JptLibraryProviderInstallOperationConfig config) {
+ return new FilteringIterable<LibraryValidator>(
+ new TransformationIterable<LibraryValidatorConfig, LibraryValidator>(
+ new FilteringIterable<LibraryValidatorConfig>(
+ this.libraryValidatorConfigs.getItemSet()) {
+ @Override
+ protected boolean accept(LibraryValidatorConfig o) {
+ return o.isEnabledFor(config);
+ }
+ }) {
+ @Override
+ protected LibraryValidator transform(LibraryValidatorConfig o) {
+ return o.getLibraryValidator();
+ }
+ }) {
+ @Override
+ protected boolean accept(LibraryValidator o) {
+ return o != null;
+ }
+ };
+ }
+
+ private void readExtensions() {
+ final IExtensionRegistry registry = Platform.getExtensionRegistry();
+
+ final IExtensionPoint xpoint
+ = registry.getExtensionPoint(JptCorePlugin.PLUGIN_ID, EXTENSION_POINT_ID);
+
+ if (xpoint == null) {
+ throw new IllegalStateException();
+ }
+
+ final List<IConfigurationElement> configs = new ArrayList<IConfigurationElement>();
+
+ for (IExtension extension : xpoint.getExtensions()) {
+ for (IConfigurationElement element : extension.getConfigurationElements()) {
+ configs.add(element);
+ }
+ }
+
+ for (IConfigurationElement element : configs) {
+ if (element.getName().equals(LIBRARY_VALIDATOR_ELEMENT)) {
+ readExtension(element);
+ }
+ }
+ }
+
+ private void readExtension(IConfigurationElement element) {
+ try {
+ final LibraryValidatorConfig lvConfig = new LibraryValidatorConfig();
+
+ // plug-in id
+ lvConfig.setPluginId(element.getContributor().getName());
+
+ // resource locator id
+ lvConfig.setId(findRequiredAttribute(element, ID_ATTRIBUTE));
+
+ if (this.libraryValidatorConfigs.containsKey(lvConfig.getId())) {
+ logDuplicateExtension(QUALIFIED_EXTENSION_POINT_ID, lvConfig.getId());
+ throw new XPointException();
+ }
+
+ // resource locator class name
+ lvConfig.setClassName(findRequiredAttribute(element, CLASS_ATTRIBUTE));
+
+ // enablement
+ for (IConfigurationElement child : element.getChildren()) {
+ String childName = child.getName();
+ if (childName.equals(ENABLEMENT_ELEMENT)) {
+ Expression expr;
+ try {
+ expr = ExpressionConverter.getDefault().perform(child);
+ }
+ catch (CoreException e) {
+ log(e);
+ throw new XPointException();
+ }
+ lvConfig.setEnablementCondition(expr);
+ }
+ }
+
+ this.libraryValidatorConfigs.addItem(lvConfig.getId(), lvConfig);
+ }
+ catch (XPointException e) {
+ // Ignore and continue. The problem has already been reported to the user
+ // in the log.
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/libval/LibraryValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/libval/LibraryValidator.java
new file mode 100644
index 0000000000..c9a0f84ad5
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/libval/LibraryValidator.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.core.libval;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jpt.core.internal.libprov.JptLibraryProviderInstallOperationConfig;
+
+/**
+ * Interface for extender-supplied library validators.
+ * Each library validator must have a zero-arg constructor.
+ *
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.0
+ * @since 3.0
+ */
+public interface LibraryValidator {
+
+ IStatus validate(JptLibraryProviderInstallOperationConfig config);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF
index 54a3576708..fa5888a824 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF
@@ -21,6 +21,7 @@ Require-Bundle: org.eclipse.core.commands;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jpt.db;bundle-version="[1.2.0,2.0.0)",
org.eclipse.jpt.utility;bundle-version="[1.2.0,2.0.0)",
org.eclipse.jst.common.project.facet.core;bundle-version="[1.3.100,2.0.0)",
+ org.eclipse.jst.j2ee;bundle-version="1.1.402",
org.eclipse.text;bundle-version="[3.5.0,4.0.0)",
org.eclipse.wst.common.emf;bundle-version="[1.1.200,2.0.0)",
org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.1.200,2.0.0)",
@@ -53,12 +54,12 @@ Export-Package: org.eclipse.jpt.eclipselink.core,
org.eclipse.jpt.eclipselink.core.internal.context.persistence.options;x-internal:=true,
org.eclipse.jpt.eclipselink.core.internal.context.persistence.schema.generation;x-internal:=true,
org.eclipse.jpt.eclipselink.core.internal.ddlgen;x-internal:=true,
+ org.eclipse.jpt.eclipselink.core.internal.libval,
org.eclipse.jpt.eclipselink.core.internal.operations;x-internal:=true,
org.eclipse.jpt.eclipselink.core.internal.resource.java;x-internal:=true,
org.eclipse.jpt.eclipselink.core.internal.resource.java.binary;x-internal:=true,
org.eclipse.jpt.eclipselink.core.internal.resource.java.source;x-internal:=true,
org.eclipse.jpt.eclipselink.core.internal.resource.orm;x-internal:=true,
- org.eclipse.jpt.eclipselink.core.internal.utility;x-internal:=true,
org.eclipse.jpt.eclipselink.core.internal.v1_1;x-internal:=true,
org.eclipse.jpt.eclipselink.core.internal.v1_1.context;x-internal:=true,
org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm;x-internal:=true,
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml
index 7a39f465e7..71ae59f55e 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml
@@ -73,8 +73,43 @@
jpaFacetVersion="2.0"/>
</extension>
-
-
+
+
+ <extension
+ point="org.eclipse.jpt.core.libraryValidators">
+
+ <libraryValidator
+ id="eclipselinkLibraryValidator"
+ class="org.eclipse.jpt.eclipselink.core.internal.libval.EclipseLinkUserLibraryValidator">
+ <enablement>
+ <and>
+ <with variable="libraryProvider">
+ <test property="org.eclipse.jpt.core.extendsId" value="jpa-user-library-provider"/>
+ </with>
+ <with variable="config">
+ <test property="org.eclipse.jpt.core.jpaPlatformGroup" value="eclipselink"/>
+ </with>
+ </and>
+ </enablement>
+ </libraryValidator>
+
+ <libraryValidator
+ id="eclipselinkEclipselinkBundlesLibraryValidator"
+ class="org.eclipse.jpt.eclipselink.core.internal.libval.EclipseLinkEclipseLinkBundlesLibraryValidator">
+ <enablement>
+ <and>
+ <with variable="libraryProvider">
+ <test property="org.eclipse.jpt.core.extendsId" value="eclipselink-bundles-library-provider"/>
+ </with>
+ <with variable="config">
+ <test property="org.eclipse.jpt.core.jpaPlatformGroup" value="eclipselink"/>
+ </with>
+ </and>
+ </enablement>
+ </libraryValidator>
+
+ </extension>
+
<!--
******************************************
@@ -104,136 +139,32 @@
<provider
id="jpa-eclipselink1_0-user-library-provider"
- extends="jpa-user-library-provider">
- <param name="validator" value="org.eclipse.jpt.eclipselink.core.internal.utility.EclipseLinkLibraryValidator"/>
- <param name="validator.param.0" value="version-range:[1.0, 3.0)"/>
- <param name="validator.param.1" value="key-class:javax.persistence.Entity"/>
- <enablement>
- <with variable="jpaPlatform">
- <equals value="org.eclipse.eclipselink.platform"/>
- </with>
- </enablement>
- </provider>
-
- <provider
- id="jpa-eclipselink1_0-wtp-user-library-provider"
- extends="jpa-wtp-user-library-provider">
- <param name="validator" value="org.eclipse.jpt.eclipselink.core.internal.utility.EclipseLinkLibraryValidator"/>
- <param name="validator.param.0" value="version-range:[1.0, 3.0)"/>
- <param name="validator.param.1" value="key-class:javax.persistence.Entity"/>
- <enablement>
- <with variable="jpaPlatform">
- <equals value="org.eclipse.eclipselink.platform"/>
- </with>
- </enablement>
+ extends="jpa-deprecated-user-library-provider"
+ hidden="true">
</provider>
<provider
id="jpa-eclipselink1_1-user-library-provider"
- extends="jpa-user-library-provider">
- <param name="validator" value="org.eclipse.jpt.eclipselink.core.internal.utility.EclipseLinkLibraryValidator"/>
- <param name="validator.param.0" value="version-range:[1.1, 3.0)"/>
- <param name="validator.param.1" value="key-class:javax.persistence.Entity"/>
- <enablement>
- <with variable="jpaPlatform">
- <equals value="eclipselink1_1"/>
- </with>
- </enablement>
- </provider>
-
- <provider
- id="jpa-eclipselink1_1-wtp-user-library-provider"
- extends="jpa-wtp-user-library-provider">
- <param name="validator" value="org.eclipse.jpt.eclipselink.core.internal.utility.EclipseLinkLibraryValidator"/>
- <param name="validator.param.0" value="version-range:[1.1, 3.0)"/>
- <param name="validator.param.1" value="key-class:javax.persistence.Entity"/>
- <enablement>
- <with variable="jpaPlatform">
- <equals value="eclipselink1_1"/>
- </with>
- </enablement>
+ extends="jpa-deprecated-user-library-provider"
+ hidden="true">
</provider>
<provider
id="jpa-eclipselink1_2-user-library-provider"
- extends="jpa-user-library-provider">
- <param name="validator" value="org.eclipse.jpt.eclipselink.core.internal.utility.EclipseLinkLibraryValidator"/>
- <param name="validator.param.0" value="version-range:[1.2, 3.0)"/>
- <param name="validator.param.1" value="key-class:javax.persistence.Entity"/>
- <enablement>
- <with variable="jpaPlatform">
- <equals value="eclipselink1_2"/>
- </with>
- </enablement>
- </provider>
-
- <provider
- id="jpa-eclipselink1_2-wtp-user-library-provider"
- extends="jpa-wtp-user-library-provider">
- <param name="validator" value="org.eclipse.jpt.eclipselink.core.internal.utility.EclipseLinkLibraryValidator"/>
- <param name="validator.param.0" value="version-range:[1.2, 3.0)"/>
- <param name="validator.param.1" value="key-class:javax.persistence.Entity"/>
- <enablement>
- <with variable="jpaPlatform">
- <equals value="eclipselink1_2"/>
- </with>
- </enablement>
+ extends="jpa-deprecated-user-library-provider"
+ hidden="true">
</provider>
<provider
id="eclipselink2_0-user-library-provider"
- extends="jpa-user-library-provider">
- <param name="validator" value="org.eclipse.jpt.eclipselink.core.internal.utility.EclipseLinkLibraryValidator"/>
- <param name="validator.param.0" value="version-range:[2.0, 3.0)"/>
- <param name="validator.param.1" value="key-class:javax.persistence.Entity"/>
- <param name="validator.param.2" value="key-class:javax.persistence.ElementCollection"/>
- <enablement>
- <with variable="jpaPlatform">
- <equals value="eclipselink2_0"/>
- </with>
- </enablement>
- </provider>
-
- <provider
- id="eclipselink2_0-wtp-user-library-provider"
- extends="jpa-wtp-user-library-provider">
- <param name="validator" value="org.eclipse.jpt.eclipselink.core.internal.utility.EclipseLinkLibraryValidator"/>
- <param name="validator.param.0" value="version-range:[2.0, 3.0)"/>
- <param name="validator.param.1" value="key-class:javax.persistence.Entity"/>
- <param name="validator.param.2" value="key-class:javax.persistence.ElementCollection"/>
- <enablement>
- <with variable="jpaPlatform">
- <equals value="eclipselink2_0"/>
- </with>
- </enablement>
+ extends="jpa-deprecated-user-library-provider"
+ hidden="true">
</provider>
<provider
id="jpa-eclipselink2_1-user-library-provider"
- extends="jpa-user-library-provider">
- <param name="validator" value="org.eclipse.jpt.eclipselink.core.internal.utility.EclipseLinkLibraryValidator"/>
- <param name="validator.param.0" value="version-range:[2.1, 3.0)"/>
- <param name="validator.param.1" value="key-class:javax.persistence.Entity"/>
- <param name="validator.param.2" value="key-class:javax.persistence.ElementCollection"/>
- <enablement>
- <with variable="jpaPlatform">
- <equals value="eclipselink2_1"/>
- </with>
- </enablement>
- </provider>
-
- <provider
- id="jpa-eclipselink2_1-wtp-user-library-provider"
- extends="jpa-wtp-user-library-provider">
- <param name="validator" value="org.eclipse.jpt.eclipselink.core.internal.utility.EclipseLinkLibraryValidator"/>
- <param name="validator.param.0" value="version-range:[2.1, 3.0)"/>
- <param name="validator.param.1" value="key-class:javax.persistence.Entity"/>
- <param name="validator.param.2" value="key-class:javax.persistence.ElementCollection"/>
- <enablement>
- <with variable="jpaPlatform">
- <equals value="eclipselink2_1"/>
- </with>
- </enablement>
+ extends="jpa-deprecated-user-library-provider"
+ hidden="true">
</provider>
</extension>
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/jpt_eclipselink_core.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/jpt_eclipselink_core.properties
index 778ab9c664..a0173b3f3b 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/jpt_eclipselink_core.properties
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/jpt_eclipselink_core.properties
@@ -8,7 +8,6 @@
# Oracle - initial API and implementation
################################################################################
-EclipseLinkLibraryValidator_invalidJpaLibrary=Selected libraries do not include all required JPA annotation classes.
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.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/JptEclipseLinkCoreMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/JptEclipseLinkCoreMessages.java
index 8ebda63495..38e7fd39bf 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/JptEclipseLinkCoreMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/JptEclipseLinkCoreMessages.java
@@ -17,7 +17,6 @@ import org.eclipse.osgi.util.NLS;
*/
public class JptEclipseLinkCoreMessages
{
- public static String EclipseLinkLibraryValidator_invalidJpaLibrary;
public static String EclipseLinkLibraryValidator_noEclipseLinkVersion;
public static String EclipseLinkLibraryValidator_multipleEclipseLinkVersions;
public static String EclipseLinkLibraryValidator_improperEclipseLinkVersion;
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/libval/EclipseLinkEclipseLinkBundlesLibraryValidator.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/libval/EclipseLinkEclipseLinkBundlesLibraryValidator.java
new file mode 100644
index 0000000000..d80bf2ea79
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/libval/EclipseLinkEclipseLinkBundlesLibraryValidator.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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.eclipselink.core.internal.libval;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jpt.core.internal.libprov.JpaOsgiBundlesLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.internal.libprov.JptLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.internal.libval.AbstractOsgiBundlesLibraryValidator;
+import org.eclipse.jpt.core.platform.JpaPlatformDescription;
+import org.eclipse.jpt.eclipselink.core.platform.EclipseLinkPlatform;
+import org.eclipse.osgi.service.resolver.VersionRange;
+
+public class EclipseLinkEclipseLinkBundlesLibraryValidator
+ extends AbstractOsgiBundlesLibraryValidator {
+
+ public IStatus validate(JptLibraryProviderInstallOperationConfig config) {
+ JpaOsgiBundlesLibraryProviderInstallOperationConfig jpaConfig
+ = (JpaOsgiBundlesLibraryProviderInstallOperationConfig) config;
+ Map<String, VersionRange[]> bundleVersionRanges = new HashMap<String, VersionRange[]>();
+ JpaPlatformDescription platform = jpaConfig.getJpaPlatform();
+ if (EclipseLinkPlatform.VERSION_1_0.equals(platform)) {
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.core",
+ new VersionRange[] {new VersionRange("[1.0, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.jpa",
+ new VersionRange[] {new VersionRange("[1.0, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.asm",
+ new VersionRange[] {new VersionRange("[1.0, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.antlr",
+ new VersionRange[] {new VersionRange("[1.0, 3.0)")});
+ }
+ else if (EclipseLinkPlatform.VERSION_1_1.equals(platform)) {
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.core",
+ new VersionRange[] {new VersionRange("[1.1, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.jpa",
+ new VersionRange[] {new VersionRange("[1.1, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.asm",
+ new VersionRange[] {new VersionRange("[1.1, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.antlr",
+ new VersionRange[] {new VersionRange("[1.1, 3.0)")});
+ }
+ else if (EclipseLinkPlatform.VERSION_1_2.equals(platform)) {
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.core",
+ new VersionRange[] {new VersionRange("[1.2, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.jpa",
+ new VersionRange[] {new VersionRange("[1.2, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.asm",
+ new VersionRange[] {new VersionRange("[1.2, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.antlr",
+ new VersionRange[] {new VersionRange("[1.2, 3.0)")});
+ }
+ else if (EclipseLinkPlatform.VERSION_2_0.equals(platform)) {
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.core",
+ new VersionRange[] {new VersionRange("[2.0, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.jpa",
+ new VersionRange[] {new VersionRange("[2.0, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.asm",
+ new VersionRange[] {new VersionRange("[2.0, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.antlr",
+ new VersionRange[] {new VersionRange("[2.0, 3.0)")});
+ }
+ else if (EclipseLinkPlatform.VERSION_2_1.equals(platform)) {
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.core",
+ new VersionRange[] {new VersionRange("[2.1, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.jpa",
+ new VersionRange[] {new VersionRange("[2.1, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.asm",
+ new VersionRange[] {new VersionRange("[2.1, 3.0)")});
+ bundleVersionRanges.put(
+ "org.eclipse.persistence.antlr",
+ new VersionRange[] {new VersionRange("[2.1, 3.0)")});
+ }
+ return validate(jpaConfig, bundleVersionRanges);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/libval/EclipseLinkUserLibraryValidator.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/libval/EclipseLinkUserLibraryValidator.java
new file mode 100644
index 0000000000..ba0859952f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/libval/EclipseLinkUserLibraryValidator.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * 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.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.core.internal.libprov.JpaUserLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.internal.libprov.JptLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.core.libval.LibraryValidator;
+import org.eclipse.jpt.core.platform.JpaPlatformDescription;
+import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCoreMessages;
+import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin;
+import org.eclipse.jpt.eclipselink.core.platform.EclipseLinkPlatform;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.osgi.framework.Version;
+
+/**
+ * Library validator for EclipseLink user libraries.
+ *
+ * In order to validate that the correct eclipselink.jar is present in the user library, the version
+ * class which appears in standard EclipseLink libraries will be examined and compared against the
+ * union of calculated version ranges, depending on the platform specified in the config.
+ */
+public class EclipseLinkUserLibraryValidator
+ implements LibraryValidator {
+
+ private final static String VERSION_CLASS_PATH = "org/eclipse/persistence/Version.class";
+
+ private final static String VERSION_FIELD_NAME = "version";
+
+
+ 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)"));
+ }
+ else if (EclipseLinkPlatform.VERSION_1_1.equals(platform)) {
+ versionRanges.add(new VersionRange("[1.1, 3.0)"));
+ }
+ else if (EclipseLinkPlatform.VERSION_1_2.equals(platform)) {
+ versionRanges.add(new VersionRange("[1.2, 3.0)"));
+ }
+ else if (EclipseLinkPlatform.VERSION_2_0.equals(platform)) {
+ versionRanges.add(new VersionRange("[2.0, 3.0)"));
+ }
+ else if (EclipseLinkPlatform.VERSION_2_1.equals(platform)) {
+ versionRanges.add(new VersionRange("[2.1, 3.0)"));
+ }
+ 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, JptEclipseLinkCorePlugin.PLUGIN_ID,
+ JptEclipseLinkCoreMessages.EclipseLinkLibraryValidator_multipleEclipseLinkVersions);
+ }
+ else {
+ version = new Version(versionString);
+ }
+ }
+ }
+ }
+
+ if (version == null) {
+ return new Status(
+ IStatus.ERROR, JptEclipseLinkCorePlugin.PLUGIN_ID,
+ JptEclipseLinkCoreMessages.EclipseLinkLibraryValidator_noEclipseLinkVersion);
+ }
+
+ for (VersionRange versionRange : versionRanges) {
+ if (! versionRange.isIncluded(version)) {
+ return new Status(
+ IStatus.ERROR, JptEclipseLinkCorePlugin.PLUGIN_ID,
+ JptEclipseLinkCoreMessages.EclipseLinkLibraryValidator_improperEclipseLinkVersion);
+ }
+ }
+
+ return Status.OK_STATUS;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/utility/EclipseLinkLibraryValidator.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/utility/EclipseLinkLibraryValidator.java
deleted file mode 100644
index 9f4ac41c33..0000000000
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/utility/EclipseLinkLibraryValidator.java
+++ /dev/null
@@ -1,141 +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.eclipselink.core.internal.utility;
-
-import java.util.ArrayList;
-import java.util.List;
-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.core.internal.utility.KeyClassesValidator;
-import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCoreMessages;
-import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryProviderInstallOperationConfig;
-import org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryValidator;
-import org.eclipse.osgi.service.resolver.VersionRange;
-import org.osgi.framework.Version;
-
-/**
- * Library validator for EclipseLink user libraries.
- *
- * This has two facets:
- * - eclipselink version: In order to validate that the correct eclipselink.jar is present in the
- * user library, the extension using this should specify none or more version ranges using a
- * standard library provider param expression, but with the prefix "version-range". The actual
- * version of the eclipselink build will be checked against the union of these version ranges.
- * (e.g. <param name="validator.param.0" value="version-range:[2.0, 3.0)"/> )
- * - jpa key classes: In order to validate that the correct jpa.jar is present in the user
- * library (since version of that jar is impossible to check,) the extension using this should
- * specify none or more key classes using a standard library provider param expression, but
- * with the prefix "key-class". The user library will check that all specified key classes
- * are present.
- * (e.g. <param name="validator.param.1" value="key-class:javax.persistence.Entity"/> )
- */
-public class EclipseLinkLibraryValidator
- extends UserLibraryValidator
-{
- private final static String VERSION_CLASS_PATH = "org/eclipse/persistence/Version.class";
-
- private final static String VERSION_FIELD_NAME = "version";
-
- private final static String VERSION_RANGE_PREFIX = "version-range:";
-
- private final static String KEY_CLASS_PREFIX = "key-class:";
-
- private final List<VersionRange> versionRanges = new ArrayList<VersionRange>();
-
- private final List<String> keyClasses = new ArrayList<String>();
-
-
- private final KeyClassesValidator keyClassesValidator = new KeyClassesValidator();
-
-
- public EclipseLinkLibraryValidator() {
- super();
- }
-
-
- @Override
- public void init(final List<String> params) {
- for (String param : params) {
- if (param.startsWith(VERSION_RANGE_PREFIX)) {
- versionRanges.add(new VersionRange(param.replaceFirst(VERSION_RANGE_PREFIX, "")));
- }
- else if (param.startsWith(KEY_CLASS_PREFIX)) {
- keyClasses.add(param.replaceFirst(KEY_CLASS_PREFIX, ""));
- }
- }
- this.keyClassesValidator.init(this.keyClasses);
- }
-
- @Override
- public IStatus validate(UserLibraryProviderInstallOperationConfig config) {
- if (! this.keyClassesValidator.validate(config).isOK()) {
- return new Status(
- IStatus.ERROR, JptEclipseLinkCorePlugin.PLUGIN_ID,
- JptEclipseLinkCoreMessages.EclipseLinkLibraryValidator_invalidJpaLibrary);
- }
-
- 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, JptEclipseLinkCorePlugin.PLUGIN_ID,
- JptEclipseLinkCoreMessages.EclipseLinkLibraryValidator_multipleEclipseLinkVersions);
- }
- else {
- version = new Version(versionString);
- }
- }
- }
- }
-
- if (version == null) {
- return new Status(
- IStatus.ERROR, JptEclipseLinkCorePlugin.PLUGIN_ID,
- JptEclipseLinkCoreMessages.EclipseLinkLibraryValidator_noEclipseLinkVersion);
- }
-
- for (VersionRange versionRange : this.versionRanges) {
- if (! versionRange.isIncluded(version)) {
- return new Status(
- IStatus.ERROR, JptEclipseLinkCorePlugin.PLUGIN_ID,
- JptEclipseLinkCoreMessages.EclipseLinkLibraryValidator_improperEclipseLinkVersion);
- }
- }
-
- return Status.OK_STATUS;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java
index 32e6636bba..3a8e42d084 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java
@@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
+import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
@@ -44,7 +44,7 @@ import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.JpaProjectManager;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.internal.JptCoreMessages;
-import org.eclipse.jpt.core.internal.facet.JpaLibraryProviderConstants;
+import org.eclipse.jpt.core.internal.libprov.JpaLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.core.jpa2.JpaProject2_0;
import org.eclipse.jpt.core.platform.JpaPlatformDescription;
import org.eclipse.jpt.db.Catalog;
@@ -100,7 +100,10 @@ import org.eclipse.jpt.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.utility.model.value.ListValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
+import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener;
import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
import org.eclipse.jst.common.project.facet.ui.libprov.LibraryFacetPropertyPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -227,9 +230,7 @@ public class JpaProjectPropertiesPage
if ( ! this.getControl().isDisposed()) {
// handle null, in the case the jpa facet is changed via the facets page,
// the library install delegate is temporarily null
- if (getLibraryInstallDelegate() != null) {
- getLibraryInstallDelegate().setEnablementContextVariable(JpaLibraryProviderConstants.EXPR_VAR_JPA_PLATFORM, newPlatformId);
- }
+ adjustLibraryProviders();
}
}
@@ -411,18 +412,53 @@ public class JpaProjectPropertiesPage
@Override
protected LibraryInstallDelegate createLibraryInstallDelegate(IFacetedProject project, IProjectFacetVersion fv) {
- Map<String, Object> enablementVariables = new HashMap<String, Object>();
- enablementVariables.put(JpaLibraryProviderConstants.EXPR_VAR_JPA_PLATFORM, ""); //$NON-NLS-1$
- return new LibraryInstallDelegate(project, fv, enablementVariables);
+ LibraryInstallDelegate lid = new LibraryInstallDelegate(project, fv, null);
+ lid.addListener(buildLibraryProviderListener());
+ return lid;
}
-
-
+
+ protected IPropertyChangeListener buildLibraryProviderListener() {
+ return new IPropertyChangeListener() {
+ public void propertyChanged(String property, Object oldValue, Object newValue ) {
+ if (LibraryInstallDelegate.PROP_AVAILABLE_PROVIDERS.equals(property)) {
+ adjustLibraryProviders();
+ }
+ }
+ };
+ }
+
+ protected void adjustLibraryProviders() {
+ LibraryInstallDelegate lid = this.getLibraryInstallDelegate();
+ if (lid != null) {
+ List<JpaLibraryProviderInstallOperationConfig> jpaConfigs
+ = new ArrayList<JpaLibraryProviderInstallOperationConfig>();
+ // add the currently selected one first
+ JpaLibraryProviderInstallOperationConfig currentJpaConfig = null;
+ LibraryProviderOperationConfig config = lid.getLibraryProviderOperationConfig();
+ if (config instanceof JpaLibraryProviderInstallOperationConfig) {
+ currentJpaConfig = (JpaLibraryProviderInstallOperationConfig) config;
+ jpaConfigs.add(currentJpaConfig);
+ }
+ for (ILibraryProvider lp : lid.getLibraryProviders()) {
+ config = lid.getLibraryProviderOperationConfig(lp);
+ if (config instanceof JpaLibraryProviderInstallOperationConfig
+ && ! config.equals(currentJpaConfig)) {
+ jpaConfigs.add((JpaLibraryProviderInstallOperationConfig) config);
+ }
+ }
+ for (JpaLibraryProviderInstallOperationConfig jpaConfig : jpaConfigs) {
+ jpaConfig.setJpaPlatform(JptCorePlugin.getJpaPlatformManager().getJpaPlatform(this.platformIdModel.getValue()));
+ }
+ }
+ }
+
+
// ********** page **********
@Override
protected Control createPageContents(Composite parent) {
this.projectModel.setValue(this.getProject());
-
+
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
@@ -444,7 +480,8 @@ public class JpaProjectPropertiesPage
Dialog.applyDialogFont(composite);
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, JpaHelpContextIds.PROPERTIES_JAVA_PERSISTENCE);
-
+
+ adjustLibraryProviders();
this.updateValidation();
return composite;
@@ -938,15 +975,14 @@ public class JpaProjectPropertiesPage
statuses.put(WARNING_STATUS, new ArrayList<IStatus>());
statuses.put(INFO_STATUS, new ArrayList<IStatus>());
statuses.put(OK_STATUS, CollectionTools.list(Status.OK_STATUS));
-
+
/* platform */
// user is unable to unset the platform, so no validation necessary
-
+
/* library provider */
- IStatus lpStatus = validateLibraryProvider();
+ IStatus lpStatus = super.performValidation();
statuses.get(Integer.valueOf(lpStatus.getSeverity())).add(lpStatus);
-
/* connection */
ConnectionProfile connectionProfile = this.getConnectionProfile();
String connectionName = this.getConnectionName();
@@ -1008,18 +1044,6 @@ public class JpaProjectPropertiesPage
}
}
- private IStatus validateLibraryProvider() {
- Map<String, Object> enablementVariables = new HashMap<String, Object>();
- enablementVariables.put(JpaLibraryProviderConstants.EXPR_VAR_JPA_PLATFORM, this.platformIdModel.getValue()); //$NON-NLS-1$
-
- if (! getLibraryInstallDelegate().getLibraryProvider().isEnabledFor(
- getFacetedProject(), getProjectFacetVersion(), enablementVariables)) {
- return buildErrorStatus(JptCoreMessages.VALIDATE_LIBRARY_PROVIDER_INVALID);
- }
-
- return super.performValidation();
- }
-
private IStatus buildInfoStatus(String message) {
return this.buildStatus(IStatus.INFO, message);
}

Back to the top