Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rules-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
<name>Jahia Rules samples</name>
<description>This is a module with Rules samples</description>

<properties>
<!-- This property is important we declare that we want to export our package that contains our services, -->
<!-- we could provide multiple package if needed to do so just separate them with a comma. -->
<export-package>org.foo.modules.rules</export-package>
</properties>

<scm>
<connection>scm:git:git@github.com:Jahia/OSGi-modules-samples.git</connection>
<developerConnection>scm:git:git@github.com:Jahia/OSGi-modules-samples.git</developerConnection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
@Component(service=Service1.class)
public class Service1 {
private static Logger logger = LoggerFactory.getLogger(Service1.class);

public void hello(AddedNodeFact node) throws RepositoryException {
logger.info("Hello 1 " + node.getName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import org.osgi.service.component.annotations.Reference;

/**
* Simple Background Job declared with OSGi
* Module global rules object to register custom OSGi services
*
* @author dgaillard
*/
@Component(service = ModuleGlobalObject.class)
public class TestRules extends ModuleGlobalObject {
Expand Down
14 changes: 8 additions & 6 deletions rules-samples/src/main/resources/META-INF/rules.drl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package org.foo.modules.rules

// list any import classes here.
// list any import classes here. This is needed for OSGi to calculate the proper dependencies
import org.jahia.services.content.rules.*
import org.jahia.services.content.JCRContentUtils
import org.jahia.services.content.JCRValueWrapper
import org.slf4j.Logger

global User user
Expand All @@ -14,15 +13,18 @@ global Service1 service1
global Service2 service2

rule "Hello bigText"
salience 100
when
> node: AddedNodeFact ( types contains "jnt:bigText" )
A new node is created
- the node has the type jnt:bigText
then
> service1.hello(node);
Say hello to node using service1
end

rule "Hello contentList"
when
> node: AddedNodeFact (types contains "jnt:contentList")
A new node is created
- the node has the type jnt:contentList
then
> service2.hello(node);
Say hello to node using service2
end
2 changes: 2 additions & 0 deletions rules-samples/src/main/resources/META-INF/rules.dsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[consequence][]Say hello to {node} using service1=service1.hello({node});
[consequence][]Say hello to {node} using service2=service2.hello({node});