@Produces({"application/vnd.sun.wadl+xml", "application/xml"}) @GET public synchronized Response getWadl(@Context UriInfo uriInfo) { try { if (!wadlContext.isWadlGenerationEnabled()) { return Response.status(Response.Status.NOT_FOUND).build(); } final boolean detailedWadl = WadlUtils.isDetailedWadlRequested(uriInfo); if ((wadlXmlRepresentation == null) || (!isCached(uriInfo, detailedWadl))) { this.lastBaseUri = uriInfo.getBaseUri(); lastDetailedWadl = detailedWadl; this.lastModified = new SimpleDateFormat(HTTPDATEFORMAT).format(new Date()); ApplicationDescription applicationDescription = wadlContext.getApplication(uriInfo, detailedWadl); Application application = applicationDescription.getApplication(); try { final Marshaller marshaller = wadlContext.getJAXBContext().createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); final ByteArrayOutputStream os = new ByteArrayOutputStream(); marshaller.marshal(application, os); wadlXmlRepresentation = os.toByteArray(); os.close(); } catch (Exception e) { throw new ProcessingException("Could not marshal the wadl Application.", e); } } return Response.ok(new ByteArrayInputStream(wadlXmlRepresentation)) .header("Last-modified", lastModified) .build(); } catch (Exception e) { throw new ProcessingException("Error generating /application.wadl.", e); } }