diff options
Diffstat (limited to 'plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/middleend/MiddleEndFactory.java')
-rw-r--r-- | plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/middleend/MiddleEndFactory.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/middleend/MiddleEndFactory.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/middleend/MiddleEndFactory.java new file mode 100644 index 00000000..6321bb2a --- /dev/null +++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/middleend/MiddleEndFactory.java @@ -0,0 +1,49 @@ +/* +Copyright (c) 2008 Arno Haase. +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: + Arno Haase - initial API and implementation + */ +package org.eclipse.xtend.middleend; + +import java.util.List; +import java.util.Map; + +import org.eclipse.xtend.backend.common.BackendTypesystem; +import org.eclipse.xtend.middleend.internal.Activator; +import org.eclipse.xtend.middleend.internal.MiddleEndImpl; +import org.eclipse.xtend.middleend.plugins.LanguageSpecificMiddleEnd; + + +/** + * This class encapsulates the OSGi / Eclipse extension registry specific behavior and + * initialization code. It serves as an optional wrapper / convenience initialization + * code for the actual MiddleEnd class. + * + * @author Arno Haase (http://www.haase-consulting.com) + */ +public final class MiddleEndFactory { + /** + * This method creates a MiddleEnd instance based on an explicitly provided list of handlers. It works without + * OSGi. + */ + public static MiddleEnd create (BackendTypesystem ts, List<LanguageSpecificMiddleEnd> languageHandlers) { + return new MiddleEndImpl (ts, languageHandlers); + } + + /** + * This method creates a middle end based on the handlers registered with the extension point. It relies + * on OSGi and makes use of the Eclipse extension registry.<br> + * + * The map with "specific params" is used to initialize the contributed middle ends. + * The key must be the class implementing the LanguageSpecificMiddleEnd interface + * and contributed via the extension point. + */ + public static MiddleEnd createFromExtensions (BackendTypesystem ts, Map<Class<?>, Object> specificParams) { + return new MiddleEndImpl (ts, Activator.getInstance().getFreshMiddleEnds (specificParams)); + } +} |