Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/META-INF/MANIFEST.MF5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/GenericJaxbProjectManager.java3
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java30
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbNode.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java249
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java24
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextNode.java46
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackage.java33
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackageInfo.java35
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRootContextNode.java46
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrder.java66
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrderHolder.java59
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessType.java72
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessTypeHolder.java59
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java25
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbNode.java16
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java873
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractSynchronizerJaxbProjectUpdater.java67
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AsynchronousJaxbProjectUpdater.java63
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SynchronousJaxbProjectUpdater.java49
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/AbstractJaxbContextNode.java47
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/ContextContainerTools.java134
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericPackage.java54
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericRootContextNode.java146
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java126
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallConfig.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformManagerImpl.java3
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullAnnotation.java78
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlAccessorOrderAnnotation.java56
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlAccessorTypeAnnotation.java56
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlAccessorOrderAnnotationDefinition.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlAccessorTypeAnnotationDefinition.java2
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/META-INF/MANIFEST.MF5
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/JptJaxbCoreTestsPlugin.java9
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/JaxbCoreTests.java2
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbContextModelTestCase.java47
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbCoreContextModelTests.java31
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java153
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java28
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/projects/TestJaxbProject.java20
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAccessorTypePackageAnnotationTests.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractSynchronizerJpaProjectUpdater.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AsynchronousJpaProjectUpdater.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SynchronousJpaProjectUpdater.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/CallbackJobSynchronizer.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/JobSynchronizer.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF3
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/AsynchronousSynchronizer.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackAsynchronousSynchronizer.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackSynchronousSynchronizer.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/SynchronousSynchronizer.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/synchronizers/CallbackSynchronizer.java (renamed from jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackSynchronizer.java)45
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/synchronizers/Synchronizer.java (renamed from jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/Synchronizer.java)4
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java11
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/AsynchronousSynchronizerTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronizerTests.java5
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java2
57 files changed, 2131 insertions, 793 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/META-INF/MANIFEST.MF b/jaxb/plugins/org.eclipse.jpt.jaxb.core/META-INF/MANIFEST.MF
index a2093b389f..0748348e98 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/META-INF/MANIFEST.MF
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/META-INF/MANIFEST.MF
@@ -16,11 +16,14 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.100,4.0.0)",
org.eclipse.jpt.core;bundle-version="[2.4.0,3.0.0)",
org.eclipse.jpt.utility;bundle-version="[1.6.0,2.0.0)",
org.eclipse.jst.common.project.facet.core;bundle-version="[1.4.200,2.0.0)",
- org.eclipse.jst.j2ee;bundle-version="1.1.402",
+ org.eclipse.jst.j2ee;bundle-version="[1.1.402,2.0.0)",
org.eclipse.wst.common.frameworks;bundle-version="[1.1.200,2.0.0)",
org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.200,2.0.0)"
Export-Package: org.eclipse.jpt.jaxb.core,
+ org.eclipse.jpt.jaxb.core.context,
org.eclipse.jpt.jaxb.core.internal;x-internal:=true,
+ org.eclipse.jpt.jaxb.core.internal.context;x-internal:=true,
+ org.eclipse.jpt.jaxb.core.internal.context.java;x-internal:=true,
org.eclipse.jpt.jaxb.core.internal.facet;x-internal:=true,
org.eclipse.jpt.jaxb.core.internal.gen;x-internal:=true,
org.eclipse.jpt.jaxb.core.internal.jaxb21;x-internal:=true,
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/GenericJaxbProjectManager.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/GenericJaxbProjectManager.java
index 05fc49619d..4572a92cac 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/GenericJaxbProjectManager.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/GenericJaxbProjectManager.java
@@ -30,7 +30,6 @@ import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IElementChangedListener;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.core.internal.JptCoreMessages;
-import org.eclipse.jpt.jaxb.core.internal.AsynchronousJaxbProjectUpdater;
import org.eclipse.jpt.jaxb.core.internal.SimpleJaxbProjectConfig;
import org.eclipse.jpt.jaxb.core.internal.platform.JaxbPlatformImpl;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatform;
@@ -379,7 +378,7 @@ class GenericJaxbProjectManager
if (jaxbProject == null) {
return null;
}
- jaxbProject.setUpdater(new AsynchronousJaxbProjectUpdater(jaxbProject));
+// jaxbProject.setUpdateSynchronizer(new CallbackAsynchronousSynchronizer());
return jaxbProject;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java
index 308b9a684b..ae18424f1a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java
@@ -15,6 +15,10 @@ import org.eclipse.jpt.core.JpaResourceModel;
import org.eclipse.jpt.core.context.java.JavaEntity;
import org.eclipse.jpt.core.context.orm.EntityMappings;
import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
+import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
/**
* Use a JAXB factory to build any core (e.g. {@link JaxbProject})
@@ -62,15 +66,19 @@ public interface JaxbFactory
* and resource model.
*/
JaxbFile buildJaxbFile(JaxbProject jaxbProject, IFile file, IContentType contentType, JpaResourceModel resourceModel);
-
-//
-// // ********** Context Nodes **********
-//
-// /**
-// * Build a (/an updated) root context node to be associated with the given
-// * JAXB project.
-// * The root context node will be built once, but updated many times.
-// * @see JaxbProject#update(org.eclipse.core.runtime.IProgressMonitor)
-// */
-// JaxbRootContextNode buildRootContextNode(JaxbProject jaxbProject);
+
+
+ // ********** Context Nodes **********
+
+ /**
+ * Build a (/an updated) root context node to be associated with the given
+ * JAXB project.
+ * The root context node will be built once, but updated many times.
+ * @see JaxbProject#update(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ JaxbRootContextNode buildRootContextNode(JaxbProject jaxbProject);
+
+ JaxbPackage buildPackage(JaxbRootContextNode parent, JavaResourcePackage resourcePackage);
+
+ JaxbPackageInfo buildJavaPackageInfo(JaxbPackage parent, JavaResourcePackage resourcePackage);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbNode.java
index f2710a1d18..9d295cadd5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbNode.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbNode.java
@@ -14,8 +14,8 @@ import org.eclipse.jpt.core.IResourcePart;
import org.eclipse.jpt.utility.model.Model;
/**
- * JPA-specific protocol. All JPA objects belong to a JPA project, are
- * associated with a resource, and have a parent (excepting the JPA project).
+ * JAXB-specific protocol. All JAXB objects belong to a JAXB project, are
+ * associated with a resource, and have a parent (excepting the JAXB project).
*
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
@@ -38,4 +38,6 @@ public interface JaxbNode
* Return the JAXB node's parent. The JAXB project will not have a parent.
*/
JaxbNode getParent();
+
+ void stateChanged();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java
index 3c026b4eef..8278721d2d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java
@@ -16,8 +16,13 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatform;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.utility.CommandExecutor;
+import org.eclipse.jpt.utility.synchronizers.CallbackSynchronizer;
+import org.eclipse.jpt.utility.synchronizers.Synchronizer;
/**
* A JAXB project is associated with an Eclipse project (and its corresponding
@@ -64,11 +69,11 @@ public interface JaxbProject
* and its contents.
*/
JaxbPlatform getJaxbPlatform();
-//
-// /**
-// * Return the root of the JPA project's context model.
-// */
-// JpaRootContextNode getRootContextNode();
+
+ /**
+ * Return the root of the JAXB project's context model.
+ */
+ JaxbRootContextNode getRootContextNode();
/**
* The JAXB project has been removed from the JJAXBPA model. Clean up any
@@ -129,69 +134,38 @@ public interface JaxbProject
// */
// JavaResourcePersistentTypeCache getExternalJavaResourcePersistentTypeCache();
//
-//
-// // ********** XML resources **********
-//
-// /**
-// * Return the XML resource model corresponding to the file with runtime path
-// * <code>META-INF/persistence.xml</code> if that file has the persistence content type
-// * (<code>"org.eclipse.jpt.core.content.persistence"</code>).
-// *
-// * @see JptCorePlugin#DEFAULT_PERSISTENCE_XML_RUNTIME_PATH
-// * @see JptCorePlugin#PERSISTENCE_XML_CONTENT_TYPE
-// */
-// JpaXmlResource getPersistenceXmlResource();
-//
-// /**
-// * Return the XML resource model corresponding to the file with the specified
-// * runtime path if that file has the mapping file content type
-// * (<code>"org.eclipse.jpt.core.content.mappingFile"</code>)
-// *
-// * @see JptCorePlugin#MAPPING_FILE_CONTENT_TYPE
-// */
-// JpaXmlResource getMappingFileXmlResource(IPath runtimePath);
-//
-// /**
-// * Return the XML resource model corresponding to the file
-// * <code>META-INF/orm.xml</code> if that file has the mapping file content type.
-// *
-// * @see JptCorePlugin#DEFAULT_ORM_XML_RUNTIME_PATH
-// */
-// JpaXmlResource getDefaultOrmXmlResource();
-//
-//
-// // ********** Java resources **********
-//
-// /**
-// * Return the names of the JPA project's annotated Java classes
-// * (ignoring classes in JARs referenced in the persistence.xml).
-// */
-// Iterator<String> annotatedJavaSourceClassNames();
-//
-// /**
-// * Return the names of the JPA project's mapped (i.e. annotated with @Entity, etc.) Java
-// * classes (ignoring classes in JARs referenced in the persistence.xml).
-// */
-// Iterable<String> getMappedJavaSourceClassNames();
-//
-// /**
-// * Return the Java resource persistent type for the specified type.
-// * Return null if invalid or absent.
-// */
-// JavaResourcePersistentType getJavaResourcePersistentType(String typeName);
-//
-// /**
-// * Return the Java resource package for the specified package.
-// * Return null if invalid or absent.
-// */
-// JavaResourcePackage getJavaResourcePackage(String packageName);
-//
-// /**
-// * Return the Java resource packages for the project.
-// * Return null if invalid or absent.
-// */
-// Iterable<JavaResourcePackage> getJavaResourcePackages();
-//
+
+ // ********** Java resources **********
+
+ /**
+ * Return the names of the JAXB project's annotated Java classes
+ */
+ Iterable<String> getAnnotatedJavaSourceClassNames();
+
+ /**
+ * Return the Java resource persistent type for the specified type.
+ * Return null if invalid or absent.
+ */
+ JavaResourceType getJavaResourceType(String typeName);
+
+ /**
+ * Return the Java resource package for the specified package.
+ * Return null if invalid or absent.
+ */
+ JavaResourcePackage getJavaResourcePackage(String packageName);
+
+ /**
+ * Return the Java resource packages for the project.
+ * Return null if invalid or absent. These correspond to package-info.java files
+ */
+ Iterable<JavaResourcePackage> getJavaResourcePackages();
+
+ /**
+ * Return the java resource packages that are annotated with
+ * 1 or more valid JAXB package annotations
+ */
+ Iterable<JavaResourcePackage> getAnnotatedJavaResourcePackages();
+
// /**
// * Return the Java resource package fragement root for the specified JAR.
// * Return null if absent.
@@ -213,106 +187,91 @@ public interface JaxbProject
void javaElementChanged(ElementChangedEvent event);
- // ********** synchronize context model with resource model **********
-
- void synchronizeContextModel();
-
- // ********** project "update" **********
+ // ********** synchronize context model with resource model **********
/**
- * Return the implementation of the Updater
- * interface that will be used to "update" the JPA project.
+ * Return the synchronizer that will synchronize the context model with
+ * the resource model whenever the resource model changes.
*/
- Updater getUpdater();
+ Synchronizer getContextModelSynchronizer();
/**
- * Set the implementation of the Updater
- * interface that will be used to "update" the JPA project.
- * Before setting the updater, clients should save the current updater so
- * it can be restored later.
+ * Set the synchronizer that will keep the context model synchronized with
+ * the resource model whenever the resource model changes.
+ * Before setting the synchronizer, clients should save the current
+ * synchronizer so it can be restored later.
+ *
+ * @see #getContextModelSynchronizer()
*/
- void setUpdater(Updater updater);
+ void setContextModelSynchronizer(Synchronizer synchronizer);
/**
- * The JPA project's state has changed, "update" those parts of the
- * JPA project that are dependent on other parts of the JPA project.
- * This is called when<ul>
- * <li>(almost) any state in the JPA project changes
- * <li>the JPA project's database connection is changed, opened, or closed
- * </ul>
+ * The JAXB project's resource model has changed; synchronize the JPA
+ * project's context model with it. This method is typically called when the
+ * resource model state has changed when it is synchronized with its
+ * underlying Eclipse resource as the result of an Eclipse resource change
+ * event. This method can also be called when a client (e.g. a JUnit test
+ * case) has manipulated the resource model via its API (as opposed to
+ * modifying the underlying Eclipse resource directly) and needs the context
+ * model to be synchronized accordingly (since manipulating the resource
+ * model via its API will not trigger this method). Whether the context
+ * model is synchronously (or asynchronously) depends on the current context
+ * model synchronizer.
+ *
+ * @see #synchronizeContextModelAndWait()
*/
- void update();
+ void synchronizeContextModel();
/**
- * This is the callback used by the updater to perform the actual
- * "update", which most likely will happen asynchronously.
+ * Force the JAXB project's context model to synchronize with it resource
+ * model <em>synchronously</em>.
+ *
+ * @see #synchronizeContextModel()
+ * @see #updateAndWait()
*/
- IStatus update(IProgressMonitor monitor);
+ void synchronizeContextModelAndWait();
/**
- * This is the callback used by the updater to notify the JPA project that
- * the "update" has quiesced (i.e. the "update" has completed and there
- * are no outstanding requests for further "updates").
+ * This is the callback used by the context model synchronizer to perform
+ * the actual "synchronize".
*/
- void updateQuiesced();
+ IStatus synchronizeContextModel(IProgressMonitor monitor);
+ // ********** project "update" **********
/**
- * Define a strategy that can be used to "update" a JPA project whenever
- * something changes.
+ * Return the synchronizer that will update the context model whenever
+ * it has any changes. This allows any intra-JAXB project dependencies to
+ * be updated.
*/
- interface Updater {
+ CallbackSynchronizer getUpdateSynchronizer();
- /**
- * The updater has just been assigned to its JPA project.
- */
- void start();
+ /**
+ * Set the synchronizer that will update the context model whenever
+ * it has any changes. This allows any intra-JAXB project dependencies to
+ * be updated.
+ * Before setting the update synchronizer, clients should save the current
+ * synchronizer so it can be restored later.
+ *
+ * @see #getUpdateSynchronizer()
+ */
+ void setUpdateSynchronizer(CallbackSynchronizer synchronizer);
- /**
- * Update the JPA project.
- * <p>
- * {@link JaxbProject#update()} will call {@link Updater#update()},
- * from which the updater is to call {@link JaxbProject#update(IProgressMonitor)}
- * as appropriate (typically from an asynchronously executing job).
- * Once the updating has quiesced (i.e. there are no outstanding requests
- * for another update), the updater is to call {@link JaxbProject#updateQuiesced()}.
- */
- void update();
+ /**
+ * Force the JAXB project to "update" <em>synchronously</em>.
+ *
+ * @see #synchronizeContextModelAndWait()
+ */
+ void updateAndWait();
- /**
- * The JPA project is disposed; stop the updater.
- */
- void stop();
+ /**
+ * This is the callback used by the update synchronizer to perform the
+ * actual "update".
+ */
+ IStatus update(IProgressMonitor monitor);
- /**
- * This updater does nothing. Useful for testing.
- */
- final class Null implements Updater {
- private static final Updater INSTANCE = new Null();
- public static Updater instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void start() {
- // do nothing
- }
- public void update() {
- // do nothing
- }
- public void stop() {
- // do nothing
- }
- @Override
- public String toString() {
- return "JpaProject.Updater.Null"; //$NON-NLS-1$
- }
- }
- }
// // ********** utility **********
@@ -359,12 +318,12 @@ public interface JaxbProject
interface Config {
/**
- * Return the Eclipse project to be associated with the new JPA project.
+ * Return the Eclipse project to be associated with the new JAXB project.
*/
IProject getProject();
/**
- * Return the JPA platform to be associated with the new JPA project.
+ * Return the JAXB platform to be associated with the new JAXB project.
*/
JaxbPlatform getJaxbPlatform();
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java
index b824d3e95e..6d4529d2e5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java
@@ -179,7 +179,29 @@ public class JptJaxbCorePlugin
}
return null;
}
-
+
+ /**
+ * Return the JAXB platform ID associated with the specified Eclipse project.
+ */
+ public static String getJaxbPlatformId(IProject project) {
+ return JptCorePlugin.getProjectPreferences(project).get(JAXB_PLATFORM_PREF_KEY, GenericJaxbPlatform.VERSION_2_1.getId());
+ }
+
+ /**
+ * Return the JAXB platform description associated with the specified Eclipse project.
+ */
+ public static JaxbPlatformDescription getJaxbPlatformDescription(IProject project) {
+ String jpaPlatformId = getJaxbPlatformId(project);
+ return getJaxbPlatformManager().getJaxbPlatform(jpaPlatformId);
+ }
+
+ /**
+ * Set the JAXB platform ID associated with the specified Eclipse project.
+ */
+ public static void setJaxbPlatformId(IProject project, String jpaPlatformId) {
+ JptCorePlugin.setProjectPreference(project, JAXB_PLATFORM_PREF_KEY, jpaPlatformId);
+ }
+
public static void clearProjectPreferences(IProject project) {
JptCorePlugin.clearProjectPreferences(project, JAXB_PLATFORM_PREF_KEY);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextNode.java
new file mode 100644
index 0000000000..0b9798ba06
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbContextNode.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.jaxb.core.context;
+
+import org.eclipse.jpt.core.JpaResourceType;
+import org.eclipse.jpt.jaxb.core.JaxbNode;
+
+/**
+ * Common protocol for JAXB objects that have a context, as opposed to
+ * resource objects.
+ * <p>
+ * 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 JaxbContextNode
+ extends JaxbNode
+{
+ /**
+ * Return the resource type of the context node's resource.
+ */
+ JpaResourceType getResourceType();
+
+
+ // ********** updating **********
+
+ void synchronizeWithResourceModel();
+
+ /**
+ * Update the context model with the content of the JAXB resource model.
+ */
+ void update();
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackage.java
new file mode 100644
index 0000000000..be286e8af9
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackage.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.jaxb.core.context;
+
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+
+/**
+ *
+ * <p>
+ * 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 JaxbPackage
+ extends JaxbContextNode
+{
+
+ JavaResourcePackage getResourcePackage();
+
+ JaxbPackageInfo getPackageInfo();
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackageInfo.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackageInfo.java
new file mode 100644
index 0000000000..9fcb67cd9f
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPackageInfo.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.context;
+
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+
+/**
+ *
+ * <p>
+ * 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 JaxbPackageInfo
+ extends
+ JaxbContextNode,
+ XmlAccessTypeHolder,
+ XmlAccessOrderHolder
+{
+
+ JavaResourcePackage getResourcePackage();
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRootContextNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRootContextNode.java
new file mode 100644
index 0000000000..cfc1065053
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRootContextNode.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.jaxb.core.context;
+
+/**
+ * Root of the Dali context model.
+ * <p>
+ * 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 JaxbRootContextNode
+ extends JaxbContextNode
+{
+
+ Iterable<JaxbPackage> getPackages();
+
+ int getPackagesSize();
+
+ /**
+ * String constant associated with changes to the packages property
+ * @see #addPropertyChangeListener(String, org.eclipse.jpt.utility.model.listener.PropertyChangeListener)
+ */
+ public final static String PACKAGES_COLLECTION = "packages"; //$NON-NLS-1$
+
+
+// // ********** validation **********
+//
+// /**
+// * Add validation messages to the specified list.
+// */
+// public void validate(List<IMessage> messages, IReporter reporter);
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrder.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrder.java
new file mode 100644
index 0000000000..7c3a887420
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrder.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.jaxb.core.context;
+
+/**
+ * Access Order
+ *
+ * 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 enum XmlAccessOrder {
+
+ ALPHABETICAL(
+ org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder.ALPHABETICAL
+ ),
+ UNDEFINED(
+ org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder.UNDEFINED
+ );
+
+
+ private org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder javaAccessOrder;
+
+ XmlAccessOrder(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder javaAccessOrder) {
+ if (javaAccessOrder == null) {
+ throw new NullPointerException();
+ }
+ this.javaAccessOrder = javaAccessOrder;
+ }
+
+ public org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder getJavaAccessOrder() {
+ return this.javaAccessOrder;
+ }
+
+
+ // ********** static methods **********
+
+ public static XmlAccessOrder fromJavaResourceModel(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder javaAccessOrder) {
+ return (javaAccessOrder == null) ? null : fromJavaResourceModel_(javaAccessOrder);
+ }
+
+ private static XmlAccessOrder fromJavaResourceModel_(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder javaAccessOrder) {
+ for (XmlAccessOrder accessOrder : XmlAccessOrder.values()) {
+ if (accessOrder.getJavaAccessOrder() == javaAccessOrder) {
+ return accessOrder;
+ }
+ }
+ return null;
+ }
+
+ public static org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder toJavaResourceModel(XmlAccessOrder accessOrder) {
+ return (accessOrder == null) ? null : accessOrder.getJavaAccessOrder();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrderHolder.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrderHolder.java
new file mode 100644
index 0000000000..8110846e90
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessOrderHolder.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.jaxb.core.context;
+
+
+/**
+ *
+ *
+ * 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 XmlAccessOrderHolder
+ extends JaxbContextNode
+{
+ /**
+ * Return the access order, whether specified or defaulted.
+ * This should never return null since at least the default will be set
+ */
+ XmlAccessOrder getAccessOrder();
+
+ /**
+ * Return the default access order, never null
+ */
+ XmlAccessOrder getDefaultAccessOrder();
+
+ /**
+ * String constant associated with changes to the default access order
+ */
+ String DEFAULT_ACCESS_ORDER_PROPERTY = "defaultAccessOrder"; //$NON-NLS-1$
+
+ /**
+ * Return the specified access order;
+ */
+ XmlAccessOrder getSpecifiedAccessOrder();
+
+ /**
+ * Set the specified access order.
+ */
+ void setSpecifiedAccessOrder(XmlAccessOrder newSpecifiedAccessOrder);
+
+ /**
+ * String constant associated with changes to the specified access order
+ */
+ String SPECIFIED_ACCESS_ORDER_PROPERTY = "specifiedAccessOrder"; //$NON-NLS-1$
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessType.java
new file mode 100644
index 0000000000..b2c8fd639a
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessType.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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.jaxb.core.context;
+
+/**
+ * Access Type
+ *
+ * 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 enum XmlAccessType {
+
+ FIELD(
+ org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.FIELD
+ ),
+ NONE(
+ org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.NONE
+ ),
+ PROPERTY(
+ org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.PROPERTY
+ ),
+ PUBLIC_MEMBER(
+ org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.PUBLIC_MEMBER
+ );
+
+
+ private org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType javaAccessType;
+
+ XmlAccessType(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType javaAccessType) {
+ if (javaAccessType == null) {
+ throw new NullPointerException();
+ }
+ this.javaAccessType = javaAccessType;
+ }
+
+ public org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType getJavaAccessType() {
+ return this.javaAccessType;
+ }
+
+
+ // ********** static methods **********
+
+ public static XmlAccessType fromJavaResourceModel(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType javaAccessType) {
+ return (javaAccessType == null) ? null : fromJavaResourceModel_(javaAccessType);
+ }
+
+ private static XmlAccessType fromJavaResourceModel_(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType javaAccessType) {
+ for (XmlAccessType accessType : XmlAccessType.values()) {
+ if (accessType.getJavaAccessType() == javaAccessType) {
+ return accessType;
+ }
+ }
+ return null;
+ }
+
+ public static org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType toJavaResourceModel(XmlAccessType accessType) {
+ return (accessType == null) ? null : accessType.getJavaAccessType();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessTypeHolder.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessTypeHolder.java
new file mode 100644
index 0000000000..986195e690
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/XmlAccessTypeHolder.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.jaxb.core.context;
+
+
+/**
+ *
+ *
+ * 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 XmlAccessTypeHolder
+ extends JaxbContextNode
+{
+ /**
+ * Return the access type, whether specified or defaulted.
+ * This should never return null since at least the default will be set
+ */
+ XmlAccessType getAccessType();
+
+ /**
+ * Return the default access type, never null
+ */
+ XmlAccessType getDefaultAccessType();
+
+ /**
+ * String constant associated with changes to the default access type
+ */
+ String DEFAULT_ACCESS_TYPE_PROPERTY = "defaultAccessType"; //$NON-NLS-1$
+
+ /**
+ * Return the specified access type;
+ */
+ XmlAccessType getSpecifiedAccessType();
+
+ /**
+ * Set the specified access type.
+ */
+ void setSpecifiedAccessType(XmlAccessType newSpecifiedAccessType);
+
+ /**
+ * String constant associated with changes to the specified access type
+ */
+ String SPECIFIED_ACCESS_TYPE_PROPERTY = "specifiedAccessType"; //$NON-NLS-1$
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
index 11f1b6370a..62582ab299 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
@@ -16,6 +16,13 @@ import org.eclipse.jpt.jaxb.core.JaxbFactory;
import org.eclipse.jpt.jaxb.core.JaxbFile;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JaxbProject.Config;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
+import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
+import org.eclipse.jpt.jaxb.core.internal.context.GenericPackage;
+import org.eclipse.jpt.jaxb.core.internal.context.GenericRootContextNode;
+import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPackageInfo;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
/**
* Central class that allows extenders to easily replace implementations of
@@ -39,9 +46,17 @@ public abstract class AbstractJaxbFactory
return new GenericJaxbFile(jaxbProject, file, contentType, resourceModel);
}
-// // ********** Context Nodes **********
-//
-// public JpaRootContextNode buildRootContextNode(JpaProject parent) {
-// return new GenericRootContextNode(parent);
-// }
+ // ********** Context Nodes **********
+
+ public JaxbRootContextNode buildRootContextNode(JaxbProject parent) {
+ return new GenericRootContextNode(parent);
+ }
+
+ public JaxbPackage buildPackage(JaxbRootContextNode parent, JavaResourcePackage resourcePackage) {
+ return new GenericPackage(parent, resourcePackage);
+ }
+
+ public JaxbPackageInfo buildJavaPackageInfo(JaxbPackage parent, JavaResourcePackage resourcePackage) {
+ return new GenericJavaPackageInfo(parent, resourcePackage);
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbNode.java
index fe52dc861b..757b76797e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbNode.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbNode.java
@@ -130,7 +130,7 @@ public abstract class AbstractJaxbNode
// String msg = Thread.currentThread() + " aspect change: " + this + ": " + aspectName;
// System.out.println(msg);
// new Exception(msg).printStackTrace(System.out);
- this.getJaxbProject().update();
+ this.stateChanged();
}
}
@@ -138,8 +138,11 @@ public abstract class AbstractJaxbNode
return ! this.aspectDoesNotTriggerUpdate(aspectName);
}
- private boolean aspectDoesNotTriggerUpdate(String aspectName) {
- return this.nonUpdateAspectNames().contains(aspectName);
+ protected boolean aspectDoesNotTriggerUpdate(String aspectName) {
+ // ignore state changes so we don't get a stack overflow :-)
+ // (and we don't use state changes except here)
+ return (aspectName == null) ||
+ this.nonUpdateAspectNames().contains(aspectName);
}
protected final Set<String> nonUpdateAspectNames() {
@@ -161,4 +164,11 @@ public abstract class AbstractJaxbNode
// super.addNonUpdateAspectNamesTo(nonUpdateAspectNames);
}
+ public void stateChanged() {
+ this.fireStateChanged();
+ if (this.parent != null) {
+ this.parent.stateChanged();
+ }
+ }
+
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
index 43e532c2bd..8379c872d9 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
@@ -20,6 +20,7 @@ import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jdt.core.ElementChangedEvent;
@@ -33,31 +34,41 @@ import org.eclipse.jpt.core.JpaResourceModelListener;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.internal.utility.PlatformTools;
import org.eclipse.jpt.core.resource.ResourceLocator;
-import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.core.resource.xml.JpaXmlResource;
import org.eclipse.jpt.jaxb.core.JaxbFile;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatform;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackageInfoCompilationUnit;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.utility.Command;
import org.eclipse.jpt.utility.CommandExecutor;
import org.eclipse.jpt.utility.internal.BitTools;
import org.eclipse.jpt.utility.internal.ThreadLocalCommandExecutor;
+import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
+import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronousSynchronizer;
+import org.eclipse.jpt.utility.internal.synchronizers.SynchronousSynchronizer;
+import org.eclipse.jpt.utility.synchronizers.CallbackSynchronizer;
+import org.eclipse.jpt.utility.synchronizers.Synchronizer;
/**
- * JPA project. Holds all the JPA stuff.
+ * JAXB project. Holds all the JAXB stuff.
*
- * The JPA platform provides the hooks for vendor-specific stuff.
+ * The JAXB platform provides the hooks for vendor-specific stuff.
*
- * The JPA files are the "resource" model (i.e. objects that correspond directly
+ * The JAXB files are the "resource" model (i.e. objects that correspond directly
* to Eclipse resources; e.g. Java source code files, XML files, JAR files).
*
- * The root context node is the "context"model (i.e. objects that attempt to
- * model the JPA spec, using the "resource" model as an adapter to the Eclipse
+ * The root context node is the "context" model (i.e. objects that attempt to
+ * model the JAXB spec, using the "resource" model as an adapter to the Eclipse
* resources).
- *
- * The data source is an adapter to the DTP meta-data model.
*/
public abstract class AbstractJaxbProject
extends AbstractJaxbNode
@@ -98,25 +109,42 @@ public abstract class AbstractJaxbProject
*/
protected final JpaResourceModelListener resourceModelListener;
-// /**
-// * The root of the model representing the collated resources associated with
-// * the JPA project.
-// */
-// protected final JpaRootContextNode rootContextNode;
+ /**
+ * The root of the model representing the collated resources associated with
+ * the JAXB project.
+ */
+ protected final JaxbRootContextNode rootContextNode;
+
+ /**
+ * A pluggable synchronizer that keeps the JAXB
+ * project's context model synchronized with its resource model, either
+ * synchronously or asynchronously (or not at all). A synchronous synchronizer
+ * is the default. For performance reasons, a UI should
+ * immediately change this to an asynchronous synchronizer. A synchronous
+ * synchronizer can be used when the project is being manipulated by a "batch"
+ * (or non-UI) client (e.g. when testing "synchronization"). A null updater
+ * can used during tests that do not care whether "synchronization" occur.
+ * Clients will need to explicitly configure the synchronizer if they require
+ * an asynchronous synchronizer.
+ */
+ protected volatile Synchronizer contextModelSynchronizer;
+ protected volatile boolean synchronizingContextModel = false;
/**
- * A pluggable updater that can be used to "update" the JPA project either
+ * A pluggable synchronizer that "updates" the JAXB project, either
* synchronously or asynchronously (or not at all). A synchronous updater
- * is the default, allowing a newly-constructed JPA project to be "updated"
+ * is the default, allowing a newly-constructed JAXB project to be "updated"
* upon return from the constructor. For performance reasons, a UI should
* immediately change this to an asynchronous updater. A synchronous
* updater can be used when the project is being manipulated by a "batch"
* (or non-UI) client (e.g. when testing the "update" behavior). A null
- * updater can used during tests that do not care whether "updates" occur.
+ * updater can used during tests that do not care whether "synchronization"
+ * occur.
* Clients will need to explicitly configure the updater if they require
- * something other than a synchronous updater.
+ * an asynchronous updater.
*/
- protected Updater updater;
+ protected volatile CallbackSynchronizer updateSynchronizer;
+ protected final CallbackSynchronizer.Listener updateSynchronizerListener;
/**
* Support for modifying documents shared with the UI.
@@ -140,14 +168,18 @@ public abstract class AbstractJaxbProject
// build the JPA files corresponding to the Eclipse project's files
InitialResourceProxyVisitor visitor = this.buildInitialResourceProxyVisitor();
visitor.visitProject(this.project);
-//
+
// this.externalJavaResourcePersistentTypeCache = this.buildExternalJavaResourcePersistentTypeCache();
-//
-// this.rootContextNode = this.buildRootContextNode();
+ this.rootContextNode = this.buildRootContextNode();
+
+ // there *shouldn't* be any changes to the resource model...
+ this.setContextModelSynchronizer_(this.buildSynchronousContextModelSynchronizer());
+
+ this.updateSynchronizerListener = this.buildUpdateSynchronizerListener();
// "update" the project before returning
- this.setUpdater_(new SynchronousJaxbProjectUpdater(this));
-//
+ this.setUpdateSynchronizer_(this.buildSynchronousUpdateSynchronizer());
+
// // start listening to this cache once the context model has been built
// // and all the external types are faulted in
// this.externalJavaResourcePersistentTypeCache.addResourceModelListener(this.resourceModelListener);
@@ -167,10 +199,6 @@ public abstract class AbstractJaxbProject
return new ThreadLocalCommandExecutor();
}
- protected JpaResourceModelListener buildResourceModelListener() {
- return new DefaultResourceModelListener();
- }
-
protected InitialResourceProxyVisitor buildInitialResourceProxyVisitor() {
return new InitialResourceProxyVisitor();
}
@@ -178,10 +206,10 @@ public abstract class AbstractJaxbProject
// protected JavaResourcePersistentTypeCache buildExternalJavaResourcePersistentTypeCache() {
// return new BinaryPersistentTypeCache(this.jpaPlatform.getAnnotationProvider());
// }
-//
-// protected JpaRootContextNode buildRootContextNode() {
-// return this.getJpaFactory().buildRootContextNode(this);
-// }
+
+ protected JaxbRootContextNode buildRootContextNode() {
+ return this.getFactory().buildRootContextNode(this);
+ }
// ***** inner class
protected class InitialResourceProxyVisitor implements IResourceProxyVisitor {
@@ -496,15 +524,15 @@ public abstract class AbstractJaxbProject
// jrcu.removeResourceModelListener(this.resourceModelListener);
// this.removeItemFromCollection(jrcu, this.externalJavaResourceCompilationUnits, EXTERNAL_JAVA_RESOURCE_COMPILATION_UNITS_COLLECTION);
// }
-//
-//
-// // ********** context model **********
-//
-// public JpaRootContextNode getRootContextNode() {
-// return this.rootContextNode;
-// }
-//
-//
+
+
+ // ********** context model **********
+
+ public JaxbRootContextNode getRootContextNode() {
+ return this.rootContextNode;
+ }
+
+
// // ********** utility **********
//
// public IFile getPlatformFile(IPath runtimePath) {
@@ -532,92 +560,53 @@ public abstract class AbstractJaxbProject
// JpaFile jpaFile = this.getJpaFile(file);
// return (jpaFile == null) ? null : jpaFile.getResourceModel(contentType);
// }
-//
-//
-// // ********** annotated Java source classes **********
-//
-// public Iterator<String> annotatedJavaSourceClassNames() {
-// return this.getAnnotatedJavaSourceClassNames().iterator();
-// }
-//
-// protected Iterable<String> getAnnotatedJavaSourceClassNames() {
-// return new TransformationIterable<JavaResourcePersistentType, String>(this.getInternalAnnotatedSourceJavaResourcePersistentTypes()) {
-// @Override
-// protected String transform(JavaResourcePersistentType jrpType) {
-// return jrpType.getQualifiedName();
-// }
-// };
-// }
-//
-// /**
-// * return only those valid annotated Java resource persistent types that are part of the
-// * JPA project, ignoring those in JARs referenced in persistence.xml
-// * @see org.eclipse.jpt.core.internal.utility.jdt.JPTTools#typeIsPersistable(org.eclipse.jpt.core.internal.utility.jdt.JPTTools.TypeAdapter)
-// */
-// protected Iterable<JavaResourcePersistentType> getInternalAnnotatedSourceJavaResourcePersistentTypes() {
-// return new FilteringIterable<JavaResourcePersistentType>(this.getInternalSourceJavaResourcePersistentTypes()) {
-// @Override
-// protected boolean accept(JavaResourcePersistentType jrpType) {
-// return jrpType.isPersistable() && jrpType.isAnnotated(); // i.e. the type is valid and has a valid type annotation
-// }
-// };
-// }
-//
-// public Iterable<String> getMappedJavaSourceClassNames() {
-// return new TransformationIterable<JavaResourcePersistentType, String>(this.getInternalMappedSourceJavaResourcePersistentTypes()) {
-// @Override
-// protected String transform(JavaResourcePersistentType jrpType) {
-// return jrpType.getQualifiedName();
-// }
-// };
-// }
-//
-// /**
-// * return only those valid "mapped" (i.e. annotated with @Entity, @Embeddable, etc.) Java
-// * resource persistent types that are part of the JPA project, ignoring those in JARs
-// * referenced in persistence.xml
-// */
-// protected Iterable<JavaResourcePersistentType> getInternalMappedSourceJavaResourcePersistentTypes() {
-// return new FilteringIterable<JavaResourcePersistentType>(this.getInternalAnnotatedSourceJavaResourcePersistentTypes()) {
-// @Override
-// protected boolean accept(JavaResourcePersistentType jrpType) {
-// return jrpType.isMapped(); // i.e. the type is already persistable and annotated
-// }
-// };
-// }
-//
-// /**
-// * return only those Java resource persistent types that are
-// * part of the JPA project, ignoring those in JARs referenced in persistence.xml
-// */
-// protected Iterable<JavaResourcePersistentType2_0> getInternalSourceJavaResourcePersistentTypes2_0() {
-// return new SubIterableWrapper<JavaResourcePersistentType, JavaResourcePersistentType2_0>(this.getInternalSourceJavaResourcePersistentTypes());
-// }
-//
-// /**
-// * return only those Java resource persistent types that are
-// * part of the JPA project, ignoring those in JARs referenced in persistence.xml
-// */
-// protected Iterable<JavaResourcePersistentType> getInternalSourceJavaResourcePersistentTypes() {
-// return new CompositeIterable<JavaResourcePersistentType>(this.getInternalSourceJavaResourcePersistentTypeSets());
-// }
-//
-// /**
-// * return only those Java resource persistent types that are
-// * part of the JPA project, ignoring those in JARs referenced in persistence.xml
-// */
-// protected Iterable<Iterable<JavaResourcePersistentType>> getInternalSourceJavaResourcePersistentTypeSets() {
-// return new TransformationIterable<JavaResourceCompilationUnit, Iterable<JavaResourcePersistentType>>(this.getInternalJavaResourceCompilationUnits()) {
-// @Override
-// protected Iterable<JavaResourcePersistentType> transform(final JavaResourceCompilationUnit compilationUnit) {
-// return new Iterable<JavaResourcePersistentType>() {
-// public Iterator<JavaResourcePersistentType> iterator() {
-// return compilationUnit.persistentTypes(); // *all* the types in the compilation unit
-// }
-// };
-// }
-// };
-// }
+
+
+ // ********** annotated Java source classes **********
+
+ public Iterable<String> getAnnotatedJavaSourceClassNames() {
+ return new TransformationIterable<JavaResourceType, String>(this.getInternalAnnotatedSourceJavaResourceTypes()) {
+ @Override
+ protected String transform(JavaResourceType type) {
+ return type.getQualifiedName();
+ }
+ };
+ }
+
+ /**
+ * return only those valid annotated Java resource persistent types that are part of the
+ * JPA project, ignoring those in JARs referenced in persistence.xml
+ * @see org.eclipse.jpt.core.internal.utility.jdt.JPTTools#typeIsPersistable(org.eclipse.jpt.core.internal.utility.jdt.JPTTools.TypeAdapter)
+ */
+ protected Iterable<JavaResourceType> getInternalAnnotatedSourceJavaResourceTypes() {
+ return new FilteringIterable<JavaResourceType>(this.getInternalSourceJavaResourcePTypes()) {
+ @Override
+ protected boolean accept(JavaResourceType type) {
+ return type.isPersistable() && type.isAnnotated(); // i.e. the type is valid and has a valid type annotation
+ }
+ };
+ }
+
+ /**
+ * return only those Java resource persistent types that are
+ * part of the JPA project, ignoring those in JARs referenced in persistence.xml
+ */
+ protected Iterable<JavaResourceType> getInternalSourceJavaResourcePTypes() {
+ return new CompositeIterable<JavaResourceType>(this.getInternalSourceJavaResourceTypeSets());
+ }
+
+ /**
+ * return only those Java resource persistent types that are
+ * part of the JPA project, ignoring those in JARs referenced in persistence.xml
+ */
+ protected Iterable<Iterable<JavaResourceType>> getInternalSourceJavaResourceTypeSets() {
+ return new TransformationIterable<JavaResourceCompilationUnit, Iterable<JavaResourceType>>(this.getInternalJavaResourceCompilationUnits()) {
+ @Override
+ protected Iterable<JavaResourceType> transform(JavaResourceCompilationUnit compilationUnit) {
+ return compilationUnit.getTypes();
+ }
+ };
+ }
protected Iterable<JavaResourceCompilationUnit> getInternalJavaResourceCompilationUnits() {
return new TransformationIterable<JaxbFile, JavaResourceCompilationUnit>(this.getJavaSourceJaxbFiles()) {
@@ -636,103 +625,109 @@ public abstract class AbstractJaxbProject
}
-// // ********** Java resource persistent type look-up **********
-//
-// public JavaResourcePersistentType getJavaResourcePersistentType(String typeName) {
-// for (JavaResourcePersistentType jrpType : this.getPersistableJavaResourcePersistentTypes()) {
-// if (jrpType.getQualifiedName().equals(typeName)) {
-// return jrpType;
-// }
-// }
+ // ********** Java resource persistent type look-up **********
+
+ public JavaResourceType getJavaResourceType(String typeName) {
+ for (JavaResourceType jrpType : this.getPersistableJavaResourceTypes()) {
+ if (jrpType.getQualifiedName().equals(typeName)) {
+ return jrpType;
+ }
+ }
+ return null;
// // if we don't have a type already, try to build new one from the project classpath
// return this.buildPersistableExternalJavaResourcePersistentType(typeName);
-// }
-//
-// /**
-// * return *all* the "persistable" Java resource persistent types, including those in JARs referenced in
-// * persistence.xml
-// * @see org.eclipse.jpt.core.internal.utility.jdt.JPTTools#typeIsPersistable(org.eclipse.jpt.core.internal.utility.jdt.JPTTools.TypeAdapter)
-// */
-// protected Iterable<JavaResourcePersistentType> getPersistableJavaResourcePersistentTypes() {
-// return new FilteringIterable<JavaResourcePersistentType>(this.getJavaResourcePersistentTypes()) {
-// @Override
-// protected boolean accept(JavaResourcePersistentType jrpType) {
-// return jrpType.isPersistable();
-// }
-// };
-// }
-//
-// /**
-// * return *all* the Java resource persistent types, including those in JARs referenced in
-// * persistence.xml
-// */
-// protected Iterable<JavaResourcePersistentType> getJavaResourcePersistentTypes() {
-// return new CompositeIterable<JavaResourcePersistentType>(this.getJavaResourcePersistentTypeSets());
-// }
-//
-// /**
-// * return *all* the Java resource persistent types, including those in JARs referenced in
-// * persistence.xml
-// */
-// protected Iterable<Iterable<JavaResourcePersistentType>> getJavaResourcePersistentTypeSets() {
-// return new TransformationIterable<JavaResourceNode.Root, Iterable<JavaResourcePersistentType>>(this.getJavaResourceNodeRoots()) {
-// @Override
-// protected Iterable<JavaResourcePersistentType> transform(final JavaResourceNode.Root root) {
-// return new Iterable<JavaResourcePersistentType>() {
-// public Iterator<JavaResourcePersistentType> iterator() {
-// return root.persistentTypes(); // *all* the types held by the root
-// }
-// };
-// }
-// };
-// }
-//
-// @SuppressWarnings("unchecked")
-// protected Iterable<JavaResourceNode.Root> getJavaResourceNodeRoots() {
-// return new CompositeIterable<JavaResourceNode.Root>(
-// this.getInternalJavaResourceCompilationUnits(),
-// this.getInternalJavaResourcePackageFragmentRoots(),
-// this.getExternalJavaResourceCompilationUnits(),
-// Collections.singleton(this.externalJavaResourcePersistentTypeCache)
-// );
-// }
-//
-//
-// // ********** Java resource persistent package look-up **********
-//
-// public JavaResourcePackage getJavaResourcePackage(String packName) {
-// for (JavaResourcePackage jrpp : this.getJavaResourcePackages()) {
-// if (jrpp.getName().equals(packName)) {
-// return jrpp;
-// }
-// }
-// return null;
-// }
-//
-// public Iterable<JavaResourcePackage> getJavaResourcePackages(){
-// return new FilteringIterable<JavaResourcePackage>(
-// new TransformationIterable<JpaFile, JavaResourcePackage>(this.getPackageInfoSourceJpaFiles()) {
-// @Override
-// protected JavaResourcePackage transform(JpaFile jpaFile) {
-// return ((JavaResourcePackageInfoCompilationUnit) jpaFile.getResourceModel()).getPackage();
-// }
-// })
-// {
-// @Override
-// protected boolean accept(JavaResourcePackage packageInfo) {
-// return packageInfo != null;
-// }
-// };
-// }
-//
-// /**
-// * return JPA files with package-info source "content"
-// */
-// protected Iterable<JpaFile> getPackageInfoSourceJpaFiles() {
-// return this.getJpaFiles(JptCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE);
-// }
-//
-//
+ }
+
+ /**
+ * return *all* the "persistable" Java resource persistent types, including those in JARs referenced in
+ * persistence.xml
+ * @see org.eclipse.jpt.core.internal.utility.jdt.JPTTools#typeIsPersistable(org.eclipse.jpt.core.internal.utility.jdt.JPTTools.TypeAdapter)
+ */
+ protected Iterable<JavaResourceType> getPersistableJavaResourceTypes() {
+ return new FilteringIterable<JavaResourceType>(this.getJavaResourceTypes()) {
+ @Override
+ protected boolean accept(JavaResourceType jrpType) {
+ return jrpType.isPersistable();
+ }
+ };
+ }
+
+ /**
+ * return *all* the Java resource persistent types, including those in JARs referenced in
+ * persistence.xml
+ */
+ protected Iterable<JavaResourceType> getJavaResourceTypes() {
+ return new CompositeIterable<JavaResourceType>(this.getJavaResourceTypeSets());
+ }
+
+ /**
+ * return *all* the Java resource persistent types, including those in JARs referenced in
+ * persistence.xml
+ */
+ protected Iterable<Iterable<JavaResourceType>> getJavaResourceTypeSets() {
+ return new TransformationIterable<JavaResourceNode.Root, Iterable<JavaResourceType>>(this.getJavaResourceNodeRoots()) {
+ @Override
+ protected Iterable<JavaResourceType> transform(JavaResourceNode.Root root) {
+ return root.getTypes();
+ }
+ };
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Iterable<JavaResourceNode.Root> getJavaResourceNodeRoots() {
+ return new CompositeIterable<JavaResourceNode.Root>(
+ this.getInternalJavaResourceCompilationUnits()/*,
+ this.getInternalJavaResourcePackageFragmentRoots(),
+ this.getExternalJavaResourceCompilationUnits(),
+ Collections.singleton(this.externalJavaResourcePersistentTypeCache)*/
+ );
+ }
+
+
+ // ********** Java resource persistent package look-up **********
+
+ public JavaResourcePackage getJavaResourcePackage(String packName) {
+ for (JavaResourcePackage jrpp : this.getJavaResourcePackages()) {
+ if (jrpp.getName().equals(packName)) {
+ return jrpp;
+ }
+ }
+ return null;
+ }
+
+ public Iterable<JavaResourcePackage> getJavaResourcePackages(){
+ return new FilteringIterable<JavaResourcePackage>(
+ new TransformationIterable<JaxbFile, JavaResourcePackage>(this.getPackageInfoSourceJaxbFiles()) {
+ @Override
+ protected JavaResourcePackage transform(JaxbFile jaxbFile) {
+ return ((JavaResourcePackageInfoCompilationUnit) jaxbFile.getResourceModel()).getPackage();
+ }
+ })
+ {
+ @Override
+ protected boolean accept(JavaResourcePackage packageInfo) {
+ return packageInfo != null;
+ }
+ };
+ }
+
+ public Iterable<JavaResourcePackage> getAnnotatedJavaResourcePackages() {
+ return new FilteringIterable<JavaResourcePackage>(this.getJavaResourcePackages()) {
+ @Override
+ protected boolean accept(JavaResourcePackage resourcePackage) {
+ return resourcePackage.isAnnotated(); // i.e. the package has a valid package annotation
+ }
+ };
+ }
+
+ /**
+ * return JPA files with package-info source "content"
+ */
+ protected Iterable<JaxbFile> getPackageInfoSourceJaxbFiles() {
+ return this.getJaxbFiles(JptCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE);
+ }
+
+
// // ********** JARs **********
//
// // TODO
@@ -897,55 +892,55 @@ public abstract class AbstractJaxbProject
* as appropriate.
*/
protected void rebuild(IJavaProject javaProject) {
-// // if the classpath has changed, we need to update everything since
-// // class references could now be resolved (or not) etc.
-// if (javaProject.equals(this.getJavaProject())) {
-// this.removeDeadJpaFiles();
-// this.update(this.getInternalJavaResourceCompilationUnits());
-// } else {
-// // TODO see if changed project is on our classpath?
-// this.update(this.getExternalJavaResourceCompilationUnits());
-// }
+ // if the classpath has changed, we need to update everything since
+ // class references could now be resolved (or not) etc.
+ if (javaProject.equals(this.getJavaProject())) {
+ this.removeDeadJpaFiles();
+ this.synchronizeWithJavaSource(this.getInternalJavaResourceCompilationUnits());
+ } else {
+ // TODO see if changed project is on our classpath?
+ //this.synchronizeWithJavaSource(this.getExternalJavaResourceCompilationUnits());
+ }
+ }
+
+ /**
+ * Loop through all our JPA files, remove any that are no longer on the
+ * classpath.
+ */
+ protected void removeDeadJpaFiles() {
+ for (JaxbFile jaxbFile : this.getJaxbFiles()) {
+ if (this.jaxbFileIsDead(jaxbFile)) {
+ this.removeJaxbFile(jaxbFile);
+ }
+ }
+ }
+
+ protected boolean jaxbFileIsDead(JaxbFile jaxbFile) {
+ return ! this.jaxbFileIsAlive(jaxbFile);
+ }
+
+ /**
+ * Sometimes (e.g. during tests), when a project has been deleted, we get a
+ * Java change event that indicates the Java project is CHANGED (as
+ * opposed to REMOVED, which is what typically happens). The event's delta
+ * indicates that everything in the Java project has been deleted and the
+ * classpath has changed. All entries in the classpath have been removed;
+ * but single entry for the Java project's root folder has been added. (!)
+ * This means any file in the project is on the Java project's classpath.
+ * This classpath change is what triggers us to rebuild the JPA project; so
+ * we put an extra check here to make sure the JPA file's resource file is
+ * still present.
+ * <p>
+ * This would not be a problem if Dali received the resource change event
+ * <em>before</em> JDT and simply removed the JPA project; but JDT receives
+ * the resource change event first and converts it into the problematic
+ * Java change event....
+ */
+ protected boolean jaxbFileIsAlive(JaxbFile jaxbFile) {
+ IFile file = jaxbFile.getFile();
+ return this.getJavaProject().isOnClasspath(file) &&
+ file.exists();
}
-//
-// /**
-// * Loop through all our JPA files, remove any that are no longer on the
-// * classpath.
-// */
-// protected void removeDeadJpaFiles() {
-// for (JpaFile jpaFile : this.getJpaFiles()) {
-// if (this.jpaFileIsDead(jpaFile)) {
-// this.removeJpaFile(jpaFile);
-// }
-// }
-// }
-//
-// protected boolean jpaFileIsDead(JpaFile jpaFile) {
-// return ! this.jpaFileIsAlive(jpaFile);
-// }
-//
-// /**
-// * Sometimes (e.g. during tests), when a project has been deleted, we get a
-// * Java change event that indicates the Java project is CHANGED (as
-// * opposed to REMOVED, which is what typically happens). The event's delta
-// * indicates that everything in the Java project has been deleted and the
-// * classpath has changed. All entries in the classpath have been removed;
-// * but single entry for the Java project's root folder has been added. (!)
-// * This means any file in the project is on the Java project's classpath.
-// * This classpath change is what triggers us to rebuild the JPA project; so
-// * we put an extra check here to make sure the JPA file's resource file is
-// * still present.
-// * <p>
-// * This would not be a problem if Dali received the resource change event
-// * <em>before</em> JDT and simply removed the JPA project; but JDT receives
-// * the resource change event first and converts it into the problematic
-// * Java change event....
-// */
-// protected boolean jpaFileIsAlive(JpaFile jpaFile) {
-// IFile file = jpaFile.getFile();
-// return this.getJavaProject().isOnClasspath(file) &&
-// file.exists();
-// }
/**
* pre-condition:
@@ -955,12 +950,13 @@ public abstract class AbstractJaxbProject
return this.deltaFlagIsSet(delta, IJavaElementDelta.F_RESOLVED_CLASSPATH_CHANGED);
}
- protected void update(Iterable<JavaResourceCompilationUnit> javaResourceCompilationUnits) {
+ protected void synchronizeWithJavaSource(Iterable<JavaResourceCompilationUnit> javaResourceCompilationUnits) {
for (JavaResourceCompilationUnit javaResourceCompilationUnit : javaResourceCompilationUnits) {
javaResourceCompilationUnit.synchronizeWithJavaSource();
}
}
+
// ***** package fragment root
protected void processJavaPackageFragmentRootDelta(IJavaElementDelta delta) {
// process the Java package fragment root's package fragments
@@ -1066,17 +1062,24 @@ public abstract class AbstractJaxbProject
// ********** dispose **********
public void dispose() {
- this.updater.stop();
+ this.contextModelSynchronizer.stop();
+ this.updateSynchronizer.stop();
+ this.updateSynchronizer.removeListener(this.updateSynchronizerListener);
// the XML resources are held indefinitely by the WTP translator framework,
- // so we better remove our listener or the JPA project will not be GCed
-// for (JpaFile jpaFile : this.getJpaFiles()) {
-// jpaFile.getResourceModel().removeResourceModelListener(this.resourceModelListener);
-// }
+ // so we better remove our listener or the JAXB project will not be GCed
+ for (JaxbFile jaxbFile : this.getJaxbFiles()) {
+ jaxbFile.getResourceModel().removeResourceModelListener(this.resourceModelListener);
+ }
}
+
// ********** resource model listener **********
+ protected JpaResourceModelListener buildResourceModelListener() {
+ return new DefaultResourceModelListener();
+ }
+
protected class DefaultResourceModelListener
implements JpaResourceModelListener
{
@@ -1093,19 +1096,23 @@ public abstract class AbstractJaxbProject
public void resourceModelReverted(JpaResourceModel jpaResourceModel) {
// IFile file = WorkbenchResourceHelper.getFile((JpaXmlResource)jpaResourceModel);
-// AbstractJaxbProject.this.removeJpaFile(file);
-// AbstractJaxbProject.this.addJpaFile(file);
+// AbstractJaxbProject.this.removeJaxbFile(file);
+// AbstractJaxbProject.this.addJaxbFile(file);
}
public void resourceModelUnloaded(JpaResourceModel jpaResourceModel) {
// IFile file = WorkbenchResourceHelper.getFile((JpaXmlResource)jpaResourceModel);
-// AbstractJaxbProject.this.removeJpaFile(file);
+// AbstractJaxbProject.this.removeJaxbFile(file);
}
}
-
-
+
+ protected void synchronizeContextModel(@SuppressWarnings("unused") JpaResourceModel jpaResourceModel) {
+ this.synchronizeContextModel();
+ }
+
+
// ********** resource events **********
-
+
// TODO need to do the same thing for external projects and compilation units
public void projectChanged(IResourceDelta delta) {
if (delta.getResource().equals(this.getProject())) {
@@ -1116,77 +1123,74 @@ public abstract class AbstractJaxbProject
}
protected void internalProjectChanged(IResourceDelta delta) {
- if (delta.getKind() == IResourceDelta.REMOVED) {
- setUpdater(JaxbProject.Updater.Null.instance());
+ ResourceDeltaVisitor resourceDeltaVisitor = this.buildInternalResourceDeltaVisitor();
+ resourceDeltaVisitor.visitDelta(delta);
+ // at this point, if we have added and/or removed JpaFiles, an "update" will have been triggered;
+ // any changes to the resource model during the "resolve" will trigger further "updates";
+ // there should be no need to "resolve" external Java types (they can't have references to
+ // the internal Java types)
+ if (resourceDeltaVisitor.encounteredSignificantChange()) {
+ this.resolveInternalJavaTypes();
}
-// ResourceDeltaVisitor resourceDeltaVisitor = this.buildInternalResourceDeltaVisitor();
-// resourceDeltaVisitor.visitDelta(delta);
-// // at this point, if we have added and/or removed JpaFiles, an "update" will have been triggered;
-// // any changes to the resource model during the "resolve" will trigger further "updates";
-// // there should be no need to "resolve" external Java types (they can't have references to
-// // the internal Java types)
-// if (resourceDeltaVisitor.encounteredSignificantChange()) {
-// this.resolveInternalJavaTypes();
-// }
}
-//
-// protected ResourceDeltaVisitor buildInternalResourceDeltaVisitor() {
-// return new ResourceDeltaVisitor() {
-// @Override
-// public boolean fileChangeIsSignificant(IFile file, int deltaKind) {
-// return AbstractJaxbProject.this.synchronizeJpaFiles(file, deltaKind);
-// }
-// };
-// }
-//
-// /**
-// * Internal resource delta visitor callback.
-// * Return true if a JpaFile was either added or removed.
-// */
-// protected boolean synchronizeJpaFiles(IFile file, int deltaKind) {
-// switch (deltaKind) {
-// case IResourceDelta.ADDED :
-// return this.addJpaFile(file);
-// case IResourceDelta.REMOVED :
-// return this.removeJpaFile(file);
-// case IResourceDelta.CHANGED :
-// return this.checkForChangedFileContent(file);
-// case IResourceDelta.ADDED_PHANTOM :
-// break; // ignore
-// case IResourceDelta.REMOVED_PHANTOM :
-// break; // ignore
-// default :
-// break; // only worried about added/removed/changed files
-// }
-//
-// return false;
-// }
-//
-// protected boolean checkForChangedFileContent(IFile file) {
-// JpaFile jpaFile = this.getJpaFile(file);
-// if (jpaFile == null) {
-// // the file might have changed its content to something that we are interested in
-// return this.addJpaFile(file);
-// }
-//
-// if (jpaFile.getContentType().equals(PlatformTools.getContentType(file))) {
-// // content has not changed - ignore
-// return false;
-// }
-//
-// // the content type changed, we need to build a new JPA file
-// // (e.g. the schema of an orm.xml file changed from JPA to EclipseLink)
-// this.removeJpaFile(jpaFile);
-// this.addJpaFile(file);
-// return true; // at the least, we have removed a JPA file
-// }
-//
-// protected void resolveInternalJavaTypes() {
-// for (JavaResourceCompilationUnit jrcu : this.getInternalJavaResourceCompilationUnits()) {
-// jrcu.resolveTypes();
-// }
-// }
-//
+
+ protected ResourceDeltaVisitor buildInternalResourceDeltaVisitor() {
+ return new ResourceDeltaVisitor() {
+ @Override
+ public boolean fileChangeIsSignificant(IFile file, int deltaKind) {
+ return AbstractJaxbProject.this.synchronizeJpaFiles(file, deltaKind);
+ }
+ };
+ }
+
+ /**
+ * Internal resource delta visitor callback.
+ * Return true if a JpaFile was either added or removed.
+ */
+ protected boolean synchronizeJpaFiles(IFile file, int deltaKind) {
+ switch (deltaKind) {
+ case IResourceDelta.ADDED :
+ return this.addJaxbFile(file);
+ case IResourceDelta.REMOVED :
+ return this.removeJaxbFile(file);
+ case IResourceDelta.CHANGED :
+ return this.checkForChangedFileContent(file);
+ case IResourceDelta.ADDED_PHANTOM :
+ break; // ignore
+ case IResourceDelta.REMOVED_PHANTOM :
+ break; // ignore
+ default :
+ break; // only worried about added/removed/changed files
+ }
+
+ return false;
+ }
+
+ protected boolean checkForChangedFileContent(IFile file) {
+ JaxbFile jaxbFile = this.getJaxbFile(file);
+ if (jaxbFile == null) {
+ // the file might have changed its content to something that we are interested in
+ return this.addJaxbFile(file);
+ }
+
+ if (jaxbFile.getContentType().equals(PlatformTools.getContentType(file))) {
+ // content has not changed - ignore
+ return false;
+ }
+
+ // the content type changed, we need to build a new JPA file
+ // (e.g. the schema of an orm.xml file changed from JPA to EclipseLink)
+ this.removeJaxbFile(jaxbFile);
+ this.addJaxbFile(file);
+ return true; // at the least, we have removed a JPA file
+ }
+
+ protected void resolveInternalJavaTypes() {
+ for (JavaResourceCompilationUnit jrcu : this.getInternalJavaResourceCompilationUnits()) {
+ jrcu.resolveTypes();
+ }
+ }
+
// protected void externalProjectChanged(IResourceDelta delta) {
// if (this.getJavaProject().isOnClasspath(delta.getResource())) {
// ResourceDeltaVisitor resourceDeltaVisitor = this.buildExternalResourceDeltaVisitor();
@@ -1338,60 +1342,179 @@ public abstract class AbstractJaxbProject
// ********** synchronize context model with resource model **********
- // TODO ...
- protected void synchronizeContextModel(@SuppressWarnings("unused") JpaResourceModel jpaResourceModel) {
- this.synchronizeContextModel();
+ public Synchronizer getContextModelSynchronizer() {
+ return this.contextModelSynchronizer;
}
+ public void setContextModelSynchronizer(Synchronizer synchronizer) {
+ if (synchronizer == null) {
+ throw new NullPointerException();
+ }
+ this.contextModelSynchronizer.stop();
+ this.setContextModelSynchronizer_(synchronizer);
+ }
+
+ protected void setContextModelSynchronizer_(Synchronizer synchronizer) {
+ this.contextModelSynchronizer = synchronizer;
+ this.contextModelSynchronizer.start();
+ }
+
+ /**
+ * Delegate to the context model synchronizer so clients can configure how
+ * synchronizations occur.
+ */
public void synchronizeContextModel() {
+ this.synchronizingContextModel = true;
+ this.contextModelSynchronizer.synchronize();
+ this.synchronizingContextModel = false;
+
+ // There are some changes to the resource model that will not change
+ // the existing context model and trigger an update (e.g. adding an
+ // @Entity annotation when the the JPA project is automatically
+ // discovering annotated classes); so we explicitly execute an update
+ // here to discover those changes.
this.update();
}
+ /**
+ * Called by the context model synchronizer.
+ */
+ public IStatus synchronizeContextModel(IProgressMonitor monitor) {
+ this.rootContextNode.synchronizeWithResourceModel();
+ return Status.OK_STATUS;
+ }
+
+ public void synchronizeContextModelAndWait() {
+ Synchronizer temp = this.contextModelSynchronizer;
+ this.setContextModelSynchronizer(this.buildSynchronousContextModelSynchronizer());
+ this.synchronizeContextModel();
+ this.setContextModelSynchronizer(temp);
+ }
+
+
+ // ********** default context model synchronizer (synchronous) **********
+
+ protected Synchronizer buildSynchronousContextModelSynchronizer() {
+ return new SynchronousSynchronizer(this.buildSynchronousContextModelSynchronizerCommand());
+ }
+
+ protected Command buildSynchronousContextModelSynchronizerCommand() {
+ return new SynchronousContextModelSynchronizerCommand();
+ }
+
+ protected class SynchronousContextModelSynchronizerCommand
+ implements Command
+ {
+ public void execute() {
+ AbstractJaxbProject.this.synchronizeContextModel(new NullProgressMonitor());
+ }
+ }
+
// ********** project "update" **********
- public Updater getUpdater() {
- return this.updater;
+ public CallbackSynchronizer getUpdateSynchronizer() {
+ return this.updateSynchronizer;
}
- public void setUpdater(Updater updater) {
- if (updater == null) {
+ public void setUpdateSynchronizer(CallbackSynchronizer synchronizer) {
+ if (synchronizer == null) {
throw new NullPointerException();
}
- this.updater.stop();
- this.setUpdater_(updater);
+ this.updateSynchronizer.stop();
+ this.updateSynchronizer.removeListener(this.updateSynchronizerListener);
+ this.setUpdateSynchronizer_(synchronizer);
}
- protected void setUpdater_(Updater updater) {
- this.updater = updater;
- this.updater.start();
+ protected void setUpdateSynchronizer_(CallbackSynchronizer synchronizer) {
+ this.updateSynchronizer = synchronizer;
+ this.updateSynchronizer.addListener(this.updateSynchronizerListener);
+ this.updateSynchronizer.start();
+ }
+
+ @Override
+ public void stateChanged() {
+ super.stateChanged();
+ this.update();
}
/**
- * Delegate to the updater so clients can configure how updates occur.
+ * The JAXB project's state has changed, "update" those parts of the
+ * JAXB project that are dependent on other parts of the JAXB project.
+ * <p>
+ * Delegate to the update synchronizer so clients can configure how
+ * updates occur.
+ * <p>
+ * Ignore any <em>updates</em> that occur while we are synchronizing
+ * the context model with the resource model because we will <em>update</em>
+ * the context model at the completion of the <em>sync</em>. This is really
+ * only useful for synchronous <em>syncs</em> and <em>updates</em>; since
+ * the job scheduling rules will prevent the <em>sync</em> and
+ * <em>update</em> jobs from running concurrently.
+ *
+ * @see #updateAndWait()
*/
- public void update() {
- this.updater.update();
+ protected void update() {
+ if ( ! this.synchronizingContextModel) {
+ this.updateSynchronizer.synchronize();
+ }
}
/**
- * Called by the updater.
+ * Called by the update synchronizer.
*/
public IStatus update(IProgressMonitor monitor) {
- this.update_(monitor);
+ this.rootContextNode.update();
return Status.OK_STATUS;
}
- protected void update_(IProgressMonitor monitor) {
-// this.rootContextNode.update(monitor);
-// this.rootContextNode.postUpdate();
- }
-
/**
- * Also called by the updater.
+ * This is the callback used by the update synchronizer to notify the JAXB
+ * project that the "update" has quiesced (i.e. the "update" has completed
+ * and there are no outstanding requests for further "updates").
*/
- public void updateQuiesced() {
- //nothing yet
+ public void updateQuiesced() {
+ //nothing yet
+ }
+
+ public void updateAndWait() {
+ CallbackSynchronizer temp = this.updateSynchronizer;
+ this.setUpdateSynchronizer(this.buildSynchronousUpdateSynchronizer());
+ this.update();
+ this.setUpdateSynchronizer(temp);
+ }
+
+
+ // ********** default update synchronizer (synchronous) **********
+
+ protected CallbackSynchronizer buildSynchronousUpdateSynchronizer() {
+ return new CallbackSynchronousSynchronizer(this.buildSynchronousUpdateSynchronizerCommand());
+ }
+
+ protected Command buildSynchronousUpdateSynchronizerCommand() {
+ return new SynchronousUpdateSynchronizerCommand();
}
+ protected class SynchronousUpdateSynchronizerCommand
+ implements Command
+ {
+ public void execute() {
+ AbstractJaxbProject.this.update(new NullProgressMonitor());
+ }
+ }
+
+
+ // ********** update synchronizer listener **********
+
+ protected CallbackSynchronizer.Listener buildUpdateSynchronizerListener() {
+ return new UpdateSynchronizerListener();
+ }
+
+ protected class UpdateSynchronizerListener
+ implements CallbackSynchronizer.Listener
+ {
+ public void synchronizationQuiesced(CallbackSynchronizer synchronizer) {
+ AbstractJaxbProject.this.updateQuiesced();
+ }
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractSynchronizerJaxbProjectUpdater.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractSynchronizerJaxbProjectUpdater.java
deleted file mode 100644
index 3b47046ea2..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractSynchronizerJaxbProjectUpdater.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jaxb.core.internal;
-
-import org.eclipse.jpt.jaxb.core.JaxbProject;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronizer;
-
-/**
- * Adapt the "callback synchronizer" interface to the JAXB project "updater"
- * interface.
- * <p>
- * Subclasses are to build the appropriate callback synchronizer.
- */
-public abstract class AbstractSynchronizerJaxbProjectUpdater
- implements JaxbProject.Updater
-{
- protected final JaxbProject jaxbProject;
- protected final CallbackSynchronizer synchronizer;
-
-
- protected AbstractSynchronizerJaxbProjectUpdater(JaxbProject jaxbProject) {
- super();
- this.jaxbProject = jaxbProject;
- this.synchronizer = this.buildSynchronizer();
- this.synchronizer.addListener(this.buildCallbackSynchronizerListener());
- }
-
- protected abstract CallbackSynchronizer buildSynchronizer();
-
- protected CallbackSynchronizer.Listener buildCallbackSynchronizerListener() {
- return new CallbackSynchronizer.Listener() {
- public void synchronizationQuiesced(CallbackSynchronizer s) {
- AbstractSynchronizerJaxbProjectUpdater.this.jaxbProject.updateQuiesced();
- }
- };
- }
-
-
- // ********** JaxbProject implementation **********
-
- public void start() {
- this.synchronizer.start();
- }
-
- // recursion: we come back here if JaxbProject#update() is called again, during the "update"
- public void update() {
- this.synchronizer.synchronize();
- }
-
- public void stop() {
- this.synchronizer.stop();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.synchronizer);
- }
-
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AsynchronousJaxbProjectUpdater.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AsynchronousJaxbProjectUpdater.java
deleted file mode 100644
index 7aa8451684..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AsynchronousJaxbProjectUpdater.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jaxb.core.internal;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.internal.JptCoreMessages;
-import org.eclipse.jpt.core.internal.utility.CallbackJobSynchronizer;
-import org.eclipse.jpt.core.internal.utility.JobCommand;
-import org.eclipse.jpt.jaxb.core.JaxbProject;
-import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronizer;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Adapt the "callback synchronizer" interface to the JPA project "updater"
- * interface.
- * <p>
- * This updater will "update" the JPA project in an Eclipse job that executes
- * in a separate thread allowing calls to {@link JpaProject.Updater#update()}
- * to return immediately.
- */
-public class AsynchronousJaxbProjectUpdater
- extends AbstractSynchronizerJaxbProjectUpdater
-{
- public AsynchronousJaxbProjectUpdater(JaxbProject jaxbProject) {
- super(jaxbProject);
- }
-
- @Override
- protected CallbackSynchronizer buildSynchronizer() {
- return new CallbackJobSynchronizer(
- this.buildJobName(),
- this.buildJobCommand(),
- this.buildJobSchedulingRule()
- );
- }
-
- protected String buildJobName() {
- return NLS.bind(JptCoreMessages.UPDATE_JOB_NAME, this.jaxbProject.getName());
- }
-
- protected JobCommand buildJobCommand() {
- return new JobCommand() {
- public IStatus execute(IProgressMonitor monitor) {
- return AsynchronousJaxbProjectUpdater.this.jaxbProject.update(monitor);
- }
- };
- }
-
- protected ISchedulingRule buildJobSchedulingRule() {
- return this.jaxbProject.getProject();
- }
-
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SynchronousJaxbProjectUpdater.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SynchronousJaxbProjectUpdater.java
deleted file mode 100644
index 1a4e8792e8..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SynchronousJaxbProjectUpdater.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jaxb.core.internal;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jpt.jaxb.core.JaxbProject;
-import org.eclipse.jpt.utility.Command;
-import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronizer;
-import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronousSynchronizer;
-
-/**
- * Adapt the "callback synchronizer" interface to the JAXB project "updater"
- * interface.
- * <p>
- * This updater will "update" the JAXB project immediately and not return until
- * the "update" and all resulting "updates" are complete. This implementation
- * should be used sparingly and for as short a time as possible, as it increases
- * the probability of deadlocks. A deadlock can occur when a JAXB project is
- * updated from multiple threads and various resources are locked in varying
- * orders.
- */
-public class SynchronousJaxbProjectUpdater
- extends AbstractSynchronizerJaxbProjectUpdater
-{
- public SynchronousJaxbProjectUpdater(JaxbProject jaxbProject) {
- super(jaxbProject);
- }
-
- @Override
- protected CallbackSynchronizer buildSynchronizer() {
- return new CallbackSynchronousSynchronizer(this.buildCommand());
- }
-
- protected Command buildCommand() {
- return new Command() {
- public void execute() {
- SynchronousJaxbProjectUpdater.this.jaxbProject.update(new NullProgressMonitor());
- }
- };
- }
-
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/AbstractJaxbContextNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/AbstractJaxbContextNode.java
new file mode 100644
index 0000000000..6800790732
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/AbstractJaxbContextNode.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.jaxb.core.internal.context;
+
+import org.eclipse.jpt.core.JpaResourceType;
+import org.eclipse.jpt.jaxb.core.JaxbNode;
+import org.eclipse.jpt.jaxb.core.context.JaxbContextNode;
+import org.eclipse.jpt.jaxb.core.internal.AbstractJaxbNode;
+
+public abstract class AbstractJaxbContextNode
+ extends AbstractJaxbNode
+ implements JaxbContextNode
+{
+
+ // ********** constructor **********
+
+ protected AbstractJaxbContextNode(JaxbNode parent) {
+ super(parent);
+ }
+
+
+ // ********** JpaNode implentation **********
+
+ /**
+ * covariant override
+ */
+ @Override
+ public JaxbContextNode getParent() {
+ return (JaxbContextNode) super.getParent();
+ }
+
+
+ // ********** JaxbContextNode implementation **********
+
+ public JpaResourceType getResourceType() {
+ return getParent().getResourceType();
+ }
+
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/ContextContainerTools.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/ContextContainerTools.java
new file mode 100644
index 0000000000..772bf7a860
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/ContextContainerTools.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * 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.jaxb.core.internal.context;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import org.eclipse.jpt.jaxb.core.context.JaxbContextNode;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.Tools;
+
+/**
+ * Utility methods for manipulating context containers.
+ */
+public class ContextContainerTools {
+
+ /**
+ * Adapter used to synchronize a context container with its corresponding
+ * resource container.
+ *
+ * @param <C> the type of context elements
+ * @param <R> the type of resource elements
+ */
+ public interface Adapter<C extends JaxbContextNode, R> {
+
+ /**
+ * Return the container's context elements.
+ */
+ Iterable<C> getContextElements();
+
+ /**
+ * Return the container's current set of resource elements.
+ * These are what the context elements will be synchronized to.
+ */
+ Iterable<R> getResourceElements();
+
+ /**
+ * Return the resource element corresponding to the specified context
+ * element.
+ */
+ R getResourceElement(C contextElement);
+
+ /**
+ * Move the specified context element to the specified index.
+ */
+ void moveContextElement(int index, C element);
+
+ /**
+ * Add a context element for the specified resource element at the
+ * specified index.
+ */
+ void addContextElement(int index, R resourceElement);
+
+ /**
+ * Remove the specified context element from the container.
+ */
+ void removeContextElement(C element);
+ }
+
+
+ /**
+ * Using the specified adapter, synchronize a context container with its
+ * corresponding resource container: moving, removing, and adding elements
+ * as necessary.
+ * <p>
+ * We can do this because:<ul>
+ * <li>the XML translators will <em>move</em> the EMF elements when
+ * appropriate (as opposed to simply rebuilding them in place).
+ * <li>the Java resource model will re-use existing annotations when
+ * appropriate (as opposed to simply rebuilding them in place).
+ * </ul>
+ */
+ public static <C extends JaxbContextNode, R> void synchronizeWithResourceModel(Adapter<C, R> adapter) {
+ sync(adapter, true); // true = sync
+ }
+
+ /**
+ * @see #synchronizeWithResourceModel(Adapter)
+ */
+ public static <C extends JaxbContextNode, R> void update(Adapter<C, R> adapter) {
+ sync(adapter, false); // false = update
+ }
+
+ /**
+ * The specified <code>sync</code> flag controls whether any surviving
+ * context nodes are either <em>synchronized</em> (<code>true</code>) or
+ * <em>updated</em> (<code>false</code>).
+ */
+ protected static <C extends JaxbContextNode, R> void sync(Adapter<C, R> adapter, boolean sync) {
+ HashSet<C> contextElements = CollectionTools.set(adapter.getContextElements());
+ int resourceIndex = 0;
+
+ for (R resourceElement : adapter.getResourceElements()) {
+ boolean match = false;
+ for (Iterator<C> stream = contextElements.iterator(); stream.hasNext(); ) {
+ C contextElement = stream.next();
+ if (Tools.valuesAreEqual(adapter.getResourceElement(contextElement), resourceElement)) {
+ // we don't know the source index because the element has been moved by previously moved elements
+ adapter.moveContextElement(resourceIndex, contextElement);
+ stream.remove();
+ if (sync) {
+ contextElement.synchronizeWithResourceModel();
+ } else {
+ contextElement.update();
+ }
+ match = true;
+ break;
+ }
+ }
+ if ( ! match) {
+ // added elements are sync'ed during construction or will be
+ // updated during the next "update" (which is triggered by
+ // their addition to the model)
+ adapter.addContextElement(resourceIndex, resourceElement);
+ }
+ resourceIndex++;
+ }
+ // remove any leftover context elements
+ for (C contextElement : contextElements) {
+ adapter.removeContextElement(contextElement);
+ }
+ }
+
+ private ContextContainerTools() {
+ super();
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericPackage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericPackage.java
new file mode 100644
index 0000000000..521397452a
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericPackage.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.jaxb.core.internal.context;
+
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
+import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+
+//TODO for now we will assume a 1-1 relationship between a package and a package-info.
+//Later there could be annotated types in a package that has no package-info.java
+//Or we could have a mapping file instead and this would have the PackageInfo in it.
+public class GenericPackage
+ extends AbstractJaxbContextNode
+ implements JaxbPackage
+{
+
+ protected final JaxbPackageInfo packageInfo;
+
+ public GenericPackage(JaxbRootContextNode parent, JavaResourcePackage resourcePackage) {
+ super(parent);
+ this.packageInfo = buildPackageInfo(resourcePackage);
+ }
+
+ public void synchronizeWithResourceModel() {
+ this.packageInfo.synchronizeWithResourceModel();
+ }
+
+ public void update() {
+ this.packageInfo.update();
+ }
+
+ public JavaResourcePackage getResourcePackage() {
+ return this.packageInfo.getResourcePackage();
+ }
+
+
+ // ********** package info **********
+
+ public JaxbPackageInfo getPackageInfo() {
+ return this.packageInfo;
+ }
+
+ protected JaxbPackageInfo buildPackageInfo(JavaResourcePackage resourcePackage) {
+ return getFactory().buildJavaPackageInfo(this, resourcePackage);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericRootContextNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericRootContextNode.java
new file mode 100644
index 0000000000..b1eb7d2790
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericRootContextNode.java
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * 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.jaxb.core.internal.context;
+
+import java.util.Vector;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
+
+/**
+ * the context model root
+ */
+public class GenericRootContextNode
+ extends AbstractJaxbContextNode
+ implements JaxbRootContextNode
+{
+ /* This object has no parent, so it must point to the JAXB project explicitly. */
+ protected final JaxbProject jaxbProject;
+
+ /* Main context objects. */
+ protected final Vector<JaxbPackage> packages = new Vector<JaxbPackage>();
+ protected final PackageContainerAdapter packageContainerAdapter = new PackageContainerAdapter();
+
+
+ public GenericRootContextNode(JaxbProject jaxbProject) {
+ super(null); // the JPA project is not really a "parent"...
+ if (jaxbProject == null) {
+ throw new NullPointerException();
+ }
+ this.jaxbProject = jaxbProject;
+ this.initializePackages();
+ }
+
+
+ @Override
+ protected boolean requiresParent() {
+ return false;
+ }
+
+ public void synchronizeWithResourceModel() {
+ this.syncPackages();
+ }
+
+ public void update() {
+ this.updatePackages();
+ }
+
+
+ // ********** AbstractJaxbNode overrides **********
+
+ @Override
+ public JaxbProject getJaxbProject() {
+ return this.jaxbProject;
+ }
+
+ @Override
+ public IResource getResource() {
+ return this.getProject();
+ }
+
+ protected IProject getProject() {
+ return this.jaxbProject.getProject();
+ }
+
+
+ // ************* packages ***************
+
+ public Iterable<JaxbPackage> getPackages() {
+ return new LiveCloneIterable<JaxbPackage>(this.packages);
+ }
+
+ public int getPackagesSize() {
+ return this.packages.size();
+ }
+
+ protected void addPackage(JavaResourcePackage resourcePackage) {
+ addPackage(this.buildPackage(resourcePackage));
+ }
+
+ protected void addPackage(JaxbPackage contextPackage) {
+ this.addItemToCollection(contextPackage, this.packages, PACKAGES_COLLECTION);
+ }
+
+ protected void removePackage(JaxbPackage contextPackage) {
+ this.removeItemFromCollection(contextPackage, this.packages, PACKAGES_COLLECTION);
+ }
+
+ protected void initializePackages() {
+ for (JavaResourcePackage resourcePackage : this.getJaxbProject().getAnnotatedJavaResourcePackages()) {
+ this.packages.add(this.buildPackage(resourcePackage));
+ }
+ }
+
+ protected void syncPackages() {
+ ContextContainerTools.synchronizeWithResourceModel(this.packageContainerAdapter);
+ }
+
+ protected void updatePackages() {
+ //In this case we need to actually "sync" the list of packages since this is dependent on JaxbFiles
+ //and an update will be called when jaxb files are added/removed, not a synchronizeWithResourceModel
+ ContextContainerTools.update(this.packageContainerAdapter);
+ }
+
+ protected JaxbPackage buildPackage(JavaResourcePackage resourcePackage) {
+ return this.getFactory().buildPackage(this, resourcePackage);
+ }
+
+
+ /**
+ * package container adapter
+ */
+ protected class PackageContainerAdapter
+ implements ContextContainerTools.Adapter<JaxbPackage, JavaResourcePackage>
+ {
+ public Iterable<JaxbPackage> getContextElements() {
+ return GenericRootContextNode.this.getPackages();
+ }
+ public Iterable<JavaResourcePackage> getResourceElements() {
+ return GenericRootContextNode.this.getJaxbProject().getAnnotatedJavaResourcePackages();
+ }
+ public JavaResourcePackage getResourceElement(JaxbPackage contextElement) {
+ return contextElement.getResourcePackage();
+ }
+ public void moveContextElement(int index, JaxbPackage element) {
+ //ignore since we don't need order for packages
+ }
+ public void addContextElement(int index, JavaResourcePackage resourceElement) {
+ GenericRootContextNode.this.addPackage(resourceElement);
+ }
+ public void removeContextElement(JaxbPackage element) {
+ GenericRootContextNode.this.removePackage(element);
+ }
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java
new file mode 100644
index 0000000000..347c093832
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPackageInfo.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * 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.jaxb.core.internal.context.java;
+
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
+import org.eclipse.jpt.jaxb.core.context.XmlAccessOrder;
+import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
+import org.eclipse.jpt.jaxb.core.internal.context.AbstractJaxbContextNode;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
+
+public class GenericJavaPackageInfo
+ extends AbstractJaxbContextNode
+ implements JaxbPackageInfo
+{
+
+ protected final JavaResourcePackage resourcePackage;
+
+ protected XmlAccessType specifiedAccessType;
+
+ protected XmlAccessOrder specifiedAccessOrder;
+
+ public GenericJavaPackageInfo(JaxbPackage parent, JavaResourcePackage resourcePackage) {
+ super(parent);
+ this.resourcePackage = resourcePackage;
+ this.specifiedAccessType = getResourceAccessType();
+ this.specifiedAccessOrder = getResourceAccessOrder();
+ }
+
+
+ // ********** synchronize/update **********
+
+ public void synchronizeWithResourceModel() {
+ this.setSpecifiedAccessType_(this.getResourceAccessType());
+ this.setSpecifiedAccessOrder_(this.getResourceAccessOrder());
+ }
+
+ public void update() {
+ //nothing yet
+ }
+
+
+ // ********** JaxbPackageInfo implementation **********
+
+ public JavaResourcePackage getResourcePackage() {
+ return this.resourcePackage;
+ }
+
+
+ // ********** access type **********
+
+ public XmlAccessType getAccessType() {
+ return (this.specifiedAccessType != null) ? this.specifiedAccessType : this.getDefaultAccessType();
+ }
+
+ public XmlAccessType getSpecifiedAccessType() {
+ return this.specifiedAccessType;
+ }
+
+ public void setSpecifiedAccessType(XmlAccessType access) {
+ this.getAccessorTypeAnnotation().setValue(XmlAccessType.toJavaResourceModel(access));
+ this.setSpecifiedAccessType_(access);
+ }
+
+ protected void setSpecifiedAccessType_(XmlAccessType access) {
+ XmlAccessType old = this.specifiedAccessType;
+ this.specifiedAccessType = access;
+ this.firePropertyChanged(SPECIFIED_ACCESS_TYPE_PROPERTY, old, access);
+ }
+
+ public XmlAccessType getDefaultAccessType() {
+ return XmlAccessType.PUBLIC_MEMBER;
+ }
+
+ protected XmlAccessType getResourceAccessType() {
+ return XmlAccessType.fromJavaResourceModel(this.getAccessorTypeAnnotation().getValue());
+ }
+
+ protected XmlAccessorTypeAnnotation getAccessorTypeAnnotation() {
+ return (XmlAccessorTypeAnnotation) this.resourcePackage.getNonNullAnnotation(XmlAccessorTypeAnnotation.ANNOTATION_NAME);
+ }
+
+
+ // ********** access order **********
+
+ public XmlAccessOrder getAccessOrder() {
+ return (this.specifiedAccessOrder != null) ? this.specifiedAccessOrder : this.getDefaultAccessOrder();
+ }
+
+ public XmlAccessOrder getSpecifiedAccessOrder() {
+ return this.specifiedAccessOrder;
+ }
+
+ public void setSpecifiedAccessOrder(XmlAccessOrder accessOrder) {
+ this.getAccessorOrderAnnotation().setValue(XmlAccessOrder.toJavaResourceModel(accessOrder));
+ this.setSpecifiedAccessOrder_(accessOrder);
+ }
+
+ protected void setSpecifiedAccessOrder_(XmlAccessOrder accessOrder) {
+ XmlAccessOrder old = this.specifiedAccessOrder;
+ this.specifiedAccessOrder = accessOrder;
+ this.firePropertyChanged(SPECIFIED_ACCESS_ORDER_PROPERTY, old, accessOrder);
+ }
+
+ public XmlAccessOrder getDefaultAccessOrder() {
+ return XmlAccessOrder.UNDEFINED;
+ }
+
+ protected XmlAccessOrder getResourceAccessOrder() {
+ return XmlAccessOrder.fromJavaResourceModel(this.getAccessorOrderAnnotation().getValue());
+ }
+
+ protected XmlAccessorOrderAnnotation getAccessorOrderAnnotation() {
+ return (XmlAccessorOrderAnnotation) this.resourcePackage.getNonNullAnnotation(XmlAccessorOrderAnnotation.ANNOTATION_NAME);
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallConfig.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallConfig.java
index 9a553f6d48..72802e9409 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallConfig.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallConfig.java
@@ -62,7 +62,7 @@ public class JaxbFacetInstallConfig
super.setProjectFacetVersion(fv);
this.changeSupport.firePropertyChange(PROJECT_FACET_VERSION_PROPERTY, oldFv, fv);
adjustLibraryProviders();
- if (getLibraryInstallDelegate().getProjectFacetVersion().equals(getProjectFacetVersion())) {
+ if (getLibraryInstallDelegate() != null && getLibraryInstallDelegate().getProjectFacetVersion().equals(getProjectFacetVersion())) {
getLibraryInstallDelegate().dispose();
setLibraryInstallDelegate(buildLibraryInstallDelegate());
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformManagerImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformManagerImpl.java
index 487a4bfb3c..6c1baaa6db 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformManagerImpl.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformManagerImpl.java
@@ -18,7 +18,6 @@ import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.internal.XPointUtil.XPointException;
import org.eclipse.jpt.jaxb.core.JaxbFacet;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
@@ -244,7 +243,7 @@ public class JaxbPlatformManagerImpl
}
public JaxbPlatformDefinition buildJaxbPlatformDefinition(IProject project) {
- String jaxbPlatformId = JptCorePlugin.getJpaPlatformId(project);
+ String jaxbPlatformId = JptJaxbCorePlugin.getJaxbPlatformId(project);
JaxbPlatformDescriptionImpl platformDesc = this.platformDescriptions.getItem(jaxbPlatformId);
if (platformDesc == null) {
throw new IllegalArgumentException("Project does not have a recognized JAXB platform."); //$NON-NLS-1$
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullAnnotation.java
new file mode 100644
index 0000000000..6c2b530a66
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullAnnotation.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.internal.resource.java.source.AbstractJavaResourceNode;
+import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMember;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceNode;
+
+/**
+ * Simplify null annotation classes
+ */
+public abstract class NullAnnotation
+ extends AbstractJavaResourceNode
+ implements Annotation
+{
+
+ protected NullAnnotation(JavaResourceNode parent) {
+ super(parent);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ // do nothing
+ }
+
+ public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) {
+ return null;
+ }
+
+ public JavaResourceCompilationUnit getJavaResourceCompilationUnit() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void newAnnotation() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeAnnotation() {
+ throw new UnsupportedOperationException();
+ }
+
+ public TextRange getTextRange(CompilationUnit astRoot) {
+ return null;
+ }
+
+ public void synchronizeWith(CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Convenience method: Cast the annotation's parent to a
+ * persistent member.
+ */
+ protected JavaResourceMember getMember() {
+ return (JavaResourceMember) this.parent;
+ }
+
+ /**
+ * Convenience method: Add the type or attribute's annotation
+ * and return it.
+ * Pre-condition: The annotation's parent must be a persistent member
+ * (type or attribute).
+ */
+ protected Annotation addAnnotation() {
+ return this.getMember().addAnnotation(this.getAnnotationName());
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlAccessorOrderAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlAccessorOrderAnnotation.java
new file mode 100644
index 0000000000..910da51272
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlAccessorOrderAnnotation.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.jaxb.core.internal.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation;
+
+/**
+ * javax.xml.bind.annotation.XmlAccessorOrder
+ */
+public final class NullXmlAccessorOrderAnnotation
+ extends NullAnnotation
+ implements XmlAccessorOrderAnnotation
+{
+ protected NullXmlAccessorOrderAnnotation(JavaResourceAnnotatedElement parent) {
+ super(parent);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ @Override
+ protected XmlAccessorOrderAnnotation addAnnotation() {
+ return (XmlAccessorOrderAnnotation) super.addAnnotation();
+ }
+
+
+ // ********** XmlAccessorTOrderAnnotation implementation **********
+
+ // ***** value
+ public XmlAccessOrder getValue() {
+ return null;
+ }
+
+ public void setValue(XmlAccessOrder value) {
+ if (value != null) {
+ this.addAnnotation().setValue(value);
+ }
+ }
+
+ public TextRange getValueTextRange(CompilationUnit astRoot) {
+ return null;
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlAccessorTypeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlAccessorTypeAnnotation.java
new file mode 100644
index 0000000000..83b59bccb0
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/NullXmlAccessorTypeAnnotation.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.jaxb.core.internal.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
+
+/**
+ * javax.xml.bind.annotation.XmlAccessorType
+ */
+public final class NullXmlAccessorTypeAnnotation
+ extends NullAnnotation
+ implements XmlAccessorTypeAnnotation
+{
+ protected NullXmlAccessorTypeAnnotation(JavaResourceAnnotatedElement parent) {
+ super(parent);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ @Override
+ protected XmlAccessorTypeAnnotation addAnnotation() {
+ return (XmlAccessorTypeAnnotation) super.addAnnotation();
+ }
+
+
+ // ********** XmlAccessorTypeAnnotation implementation **********
+
+ // ***** value
+ public XmlAccessType getValue() {
+ return null;
+ }
+
+ public void setValue(XmlAccessType value) {
+ if (value != null) {
+ this.addAnnotation().setValue(value);
+ }
+ }
+
+ public TextRange getValueTextRange(CompilationUnit astRoot) {
+ return null;
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlAccessorOrderAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlAccessorOrderAnnotationDefinition.java
index cecc953311..890da0ef99 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlAccessorOrderAnnotationDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlAccessorOrderAnnotationDefinition.java
@@ -46,7 +46,7 @@ public final class XmlAccessorOrderAnnotationDefinition
}
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
- throw new UnsupportedOperationException();
+ return new NullXmlAccessorOrderAnnotation(parent);
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlAccessorTypeAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlAccessorTypeAnnotationDefinition.java
index 441c4e82f2..43d9fc14e0 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlAccessorTypeAnnotationDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlAccessorTypeAnnotationDefinition.java
@@ -46,7 +46,7 @@ public final class XmlAccessorTypeAnnotationDefinition
}
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
- throw new UnsupportedOperationException();
+ return new NullXmlAccessorTypeAnnotation(parent);
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/META-INF/MANIFEST.MF b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/META-INF/MANIFEST.MF
index 5dfc3752d3..5baa1e13d7 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/META-INF/MANIFEST.MF
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/META-INF/MANIFEST.MF
@@ -15,6 +15,7 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.6.100,4.0.0)",
org.eclipse.jpt.core.tests;bundle-version="[2.4.0,3.0.0)",
org.eclipse.jpt.jaxb.core;bundle-version="[1.0.0,2.0.0)",
org.eclipse.jpt.utility;bundle-version="[1.6.0,2.0.0)",
+ org.eclipse.jst.common.project.facet.core;bundle-version="[1.4.200,2.0.0)",
org.eclipse.wst.common.frameworks;bundle-version="[1.2.0,2.0.0)",
- org.junit;bundle-version="3.8.0",
- org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.200,2.0.0)"
+ org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.200,2.0.0)",
+ org.junit;bundle-version="3.8.0"
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/JptJaxbCoreTestsPlugin.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/JptJaxbCoreTestsPlugin.java
index 2037b78472..69df17f13c 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/JptJaxbCoreTestsPlugin.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/JptJaxbCoreTestsPlugin.java
@@ -10,6 +10,9 @@
package org.eclipse.jpt.jaxb.core.tests;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jpt.jaxb.core.JaxbProjectManager;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.osgi.framework.BundleContext;
/**
@@ -40,9 +43,9 @@ public class JptJaxbCoreTestsPlugin extends Plugin {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
-// JpaProjectManager jpaProjectManager = JptCorePlugin.getJpaProjectManager();
-// ReflectionTools.executeMethod(jpaProjectManager, "handleEventsSynchronously");
-// ReflectionTools.executeStaticMethod(JptCorePlugin.class, "doNotFlushPreferences");
+ JaxbProjectManager jaxbProjectManager = JptJaxbCorePlugin.getProjectManager();
+ ReflectionTools.executeMethod(jaxbProjectManager, "handleEventsSynchronously");
+// ReflectionTools.executeStaticMethod(JptJaxbCorePlugin.class, "doNotFlushPreferences");
}
@Override
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/JaxbCoreTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/JaxbCoreTests.java
index 9b97d3854c..4aa0cef7f9 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/JaxbCoreTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/JaxbCoreTests.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbCoreContextModelTests;
import org.eclipse.jpt.jaxb.core.tests.internal.resource.JaxbCoreResourceModelTests;
public class JaxbCoreTests {
@@ -18,6 +19,7 @@ public class JaxbCoreTests {
public static Test suite() {
TestSuite suite = new TestSuite(JaxbCoreTests.class.getPackage().getName());
suite.addTest(JaxbCoreResourceModelTests.suite());
+ suite.addTest(JaxbCoreContextModelTests.suite());
return suite;
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbContextModelTestCase.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbContextModelTestCase.java
index 150486f507..7227f2800c 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbContextModelTestCase.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbContextModelTestCase.java
@@ -11,9 +11,14 @@ package org.eclipse.jpt.jaxb.core.tests.internal.context;
import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject;
import org.eclipse.jpt.core.tests.internal.utility.jdt.AnnotationTestCase;
+import org.eclipse.jpt.jaxb.core.JaxbFacet;
import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
+import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetInstallConfig;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
import org.eclipse.jpt.jaxb.core.tests.internal.projects.TestJaxbProject;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@SuppressWarnings("nls")
public abstract class JaxbContextModelTestCase extends AnnotationTestCase
@@ -27,28 +32,32 @@ public abstract class JaxbContextModelTestCase extends AnnotationTestCase
@Override
protected TestJavaProject buildJavaProject(boolean autoBuild) throws Exception {
- return buildJaxbProject(BASE_PROJECT_NAME, autoBuild, null);
+ return buildJaxbProject(BASE_PROJECT_NAME, autoBuild, buildJaxbFacetInstallConfig());
}
- protected TestJaxbProject buildJaxbProject(String projectName, boolean autoBuild, IDataModel jaxbConfig)
+ protected TestJaxbProject buildJaxbProject(String projectName, boolean autoBuild, JaxbFacetInstallConfig jaxbConfig)
throws Exception {
return TestJaxbProject.buildJaxbProject(projectName, autoBuild, jaxbConfig);
}
-// protected IDataModel buildJaxbConfigDataModel() {
-// IDataModel dataModel = DataModelFactory.createDataModel(new JaxbFacetInstallDataModelProvider());
-// // 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, GenericPlatform.VERSION_1_0);
-// // most tests do use an orm.xml
-// dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
-// return dataModel;
-// }
-//
-// protected JaxbRootContextNode getRootContextNode() {
-// return this.getJaxbProject().getRootContextNode();
-// }
+ protected JaxbFacetInstallConfig buildJaxbFacetInstallConfig() {
+ JaxbFacetInstallConfig config = new JaxbFacetInstallConfig();
+ config.setProjectFacetVersion(getProjectFacetVersion());
+ config.setPlatform(getPlatform());
+ return config;
+ }
+
+ protected JaxbPlatformDescription getPlatform() {
+ return JptJaxbCorePlugin.getDefaultPlatform(getProjectFacetVersion());
+ }
+
+ protected IProjectFacetVersion getProjectFacetVersion() {
+ return JaxbFacet.VERSION_2_1;
+ }
+
+ protected JaxbRootContextNode getRootContextNode() {
+ return this.getJaxbProject().getRootContextNode();
+ }
@Override
protected TestJaxbProject getJavaProject() {
@@ -58,8 +67,4 @@ public abstract class JaxbContextModelTestCase extends AnnotationTestCase
protected JaxbProject getJaxbProject() {
return this.getJavaProject().getJaxbProject();
}
-//
-// protected void deleteResource(Resource resource) throws CoreException {
-// WorkbenchResourceHelper.deleteResource(resource);
-// }
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbCoreContextModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbCoreContextModelTests.java
new file mode 100644
index 0000000000..f6ad58cdc5
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/JaxbCoreContextModelTests.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.core.tests.internal.context;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.eclipse.jpt.jaxb.core.tests.internal.context.java.JaxbCoreJavaContextModelTests;
+
+public class JaxbCoreContextModelTests extends TestCase
+{
+ public static Test suite() {
+ TestSuite suite = new TestSuite(JaxbCoreContextModelTests.class.getName());
+
+ suite.addTest(JaxbCoreJavaContextModelTests.suite());
+ return suite;
+ }
+
+ private JaxbCoreContextModelTests() {
+ super();
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java
new file mode 100644
index 0000000000..522b08d406
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPackageInfoTests.java
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * 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.jaxb.core.tests.internal.context.java;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
+import org.eclipse.jpt.jaxb.core.context.XmlAccessOrder;
+import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
+import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+
+
+@SuppressWarnings("nls")
+public class GenericJavaPackageInfoTests extends JaxbContextModelTestCase
+{
+
+ public GenericJavaPackageInfoTests(String name) {
+ super(name);
+ }
+
+ private ICompilationUnit createPackageInfoWithAccessorType() throws CoreException {
+ return createTestPackageInfo(
+ "@XmlAccessorType(value = XmlAccessType.PROPERTY)",
+ JAXB.XML_ACCESS_TYPE, JAXB.XML_ACCESSOR_TYPE);
+ }
+
+ private ICompilationUnit createPackageInfoWithAccessorOrder() throws CoreException {
+ return createTestPackageInfo(
+ "@XmlAccessorOrder(value = XmlAccessOrder.ALPHABETICAL)",
+ JAXB.XML_ACCESS_ORDER, JAXB.XML_ACCESSOR_ORDER);
+ }
+
+ public void testModifyAccessType() throws Exception {
+ createPackageInfoWithAccessorType();
+ JaxbPackageInfo contextPackageInfo = CollectionTools.get(getRootContextNode().getPackages(), 0).getPackageInfo();
+ JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
+
+ assertEquals(XmlAccessType.PROPERTY, contextPackageInfo.getSpecifiedAccessType());
+ assertEquals(XmlAccessType.PROPERTY, contextPackageInfo.getAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getDefaultAccessType());
+
+ contextPackageInfo.setSpecifiedAccessType(XmlAccessType.FIELD);
+ XmlAccessorTypeAnnotation accessorTypeAnnotation = (XmlAccessorTypeAnnotation) resourcePackage.getAnnotation(XmlAccessorTypeAnnotation.ANNOTATION_NAME);
+ assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.FIELD, accessorTypeAnnotation.getValue());
+ assertEquals(XmlAccessType.FIELD, contextPackageInfo.getAccessType());
+
+ contextPackageInfo.setSpecifiedAccessType(XmlAccessType.PUBLIC_MEMBER);
+ assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.PUBLIC_MEMBER, accessorTypeAnnotation.getValue());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getAccessType());
+
+ contextPackageInfo.setSpecifiedAccessType(XmlAccessType.NONE);
+ assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.NONE, accessorTypeAnnotation.getValue());
+ assertEquals(XmlAccessType.NONE, contextPackageInfo.getAccessType());
+
+ contextPackageInfo.setSpecifiedAccessType(null);
+ accessorTypeAnnotation = (XmlAccessorTypeAnnotation) resourcePackage.getAnnotation(XmlAccessorTypeAnnotation.ANNOTATION_NAME);
+ assertNull(accessorTypeAnnotation);
+ assertNull(contextPackageInfo.getSpecifiedAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getDefaultAccessType());
+ }
+
+ public void testUpdateAccessType() throws Exception {
+ createPackageInfoWithAccessorType();
+ JaxbPackageInfo contextPackageInfo = CollectionTools.get(getRootContextNode().getPackages(), 0).getPackageInfo();
+ JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
+
+ assertEquals(XmlAccessType.PROPERTY, contextPackageInfo.getSpecifiedAccessType());
+ assertEquals(XmlAccessType.PROPERTY, contextPackageInfo.getAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getDefaultAccessType());
+
+ XmlAccessorTypeAnnotation accessorTypeAnnotation = (XmlAccessorTypeAnnotation) resourcePackage.getAnnotation(XmlAccessorTypeAnnotation.ANNOTATION_NAME);
+ accessorTypeAnnotation.setValue(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.FIELD);
+ getJaxbProject().synchronizeContextModel();
+ assertEquals(XmlAccessType.FIELD, contextPackageInfo.getAccessType());
+
+ accessorTypeAnnotation.setValue(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.PUBLIC_MEMBER);
+ getJaxbProject().synchronizeContextModel();
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getAccessType());
+
+ accessorTypeAnnotation.setValue(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType.NONE);
+ getJaxbProject().synchronizeContextModel();
+ assertEquals(XmlAccessType.NONE, contextPackageInfo.getAccessType());
+
+ //add another package annotation so that the context model object doesn't get removed when
+ //removing the XmlAccessorType annotation. Only "annotated" packages are added to the context model
+ resourcePackage.addAnnotation(XmlAccessorOrderAnnotation.ANNOTATION_NAME);
+ resourcePackage.removeAnnotation(XmlAccessorTypeAnnotation.ANNOTATION_NAME);
+ getJaxbProject().synchronizeContextModel();
+ assertNull(contextPackageInfo.getSpecifiedAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getAccessType());
+ assertEquals(XmlAccessType.PUBLIC_MEMBER, contextPackageInfo.getDefaultAccessType());
+ }
+
+ public void testModifyAccessOrder() throws Exception {
+ createPackageInfoWithAccessorOrder();
+ JaxbPackageInfo contextPackageInfo = CollectionTools.get(getRootContextNode().getPackages(), 0).getPackageInfo();
+ JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
+
+ assertEquals(XmlAccessOrder.ALPHABETICAL, contextPackageInfo.getSpecifiedAccessOrder());
+ assertEquals(XmlAccessOrder.ALPHABETICAL, contextPackageInfo.getAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getDefaultAccessOrder());
+
+ contextPackageInfo.setSpecifiedAccessOrder(XmlAccessOrder.UNDEFINED);
+ XmlAccessorOrderAnnotation accessorOrderAnnotation = (XmlAccessorOrderAnnotation) resourcePackage.getAnnotation(XmlAccessorOrderAnnotation.ANNOTATION_NAME);
+ assertEquals(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder.UNDEFINED, accessorOrderAnnotation.getValue());
+ assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getAccessOrder());
+
+ contextPackageInfo.setSpecifiedAccessOrder(null);
+ accessorOrderAnnotation = (XmlAccessorOrderAnnotation) resourcePackage.getAnnotation(XmlAccessorOrderAnnotation.ANNOTATION_NAME);
+ assertNull(accessorOrderAnnotation);
+ assertNull(contextPackageInfo.getSpecifiedAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getDefaultAccessOrder());
+ }
+
+ public void testUpdateAccessOrder() throws Exception {
+ createPackageInfoWithAccessorOrder();
+ JaxbPackageInfo contextPackageInfo = CollectionTools.get(getRootContextNode().getPackages(), 0).getPackageInfo();
+ JavaResourcePackage resourcePackage = contextPackageInfo.getResourcePackage();
+
+ assertEquals(XmlAccessOrder.ALPHABETICAL, contextPackageInfo.getSpecifiedAccessOrder());
+ assertEquals(XmlAccessOrder.ALPHABETICAL, contextPackageInfo.getAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getDefaultAccessOrder());
+
+ XmlAccessorOrderAnnotation accessorOrderAnnotation = (XmlAccessorOrderAnnotation) resourcePackage.getAnnotation(XmlAccessorOrderAnnotation.ANNOTATION_NAME);
+ accessorOrderAnnotation.setValue(org.eclipse.jpt.jaxb.core.resource.java.XmlAccessOrder.UNDEFINED);
+ getJaxbProject().synchronizeContextModel();
+ assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getAccessOrder());
+
+ //add another package annotation so that the context model object doesn't get removed when
+ //removing the XmlAccessorOrder annotation. Only "annotated" packages are added to the context model
+ resourcePackage.addAnnotation(XmlAccessorTypeAnnotation.ANNOTATION_NAME);
+ resourcePackage.removeAnnotation(XmlAccessorOrderAnnotation.ANNOTATION_NAME);
+ getJaxbProject().synchronizeContextModel();
+ assertNull(contextPackageInfo.getSpecifiedAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getAccessOrder());
+ assertEquals(XmlAccessOrder.UNDEFINED, contextPackageInfo.getDefaultAccessOrder());
+ }
+
+}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java
new file mode 100644
index 0000000000..a097b251bb
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/JaxbCoreJavaContextModelTests.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.jaxb.core.tests.internal.context.java;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class JaxbCoreJavaContextModelTests extends TestCase
+{
+ public static Test suite() {
+ TestSuite suite = new TestSuite(JaxbCoreJavaContextModelTests.class.getName());
+ suite.addTestSuite(GenericJavaPackageInfoTests.class);
+ return suite;
+ }
+
+ private JaxbCoreJavaContextModelTests() {
+ super();
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/projects/TestJaxbProject.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/projects/TestJaxbProject.java
index ac1eb0825c..a75bf5bb32 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/projects/TestJaxbProject.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/projects/TestJaxbProject.java
@@ -14,7 +14,7 @@ import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject;
import org.eclipse.jpt.jaxb.core.JaxbFacet;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetInstallConfig;
/**
* This builds and holds a "JAXB" project.
@@ -30,14 +30,9 @@ public class TestJaxbProject extends TestJavaProject {
// ********** builders **********
- public static TestJaxbProject buildJaxbProject(String baseProjectName, boolean autoBuild, IDataModel jpaConfig)
+ public static TestJaxbProject buildJaxbProject(String baseProjectName, boolean autoBuild, JaxbFacetInstallConfig config)
throws CoreException {
- return new TestJaxbProject(baseProjectName, autoBuild, jpaConfig);
- }
-
- public static TestJaxbProject buildJaxbProject(String baseProjectName, boolean autoBuild)
- throws CoreException {
- return buildJaxbProject(baseProjectName, autoBuild, null);
+ return new TestJaxbProject(baseProjectName, autoBuild, config);
}
// ********** constructors/initialization **********
@@ -50,13 +45,10 @@ public class TestJaxbProject extends TestJavaProject {
this(projectName, autoBuild, null);
}
- public TestJaxbProject(String projectName, boolean autoBuild, IDataModel jaxbConfig) throws CoreException {
+ public TestJaxbProject(String projectName, boolean autoBuild, JaxbFacetInstallConfig config) throws CoreException {
super(projectName, autoBuild);
- String jaxbFacetVersion = JaxbFacet.VERSION_2_1.getVersionString();
-// if (jaxbConfig != null) {
-// jaxbFacetVersion = jaxbConfig.getStringProperty(IFacetDataModelProperties.FACET_VERSION_STR);
-// }
- this.installFacet(JaxbFacet.ID, jaxbFacetVersion, jaxbConfig);
+ String jaxbFacetVersion = config.getProjectFacetVersion().getVersionString();
+ this.installFacet(JaxbFacet.ID, jaxbFacetVersion, config);
this.jaxbProject = JptJaxbCorePlugin.getJaxbProject(this.getProject());
// this.jaxbProject.setUpdater(new SynchronousJpaProjectUpdater(this.jaxbProject));
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAccessorTypePackageAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAccessorTypePackageAnnotationTests.java
index 39f61e6b72..fac334d210 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAccessorTypePackageAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAccessorTypePackageAnnotationTests.java
@@ -25,7 +25,7 @@ public class XmlAccessorTypePackageAnnotationTests
}
- private ICompilationUnit createPackageInfoWithAccessorOrder() throws CoreException {
+ private ICompilationUnit createPackageInfoWithAccessorType() throws CoreException {
return createTestPackageInfo(
"@XmlAccessorType(value = XmlAccessType.PROPERTY)",
JAXB.XML_ACCESS_TYPE, JAXB.XML_ACCESSOR_TYPE);
@@ -34,7 +34,7 @@ public class XmlAccessorTypePackageAnnotationTests
public void testValue()
throws Exception {
- ICompilationUnit cu = createPackageInfoWithAccessorOrder();
+ ICompilationUnit cu = createPackageInfoWithAccessorType();
JavaResourcePackage resourcePackage = buildJavaResourcePackage(cu);
XmlAccessorTypeAnnotation annotation =
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractSynchronizerJpaProjectUpdater.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractSynchronizerJpaProjectUpdater.java
index 462af6962c..cc7da709af 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractSynchronizerJpaProjectUpdater.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractSynchronizerJpaProjectUpdater.java
@@ -11,7 +11,7 @@ package org.eclipse.jpt.core.internal;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronizer;
+import org.eclipse.jpt.utility.synchronizers.CallbackSynchronizer;
/**
* Adapt the "callback synchronizer" interface to the JPA project "updater"
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AsynchronousJpaProjectUpdater.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AsynchronousJpaProjectUpdater.java
index a0f67a1386..10a8007eec 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AsynchronousJpaProjectUpdater.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AsynchronousJpaProjectUpdater.java
@@ -15,7 +15,7 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.internal.utility.CallbackJobSynchronizer;
import org.eclipse.jpt.core.internal.utility.JobCommand;
-import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronizer;
+import org.eclipse.jpt.utility.synchronizers.CallbackSynchronizer;
import org.eclipse.osgi.util.NLS;
/**
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SynchronousJpaProjectUpdater.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SynchronousJpaProjectUpdater.java
index 314b92e8d4..c65b6d269e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SynchronousJpaProjectUpdater.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SynchronousJpaProjectUpdater.java
@@ -12,8 +12,8 @@ package org.eclipse.jpt.core.internal;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.utility.Command;
-import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronizer;
import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronousSynchronizer;
+import org.eclipse.jpt.utility.synchronizers.CallbackSynchronizer;
/**
* Adapt the "callback synchronizer" interface to the JPA project "updater"
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/CallbackJobSynchronizer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/CallbackJobSynchronizer.java
index 7ddb587da5..0fc44eb082 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/CallbackJobSynchronizer.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/CallbackJobSynchronizer.java
@@ -13,7 +13,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jpt.utility.internal.ListenerList;
-import org.eclipse.jpt.utility.internal.synchronizers.CallbackSynchronizer;
+import org.eclipse.jpt.utility.synchronizers.CallbackSynchronizer;
/**
* Extend the job synchronizer to notify listeners
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/JobSynchronizer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/JobSynchronizer.java
index 30d5cf3648..63bee1f5e6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/JobSynchronizer.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/JobSynchronizer.java
@@ -14,7 +14,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.synchronizers.Synchronizer;
+import org.eclipse.jpt.utility.synchronizers.Synchronizer;
/**
* This synchronizer will perform synchronizations in an Eclipse job on a
diff --git a/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF
index 26641f1b28..d11e934e10 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF
+++ b/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF
@@ -87,4 +87,5 @@ Export-Package: org.eclipse.jpt.utility,
org.eclipse.jpt.utility.model,
org.eclipse.jpt.utility.model.event,
org.eclipse.jpt.utility.model.listener,
- org.eclipse.jpt.utility.model.value
+ org.eclipse.jpt.utility.model.value,
+ org.eclipse.jpt.utility.synchronizers
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/AsynchronousSynchronizer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/AsynchronousSynchronizer.java
index 379a11a489..ee294e847f 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/AsynchronousSynchronizer.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/AsynchronousSynchronizer.java
@@ -14,6 +14,7 @@ import java.util.concurrent.ThreadFactory;
import org.eclipse.jpt.utility.Command;
import org.eclipse.jpt.utility.internal.ConsumerThreadCoordinator;
import org.eclipse.jpt.utility.internal.SynchronizedBoolean;
+import org.eclipse.jpt.utility.synchronizers.Synchronizer;
/**
* This synchronizer will perform synchronizations in a separate thread,
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackAsynchronousSynchronizer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackAsynchronousSynchronizer.java
index 2c30a3241f..2ac2473ec6 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackAsynchronousSynchronizer.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackAsynchronousSynchronizer.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,6 +12,7 @@ package org.eclipse.jpt.utility.internal.synchronizers;
import org.eclipse.jpt.utility.Command;
import org.eclipse.jpt.utility.internal.ConsumerThreadCoordinator;
import org.eclipse.jpt.utility.internal.ListenerList;
+import org.eclipse.jpt.utility.synchronizers.CallbackSynchronizer;
/**
* Extend the asynchronous synchronizer to notify listeners
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackSynchronousSynchronizer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackSynchronousSynchronizer.java
index ab101511ec..fef11a2e2f 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackSynchronousSynchronizer.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackSynchronousSynchronizer.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.
@@ -11,6 +11,7 @@ package org.eclipse.jpt.utility.internal.synchronizers;
import org.eclipse.jpt.utility.Command;
import org.eclipse.jpt.utility.internal.ListenerList;
+import org.eclipse.jpt.utility.synchronizers.CallbackSynchronizer;
/**
* Extend the synchronous synchronizer to notify listeners
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/SynchronousSynchronizer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/SynchronousSynchronizer.java
index ea0c6090e9..271c51ceaf 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/SynchronousSynchronizer.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/SynchronousSynchronizer.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.
@@ -10,11 +10,11 @@
package org.eclipse.jpt.utility.internal.synchronizers;
import java.util.Vector;
-
import org.eclipse.jpt.utility.Command;
import org.eclipse.jpt.utility.internal.CompositeException;
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.SynchronizedObject;
+import org.eclipse.jpt.utility.synchronizers.Synchronizer;
/**
* This synchronizer will synchronize immediately and not return until the
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackSynchronizer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/synchronizers/CallbackSynchronizer.java
index 441a06d342..f6954f473c 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/CallbackSynchronizer.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/synchronizers/CallbackSynchronizer.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.
@@ -7,8 +7,9 @@
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
-package org.eclipse.jpt.utility.internal.synchronizers;
+package org.eclipse.jpt.utility.synchronizers;
+import java.io.Serializable;
import java.util.EventListener;
/**
@@ -48,4 +49,44 @@ public interface CallbackSynchronizer
void synchronizationQuiesced(CallbackSynchronizer synchronizer);
}
+
+ /**
+ * Singleton implementation of the {@link CallbackSynchronizer} interface that will do
+ * nothing.
+ */
+ final class Null implements CallbackSynchronizer, Serializable {
+ public static final CallbackSynchronizer INSTANCE = new Null();
+ public static CallbackSynchronizer instance() {
+ return INSTANCE;
+ }
+ // ensure single instance
+ private Null() {
+ super();
+ }
+ public void start() {
+ // do nothing
+ }
+ public void synchronize() {
+ // do nothing
+ }
+ public void stop() {
+ // do nothing
+ }
+ public void addListener(Listener listener) {
+ // do nothing
+ }
+ public void removeListener(Listener listener) {
+ // do nothing
+ }
+ @Override
+ public String toString() {
+ return "CallbackSynchronizer.Null"; //$NON-NLS-1$
+ }
+ private static final long serialVersionUID = 1L;
+ private Object readResolve() {
+ // replace this object with the singleton
+ return INSTANCE;
+ }
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/Synchronizer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/synchronizers/Synchronizer.java
index 7b5a459ec6..e1041f6302 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/synchronizers/Synchronizer.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/synchronizers/Synchronizer.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.
@@ -7,7 +7,7 @@
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
-package org.eclipse.jpt.utility.internal.synchronizers;
+package org.eclipse.jpt.utility.synchronizers;
import java.io.Serializable;
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java
index 14682ba6af..f889fddf42 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java
@@ -10,7 +10,6 @@
package org.eclipse.jpt.core.tests.internal.projects;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
@@ -64,12 +63,18 @@ public class TestFacetedProject extends TestPlatformProject {
/**
* if 'config' is null (and 'facetName' is "jpt.jpa"), the JPA project will be built with the defaults
* defined in JpaFacetInstallDataModelProvider#getDefaultProperty(String)
+ * In JPA the config object will be an IDataModel
+ * In JAXB the config object will be a JaxbFacetInstallConfig
*/
- public void installFacet(String facetName, String versionName, IDataModel config) throws CoreException {
+ public void installFacet(String facetName, String versionName, Object config) throws CoreException {
this.facetedProject.installProjectFacet(this.facetVersion(facetName, versionName), config, null);
}
- public void uninstallFacet(String facetName, String versionName, IDataModel config) throws CoreException {
+ /**
+ * In JPA the config object will be an IDataModel
+ * In JAXB the config object will be a JaxbFacetUninstallConfig
+ */
+ public void uninstallFacet(String facetName, String versionName, Object config) throws CoreException {
this.facetedProject.uninstallProjectFacet(this.facetVersion(facetName, versionName), config, null);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/AsynchronousSynchronizerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/AsynchronousSynchronizerTests.java
index a30814a2fd..0b42a0c55b 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/AsynchronousSynchronizerTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/AsynchronousSynchronizerTests.java
@@ -14,7 +14,7 @@ import org.eclipse.jpt.utility.internal.CompositeException;
import org.eclipse.jpt.utility.internal.ConsumerThreadCoordinator;
import org.eclipse.jpt.utility.internal.ReflectionTools;
import org.eclipse.jpt.utility.internal.synchronizers.AsynchronousSynchronizer;
-import org.eclipse.jpt.utility.internal.synchronizers.Synchronizer;
+import org.eclipse.jpt.utility.synchronizers.Synchronizer;
import org.eclipse.jpt.utility.tests.internal.MultiThreadedTestCase;
@SuppressWarnings("nls")
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronizerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronizerTests.java
index 95d9d50315..a03b7cb621 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronizerTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronizerTests.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.
@@ -10,8 +10,7 @@
package org.eclipse.jpt.utility.tests.internal.synchronizers;
import junit.framework.TestCase;
-
-import org.eclipse.jpt.utility.internal.synchronizers.Synchronizer;
+import org.eclipse.jpt.utility.synchronizers.Synchronizer;
public class SynchronizerTests extends TestCase {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java
index 2ceea2b2f7..1c242dd570 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java
@@ -12,8 +12,8 @@ package org.eclipse.jpt.utility.tests.internal.synchronizers;
import org.eclipse.jpt.utility.Command;
import org.eclipse.jpt.utility.internal.CompositeException;
import org.eclipse.jpt.utility.internal.SynchronizedBoolean;
-import org.eclipse.jpt.utility.internal.synchronizers.Synchronizer;
import org.eclipse.jpt.utility.internal.synchronizers.SynchronousSynchronizer;
+import org.eclipse.jpt.utility.synchronizers.Synchronizer;
import org.eclipse.jpt.utility.tests.internal.MultiThreadedTestCase;
import org.eclipse.jpt.utility.tests.internal.TestTools;

Back to the top