@DELETE @Path("broker") public void deleteConfiguration() { broker.setConfiguration(new Configuration()); // Broadcast new stream list OutboundEvent.Builder eventBuilder = new OutboundEvent.Builder(); OutboundEvent event = eventBuilder .name("broker") .mediaType(MediaType.APPLICATION_JSON_TYPE) .data(Configuration.class, broker.getConfiguration()) .build(); broadcaster.broadcast(event); }
@DELETE @Path("broker/{routing-id}") public void deleteRouting(@PathParam("routing-id") String name) { broker.removeRouting("^" + name + "$"); // Broadcast new stream list OutboundEvent.Builder eventBuilder = new OutboundEvent.Builder(); OutboundEvent event = eventBuilder .name("broker") .mediaType(MediaType.APPLICATION_JSON_TYPE) .data(Configuration.class, broker.getConfiguration()) .build(); broadcaster.broadcast(event); }
@PUT @Path("broker/{routing-id}") public void addRouting(@PathParam("routing-id") String name, Routing routing) { routing.setName(name); // Ensure that name is the same as the one specified on the URL broker.addRouting(routing); // Broadcast new stream list OutboundEvent.Builder eventBuilder = new OutboundEvent.Builder(); OutboundEvent event = eventBuilder .name("broker") .mediaType(MediaType.APPLICATION_JSON_TYPE) .data(Configuration.class, broker.getConfiguration()) .build(); broadcaster.broadcast(event); }
@PUT @Path("broker") @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public void setConfiguration(Configuration configuration) { broker.setConfiguration(configuration); // Broadcast new stream list OutboundEvent.Builder eventBuilder = new OutboundEvent.Builder(); OutboundEvent event = eventBuilder .name("broker") .mediaType(MediaType.APPLICATION_JSON_TYPE) .data(Configuration.class, broker.getConfiguration()) .build(); broadcaster.broadcast(event); }
@GET @Path("broker/{routing-id}") public Routing getRouting(@PathParam("routing-id") String name) { for (Routing r : broker.getConfiguration().getRouting()) { if (r.getName().equals(name)) { return r; } } return null; }
@GET @Path("broker") @Produces(MediaType.APPLICATION_JSON) public Configuration getConfiguration() { return broker.getConfiguration(); }