public void multipleDifferentRuntimeExamples(String deploymentId, URL deploymentUrl, boolean useFormBasedAuth) throws Exception { RemoteRestRuntimeEngineBuilder runtimeEngineBuilder = RemoteRuntimeEngineFactory.newRestBuilder() .addDeploymentId(deploymentId) .addUrl(deploymentUrl); RuntimeEngine krisRemoteEngine = runtimeEngineBuilder .addUserName(KRIS_USER) .addPassword(KRIS_PASSWORD) .build(); RuntimeEngine maryRemoteEngine = runtimeEngineBuilder .addUserName(MARY_USER) .addPassword(MARY_PASSWORD) .build(); RuntimeEngine johnRemoteEngine = runtimeEngineBuilder .addUserName(JOHN_USER) .addPassword(JOHN_PASSWORD) .build(); }
/** * With the introduction of the fluent/builder API in 6.0.x, we could do this: * * RemoteRestRuntimeEngineFactory factory = * RemoteRestRuntimeEngineFactory.newBuilder() * .addUserName("user") * .addPassword("pass") * .addUrl(new URL("http://localhost:8080/business-central")) * .build(); * * RuntimeEngine runtimeEngine = factory.newRuntimeEngine(); * * With the 6.0.x code, we built a factory, that we then used to create the runtime.. * * Why not just build the runtime immediately? :) */ public void createRestRuntimeEngineWithBuilder() throws MalformedURLException { // unfortunately, this breaks backward compatibility, but the improvement and clarity in the API is worth the risk RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .build(); } }
protected KieSession initKieSession() throws CoreException { RuntimeEngine restSessionFactory; try { restSessionFactory = RemoteRuntimeEngineFactory.newRestBuilder() .addDeploymentId(bpmConfig.getDeploymentId()) .addUrl(new URL(bpmConfig.getBpmInstanceUrl())) .addUserName(bpmConfig.getUsername()) .addPassword(bpmConfig.getPassword()) .addTimeout(AUTHENTICATION_TIMEOUT_S) .build(); } catch (Exception e) { throw new CoreException("Could not initialize connection to BPM server at '" + bpmConfig.getBpmInstanceUrl() + "' check that the URL is correct.", e); } return restSessionFactory.getKieSession(); }
public void minimumRestBuilderExample() throws Exception { RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .build(); runtimeEngine.getTaskService().claim(23l, "user"); // This will throw a MissingRequiredInfoException because the deployment id is required here runtimeEngine.getKieSession().startProcess("org.test.process"); }
@Test public void notAceptedMethodTest() throws Exception { URL deploymentUrl = new URL( "http://localhost:8080/kie-wb/" ); RemoteRestRuntimeEngineFactory restSessionFactory = RemoteRuntimeEngineFactory.newRestBuilder() .addDeploymentId("deployment") .addUrl(deploymentUrl) .addUserName("mary") .addPassword("pass") .buildFactory(); WorkItemHandler wih = new DoNothingWorkItemHandler(); try { restSessionFactory.newRuntimeEngine().getKieSession().getWorkItemManager().registerWorkItemHandler("test", wih); fail( "The above call should have failed."); } catch( UnsupportedOperationException uoe ) { assertTrue("Incorrect error message: " + uoe.getMessage(), uoe.getMessage().contains("not supported on the Remote Client instance.")); } }
.addDeploymentId(deploymentId) .addUrl(deploymentUrl) .addUserName(userId) .addPassword(password) .build();
.addPassword("user").addUserName("pass") .addDeploymentId("deploymentId") .addUrl(new URL("http://localhost:" + port + "/" )) .addPassword("user").addUserName("pass") .addDeploymentId("deploymentId") .addUrl(new URL("http://localhost:" + port + "/" ))
RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName(authUser) .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .addUserName(authUser) .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .addUserName(authUser) .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central"))
.addDeploymentId("deployment") .addProcessInstanceId(23l) .addUserName("S") .addPassword("koek") .addUrl(new URL("http://localhost:8080/kie-wb")) RemoteRestRuntimeEngineFactory.newBuilder() .addDeploymentId("deployment") .addUserName("A") .addUrl(new URL("http://localhost:8080/kie-wb")) .addTimeout(3) RemoteRestRuntimeEngineFactory.newBuilder() .addDeploymentId("deployment") .addUserName("E") .addPassword("suiker") .addTimeout(3) .addUserName("joke") .addPassword("stroop") .addUrl(new URL("http://localhost:8080/kie-wb"))
.addUrl(instanceUrl) .addDeploymentId(deploymentId) .addUserName(user) .addPassword(password) .build();
.addDeploymentId("deployment") .addProcessInstanceId(23l) .addUserName("S") .addPassword("koek") .addUrl(new URL("http://localhost:8080/kie-wb")) RemoteRestRuntimeEngineFactory.newBuilder() .addDeploymentId("deployment") .addUserName("A") .addUrl(new URL("http://localhost:8080/kie-wb")) .addTimeout(3) RemoteRestRuntimeEngineFactory.newBuilder() .addDeploymentId("deployment") .addUserName("E") .addPassword("suiker") .addTimeout(3) .addUserName("joke") .addPassword("stroop") .addUrl(new URL("http://localhost:8080/kie-wb"))
@Test public void setHeaderFields() throws Exception { RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .addHeader("HEADER-NAME", "header-value") .clearHeaderFields() .addCorrelationProperties() .addDeploymentId("dep-id") .build(); try { runtimeEngine.getTaskService().claim(23l, "user"); fail( "This should have failed because there's no server running... "); } catch( org.kie.remote.client.api.exception.RemoteCommunicationException rce ) { // expected } } }
.addDeploymentId(deploymentId) .addUrl(baseUrl) .addUserName(user) .addPassword(password) .build();
RuntimeEngine runtimeEngine = RemoteRestRuntimeEngineFactory.newBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central"))
RemoteRestRuntimeEngineFactory factory = RemoteRestRuntimeEngineFactory.newBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central"))