Search in sources :

Example 1 with ClassInspectionResponse

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();
}
Also used : ClassInspectionResponse(io.atlasmap.java.v2.ClassInspectionResponse) JavaClass(io.atlasmap.java.v2.JavaClass) ClassInspectionService(io.atlasmap.java.inspect.ClassInspectionService) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) WebApplicationException(javax.ws.rs.WebApplicationException) ClassInspectionRequest(io.atlasmap.java.v2.ClassInspectionRequest) Path(javax.ws.rs.Path) ApplicationPath(javax.ws.rs.ApplicationPath) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ClassInspectionService (io.atlasmap.java.inspect.ClassInspectionService)1 ClassInspectionRequest (io.atlasmap.java.v2.ClassInspectionRequest)1 ClassInspectionResponse (io.atlasmap.java.v2.ClassInspectionResponse)1 JavaClass (io.atlasmap.java.v2.JavaClass)1 IOException (java.io.IOException)1 ApplicationPath (javax.ws.rs.ApplicationPath)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1