Bug 566942 - Workaround some performance issues with CDO by enabling
DEPTH_INFINITE prefetch of CDO resources by default.

The org.eclipse.papyrus.cdo.core.resource.PapyrusCDOResourceImpl.ORG_ECLIPSE_PAPYRUS_LAZY_CDO_RESOURCE_LOADING
System property can be used to avoid this DEPTH_INFINITE prefetch.

Change-Id: I0cd96a48929f8af2e631c08eb63884f783274bbb
diff --git a/cdo/bundles/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusCDOResourceImpl.java b/cdo/bundles/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusCDOResourceImpl.java
index 66efef4..443947a 100644
--- a/cdo/bundles/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusCDOResourceImpl.java
+++ b/cdo/bundles/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/PapyrusCDOResourceImpl.java
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (c) 2017 CEA LIST and others.
+ * Copyright (c) 2017, 2020 CEA LIST and others.
  * 
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -10,23 +10,42 @@
  *
  * Contributors:
  *   CEA LIST - Initial API and implementation
+ *   CEA LIST - Bug 566942
  *   
  *****************************************************************************/
 
 package org.eclipse.papyrus.cdo.core.resource;
 
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.eclipse.emf.cdo.common.revision.CDORevision;
 import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
 import org.eclipse.emf.common.util.URI;
 
-/**
- * @author XZ223605
- * needed to be compatible with internationnalization
- */
 public class PapyrusCDOResourceImpl extends CDOResourceImpl {
-	
+
+	/**
+	 * Set this System property to true to avoid resource DEPTH_INFINITE prefetch.
+	 */
+	public static final String ORG_ECLIPSE_PAPYRUS_LAZY_CDO_RESOURCE_LOADING = "org.eclipse.papyrus.lazyCDOResourceLoading"; //$NON-NLS-1$
+
+	/**
+	 * @see org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#load(java.util.Map)
+	 *
+	 * @param options
+	 * @throws IOException
+	 */
+	@Override
+	public void load(Map<?, ?> options) throws IOException {
+		super.load(options);
+		Boolean lazy = Boolean.getBoolean(ORG_ECLIPSE_PAPYRUS_LAZY_CDO_RESOURCE_LOADING);
+		if (!lazy) {
+			cdoPrefetch(CDORevision.DEPTH_INFINITE);
+		}
+	}
+
 	/**
 	 * Constructor.
 	 *
@@ -44,5 +63,5 @@
 	public Map<Object, Object> getDefaultSaveOptions() {
 		return new HashMap<Object, Object>();
 	}
-	
+
 }