Introduction of ModelInjectorProvider

Signed-off-by: Oliver Libutzki <oliver@libutzki.de>
This commit is contained in:
Oliver Libutzki 2014-05-14 16:45:35 +02:00
Родитель dc44e8e008
Коммит 0e2d026a0e
52 изменённых файлов: 762 добавлений и 26 удалений

Просмотреть файл

@ -8,6 +8,7 @@ Bundle-Vendor: Eclipse.org/SmartHome
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: com.google.common.base,
com.google.common.collect,
com.google.inject,
org.apache.commons.collections;version="3.2.0",
org.apache.commons.io,
org.apache.commons.lang;version="2.3.0",

Просмотреть файл

@ -0,0 +1,8 @@
package org.eclipse.smarthome.model.core;
import com.google.inject.Injector;
public interface ModelInjectorProvider {
Injector getInjector();
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Просмотреть файл

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.smarthome.model.item.runtime</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

Просмотреть файл

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

Просмотреть файл

@ -0,0 +1,15 @@
Manifest-Version: 1.0
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

Просмотреть файл

@ -0,0 +1,17 @@
<?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>

Просмотреть файл

@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/

Просмотреть файл

@ -0,0 +1,56 @@
/**
* 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,13 @@
package org.eclipse.smarthome.model.item.runtime.internal;
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
import com.google.inject.Injector;
public class ItemRuntimeInjectorProvider implements ModelInjectorProvider {
public Injector getInjector() {
return ItemRuntimeActivator.getInstance().getInjector();
}
}

Просмотреть файл

@ -20,8 +20,9 @@ Import-Package: com.google.common.collect,
org.apache.log4j,
org.eclipse.smarthome.core.items,
org.eclipse.smarthome.designer.ui,
org.osgi.service.event,
org.eclipse.xtext.xbase.lib
org.eclipse.smarthome.model.core,
org.eclipse.xtext.xbase.lib,
org.osgi.service.event
Export-Package: org.eclipse.smarthome.model.ui.contentassist.antlr,
org.eclipse.smarthome.model.ui.contentassist,
org.eclipse.smarthome.model.ui.quickfix,

Просмотреть файл

@ -0,0 +1,17 @@
<?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>

Просмотреть файл

@ -0,0 +1,14 @@
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);
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Просмотреть файл

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.smarthome.model.persistence.runtime</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

Просмотреть файл

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

Просмотреть файл

@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse SmartHome Persistence Runtime
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.osgi.framework,
org.slf4j
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclipse.smarthome.model.persistence.runtime.internal.PersistenceRuntimeActivator

Просмотреть файл

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

Просмотреть файл

@ -0,0 +1,29 @@
/**
* 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;
public class PersistenceRuntimeActivator implements BundleActivator {
private final static Logger logger = LoggerFactory.getLogger(PersistenceRuntimeActivator.class);
public void start(BundleContext context) throws Exception {
new PersistenceStandaloneSetup().createInjectorAndDoEMFRegistration();
logger.debug("Registered 'persistence' configuration parser");
}
public void stop(BundleContext context) throws Exception {
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Просмотреть файл

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.smarthome.model.rule.runtime</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

Просмотреть файл

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

Просмотреть файл

@ -0,0 +1,15 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse SmartHome Rule Runtime
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

Просмотреть файл

@ -0,0 +1,17 @@
<?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>

Просмотреть файл

@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/

Просмотреть файл

@ -0,0 +1,56 @@
/**
* 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;
}
}

Просмотреть файл

@ -0,0 +1,13 @@
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();
}
}

Просмотреть файл

@ -30,6 +30,7 @@ Import-Package: com.google.common.base,
org.eclipse.smarthome.core.persistence,
org.eclipse.smarthome.core.scriptengine,
org.eclipse.smarthome.core.scriptengine.action,
org.eclipse.smarthome.model.core,
org.eclipse.smarthome.model.persistence.extensions,
org.eclipse.xtext.xbase.lib,
org.joda.time,

Просмотреть файл

@ -0,0 +1,17 @@
<?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>

Просмотреть файл

@ -0,0 +1,14 @@
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);
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Просмотреть файл

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.smarthome.model.script.runtime</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

Просмотреть файл

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

Просмотреть файл

@ -0,0 +1,15 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse SmartHome Script Runtime
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

Просмотреть файл

@ -0,0 +1,17 @@
<?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>

Просмотреть файл

@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/

Просмотреть файл

@ -0,0 +1,55 @@
/**
* 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,13 @@
package org.eclipse.smarthome.model.script.runtime.internal;
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
import com.google.inject.Injector;
public class ScriptRuntimeInjectorProvider implements ModelInjectorProvider {
public Injector getInjector() {
return ScriptRuntimeActivator.getInstance().getInjector();
}
}

Просмотреть файл

@ -28,6 +28,7 @@ Import-Package: com.google.common.base,
org.eclipse.smarthome.core.persistence,
org.eclipse.smarthome.core.scriptengine.action,
org.eclipse.smarthome.core.types,
org.eclipse.smarthome.model.core,
org.eclipse.smarthome.model.persistence.extensions,
org.eclipse.xtext.xbase.lib,
org.joda.time,

Просмотреть файл

@ -0,0 +1,17 @@
<?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,4 +4,5 @@ source.. = src/,\
bin.includes = META-INF/,\
.,\
plugin.xml,\
icons/
icons/,\
OSGI-INF/

Просмотреть файл

@ -0,0 +1,14 @@
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);
}
}

Просмотреть файл

@ -13,4 +13,5 @@
<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>

Просмотреть файл

@ -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.script.ScriptStandaloneSetup;
import org.eclipse.smarthome.model.core.ModelInjectorProvider;
import org.eclipse.xtext.diagnostics.Severity;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
@ -34,7 +34,6 @@ import org.eclipse.xtext.validation.Issue;
import org.eclipse.xtext.xbase.XExpression;
import com.google.common.base.Predicate;
import com.google.inject.Inject;
import com.google.inject.Injector;
/**
@ -46,40 +45,28 @@ import com.google.inject.Injector;
@SuppressWarnings("restriction")
public class ScriptEngineImpl implements ScriptEngine {
protected Injector guiceInjector;
protected XtextResourceSet resourceSet;
private Injector injector;
public ScriptEngineImpl() {}
public void activate() {
}
@Inject
public void setGuiceInjector(Injector injector) {
this.guiceInjector = injector;
}
private Injector getInjector() {
if (guiceInjector == null) {
guiceInjector = new ScriptStandaloneSetup().createInjectorAndDoEMFRegistration();
}
return guiceInjector;
}
private XtextResourceSet getResourceSet() {
if (resourceSet == null) {
resourceSet = guiceInjector.getInstance(XtextResourceSet.class);
resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
}
return resourceSet;
}
public void deactivate() {
this.guiceInjector = null;
this.injector = null;
this.resourceSet = null;
}
@ -95,7 +82,7 @@ public class ScriptEngineImpl implements ScriptEngine {
* {@inheritDoc}
*/
public Script newScriptFromXExpression(XExpression expression) {
ScriptImpl script = getInjector().getInstance(ScriptImpl.class);
ScriptImpl script = injector.getInstance(ScriptImpl.class);
script.setXExpression(expression);
return script;
}
@ -162,5 +149,13 @@ public class ScriptEngineImpl implements ScriptEngine {
});
return issues;
}
public void setInjectorProvider(ModelInjectorProvider injectorProvider) {
this.injector = injectorProvider.getInjector();
}
public void unsetInjectorProvider(ModelInjectorProvider injectorProvider) {
this.injector = null;
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Просмотреть файл

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.smarthome.model.sitemap.runtime</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

Просмотреть файл

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

Просмотреть файл

@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse SmartHome Sitemap Runtime
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.osgi.framework,
org.slf4j
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclipse.smarthome.model.sitemap.runtime.internal.SitemapRuntimeActivator

Просмотреть файл

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

Просмотреть файл

@ -0,0 +1,29 @@
/**
* 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;
public class SitemapRuntimeActivator implements BundleActivator {
private final static Logger logger = LoggerFactory.getLogger(SitemapRuntimeActivator.class);
public void start(BundleContext context) throws Exception {
new SitemapStandaloneSetup().createInjectorAndDoEMFRegistration();
logger.debug("Registered 'sitemap' configuration parser");
}
public void stop(BundleContext context) throws Exception {
}
}

Просмотреть файл

@ -15,7 +15,7 @@
<booleanAttribute key="includeOptional" value="false"/>
<stringAttribute key="location" value="${workspace_loc}/../smarthome-designer"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 7"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JDK 7 [1.7.0_51]"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dsmarthome.configfile=configurations/smarthome.cfg -DnoRules=true -Dlogback.configurationFile=configurations/logback.xml -Xmx256m -XX:PermSize=128m"/>

Просмотреть файл

@ -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@default:true,org.eclipse.smarthome.model.persistence@default:true,org.eclipse.smarthome.model.rule@default:true,org.eclipse.smarthome.model.script@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:default,org.eclipse.smarthome.model.item@default:true,org.eclipse.smarthome.model.persistence.runtime@default:default,org.eclipse.smarthome.model.persistence@default:true,org.eclipse.smarthome.model.rule.runtime@default:default,org.eclipse.smarthome.model.rule@default:true,org.eclipse.smarthome.model.script.runtime@default:default,org.eclipse.smarthome.model.script@default:true,org.eclipse.smarthome.model.sitemap.runtime@default:default,org.eclipse.smarthome.model.sitemap@default: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"/>