本文整理汇总了Java中org.kie.internal.builder.KnowledgeBuilderFactory类的典型用法代码示例。如果您正苦于以下问题:Java KnowledgeBuilderFactory类的具体用法?Java KnowledgeBuilderFactory怎么用?Java KnowledgeBuilderFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KnowledgeBuilderFactory类属于org.kie.internal.builder包,在下文中一共展示了KnowledgeBuilderFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadDrools
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
private void loadDrools() {
try {
logger.info("Initializing Drools rule engine");
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
addDrls(kbuilder);
KieSessionConfiguration config = KieServices.Factory.get().newKieSessionConfiguration();
config.setOption(ClockTypeOption.get("pseudo"));
logger.debug("Compiling rules");
kSession = kbuilder.newKieBase().newKieSession(config, null);
homeioSessionClock = new HomeioSessionClock(kSession.getSessionClock());
initGlobals();
droolsInitialized = true;
logger.debug("Successfully initialized Drools rule engine");
} catch (Exception e) {
logger.error("Exiting because of an exception during the Drools initialization ", e);
new RuntimeException("Exiting because of an exception during the Drools initialization");
}
}
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:26,代码来源:DroolsEventBusClient.java
示例2: loadDrools
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
private void loadDrools() {
try {
logger.info("Initializing Drools rule engine");
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
addDrls(kbuilder);
logger.debug("Compiling rules");
kSession = kbuilder.newKieBase().newKieSession();
initGlobals();
droolsInitialized = true;
logger.info("Successfully initialized Drools rule engine");
} catch (Exception e) {
logger.error("Exiting because of an exception during the Drools initialization ", e);
new RuntimeException("Exiting because of an exception during the Drools initialization");
}
}
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:21,代码来源:DroolsEventBusClient.java
示例3: addRule
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
/**
* 单一规则上线
*
* @param packageName
* @param ruleName
*/
public void addRule(String packageName, String ruleName) {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(packageName + "/" + ruleName + ".drl"), ResourceType.DRL);
if (kbuilder.hasErrors()) {
logger.error("Unable to compile drl. " + packageName + ruleName + ".drl");
return;
} else {
if (kbase.getRule(packageName, ruleName) != null) {
logger.info("update rule: " + packageName + "." + ruleName);
} else {
logger.info("add rule: " + packageName + "." + ruleName);
}
}
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
kieSession = kbase.newStatelessKieSession();
setGlobal();
printRules();
}
开发者ID:ysrc,项目名称:Liudao,代码行数:26,代码来源:KieService.java
示例4: testCallService
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
@Test
public void testCallService() throws Exception {
final Holder holder = new Holder();
serviceDomain.registerService(new QName("CallService"), new InOnlyService(), new BaseHandler(){
public void handleMessage(Exchange exchange) throws HandlerException {
holder.setValue("message handled");
}
});
serviceDomain.registerServiceReference(new QName("CallService"), new InOnlyService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(CALL_SERVICE_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
ksession.startProcess("CallService");
ksession.halt();
ksession.dispose();
Assert.assertEquals("message handled", holder.getValue());
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:23,代码来源:BPMServiceTests.java
示例5: runFaultBoundaryProcess
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
private void runFaultBoundaryProcess(final boolean bomb) throws Exception {
serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler(){
public void handleMessage(Exchange exchange) throws HandlerException {
if (bomb) {
throw new HandlerException("BOOM!");
}
}
});
serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(FAULT_BOUNDARY_PROCESS_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultBoundaryProcess");
String output = (String)wpi.getVariable("TestOutput");
Assert.assertEquals(bomb ? "Failure" : "Success", output);
ksession.halt();
ksession.dispose();
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:24,代码来源:BPMServiceTests.java
示例6: testCallService
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
@Test
public void testCallService() throws Exception {
final Holder holder = new Holder();
serviceDomain.registerService(new QName("CallService"), new InOnlyService(), new BaseHandler() {
public void handleMessage(Exchange exchange) throws HandlerException {
holder.setValue("message handled");
}
});
serviceDomain.registerServiceReference(new QName("CallService"), new InOnlyService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(CALL_SERVICE_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
ksession.startProcess("CallService");
ksession.halt();
ksession.dispose();
Assert.assertEquals("message handled", holder.getValue());
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:23,代码来源:BPMServiceTests.java
示例7: runFaultBoundaryProcess
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
private void runFaultBoundaryProcess(final boolean bomb) throws Exception {
serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler() {
public void handleMessage(Exchange exchange) throws HandlerException {
if (bomb) {
throw new HandlerException("BOOM!");
}
}
});
serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(FAULT_BOUNDARY_PROCESS_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultBoundaryProcess");
String output = (String)wpi.getVariable("TestOutput");
Assert.assertEquals(bomb ? "Failure" : "Success", output);
ksession.halt();
ksession.dispose();
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:24,代码来源:BPMServiceTests.java
示例8: testNamedWorksheet
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
/**
* Test named worksheet.
*
* @throws Exception the exception
*/
@Test
public void testNamedWorksheet() throws Exception {
DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType(DecisionTableInputType.XLS);
dtconf.setWorksheetName("Tables");
Resource dt = ResourceFactory.newClassPathResource("/data/IntegrationExampleTest.xls", getClass()).setConfiguration(
dtconf);
KieSession ksession = getKieSession(dt);
// ASSERT AND FIRE
ksession.insert(new Cheese("cheddar", 42));
ksession.insert(new Person("michael", "stilton", 21));
final List<String> list = new ArrayList<String>();
ksession.setGlobal("list", list);
ksession.fireAllRules();
assertEquals(1, list.size());
assertEquals("Young man cheddar", list.get(0));
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:25,代码来源:SpreadsheetIntegrationExampleTest.java
示例9: addPackage
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
/**
* 规则集上线
*
* @param packageName
*/
public void addPackage(String packageName) {
try {
File path = new File(this.getClass().getClassLoader().getResource(packageName).toURI().getPath());
if (path.isDirectory()) {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
File[] files = path.listFiles();
for (File file : files) {
if (file.getName().endsWith(".drl")) {
kbuilder.add(ResourceFactory.newClassPathResource(packageName + "/" + file.getName()), ResourceType.DRL);
if (kbuilder.hasErrors()) {
logger.error("Unable to compile drl. " + packageName + file.getName());
return;
} else {
String ruleName = file.getName().replace(".drl", "");
if (kbase.getRule(packageName, ruleName) != null) {
logger.info("update rule: " + packageName + "." + ruleName);
} else {
logger.info("add rule: " + packageName + "." + ruleName);
}
}
}
}
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
kieSession = kbase.newStatelessKieSession();
setGlobal();
printRules();
}
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
开发者ID:ysrc,项目名称:Liudao,代码行数:38,代码来源:KieService.java
示例10: runFaultResultProcess
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
private void runFaultResultProcess(final boolean bomb) throws Exception {
serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler(){
public void handleMessage(Exchange exchange) throws HandlerException {
if (bomb) {
throw new HandlerException("BOOM!");
}
}
});
serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(FAULT_RESULT_PROCESS_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultResultProcess");
HandlerException he = (HandlerException)wpi.getVariable("faultResult");
if (bomb) {
Assert.assertNotNull(he);
Assert.assertEquals("BOOM!", he.getMessage());
} else {
Assert.assertNull(he);
}
ksession.halt();
ksession.dispose();
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:29,代码来源:BPMServiceTests.java
示例11: runFaultEventProcess
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
private void runFaultEventProcess(final boolean bomb) throws Exception {
serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler(){
public void handleMessage(Exchange exchange) throws HandlerException {
if (bomb) {
throw new HandlerException("BOOM!");
}
}
});
serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(FAULT_EVENT_PROCESS_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultEventProcess");
HandlerException he = (HandlerException)wpi.getVariable("faultEvent");
if (bomb) {
Assert.assertNotNull(he);
Assert.assertEquals("BOOM!", he.getMessage());
} else {
Assert.assertNull(he);
}
ksession.halt();
ksession.dispose();
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:29,代码来源:BPMServiceTests.java
示例12: ResourceBuilder
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
/**
* Creates a new ResourceBuilder.
* @param classLoader classLoader
* @param resourceModel resourceModel
*/
public ResourceBuilder(ClassLoader classLoader, ResourceModel resourceModel) {
super(classLoader);
_kieResources = KieServices.Factory.get().getResources();
if (resourceModel != null) {
_url = resourceModel.getLocationURL(getClassLoader());
_resourceType = convertResourceType(resourceModel.getType());
ResourceDetail syResourceDetail = resourceModel.getDetail();
if (syResourceDetail != null) {
if (ResourceType.DTABLE.equals(_resourceType)) {
String inputType = getInputType(syResourceDetail, DecisionTableInputType.XLS.toString());
DecisionTableConfiguration dtc = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtc.setInputType(DecisionTableInputType.valueOf(inputType));
dtc.setWorksheetName(getWorksheetName(syResourceDetail));
//dtc.setUsingExternalTypes(syResourceDetail.isUsingExternalTypes());
_resourceConfiguration = dtc;
}
/* SWITCHYARD-1662
else if (ResourceType.SCARD.equals(_resourceType)) {
String inputType = getInputType(syResourceDetail, ScoreCardConfiguration.SCORECARD_INPUT_TYPE.EXCEL.name());
if ("XLS".equals(inputType)) {
inputType = ScoreCardConfiguration.SCORECARD_INPUT_TYPE.EXCEL.name();
}
ScoreCardConfiguration scc = KnowledgeBuilderFactory.newScoreCardConfiguration();
scc.setInputType(ScoreCardConfiguration.SCORECARD_INPUT_TYPE.valueOf(inputType));
scc.setWorksheetName(getWorksheetName(syResourceDetail));
//scc.setUsingExternalTypes(syResourceDetail.isUsingExternalTypes());
_resourceConfiguration = scc;
}
*/
}
}
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:38,代码来源:ResourceBuilder.java
示例13: getDistributeSimplifyKnowledgeBase
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
/**
* Returns Drools ( <A href="http://drools.org">http://drools.org</A> ) knowledge base for algebraic simplification.
*
* @return Drools ( <A href="http://drools.org">http://drools.org</A> ) knowledge base for algebraic simplification.
*/
public static KnowledgeBase getDistributeSimplifyKnowledgeBase()
{
if( distributeSimplifyKnowledgeBase == null )
{
OptimizerFactory.setDefaultOptimizer( OptimizerFactory.SAFE_REFLECTIVE );
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// Load in the reng support as a separate cross-cutting concern.
builder.add( ResourceFactory.newClassPathResource( "reng.drl" ) ,
ResourceType.DRL );
builder.add( ResourceFactory.newClassPathResource( "distributeSimplify.drl" ) ,
ResourceType.DRL );
if( LoggingConfiguration.LOGGING_ON )
{
builder.add( ResourceFactory.newClassPathResource( "logging.drl" ) ,
ResourceType.DRL );
}
if( builder.hasErrors() )
{
throw( new RuntimeException( builder.getErrors().toString() ) );
}
distributeSimplifyKnowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
distributeSimplifyKnowledgeBase.addKnowledgePackages( builder.getKnowledgePackages() );
}
return( distributeSimplifyKnowledgeBase );
}
开发者ID:viridian1138,项目名称:SimpleAlgebra_V2,代码行数:37,代码来源:Elem.java
示例14: getDistributeSimplify2KnowledgeBase
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
/**
* Returns Drools ( <A href="http://drools.org">http://drools.org</A> ) knowledge base for algebraic simplification.
*
* @return Drools ( <A href="http://drools.org">http://drools.org</A> ) knowledge base for algebraic simplification.
*/
public static KnowledgeBase getDistributeSimplify2KnowledgeBase()
{
if( distributeSimplify2KnowledgeBase == null )
{
OptimizerFactory.setDefaultOptimizer( OptimizerFactory.SAFE_REFLECTIVE );
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// Load in the reng support as a separate cross-cutting concern.
builder.add( ResourceFactory.newClassPathResource( "reng.drl" ) ,
ResourceType.DRL );
builder.add( ResourceFactory.newClassPathResource( "distributeSimplify2.drl" ) ,
ResourceType.DRL );
if( LoggingConfiguration.LOGGING_ON )
{
builder.add( ResourceFactory.newClassPathResource( "logging.drl" ) ,
ResourceType.DRL );
}
if( builder.hasErrors() )
{
throw( new RuntimeException( builder.getErrors().toString() ) );
}
distributeSimplify2KnowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
distributeSimplify2KnowledgeBase.addKnowledgePackages( builder.getKnowledgePackages() );
}
return( distributeSimplify2KnowledgeBase );
}
开发者ID:viridian1138,项目名称:SimpleAlgebra_V2,代码行数:37,代码来源:Elem.java
示例15: runFaultResultProcess
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
private void runFaultResultProcess(final boolean bomb) throws Exception {
serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler() {
public void handleMessage(Exchange exchange) throws HandlerException {
if (bomb) {
throw new HandlerException("BOOM!");
}
}
});
serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(FAULT_RESULT_PROCESS_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultResultProcess");
HandlerException he = (HandlerException)wpi.getVariable("faultResult");
if (bomb) {
Assert.assertNotNull(he);
Assert.assertEquals("BOOM!", he.getMessage());
} else {
Assert.assertNull(he);
}
ksession.halt();
ksession.dispose();
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:29,代码来源:BPMServiceTests.java
示例16: runFaultEventProcess
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
private void runFaultEventProcess(final boolean bomb) throws Exception {
serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler() {
public void handleMessage(Exchange exchange) throws HandlerException {
if (bomb) {
throw new HandlerException("BOOM!");
}
}
});
serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(FAULT_EVENT_PROCESS_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultEventProcess");
HandlerException he = (HandlerException)wpi.getVariable("faultEvent");
if (bomb) {
Assert.assertNotNull(he);
Assert.assertEquals("BOOM!", he.getMessage());
} else {
Assert.assertNull(he);
}
ksession.halt();
ksession.dispose();
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:29,代码来源:BPMServiceTests.java
示例17: ResourceBuilder
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
/** Creates a new ResourceBuilder.
*
* @param classLoader classLoader
* @param resourceModel resourceModel */
public ResourceBuilder(ClassLoader classLoader, ResourceModel resourceModel) {
super(classLoader);
_kieResources = KieServices.Factory.get().getResources();
if (resourceModel != null) {
_url = resourceModel.getLocationURL(getClassLoader());
_resourceType = convertResourceType(resourceModel.getType());
ResourceDetail syResourceDetail = resourceModel.getDetail();
if (syResourceDetail != null) {
if (ResourceType.DTABLE.equals(_resourceType)) {
String inputType;
if (syResourceDetail.getInputType().toLowerCase().endsWith("csv")) {
inputType = getInputType(syResourceDetail, DecisionTableInputType.CSV.toString());
} else {
inputType = getInputType(syResourceDetail, DecisionTableInputType.XLS.toString());
}
DecisionTableConfiguration dtc = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtc.setInputType(DecisionTableInputType.valueOf(inputType));
dtc.setWorksheetName(getWorksheetName(syResourceDetail));
// dtc.setUsingExternalTypes(syResourceDetail.isUsingExternalTypes());
_resourceConfiguration = dtc;
}
/*
* SWITCHYARD-1662
* else if (ResourceType.SCARD.equals(_resourceType)) {
* String inputType = getInputType(syResourceDetail, ScoreCardConfiguration.SCORECARD_INPUT_TYPE.EXCEL.name());
* if ("XLS".equals(inputType)) {
* inputType = ScoreCardConfiguration.SCORECARD_INPUT_TYPE.EXCEL.name();
* }
* ScoreCardConfiguration scc = KnowledgeBuilderFactory.newScoreCardConfiguration();
* scc.setInputType(ScoreCardConfiguration.SCORECARD_INPUT_TYPE.valueOf(inputType));
* scc.setWorksheetName(getWorksheetName(syResourceDetail));
* //scc.setUsingExternalTypes(syResourceDetail.isUsingExternalTypes());
* _resourceConfiguration = scc;
* }
*/
}
}
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:44,代码来源:ResourceBuilder.java
示例18: registerKnowledgeRuntime
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
@Override
protected KieSession registerKnowledgeRuntime(String identifier, String rule) {
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
KieResources kieResources = ks.getResources();
Options xjcOpts = new Options();
xjcOpts.setSchemaLanguage(Language.XMLSCHEMA);
JaxbConfiguration jaxbConfiguration = KnowledgeBuilderFactory.newJaxbConfiguration(xjcOpts, "xsd");
kfs.write(kieResources.newClassPathResource("person.xsd", getClass()).setResourceType(ResourceType.XSD).setConfiguration(jaxbConfiguration));
if (rule != null && rule.length() > 0) {
kfs.write("src/main/resources/rule.drl", rule);
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
List<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);
if (!errors.isEmpty()) {
fail("" + errors);
}
KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
classLoader = ((KnowledgeBaseImpl)ksession.getKieBase()).getRootClassLoader();
try {
jndiContext.bind(identifier, ksession);
} catch (NamingException e) {
throw new RuntimeException(e);
}
return ksession;
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:36,代码来源:CamelEndpointWithJaxbXSDModelTest.java
示例19: registerKnowledgeRuntime
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
@Override
protected KieSession registerKnowledgeRuntime(String identifier, String rule) {
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
KieResources kieResources = ks.getResources();
Options xjcOpts = new Options();
xjcOpts.setSchemaLanguage(Language.XMLSCHEMA);
JaxbConfiguration jaxbConfiguration = KnowledgeBuilderFactory.newJaxbConfiguration(xjcOpts, "xsd");
kfs.write(kieResources.newClassPathResource("person.xsd", getClass()).setResourceType(ResourceType.XSD).setConfiguration(jaxbConfiguration));
if (rule != null && rule.length() > 0) {
kfs.write("src/main/resources/rule.drl", rule);
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
List<Message> errors = kieBuilder.getResults().getMessages(Message.Level.ERROR);
if (!errors.isEmpty()) {
fail("" + errors);
}
KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
try {
jndiContext.bind(identifier, ksession);
} catch (NamingException e) {
throw new RuntimeException(e);
}
return ksession;
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:35,代码来源:CamelEndpointWithJaxWrapperCollectionTest.java
示例20: main
import org.kie.internal.builder.KnowledgeBuilderFactory; //导入依赖的package包/类
public static void main(String[] args) {
//rule,rule2可以放在数据库中,有个唯一code和他们对于,代码要执行规则的时候,根据code从数据库获取出来就OK了,这样自己开发的规则管理系统那边对数据库里的规则进行维护就行了
String rule = "package com.neo.drools\r\n";
rule += "import com.neo.drools.model.Message;\r\n";
rule += "rule \"rule1\"\r\n";
rule += "\twhen\r\n";
rule += "Message( status == 1, myMessage : msg )";
rule += "\tthen\r\n";
rule += "\t\tSystem.out.println( 1+\":\"+myMessage );\r\n";
rule += "end\r\n";
String rule2 = "package com.neo.drools\r\n";
rule += "import com.neo.drools.model.Message;\r\n";
rule += "rule \"rule2\"\r\n";
rule += "\twhen\r\n";
rule += "Message( status == 2, myMessage : msg )";
rule += "\tthen\r\n";
rule += "\t\tSystem.out.println( 2+\":\"+myMessage );\r\n";
rule += "end\r\n";
StatefulKnowledgeSession kSession = null;
try {
KnowledgeBuilder kb = KnowledgeBuilderFactory.newKnowledgeBuilder();
//装入规则,可以装入多个
kb.add(ResourceFactory.newByteArrayResource(rule.getBytes("utf-8")), ResourceType.DRL);
kb.add(ResourceFactory.newByteArrayResource(rule2.getBytes("utf-8")), ResourceType.DRL);
KnowledgeBuilderErrors errors = kb.getErrors();
for (KnowledgeBuilderError error : errors) {
System.out.println(error);
}
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addKnowledgePackages(kb.getKnowledgePackages());
kSession = kBase.newStatefulKnowledgeSession();
Message message1 = new Message();
message1.setStatus(1);
message1.setMsg("hello world!");
Message message2 = new Message();
message2.setStatus(2);
message2.setMsg("hi world!");
kSession.insert(message1);
kSession.insert(message2);
kSession.fireAllRules();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} finally {
if (kSession != null)
kSession.dispose();
}
}
开发者ID:ityouknow,项目名称:drools-examples,代码行数:63,代码来源:DdLoadTest.java
注:本文中的org.kie.internal.builder.KnowledgeBuilderFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论