|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.fosstrak.capturingapp.ECReportsHandler
public abstract class ECReportsHandler
An ECReportHandler receives a ECReport and generates a EPCIS document that
can be sent to an EPCIS repository. If you would like to implement your own
handler, you will find some guide-lines below. In addition you can get inspiration
by the default reports handler DefaultECReportHandler
.
LinkedList<EPCISDocumentType>
handle(ECReports reports)
, the execution sequence of the handler is
as following:
abstract loadRules()
: load drools rules from disc.checkErrors()
: checks if errors in the rule-set. If there are
errors, an exception is thrown.registerKnowledgeBase()
: Create a new knowledge-base
kbase
from the kbuilder
.createSession()
: Creates a drools session. By default, a
StatefulKnowledgeSession is created. Notice, that all
subsequent generic methods are programmed in such a way, that they can
handle both StatefulKnowledgeSession and
StatelessKnowledgeSession.prepareGlobalCollector(ksession)
: Registers a collector for
the EPCIS documents. If you override the method handle
make
sure, to call this method before you execute the drools
rules as otherwise third-party drools rules might crash.executeSession(reports):
: Execute the drools rules. In
StatefulKnowledgeSession the ECReports are injected via
insert
, in StatelessKnowledgeSession the
rules are executed via execute
.collectResults()
: Retrieves the results from the global
collector and submits them to the capture application for further delivery.loadRules()
. It is required, that
this method loads the drools rules from the file-system into
kbuilder
.kbuilder.add(
ResourceFactory.newClassPathResource(
changeSet,
DefaultECReportHandler.class),
ResourceType.CHANGE_SET);
Field Summary | |
---|---|
protected java.lang.String |
changeSet
|
static java.lang.String |
DEFAULT_RULE_SET
the default change-set to load with the drools rules. |
protected java.util.ArrayList<java.lang.Object> |
epcis
array that will collect the results from the drools executions. |
protected org.drools.KnowledgeBase |
kbase
the knowledge base. |
protected org.drools.builder.KnowledgeBuilder |
kbuilder
the knowledge builder. |
protected java.lang.Object |
ksession
the knowledge session. this is object to allow either state-full or state-less sessions. |
static java.lang.String |
RESULTS
the name of the global variable for the drools results. |
Constructor Summary | |
---|---|
ECReportsHandler()
default constructor. sets the rule-set to 'changeset.xml'. |
|
ECReportsHandler(java.lang.String changeSet)
create a new handler with a non default change set. |
Method Summary | |
---|---|
protected void |
checkErrors()
check the knowledge-builder for errors in the rules. |
protected java.util.LinkedList<org.fosstrak.epcis.model.EPCISDocumentType> |
collectResults()
collect the results from the rules evaluation and put them into a nice typed linked list. |
protected void |
createSession()
create a new knowledge session. |
void |
dispose()
in case of a StatefullKnowledgeSession we have to call
dispose at the end of execution. |
void |
executeSession(org.fosstrak.ale.xsd.ale.epcglobal.ECReports reports)
executes the drools session. |
java.lang.String |
getChangeSet()
|
java.util.LinkedList<org.fosstrak.epcis.model.EPCISDocumentType> |
handle(org.fosstrak.ale.xsd.ale.epcglobal.ECReports reports)
this method is invoked from the capture application whenever a new ECReports is received. |
abstract void |
loadRules()
// parse and compile the rule from file kbuilder.add(ResourceFactory.newClassPathResource( "HelloWorld.drl", HelloWorld.class), ResourceType.DRL); |
protected void |
prepareGlobalCollector(java.lang.Object ksession)
prepare a global collector where the rules can store the results to. |
protected void |
registerKnowledgeBase()
register the knowledge base from the rule builder in the knowledge base. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String RESULTS
protected java.util.ArrayList<java.lang.Object> epcis
protected final org.drools.builder.KnowledgeBuilder kbuilder
protected org.drools.KnowledgeBase kbase
protected java.lang.Object ksession
public static final java.lang.String DEFAULT_RULE_SET
protected final java.lang.String changeSet
Constructor Detail |
---|
public ECReportsHandler()
public ECReportsHandler(java.lang.String changeSet)
changeSet
- Method Detail |
---|
public final java.lang.String getChangeSet()
public java.util.LinkedList<org.fosstrak.epcis.model.EPCISDocumentType> handle(org.fosstrak.ale.xsd.ale.epcglobal.ECReports reports) throws java.lang.RuntimeException
null
, then no report is generated. prepareGlobalCollector(ksession)
before you invoke the rule-set.
reports
- the ECReports with the EPC data.
java.lang.RuntimeException
- when the rule(s) could not be compiled.public void executeSession(org.fosstrak.ale.xsd.ale.epcglobal.ECReports reports)
StatelessKnowledgeSession
and
StatefulKnowledgeSession
and invokes them respectively.
reports
- the ECReports.protected void createSession()
StatefulKnowledgeSession
is generated.
protected void registerKnowledgeBase()
protected void checkErrors() throws java.lang.RuntimeException
java.lang.RuntimeException
- when there are errors in the rules.protected void prepareGlobalCollector(java.lang.Object ksession)
ksession
- the session holding the collector.protected java.util.LinkedList<org.fosstrak.epcis.model.EPCISDocumentType> collectResults()
public abstract void loadRules()
// parse and compile the rule from file
kbuilder.add(ResourceFactory.newClassPathResource(
"HelloWorld.drl", HelloWorld.class), ResourceType.DRL);
public void dispose()
StatefullKnowledgeSession
we have to call
dispose at the end of execution.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |