本文整理汇总了Java中org.kie.api.command.Command类的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于org.kie.api.command包,在下文中一共展示了Command类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processRules
import org.kie.api.command.Command; //导入依赖的package包/类
public Measure processRules(@Body Measure measure) {
KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(
kieHost, kieUser,
kiePassword);
Set<Class<?>> jaxBClasses = new HashSet<Class<?>>();
jaxBClasses.add(Measure.class);
config.addJaxbClasses(jaxBClasses);
config.setMarshallingFormat(MarshallingFormat.JAXB);
RuleServicesClient client = KieServicesFactory.newKieServicesClient(config)
.getServicesClient(RuleServicesClient.class);
List<Command<?>> cmds = new ArrayList<Command<?>>();
KieCommands commands = KieServices.Factory.get().getCommands();
cmds.add(commands.newInsert(measure));
GetObjectsCommand getObjectsCommand = new GetObjectsCommand();
getObjectsCommand.setOutIdentifier("objects");
cmds.add(commands.newFireAllRules());
cmds.add(getObjectsCommand);
BatchExecutionCommand myCommands = CommandFactory.newBatchExecution(cmds,
"DecisionTableKS");
ServiceResponse<ExecutionResults> response = client.executeCommandsWithResults("iot-ocp-businessrules-service", myCommands);
List responseList = (List) response.getResult().getValue("objects");
Measure responseMeasure = (Measure) responseList.get(0);
return responseMeasure;
}
开发者ID:sabre1041,项目名称:iot-ocp,代码行数:36,代码来源:BusinessRulesBean.java
示例2: doTest
import org.kie.api.command.Command; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void doTest() throws Exception {
ClaimTaskCommand claimTaskCmd = new ClaimTaskCommand();
claimTaskCmd.setTaskId(TASK_ID);
claimTaskCmd.setUserId(USER);
StartTaskCommand startTaskCmd = new StartTaskCommand();
startTaskCmd.setTaskId(TASK_ID);
startTaskCmd.setUserId(USER);
CompleteTaskCommand completeTaskCommand = new CompleteTaskCommand();
completeTaskCommand.setTaskId(TASK_ID);
completeTaskCommand.setUserId(USER);
List<Command> cmds = new ArrayList<>();
cmds.add(claimTaskCmd);
cmds.add(startTaskCmd);
cmds.add(completeTaskCommand);
executeCommand(cmds);
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:19,代码来源:TaskCommandOperationsTest.java
示例3: executeCommand
import org.kie.api.command.Command; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private List<JaxbCommandResponse<?>> executeCommand(List<Command> commands)
throws Exception {
URL address = new URL(APP_URL + "/rest/execute");
ClientRequest request = createRequest(address);
// NEEDED ON 6.1
request.header(JaxbSerializationProvider.EXECUTE_DEPLOYMENT_ID_HEADER,
DEPLOYMENT_ID);
JaxbCommandsRequest commandMessage = new JaxbCommandsRequest();
commandMessage.setCommands(commands);
commandMessage.setDeploymentId(DEPLOYMENT_ID);
String body = convertJaxbObjectToString(commandMessage);
System.out.println(body);
request.body(MediaType.APPLICATION_XML, body);
ClientResponse<String> responseObj = request.post(String.class);
String strResponse = responseObj.getEntity();
System.out.println("RESPONSE FROM THE SERVER: \n" + strResponse);
JaxbCommandsResponse cmdsResp = convertStringToJaxbObject(strResponse);
return cmdsResp.getResponses();
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:21,代码来源:TaskCommandOperationsTest.java
示例4: main
import org.kie.api.command.Command; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Our list of commands to be executed;
List<Command> commands = new ArrayList<>();
/*
Create the signal event command and set the object
SignalEventCommand command = new SignalEventCommand();
command.setEventType("TEST");
command.setEvent(new Person("William", 27));
command.setProcessInstanceId(PROCESS_INSTANCE_ID);
commands.add(command);
*/
List<JaxbCommandResponse<?>> response = executeCommand(DEPLOYMENT_ID,
commands);
System.out.printf("Command %s executed.\n", response.toString());
System.out.println("commands1" + commands);
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:17,代码来源:SignalProcessWithPOJO.java
示例5: executeCommand
import org.kie.api.command.Command; //导入依赖的package包/类
static List<JaxbCommandResponse<?>> executeCommand(String deploymentId,
List<Command> commands) throws Exception {
URL address = new URL(APP_URL + "/execute");
ClientRequest request = createRequest(address);
// NEEDED ON 6.1
request.header(JaxbSerializationProvider.EXECUTE_DEPLOYMENT_ID_HEADER, DEPLOYMENT_ID);
JaxbCommandsRequest commandMessage = new JaxbCommandsRequest();
commandMessage.setCommands(commands);
commandMessage.setDeploymentId(DEPLOYMENT_ID);
String body = convertJaxbObjectToString(commandMessage);
request.body(MediaType.APPLICATION_XML, body);
ClientResponse<String> responseObj = request.post(String.class);
String strResponse = responseObj.getEntity();
System.out.println("RESPONSE FROM THE SERVER: \n" + strResponse);
JaxbCommandsResponse cmdsResp = convertStringToJaxbObject(strResponse);
return cmdsResp.getResponses();
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:18,代码来源:SignalProcessWithPOJO.java
示例6: executeCommand
import org.kie.api.command.Command; //导入依赖的package包/类
static List<JaxbCommandResponse<?>> executeCommand(String deploymentId,
List<Command> commands) throws Exception {
URL address = new URL(APP_URL + "/rest/execute");
ClientRequest request = createRequest(address);
// NEEDED ON 6.1
request.header(JaxbSerializationProvider.EXECUTE_DEPLOYMENT_ID_HEADER, DEPLOYMENT_ID);
JaxbCommandsRequest commandMessage = new JaxbCommandsRequest();
commandMessage.setCommands(commands);
commandMessage.setDeploymentId(DEPLOYMENT_ID);
String body = convertJaxbObjectToString(commandMessage);
request.body(MediaType.APPLICATION_XML, body);
ClientResponse<String> responseObj = request.post(String.class);
String strResponse = responseObj.getEntity();
System.out.println("RESPONSE FROM THE SERVER: \n" + strResponse);
JaxbCommandsResponse cmdsResp = convertStringToJaxbObject(strResponse);
return cmdsResp.getResponses();
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:18,代码来源:UpdateVariableUsingExecuteTest.java
示例7: main
import org.kie.api.command.Command; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Our list of commands to be executed;
List<Command> commands = new ArrayList<>();
// a sample command to start a process
StartProcessCommand startProcessCommand = new StartProcessCommand();
JaxbStringObjectPairArray params = new JaxbStringObjectPairArray();
// Add your process parameters here
//params.getItems().add(new JaxbStringObjectPair(PROCESS_PARAM_NAME, new MyPOJO("My POJO TESTING")));
startProcessCommand.setProcessId(PROCESS_ID);
startProcessCommand.setParameter(params);
commands.add(startProcessCommand);
List<JaxbCommandResponse<?>> response = executeCommand(DEPLOYMENT_ID,
commands);
System.out.printf("Command %s executed.\n", response.toString());
System.out.println("commands1" + commands);
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:17,代码来源:StartProcessWithPOJO.java
示例8: main
import org.kie.api.command.Command; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Our list of commands to be executed;
List<Command> commands = new ArrayList<>();
// a sample command to start a process
StartProcessCommand startProcessCommand = new StartProcessCommand();
JaxbStringObjectPairArray params = new JaxbStringObjectPairArray();
// Add your process parameters here
// params.getItems().add(new JaxbStringObjectPair("p_person", new Person("William", 27)));
startProcessCommand.setProcessId(PROCESS_ID);
startProcessCommand.setParameter(params);
commands.add(startProcessCommand);
List<JaxbCommandResponse<?>> response = executeCommand(DEPLOYMENT_ID,
commands);
System.out.printf("Command %s executed.\n", response.toString());
System.out.println("commands1" + commands);
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:17,代码来源:StartProcessWithPOJO.java
示例9: main
import org.kie.api.command.Command; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Our list of commands to be executed;
List<Command> commands = new ArrayList<>();
// a sample command to start a process
StartProcessCommand startProcessCommand = new StartProcessCommand();
JaxbStringObjectPairArray params = new JaxbStringObjectPairArray();
// Add your process parameters here
Product prod = new Product(10, "Bread", 10f);
params.getItems().add(new JaxbStringObjectPair(PROCESS_PARAM_NAME, prod));
startProcessCommand.setProcessId(PROCESS_ID);
startProcessCommand.setParameter(params);
commands.add(startProcessCommand);
List<JaxbCommandResponse<?>> response = executeCommand(DEPLOYMENT_ID,
commands);
System.out.printf("Command %s executed.\n", response.toString());
System.out.println("commands1" + commands);
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:18,代码来源:StartProcessWithPOJO.java
示例10: executeCommands
import org.kie.api.command.Command; //导入依赖的package包/类
@Test
public void executeCommands() {
System.out.println("== Sending commands to the server ==");
RuleServicesClient rulesClient = kieServicesClient
.getServicesClient(RuleServicesClient.class);
KieCommands commandsFactory = KieServices.Factory.get().getCommands();
Command<?> insert = commandsFactory.newInsert("Some String OBJ");
Command<?> fireAllRules = commandsFactory.newFireAllRules();
Command<?> batchCommand = commandsFactory.newBatchExecution(Arrays
.asList(insert, fireAllRules));
ServiceResponse<ExecutionResults> executeResponse = rulesClient
.executeCommandsWithResults(RULES_CONTAINER, batchCommand);
if (executeResponse.getType() == ResponseType.SUCCESS) {
System.out.println("Commands executed with success! Response: ");
System.out.println(executeResponse.getResult());
} else {
System.out.println("Error executing rules. Message: ");
System.out.println(executeResponse.getMsg());
}
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:21,代码来源:DecisionServerJMSTest.java
示例11: executeCommands
import org.kie.api.command.Command; //导入依赖的package包/类
@Test
public void executeCommands() {
System.out.println("== Sending commands to the server ==");
RuleServicesClient rulesClient = kieServicesClient
.getServicesClient(RuleServicesClient.class);
KieCommands commandsFactory = KieServices.Factory.get().getCommands();
Command<?> insert = commandsFactory.newInsert("Some String OBJ");
Command<?> fireAllRules = commandsFactory.newFireAllRules();
Command<?> batchCommand = commandsFactory.newBatchExecution(Arrays
.asList(insert, fireAllRules));
ServiceResponse<ExecutionResults> executeResponse = rulesClient.executeCommandsWithResults(RULES_CONTAINER, batchCommand);
if (executeResponse.getType() == ResponseType.SUCCESS) {
System.out.println("Commands executed with success! Response: ");
System.out.println(executeResponse.getResult());
} else {
System.out.println("Error executing rules. Message: ");
System.out.println(executeResponse.getMsg());
}
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:20,代码来源:DecisionServerTest.java
示例12: start
import org.kie.api.command.Command; //导入依赖的package包/类
/**
*
*/
public void start() throws Exception {
for (int i = 0; i < 10; i++) {
Customer customer = customer();
logger.info("------------------- START ------------------\n"
+ " KieSession fireAllRules. {}", customer);
List<Command<?>> commands = new ArrayList<Command<?>>();
commands.add(CommandFactory.newInsert(customer, "customer"));
commands.add(CommandFactory.newFireAllRules("num-rules-fired"));
ExecutionResults results = ksession.execute(CommandFactory
.newBatchExecution(commands));
int fired = Integer.parseInt(results.getValue("num-rules-fired")
.toString());
customer = (Customer)results.getValue("customer");
logger.info("After rule rules-fired={} {} \n"
+ "------------------- STOP ---------------------", fired,
customer);
}
}
开发者ID:apache,项目名称:servicemix,代码行数:29,代码来源:SimpleRuleBean.java
示例13: testExecutionResults
import org.kie.api.command.Command; //导入依赖的package包/类
@Test
public void testExecutionResults() throws JAXBException {
JAXBContext jaxbContext = getJaxbContext();
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
List<Command> commands = new ArrayList<Command>();
commands.add(CommandFactory.newInsert(new Person("darth", 105), "p"));
commands.add(CommandFactory.newFireAllRules());
ExecutionResults res1 = ksession.execute(CommandFactory.newBatchExecution(commands));
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
marshaller.marshal(res1, baos);
// note it's using xsi:type
logger.debug(new String(baos.toByteArray()));
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
ExecutionResults res2 = (ExecutionResults)unmarshaller.unmarshal(new StringReader(baos.toString()));
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:25,代码来源:JaxbTest.java
示例14: createRandomCommand
import org.kie.api.command.Command; //导入依赖的package包/类
public BatchExecutionCommand createRandomCommand() {
Person person = new Person();
String name = NAMES[random.nextInt(NAMES.length)];
person.setName(name);
List<Command<?>> cmds = new ArrayList<Command<?>>();
KieCommands commands = KieServices.Factory.get().getCommands();
cmds.add(commands.newInsert(person));
cmds.add(commands.newFireAllRules());
cmds.add(commands.newQuery("greetings", "get greeting"));
BatchExecutionCommand command = commands.newBatchExecution(cmds, "HelloRulesSession");
return command;
}
开发者ID:fabric8-quickstarts,项目名称:spring-boot-camel-drools,代码行数:14,代码来源:DecisionServerHelper.java
示例15: execute
import org.kie.api.command.Command; //导入依赖的package包/类
public Object execute(Command command, String containerId) {
BatchExecutionHelperProviderImpl batchExecutionHelperProviderImpl = new BatchExecutionHelperProviderImpl();
XStream xstream = batchExecutionHelperProviderImpl
.newXStreamMarshaller();
String payload = xstream.toXML(command);
LOG.debug("payload=" + payload);
ServiceResponse<String> serviceResponse = kieServicesClient
.executeCommands(containerId, payload);
if (serviceResponse.getType().equals(ResponseType.FAILURE)) {
throw new RuntimeException(serviceResponse.getMsg());
}
String response = serviceResponse.getResult();
LOG.debug("response=" + response);
return xstream.fromXML(response);
}
开发者ID:anurag-saran,项目名称:drools-usage-patterns,代码行数:16,代码来源:RemoteCommandExecutor.java
示例16: executeCommands
import org.kie.api.command.Command; //导入依赖的package包/类
@Test
public void executeCommands() {
System.out.println("== Sending commands to the server ==");
RuleServicesClient rulesClient = kieServicesClient
.getServicesClient(RuleServicesClient.class);
KieCommands commandsFactory = KieServices.Factory.get().getCommands();
Command<?> insert = commandsFactory.newInsert("Some String OBJ");
Command<?> fireAllRules = commandsFactory.newFireAllRules();
Command<?> batchCommand = commandsFactory.newBatchExecution(Arrays
.asList(insert, fireAllRules));
ServiceResponse<String> executeResponse = rulesClient.executeCommands(RULES_CONTAINER, batchCommand);
if (executeResponse.getType() == ResponseType.SUCCESS) {
System.out.println("Commands executed with success! Response: ");
System.out.println(executeResponse.getResult());
} else {
System.out.println("Error executing rules. Message: ");
System.out.println(executeResponse.getMsg());
}
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:20,代码来源:DecisionServerTest.java
示例17: doTest
import org.kie.api.command.Command; //导入依赖的package包/类
@Test
public void doTest() throws Exception {
List<Command> commands = new ArrayList<>();
SetProcessInstanceVariablesCommand updateVarCommand = new SetProcessInstanceVariablesCommand();
JaxbStringObjectPairArray params = new JaxbStringObjectPairArray();
params.getItems().add(new JaxbStringObjectPair(VAR_ID, VAR_VALUE));
updateVarCommand.setProcessInstanceId(INSTANCE_ID);
updateVarCommand.setVariables(params);
commands.add(updateVarCommand);
List<JaxbCommandResponse<?>> response = executeCommand(DEPLOYMENT_ID,
commands);
System.out.printf("Command %s executed.\n", response.toString());
System.out.println("commands1" + commands);
}
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:15,代码来源:UpdateVariableUsingExecuteTest.java
示例18: insertAndFireAll
import org.kie.api.command.Command; //导入依赖的package包/类
public void insertAndFireAll(Exchange exchange) {
final Message in = exchange.getIn();
final Object body = in.getBody();
final List<Command<?>> commands = new ArrayList<Command<?>>(2);
commands.add(CommandFactory.newInsert(body));
commands.add(CommandFactory.newFireAllRules());
Command<?> batch = CommandFactory.newBatchExecution(commands);
in.setBody(batch);
}
开发者ID:apache,项目名称:servicemix,代码行数:12,代码来源:Utils.java
示例19: isWriteable
import org.kie.api.command.Command; //导入依赖的package包/类
/**
* isWriteable
*/
@Override
public boolean isWriteable(Class<?> type, Type genericType,
Annotation[] arg2, MediaType arg3) {
return Command.class.isAssignableFrom(type);
}
开发者ID:apache,项目名称:servicemix,代码行数:10,代码来源:CommandMessageBodyRW.java
示例20: writeTo
import org.kie.api.command.Command; //导入依赖的package包/类
/**
* writeTo
*/
@Override
public void writeTo(Command<?> obj, Class<?> arg1, Type arg2,
Annotation[] arg3, MediaType arg4,
MultivaluedMap<String, Object> arg5, OutputStream out)
throws IOException, WebApplicationException {
provider.newXStreamMarshaller().toXML(obj, out);
}
开发者ID:apache,项目名称:servicemix,代码行数:11,代码来源:CommandMessageBodyRW.java
注:本文中的org.kie.api.command.Command类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论