Search in sources :

Example 1 with ComponentCacheResourceFactoryImpl

use of org.talend.core.model.component_cache.util.ComponentCacheResourceFactoryImpl in project tdi-studio-se by Talend.

the class ComponentsFactory method loadComponentResource.

/**
     * DOC guanglong.du Comment method "loadComponentResource".
     * 
     * @param eclipseProject
     * @return
     * @throws IOException
     */
private ComponentsCache loadComponentResource(String installLocation) throws IOException {
    String filePath = ComponentsFactory.TALEND_COMPONENT_CACHE + LanguageManager.getCurrentLanguage().toString().toLowerCase() + ComponentsFactory.TALEND_FILE_NAME;
    URI uri = URI.createFileURI(installLocation).appendSegment(filePath);
    ComponentCacheResourceFactoryImpl compFact = new ComponentCacheResourceFactoryImpl();
    Resource resource = compFact.createResource(uri);
    Map optionMap = new HashMap();
    optionMap.put(XMLResource.OPTION_DEFER_ATTACHMENT, Boolean.TRUE);
    optionMap.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
    optionMap.put(XMLResource.OPTION_USE_PARSER_POOL, new XMLParserPoolImpl());
    optionMap.put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, new HashMap());
    optionMap.put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE);
    resource.load(optionMap);
    ComponentsCache cache = (ComponentsCache) EcoreUtil.getObjectByType(resource.getContents(), ComponentCachePackage.eINSTANCE.getComponentsCache());
    return cache;
}
Also used : HashMap(java.util.HashMap) XMLParserPoolImpl(org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl) Resource(org.eclipse.emf.ecore.resource.Resource) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) ComponentsCache(org.talend.core.model.component_cache.ComponentsCache) URI(org.eclipse.emf.common.util.URI) Map(java.util.Map) HashMap(java.util.HashMap) ComponentCacheResourceFactoryImpl(org.talend.core.model.component_cache.util.ComponentCacheResourceFactoryImpl)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 URI (org.eclipse.emf.common.util.URI)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)1 XMLParserPoolImpl (org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl)1 ComponentsCache (org.talend.core.model.component_cache.ComponentsCache)1 ComponentCacheResourceFactoryImpl (org.talend.core.model.component_cache.util.ComponentCacheResourceFactoryImpl)1