use of io.atlasmap.java.v2.ClassInspectionResponse in project atlasmap by atlasmap.
the class JavaService method inspectClass.
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Path("/class")
public Response inspectClass(InputStream requestIn) {
ClassInspectionRequest request = fromJson(requestIn, ClassInspectionRequest.class);
ClassInspectionResponse response = new ClassInspectionResponse();
ClassInspectionService classInspectionService = new ClassInspectionService();
classInspectionService.setConversionService(DefaultAtlasConversionService.getInstance());
configureInspectionService(classInspectionService, request);
long startTime = System.currentTimeMillis();
try {
JavaClass c = null;
if (request.getClasspath() == null || request.getClasspath().isEmpty()) {
c = classInspectionService.inspectClass(request.getClassName());
} else {
c = classInspectionService.inspectClass(request.getClassName(), request.getClasspath());
}
response.setJavaClass(c);
} catch (Exception e) {
LOG.error("Error inspecting class with classpath: " + e.getMessage(), e);
response.setErrorMessage(e.getMessage());
} finally {
response.setExecutionTime(System.currentTimeMillis() - startTime);
}
return Response.ok().entity(toJson(response)).build();
}
Aggregations