/** * Constructs a new service statistics instance without statistics. * * @param serviceRegistration * the service registration */ public JaxbServiceStatistics(ServiceRegistration serviceRegistration) { super(); this.serviceRegistration = new JaxbServiceRegistration(serviceRegistration); }
@GET @Path("available.xml") @Produces(MediaType.TEXT_XML) @RestQuery(name = "availableasxml", description = "Lists available services by service type identifier, ordered by load.", returnDescription = "The services list as XML", restParameters = { @RestParameter(name = "serviceType", isRequired = false, type = Type.STRING, description = "The service type identifier") }, reponses = { @RestResponse(responseCode = SC_OK, description = "Returned the available services."), @RestResponse(responseCode = SC_BAD_REQUEST, description = "No service type specified, bad request.") }) public Response getAvailableServicesAsXml(@QueryParam("serviceType") String serviceType) { if (isBlank(serviceType)) throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity("Service type must be specified") .build()); JaxbServiceRegistrationList registrations = new JaxbServiceRegistrationList(); try { for (ServiceRegistration reg : serviceRegistry.getServiceRegistrationsByLoad(serviceType)) { registrations.add(new JaxbServiceRegistration(reg)); } return Response.ok(registrations).build(); } catch (ServiceRegistryException e) { throw new WebApplicationException(e); } }
@POST @Path("register") @Produces(MediaType.TEXT_XML) @RestQuery(name = "register", description = "Add a new service registration to the cluster.", returnDescription = "The service registration.", restParameters = { @RestParameter(name = "serviceType", isRequired = true, description = "The service type identifier", type = Type.STRING, defaultValue = ""), @RestParameter(name = "host", isRequired = true, description = "The host providing the service, including the http(s) protocol", type = Type.STRING, defaultValue = ""), @RestParameter(name = "path", isRequired = true, description = "The service path on the host", type = Type.STRING, defaultValue = ""), @RestParameter(name = "jobProducer", isRequired = true, description = "Whether this service is a producer of long running jobs requiring dispatch", type = Type.STRING, defaultValue = "false") }, reponses = { @RestResponse(responseCode = SC_OK, description = "An XML representation of the new service registration") }) public JaxbServiceRegistration register(@FormParam("serviceType") String serviceType, @FormParam("host") String host, @FormParam("path") String path, @FormParam("jobProducer") boolean jobProducer) { try { return new JaxbServiceRegistration(serviceRegistry.registerService(serviceType, host, path, jobProducer)); } catch (ServiceRegistryException e) { throw new WebApplicationException(e); } }
throw new NotFoundException(); } else { return new JaxbServiceRegistrationList(new JaxbServiceRegistration(reg)); registrations.add(new JaxbServiceRegistration(reg)); registrations.add(new JaxbServiceRegistration(reg)); registrations.add(new JaxbServiceRegistration(reg));