package algoLike.push; import java.util.*; import javax.ws.rs.*; import javax.ws.rs.client.*; import javax.ws.rs.core.*; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.core.JsonProcessingException; import org.springframework.stereotype.Repository; import pushPullRefactor.Getter; import pushPullRefactor.Message; import pushPullRefactor.Resource; import pushPullRefactor.State; @Path("/resultBySelectingB") @Component @Resource("resultBySelecting") public class ResultBySelectingB { private Client client = ClientBuilder.newClient(); @State private Map.Entry<Boolean, Map.Entry<Integer, Integer>> value; @PUT @Message({}) public void selectAndAttackB(@FormParam("t") int t, @FormParam("g") int g, @FormParam("a") List<Map.Entry<Integer, Boolean>> a, @FormParam("atk") int atk) throws JsonProcessingException { this.value = new AbstractMap.SimpleEntry<>((a.get(t).getKey()==g), new AbstractMap.SimpleEntry<>(t, atk) ); Form form = new Form(); form.param("resultBySelectingB", new ObjectMapper().writeValueAsString(this.value)); Entity<Form> entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); String result = client.target("http://localhost:8080").path("/handsB/resultBySelectingB").request().post(entity, String.class); form = new Form(); form.param("resultBySelectingB", new ObjectMapper().writeValueAsString(this.value)); entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED); result = client.target("http://localhost:8080").path("/handsA/resultBySelectingB").request().post(entity, String.class); } @Produces(MediaType.APPLICATION_JSON) @GET @Getter public Map.Entry<Boolean, Map.Entry<Integer, Integer>> getValue() { return value; } }