зеркало из https://github.com/mozilla/smarthome.git
Refactored Guice injection
Signed-off-by: Oliver Libutzki <oliver@libutzki.de>
This commit is contained in:
Родитель
1233ce5038
Коммит
ca887d9c64
|
@ -25,4 +25,5 @@ Import-Package: com.google.common.base,
|
|||
org.slf4j;version="1.5.11"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Service-Component: OSGI-INF/folderobserver.xml, OSGI-INF/modelrepository.xml
|
||||
Export-Package: org.eclipse.smarthome.model.core
|
||||
Export-Package: org.eclipse.smarthome.model.core,
|
||||
org.eclipse.smarthome.model.core.guice
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package org.eclipse.smarthome.model.core;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public interface ModelInjectorProvider {
|
||||
|
||||
Injector getInjector();
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package org.eclipse.smarthome.model.core.guice;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExecutableExtension;
|
||||
import org.eclipse.core.runtime.IExecutableExtensionFactory;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
public abstract class AbstractGuiceAwareExecutableExtensionFactory implements IExecutableExtensionFactory, IExecutableExtension {
|
||||
public static final String GUICEKEY = "guicekey";
|
||||
protected Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected String clazzName;
|
||||
protected IConfigurationElement config;
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
|
||||
throws CoreException {
|
||||
if (data instanceof String) {
|
||||
clazzName = (String) data;
|
||||
} else if (data instanceof Map<?, ?>) {
|
||||
clazzName = ((Map<String, String>)data).get(GUICEKEY);
|
||||
}
|
||||
if (clazzName == null) {
|
||||
throw new IllegalArgumentException("couldn't handle passed data : "+data);
|
||||
}
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public Object create() throws CoreException {
|
||||
try {
|
||||
final Class<?> clazz = getBundle().loadClass(clazzName);
|
||||
final Injector injector = getInjector();
|
||||
final Object result = injector.getInstance(clazz);
|
||||
if (result instanceof IExecutableExtension)
|
||||
((IExecutableExtension) result).setInitializationData(config, null, null);
|
||||
return result;
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("An error occurred while creating the extension.", e);
|
||||
throw new CoreException(new Status(IStatus.ERROR, getBundle().getSymbolicName(), e.getMessage() + " ExtensionFactory: "+ getClass().getName(), e));
|
||||
}
|
||||
}
|
||||
|
||||
protected Bundle getBundle() {
|
||||
return FrameworkUtil.getBundle(getClass());
|
||||
}
|
||||
|
||||
protected abstract Injector getInjector();
|
||||
}
|
|
@ -3,13 +3,10 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: Eclipse SmartHome Item Model Runtime
|
||||
Bundle-SymbolicName: org.eclipse.smarthome.model.item.runtime;singleton:=true
|
||||
Bundle-Version: 0.7.0.qualifier
|
||||
Bundle-Activator: org.eclipse.smarthome.model.item.runtime.internal.ItemRuntimeActivator
|
||||
Require-Bundle: org.eclipse.smarthome.model.item,
|
||||
com.google.inject
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Import-Package: org.eclipse.smarthome.model.core,
|
||||
org.osgi.framework,
|
||||
org.slf4j
|
||||
Service-Component: OSGI-INF/iteminjectorprovider.xml
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Vendor: Eclipse.org/SmartHome
|
||||
Fragment-Host: org.eclipse.smarthome.model.item
|
||||
Import-Package: org.eclipse.core.runtime,
|
||||
org.eclipse.smarthome.model.core.guice
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
|
||||
-->
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.smarthome.model.item.runtime.internal.ItemRuntimeInjectorProvider">
|
||||
<implementation class="org.eclipse.smarthome.model.item.runtime.internal.ItemRuntimeInjectorProvider"/>
|
||||
<service>
|
||||
<provide interface="org.eclipse.smarthome.model.core.ModelInjectorProvider"/>
|
||||
</service>
|
||||
<property name="injectorprovider.type" type="String" value="item"/>
|
||||
</scr:component>
|
|
@ -2,4 +2,5 @@ source.. = src/
|
|||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
OSGI-INF/
|
||||
OSGI-INF/,\
|
||||
fragment.xml
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<fragment>
|
||||
<extension
|
||||
point="org.eclipse.emf.ecore.extension_parser">
|
||||
<parser
|
||||
class="org.eclipse.smarthome.model.item.runtime.internal.ItemRuntimeExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
|
||||
type="items">
|
||||
</parser>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.xtext.extension_resourceServiceProvider">
|
||||
<resourceServiceProvider
|
||||
class="org.eclipse.smarthome.model.item.runtime.internal.ItemRuntimeExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceServiceProvider"
|
||||
uriExtension="items">
|
||||
</resourceServiceProvider>
|
||||
</extension>
|
||||
|
||||
</fragment>
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
*/
|
||||
package org.eclipse.smarthome.model.item.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.ItemsStandaloneSetup;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
||||
public class ItemRuntimeActivator implements BundleActivator {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ItemRuntimeActivator.class);
|
||||
|
||||
private static ItemRuntimeActivator INSTANCE;
|
||||
|
||||
private Injector injector;
|
||||
|
||||
public void start(BundleContext context) throws Exception {
|
||||
INSTANCE = this;
|
||||
getInjector();
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
injector = null;
|
||||
INSTANCE = null;
|
||||
}
|
||||
|
||||
public static ItemRuntimeActivator getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public Injector getInjector() {
|
||||
synchronized (this) {
|
||||
if (injector == null) {
|
||||
injector = createInjector();
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
}
|
||||
|
||||
protected Injector createInjector() {
|
||||
Injector injector = new ItemsStandaloneSetup().createInjectorAndDoEMFRegistration();
|
||||
logger.debug("Registered 'item' configuration parser");
|
||||
return injector;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.eclipse.smarthome.model.item.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.guice.AbstractGuiceAwareExecutableExtensionFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class ItemRuntimeExecutableExtensionFactory extends
|
||||
AbstractGuiceAwareExecutableExtensionFactory {
|
||||
|
||||
|
||||
@Override
|
||||
protected Injector getInjector() {
|
||||
return ItemRuntimeInjectorProvider.getInjector();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +1,19 @@
|
|||
package org.eclipse.smarthome.model.item.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
|
||||
import org.eclipse.smarthome.model.ItemsRuntimeModule;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class ItemRuntimeInjectorProvider implements ModelInjectorProvider {
|
||||
|
||||
public Injector getInjector() {
|
||||
return ItemRuntimeActivator.getInstance().getInjector();
|
||||
public class ItemRuntimeInjectorProvider {
|
||||
private static Injector injector;
|
||||
|
||||
public static Injector getInjector() {
|
||||
|
||||
if (injector == null) {
|
||||
injector = Guice.createInjector(new ItemsRuntimeModule());
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
|
||||
-->
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.smarthome.model.ui.internal.ItemUiInjectorProvider">
|
||||
<implementation class="org.eclipse.smarthome.model.ui.internal.ItemUiInjectorProvider"/>
|
||||
<service>
|
||||
<provide interface="org.eclipse.smarthome.model.core.ModelInjectorProvider"/>
|
||||
</service>
|
||||
<property name="injectorprovider.type" type="String" value="item"/>
|
||||
</scr:component>
|
|
@ -1,14 +0,0 @@
|
|||
package org.eclipse.smarthome.model.ui.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class ItemUiInjectorProvider implements ModelInjectorProvider {
|
||||
|
||||
@Override
|
||||
public Injector getInjector() {
|
||||
return ItemsActivator.getInstance().getInjector(ItemsActivator.ORG_ECLIPSE_SMARTHOME_MODEL_ITEMS);
|
||||
}
|
||||
|
||||
}
|
|
@ -5,10 +5,7 @@ Bundle-Vendor: Eclipse.org/SmartHome
|
|||
Bundle-Version: 0.7.0.qualifier
|
||||
Bundle-SymbolicName: org.eclipse.smarthome.model.persistence.runtime;singleton:=true
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: org.eclipse.smarthome.model.persistence,
|
||||
com.google.inject
|
||||
Import-Package: org.eclipse.smarthome.model.core,
|
||||
org.osgi.framework,
|
||||
org.slf4j
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Activator: org.eclipse.smarthome.model.persistence.runtime.internal.PersistenceRuntimeActivator
|
||||
Fragment-Host: org.eclipse.smarthome.model.persistence
|
||||
Import-Package: org.eclipse.core.runtime,
|
||||
org.eclipse.smarthome.model.core.guice
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
.,\
|
||||
fragment.xml
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<fragment>
|
||||
<extension
|
||||
point="org.eclipse.emf.ecore.extension_parser">
|
||||
<parser
|
||||
class="org.eclipse.smarthome.model.persistence.runtime.internal.PersistenceRuntimeExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
|
||||
type="persistence">
|
||||
</parser>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.xtext.extension_resourceServiceProvider">
|
||||
<resourceServiceProvider
|
||||
class="org.eclipse.smarthome.model.persistence.runtime.internal.PersistenceRuntimeExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceServiceProvider"
|
||||
uriExtension="persistence">
|
||||
</resourceServiceProvider>
|
||||
</extension>
|
||||
|
||||
</fragment>
|
|
@ -1,55 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
*/
|
||||
package org.eclipse.smarthome.model.persistence.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.persistence.PersistenceStandaloneSetup;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
||||
public class PersistenceRuntimeActivator implements BundleActivator {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(PersistenceRuntimeActivator.class);
|
||||
|
||||
private static PersistenceRuntimeActivator INSTANCE;
|
||||
|
||||
private Injector injector;
|
||||
|
||||
public void start(BundleContext context) throws Exception {
|
||||
INSTANCE = this;
|
||||
getInjector();
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
injector = null;
|
||||
INSTANCE = null;
|
||||
}
|
||||
|
||||
public static PersistenceRuntimeActivator getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public Injector getInjector() {
|
||||
synchronized (this) {
|
||||
if (injector == null) {
|
||||
injector = createInjector();
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
}
|
||||
|
||||
protected Injector createInjector() {
|
||||
Injector injector = new PersistenceStandaloneSetup().createInjectorAndDoEMFRegistration();
|
||||
logger.debug("Registered 'persistence' configuration parser");
|
||||
return injector;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.eclipse.smarthome.model.persistence.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.guice.AbstractGuiceAwareExecutableExtensionFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class PersistenceRuntimeExecutableExtensionFactory extends
|
||||
AbstractGuiceAwareExecutableExtensionFactory {
|
||||
|
||||
|
||||
@Override
|
||||
protected Injector getInjector() {
|
||||
return PersistenceRuntimeInjectorProvider.getInjector();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +1,19 @@
|
|||
package org.eclipse.smarthome.model.persistence.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
|
||||
import org.eclipse.smarthome.model.persistence.PersistenceRuntimeModule;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class PersistenceRuntimeInjectorProvider implements ModelInjectorProvider {
|
||||
|
||||
public Injector getInjector() {
|
||||
return PersistenceRuntimeActivator.getInstance().getInjector();
|
||||
public class PersistenceRuntimeInjectorProvider {
|
||||
private static Injector injector;
|
||||
|
||||
public static Injector getInjector() {
|
||||
|
||||
if (injector == null) {
|
||||
injector = Guice.createInjector(new PersistenceRuntimeModule());
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,11 +5,8 @@ Bundle-Vendor: Eclipse.org/SmartHome
|
|||
Bundle-Version: 0.7.0.qualifier
|
||||
Bundle-SymbolicName: org.eclipse.smarthome.model.rule.runtime;singleton:=true
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: org.eclipse.smarthome.model.rule,
|
||||
com.google.inject
|
||||
Import-Package: org.eclipse.smarthome.model.core,
|
||||
org.osgi.framework,
|
||||
org.slf4j
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Service-Component: OSGI-INF/rulesinjectorprovider.xml
|
||||
Bundle-Activator: org.eclipse.smarthome.model.rule.runtime.internal.RulesRuntimeActivator
|
||||
Fragment-Host: org.eclipse.smarthome.model.rule
|
||||
Import-Package: org.eclipse.core.runtime,
|
||||
org.eclipse.smarthome.model.core.guice
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
-->
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" immediate="true" name="org.eclipse.smarthome.model.ruleengine">
|
||||
<implementation class="org.eclipse.smarthome.model.rule.internal.engine.RuleEngine"/>
|
||||
<implementation class="org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngine"/>
|
||||
<service>
|
||||
<provide interface="org.osgi.service.event.EventHandler"/>
|
||||
</service>
|
||||
|
@ -17,5 +17,4 @@
|
|||
<property name="event.topics" type="String" value="smarthome/command/*"/>
|
||||
<reference bind="setModelRepository" cardinality="1..1" interface="org.eclipse.smarthome.model.core.ModelRepository" name="ModelRepository" policy="dynamic" unbind="unsetModelRepository"/>
|
||||
<reference bind="setScriptEngine" cardinality="1..1" interface="org.eclipse.smarthome.core.scriptengine.ScriptEngine" name="ScriptEngine" policy="dynamic" unbind="unsetScriptEngine"/>
|
||||
<reference bind="setInjectorProvider" cardinality="1..1" interface="org.eclipse.smarthome.model.core.ModelInjectorProvider" name="InjectorProvider" policy="dynamic" target="(injectorprovider.type=rules)" unbind="unsetInjectorProvider"/>
|
||||
</scr:component>
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
|
||||
-->
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.smarthome.model.rule.runtime.internal.RulesRuntimeInjectorProvider">
|
||||
<implementation class="org.eclipse.smarthome.model.rule.runtime.internal.RulesRuntimeInjectorProvider"/>
|
||||
<service>
|
||||
<provide interface="org.eclipse.smarthome.model.core.ModelInjectorProvider"/>
|
||||
</service>
|
||||
<property name="injectorprovider.type" type="String" value="rules"/>
|
||||
</scr:component>
|
|
@ -2,4 +2,5 @@ source.. = src/
|
|||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
OSGI-INF/
|
||||
OSGI-INF/,\
|
||||
fragment.xml
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<fragment>
|
||||
<extension
|
||||
point="org.eclipse.emf.ecore.extension_parser">
|
||||
<parser
|
||||
class="org.eclipse.smarthome.model.rule.runtime.internal.RuleRuntimeExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
|
||||
type="rules">
|
||||
</parser>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.xtext.extension_resourceServiceProvider">
|
||||
<resourceServiceProvider
|
||||
class="org.eclipse.smarthome.model.rule.runtime.internal.RuleRuntimeExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceServiceProvider"
|
||||
uriExtension="rules">
|
||||
</resourceServiceProvider>
|
||||
</extension>
|
||||
|
||||
</fragment>
|
|
@ -0,0 +1,16 @@
|
|||
package org.eclipse.smarthome.model.rule.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.guice.AbstractGuiceAwareExecutableExtensionFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class RuleRuntimeExecutableExtensionFactory extends
|
||||
AbstractGuiceAwareExecutableExtensionFactory {
|
||||
|
||||
|
||||
@Override
|
||||
protected Injector getInjector() {
|
||||
return RuleRuntimeInjectorProvider.getInjector();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.eclipse.smarthome.model.rule.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.rule.RulesRuntimeModule;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class RuleRuntimeInjectorProvider {
|
||||
private static Injector injector;
|
||||
|
||||
public static Injector getInjector() {
|
||||
|
||||
if (injector == null) {
|
||||
injector = Guice.createInjector(new RulesRuntimeModule());
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
*/
|
||||
package org.eclipse.smarthome.model.rule.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.rule.RulesStandaloneSetup;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
||||
public class RulesRuntimeActivator implements BundleActivator {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(RulesRuntimeActivator.class);
|
||||
|
||||
private static RulesRuntimeActivator INSTANCE;
|
||||
|
||||
private Injector injector;
|
||||
|
||||
public void start(BundleContext context) throws Exception {
|
||||
INSTANCE = this;
|
||||
getInjector();
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
injector = null;
|
||||
INSTANCE = null;
|
||||
}
|
||||
|
||||
public static RulesRuntimeActivator getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public Injector getInjector() {
|
||||
synchronized (this) {
|
||||
if (injector == null) {
|
||||
injector = createInjector();
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
}
|
||||
|
||||
protected Injector createInjector() {
|
||||
Injector injector = new RulesStandaloneSetup().createInjectorAndDoEMFRegistration();
|
||||
logger.debug("Registered 'rules' configuration parser");
|
||||
return injector;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package org.eclipse.smarthome.model.rule.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class RulesRuntimeInjectorProvider implements ModelInjectorProvider {
|
||||
|
||||
public Injector getInjector() {
|
||||
return RulesRuntimeActivator.getInstance().getInjector();
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.smarthome.model.rule.internal.engine;
|
||||
package org.eclipse.smarthome.model.rule.runtime.internal.engine;
|
||||
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.smarthome.core.scriptengine.Script;
|
|
@ -1,4 +1,4 @@
|
|||
package org.eclipse.smarthome.model.rule.internal.engine;
|
||||
package org.eclipse.smarthome.model.rule.runtime.internal.engine;
|
||||
|
||||
import org.quartz.Job;
|
||||
import org.quartz.Scheduler;
|
|
@ -5,13 +5,12 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.smarthome.model.rule.internal.engine;
|
||||
package org.eclipse.smarthome.model.rule.runtime.internal.engine;
|
||||
|
||||
import org.eclipse.emf.common.notify.Adapter;
|
||||
import org.eclipse.emf.ecore.util.EContentAdapter;
|
||||
import org.eclipse.smarthome.core.scriptengine.ScriptEngine;
|
||||
import org.eclipse.smarthome.core.scriptengine.ScriptExecutionException;
|
||||
import org.eclipse.smarthome.model.rule.RulesStandaloneSetup;
|
||||
import org.eclipse.smarthome.model.rule.internal.RuleModelActivator;
|
||||
import org.eclipse.smarthome.model.rule.rules.Rule;
|
||||
import org.eclipse.smarthome.model.rule.rules.RuleModel;
|
||||
|
@ -34,12 +33,6 @@ import com.google.inject.Provider;
|
|||
public class RuleContextHelper {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RuleContextHelper.class);
|
||||
|
||||
/** Variable name for the previous state of an item in a "changed state triggered" rule */
|
||||
public static final String VAR_PREVIOUS_STATE = "previousState";
|
||||
|
||||
/** Variable name for the received command in a "command triggered" rule */
|
||||
public static final String VAR_RECEIVED_COMMAND = "receivedCommand";
|
||||
|
||||
private static ScriptEngine scriptEngine = RuleModelActivator.scriptEngineTracker.getService();
|
||||
|
|
@ -5,15 +5,15 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.smarthome.model.rule.internal.engine;
|
||||
package org.eclipse.smarthome.model.rule.runtime.internal.engine;
|
||||
|
||||
import static org.eclipse.smarthome.core.events.EventConstants.TOPIC_PREFIX;
|
||||
import static org.eclipse.smarthome.core.events.EventConstants.TOPIC_SEPERATOR;
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.CHANGE;
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.COMMAND;
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.SHUTDOWN;
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.STARTUP;
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.UPDATE;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.CHANGE;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.COMMAND;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.SHUTDOWN;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.STARTUP;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.UPDATE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -33,11 +33,12 @@ import org.eclipse.smarthome.core.scriptengine.ScriptExecutionThread;
|
|||
import org.eclipse.smarthome.core.types.Command;
|
||||
import org.eclipse.smarthome.core.types.EventType;
|
||||
import org.eclipse.smarthome.core.types.State;
|
||||
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
|
||||
import org.eclipse.smarthome.model.core.ModelRepository;
|
||||
import org.eclipse.smarthome.model.core.ModelRepositoryChangeListener;
|
||||
import org.eclipse.smarthome.model.rule.jvmmodel.RulesJvmModelInferrer;
|
||||
import org.eclipse.smarthome.model.rule.rules.Rule;
|
||||
import org.eclipse.smarthome.model.rule.rules.RuleModel;
|
||||
import org.eclipse.smarthome.model.rule.runtime.internal.RuleRuntimeInjectorProvider;
|
||||
import org.eclipse.xtext.naming.QualifiedName;
|
||||
import org.osgi.service.event.Event;
|
||||
import org.osgi.service.event.EventHandler;
|
||||
|
@ -68,7 +69,7 @@ public class RuleEngine implements EventHandler, ItemRegistryChangeListener, Sta
|
|||
|
||||
private RuleTriggerManager triggerManager;
|
||||
|
||||
private Injector injector;
|
||||
private Injector injector = RuleRuntimeInjectorProvider.getInjector();
|
||||
|
||||
public void activate() {
|
||||
triggerManager = injector.getInstance(RuleTriggerManager.class);
|
||||
|
@ -302,7 +303,7 @@ public class RuleEngine implements EventHandler, ItemRegistryChangeListener, Sta
|
|||
protected synchronized void executeRules(Iterable<Rule> rules, Command command) {
|
||||
for(Rule rule : rules) {
|
||||
RuleEvaluationContext context = new RuleEvaluationContext();
|
||||
context.newValue(QualifiedName.create(RuleContextHelper.VAR_RECEIVED_COMMAND), command);
|
||||
context.newValue(QualifiedName.create(RulesJvmModelInferrer.VAR_RECEIVED_COMMAND), command);
|
||||
executeRule(rule, context);
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +311,7 @@ public class RuleEngine implements EventHandler, ItemRegistryChangeListener, Sta
|
|||
protected synchronized void executeRules(Iterable<Rule> rules, State oldState) {
|
||||
for(Rule rule : rules) {
|
||||
RuleEvaluationContext context = new RuleEvaluationContext();
|
||||
context.newValue(QualifiedName.create(RuleContextHelper.VAR_PREVIOUS_STATE), oldState);
|
||||
context.newValue(QualifiedName.create(RulesJvmModelInferrer.VAR_PREVIOUS_STATE), oldState);
|
||||
executeRule(rule, context);
|
||||
}
|
||||
}
|
||||
|
@ -324,13 +325,4 @@ public class RuleEngine implements EventHandler, ItemRegistryChangeListener, Sta
|
|||
private boolean isEnabled() {
|
||||
return !"true".equalsIgnoreCase(System.getProperty("noRules"));
|
||||
}
|
||||
|
||||
public void setInjectorProvider(ModelInjectorProvider injectorProvider) {
|
||||
this.injector = injectorProvider.getInjector();
|
||||
}
|
||||
|
||||
public void unsetInjectorProvider(ModelInjectorProvider injectorProvider) {
|
||||
this.injector = null;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.smarthome.model.rule.internal.engine;
|
||||
package org.eclipse.smarthome.model.rule.runtime.internal.engine;
|
||||
|
||||
import org.eclipse.xtext.naming.QualifiedName;
|
||||
import org.eclipse.xtext.xbase.interpreter.IEvaluationContext;
|
|
@ -5,14 +5,14 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.smarthome.model.rule.internal.engine;
|
||||
package org.eclipse.smarthome.model.rule.runtime.internal.engine;
|
||||
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.CHANGE;
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.COMMAND;
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.SHUTDOWN;
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.STARTUP;
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.TIMER;
|
||||
import static org.eclipse.smarthome.model.rule.internal.engine.RuleTriggerManager.TriggerTypes.UPDATE;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.CHANGE;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.COMMAND;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.SHUTDOWN;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.STARTUP;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.TIMER;
|
||||
import static org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleTriggerManager.TriggerTypes.UPDATE;
|
||||
import static org.quartz.JobBuilder.newJob;
|
||||
import static org.quartz.TriggerBuilder.newTrigger;
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
|
||||
-->
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.smarthome.model.rule.ui.internal.RuleUiInjectorProvider">
|
||||
<implementation class="org.eclipse.smarthome.model.rule.ui.internal.RuleUiInjectorProvider"/>
|
||||
<service>
|
||||
<provide interface="org.eclipse.smarthome.model.core.ModelInjectorProvider"/>
|
||||
</service>
|
||||
<property name="injectorprovider.type" type="String" value="rules"/>
|
||||
</scr:component>
|
|
@ -10,8 +10,6 @@
|
|||
*/
|
||||
package org.eclipse.smarthome.model.rule.ui;
|
||||
|
||||
import org.eclipse.smarthome.model.script.scoping.ActionClasspathBasedTypeScopeProvider;
|
||||
import org.eclipse.smarthome.model.script.scoping.ActionClasspathTypeProviderFactory;
|
||||
import org.eclipse.smarthome.model.script.ui.contentassist.ActionEObjectHoverProvider;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider;
|
||||
|
@ -25,14 +23,6 @@ public class RulesUiModule extends org.eclipse.smarthome.model.rule.ui.AbstractR
|
|||
super(plugin);
|
||||
}
|
||||
|
||||
// public Class<? extends org.eclipse.xtext.common.types.access.IJvmTypeProvider.Factory> bindIJvmTypeProvider$Factory() {
|
||||
// return ActionClasspathTypeProviderFactory.class;
|
||||
// }
|
||||
//
|
||||
// public Class<? extends org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider> bindAbstractTypeScopeProvider() {
|
||||
// return ActionClasspathBasedTypeScopeProvider.class;
|
||||
// }
|
||||
|
||||
public Class<? extends IEObjectHoverProvider> bindIEObjectHoverProvider() {
|
||||
return ActionEObjectHoverProvider.class;
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package org.eclipse.smarthome.model.rule.ui.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class RuleUiInjectorProvider implements ModelInjectorProvider {
|
||||
|
||||
@Override
|
||||
public Injector getInjector() {
|
||||
return RuleModelUIActivator.getInstance().getInjector(RuleModelUIActivator.ORG_ECLIPSE_SMARTHOME_MODEL_RULE_RULES);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,5 +4,4 @@ source.. = src/,\
|
|||
bin.includes = model/,\
|
||||
META-INF/,\
|
||||
.,\
|
||||
plugin.xml,\
|
||||
OSGI-INF/
|
||||
plugin.xml
|
||||
|
|
|
@ -12,9 +12,6 @@ package org.eclipse.smarthome.model.rule;
|
|||
|
||||
import org.eclipse.smarthome.model.rule.scoping.RulesImplicitlyImportedTypes;
|
||||
import org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter;
|
||||
import org.eclipse.smarthome.model.script.scoping.ActionClassLoader;
|
||||
import org.eclipse.smarthome.model.script.scoping.ActionClasspathBasedTypeScopeProvider;
|
||||
import org.eclipse.smarthome.model.script.scoping.ActionClasspathTypeProviderFactory;
|
||||
import org.eclipse.smarthome.model.script.scoping.ScriptImportSectionNamespaceScopeProvider;
|
||||
import org.eclipse.smarthome.model.script.scoping.StateAndCommandProvider;
|
||||
import org.eclipse.xtext.generator.IGenerator;
|
||||
|
@ -22,7 +19,6 @@ import org.eclipse.xtext.generator.IGenerator.NullGenerator;
|
|||
import org.eclipse.xtext.scoping.IScopeProvider;
|
||||
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
|
||||
import org.eclipse.xtext.xbase.interpreter.IExpressionInterpreter;
|
||||
import org.eclipse.xtext.xbase.scoping.XImportSectionNamespaceScopeProvider;
|
||||
import org.eclipse.xtext.xbase.scoping.batch.ImplicitlyImportedTypes;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
|
@ -42,25 +38,7 @@ public class RulesRuntimeModule extends org.eclipse.smarthome.model.rule.Abstrac
|
|||
public Class<StateAndCommandProvider> bindStateAndCommandProvider() {
|
||||
return StateAndCommandProvider.class;
|
||||
}
|
||||
//
|
||||
// /* we need this so that our pluggable actions can be resolved at design time */
|
||||
// @Override
|
||||
// public Class<? extends org.eclipse.xtext.common.types.access.IJvmTypeProvider.Factory> bindIJvmTypeProvider$Factory() {
|
||||
// return ActionClasspathTypeProviderFactory.class;
|
||||
// }
|
||||
//
|
||||
// /* we need this so that our pluggable actions can be resolved when being parsed at runtime */
|
||||
// @Override
|
||||
// public Class<? extends org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider> bindAbstractTypeScopeProvider() {
|
||||
// return ActionClasspathBasedTypeScopeProvider.class;
|
||||
// }
|
||||
//
|
||||
// /* we need this so that our pluggable actions can be resolved when being executed at runtime */
|
||||
// @Override
|
||||
// public ClassLoader bindClassLoaderToInstance() {
|
||||
// return new ActionClassLoader(getClass().getClassLoader());
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public Class<? extends IGenerator> bindIGenerator() {
|
||||
return NullGenerator.class;
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.google.inject.Inject
|
|||
import java.util.Set
|
||||
import org.eclipse.smarthome.core.types.Command
|
||||
import org.eclipse.smarthome.core.types.State
|
||||
import org.eclipse.smarthome.model.rule.internal.engine.RuleContextHelper
|
||||
import org.eclipse.smarthome.model.rule.rules.ChangedEventTrigger
|
||||
import org.eclipse.smarthome.model.rule.rules.CommandEventTrigger
|
||||
import org.eclipse.smarthome.model.rule.rules.EventTrigger
|
||||
|
@ -33,6 +32,13 @@ class RulesJvmModelInferrer extends ScriptJvmModelInferrer {
|
|||
|
||||
|
||||
static private final Logger logger = LoggerFactory.getLogger(RulesJvmModelInferrer)
|
||||
|
||||
/** Variable name for the previous state of an item in a "changed state triggered" rule */
|
||||
public static final String VAR_PREVIOUS_STATE = "previousState";
|
||||
|
||||
/** Variable name for the received command in a "command triggered" rule */
|
||||
public static final String VAR_RECEIVED_COMMAND = "receivedCommand";
|
||||
|
||||
/**
|
||||
* conveninence API to build and initialize JvmTypes and their members.
|
||||
*/
|
||||
|
@ -98,11 +104,11 @@ class RulesJvmModelInferrer extends ScriptJvmModelInferrer {
|
|||
static = true
|
||||
if(containsCommandTrigger(rule)) {
|
||||
val commandTypeRef = ruleModel.newTypeRef(Command)
|
||||
parameters += rule.toParameter(RuleContextHelper.VAR_RECEIVED_COMMAND, commandTypeRef)
|
||||
parameters += rule.toParameter(VAR_RECEIVED_COMMAND, commandTypeRef)
|
||||
}
|
||||
if(containsStateChangeTrigger(rule)) {
|
||||
val stateTypeRef = ruleModel.newTypeRef(State)
|
||||
parameters += rule.toParameter(RuleContextHelper.VAR_PREVIOUS_STATE, stateTypeRef)
|
||||
parameters += rule.toParameter(VAR_PREVIOUS_STATE, stateTypeRef)
|
||||
}
|
||||
|
||||
body = rule.script
|
||||
|
|
|
@ -5,11 +5,7 @@ Bundle-Vendor: Eclipse.org/SmartHome
|
|||
Bundle-Version: 0.7.0.qualifier
|
||||
Bundle-SymbolicName: org.eclipse.smarthome.model.script.runtime;singleton:=true
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: org.eclipse.smarthome.model.script,
|
||||
com.google.inject
|
||||
Import-Package: org.eclipse.smarthome.model.core,
|
||||
org.osgi.framework,
|
||||
org.slf4j
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Service-Component: OSGI-INF/scriptinjectorprovider.xml
|
||||
Bundle-Activator: org.eclipse.smarthome.model.script.runtime.internal.ScriptRuntimeActivator
|
||||
Fragment-Host: org.eclipse.smarthome.model.script
|
||||
Import-Package: org.eclipse.core.runtime,
|
||||
org.eclipse.smarthome.model.core.guice
|
||||
|
|
|
@ -9,9 +9,8 @@
|
|||
|
||||
-->
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="org.eclipse.smarthome.model.script">
|
||||
<implementation class="org.eclipse.smarthome.model.script.internal.engine.ScriptEngineImpl"/>
|
||||
<implementation class="org.eclipse.smarthome.model.script.runtime.internal.engine.ScriptEngineImpl"/>
|
||||
<service>
|
||||
<provide interface="org.eclipse.smarthome.core.scriptengine.ScriptEngine"/>
|
||||
</service>
|
||||
<reference bind="setInjectorProvider" cardinality="1..1" interface="org.eclipse.smarthome.model.core.ModelInjectorProvider" name="InjectorProvider" policy="dynamic" target="(injectorprovider.type=script)" unbind="unsetInjectorProvider"/>
|
||||
</scr:component>
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
|
||||
-->
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.smarthome.model.script.runtime.internal.ScriptRuntimeInjectorProvider">
|
||||
<implementation class="org.eclipse.smarthome.model.script.runtime.internal.ScriptRuntimeInjectorProvider"/>
|
||||
<service>
|
||||
<provide interface="org.eclipse.smarthome.model.core.ModelInjectorProvider"/>
|
||||
</service>
|
||||
<property name="injectorprovider.type" type="String" value="script"/>
|
||||
</scr:component>
|
|
@ -2,4 +2,5 @@ source.. = src/
|
|||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
OSGI-INF/
|
||||
OSGI-INF/,\
|
||||
fragment.xml
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<fragment>
|
||||
<extension
|
||||
point="org.eclipse.emf.ecore.extension_parser">
|
||||
<parser
|
||||
class="org.eclipse.smarthome.model.script.runtime.internal.ScriptRuntimeExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
|
||||
type="script">
|
||||
</parser>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.xtext.extension_resourceServiceProvider">
|
||||
<resourceServiceProvider
|
||||
class="org.eclipse.smarthome.model.script.runtime.internal.ScriptRuntimeExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceServiceProvider"
|
||||
uriExtension="script">
|
||||
</resourceServiceProvider>
|
||||
</extension>
|
||||
</fragment>
|
|
@ -1,55 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
*/
|
||||
package org.eclipse.smarthome.model.script.runtime.internal;
|
||||
import org.eclipse.smarthome.model.script.ScriptStandaloneSetup;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
||||
public class ScriptRuntimeActivator implements BundleActivator {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ScriptRuntimeActivator.class);
|
||||
|
||||
private static ScriptRuntimeActivator INSTANCE;
|
||||
|
||||
private Injector injector;
|
||||
|
||||
public void start(BundleContext context) throws Exception {
|
||||
INSTANCE = this;
|
||||
getInjector();
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
injector = null;
|
||||
INSTANCE = null;
|
||||
}
|
||||
|
||||
public static ScriptRuntimeActivator getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public Injector getInjector() {
|
||||
synchronized (this) {
|
||||
if (injector == null) {
|
||||
injector = createInjector();
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
}
|
||||
|
||||
protected Injector createInjector() {
|
||||
Injector injector = new ScriptStandaloneSetup().createInjectorAndDoEMFRegistration();
|
||||
logger.debug("Registered 'script' configuration parser");
|
||||
return injector;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.eclipse.smarthome.model.script.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.guice.AbstractGuiceAwareExecutableExtensionFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class ScriptRuntimeExecutableExtensionFactory extends
|
||||
AbstractGuiceAwareExecutableExtensionFactory {
|
||||
|
||||
|
||||
@Override
|
||||
protected Injector getInjector() {
|
||||
return ScriptRuntimeInjectorProvider.getInjector();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +1,17 @@
|
|||
package org.eclipse.smarthome.model.script.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class ScriptRuntimeInjectorProvider implements ModelInjectorProvider {
|
||||
|
||||
public Injector getInjector() {
|
||||
return ScriptRuntimeActivator.getInstance().getInjector();
|
||||
public class ScriptRuntimeInjectorProvider {
|
||||
private static Injector injector;
|
||||
|
||||
public static Injector getInjector() {
|
||||
|
||||
if (injector == null) {
|
||||
injector = Guice.createInjector(new org.eclipse.smarthome.model.script.ScriptRuntimeModule(), new ScriptRuntimeModule());
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package org.eclipse.smarthome.model.script.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.core.scriptengine.Script;
|
||||
import org.eclipse.smarthome.core.scriptengine.ScriptEngine;
|
||||
import org.eclipse.smarthome.model.script.runtime.internal.engine.ScriptEngineImpl;
|
||||
import org.eclipse.smarthome.model.script.runtime.internal.engine.ScriptImpl;
|
||||
import org.eclipse.xtext.service.AbstractGenericModule;
|
||||
|
||||
public class ScriptRuntimeModule extends AbstractGenericModule {
|
||||
|
||||
public Class<? extends ScriptEngine> bindScriptEngine() {
|
||||
return ScriptEngineImpl.class;
|
||||
}
|
||||
|
||||
public Class<? extends Script> bindScript() {
|
||||
return ScriptImpl.class;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.smarthome.model.script.internal.engine;
|
||||
package org.eclipse.smarthome.model.script.runtime.internal.engine;
|
||||
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
|
||||
|
@ -22,7 +22,7 @@ import org.eclipse.smarthome.core.scriptengine.Script;
|
|||
import org.eclipse.smarthome.core.scriptengine.ScriptEngine;
|
||||
import org.eclipse.smarthome.core.scriptengine.ScriptExecutionException;
|
||||
import org.eclipse.smarthome.core.scriptengine.ScriptParsingException;
|
||||
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
|
||||
import org.eclipse.smarthome.model.script.runtime.internal.ScriptRuntimeInjectorProvider;
|
||||
import org.eclipse.xtext.diagnostics.Severity;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.resource.XtextResourceSet;
|
||||
|
@ -47,9 +47,8 @@ public class ScriptEngineImpl implements ScriptEngine {
|
|||
|
||||
|
||||
protected XtextResourceSet resourceSet;
|
||||
|
||||
|
||||
private Injector injector;
|
||||
private Injector injector = ScriptRuntimeInjectorProvider.getInjector();
|
||||
|
||||
|
||||
public ScriptEngineImpl() {}
|
||||
|
||||
|
@ -66,7 +65,6 @@ public class ScriptEngineImpl implements ScriptEngine {
|
|||
}
|
||||
|
||||
public void deactivate() {
|
||||
this.injector = null;
|
||||
this.resourceSet = null;
|
||||
}
|
||||
|
||||
|
@ -149,13 +147,5 @@ public class ScriptEngineImpl implements ScriptEngine {
|
|||
});
|
||||
return issues;
|
||||
}
|
||||
|
||||
public void setInjectorProvider(ModelInjectorProvider injectorProvider) {
|
||||
this.injector = injectorProvider.getInjector();
|
||||
}
|
||||
|
||||
public void unsetInjectorProvider(ModelInjectorProvider injectorProvider) {
|
||||
this.injector = null;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.smarthome.model.script.internal.engine;
|
||||
package org.eclipse.smarthome.model.script.runtime.internal.engine;
|
||||
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.smarthome.core.scriptengine.Script;
|
|
@ -11,8 +11,7 @@ Require-Bundle: org.eclipse.xtend.lib,
|
|||
org.eclipse.xtext.xbase.lib,
|
||||
org.eclipse.smarthome.model.script,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.xtext.junit4,
|
||||
org.eclipse.smarthome.model.script.runtime
|
||||
org.eclipse.xtext.junit4
|
||||
Import-Package: org.eclipse.smarthome.core.items,
|
||||
org.eclipse.smarthome.core.library.items,
|
||||
org.eclipse.smarthome.model.script.engine,
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
|
||||
-->
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.smarthome.model.script.ui.internal.ScriptUiInjectorProvider">
|
||||
<implementation class="org.eclipse.smarthome.model.script.ui.internal.ScriptUiInjectorProvider"/>
|
||||
<service>
|
||||
<provide interface="org.eclipse.smarthome.model.core.ModelInjectorProvider"/>
|
||||
</service>
|
||||
<property name="injectorprovider.type" type="String" value="script"/>
|
||||
</scr:component>
|
|
@ -4,5 +4,4 @@ source.. = src/,\
|
|||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml,\
|
||||
icons/,\
|
||||
OSGI-INF/
|
||||
icons/
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*/
|
||||
package org.eclipse.smarthome.model.script.ui;
|
||||
|
||||
import org.eclipse.smarthome.model.script.scoping.ActionClasspathBasedTypeScopeProvider;
|
||||
import org.eclipse.smarthome.model.script.scoping.ActionClasspathTypeProviderFactory;
|
||||
import org.eclipse.smarthome.model.script.ui.contentassist.ActionEObjectHoverProvider;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider;
|
||||
|
@ -24,14 +22,6 @@ public class ScriptUiModule extends org.eclipse.smarthome.model.script.ui.Abstra
|
|||
public ScriptUiModule(AbstractUIPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
// public Class<? extends org.eclipse.xtext.common.types.access.IJvmTypeProvider.Factory> bindIJvmTypeProvider$Factory() {
|
||||
// return ActionClasspathTypeProviderFactory.class;
|
||||
// }
|
||||
//
|
||||
// public Class<? extends org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider> bindAbstractTypeScopeProvider() {
|
||||
// return ActionClasspathBasedTypeScopeProvider.class;
|
||||
// }
|
||||
|
||||
public Class<? extends IEObjectHoverProvider> bindIEObjectHoverProvider() {
|
||||
return ActionEObjectHoverProvider.class;
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package org.eclipse.smarthome.model.script.ui.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class ScriptUiInjectorProvider implements ModelInjectorProvider {
|
||||
|
||||
@Override
|
||||
public Injector getInjector() {
|
||||
return ScriptUIActivator.getInstance().getInjector(ScriptUIActivator.ORG_ECLIPSE_SMARTHOME_MODEL_SCRIPT_SCRIPT);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
bin.includes = model/,\
|
||||
META-INF/,\
|
||||
.,\
|
||||
plugin.xml,\
|
||||
OSGI-INF/
|
||||
META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
source.. = src/,\
|
||||
src-gen/,\
|
||||
xtend-gen/
|
||||
|
|
|
@ -10,14 +10,7 @@
|
|||
*/
|
||||
package org.eclipse.smarthome.model.script;
|
||||
|
||||
import org.eclipse.smarthome.core.scriptengine.Script;
|
||||
import org.eclipse.smarthome.core.scriptengine.ScriptEngine;
|
||||
import org.eclipse.smarthome.model.script.internal.engine.ScriptEngineImpl;
|
||||
import org.eclipse.smarthome.model.script.internal.engine.ScriptImpl;
|
||||
import org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter;
|
||||
import org.eclipse.smarthome.model.script.scoping.ActionClassLoader;
|
||||
import org.eclipse.smarthome.model.script.scoping.ActionClasspathBasedTypeScopeProvider;
|
||||
import org.eclipse.smarthome.model.script.scoping.ActionClasspathTypeProviderFactory;
|
||||
import org.eclipse.smarthome.model.script.scoping.ScriptImplicitlyImportedTypes;
|
||||
import org.eclipse.smarthome.model.script.scoping.ScriptImportSectionNamespaceScopeProvider;
|
||||
import org.eclipse.xtext.generator.IGenerator;
|
||||
|
@ -41,40 +34,17 @@ public class ScriptRuntimeModule extends org.eclipse.smarthome.model.script.Abst
|
|||
return ScriptImplicitlyImportedTypes.class;
|
||||
}
|
||||
|
||||
public Class<? extends Script> bindScript() {
|
||||
return ScriptImpl.class;
|
||||
}
|
||||
|
||||
|
||||
public Class<? extends IExpressionInterpreter> bindIExpressionInterpreter() {
|
||||
return ScriptInterpreter.class;
|
||||
}
|
||||
//
|
||||
// /* we need this so that our pluggable actions can be resolved at design time */
|
||||
// @Override
|
||||
// public Class<? extends org.eclipse.xtext.common.types.access.IJvmTypeProvider.Factory> bindIJvmTypeProvider$Factory() {
|
||||
// return ActionClasspathTypeProviderFactory.class;
|
||||
// }
|
||||
//
|
||||
// /* we need this so that our pluggable actions can be resolved when being parsed at runtime */
|
||||
// @Override
|
||||
// public Class<? extends org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider> bindAbstractTypeScopeProvider() {
|
||||
// return ActionClasspathBasedTypeScopeProvider.class;
|
||||
// }
|
||||
//
|
||||
// /* we need this so that our pluggable actions can be resolved when being executed at runtime */
|
||||
// @Override
|
||||
// public ClassLoader bindClassLoaderToInstance() {
|
||||
// return new ActionClassLoader(getClass().getClassLoader());
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Class<? extends IGenerator> bindIGenerator() {
|
||||
return NullGenerator.class;
|
||||
}
|
||||
|
||||
public Class<? extends ScriptEngine> bindScriptEngine() {
|
||||
return ScriptEngineImpl.class;
|
||||
}
|
||||
|
||||
public void configureIScopeProviderDelegate(Binder binder) {
|
||||
binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(ScriptImportSectionNamespaceScopeProvider.class);
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2014 openHAB UG (haftungsbeschraenkt) 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
|
||||
*/
|
||||
package org.eclipse.smarthome.model.script.scoping;
|
||||
|
||||
import org.eclipse.xtext.common.types.access.ClasspathTypeProviderFactory;
|
||||
import org.eclipse.xtext.common.types.access.IJvmTypeProvider;
|
||||
import org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider;
|
||||
import org.eclipse.xtext.common.types.xtext.AbstractConstructorScope;
|
||||
import org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider;
|
||||
import org.eclipse.xtext.common.types.xtext.ClasspathBasedConstructorScope;
|
||||
import org.eclipse.xtext.common.types.xtext.ClasspathBasedTypeScope;
|
||||
import org.eclipse.xtext.naming.IQualifiedNameConverter;
|
||||
import org.eclipse.xtext.resource.IEObjectDescription;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* Same implementation as {@link ClasspathBasedTypeScopeProvider}, just that it needs a
|
||||
* {@link ActionClasspathTypeProviderFactory} injected instead of a {@link ClasspathTypeProviderFactory}
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class ActionClasspathBasedTypeScopeProvider extends AbstractTypeScopeProvider {
|
||||
|
||||
@Inject
|
||||
private ActionClasspathTypeProviderFactory typeProviderFactory;
|
||||
|
||||
@Inject
|
||||
private IQualifiedNameConverter qualifiedNameConverter;
|
||||
|
||||
@Override
|
||||
public ClasspathBasedTypeScope createTypeScope(IJvmTypeProvider typeProvider, Predicate<IEObjectDescription> filter) {
|
||||
return new ClasspathBasedTypeScope((ClasspathTypeProvider) typeProvider, qualifiedNameConverter, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractConstructorScope createConstructorScope(IJvmTypeProvider typeProvider, Predicate<IEObjectDescription> filter) {
|
||||
ClasspathBasedTypeScope typeScope = createTypeScope(typeProvider, filter);
|
||||
return new ClasspathBasedConstructorScope(typeScope);
|
||||
}
|
||||
|
||||
public void setTypeProviderFactory(ActionClasspathTypeProviderFactory typeProviderFactory) {
|
||||
this.typeProviderFactory = typeProviderFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClasspathTypeProviderFactory getTypeProviderFactory() {
|
||||
return typeProviderFactory;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2014 openHAB UG (haftungsbeschraenkt) 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
|
||||
*/
|
||||
package org.eclipse.smarthome.model.script.scoping;
|
||||
|
||||
import org.eclipse.xtext.common.types.access.ClasspathTypeProviderFactory;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* This class makes use of the {@link ActionClassLoader} instead of a normal one.
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution and API
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
@Singleton
|
||||
public class ActionClasspathTypeProviderFactory extends ClasspathTypeProviderFactory {
|
||||
|
||||
@Inject
|
||||
public ActionClasspathTypeProviderFactory(ClassLoader classLoader) {
|
||||
super(classLoader);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
// @Inject
|
||||
// public ActionClasspathTypeProviderFactory(ClassLoader classLoader) {
|
||||
// super(new ActionClassLoader(classLoader));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected ClasspathTypeProvider createClasspathTypeProvider(ResourceSet resourceSet) {
|
||||
// return new ClasspathTypeProvider(new ActionClassLoader(super.getClassLoader(resourceSet)), resourceSet, getIndexedJvmTypeAccess());
|
||||
// }
|
||||
|
||||
}
|
|
@ -5,10 +5,7 @@ Bundle-Vendor: Eclipse.org/SmartHome
|
|||
Bundle-Version: 0.7.0.qualifier
|
||||
Bundle-SymbolicName: org.eclipse.smarthome.model.sitemap.runtime;singleton:=true
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: org.eclipse.smarthome.model.sitemap,
|
||||
com.google.inject
|
||||
Import-Package: org.eclipse.smarthome.model.core,
|
||||
org.osgi.framework,
|
||||
org.slf4j
|
||||
Fragment-Host: org.eclipse.smarthome.model.sitemap
|
||||
Import-Package: org.eclipse.core.runtime,
|
||||
org.eclipse.smarthome.model.core.guice
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Activator: org.eclipse.smarthome.model.sitemap.runtime.internal.SitemapRuntimeActivator
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
.,\
|
||||
fragment.xml
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<fragment>
|
||||
<extension
|
||||
point="org.eclipse.emf.ecore.extension_parser">
|
||||
<parser
|
||||
class="org.eclipse.smarthome.model.sitemap.runtime.internal.SitemapRuntimeExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
|
||||
type="sitemap">
|
||||
</parser>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.xtext.extension_resourceServiceProvider">
|
||||
<resourceServiceProvider
|
||||
class="org.eclipse.smarthome.model.sitemap.runtime.internal.SitemapRuntimeExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceServiceProvider"
|
||||
uriExtension="sitemap">
|
||||
</resourceServiceProvider>
|
||||
</extension>
|
||||
|
||||
</fragment>
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2014 openHAB UG (haftungsbeschränkt) 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
|
||||
*/
|
||||
package org.eclipse.smarthome.model.sitemap.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.SitemapStandaloneSetup;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
||||
public class SitemapRuntimeActivator implements BundleActivator {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(SitemapRuntimeActivator.class);
|
||||
|
||||
private static SitemapRuntimeActivator INSTANCE;
|
||||
|
||||
private Injector injector;
|
||||
|
||||
public void start(BundleContext context) throws Exception {
|
||||
INSTANCE = this;
|
||||
getInjector();
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
injector = null;
|
||||
INSTANCE = null;
|
||||
}
|
||||
|
||||
public static SitemapRuntimeActivator getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public Injector getInjector() {
|
||||
synchronized (this) {
|
||||
if (injector == null) {
|
||||
injector = createInjector();
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
}
|
||||
|
||||
protected Injector createInjector() {
|
||||
Injector injector = new SitemapStandaloneSetup().createInjectorAndDoEMFRegistration();
|
||||
logger.debug("Registered 'sitemap' configuration parser");
|
||||
return injector;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.eclipse.smarthome.model.sitemap.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.guice.AbstractGuiceAwareExecutableExtensionFactory;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class SitemapRuntimeExecutableExtensionFactory extends
|
||||
AbstractGuiceAwareExecutableExtensionFactory {
|
||||
|
||||
|
||||
@Override
|
||||
protected Injector getInjector() {
|
||||
return SitemapRuntimeInjectorProvider.getInjector();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +1,19 @@
|
|||
package org.eclipse.smarthome.model.sitemap.runtime.internal;
|
||||
|
||||
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
|
||||
import org.eclipse.smarthome.model.SitemapRuntimeModule;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class SitemapRuntimeInjectorProvider implements ModelInjectorProvider {
|
||||
|
||||
public Injector getInjector() {
|
||||
return SitemapRuntimeActivator.getInstance().getInjector();
|
||||
public class SitemapRuntimeInjectorProvider {
|
||||
private static Injector injector;
|
||||
|
||||
public static Injector getInjector() {
|
||||
|
||||
if (injector == null) {
|
||||
injector = Guice.createInjector(new SitemapRuntimeModule());
|
||||
}
|
||||
return injector;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<stringAttribute key="product" value=""/>
|
||||
<stringAttribute key="productFile" value="/org.eclipse.smarthome.runtime.product/org.eclipse.smarthome.runtime.product.product"/>
|
||||
<stringAttribute key="selected_target_plugins" value="ch.qos.logback.classic*1.0.0.v20111214-2030@default:default,ch.qos.logback.classic*1.0.7.v20121108-1250@default:default,ch.qos.logback.core*1.0.0.v20111214-2030@default:default,ch.qos.logback.core*1.0.7.v20121108-1250@default:default,ch.qos.logback.slf4j*1.0.7.v20121108-1250@default:false,com.google.guava@default:default,com.google.inject@default:default,com.ibm.icu@default:default,com.sun.jersey@default:default,javax.inject@default:default,javax.servlet@default:default,javax.ws.rs@default:default,javax.xml@default:default,org.antlr.runtime@default:default,org.apache.commons.codec@default:default,org.apache.commons.collections@default:default,org.apache.commons.exec@default:default,org.apache.commons.httpclient@default:default,org.apache.commons.io@default:default,org.apache.commons.lang@default:default,org.apache.commons.logging@default:default,org.apache.commons.net@default:default,org.apache.felix.gogo.command@default:true,org.apache.felix.gogo.runtime@default:true,org.apache.felix.gogo.shell@default:true,org.apache.httpcomponents.httpclient@default:default,org.apache.httpcomponents.httpcore@default:default,org.codehaus.jackson.core@default:default,org.codehaus.jackson.jaxrs@default:default,org.codehaus.jackson.mapper@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime@default:true,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.cm@3:true,org.eclipse.equinox.common@2:true,org.eclipse.equinox.console@default:true,org.eclipse.equinox.ds@2:true,org.eclipse.equinox.event@2:true,org.eclipse.equinox.frameworkadmin.equinox@3:true,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.http.servlet*1.1.400.v20130418-1354@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.console@3:true,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.ql@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@3:true,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.util@default:default,org.eclipse.jdt.core@default:default,org.eclipse.jetty.continuation*8.1.14.v20131031@default:default,org.eclipse.jetty.continuation*8.1.3.v20120522@default:default,org.eclipse.jetty.deploy@default:default,org.eclipse.jetty.http*8.1.14.v20131031@default:default,org.eclipse.jetty.http*8.1.3.v20120522@default:default,org.eclipse.jetty.io*8.1.14.v20131031@default:default,org.eclipse.jetty.io*8.1.3.v20120522@default:default,org.eclipse.jetty.osgi.boot@default:true,org.eclipse.jetty.osgi.httpservice@default:true,org.eclipse.jetty.security*8.1.14.v20131031@default:default,org.eclipse.jetty.security*8.1.3.v20120522@default:default,org.eclipse.jetty.server*8.1.14.v20131031@default:true,org.eclipse.jetty.server*8.1.3.v20120522@default:true,org.eclipse.jetty.servlet*8.1.14.v20131031@default:true,org.eclipse.jetty.util*8.1.14.v20131031@default:default,org.eclipse.jetty.util*8.1.3.v20120522@default:default,org.eclipse.jetty.webapp@default:default,org.eclipse.jetty.xml@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.text@default:default,org.eclipse.xtend.lib@default:default,org.eclipse.xtext.common.types@default:true,org.eclipse.xtext.ecore@default:default,org.eclipse.xtext.util@default:default,org.eclipse.xtext.xbase.lib@default:default,org.eclipse.xtext.xbase@default:default,org.eclipse.xtext@default:default,org.objectweb.asm@default:default,org.sat4j.core@default:default,org.sat4j.pb@default:default,org.slf4j.api*1.7.2.v20121108-1250@default:default,org.slf4j.jcl*1.7.2.v20130115-1340@default:default,org.slf4j.jul*1.7.2.v20121108-1250@default:default,org.slf4j.log4j*1.7.2.v20130115-1340@default:default"/>
|
||||
<stringAttribute key="selected_workspace_plugins" value="org.eclipse.smarthome.config.core@default:true,org.eclipse.smarthome.core.autoupdate@default:true,org.eclipse.smarthome.core.library@default:true,org.eclipse.smarthome.core.persistence@default:true,org.eclipse.smarthome.core.scheduler@default:true,org.eclipse.smarthome.core.scriptengine@default:true,org.eclipse.smarthome.core.transform@default:true,org.eclipse.smarthome.core@default:true,org.eclipse.smarthome.io.console@default:true,org.eclipse.smarthome.io.monitor@default:true,org.eclipse.smarthome.io.multimedia@default:true,org.eclipse.smarthome.io.net@default:true,org.eclipse.smarthome.io.rest@default:true,org.eclipse.smarthome.io.servicediscovery@default:true,org.eclipse.smarthome.model.core@default:true,org.eclipse.smarthome.model.item.runtime@default:true,org.eclipse.smarthome.model.item@default:true,org.eclipse.smarthome.model.persistence.runtime@default:true,org.eclipse.smarthome.model.persistence@default:true,org.eclipse.smarthome.model.rule.runtime@default:true,org.eclipse.smarthome.model.rule@default:true,org.eclipse.smarthome.model.script.runtime@default:true,org.eclipse.smarthome.model.script@default:true,org.eclipse.smarthome.model.sitemap.runtime@default:true,org.eclipse.smarthome.model.sitemap@default:true,org.eclipse.smarthome.ui.webapp@default:true,org.eclipse.smarthome.ui@default:true"/>
|
||||
<stringAttribute key="selected_workspace_plugins" value="org.eclipse.smarthome.config.core@default:true,org.eclipse.smarthome.core.autoupdate@default:true,org.eclipse.smarthome.core.library@default:true,org.eclipse.smarthome.core.persistence@default:true,org.eclipse.smarthome.core.scheduler@default:true,org.eclipse.smarthome.core.scriptengine@default:true,org.eclipse.smarthome.core.transform@default:true,org.eclipse.smarthome.core@default:true,org.eclipse.smarthome.io.console@default:true,org.eclipse.smarthome.io.monitor@default:true,org.eclipse.smarthome.io.multimedia@default:true,org.eclipse.smarthome.io.net@default:true,org.eclipse.smarthome.io.rest@default:true,org.eclipse.smarthome.io.servicediscovery@default:true,org.eclipse.smarthome.model.core@default:true,org.eclipse.smarthome.model.item.runtime@default:false,org.eclipse.smarthome.model.item@3:true,org.eclipse.smarthome.model.persistence.runtime@default:false,org.eclipse.smarthome.model.persistence@3:true,org.eclipse.smarthome.model.rule.runtime@default:false,org.eclipse.smarthome.model.rule@3:true,org.eclipse.smarthome.model.script.runtime@default:false,org.eclipse.smarthome.model.script@3:true,org.eclipse.smarthome.model.sitemap.runtime@default:false,org.eclipse.smarthome.model.sitemap@3:true,org.eclipse.smarthome.ui.webapp@default:true,org.eclipse.smarthome.ui@default:true"/>
|
||||
<booleanAttribute key="show_selected_only" value="false"/>
|
||||
<booleanAttribute key="tracing" value="false"/>
|
||||
<booleanAttribute key="useCustomFeatures" value="false"/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче