diff options
author | pfullbright | 2010-08-16 17:42:13 +0000 |
---|---|---|
committer | pfullbright | 2010-08-16 17:42:13 +0000 |
commit | 08101996b6d1bf7de7aa210990eefde9548f896d (patch) | |
tree | 742d36bc8d8fec28e2190a18edb9f36c99dd2596 | |
parent | e80da5d1385f126d11c6838e26fb74ab61d5bc95 (diff) | |
download | webtools.dali-08101996b6d1bf7de7aa210990eefde9548f896d.tar.gz webtools.dali-08101996b6d1bf7de7aa210990eefde9548f896d.tar.xz webtools.dali-08101996b6d1bf7de7aa210990eefde9548f896d.zip |
refactored jpaPlatforms extension point, added jpaPlatformGroup
45 files changed, 892 insertions, 457 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 6a2ec18e7b..509ff83cf5 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,7 @@ Export-Package: org.eclipse.jpt.core, 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.operations;x-internal:=true, + org.eclipse.jpt.core.internal.platform, org.eclipse.jpt.core.internal.prefs;x-internal:=true, org.eclipse.jpt.core.internal.refactoring;x-internal:=true, org.eclipse.jpt.core.internal.resource;x-internal:=true, @@ -87,6 +88,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.platform, org.eclipse.jpt.core.resource, org.eclipse.jpt.core.resource.java, org.eclipse.jpt.core.resource.orm, diff --git a/jpa/plugins/org.eclipse.jpt.core/plugin.properties b/jpa/plugins/org.eclipse.jpt.core/plugin.properties index f6bc34fe77..9f9e846f07 100644 --- a/jpa/plugins/org.eclipse.jpt.core/plugin.properties +++ b/jpa/plugins/org.eclipse.jpt.core/plugin.properties @@ -34,6 +34,7 @@ MAPPING_FILE_CONTENT = Base content for JPA XML mapping files ORM_XML_CONTENT = JPA orm.xml mapping files JAR_CONTENT = JAR Content +GENERIC_PLATFORM_GROUP_LABEL=Generic GENERIC_1_0_PLATFORM_LABEL=Generic 1.0 GENERIC_2_0_PLATFORM_LABEL=Generic 2.0 diff --git a/jpa/plugins/org.eclipse.jpt.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.core/plugin.xml index 4c9e5c0add..642672550e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/plugin.xml +++ b/jpa/plugins/org.eclipse.jpt.core/plugin.xml @@ -101,14 +101,14 @@ id="org.eclipse.jpt.core.propertyTester.platformResource" type="org.eclipse.core.resources.IResource" namespace="org.eclipse.jpt.core" - properties="jpaPlatform" + properties="jpaPlatform, jpaPlatformGroup" class="org.eclipse.jpt.core.internal.JpaPlatformTester"/> <propertyTester id="org.eclipse.jpt.core.propertyTester.javaElement" type="org.eclipse.jdt.core.IJavaElement" namespace="org.eclipse.jpt.core" - properties="jpaPlatform" + properties="jpaPlatform, jpaPlatformGroup" class="org.eclipse.jpt.core.internal.JpaPlatformTester"/> <propertyTester @@ -179,21 +179,25 @@ <extension point="org.eclipse.jpt.core.jpaPlatforms"> + <jpaPlatformGroup + id="generic" + label="%GENERIC_PLATFORM_GROUP_LABEL"/> + <jpaPlatform id="generic" label="%GENERIC_1_0_PLATFORM_LABEL" factoryClass="org.eclipse.jpt.core.internal.GenericJpaPlatformFactory" + group="generic" jpaFacetVersion="1.0" - default="false"> - </jpaPlatform> + default="false"/> <jpaPlatform id="generic2_0" label="%GENERIC_2_0_PLATFORM_LABEL" factoryClass="org.eclipse.jpt.core.internal.jpa2.Generic2_0JpaPlatformFactory" + group="generic" jpaFacetVersion="2.0" - default="false"> - </jpaPlatform> + default="false"/> </extension> @@ -592,20 +596,20 @@ <project-facet-version facet="jpt.jpa" version="1.0"> <constraint> - <requires facet="jst.java" version="[5.0"/> + <requires facet="java" version="[5.0"/> </constraint> </project-facet-version> <project-facet-version facet="jpt.jpa" version="2.0"> <constraint> - <requires facet="jst.java" version="[5.0"/> + <requires facet="java" version="[5.0"/> </constraint> </project-facet-version> <template id="jpt.jpa.se.template"> <label>%JPA_SE_TEMPLATE_LABEL</label> <fixed facet="jpt.jpa"/> - <fixed facet="jst.java"/> + <fixed facet="java"/> <!-- <preset id="jpt.jpa.2_0.preset"/> --> @@ -614,7 +618,7 @@ <template id="jpt.jpa.ee.template"> <label>%JPA_EE_TEMPLATE_LABEL</label> <fixed facet="jpt.jpa"/> - <fixed facet="jst.java"/> + <fixed facet="java"/> <fixed facet="jst.utility"/> <!-- <preset id="jpt.jpa.2_0.preset"/> @@ -661,26 +665,26 @@ <static-preset id="jpt.jpa.1_0.se.preset"> <label>%JPA_1.0_SE_PRESET_LABEL</label> - <facet id="jst.java" version="5.0"/> + <facet id="java" version="5.0"/> <facet id="jpt.jpa" version="1.0"/> </static-preset> <static-preset id="jpt.jpa.1_0.ee.preset"> <label>%JPA_1.0_EE_PRESET_LABEL</label> - <facet id="jst.java" version="5.0"/> + <facet id="java" version="5.0"/> <facet id="jst.utility" version="1.0"/> <facet id="jpt.jpa" version="1.0"/> </static-preset> <static-preset id="jpt.jpa.2_0.se.preset"> <label>%JPA_2.0_SE_PRESET_LABEL</label> - <facet id="jst.java" version="6.0"/> + <facet id="java" version="6.0"/> <facet id="jpt.jpa" version="2.0"/> </static-preset> <static-preset id="jpt.jpa.2_0.ee.preset"> <label>%JPA_2.0_EE_PRESET_LABEL</label> - <facet id="jst.java" version="6.0"/> + <facet id="java" version="6.0"/> <facet id="jst.utility" version="1.0"/> <facet id="jpt.jpa" version="2.0"/> </static-preset> diff --git a/jpa/plugins/org.eclipse.jpt.core/schema/jpaPlatforms.exsd b/jpa/plugins/org.eclipse.jpt.core/schema/jpaPlatforms.exsd index 1923aa80b3..e2325913a2 100644 --- a/jpa/plugins/org.eclipse.jpt.core/schema/jpaPlatforms.exsd +++ b/jpa/plugins/org.eclipse.jpt.core/schema/jpaPlatforms.exsd @@ -6,7 +6,7 @@ <meta.schema plugin="org.eclipse.jpt.core" id="jpaPlatforms" name="JPA Platforms"/> </appInfo> <documentation> - Used to add JPA platforms as choices when configuring a project with the JPA facet. The optional "jpaFacetVersion" attribute is used to tie a platform to a particular JPA facet version (if not present, the platform is available for all facet versions.) The optional "default" attribute is used to determine if a platform should have a higher priority when calculating the default platform for a project. + Defines JPA platforms and JPA platform groups. </documentation> </annotation> @@ -17,9 +17,10 @@ </appInfo> </annotation> <complexType> - <sequence> - <element ref="jpaPlatform" minOccurs="1" maxOccurs="unbounded"/> - </sequence> + <choice minOccurs="0" maxOccurs="unbounded"> + <element ref="jpaPlatformGroup"/> + <element ref="jpaPlatform"/> + </choice> <attribute name="point" type="string" use="required"> <annotation> <documentation> @@ -47,10 +48,37 @@ </complexType> </element> + <element name="jpaPlatformGroup"> + <annotation> + <documentation> + Declares a JPA platform group. Acts as a sort of "super" platform. Most useful for enabling functionality for a set of platforms without having to enable the functionality for each platform separately. + </documentation> + </annotation> + <complexType> + <attribute name="id" type="string" use="required"> + <annotation> + <documentation> + The unique identifier for a JPA platform group. + </documentation> + </annotation> + </attribute> + <attribute name="label" type="string" use="required"> + <annotation> + <documentation> + A translatable string representation of the JPA platform group. + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + <element name="jpaPlatform"> <annotation> <documentation> - Declares a JPA platform, one jpaPlatform will be chosen per JpaProject. See <samp>org.eclipse.jpt.core.JpaPlatform</samp> for more information on JPA platforms. Also see the org.eclipse.jpt.ui.jpaPlatforms extension point. + Declares a JPA platform. One JPA platform will be selected per JPA-faceted project. See <samp>org.eclipse.jpt.core.JpaPlatform</samp> for more information on JPA platforms. Also see the org.eclipse.jpt.ui.jpaPlatforms extension point. </documentation> </annotation> <complexType> @@ -81,6 +109,13 @@ </appInfo> </annotation> </attribute> + <attribute name="group" type="string"> + <annotation> + <documentation> + Declares which JPA platform group this platform belongs to, if any. + </documentation> + </annotation> + </attribute> <attribute name="jpaFacetVersion" type="string"> <annotation> <documentation> @@ -103,7 +138,7 @@ <meta.section type="since"/> </appInfo> <documentation> - 2.2 + JPT 1.0 </documentation> </annotation> @@ -112,16 +147,25 @@ <meta.section type="examples"/> </appInfo> <documentation> - The following example shows a basic JPA platform which should be considered a prominent platform for JPA 1.0 - + <br> +<p> +The following example is the included generic JPA 1.0 platform and its platform group +<p> +<pre> <extension point="org.eclipse.jpt.core.jpaPlatforms"> + + <jpaPlatformGroup + id="myJpaPlatformGroup" + label="My JPA Platform"/> + <jpaPlatform - id="myJpaPlatform" - label="My JPA Platform" - factoryClass="org.foo.MyJpaPlatformFactory" + id="generic" + label="%GENERIC_1_0_PLATFORM_LABEL" + factoryClass="org.eclipse.jpt.core.internal.GenericJpaPlatformFactory" jpaFacetVersion="1.0" - default="true"> + default="false"> </jpaPlatform> + </extension> </documentation> </annotation> @@ -153,7 +197,7 @@ will almost certainly be broken (repeatedly) as the API evolves. <meta.section type="copyright"/> </appInfo> <documentation> - Copyright (c) 2006, 2009 Oracle. All rights reserved. + Copyright (c) 2006, 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. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/GenericJpaProjectManager.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/GenericJpaProjectManager.java index 4eaf9cb61e..3e280b51e5 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/GenericJpaProjectManager.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/GenericJpaProjectManager.java @@ -396,7 +396,7 @@ class GenericJpaProjectManager private JpaProject.Config buildJpaProjectConfig(IProject project) { SimpleJpaProjectConfig config = new SimpleJpaProjectConfig(); config.setProject(project); - config.setJpaPlatform(JptCorePlugin.getJpaPlatform(project)); + config.setJpaPlatform(JptCorePlugin.getJpaPlatformManager().buildJpaPlatformImplementation(project)); config.setConnectionProfileName(JptCorePlugin.getConnectionProfileName(project)); config.setUserOverrideDefaultCatalog(JptCorePlugin.getUserOverrideDefaultCatalog(project)); config.setUserOverrideDefaultSchema(JptCorePlugin.getUserOverrideDefaultSchema(project)); 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 a104200435..8b77fbaff3 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 @@ -29,18 +29,20 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences; 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.GenericJpaPlatformProvider; -import org.eclipse.jpt.core.internal.JpaPlatformRegistry; import org.eclipse.jpt.core.internal.JptCoreMessages; -import org.eclipse.jpt.core.internal.jpa2.Generic2_0JpaPlatformProvider; +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.platform.GenericPlatform; +import org.eclipse.jpt.core.platform.JpaPlatformDescription; +import org.eclipse.jpt.core.platform.JpaPlatformManager; import org.eclipse.jpt.core.resource.ResourceLocator; import org.eclipse.jpt.utility.internal.StringTools; 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.IProjectFacetVersion; import org.osgi.framework.BundleContext; import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; @@ -332,19 +334,21 @@ public class JptCorePlugin extends Plugin { IEclipsePreferences node = getDefaultPreferences(); // default JPA platforms - String defaultPlatformId_1_0 = JpaPlatformRegistry.instance().getDefaultJpaPlatformId(JpaFacet.VERSION_1_0.getVersionString()); - if (StringTools.stringIsEmpty(defaultPlatformId_1_0)) { - defaultPlatformId_1_0 = GenericJpaPlatformProvider.ID; + JpaPlatformDescription defaultPlatform_1_0 = + JpaPlatformManagerImpl.instance().getDefaultJpaPlatform(JpaFacet.VERSION_1_0); + if (defaultPlatform_1_0 == null) { + defaultPlatform_1_0 = GenericPlatform.VERSION_1_0; } - node.put(DEFAULT_JPA_PLATFORM_1_0_PREF_KEY, defaultPlatformId_1_0); + node.put(DEFAULT_JPA_PLATFORM_1_0_PREF_KEY, defaultPlatform_1_0.getId()); - String defaultPlatformId_2_0 = JpaPlatformRegistry.instance().getDefaultJpaPlatformId(JpaFacet.VERSION_2_0.getVersionString()); - if (StringTools.stringIsEmpty(defaultPlatformId_2_0)) { - defaultPlatformId_2_0 = Generic2_0JpaPlatformProvider.ID; + JpaPlatformDescription defaultPlatform_2_0 = + JpaPlatformManagerImpl.instance().getDefaultJpaPlatform(JpaFacet.VERSION_2_0); + if (defaultPlatform_2_0 == null) { + defaultPlatform_2_0 = GenericPlatform.VERSION_2_0; } - node.put(DEFAULT_JPA_PLATFORM_2_0_PREF_KEY, defaultPlatformId_2_0); + node.put(DEFAULT_JPA_PLATFORM_2_0_PREF_KEY, defaultPlatform_2_0.getId()); } - + /** * Return the default Dali preferences * @see JpaPreferenceInitializer @@ -375,56 +379,57 @@ public class JptCorePlugin extends Plugin { } /** - * Return the default JPA Platform ID for new JPA projects with the given JPA facet version. + * Return the default {@link JpaPlatformDescription} for new JPA projects with the given JPA facet version. */ - public static String getDefaultJpaPlatformId(String jpaFacetVersion) { - String defaultPlatformId = - getDefaultJpaPlatformId(jpaFacetVersion, getWorkspacePreferences(), getDefaultPreferences()); - if (defaultPlatformId == null) { + public static JpaPlatformDescription getDefaultJpaPlatform(IProjectFacetVersion jpaFacetVersion) { + JpaPlatformDescription defaultPlatform = + getDefaultJpaPlatform(jpaFacetVersion, getWorkspacePreferences(), getDefaultPreferences()); + if (defaultPlatform == null) { // if the platform ID stored in the workspace prefs is invalid (i.e. null), look in the default prefs - defaultPlatformId = getDefaultJpaPlatformId(jpaFacetVersion, getDefaultPreferences()); + defaultPlatform = getDefaultJpaPlatform(jpaFacetVersion, getDefaultPreferences()); } - return defaultPlatformId; + return defaultPlatform; } - private static String getDefaultJpaPlatformId(String jpaFacetVersion, Preferences ... nodes) { - String defaultDefaultPlatformId = - getDefaultJpaPlatformId(jpaFacetVersion, DEFAULT_JPA_PLATFORM_PREF_KEY, null, nodes); + private static JpaPlatformDescription getDefaultJpaPlatform(IProjectFacetVersion jpaFacetVersion, Preferences ... nodes) { + JpaPlatformDescription defaultDefaultPlatform = + getDefaultJpaPlatform(jpaFacetVersion, DEFAULT_JPA_PLATFORM_PREF_KEY, null, nodes); String preferenceKey = null; - if (jpaFacetVersion.equals(JpaFacet.VERSION_1_0.getVersionString())) { - if (defaultDefaultPlatformId == null) { - defaultDefaultPlatformId = GenericJpaPlatformProvider.ID; + if (jpaFacetVersion.equals(JpaFacet.VERSION_1_0)) { + if (defaultDefaultPlatform == null) { + defaultDefaultPlatform = GenericPlatform.VERSION_1_0; } preferenceKey = DEFAULT_JPA_PLATFORM_1_0_PREF_KEY; } - else if (jpaFacetVersion.equals(JpaFacet.VERSION_2_0.getVersionString())) { - if (defaultDefaultPlatformId == null) { - defaultDefaultPlatformId = Generic2_0JpaPlatformProvider.ID; + else if (jpaFacetVersion.equals(JpaFacet.VERSION_2_0)) { + if (defaultDefaultPlatform == null) { + defaultDefaultPlatform = GenericPlatform.VERSION_2_0; } preferenceKey = DEFAULT_JPA_PLATFORM_2_0_PREF_KEY; } else { throw new IllegalArgumentException("Illegal JPA facet version: " + jpaFacetVersion); //$NON-NLS-1$ } - return getDefaultJpaPlatformId(jpaFacetVersion, preferenceKey, defaultDefaultPlatformId, nodes); + return getDefaultJpaPlatform(jpaFacetVersion, preferenceKey, defaultDefaultPlatform, nodes); } - private static String getDefaultJpaPlatformId( - String jpaFacetVersion, String preferenceKey, String defaultDefault, Preferences ... nodes) { - String defaultPlatformId = Platform.getPreferencesService().get(preferenceKey, defaultDefault, nodes); - if (jpaPlatformIdIsValid(defaultPlatformId) - && JpaPlatformRegistry.instance().platformSupportsJpaFacetVersion(defaultPlatformId, jpaFacetVersion)) { - return defaultPlatformId; + private static JpaPlatformDescription getDefaultJpaPlatform( + IProjectFacetVersion jpaFacetVersion, String preferenceKey, JpaPlatformDescription defaultDefault, Preferences ... nodes) { + + String defaultDefaultId = (defaultDefault == null) ? null : defaultDefault.getId(); + String defaultPlatformId = Platform.getPreferencesService().get(preferenceKey, defaultDefaultId, nodes); + JpaPlatformDescription defaultPlatform = getJpaPlatformManager().getJpaPlatform(defaultPlatformId); + if (defaultPlatform != null && defaultPlatform.supportsJpaFacetVersion(jpaFacetVersion)) { + return defaultPlatform; } - else if (jpaPlatformIdIsValid(defaultDefault) - && JpaPlatformRegistry.instance().platformSupportsJpaFacetVersion(defaultDefault, jpaFacetVersion)) { + else if (defaultDefault != null && defaultDefault.supportsJpaFacetVersion(jpaFacetVersion)) { return defaultDefault; } return null; } - private static boolean jpaPlatformIdIsValid(String platformId) { - return JpaPlatformRegistry.instance().containsPlatform(platformId); + public static JpaPlatformManager getJpaPlatformManager() { + return JpaPlatformManagerImpl.instance(); } /** @@ -445,19 +450,12 @@ public class JptCorePlugin extends Plugin { prefs.put(preferenceKey, platformId); flush(prefs); } - - /** - * Return the JPA platform associated with the specified Eclipse project. - */ - public static JpaPlatform getJpaPlatform(IProject project) { - return JpaPlatformRegistry.instance().getJpaPlatform(project); - } - + /** * Return the JPA platform ID associated with the specified Eclipse project. */ public static String getJpaPlatformId(IProject project) { - return getProjectPreferences(project).get(JPA_PLATFORM_PREF_KEY, GenericJpaPlatformProvider.ID); + return getProjectPreferences(project).get(JPA_PLATFORM_PREF_KEY, GenericPlatform.VERSION_1_0.getId()); } /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaPlatformProvider.java index 751b62c1da..8d497d4e78 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaPlatformProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaPlatformProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 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. @@ -40,8 +40,6 @@ import org.eclipse.jpt.core.internal.jpa1.context.persistence.GenericPersistence public class GenericJpaPlatformProvider extends AbstractJpaPlatformProvider { - public static final String ID = "generic"; //$NON-NLS-1$ - // singleton private static final JpaPlatformProvider INSTANCE = new GenericJpaPlatformProvider(); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaPlatformRegistry.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaPlatformRegistry.java deleted file mode 100644 index 3bd1933857..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaPlatformRegistry.java +++ /dev/null @@ -1,241 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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 static org.eclipse.jpt.core.internal.XPointUtil.*; -import java.util.HashMap; -import java.util.Map; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jpt.core.JpaPlatform; -import org.eclipse.jpt.core.JpaPlatformFactory; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.utility.internal.iterables.TransformationIterable; - -/** - * Singleton registry for storing all the registered JPA platform configuration - * elements and instantiating JPA platforms from them. - */ -public class JpaPlatformRegistry { - - private final HashMap<String, IConfigurationElement> jpaPlatformConfigurationElements; - - - // singleton - private static final JpaPlatformRegistry INSTANCE = new JpaPlatformRegistry(); - - /** - * Return the singleton. - */ - public static JpaPlatformRegistry instance() { - return INSTANCE; - } - - private static final String EXTENSION_ID = "jpaPlatforms"; //$NON-NLS-1$ - private static final String QUALIFIED_EXTENSION_ID = JptCorePlugin.PLUGIN_ID_ + EXTENSION_ID; - private static final String PLATFORM_ELEMENT_NAME = "jpaPlatform"; //$NON-NLS-1$ - private static final String ID_ATTRIBUTE_NAME = "id"; //$NON-NLS-1$ - private static final String LABEL_ATTRIBUTE_NAME = "label"; //$NON-NLS-1$ - private static final String FACTORY_CLASS_ATTRIBUTE_NAME = "factoryClass"; //$NON-NLS-1$ - private static final String JPA_FACET_VERSION_ATTRIBUTE_NAME = "jpaFacetVersion"; //$NON-NLS-1$ - private static final String DEFAULT_ATTRIBUTE_NAME = "default"; //$NON-NLS-1$ - - - // ********** constructor/initialization ********** - - /** - * ensure single instance - */ - private JpaPlatformRegistry() { - super(); - this.jpaPlatformConfigurationElements = this.buildJpaPlatformConfigurationElements(); - } - - - private HashMap<String, IConfigurationElement> buildJpaPlatformConfigurationElements() { - HashMap<String, IConfigurationElement> configElements = new HashMap<String, IConfigurationElement>(); - for (IConfigurationElement configElement : this.getConfigElements()) { - this.addConfigElementTo(configElement, configElements); - } - return configElements; - } - - /** - * Return the configuration elements from the Eclipse platform extension - * registry. - */ - private Iterable<IConfigurationElement> getConfigElements() { - return new CompositeIterable<IConfigurationElement>( - new TransformationIterable<IExtension, Iterable<IConfigurationElement>>(this.getExtensions()) { - @Override - protected Iterable<IConfigurationElement> transform(IExtension extension) { - return CollectionTools.iterable(extension.getConfigurationElements()); - } - } - ); - } - - private Iterable<IExtension> getExtensions() { - return CollectionTools.iterable(this.getExtensionPoint().getExtensions()); - } - - private IExtensionPoint getExtensionPoint() { - return Platform.getExtensionRegistry().getExtensionPoint(JptCorePlugin.PLUGIN_ID, EXTENSION_ID); - } - - private void addConfigElementTo(IConfigurationElement configElement, HashMap<String, IConfigurationElement> configElements) { - if ( ! configElement.getName().equals(PLATFORM_ELEMENT_NAME)) { - return; - } - if ( ! this.configElementIsValid(configElement)) { - return; - } - - String id = configElement.getAttribute(ID_ATTRIBUTE_NAME); - if (configElements.containsKey(id)) { - logDuplicateExtension(QUALIFIED_EXTENSION_ID, id); - } - else { - configElements.put(id, configElement); - } - } - - /** - * check *all* attributes before returning - */ - private boolean configElementIsValid(IConfigurationElement configElement) { - boolean valid = true; - if (configElement.getAttribute(ID_ATTRIBUTE_NAME) == null) { - logMissingAttribute(configElement, ID_ATTRIBUTE_NAME); - valid = false; - } - if (configElement.getAttribute(LABEL_ATTRIBUTE_NAME) == null) { - logMissingAttribute(configElement, LABEL_ATTRIBUTE_NAME); - valid = false; - } - if (configElement.getAttribute(FACTORY_CLASS_ATTRIBUTE_NAME) == null) { - logMissingAttribute(configElement, FACTORY_CLASS_ATTRIBUTE_NAME); - valid = false; - } - return valid; - } - - - // ********** public methods ********** - - /** - * Return the IDs for the registered JPA platforms. - * This does not activate any of the JPA platforms' plug-ins. - */ - public Iterable<String> getJpaPlatformIds() { - return this.jpaPlatformConfigurationElements.keySet(); - } - - /** - * Return whether the platform id is registered - */ - public boolean containsPlatform(String platformId) { - return this.jpaPlatformConfigurationElements.containsKey(platformId); - } - - /** - * Return the label for the JPA platform with the specified ID. - * This does not activate the JPA platform's plug-in. - */ - public String getJpaPlatformLabel(String id) { - return this.jpaPlatformConfigurationElements.get(id).getAttribute(LABEL_ATTRIBUTE_NAME); - } - - /** - * Return whether the platform represented by the given id supports the specified JPA facet version. - * This does not active the JPA platform's plug-in. - */ - public boolean platformSupportsJpaFacetVersion(String platformId, String jpaFacetVersion) { - IConfigurationElement configElement = this.jpaPlatformConfigurationElements.get(platformId); - return configElementSupportsJpaFacetVersion(configElement, jpaFacetVersion); - } - - boolean configElementSupportsJpaFacetVersion(IConfigurationElement configElement, String jpaFacetVersion) { - - // config element supports version if it explicitly sets it to that version - // or if it specifies no version at all - String ver = configElement.getAttribute(JPA_FACET_VERSION_ATTRIBUTE_NAME); - return (ver == null) || ver.equals(jpaFacetVersion); - } - - /** - * Return the IDs for the registered JPA platforms that support the - * specified JPA facet version. - * This does not activate the JPA platforms' plug-in. - */ - public Iterable<String> getJpaPlatformIdsForJpaFacetVersion(final String jpaFacetVersion) { - return new TransformationIterable<IConfigurationElement, String>(this.getConfigurationElementsForJpaFacetVersion(jpaFacetVersion)) { - @Override - protected String transform(IConfigurationElement configElement) { - return configElement.getAttribute(ID_ATTRIBUTE_NAME); - } - }; - } - - private Iterable<IConfigurationElement> getConfigurationElementsForJpaFacetVersion(final String jpaFacetVersion) { - return new FilteringIterable<IConfigurationElement>(this.jpaPlatformConfigurationElements.values()) { - @Override - protected boolean accept(IConfigurationElement configElement) { - return configElementSupportsJpaFacetVersion(configElement, jpaFacetVersion); - } - }; - } - - /** - * Return the ID for a JPA platform registered as a default platform. - * Returns null if there are no such registered platforms. - * Returns the first platform ID if there are multiple such registered platforms. - */ - public String getDefaultJpaPlatformId(String jpaFacetVersion) { - for (Map.Entry<String, IConfigurationElement> entry: this.jpaPlatformConfigurationElements.entrySet()) { - String defaultFlag = entry.getValue().getAttribute(DEFAULT_ATTRIBUTE_NAME); - String platformId = entry.getKey(); - if ((defaultFlag != null) && defaultFlag.equals("true") - && platformSupportsJpaFacetVersion(platformId, jpaFacetVersion)) { //$NON-NLS-1$ - return platformId; - } - } - return null; - } - - /** - * Return a new JPA platform for the specified ID. - * NB: This should only be called when instantiating a JPA platform - * when building a new JPA project. - * Unlike other registry methods, invoking this method may activate - * the plug-in. - */ - public JpaPlatform getJpaPlatform(IProject project) { - String id = JptCorePlugin.getJpaPlatformId(project); - IConfigurationElement configElement = this.jpaPlatformConfigurationElements.get(id); - if (configElement == null) { - log(JptCoreMessages.PLATFORM_ID_DOES_NOT_EXIST, id, project.getName()); - return null; - } - JpaPlatformFactory platformFactory = instantiate( - configElement.getContributor().getName(), QUALIFIED_EXTENSION_ID, - configElement.getAttribute(FACTORY_CLASS_ATTRIBUTE_NAME), JpaPlatformFactory.class); - if (platformFactory == null) { - throw new IllegalArgumentException(id); - } - return platformFactory.buildJpaPlatform(id); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaPlatformTester.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaPlatformTester.java index cf4f51e897..3526e066af 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaPlatformTester.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaPlatformTester.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. This + * Copyright (c) 2008, 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 @@ -13,28 +13,41 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jpt.core.JptCorePlugin; +import org.eclipse.jpt.core.platform.JpaPlatformDescription; +import org.eclipse.jpt.core.platform.JpaPlatformGroupDescription; public class JpaPlatformTester extends PropertyTester { public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (! property.equals("jpaPlatform")) { //$NON-NLS-1$ + if (! (property.equals("jpaPlatform") || property.equals("jpaPlatformGroup")) + || ! (expectedValue instanceof String)) { //$NON-NLS-1$ return false; } - String platformId = null; + JpaPlatformDescription platform = null; if (receiver instanceof IResource) { - platformId = platformId(((IResource) receiver).getProject()); + platform = platform(((IResource) receiver).getProject()); } else if (receiver instanceof IJavaElement) { - platformId = platformId(((IJavaElement) receiver).getResource().getProject()); + platform = platform(((IJavaElement) receiver).getResource().getProject()); } - - return platformId == null ? false : platformId.equals(expectedValue); + if (property.equals("jpaPlatform")) { + JpaPlatformDescription otherPlatform = JptCorePlugin.getJpaPlatformManager().getJpaPlatform((String) expectedValue); + return platform == null ? false : platform.equals(otherPlatform); + } + if (property.equals("jpaPlatformGroup")) { + JpaPlatformGroupDescription group = (platform == null) ? null : platform.getGroup(); + JpaPlatformGroupDescription otherGroup = JptCorePlugin.getJpaPlatformManager().getJpaPlatformGroup((String) expectedValue); + return group == null ? false : group.equals(otherGroup); + } + return false; } - private String platformId(IProject project) { - return (project == null) ? null : JptCorePlugin.getJpaPlatformId(project); + private JpaPlatformDescription platform(IProject project) { + return (project == null) + ? null + : JptCorePlugin.getJpaPlatformManager().getJpaPlatform(JptCorePlugin.getJpaPlatformId(project)); } } 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 0af4d4fffb..558f2ef6a5 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 @@ -19,8 +19,8 @@ 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.JpaPlatformRegistry; import org.eclipse.jpt.core.internal.JptCoreMessages; +import org.eclipse.jpt.core.platform.JpaPlatformDescription; import org.eclipse.jpt.db.Catalog; import org.eclipse.jpt.db.ConnectionProfile; import org.eclipse.jpt.db.ConnectionProfileFactory; @@ -31,6 +31,7 @@ import org.eclipse.jpt.db.SchemaContainer; import org.eclipse.jpt.utility.internal.ArrayTools; 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.IPropertyChangeListener; import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate; @@ -424,8 +425,18 @@ public abstract class JpaFacetDataModelProvider } protected Iterable<String> buildValidPlatformIds() { - String jpaFacetVersion = this.getProjectFacetVersion().getVersionString(); - return JpaPlatformRegistry.instance().getJpaPlatformIdsForJpaFacetVersion(jpaFacetVersion); + 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 static final Comparator<DataModelPropertyDescriptor> DESCRIPTOR_COMPARATOR = @@ -521,7 +532,7 @@ public abstract class JpaFacetDataModelProvider } protected String getPlatformLabel(String platformId) { - return JpaPlatformRegistry.instance().getJpaPlatformLabel(platformId); + return JptCorePlugin.getJpaPlatformManager().getJpaPlatform(platformId).getLabel(); } protected DataModelPropertyDescriptor buildConnectionDescriptor(String connectionName) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDataModelProvider.java index 2832f2fdc3..70a12f93f9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDataModelProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDataModelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Oracle. All rights reserved. + * Copyright (c) 2006, 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. @@ -84,7 +84,7 @@ public class JpaFacetInstallDataModelProvider @Override protected String getDefaultPlatformId() { - return JptCorePlugin.getDefaultJpaPlatformId(getProjectFacetVersion().getVersionString()); + return JptCorePlugin.getDefaultJpaPlatform(getProjectFacetVersion()).getId(); } @Override diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetVersionChangeDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetVersionChangeDataModelProvider.java index 17a394b0f2..3efb401b89 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetVersionChangeDataModelProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetVersionChangeDataModelProvider.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 @@ -15,8 +15,8 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IStatus; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.JpaPlatformRegistry; import org.eclipse.jpt.core.internal.JptCoreMessages; +import org.eclipse.jpt.core.platform.JpaPlatformDescription; import org.eclipse.jpt.utility.internal.CollectionTools; import org.eclipse.jpt.utility.internal.iterables.CompositeIterable; @@ -104,8 +104,8 @@ public class JpaFacetVersionChangeDataModelProvider IStatus status = super.validatePlatformId(); if (status.isOK()) { - if (! JpaPlatformRegistry.instance().platformSupportsJpaFacetVersion( - getPlatformId(), getProjectFacetVersion().getVersionString())) { + JpaPlatformDescription platform = JptCorePlugin.getJpaPlatformManager().getJpaPlatform(getPlatformId()); + if (! platform.supportsJpaFacetVersion(getProjectFacetVersion())) { status = PLATFORM_DOES_NOT_SUPPORT_FACET_VERSION_STATUS; } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaPlatformProvider.java index 6247e02782..fba0cd6952 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaPlatformProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaPlatformProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * 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 http://www.eclipse.org/legal/epl-v10.html. @@ -48,9 +48,6 @@ import org.eclipse.jpt.core.internal.jpa2.context.persistence.Generic2_0Persiste public class Generic2_0JpaPlatformProvider extends AbstractJpaPlatformProvider { - public static final String ID = "generic2_0"; //$NON-NLS-1$ - - // singleton private static final JpaPlatformProvider INSTANCE = new Generic2_0JpaPlatformProvider(); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/OrmFileCreationDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/OrmFileCreationDataModelProvider.java index d13fb7b225..da685ab03f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/OrmFileCreationDataModelProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/OrmFileCreationDataModelProvider.java @@ -15,6 +15,7 @@ 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.JpaPlatform; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.context.persistence.Persistence; @@ -96,8 +97,12 @@ public class OrmFileCreationDataModelProvider if (getProject() == null) { return null; } - return JptCorePlugin.getJpaPlatform(getProject()).getMostRecentSupportedResourceType( - JptCorePlugin.ORM_XML_CONTENT_TYPE).getVersion(); + JpaPlatform jpaPlatform; + JpaProject jpaProject = getJpaProject(); + jpaPlatform = (jpaProject == null) + ? JptCorePlugin.getJpaPlatformManager().buildJpaPlatformImplementation(getProject()) + : jpaProject.getJpaPlatform(); + return jpaPlatform.getMostRecentSupportedResourceType(JptCorePlugin.ORM_XML_CONTENT_TYPE).getVersion(); } protected PersistenceUnit getDefaultPersistenceUnit() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/PersistenceFileCreationDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/PersistenceFileCreationDataModelProvider.java index e1b03beb40..ae267abef7 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/PersistenceFileCreationDataModelProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/PersistenceFileCreationDataModelProvider.java @@ -11,6 +11,8 @@ package org.eclipse.jpt.core.internal.operations; import org.eclipse.jpt.core.JpaFacet; +import org.eclipse.jpt.core.JpaPlatform; +import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.resource.persistence.JPA; import org.eclipse.jpt.core.resource.persistence.v2_0.JPA2_0; @@ -43,8 +45,12 @@ public class PersistenceFileCreationDataModelProvider if (getProject() == null) { return null; } - return JptCorePlugin.getJpaPlatform(getProject()).getMostRecentSupportedResourceType( - JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE).getVersion(); + JpaPlatform jpaPlatform; + JpaProject jpaProject = getJpaProject(); + jpaPlatform = (jpaProject == null) + ? JptCorePlugin.getJpaPlatformManager().buildJpaPlatformImplementation(getProject()) + : jpaProject.getJpaPlatform(); + return jpaPlatform.getMostRecentSupportedResourceType(JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE).getVersion(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JpaPlatformDescriptionImpl.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JpaPlatformDescriptionImpl.java new file mode 100644 index 0000000000..2984b24577 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JpaPlatformDescriptionImpl.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.core.internal.platform; + +import org.eclipse.jpt.core.JpaPlatform; +import org.eclipse.jpt.core.JpaPlatformFactory; +import org.eclipse.jpt.core.internal.XPointUtil; +import org.eclipse.jpt.core.platform.JpaPlatformDescription; +import org.eclipse.jpt.core.platform.JpaPlatformGroupDescription; +import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; + +public class JpaPlatformDescriptionImpl + implements JpaPlatformDescription { + + private String id; + private String pluginId; + private String label; + private String factoryClassName; + private IProjectFacetVersion jpaFacetVersion; + private boolean default_ = false; + private JpaPlatformGroupDescriptionImpl group; + + + 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 getLabel() { + return this.label; + } + + void setLabel(String label) { + this.label = label; + } + + public String getFactoryClassName() { + return this.factoryClassName; + } + + void setFactoryClassName(String className) { + this.factoryClassName = className; + } + + public IProjectFacetVersion getJpaFacetVersion() { + return this.jpaFacetVersion; + } + + void setJpaFacetVersion(IProjectFacetVersion jpaFacetVersion) { + this.jpaFacetVersion = jpaFacetVersion; + } + + public boolean supportsJpaFacetVersion(IProjectFacetVersion jpaFacetVersion) { + return (this.jpaFacetVersion != null) ? this.jpaFacetVersion.equals(jpaFacetVersion) : true; + } + + public boolean isDefault() { + return this.default_; + } + + void setDefault(boolean default_) { + this.default_ = default_; + } + + public JpaPlatformGroupDescription getGroup() { + return this.group; + } + + void setGroup(JpaPlatformGroupDescriptionImpl group) { + this.group = group; + } + + public JpaPlatform buildJpaPlatform() { + JpaPlatformFactory factory = (JpaPlatformFactory) XPointUtil.instantiate( + this.pluginId, JpaPlatformManagerImpl.QUALIFIED_EXTENSION_POINT_ID, + this.factoryClassName, JpaPlatformFactory.class); + return factory.buildJpaPlatform(getId()); + } + + @Override + public String toString() { + return this.label; + } +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JpaPlatformGroupDescriptionImpl.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JpaPlatformGroupDescriptionImpl.java new file mode 100644 index 0000000000..3a3de3d42b --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JpaPlatformGroupDescriptionImpl.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * 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.platform; + +import java.util.HashMap; +import java.util.Map; +import org.eclipse.jpt.core.platform.JpaPlatformDescription; +import org.eclipse.jpt.core.platform.JpaPlatformGroupDescription; +import org.eclipse.jpt.utility.internal.CollectionTools; +import org.eclipse.jpt.utility.internal.iterables.SuperIterableWrapper; + +public class JpaPlatformGroupDescriptionImpl + implements JpaPlatformGroupDescription { + + private String id; + private String pluginId; + private String label; + private Map<String, JpaPlatformDescriptionImpl> platforms; + + + JpaPlatformGroupDescriptionImpl() { + this.platforms = new HashMap<String, JpaPlatformDescriptionImpl>(); + } + + 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 getLabel() { + return this.label; + } + + void setLabel(String label) { + this.label = label; + } + + void addPlatform(JpaPlatformDescriptionImpl platform) { + this.platforms.put(platform.getId(), platform); + } + + public Iterable<JpaPlatformDescription> getPlatforms() { + return new SuperIterableWrapper<JpaPlatformDescription>(CollectionTools.collection(this.platforms.values())); + } + + @Override + public String toString() { + return this.label; + } +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JpaPlatformManagerImpl.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JpaPlatformManagerImpl.java new file mode 100644 index 0000000000..967fcd97d5 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/JpaPlatformManagerImpl.java @@ -0,0 +1,238 @@ +/******************************************************************************* + * Copyright (c) 2006, 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.platform; + +import static org.eclipse.jpt.core.internal.XPointUtil.*; +import java.util.ArrayList; +import java.util.List; +import org.eclipse.core.resources.IProject; +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.JpaFacet; +import org.eclipse.jpt.core.JpaPlatform; +import org.eclipse.jpt.core.JptCorePlugin; +import org.eclipse.jpt.core.internal.XPointUtil.XPointException; +import org.eclipse.jpt.core.platform.JpaPlatformDescription; +import org.eclipse.jpt.core.platform.JpaPlatformGroupDescription; +import org.eclipse.jpt.core.platform.JpaPlatformManager; +import org.eclipse.jpt.utility.internal.KeyedSet; +import org.eclipse.jpt.utility.internal.iterables.SuperIterableWrapper; +import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; + +/** + * Singleton registry for storing all the registered JPA platform configuration + * elements and instantiating JPA platforms from them. + */ +public class JpaPlatformManagerImpl + implements JpaPlatformManager { + + static final String EXTENSION_POINT_ID = "jpaPlatforms"; //$NON-NLS-1$ + static final String QUALIFIED_EXTENSION_POINT_ID = JptCorePlugin.PLUGIN_ID_ + EXTENSION_POINT_ID; + static final String PLATFORM_GROUP_ELEMENT = "jpaPlatformGroup"; //$NON-NLS-1$ + static final String PLATFORM_ELEMENT = "jpaPlatform"; //$NON-NLS-1$ + static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$ + static final String LABEL_ATTRIBUTE = "label"; //$NON-NLS-1$ + static final String FACTORY_CLASS_ATTRIBUTE = "factoryClass"; //$NON-NLS-1$ + static final String JPA_FACET_VERSION_ATTRIBUTE = "jpaFacetVersion"; //$NON-NLS-1$ + static final String DEFAULT_ATTRIBUTE = "default"; //$NON-NLS-1$ + static final String GROUP_ELEMENT = "group"; //$NON-NLS-1$ + + + private static final JpaPlatformManagerImpl INSTANCE = new JpaPlatformManagerImpl(); + + + public static JpaPlatformManagerImpl instance() { + return INSTANCE; + } + + + private KeyedSet<String, JpaPlatformGroupDescriptionImpl> jpaPlatformGroupDescriptions; + private KeyedSet<String, JpaPlatformDescriptionImpl> jpaPlatformDescriptions; + + + // ********** constructor/initialization ********** + + private JpaPlatformManagerImpl() { + super(); + this.jpaPlatformGroupDescriptions = new KeyedSet<String, JpaPlatformGroupDescriptionImpl>(); + this.jpaPlatformDescriptions = new KeyedSet<String, JpaPlatformDescriptionImpl>(); + readExtensions(); + } + + + 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(); + } + + List<IConfigurationElement> platformGroupConfigs = new ArrayList<IConfigurationElement>(); + List<IConfigurationElement> platformConfigs = new ArrayList<IConfigurationElement>(); + + for (IExtension extension : xpoint.getExtensions()) { + for (IConfigurationElement element : extension.getConfigurationElements()) { + if (element.getName().equals(PLATFORM_GROUP_ELEMENT)) { + platformGroupConfigs.add(element); + } + else if (element.getName().equals(PLATFORM_ELEMENT)) { + platformConfigs.add(element); + } + } + } + + for (IConfigurationElement element : platformGroupConfigs) { + readPlatformGroupExtension(element); + } + + for (IConfigurationElement element : platformConfigs) { + readPlatformExtension(element); + } + } + + private void readPlatformGroupExtension(IConfigurationElement element) { + try { + final JpaPlatformGroupDescriptionImpl desc = new JpaPlatformGroupDescriptionImpl(); + + // plug-in id + desc.setPluginId(element.getContributor().getName()); + + // id + desc.setId(findRequiredAttribute(element, ID_ATTRIBUTE)); + + if (this.jpaPlatformGroupDescriptions.containsKey(desc.getId())) { + logDuplicateExtension(QUALIFIED_EXTENSION_POINT_ID, desc.getId()); + throw new XPointException(); + } + + // label + desc.setLabel(findRequiredAttribute(element, LABEL_ATTRIBUTE)); + + this.jpaPlatformGroupDescriptions.addItem(desc.getId(), desc); + } + catch (XPointException e) { + // Ignore and continue. The problem has already been reported to the user + // in the log. + } + } + + private void readPlatformExtension(IConfigurationElement element) { + try { + final JpaPlatformDescriptionImpl desc = new JpaPlatformDescriptionImpl(); + + // plug-in id + desc.setPluginId(element.getContributor().getName()); + + // id + desc.setId(findRequiredAttribute(element, ID_ATTRIBUTE)); + + if (this.jpaPlatformDescriptions.containsKey(desc.getId())) { + logDuplicateExtension(QUALIFIED_EXTENSION_POINT_ID, desc.getId()); + throw new XPointException(); + } + + // label + desc.setLabel(findRequiredAttribute(element, LABEL_ATTRIBUTE)); + + // factory class + desc.setFactoryClassName(findRequiredAttribute(element, FACTORY_CLASS_ATTRIBUTE)); + + // JPA facet version + String jpaFacetVersionString = element.getAttribute(JPA_FACET_VERSION_ATTRIBUTE); + if (jpaFacetVersionString != null) { + IProjectFacetVersion jpaFacetVersion = JpaFacet.FACET.getVersion(jpaFacetVersionString); + if (jpaFacetVersion != null) { + desc.setJpaFacetVersion(jpaFacetVersion); + } + else { + logInvalidValue(element, JPA_FACET_VERSION_ATTRIBUTE, jpaFacetVersionString); + throw new XPointException(); + } + } + + // default + String defaultString = element.getAttribute(DEFAULT_ATTRIBUTE); + if (defaultString != null) { + if (defaultString.equals("true")) { + desc.setDefault(true); + } + else if (defaultString.equals("false")) { + desc.setDefault(false); + } + else { + logInvalidValue(element, DEFAULT_ATTRIBUTE, defaultString); + throw new XPointException(); + } + } + + // group + String groupId = element.getAttribute(GROUP_ELEMENT); + if (groupId != null) { + JpaPlatformGroupDescriptionImpl group = this.jpaPlatformGroupDescriptions.getItem(groupId); + if (group != null) { + desc.setGroup(group); + group.addPlatform(desc); + } + else { + logInvalidValue(element, GROUP_ELEMENT, groupId); + throw new XPointException(); + } + } + + this.jpaPlatformDescriptions.addItem(desc.getId(), desc); + } + catch (XPointException e) { + // Ignore and continue. The problem has already been reported to the user + // in the log. + } + } + + + // ********** public methods ********** + + public Iterable<JpaPlatformGroupDescription> getJpaPlatformGroups() { + return new SuperIterableWrapper<JpaPlatformGroupDescription>(this.jpaPlatformGroupDescriptions.getItemSet()); + } + + public JpaPlatformGroupDescription getJpaPlatformGroup(String groupId) { + return this.jpaPlatformGroupDescriptions.getItem(groupId); + } + + public Iterable<JpaPlatformDescription> getJpaPlatforms() { + return new SuperIterableWrapper<JpaPlatformDescription>(this.jpaPlatformDescriptions.getItemSet()); + } + + public JpaPlatformDescription getJpaPlatform(String platformId) { + return this.jpaPlatformDescriptions.getItem(platformId); + } + + public JpaPlatformDescription getDefaultJpaPlatform(IProjectFacetVersion jpaFacetVersion) { + for (JpaPlatformDescription platform : getJpaPlatforms()) { + if (platform.isDefault() && platform.supportsJpaFacetVersion(jpaFacetVersion)) { + return platform; + } + } + return null; + } + public JpaPlatform buildJpaPlatformImplementation(IProject project) { + String jpaPlatformId = JptCorePlugin.getJpaPlatformId(project); + JpaPlatformDescriptionImpl platformDesc = this.jpaPlatformDescriptions.getItem(jpaPlatformId); + if (platformDesc == null) { + throw new IllegalArgumentException("Project does not have a recognized JPA platform."); + } + return platformDesc.buildJpaPlatform(); + } +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/GenericPlatform.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/GenericPlatform.java new file mode 100644 index 0000000000..4d9ec12c39 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/GenericPlatform.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.platform; + +import org.eclipse.jpt.core.JptCorePlugin; + +/** + * Constants pertaining to the Generic JPA platforms and their group. + * + * 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 class GenericPlatform { + + public static final JpaPlatformGroupDescription GROUP + = JptCorePlugin.getJpaPlatformManager().getJpaPlatformGroup("generic"); //$NON-NLS-1$ + + public static final JpaPlatformDescription VERSION_1_0 + = JptCorePlugin.getJpaPlatformManager().getJpaPlatform("generic"); //$NON-NLS-1$ + + public static final JpaPlatformDescription VERSION_2_0 + = JptCorePlugin.getJpaPlatformManager().getJpaPlatform("generic2_0"); //$NON-NLS-1$ + + /** + * Not for instantiation + */ + private GenericPlatform() {} +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/JpaPlatformDescription.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/JpaPlatformDescription.java new file mode 100644 index 0000000000..e52a110409 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/JpaPlatformDescription.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.platform; + +import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; + +/** + * Contains metadata that describes a JPA platform. Not intended to be implemented by clients. + * + * 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 JpaPlatformDescription { + + public String getId(); + + public String getPluginId(); + + public String getLabel(); + + public String getFactoryClassName(); + + public boolean supportsJpaFacetVersion(IProjectFacetVersion jpaFacetVersion); + + public boolean isDefault(); + + public JpaPlatformGroupDescription getGroup(); +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/JpaPlatformGroupDescription.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/JpaPlatformGroupDescription.java new file mode 100644 index 0000000000..f97f9cc96c --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/JpaPlatformGroupDescription.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.platform; + +/** + * Contains metadata that describes a JPA platform group. Not intended to be implemented by clients. + * + * 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 JpaPlatformGroupDescription { + + public String getId(); + + public String getPluginId(); + + public String getLabel(); + + public Iterable<JpaPlatformDescription> getPlatforms(); +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/JpaPlatformManager.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/JpaPlatformManager.java new file mode 100644 index 0000000000..05c6fb10c3 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/platform/JpaPlatformManager.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.platform; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jpt.core.JpaPlatform; +import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; + +/** + * Entry point to the "jpaPlatforms" extension point + * + * 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 JpaPlatformManager { + + Iterable<JpaPlatformGroupDescription> getJpaPlatformGroups(); + + JpaPlatformGroupDescription getJpaPlatformGroup(String groupId); + + Iterable<JpaPlatformDescription> getJpaPlatforms(); + + JpaPlatformDescription getJpaPlatform(String platformId); + + /** + * Returns the first JPA platform registered as a default platform and which supports the given + * JPA facet version. + * Returns null if there are no such registered platforms. + */ + JpaPlatformDescription getDefaultJpaPlatform(IProjectFacetVersion jpaFacetVersion); + + JpaPlatform buildJpaPlatformImplementation(IProject project); +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.properties index 850f6aa1a4..abd891f1c7 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.properties +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.properties @@ -24,6 +24,7 @@ providerName = Eclipse Web Tools Platform ECLIPSELINK_ORM_XML_CONTENT = EclipseLink XML mapping files +ECLIPSELINK_PLATFORM_GROUP_LABEL=EclipseLink ECLIPSELINK1_0_x_PLATFORM = EclipseLink 1.0.x ECLIPSELINK1_1_x_PLATFORM = EclipseLink 1.1.x ECLIPSELINK1_2_x_PLATFORM = EclipseLink 1.2.x diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml index 80de1d8e19..7a39f465e7 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/plugin.xml @@ -33,40 +33,44 @@ <extension point="org.eclipse.jpt.core.jpaPlatforms"> + <jpaPlatformGroup + id="eclipselink" + label="%ECLIPSELINK_PLATFORM_GROUP_LABEL"/> + <jpaPlatform id="org.eclipse.eclipselink.platform" - factoryClass="org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaPlatformFactory" - label="%ECLIPSELINK1_0_x_PLATFORM" - jpaFacetVersion="1.0"> - </jpaPlatform> + label="%ECLIPSELINK1_0_x_PLATFORM" + factoryClass="org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaPlatformFactory" + group="eclipselink" + jpaFacetVersion="1.0"/> <jpaPlatform id="eclipselink1_1" - factoryClass="org.eclipse.jpt.eclipselink.core.internal.v1_1.EclipseLink1_1JpaPlatformFactory" label="%ECLIPSELINK1_1_x_PLATFORM" - jpaFacetVersion="1.0"> - </jpaPlatform> + factoryClass="org.eclipse.jpt.eclipselink.core.internal.v1_1.EclipseLink1_1JpaPlatformFactory" + group="eclipselink" + jpaFacetVersion="1.0"/> <jpaPlatform id="eclipselink1_2" - factoryClass="org.eclipse.jpt.eclipselink.core.internal.v1_2.EclipseLink1_2JpaPlatformFactory" label="%ECLIPSELINK1_2_x_PLATFORM" - jpaFacetVersion="1.0"> - </jpaPlatform> + factoryClass="org.eclipse.jpt.eclipselink.core.internal.v1_2.EclipseLink1_2JpaPlatformFactory" + group="eclipselink" + jpaFacetVersion="1.0"/> <jpaPlatform id="eclipselink2_0" - factoryClass="org.eclipse.jpt.eclipselink.core.internal.v2_0.EclipseLink2_0JpaPlatformFactory" label="%ECLIPSELINK2_0_x_PLATFORM" - jpaFacetVersion="2.0"> - </jpaPlatform> + factoryClass="org.eclipse.jpt.eclipselink.core.internal.v2_0.EclipseLink2_0JpaPlatformFactory" + group="eclipselink" + jpaFacetVersion="2.0"/> <jpaPlatform id="eclipselink2_1" - factoryClass="org.eclipse.jpt.eclipselink.core.internal.v2_1.EclipseLink2_1JpaPlatformFactory" label="%ECLIPSELINK2_1_x_PLATFORM" - jpaFacetVersion="2.0"> - </jpaPlatform> + factoryClass="org.eclipse.jpt.eclipselink.core.internal.v2_1.EclipseLink2_1JpaPlatformFactory" + group="eclipselink" + jpaFacetVersion="2.0"/> </extension> diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaPlatformProvider.java index f88ba88af5..ee6ea99f3c 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaPlatformProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaPlatformProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 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. @@ -47,10 +47,8 @@ import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLink * EclipseLink platform */ public class EclipseLinkJpaPlatformProvider - extends AbstractJpaPlatformProvider -{ - public static final String ID = "org.eclipse.eclipselink.platform"; //$NON-NLS-1$ - + extends AbstractJpaPlatformProvider { + // singleton private static final JpaPlatformProvider INSTANCE = new EclipseLinkJpaPlatformProvider(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/operations/EclipseLinkOrmFileCreationDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/operations/EclipseLinkOrmFileCreationDataModelProvider.java index d194096f3b..f1510f482e 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/operations/EclipseLinkOrmFileCreationDataModelProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/operations/EclipseLinkOrmFileCreationDataModelProvider.java @@ -10,13 +10,11 @@ *******************************************************************************/ package org.eclipse.jpt.eclipselink.core.internal.operations; +import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.internal.operations.OrmFileCreationDataModelProvider; -import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaPlatformProvider; +import org.eclipse.jpt.core.platform.JpaPlatformDescription; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; -import org.eclipse.jpt.eclipselink.core.internal.v1_1.EclipseLink1_1JpaPlatformProvider; -import org.eclipse.jpt.eclipselink.core.internal.v1_2.EclipseLink1_2JpaPlatformProvider; -import org.eclipse.jpt.eclipselink.core.internal.v2_0.EclipseLink2_0JpaPlatformProvider; -import org.eclipse.jpt.eclipselink.core.internal.v2_1.EclipseLink2_1JpaPlatformProvider; +import org.eclipse.jpt.eclipselink.core.platform.EclipseLinkPlatform; import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLink; import org.eclipse.jpt.eclipselink.core.resource.orm.v1_1.EclipseLink1_1; import org.eclipse.jpt.eclipselink.core.resource.orm.v1_2.EclipseLink1_2; @@ -77,10 +75,10 @@ public class EclipseLinkOrmFileCreationDataModelProvider @Override protected boolean isSupportedPlatformId(String id) { - return id.equals(EclipseLinkJpaPlatformProvider.ID) - || id.equals(EclipseLink1_1JpaPlatformProvider.ID) - || id.equals(EclipseLink1_2JpaPlatformProvider.ID) - || id.equals(EclipseLink2_0JpaPlatformProvider.ID) - || id.equals(EclipseLink2_1JpaPlatformProvider.ID); + JpaPlatformDescription platform = JptCorePlugin.getJpaPlatformManager().getJpaPlatform(id); + if (platform == null) { + return false; + } + return EclipseLinkPlatform.GROUP.equals(platform.getGroup()); } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/EclipseLink1_1JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/EclipseLink1_1JpaPlatformProvider.java index 314943e1c8..780c70398d 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/EclipseLink1_1JpaPlatformProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/EclipseLink1_1JpaPlatformProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * 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 http://www.eclipse.org/legal/epl-v10.html. @@ -50,10 +50,8 @@ import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm.EclipseLinkOrm * EclipseLink platform */ public class EclipseLink1_1JpaPlatformProvider - extends AbstractJpaPlatformProvider -{ - public static final String ID = "eclipselink1_1"; //$NON-NLS-1$ - + extends AbstractJpaPlatformProvider { + // singleton private static final JpaPlatformProvider INSTANCE = new EclipseLink1_1JpaPlatformProvider(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_2/EclipseLink1_2JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_2/EclipseLink1_2JpaPlatformProvider.java index 393f068006..a879691820 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_2/EclipseLink1_2JpaPlatformProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_2/EclipseLink1_2JpaPlatformProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * 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 http://www.eclipse.org/legal/epl-v10.html. @@ -51,10 +51,8 @@ import org.eclipse.jpt.eclipselink.core.internal.v1_2.context.orm.EclipseLinkOrm * EclipseLink platform */ public class EclipseLink1_2JpaPlatformProvider - extends AbstractJpaPlatformProvider -{ - public static final String ID = "eclipselink1_2"; //$NON-NLS-1$ - + extends AbstractJpaPlatformProvider { + // singleton private static final JpaPlatformProvider INSTANCE = new EclipseLink1_2JpaPlatformProvider(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/EclipseLink2_0JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/EclipseLink2_0JpaPlatformProvider.java index f7ddbfcf2b..cf7c6444b1 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/EclipseLink2_0JpaPlatformProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/EclipseLink2_0JpaPlatformProvider.java @@ -55,9 +55,7 @@ import org.eclipse.jpt.eclipselink.core.internal.v2_0.context.persistence.Eclips * EclipseLink2_0JpaPlatformProvider */ public class EclipseLink2_0JpaPlatformProvider - extends AbstractJpaPlatformProvider -{ - public static final String ID = "eclipselink2_0"; //$NON-NLS-1$ + extends AbstractJpaPlatformProvider { // singleton private static final JpaPlatformProvider INSTANCE = diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_1/EclipseLink2_1JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_1/EclipseLink2_1JpaPlatformProvider.java index b7944b0be0..8476565499 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_1/EclipseLink2_1JpaPlatformProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_1/EclipseLink2_1JpaPlatformProvider.java @@ -27,9 +27,7 @@ import org.eclipse.jpt.eclipselink.core.internal.v2_0.context.persistence.Eclips import org.eclipse.jpt.eclipselink.core.internal.v2_1.context.orm.EclipseLinkOrmXml2_1Definition; public class EclipseLink2_1JpaPlatformProvider - extends EclipseLink2_0JpaPlatformProvider -{ - public static final String ID = "eclipselink2_1"; //$NON-NLS-1$ + extends EclipseLink2_0JpaPlatformProvider { // singleton private static final JpaPlatformProvider INSTANCE = diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/platform/EclipseLinkPlatform.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/platform/EclipseLinkPlatform.java new file mode 100644 index 0000000000..b9c02dec88 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/platform/EclipseLinkPlatform.java @@ -0,0 +1,43 @@ +package org.eclipse.jpt.eclipselink.core.platform; + +import org.eclipse.jpt.core.JptCorePlugin; +import org.eclipse.jpt.core.platform.JpaPlatformDescription; +import org.eclipse.jpt.core.platform.JpaPlatformGroupDescription; + +/** + * Constants pertaining to the EclipseLink JPA platforms and their group + * + * 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 class EclipseLinkPlatform { + + public static final JpaPlatformGroupDescription GROUP + = JptCorePlugin.getJpaPlatformManager().getJpaPlatformGroup("eclipselink"); //$NON-NLS-1$ + + public static final JpaPlatformDescription VERSION_1_0 + = JptCorePlugin.getJpaPlatformManager().getJpaPlatform("org.eclipse.eclipselink.platform"); //$NON-NLS-1$ + + public static final JpaPlatformDescription VERSION_1_1 + = JptCorePlugin.getJpaPlatformManager().getJpaPlatform("eclipselink1_1"); //$NON-NLS-1$ + + public static final JpaPlatformDescription VERSION_1_2 + = JptCorePlugin.getJpaPlatformManager().getJpaPlatform("eclipselink1_2"); //$NON-NLS-1$ + + public static final JpaPlatformDescription VERSION_2_0 + = JptCorePlugin.getJpaPlatformManager().getJpaPlatform("eclipselink2_0"); //$NON-NLS-1$ + + public static final JpaPlatformDescription VERSION_2_1 + = JptCorePlugin.getJpaPlatformManager().getJpaPlatform("eclipselink2_1"); //$NON-NLS-1$ + + /** + * Not for instantiation + */ + private EclipseLinkPlatform() {} +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml index 78f49870ff..c90eb90b77 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/plugin.xml @@ -87,28 +87,10 @@ property="org.eclipse.wst.common.project.facet.core.projectFacet" value="jpt.jpa" /> </adapt> - <or> - <test - property="org.eclipse.jpt.core.jpaPlatform" - value="org.eclipse.eclipselink.platform"> - </test> - <test - property="org.eclipse.jpt.core.jpaPlatform" - value="eclipselink1_1"> - </test> - <test - property="org.eclipse.jpt.core.jpaPlatform" - value="eclipselink1_2"> - </test> - <test - property="org.eclipse.jpt.core.jpaPlatform" - value="eclipselink2_0"> - </test> - <test - property="org.eclipse.jpt.core.jpaPlatform" - value="eclipselink2_1"> - </test> - </or> + <test + property="org.eclipse.jpt.core.jpaPlatformGroup" + value="eclipselink"> + </test> </and> </enablement> </commonWizard> 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 3311b8d4cb..b8f2e006c0 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 @@ -43,10 +43,10 @@ import org.eclipse.jpt.core.JpaFacet; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.JpaProjectManager; import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.JpaPlatformRegistry; import org.eclipse.jpt.core.internal.JptCoreMessages; import org.eclipse.jpt.core.internal.facet.JpaLibraryProviderConstants; import org.eclipse.jpt.core.jpa2.JpaProject2_0; +import org.eclipse.jpt.core.platform.JpaPlatformDescription; import org.eclipse.jpt.db.Catalog; import org.eclipse.jpt.db.ConnectionAdapter; import org.eclipse.jpt.db.ConnectionListener; @@ -68,6 +68,8 @@ import org.eclipse.jpt.utility.internal.NotBooleanTransformer; import org.eclipse.jpt.utility.internal.StringConverter; import org.eclipse.jpt.utility.internal.StringTools; 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.jpt.utility.internal.model.value.AbstractCollectionValueModel; import org.eclipse.jpt.utility.internal.model.value.AspectCollectionValueModelAdapter; import org.eclipse.jpt.utility.internal.model.value.AspectPropertyValueModelAdapter; @@ -496,8 +498,19 @@ public class JpaProjectPropertiesPage } private CollectionValueModel<String> buildRegistryPlatformsModel() { - String jpaFacetVersion = this.getProjectFacetVersion().getVersionString(); - Iterable<String> enabledPlatformIds = JpaPlatformRegistry.instance().getJpaPlatformIdsForJpaFacetVersion(jpaFacetVersion); + Iterable<String> enabledPlatformIds = + 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(); + } + }; return new StaticCollectionValueModel<String>(enabledPlatformIds); } @@ -518,7 +531,7 @@ public class JpaProjectPropertiesPage }; /* private */ static String getJpaPlatformLabel(String id) { - return JpaPlatformRegistry.instance().getJpaPlatformLabel(id); + return JptCorePlugin.getJpaPlatformManager().getJpaPlatform(id).getLabel(); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java index 5631d277a7..16bb406415 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java @@ -26,10 +26,10 @@ import org.eclipse.jpt.core.context.java.JavaPersistentType; import org.eclipse.jpt.core.context.orm.EntityMappings; import org.eclipse.jpt.core.context.persistence.ClassRef; import org.eclipse.jpt.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.core.internal.GenericJpaPlatformProvider; import org.eclipse.jpt.core.internal.facet.JpaFacetDataModelProperties; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProperties; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProvider; +import org.eclipse.jpt.core.platform.GenericPlatform; import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; import org.eclipse.jpt.core.resource.persistence.PersistenceFactory; import org.eclipse.jpt.core.resource.persistence.XmlJavaClassRef; @@ -91,7 +91,7 @@ public abstract class ContextModelTestCase extends AnnotationTestCase // default facet version is 2.0 - most tests use 1.0 dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, JpaFacet.VERSION_1_0.getVersionString()); // most tests use the basic generic platform - dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, GenericJpaPlatformProvider.ID); + dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, GenericPlatform.VERSION_1_0.getId()); // most tests do use an orm.xml dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE); return dataModel; diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaProjectTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaProjectTests.java index a152c825c9..8b647ee591 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaProjectTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaProjectTests.java @@ -14,13 +14,13 @@ import org.eclipse.core.runtime.Path; import org.eclipse.jpt.core.JpaFacet; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.GenericJpaPlatformProvider; import org.eclipse.jpt.core.internal.facet.JpaFacetDataModelProperties; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProperties; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProvider; import org.eclipse.jpt.core.internal.operations.JpaFileCreationDataModelProperties; import org.eclipse.jpt.core.internal.operations.OrmFileCreationDataModelProvider; import org.eclipse.jpt.core.internal.operations.PersistenceFileCreationDataModelProvider; +import org.eclipse.jpt.core.platform.GenericPlatform; import org.eclipse.jpt.core.resource.xml.JpaXmlResource; import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject; import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; @@ -48,7 +48,7 @@ public class JpaProjectTests extends TestCase protected IDataModel buildJpaConfigDataModel() { IDataModel dataModel = DataModelFactory.createDataModel(new JpaFacetInstallDataModelProvider()); dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, JpaFacet.VERSION_1_0.getVersionString()); - dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, GenericJpaPlatformProvider.ID); + dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, GenericPlatform.VERSION_1_0.getId()); dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE); return dataModel; } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/Generic2_0ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/Generic2_0ContextModelTestCase.java index 13aa385fa1..bdf48e809e 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/Generic2_0ContextModelTestCase.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/Generic2_0ContextModelTestCase.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 @@ -13,7 +13,7 @@ package org.eclipse.jpt.core.tests.internal.jpa2.context; import org.eclipse.jpt.core.JpaFacet; import org.eclipse.jpt.core.internal.facet.JpaFacetDataModelProperties; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProperties; -import org.eclipse.jpt.core.internal.jpa2.Generic2_0JpaPlatformProvider; +import org.eclipse.jpt.core.platform.GenericPlatform; import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase; import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; import org.eclipse.wst.common.frameworks.datamodel.IDataModel; @@ -28,7 +28,7 @@ public abstract class Generic2_0ContextModelTestCase extends ContextModelTestCas protected IDataModel buildJpaConfigDataModel() { IDataModel dataModel = super.buildJpaConfigDataModel(); dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, JpaFacet.VERSION_2_0.getVersionString()); - dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, Generic2_0JpaPlatformProvider.ID); + dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, GenericPlatform.VERSION_2_0.getId()); dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE); return dataModel; } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceUnitTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceUnitTests.java index b033a62aa2..14a6241311 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceUnitTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceUnitTests.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* 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 http://www.eclipse.org/legal/epl-v10.html. @@ -12,8 +12,8 @@ package org.eclipse.jpt.core.tests.internal.jpa2.context.persistence; import org.eclipse.jpt.core.JpaFacet; import org.eclipse.jpt.core.internal.facet.JpaFacetDataModelProperties; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProperties; -import org.eclipse.jpt.core.internal.jpa2.Generic2_0JpaPlatformProvider; import org.eclipse.jpt.core.jpa2.context.persistence.PersistenceUnit2_0; +import org.eclipse.jpt.core.platform.GenericPlatform; import org.eclipse.jpt.core.tests.internal.context.persistence.PersistenceUnitTestCase; import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; import org.eclipse.jpt.utility.model.value.PropertyValueModel; @@ -46,7 +46,7 @@ public abstract class Generic2_0PersistenceUnitTests extends PersistenceUnitTest protected IDataModel buildJpaConfigDataModel() { IDataModel dataModel = super.buildJpaConfigDataModel(); dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, JpaFacet.VERSION_2_0.getVersionString()); - dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, Generic2_0JpaPlatformProvider.ID); + dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, GenericPlatform.VERSION_2_0.getId()); dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE); return dataModel; } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformExtensionTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformExtensionTests.java index e04cf22c6e..44a45a3c56 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformExtensionTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformExtensionTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 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. @@ -15,7 +15,6 @@ import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; import org.eclipse.jpt.core.JpaFacet; import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.JpaPlatformRegistry; import org.eclipse.jpt.core.internal.facet.JpaFacetDataModelProperties; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProvider; import org.eclipse.jpt.core.tests.extension.resource.ExtensionTestPlugin; @@ -81,15 +80,14 @@ public class JpaPlatformExtensionTests extends ContextModelTestCase } public void testAllJpaPlatformIds() { - assertTrue(CollectionTools.size(JpaPlatformRegistry.instance().getJpaPlatformIds()) >= 2); + assertTrue(CollectionTools.size(JptCorePlugin.getJpaPlatformManager().getJpaPlatforms()) >= 2); } public void testJpaPlatformLabel() { - assertEquals(TEST_PLATFORM_LABEL, JpaPlatformRegistry.instance().getJpaPlatformLabel(TEST_PLATFORM_ID)); + assertEquals(TEST_PLATFORM_LABEL, JptCorePlugin.getJpaPlatformManager().getJpaPlatform(TEST_PLATFORM_ID).getLabel()); } public void testJpaPlatform() { - assertNotNull(JpaPlatformRegistry.instance().getJpaPlatform(this.testProject.getProject())); + assertNotNull(JptCorePlugin.getJpaPlatformManager().buildJpaPlatformImplementation(this.testProject.getProject())); } - } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/EclipseLinkContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/EclipseLinkContextModelTestCase.java index 24b8fa0b61..aa9ecedcb3 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/EclipseLinkContextModelTestCase.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/EclipseLinkContextModelTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. + * Copyright (c) 2008, 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 @@ -14,8 +14,8 @@ import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProperties; import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase; import org.eclipse.jpt.eclipselink.core.EclipseLinkJpaProject; import org.eclipse.jpt.eclipselink.core.context.java.JavaEclipseLinkEntity; -import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaPlatformProvider; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit; +import org.eclipse.jpt.eclipselink.core.platform.EclipseLinkPlatform; import org.eclipse.wst.common.frameworks.datamodel.IDataModel; public abstract class EclipseLinkContextModelTestCase @@ -29,7 +29,7 @@ public abstract class EclipseLinkContextModelTestCase @Override protected IDataModel buildJpaConfigDataModel() { IDataModel dataModel = super.buildJpaConfigDataModel(); - dataModel.setProperty(JpaFacetInstallDataModelProperties.PLATFORM_ID, EclipseLinkJpaPlatformProvider.ID); + dataModel.setProperty(JpaFacetInstallDataModelProperties.PLATFORM_ID, EclipseLinkPlatform.VERSION_1_0.getId()); return dataModel; } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTestCase.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTestCase.java index 582ef0d5cb..3ffd75489c 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTestCase.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 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. @@ -11,8 +11,8 @@ package org.eclipse.jpt.eclipselink.core.tests.internal.context.persistence; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProperties; import org.eclipse.jpt.core.tests.internal.context.persistence.PersistenceUnitTestCase; -import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaPlatformProvider; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit; +import org.eclipse.jpt.eclipselink.core.platform.EclipseLinkPlatform; import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; import org.eclipse.jpt.utility.model.value.PropertyValueModel; import org.eclipse.wst.common.frameworks.datamodel.IDataModel; @@ -42,7 +42,7 @@ public abstract class EclipseLinkPersistenceUnitTestCase extends PersistenceUnit @Override protected IDataModel buildJpaConfigDataModel() { IDataModel dataModel = super.buildJpaConfigDataModel(); - dataModel.setProperty(JpaFacetInstallDataModelProperties.PLATFORM_ID, EclipseLinkJpaPlatformProvider.ID); + dataModel.setProperty(JpaFacetInstallDataModelProperties.PLATFORM_ID, EclipseLinkPlatform.VERSION_1_0.getId()); return dataModel; } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink1_1/core/tests/internal/context/EclipseLink1_1ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink1_1/core/tests/internal/context/EclipseLink1_1ContextModelTestCase.java index 1dadc77fdb..8ac5a5e8e2 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink1_1/core/tests/internal/context/EclipseLink1_1ContextModelTestCase.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink1_1/core/tests/internal/context/EclipseLink1_1ContextModelTestCase.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 @@ -11,7 +11,7 @@ package org.eclipse.jpt.eclipselink1_1.core.tests.internal.context; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProperties; -import org.eclipse.jpt.eclipselink.core.internal.v1_1.EclipseLink1_1JpaPlatformProvider; +import org.eclipse.jpt.eclipselink.core.platform.EclipseLinkPlatform; import org.eclipse.jpt.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase; import org.eclipse.wst.common.frameworks.datamodel.IDataModel; @@ -26,7 +26,7 @@ public abstract class EclipseLink1_1ContextModelTestCase extends EclipseLinkCont @Override protected IDataModel buildJpaConfigDataModel() { IDataModel dataModel = super.buildJpaConfigDataModel(); - dataModel.setProperty(JpaFacetInstallDataModelProperties.PLATFORM_ID, EclipseLink1_1JpaPlatformProvider.ID); + dataModel.setProperty(JpaFacetInstallDataModelProperties.PLATFORM_ID, EclipseLinkPlatform.VERSION_1_1.getId()); dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE); return dataModel; } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink1_2/core/tests/internal/context/EclipseLink1_2ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink1_2/core/tests/internal/context/EclipseLink1_2ContextModelTestCase.java index 5b0cc23539..87e9ea866d 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink1_2/core/tests/internal/context/EclipseLink1_2ContextModelTestCase.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink1_2/core/tests/internal/context/EclipseLink1_2ContextModelTestCase.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 @@ -12,7 +12,7 @@ package org.eclipse.jpt.eclipselink1_2.core.tests.internal.context; import org.eclipse.jpt.core.internal.facet.JpaFacetDataModelProperties; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProperties; -import org.eclipse.jpt.eclipselink.core.internal.v1_2.EclipseLink1_2JpaPlatformProvider; +import org.eclipse.jpt.eclipselink.core.platform.EclipseLinkPlatform; import org.eclipse.jpt.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase; import org.eclipse.wst.common.frameworks.datamodel.IDataModel; @@ -27,7 +27,7 @@ public abstract class EclipseLink1_2ContextModelTestCase extends EclipseLinkCont @Override protected IDataModel buildJpaConfigDataModel() { IDataModel dataModel = super.buildJpaConfigDataModel(); - dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, EclipseLink1_2JpaPlatformProvider.ID); + dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, EclipseLinkPlatform.VERSION_1_2.getId()); dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE); return dataModel; } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/EclipseLink2_0ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/EclipseLink2_0ContextModelTestCase.java index f6a0ea0b7a..641d44b80a 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/EclipseLink2_0ContextModelTestCase.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/EclipseLink2_0ContextModelTestCase.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 @@ -13,7 +13,7 @@ package org.eclipse.jpt.eclipselink2_0.core.tests.internal.context; import org.eclipse.jpt.core.JpaFacet; import org.eclipse.jpt.core.internal.facet.JpaFacetDataModelProperties; import org.eclipse.jpt.core.internal.facet.JpaFacetInstallDataModelProperties; -import org.eclipse.jpt.eclipselink.core.internal.v2_0.EclipseLink2_0JpaPlatformProvider; +import org.eclipse.jpt.eclipselink.core.platform.EclipseLinkPlatform; import org.eclipse.jpt.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase; import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; import org.eclipse.wst.common.frameworks.datamodel.IDataModel; @@ -28,7 +28,7 @@ public abstract class EclipseLink2_0ContextModelTestCase extends EclipseLinkCont protected IDataModel buildJpaConfigDataModel() { IDataModel dataModel = super.buildJpaConfigDataModel(); dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, JpaFacet.VERSION_2_0.getVersionString()); - dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, EclipseLink2_0JpaPlatformProvider.ID); + dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, EclipseLinkPlatform.VERSION_2_0.getId()); dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE); return dataModel; } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/persistence/EclipseLink2_0PersistenceUnitTestCase.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/persistence/EclipseLink2_0PersistenceUnitTestCase.java index e58c430021..793f4491ac 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/persistence/EclipseLink2_0PersistenceUnitTestCase.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink2_0/core/tests/internal/context/persistence/EclipseLink2_0PersistenceUnitTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2009 Oracle. All rights reserved. +* 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 http://www.eclipse.org/legal/epl-v10.html. @@ -13,7 +13,7 @@ import org.eclipse.jpt.core.JpaFacet; import org.eclipse.jpt.core.internal.facet.JpaFacetDataModelProperties; import org.eclipse.jpt.core.tests.internal.context.persistence.PersistenceUnitTestCase; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit; -import org.eclipse.jpt.eclipselink.core.internal.v2_0.EclipseLink2_0JpaPlatformProvider; +import org.eclipse.jpt.eclipselink.core.platform.EclipseLinkPlatform; import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel; import org.eclipse.jpt.utility.model.value.PropertyValueModel; import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties; @@ -45,7 +45,7 @@ public abstract class EclipseLink2_0PersistenceUnitTestCase extends PersistenceU protected IDataModel buildJpaConfigDataModel() { IDataModel dataModel = super.buildJpaConfigDataModel(); dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, JpaFacet.VERSION_2_0.getVersionString()); - dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, EclipseLink2_0JpaPlatformProvider.ID); + dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM_ID, EclipseLinkPlatform.VERSION_2_0.getId()); return dataModel; } diff --git a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JpaPlatformUiExtensionTests.java b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JpaPlatformUiExtensionTests.java index 91d7edc374..3c7cb6eeee 100644 --- a/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JpaPlatformUiExtensionTests.java +++ b/jpa/tests/org.eclipse.jpt.ui.tests/src/org/eclipse/jpt/ui/tests/internal/platform/JpaPlatformUiExtensionTests.java @@ -12,7 +12,7 @@ package org.eclipse.jpt.ui.tests.internal.platform; import junit.framework.TestCase; import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.core.internal.JpaPlatformRegistry; +import org.eclipse.jpt.core.internal.platform.JpaPlatformManagerImpl; import org.eclipse.jpt.core.tests.extension.resource.ExtensionTestPlugin; import org.eclipse.jpt.core.tests.extension.resource.TestJpaPlatformProvider; import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject; @@ -60,7 +60,6 @@ public class JpaPlatformUiExtensionTests extends TestCase } public void testJpaPlatform() { - assertNotNull(JpaPlatformRegistry.instance().getJpaPlatform(this.testProject.getProject())); + assertNotNull(JpaPlatformManagerImpl.instance().buildJpaPlatformImplementation(this.testProject.getProject())); } - } |