blob: d77915cd3043580c8875258e4ba8fee5a00eeeb9 [file] [log] [blame]
/*****************************************************************************
* 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
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* 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;
import org.eclipse.emf.internal.cdo.view.CDOViewImpl.OptionsImpl;
import org.eclipse.emf.spi.cdo.InternalCDOView;
import org.eclipse.uml2.common.util.CacheAdapter;
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 {
if (!isLoaded()) {
Boolean lazy = Boolean.getBoolean(ORG_ECLIPSE_PAPYRUS_LAZY_CDO_RESOURCE_LOADING);
if (!lazy) {
cdoPrefetch(CDORevision.DEPTH_INFINITE);
InternalCDOView cdoView = this.cdoView();
((OptionsImpl) cdoView.options()).setLockStatePrefetchEnabled(true);
CacheAdapter cacheAdapter = CacheAdapter.getInstance();
if (cacheAdapter.getClass() != NonLazyPapyrusCDOCacheAdapter.class) {
NonLazyPapyrusCDOCacheAdapter.register(new NonLazyPapyrusCDOCacheAdapter());
}
}
super.load(options);
}
}
/**
* Constructor.
*
*/
public PapyrusCDOResourceImpl(URI uri) {
super(uri);
}
/**
* @see org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getDefaultSaveOptions()
*
* @return
*/
@Override
public Map<Object, Object> getDefaultSaveOptions() {
return new HashMap<Object, Object>();
}
}