/** * Retrieves the (remote) {@link InitialContext} from the JBoss AS server instance in order * to be able to retrieve the {@link ConnectionFactory} and {@link Queue} instances to communicate * with the workbench, console or BPMS instance. * </p> * This method is deprecated in favor of the {@link RemoteRuntimeEngineFactory#getRemoteJbossInitialContext(String, String, String)} * instance, which takes a {@link String} hostname parameter instead of a {@link URL} parameter. * * @param url The URL of the server instance * @param user A user permitted to retrieve the remote {@link InitialContext} * @param password The password for the user specified * @return an {@link InitialContext} that contains the {@link ConnectionFactory} and {@link Queue} instances to communicate * with the workbench, console or BPMS instance. */ @Deprecated public static InitialContext getRemoteJbossInitialContext(URL url, String user, String password) { return org.kie.remote.client.api.RemoteRuntimeEngineFactory.getRemoteJbossInitialContext(url.getHost(), user, password); }
private CommandWebService createClient(String user, String password) throws Exception { return RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder() .addUserName(user).addPassword(password) .addServerUrl("http://localhost:" + port + "/") .setWsdlLocationRelativePath(DEFAULT_ENDPOINT) .buildBasicAuthClient(); }
/** * 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(); } }
public void startProcessAndTaskViaJmsRemoteJavaAPI(URL serverUrl, String deploymentId, String user, String password) { // the serverURL should contain a URL similar to "http://localhost:8080/jbpm-console" // Setup remote JMS runtime engine factory RuntimeEngine engine = RemoteRuntimeEngineFactory.newJmsBuilder() .addDeploymentId(deploymentId) .addJbossServerHostName(serverUrl.getHost()) .addUserName(user) .addPassword(password) .build(); // Interface with JMS api KieSession ksession = engine.getKieSession(); Map<String, Object> params = new HashMap<String, Object>(); params.put("paramName", new MyType("name", 23)); ProcessInstance processInstance = ksession.startProcess("com.burns.reactor.maintenance.cycle", params); long procId = processInstance.getId(); TaskService taskService = engine.getTaskService(); List<Long> tasks = taskService.getTasksByProcessInstanceId(procId); taskService.start(tasks.get(0), user); }
/** * In the 6.0.x code, we did this: * * // Setup remote JMS runtime engine factory * RemoteJmsRuntimeEngineFactory remoteJmsFactory * = new RemoteJmsRuntimeEngineFactory(deploymentId, serverUrl, user, password); * * // Create runtime engine * RuntimeEngine engine = remoteJmsFactory.newRuntimeEngine(); */ public void createJmsRuntimeEngine(String deploymentId, URL serverUrl, String user, String password) { // Now we just do this: RuntimeEngine engine = RemoteRuntimeEngineFactory.newJmsBuilder() .addDeploymentId(deploymentId) .addJbossServerHostName(serverUrl.getHost()) .addUserName(user) .addPassword(password) .build(); // If you still want to use the factory to create multiple instances, you can always still do this: RemoteJmsRuntimeEngineFactory jmsRuntimeFactory = RemoteRuntimeEngineFactory.newJmsBuilder() .addDeploymentId(deploymentId) .addJbossServerHostName(serverUrl.getHost()) .addUserName(user) .addPassword(password) .buildFactory(); engine = jmsRuntimeFactory.newRuntimeEngine(); }
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 jmsRuntimeEngineNoSslTest() { // disableTaskSecurity RemoteRuntimeEngineFactory.newJmsBuilder() .addUserName("H") .addPassword("gummy bears") .addHostName("localhost") .addJmsConnectorPort(5446) .addRemoteInitialContext(remoteInitialContext) .disableTaskSecurity() .build(); }
@Test public void commandWebServiceClientInterfaceInheritanceTest() { try { RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder() .addPassword("test") .addUserName("tester") .addServerUrl("http://test.server.com/test-app/") .addServerUrl(new URL("http://test.server.com/test-app/")) .setWsdlLocationRelativePath("random/path/to/CommandWebservice.wsdl") .addPassword("test") .addUserName("tester") .addServerUrl("http://test.server.com/test-app/") .addServerUrl(new URL("http://test.server.com/test-app/")) .setWsdlLocationRelativePath("random/path/to/CommandWebservice.wsdl") .useHttpRedirect() .addPassword("test") .addUserName("tester") .addServerUrl("http://test.server.com/test-app/") .addServerUrl(new URL("http://test.server.com/test-app/")) .buildBasicAuthClient(); } catch( Exception e ) { logger.info("The " + ConnectException.class.getSimpleName() + " above is expected, nothing is wrong."); // the above just needs to compile.. } }
@Test public void testSetHeader() throws Exception { RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addPassword("user").addUserName("pass") .addDeploymentId("deploymentId") runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addPassword("user").addUserName("pass") .addDeploymentId("deploymentId")
RemoteRuntimeEngineFactory.newJmsBuilder() .addDeploymentId("deployment") .addProcessInstanceId(46l) jmsRuntimeFactory = RemoteRuntimeEngineFactory.newJmsBuilder() .addRemoteInitialContext(remoteInitialContext) .addUserName("E*") jmsRuntimeFactory = RemoteRuntimeEngineFactory.newJmsBuilder() .addRemoteInitialContext(remoteInitialContext) .addPassword("koffie") jmsRuntimeFactory = RemoteRuntimeEngineFactory.newJmsBuilder() .addRemoteInitialContext(remoteInitialContext) .addUserName("E*") jmsRuntimeFactory = RemoteRuntimeEngineFactory.newJmsBuilder() .addUserName("E*") .addPassword("koffie") jmsRuntimeFactory = RemoteRuntimeEngineFactory.newJmsBuilder() .addUserName("M") .addPassword("koekje") jmsRuntimeFactory = RemoteRuntimeEngineFactory.newJmsBuilder() .addUserName("1") .addPassword("ijs") jmsRuntimeFactory = RemoteRuntimeEngineFactory.newJmsBuilder()
RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder() .addPassword("user").addUserName("pass") .addServerUrl("http://localhost:" + port + "/") RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder() .addPassword("user").addUserName("pass") .addServerUrl("http://localhost:" + port + "/") RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder() .addPassword("user").addUserName("pass") .addServerUrl("http://localhost:" + port + "/") RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder() .addPassword("user").addUserName("pass") .addServerUrl("http://localhost:" + port + "/") RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder() .addPassword("user").addUserName("pass") .addServerUrl("http://localhost:" + port + "/") RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder() .addPassword("user").addUserName("pass") .addServerUrl("http://localhost:" + port + "/") RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder() .addPassword("user").addUserName("pass") .addServerUrl("http://localhost:" + port + "/") RemoteRuntimeEngineFactory.newCommandWebServiceClientBuilder()
String authUser = "user"; RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName(authUser) .addPassword("pass") runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName(authUser) .addPassword("pass") runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName(authUser) .addPassword("pass")
RemoteJmsRuntimeEngineBuilder builder = RemoteRuntimeEngineFactory.newJmsBuilder() .addUserName("H") .addPassword("gummy bears") RemoteRuntimeEngineFactory.newJmsBuilder() .addUserName("H") .addPassword("gummy bears") RemoteRuntimeEngineFactory.newJmsBuilder() .addUserName("H") .addPassword("gummy bears") RemoteRuntimeEngineFactory.newJmsBuilder() .addUserName("H") .addPassword("gummy bears") RemoteRuntimeEngineFactory.newJmsBuilder() .useSsl(true) .buildFactory(); RemoteRuntimeEngineFactory.newJmsBuilder() .useSsl(true) .addUserName("H") RemoteRuntimeEngineFactory.newJmsBuilder() .addUserName("H") .addPassword("gummy bears") RemoteRuntimeEngineFactory.newJmsBuilder()
RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder() .addUrl(instanceUrl) .addDeploymentId(deploymentId)
RemoteRuntimeEngineFactory.newJmsBuilder() .addUserName("user") .addPassword("pass")
@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 } } }
@Test public void jmsRuntimeFactoryBuilderReuseTest() throws Exception { RemoteJmsRuntimeEngineBuilder runtimeEngineBuilder = RemoteRuntimeEngineFactory.newJmsBuilder() .addDeploymentId("deploymentId") .useSsl(true)
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(); }
public void javaRemoteApiRestExample(String deploymentId, URL baseUrl, String user, String password) { RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder() .addDeploymentId(deploymentId) .addUrl(baseUrl)