blob: dbcbace66154a36832e6ea58de83b985e1b19e5a [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010, 2014 Willink Transformations and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* E.D.Willink - initial API and implementation
*******************************************************************************/
package org.eclipse.qvtd.pivot.qvttemplate;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.qvtd.pivot.qvtbase.QVTbasePivotStandaloneSetup;
import org.eclipse.qvtd.pivot.qvttemplate.scoping.QVTtemplatePivotScoping;
import com.google.inject.Guice;
import com.google.inject.Injector;
/**
* Initialization support for Pivot models without equinox extension registry
*/
public class QVTtemplatePivotStandaloneSetup //implements ISetup
{
private static Injector injector = null;
public static void doSetup() {
if (injector == null) {
injector = new QVTtemplatePivotStandaloneSetup().createInjectorAndDoEMFRegistration();
}
}
public static void init() {
QVTbasePivotStandaloneSetup.doSetup();
QVTtemplatePivotScoping.init();
}
/**
* Return the Injector for this plugin.
*/
public static final Injector getInjector() {
if (injector == null) {
doSetup();
}
return injector;
}
public Injector createInjector() {
if (Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove("xmi");
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey(Resource.Factory.Registry.DEFAULT_EXTENSION))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
return Guice.createInjector(/*new org.eclipse.ocl.xtext.essentialocl.EssentialOCLRuntimeModule()*/);
}
public Injector createInjectorAndDoEMFRegistration() {
init();
// register default ePackages
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"xmi", new org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl());
if (!EPackage.Registry.INSTANCE.containsKey(QVTtemplatePackage.eNS_URI))
EPackage.Registry.INSTANCE.put(QVTtemplatePackage.eNS_URI, QVTtemplatePackage.eINSTANCE);
Injector injector = createInjector();
register(injector);
return injector;
}
public void register(Injector injector) {
// org.eclipse.xtext.resource.IResourceFactory resourceFactory = injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
// org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider = injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
// Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("essentialocl", resourceFactory);
// org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("essentialocl", serviceProvider);
}
}