-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from seime/transformation_support
Added transformation service support
- Loading branch information
Showing
5 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/org/openhab/automation/jrule/internal/handler/JRuleTransformationHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.automation.jrule.internal.handler; | ||
|
||
import org.openhab.core.transform.TransformationException; | ||
import org.openhab.core.transform.TransformationHelper; | ||
import org.osgi.framework.BundleContext; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* The {@link JRuleTransformationHandler} is responsible for handling transformation requests | ||
* | ||
* @author Arne Seime - Initial contribution | ||
*/ | ||
public class JRuleTransformationHandler { | ||
|
||
private static volatile JRuleTransformationHandler instance; | ||
|
||
private BundleContext bundleContext; | ||
|
||
private final Logger logger = LoggerFactory.getLogger(JRuleTransformationHandler.class); | ||
|
||
private JRuleTransformationHandler() { | ||
} | ||
|
||
public static JRuleTransformationHandler get() { | ||
if (instance == null) { | ||
synchronized (JRuleTransformationHandler.class) { | ||
if (instance == null) { | ||
instance = new JRuleTransformationHandler(); | ||
} | ||
} | ||
} | ||
return instance; | ||
} | ||
|
||
public void setBundleContext(BundleContext bundleContext) { | ||
this.bundleContext = bundleContext; | ||
} | ||
|
||
public String transform(String stateDescPattern, String state) throws TransformationException { | ||
return TransformationHelper.transform(bundleContext, stateDescPattern, state); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters