blob: 8e3c3a2fc4b999a75a9404d2e319e51cd7f21289 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/**
* <copyright>
*
* Copyright (c) 2010,2011 E.D.Willink 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
*
* </copyright>
*/
package org.eclipse.qvtd.pivot.qvtcore;
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.qvtcore.scoping.QVTcorePivotScoping;
import org.eclipse.qvtd.pivot.qvtcore.utilities.QVTcoreASResourceFactory;
import org.eclipse.qvtd.pivot.qvtcore.utilities.QVTcoreToStringVisitor;
import org.eclipse.qvtd.pivot.qvtcorebase.QVTcoreBasePivotStandaloneSetup;
import com.google.inject.Guice;
import com.google.inject.Injector;
/**
* Initialization support for Pivot models without equinox extension registry
*/
public class QVTcorePivotStandaloneSetup //implements ISetup
{
private static Injector injector = null;
public static void doSetup() {
if (injector == null) {
injector = new QVTcorePivotStandaloneSetup().createInjectorAndDoEMFRegistration();
}
}
public static void init() {
QVTcoreBasePivotStandaloneSetup.doSetup();
QVTcoreASResourceFactory.INSTANCE.getClass();
QVTcorePivotScoping.init();
QVTcoreToStringVisitor.FACTORY.getClass();
}
/**
* 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.examples.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(QVTcorePackage.eNS_URI))
EPackage.Registry.INSTANCE.put(QVTcorePackage.eNS_URI, QVTcorePackage.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);
}
}
|