org.eclipse.epsilon.emc.emf.CachedResourceSet Maven / Gradle / Ivy
The newest version!
/*********************************************************************
* Copyright (c) 2008 The University of York.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipse.epsilon.emc.emf;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
public class CachedResourceSet extends ResourceSetImpl {
protected static final Cache cache = new Cache();
public static Cache getCache() {
return cache;
}
@Override
public Resource createResource(URI uri, String contentType) {
Resource cachedResource = getCache().checkoutResource(uri);
if (cachedResource == null) {
cachedResource = createNewResource(uri, contentType);
cachedResource.setTrackingModification(false);
if (cachedResource instanceof XMLResource) {
configure((XMLResource) cachedResource);
}
getResources().add(cachedResource);
getCache().cacheResource(uri, cachedResource);
}
return cachedResource;
}
public Resource createNewResource(URI uri, String contentType) {
Resource resource = super.createResource(uri, contentType);
if (resource == null) {
resource = new XMIResourceFactoryImpl().createResource(uri);
}
return resource;
}
public void configure(XMLResource resource) {
Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy