package org.fxapps.bpms.decisionserver;

import java.util.List;

import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import org.kie.server.api.marshalling.MarshallingFormat;
import org.kie.server.api.model.KieContainerResource;
import org.kie.server.client.KieServicesClient;
import org.kie.server.client.KieServicesConfiguration;
import org.kie.server.client.KieServicesFactory;


@Stateless
@Path("list-containers-resource")
public class ListContainersResource {

	private static final String USER = "kieserver";

	private static final String PSW = "kieserver1!";

	@Resource(mappedName = "java:/JmsXA")
	private ConnectionFactory connectionFactory;

	@Resource(mappedName = "java:/queue/KIE.SERVER.REQUEST")
	private Queue reqQueue;
	
	@Resource(mappedName = "java:/queue/KIE.SERVER.RESPONSE")
	private Queue respQueue;
	
	
	@POST
	@Produces("application/json")
	public List<KieContainerResource> execute(){
		KieServicesConfiguration conf = KieServicesFactory.newJMSConfiguration(connectionFactory, reqQueue, respQueue, USER, PSW);
		conf.setMarshallingFormat(MarshallingFormat.JSON);
		KieServicesClient client = KieServicesFactory.newKieServicesClient(conf);
		return client.listContainers().getResult().getContainers();
	}

}
@@ -609,16 +609,109 @@
 urce %7B%0A%0A
+%09private static final String URL = %22http://localhost:8080/kie-server/services/rest/server%22;%0A%0A
 %09private
@@ -743,32 +743,32 @@
  = %22kieserver%22;%0A
-
 %0A%09private static
@@ -803,16 +803,19 @@
 er1!%22;%0A%0A
+%0A%09%0A
 %09@Resour
@@ -1073,16 +1073,30 @@
 %0A%09@POST%0A
+%09@Path(%22jms%22)%0A
 %09@Produc
@@ -1160,16 +1160,24 @@
  execute
+UsingJMS
 ()%7B%0A%09%09Ki
@@ -1490,11 +1490,406 @@
 rs();%0A%09%7D
+%0A%09%0A%09@POST%0A%09@Path(%22rest%22)%0A%09@Produces(%22application/json%22)%0A%09public List%3CKieContainerResource%3E executeUsingREST()%7B%0A%09%09KieServicesConfiguration conf = KieServicesFactory.newRestConfiguration(URL, USER, PSW);%0A%09%09conf.setMarshallingFormat(MarshallingFormat.JSON);%0A%09%09KieServicesClient client = KieServicesFactory.newKieServicesClient(conf);%0A%09%09return client.listContainers().getResult().getContainers();%0A%09%7D
 %0A%0A%7D

Add REST Client for kie server running on BPM Suite (this works)