Skip to content

Instantly share code, notes, and snippets.

@kjellski
Last active December 10, 2015 19:58
Show Gist options
  • Select an option

  • Save kjellski/4485050 to your computer and use it in GitHub Desktop.

Select an option

Save kjellski/4485050 to your computer and use it in GitHub Desktop.
Thanks for watching over ti jary!
IActionRegistry actionRegistry
...
this.ksession = getConfiguredKnowledgeSession(this.kbase);
if (this.ksession == null) throw new IllegalStateException("StatefulKnowledgeSession was null.");
this.ksession.setGlobal("Action", actionRegistry);
/**
* This registry interface is used to define that action registry which will independently execute the actions
* from rules and other bundles.
*/
public interface IActionRegistry extends IRegistry<IAction> {
/**
* Executes the Action given by Identifier with given properties
* @param actionQualifier Qualifier to find the action
* @param actionProperties Properties to be used for the execution of the action.
*/
void executeAction(IActionQualifier actionQualifier, IActionProperties actionProperties);
/**
* Executes the Action given by Identifier
* @param actionQualifier Qualifier to find the action
*/
void executeAction(IActionQualifier actionQualifier);
/**
* Executes the given action instance with this registry.
* @param action
*/
void executeAction(IAction action);
}
import org.livingplace.controlling.informations.sensors.time.internal.UTCTimeInformation;
import org.livingplace.controlling.actions.actors.time.internal.BroadcastTimeOnAMQ;
import org.livingplace.controlling.actions.api.IAction;
global org.livingplace.controlling.actions.registry.api.IActionRegistry Action;
declare UTCTimeInformation
@role ( event )
@expires( 30s )
end
rule "Timing rule"
dialect "mvel" (1)
dialect "java" (2)
when
t : UTCTimeInformation()
then
Action.execute( (IAction) new BroadcastTimeOnAMQ() );
end
There are errors in the rules: Rule Compilation error : [Rule name='Timing rule']
defaultpkg/Rule_Timing_rule_b0791adc9a234150ac0708e353b3af03.java (2:82) : Only a type can be imported. org.livingplace.controlling.actions.actors.time.internal.BroadcastTimeOnAMQ resolves to a package
defaultpkg/Rule_Timing_rule_b0791adc9a234150ac0708e353b3af03.java (2:165) : Only a type can be imported. org.livingplace.controlling.informations.sensors.time.internal.UTCTimeInformation resolves to a package
defaultpkg/Rule_Timing_rule_b0791adc9a234150ac0708e353b3af03.java (7:622) : The type org.livingplace.controlling.api.IRegistry cannot be resolved. It is indirectly referenced from required .class files
defaultpkg/Rule_Timing_rule_b0791adc9a234150ac0708e353b3af03.java (7:629) : The method execute(IAction) is undefined for the type IActionRegistry
defaultpkg/Rule_Timing_rule_b0791adc9a234150ac0708e353b3af03.java (7:651) : BroadcastTimeOnAMQ cannot be resolved to a type
org.livingplace.controlling.knowledge.api.internal.IllegalRuleEvaluationException: There are errors in the rules: Rule Compilation error : [Rule name='Timing rule']
defaultpkg/Rule_Timing_rule_b0791adc9a234150ac0708e353b3af03.java (2:82) : Only a type can be imported. org.livingplace.controlling.actions.actors.time.internal.BroadcastTimeOnAMQ resolves to a package
defaultpkg/Rule_Timing_rule_b0791adc9a234150ac0708e353b3af03.java (2:165) : Only a type can be imported. org.livingplace.controlling.informations.sensors.time.internal.UTCTimeInformation resolves to a package
defaultpkg/Rule_Timing_rule_b0791adc9a234150ac0708e353b3af03.java (7:622) : The type org.livingplace.controlling.api.IRegistry cannot be resolved. It is indirectly referenced from required .class files
defaultpkg/Rule_Timing_rule_b0791adc9a234150ac0708e353b3af03.java (7:629) : The method execute(IAction) is undefined for the type IActionRegistry
defaultpkg/Rule_Timing_rule_b0791adc9a234150ac0708e353b3af03.java (7:651) : BroadcastTimeOnAMQ cannot be resolved to a type
at org.livingplace.controlling.knowledge.api.internal.DroolsManager.getConfiguredKnowledgeBuilder(DroolsManager.java:140)
at org.livingplace.controlling.knowledge.api.internal.DroolsManager.<init>(DroolsManager.java:46)
at org.livingplace.controlling.knowledge.api.internal.RuleEngine.init(RuleEngine.java:55)
at org.livingplace.controlling.knowledge.api.internal.RuleEngine.start(RuleEngine.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:227)
at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:38)
at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:591)
at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:472)
at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:146)
at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createImplementationObject(ImmediateComponentManager.java:226)
at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createComponent(ImmediateComponentManager.java:118)
at org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfied.activate(AbstractComponentManager.java:997)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:333)
...
There are errors in the rules: Unable to Analyse Expression Action.execute((IAction) new BroadcastTimeOnAMQ());:
[Error: unexpected character (expected identifier): ]
[Near : {... Action.execute((IAction) new BroadcastTimeOnAMQ()); ....}]
^
[Line: 12, Column: 0] : [Rule name='Timing rule']
org.livingplace.controlling.knowledge.api.internal.IllegalRuleEvaluationException: There are errors in the rules: Unable to Analyse Expression Action.execute((IAction) new BroadcastTimeOnAMQ());:
[Error: unexpected character (expected identifier): ]
[Near : {... Action.execute((IAction) new BroadcastTimeOnAMQ()); ....}]
^
[Line: 12, Column: 0] : [Rule name='Timing rule']
at org.livingplace.controlling.knowledge.api.internal.DroolsManager.getConfiguredKnowledgeBuilder(DroolsManager.java:140)
at org.livingplace.controlling.knowledge.api.internal.DroolsManager.<init>(DroolsManager.java:46)
at org.livingplace.controlling.knowledge.api.internal.RuleEngine.init(RuleEngine.java:55)
at org.livingplace.controlling.knowledge.api.internal.RuleEngine.start(RuleEngine.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:227)
at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:38)
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment