Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2011-05-12 14:51:45 +0000
committerpfullbright2011-05-12 14:51:45 +0000
commitfe85489be9890c0e73578aefc2c4aac30788a2fc (patch)
treeceb05845b81c42ce6ab2f82c4ef8a21c61d7d65f
parentf3839df4f3b3b266e76201593d47d50cfd40ddd2 (diff)
downloadwebtools.dali-fe85489be9890c0e73578aefc2c4aac30788a2fc.tar.gz
webtools.dali-fe85489be9890c0e73578aefc2c4aac30788a2fc.tar.xz
webtools.dali-fe85489be9890c0e73578aefc2c4aac30788a2fc.zip
bug 345453 - altered library validation for jaxb 2.2/java 1.6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.properties2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml1
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties9
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallDataModelProvider.java14
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/GenericJaxbUserLibraryValidator.java80
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/JaxbJreLibraryValidator.java30
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/JaxbLibValUtil.java25
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/libval/ELJaxbUserLibraryValidator.java4
9 files changed, 146 insertions, 26 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.properties
index 1879b02379..f5d65fa9c4 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.properties
@@ -29,6 +29,6 @@ JAXB_TEMPLATE_LABEL = JAXB Project
JAXB_NO_OP_LIBRARY_PROVIDER_MESSAGE = The JAXB facet requires a JAXB implementation library to be present on the project classpath. By disabling library configuration, the user takes on the responsibility of ensuring that the classpath is configured appropriately via alternate means.
JAXB_JRE_LIBRARY_PROVIDER_LABEL = JRE
-JAXB_JRE_LIBRARY_PROVIDER_MESSAGE = The project JRE provides the annotations and implementation to support the chosen JAXB version.
+JAXB_JRE_LIBRARY_PROVIDER_MESSAGE = The project JRE provides the annotations and implementation to support the chosen JAXB platform.
JAXB_VALIDATOR = JAXB Validator
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml b/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml
index adc429c2aa..72b573e81d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml
@@ -254,6 +254,7 @@
<project-facet id="jpt.jaxb">
<label>%JAXB_FACET_LABEL</label>
<description>%JAXB_FACET_DESCRIPTION</description>
+ <default-version version="2.1"/>
</project-facet>
<project-facet-version facet="jpt.jaxb" version="2.1">
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties
index 0688655614..b6ec79e1ec 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties
@@ -16,7 +16,12 @@ ClassesGenerator_generatingClassesTask = Generating classes
JaxbFacetConfig_validatePlatformNotSpecified = Platform must be specified
JaxbFacetConfig_validatePlatformDoesNotSupportFacetVersion = Platform does not support the current JAXB facet version
-JreLibraryValidator_invalidPlatform = Project JRE does not support the current JAXB platform.
-JreLibraryValidator_invalidJreJaxbVersion = Project JRE does not support the current JAXB version.
+JreLibraryValidator_invalidPlatform = The JRE only provides implementation for a Generic JAXB platform.
+JreLibraryValidator_invalidJavaFacet = The specified Java version of {0} is insufficient to provide an implementation for JAXB version {1}. The JAXB implementation of a Java {0} runtime environment must be manually overridden by an endorsement mechanism of your choice.
+JreLibraryValidator_invalidJavaLibrary = The configured runtime is insufficient to provide an implementation for JAXB {0}.
+
+UserLibraryValidator_incompatibleJavaFacet = The specified Java version of {0} provides a JAXB implementation that conflicts with JAXB version {1}. The JAXB implementation of a Java {0} runtime environment must be manually overridden by an endorsement mechanism of your choice.
+UserLibraryValidator_incompatibleJavaLibrary = The configured runtime conflicts with JAXB version {0}.
+UserLibraryValidator_noXjcClasses = Cannot detect XJC classes in library. Class generation may not work as a result.
PREFERENCES_FLUSH_JOB_NAME=Flush Preferences: {0}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java
index b8dd9e9dfb..4c07f54140 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java
@@ -23,7 +23,12 @@ public class JptJaxbCoreMessages {
public static String JaxbFacetConfig_validatePlatformDoesNotSupportFacetVersion;
public static String JreLibraryValidator_invalidPlatform;
- public static String JreLibraryValidator_invalidJreJaxbVersion;
+ public static String JreLibraryValidator_invalidJavaFacet;
+ public static String JreLibraryValidator_invalidJavaLibrary;
+
+ public static String UserLibraryValidator_incompatibleJavaFacet;
+ public static String UserLibraryValidator_incompatibleJavaLibrary;
+ public static String UserLibraryValidator_noXjcClasses;
public static String PREFERENCES_FLUSH_JOB_NAME;
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallDataModelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallDataModelProvider.java
index 40e26c3349..cf5d982cf8 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallDataModelProvider.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallDataModelProvider.java
@@ -17,4 +17,18 @@ public class JaxbFacetInstallDataModelProvider
public JaxbFacetInstallDataModelProvider() {
super();
}
+
+
+ @Override
+ public boolean propertySet(String propertyName, Object propertyValue) {
+ boolean ok = super.propertySet(propertyName, propertyValue);
+
+ if (propertyName.equals(FACET_VERSION)) {
+ if (! getPlatform().supportsJaxbFacetVersion(getProjectFacetVersion())) {
+ getDataModel().setProperty(PLATFORM, null);
+ }
+ }
+
+ return ok;
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/GenericJaxbUserLibraryValidator.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/GenericJaxbUserLibraryValidator.java
index 762a8c98e6..321f828d9b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/GenericJaxbUserLibraryValidator.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/GenericJaxbUserLibraryValidator.java
@@ -13,13 +13,17 @@ import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jpt.common.core.internal.libval.LibValUtil;
import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.common.core.libval.LibraryValidator;
import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
import org.eclipse.jpt.jaxb.core.JaxbFacet;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
import org.eclipse.jpt.jaxb.core.internal.libprov.JaxbUserLibraryProviderInstallOperationConfig;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
public class GenericJaxbUserLibraryValidator
@@ -30,27 +34,73 @@ public class GenericJaxbUserLibraryValidator
JaxbUserLibraryProviderInstallOperationConfig jaxbConfig
= (JaxbUserLibraryProviderInstallOperationConfig) config;
- IProjectFacetVersion jreJaxbVersion = JaxbLibValUtil.findJreJaxbVersion(jaxbConfig);
IProjectFacetVersion jaxbVersion = config.getProjectFacetVersion();
+ IProjectFacetVersion javaVersion = JaxbLibValUtil.getJavaVersion(jaxbConfig);
+ IProjectFacetVersion javaJaxbVersion = JaxbLibValUtil.findJavaJaxbVersion(jaxbConfig);
- Set<String> classNames = new HashSet<String>();
+ Iterable<IPath> libraryPaths =
+ new TransformationIterable<IClasspathEntry, IPath>(jaxbConfig.resolve()) {
+ @Override
+ protected IPath transform(IClasspathEntry o) {
+ return o.getPath();
+ }
+ };
- if (jreJaxbVersion == null) {
+ // dev-time portion of validation - error if actual java library *conflicts with* jaxb facet
+ // or if library does not provide supplemental classes
+
+ IProjectFacetVersion jreJaxbVersion = JaxbLibValUtil.findJreJaxbVersion(jaxbConfig);
+
+ // null here implies something prior to jaxb 2.1
+ if (jreJaxbVersion != null) {
+ if (jreJaxbVersion.compareTo(jaxbVersion) < 0) {
+ String message = NLS.bind(
+ JptJaxbCoreMessages.UserLibraryValidator_incompatibleJavaLibrary,
+ new String[] {jaxbVersion.getVersionString()});
+ return new Status(IStatus.ERROR, JptJaxbCorePlugin.PLUGIN_ID, message);
+ }
+ }
+ // if jre is enough for jaxb version, we don't look for classes in the library
+ else {
+ Set<String> classNames = new HashSet<String>();
+
classNames.add("javax.xml.bind.annotation.XmlSeeAlso"); //$NON-NLS-1$
+ if (jaxbVersion.compareTo(JaxbFacet.VERSION_2_2) >= 0) {
+ classNames.add("javax.xml.bind.JAXBPermission"); //$NON-NLS-1$
+ }
+
+ IStatus status = LibValUtil.validate(libraryPaths, classNames);
+
+ if (! status.isOK()) {
+ return status;
+ }
+ }
+
+ // runtime portion of validation - warn if java facet is insufficient to provide jaxb api.
+ // user may override implementation manually, however
+ // assume 1.6 runtime environs are latest (with jaxb 2.1, not 2.0)
+
+ // null here implies something prior to jaxb 2.1
+ if (javaJaxbVersion != null && javaJaxbVersion.compareTo(jaxbVersion) < 0) {
+ String message = NLS.bind(
+ JptJaxbCoreMessages.UserLibraryValidator_incompatibleJavaFacet,
+ new String[] {javaVersion.getVersionString(), jaxbVersion.getVersionString()});
+ return new Status(IStatus.WARNING, JptJaxbCorePlugin.PLUGIN_ID, message);
}
- if (jaxbVersion.compareTo(JaxbFacet.VERSION_2_2) >= 0
- && (jreJaxbVersion == null || jreJaxbVersion.compareTo(JaxbFacet.VERSION_2_2) < 0)) {
- classNames.add("javax.xml.bind.JAXBPermission"); //$NON-NLS-1$
+
+ // finally look for xjc classes
+
+ Set<String> classNames = new HashSet<String>();
+
+ classNames.add("com.sun.tools.xjc.XJCFacade"); //$NON-NLS-1$
+ classNames.add("com.sun.xml.bind.Util"); //$NON-NLS-1$
+
+ IStatus status = LibValUtil.validate(libraryPaths, classNames);
+
+ if (! status.isOK()) {
+ return new Status(IStatus.WARNING, JptJaxbCorePlugin.PLUGIN_ID, JptJaxbCoreMessages.UserLibraryValidator_noXjcClasses);
}
- Iterable<IPath> libraryPaths =
- new TransformationIterable<IClasspathEntry, IPath>(jaxbConfig.resolve()) {
- @Override
- protected IPath transform(IClasspathEntry o) {
- return o.getPath();
- }
- };
-
- return LibValUtil.validate(libraryPaths, classNames);
+ return Status.OK_STATUS;
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/JaxbJreLibraryValidator.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/JaxbJreLibraryValidator.java
index 462dd9ac4e..7701da3606 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/JaxbJreLibraryValidator.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/JaxbJreLibraryValidator.java
@@ -17,6 +17,7 @@ import org.eclipse.jpt.jaxb.core.GenericJaxbPlatform;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
import org.eclipse.jpt.jaxb.core.libprov.JaxbLibraryProviderInstallOperationConfig;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@@ -32,13 +33,36 @@ public class JaxbJreLibraryValidator
return new Status(IStatus.ERROR, JptJaxbCorePlugin.PLUGIN_ID, JptJaxbCoreMessages.JreLibraryValidator_invalidPlatform);
}
- IProjectFacetVersion jreJaxbVersion = JaxbLibValUtil.findJreJaxbVersion(jaxbConfig);
IProjectFacetVersion jaxbVersion = config.getProjectFacetVersion();
-
+ IProjectFacetVersion javaVersion = JaxbLibValUtil.getJavaVersion(jaxbConfig);
+ IProjectFacetVersion javaJaxbVersion = JaxbLibValUtil.findJavaJaxbVersion(jaxbConfig);
+
+ // dev-time portion of validation - error if actual java library does not support jaxb facet
+
+ IProjectFacetVersion jreJaxbVersion = JaxbLibValUtil.findJreJaxbVersion(jaxbConfig);
+
+ // null here implies something prior to jaxb 2.1
if (jreJaxbVersion == null || jreJaxbVersion.compareTo(jaxbVersion) < 0) {
- return new Status(IStatus.ERROR, JptJaxbCorePlugin.PLUGIN_ID, JptJaxbCoreMessages.JreLibraryValidator_invalidJreJaxbVersion);
+ String message = NLS.bind(
+ JptJaxbCoreMessages.JreLibraryValidator_invalidJavaLibrary,
+ new String[] {jaxbVersion.getVersionString()});
+ return new Status(IStatus.ERROR, JptJaxbCorePlugin.PLUGIN_ID, message);
}
+ // runtime portion of validation - warn if java facet is insufficient to provide jaxb api.
+ // user may override implementation manually, however
+ // assume 1.6 runtime environs are latest (with jaxb 2.1, not 2.0)
+
+ // null here implies something prior to jaxb 2.1
+ if (javaJaxbVersion == null || javaJaxbVersion.compareTo(jaxbVersion) < 0) {
+ String message = NLS.bind(
+ JptJaxbCoreMessages.JreLibraryValidator_invalidJavaFacet,
+ new String[] {javaVersion.getVersionString(), jaxbVersion.getVersionString()});
+ return new Status(IStatus.WARNING, JptJaxbCorePlugin.PLUGIN_ID, message);
+ }
+
+ // TODO - check for xjc classes when we support jdk version of xjc
+
return Status.OK_STATUS;
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/JaxbLibValUtil.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/JaxbLibValUtil.java
index b37f6b5fbe..ce5d0ab6bb 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/JaxbLibValUtil.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libval/JaxbLibValUtil.java
@@ -12,7 +12,6 @@ package org.eclipse.jpt.jaxb.core.internal.libval;
import java.io.File;
import java.io.IOException;
import java.util.zip.ZipFile;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IJavaProject;
@@ -26,6 +25,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
import org.eclipse.jpt.jaxb.core.JaxbFacet;
import org.eclipse.jpt.jaxb.core.libprov.JaxbLibraryProviderInstallOperationConfig;
+import org.eclipse.jst.common.project.facet.core.JavaFacet;
import org.eclipse.jst.common.project.facet.core.StandardJreRuntimeComponent;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
@@ -34,6 +34,27 @@ import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
public class JaxbLibValUtil {
+ static IProjectFacetVersion getJavaVersion(JaxbLibraryProviderInstallOperationConfig config) {
+ return config.getFacetedProject().getProjectFacetVersion(JavaFacet.FACET);
+ }
+
+ /**
+ * Return jaxb version determined by java facet version.
+ * Assume highest update of java (i.e. java 1.6 maps to jaxb 2.1)
+ */
+ static IProjectFacetVersion findJavaJaxbVersion(JaxbLibraryProviderInstallOperationConfig config) {
+ IProjectFacetVersion javaVersion = getJavaVersion(config);
+
+ if (javaVersion == JavaFacet.VERSION_1_6) {
+ return JaxbFacet.VERSION_2_1;
+ }
+ else if (javaVersion == JavaFacet.VERSION_1_7) {
+ return JaxbFacet.VERSION_2_2;
+ }
+
+ return null;
+ }
+
static IProjectFacetVersion findJreJaxbVersion(JaxbLibraryProviderInstallOperationConfig config) {
IRuntime runtime = config.getFacetedProject().getPrimaryRuntime();
@@ -88,10 +109,10 @@ public class JaxbLibValUtil {
if (vm instanceof IVMInstall2) {
String javaVersion = ((IVMInstall2) vm).getJavaVersion();
if (javaVersion != null) {
+ // all other versions except 1.7 and 1.6 have no corresponding version (as of yet)
if (javaVersion.startsWith(JavaCore.VERSION_1_7)) {
return JaxbFacet.VERSION_2_2;
}
- // all other versions except 1.6 have no corresponding version (as of yet)
// 1.6 must be further analyzed
if (! javaVersion.startsWith(JavaCore.VERSION_1_6)) {
return null;
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/libval/ELJaxbUserLibraryValidator.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/libval/ELJaxbUserLibraryValidator.java
index f29a274454..bc2ee5609e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/libval/ELJaxbUserLibraryValidator.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/libval/ELJaxbUserLibraryValidator.java
@@ -40,10 +40,10 @@ public class ELJaxbUserLibraryValidator
if (ELJaxbPlatform.VERSION_2_1.equals(platform)) {
versionRanges.add(new VersionRange("[2.1, 3.0)")); //$NON-NLS-1$
}
- if (ELJaxbPlatform.VERSION_2_2.equals(platform)) {
+ else if (ELJaxbPlatform.VERSION_2_2.equals(platform)) {
versionRanges.add(new VersionRange("[2.2, 3.0)")); //$NON-NLS-1$
}
- if (ELJaxbPlatform.VERSION_2_3.equals(platform)) {
+ else if (ELJaxbPlatform.VERSION_2_3.equals(platform)) {
versionRanges.add(new VersionRange("[2.3, 3.0)")); //$NON-NLS-1$
}

Back to the top