Search in sources :

Example 1 with SService

use of org.bimserver.shared.meta.SService in project BIMserver by opensourceBIM.

the class RealtimeReflectorFactoryBuilder method createCreateReflectorMethod1.

private void createCreateReflectorMethod1(CtClass reflectorFactoryImpl) throws NotFoundException, CannotCompileException {
    CtClass[] parameters = new CtClass[2];
    parameters[0] = pool.get(Class.class.getName());
    parameters[1] = pool.get(Reflector.class.getName());
    CtMethod method = new CtMethod(pool.get(PublicInterface.class.getName()), "createReflector", parameters, reflectorFactoryImpl);
    StringBuilder methodBuilder = new StringBuilder();
    methodBuilder.append("{");
    methodBuilder.append("if (1==0) {");
    for (String name : servicesMap.keySetName()) {
        SService sService = servicesMap.getByName(name);
        methodBuilder.append("} else if ($1.getSimpleName().equals(\"" + sService.getSimpleName() + "\")) {");
        methodBuilder.append("return new " + GENERATED_CLASSES_PACKAGE + "." + sService.getSimpleName() + "Impl" + implementationCounter + "($2);");
    }
    methodBuilder.append("}");
    methodBuilder.append("return null;");
    methodBuilder.append("}");
    method.setBody(methodBuilder.toString());
    reflectorFactoryImpl.addMethod(method);
}
Also used : CtClass(javassist.CtClass) CtMethod(javassist.CtMethod) SService(org.bimserver.shared.meta.SService)

Example 2 with SService

use of org.bimserver.shared.meta.SService in project BIMserver by opensourceBIM.

the class RealtimeReflectorFactoryBuilder method createCreateReflectorMethod2.

private void createCreateReflectorMethod2(CtClass reflectorFactoryImpl) throws NotFoundException, CannotCompileException {
    CtClass[] parameters = new CtClass[2];
    parameters[0] = pool.get(Class.class.getName());
    parameters[1] = pool.get(PublicInterface.class.getName());
    CtMethod method = new CtMethod(pool.get(Reflector.class.getName()), "createReflector", parameters, reflectorFactoryImpl);
    StringBuilder methodBuilder = new StringBuilder();
    methodBuilder.append("{");
    methodBuilder.append("if (1==0) {");
    for (String name : servicesMap.keySetName()) {
        SService sService = servicesMap.getByName(name);
        methodBuilder.append("} else if ($1.getSimpleName().equals(\"" + sService.getSimpleName() + "\")) {");
        methodBuilder.append("return new " + GENERATED_CLASSES_PACKAGE + "." + sService.getSimpleName() + "Reflector" + implementationCounter + "((" + sService.getInterfaceClass().getName() + ")$2);");
    }
    methodBuilder.append("}");
    methodBuilder.append("return null;");
    methodBuilder.append("}");
    method.setBody(methodBuilder.toString());
    reflectorFactoryImpl.addMethod(method);
}
Also used : CtClass(javassist.CtClass) CtMethod(javassist.CtMethod) SService(org.bimserver.shared.meta.SService)

Example 3 with SService

use of org.bimserver.shared.meta.SService in project BIMserver by opensourceBIM.

the class MetricsRegistry method getMetrics.

public synchronized SMetrics getMetrics() {
    SMetrics sMetrics = new SMetrics();
    for (SService sService : methodStats.keySet()) {
        SInterfaceMetric interfaceMetric = new SInterfaceMetric();
        interfaceMetric.setName(sService.getSimpleName());
        sMetrics.getInterfaces().add(interfaceMetric);
        for (SMethod sMethod : methodStats.get(sService).keySet()) {
            SMethodMetric sMethodMetric = new SMethodMetric();
            sMethodMetric.setName(sMethod.getName());
            interfaceMetric.getMethods().add(sMethodMetric);
            MethodStats methodStats = getMethodStats(sMethod);
            sMethodMetric.setNrCalls(methodStats.getNrCalls());
            sMethodMetric.setAverageMs(methodStats.getAverageNanoSecondsPerCall() / 1000000);
        }
    }
    return sMetrics;
}
Also used : SMethodMetric(org.bimserver.interfaces.objects.SMethodMetric) SMetrics(org.bimserver.interfaces.objects.SMetrics) SMethod(org.bimserver.shared.meta.SMethod) SInterfaceMetric(org.bimserver.interfaces.objects.SInterfaceMetric) SService(org.bimserver.shared.meta.SService)

Example 4 with SService

use of org.bimserver.shared.meta.SService in project BIMserver by opensourceBIM.

the class InterfaceList method createSServicesMap.

public static SServicesMap createSServicesMap() {
    SServicesMap servicesMap = new SServicesMap();
    CodeFetcher sourceCodeFetcher = new CodeFetcher();
    SService serviceInterface = new SServiceInterfaceService(servicesMap, sourceCodeFetcher, ServiceInterface.class);
    servicesMap.add(serviceInterface);
    for (Class<? extends PublicInterface> clazz : getInterfaces()) {
        if (clazz != ServiceInterface.class) {
            servicesMap.add(new SService(servicesMap, sourceCodeFetcher, clazz));
        }
    }
    servicesMap.initialize();
    return servicesMap;
}
Also used : SServicesMap(org.bimserver.shared.meta.SServicesMap) SServiceInterfaceService(org.bimserver.interfaces.SServiceInterfaceService) SService(org.bimserver.shared.meta.SService)

Example 5 with SService

use of org.bimserver.shared.meta.SService in project BIMserver by opensourceBIM.

the class RealtimeReflectorFactoryBuilder method createCreateReflectorMethod1.

private void createCreateReflectorMethod1(String newClassPrefix, CtClass reflectorFactoryImpl) throws NotFoundException, CannotCompileException {
    CtClass[] parameters = new CtClass[2];
    parameters[0] = pool.get(Class.class.getName());
    parameters[1] = pool.get(Reflector.class.getName());
    CtMethod method = new CtMethod(pool.get(PublicInterface.class.getName()), "createReflector", parameters, reflectorFactoryImpl);
    StringBuilder methodBuilder = new StringBuilder();
    methodBuilder.append("{");
    methodBuilder.append("if (1==0) {");
    for (String name : servicesMap.keySetName()) {
        SService sService = servicesMap.getByName(name);
        methodBuilder.append("} else if ($1.getSimpleName().equals(\"" + sService.getSimpleName() + "\")) {");
        methodBuilder.append("return new " + GENERATED_CLASSES_PACKAGE + "." + sService.getSimpleName() + "Impl" + newClassPrefix + "($2);");
    }
    methodBuilder.append("}");
    methodBuilder.append("return null;");
    methodBuilder.append("}");
    method.setBody(methodBuilder.toString());
    reflectorFactoryImpl.addMethod(method);
}
Also used : CtClass(javassist.CtClass) CtMethod(javassist.CtMethod) SService(org.bimserver.shared.meta.SService)

Aggregations

SService (org.bimserver.shared.meta.SService)16 SMethod (org.bimserver.shared.meta.SMethod)8 UserException (org.bimserver.shared.exceptions.UserException)7 CtClass (javassist.CtClass)5 SParameter (org.bimserver.shared.meta.SParameter)5 CtMethod (javassist.CtMethod)4 KeyValuePair (org.bimserver.shared.reflector.KeyValuePair)4 PublicInterface (org.bimserver.shared.interfaces.PublicInterface)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 JsonObject (com.google.gson.JsonObject)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ServiceException (org.bimserver.shared.exceptions.ServiceException)2 ReflectorException (org.bimserver.shared.reflector.ReflectorException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 DynamicMessage (com.google.protobuf.DynamicMessage)1 Builder (com.google.protobuf.DynamicMessage.Builder)1 Message (com.google.protobuf.Message)1 EOFException (java.io.EOFException)1 File (java.io.File)1