Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-09-15 17:06:30 +0000
committerEike Stepper2012-09-15 17:06:30 +0000
commitc5f8afb091979d794f7b023f98bbc6a748d90f48 (patch)
tree9a93cd1a1031b029959b61118cd605e3d7ec8c24 /plugins
parent1d259077a25c67e5789b2b76074df799a01e3265 (diff)
downloadcdo-c5f8afb091979d794f7b023f98bbc6a748d90f48.tar.gz
cdo-c5f8afb091979d794f7b023f98bbc6a748d90f48.tar.xz
cdo-c5f8afb091979d794f7b023f98bbc6a748d90f48.zip
[388928] Develop a resource transfer framework
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388928
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.transfer.repository.ui/src/org/eclipse/emf/cdo/transfer/repository/internal/ui/RepositoryUIProvider.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.transfer.repository/src/org/eclipse/emf/cdo/transfer/spi/repository/RepositoryTransferSystem.java80
2 files changed, 80 insertions, 6 deletions
diff --git a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/src/org/eclipse/emf/cdo/transfer/repository/internal/ui/RepositoryUIProvider.java b/plugins/org.eclipse.emf.cdo.transfer.repository.ui/src/org/eclipse/emf/cdo/transfer/repository/internal/ui/RepositoryUIProvider.java
index 9ed2de9783..3f199c8d75 100644
--- a/plugins/org.eclipse.emf.cdo.transfer.repository.ui/src/org/eclipse/emf/cdo/transfer/repository/internal/ui/RepositoryUIProvider.java
+++ b/plugins/org.eclipse.emf.cdo.transfer.repository.ui/src/org/eclipse/emf/cdo/transfer/repository/internal/ui/RepositoryUIProvider.java
@@ -57,8 +57,8 @@ public class RepositoryUIProvider implements TransferUIProvider
{
if (target instanceof CDOTransaction)
{
- CDOTransferSystem system = new RepositoryTransferSystem((CDOTransaction)target);
- return system.getElement("/");
+ CDOTransferSystem system = RepositoryTransferSystem.getInstance((CDOTransaction)target);
+ return system.getElement("");
}
if (target instanceof CDOResourceFolder)
@@ -67,7 +67,7 @@ public class RepositoryUIProvider implements TransferUIProvider
String path = folder.getPath();
CDOView view = folder.cdoView();
- CDOTransferSystem system = new RepositoryTransferSystem(view);
+ CDOTransferSystem system = RepositoryTransferSystem.getInstance(view);
return system.getElement(path);
}
diff --git a/plugins/org.eclipse.emf.cdo.transfer.repository/src/org/eclipse/emf/cdo/transfer/spi/repository/RepositoryTransferSystem.java b/plugins/org.eclipse.emf.cdo.transfer.repository/src/org/eclipse/emf/cdo/transfer/spi/repository/RepositoryTransferSystem.java
index c00978de68..f389be5597 100644
--- a/plugins/org.eclipse.emf.cdo.transfer.repository/src/org/eclipse/emf/cdo/transfer/spi/repository/RepositoryTransferSystem.java
+++ b/plugins/org.eclipse.emf.cdo.transfer.repository/src/org/eclipse/emf/cdo/transfer/spi/repository/RepositoryTransferSystem.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.transfer.spi.repository;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.lob.CDOBlob;
import org.eclipse.emf.cdo.common.lob.CDOClob;
@@ -25,9 +26,15 @@ import org.eclipse.emf.cdo.transfer.CDOTransferSystem;
import org.eclipse.emf.cdo.transfer.CDOTransferType;
import org.eclipse.emf.cdo.util.CDOURIUtil;
import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.io.IORuntimeException;
import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.net4j.util.ref.ReferenceValueMap;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
@@ -43,6 +50,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
/**
* @author Eike Stepper
@@ -52,9 +62,15 @@ public class RepositoryTransferSystem extends CDOTransferSystem
{
public static final String TYPE = "repository";
- private CDOView view;
+ private static final Map<CDOView, RepositoryTransferSystem> INSTANCES = new WeakHashMap<CDOView, RepositoryTransferSystem>();
- public RepositoryTransferSystem(CDOView view)
+ private static final IListener VIEW_LISTENER = new ViewListener();
+
+ private final CDOView view;
+
+ private final Map<IPath, CDOResourceNode> resourceNodeCache = new ReferenceValueMap.Soft<IPath, CDOResourceNode>();
+
+ private RepositoryTransferSystem(CDOView view)
{
super(view.isReadOnly());
this.view = view;
@@ -78,7 +94,7 @@ public class RepositoryTransferSystem extends CDOTransferSystem
CDOBranch branch = view.getBranch();
CDOSession session = view.getSession();
CDOTransaction transaction = session.openTransaction(branch);
- return new RepositoryTransferSystem(transaction);
+ return getInstance(transaction);
}
return this;
@@ -125,6 +141,7 @@ public class RepositoryTransferSystem extends CDOTransferSystem
@Override
public CDOTransferElement getElement(IPath path)
{
+ System.out.println("Get element for: " + path);
if (path.isEmpty())
{
return new RootElement(this, view.getRootResource());
@@ -200,6 +217,63 @@ public class RepositoryTransferSystem extends CDOTransferSystem
return "Repository " + view.getSession().getRepositoryInfo().getName();
}
+ protected void handleViewInvalidation(CDOViewInvalidationEvent event)
+ {
+ Set<CDOObject> dirtyObjects = event.getDirtyObjects();
+ }
+
+ public static RepositoryTransferSystem getInstance(CDOView view)
+ {
+ synchronized (INSTANCES)
+ {
+ RepositoryTransferSystem instance = INSTANCES.get(view);
+ if (instance == null)
+ {
+ instance = new RepositoryTransferSystem(view);
+ view.addListener(VIEW_LISTENER);
+ INSTANCES.put(view, instance);
+ }
+
+ return instance;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static class ViewListener extends LifecycleEventAdapter
+ {
+ @Override
+ protected void onDeactivated(ILifecycle view)
+ {
+ synchronized (INSTANCES)
+ {
+ INSTANCES.remove(view);
+ }
+ }
+
+ @Override
+ protected void notifyOtherEvent(IEvent event)
+ {
+ if (event instanceof CDOViewInvalidationEvent)
+ {
+ CDOViewInvalidationEvent e = (CDOViewInvalidationEvent)event;
+ CDOView view = e.getSource();
+
+ RepositoryTransferSystem instance;
+ synchronized (INSTANCES)
+ {
+ instance = INSTANCES.get(view);
+ }
+
+ if (instance != null)
+ {
+ instance.handleViewInvalidation(e);
+ }
+ }
+ }
+ }
+
/**
* @author Eike Stepper
*/

Back to the top