Package com.softwarementors.extjs.djn

Examples of com.softwarementors.extjs.djn.Timer


  /* package */ String processIndividualRequest( JsonRequestData request, boolean isBatched, int requestNumber ) {
    assert request != null;
    boolean resultReported = false;

    Timer timer = new Timer();
    try {
      if( isBatched ) {
        if( logger.isDebugEnabled() ) {
          logger.debug( "  - Individual request #" + requestNumber + " request data=>" + getGson().toJson(request) );
        }
      }
      Object[] parameters = getIndividualRequestParameters( request);
      String action = request.getAction();
      String method = request.getMethod();
      StandardSuccessResponseData response = new StandardSuccessResponseData( request.getTid(), action, method);

      JsonDeserializationManager mgr = JsonDeserializationManager.getManager();
      try {

        Object result = dispatchStandardMethod(action, method, parameters);
        mgr.friendOnlyAccess_setRoot(result);
        response.setResult(result);
        String json = getGson().toJson(response);
        if( isBatched ) {
          if( logger.isDebugEnabled() ) {
            timer.stop();
            timer.logDebugTimeInMilliseconds( "  - Individual request #" + requestNumber + " response data=>" + json );
            resultReported = true;
          }
        }
        return json;
      }
      finally {
        mgr.friendOnlyAccess_dispose(); // Cleanup in case we are reusing thread
      }
    }
    catch( Exception t ) {       
      StandardErrorResponseData response = createJsonServerErrorResponse(request, t);
      String json = getGson().toJson(response);
      logger.error( "(Controlled) server error: " + t.getMessage() + " for Method '" + request.getFullMethodName() + "'", t);
      return json;
    }
    finally {
      if( !resultReported ) {
        timer.stop();
        // No point in logging individual requests when the request is not batched
        if( isBatched ) {
          if( logger.isDebugEnabled() ) {
            timer.logDebugTimeInMilliseconds( "  - Individual request #" + requestNumber + ": " + request.getFullMethodName() + ". Time");
          }
        }
      }
    }
  }
View Full Code Here


    int expectedArgumentCount = method.getParameterCount();
    if( parameters.length != expectedArgumentCount ) {
      throw RequestException.forWrongMethodArgumentCount( method, parameters.length );
    }

    Timer timer = new Timer();
    try {
      Object actionInstance = null;
      try {
        actionInstance = getInvokeInstance(method);
      }
      catch( Exception e ) {
        throw MethodExecutionException.forUnableToGetActionInstance( method, e );
      }
      try {
        Object result = invokeMethod( method, actionInstance, parameters);
        return result;
      }
      catch( Exception e ) {
        throw MethodExecutionException.forJavaMethodInvocationError( method, e );
      }
    }
    finally {
      timer.stop();
      if( Timer.logger.isDebugEnabled()) {
        timer.logDebugTimeInMilliseconds("  - Java method dispatch time (" + ClassUtils.getSimpleName(javaMethod.getDeclaringClass()) + "." + method.getName() + ")" );
      }
    }
  }
View Full Code Here

    assert input != null;
    assert !StringUtils.isEmpty(inputFilename);
    assert debugCodeLength > 0;

    try {
      Timer timer = new Timer();     
      // logger.debug( "Starting minification for '" + inputFilename + "'...");
      Reader in = new StringReader( input );
      JavaScriptCompressor compressor = new JavaScriptCompressor(in, new ErrorReporter() {
        public void warning(String message, String sourceName,
            int line, String lineSource, int lineOffset) {
          if (line < 0) {
            logger.warn("Minifier Warning: " + message);
          } else {
            logger.warn("Minifier Warning, " + line + ':' + lineOffset + ':' + message);
          }
        }

        public void error(String message, String sourceName,
            int line, String lineSource, int lineOffset) {
          if (line < 0) {
            logger.warn("Minifier Error: " + message);
          } else {
            logger.warn("Minifier Error, " + line + ':' + lineOffset + ':' + message);
          }
        }

        public EvaluatorException runtimeError(String message, String sourceName,
            int line, String lineSource, int lineOffset) {
          error(message, sourceName, line, lineSource, lineOffset);
          return new EvaluatorException(message);
        }
      });

      // Close the input stream first, and then open the output stream,
      // in case the output file should override the input file.
      in.close();

      try {
        Writer out = new StringWriter();
        boolean munge = true;
        boolean preserveAllSemiColons = false;
        boolean disableOptimizations = false;
        boolean verbose = false;
        int linebreakpos = 0;

        compressor.compress(out, linebreakpos, munge, verbose,
            preserveAllSemiColons, disableOptimizations);
        out.close();
        String result = out.toString();
        if( logger.isDebugEnabled() ) {
          timer.stop();
          int compressionPercentage = 100 - (result.length() * 100 / debugCodeLength);
          timer.logDebugTimeInMilliseconds( "Finished minification for '" + inputFilename + "'. Debug code length: " + debugCodeLength + ", Minified length: " + result.length() + ", Compression: " + compressionPercentage + "%. Time");
        }
        return result;
      }
      catch (UnsupportedEncodingException e) {
        logger.warn( "Unable to minify '" + inputFilename + "'.", e );
View Full Code Here

  public void init(ServletConfig configuration) throws ServletException
  {
    assert configuration != null;
    super.init(configuration);
   
    Timer timer = new Timer();
    createDirectJNgineRouter(configuration);
    timer.stop();
    timer.logDebugTimeInMilliseconds("Djn initialization: total DirectJNgine initialization time");
  }
View Full Code Here

  }

  protected void createDirectJNgineRouter(ServletConfig configuration) throws ServletException {
    assert configuration != null;

    Timer subtaskTimer = new Timer();
    GlobalConfiguration globalConfiguration = createGlobalConfiguration(configuration);
    String registryConfiguratorClassName = ServletUtils.getParameter(configuration, REGISTRY_CONFIGURATOR_CLASS, null);  
    if( logger.isInfoEnabled() ) {
      String value = registryConfiguratorClassName;
      if( value == null) {
        value = "";
      }
      logger.info( "Servlet GLOBAL configuration: " + REGISTRY_CONFIGURATOR_CLASS + "=" + value );
    }
   
    Class<? extends ServletRegistryConfigurator> registryConfiguratorClass = getRegistryConfiguratorClass(registryConfiguratorClassName);
    List<ApiConfiguration> apiConfigurations = createApiConfigurationsFromServletConfigurationApi(configuration);
    subtaskTimer.stop();
    subtaskTimer.logDebugTimeInMilliseconds("Djn initialization: Servlet Configuration Load time");
   
    subtaskTimer.restart();
    Registry registry = new Registry( globalConfiguration );
    Scanner scanner = new Scanner(registry);
    scanner.scanAndRegisterApiConfigurations( apiConfigurations );
    subtaskTimer.stop();
    subtaskTimer.logDebugTimeInMilliseconds("Djn initialization: Standard Api processing time");

    if( registryConfiguratorClass != null ) {
      subtaskTimer.restart();
      performCustomRegistryConfiguration( registryConfiguratorClass, registry, configuration );
      subtaskTimer.stop();
      subtaskTimer.logDebugTimeInMilliseconds("Djn initialization: Custom Registry processing time");
    }
   
    subtaskTimer.restart();
    try {
      CodeFileGenerator.updateSource(registry, globalConfiguration.getCreateSourceFiles());     
      subtaskTimer.stop();
      subtaskTimer.logDebugTimeInMilliseconds("Djn initialization: Api Files creation time");
    }
    catch( IOException ex ) {
      ServletException e = new ServletException( "Unable to create DirectJNgine API files",  ex );
      logger.fatal( e.getMessage(), e );
       throw e;
    }

    subtaskTimer.restart();
   
    initializeRouter(globalConfiguration, registry);
   
    subtaskTimer.stop();
    subtaskTimer.logDebugTimeInMilliseconds("Djn initialization: Request Processor initialization time");   
  }
View Full Code Here

    assert request != null;
    assert response != null;

    NDC.push( "rid=" + Long.toString(getUniqueRequestId()) );
    try {
      Timer timer = new Timer();
      try {
        attachThreadLocalData( request, response);
        try {
          if( logger.isTraceEnabled()) {
            String requestInfo = ServletUtils.getDetailedRequestInformation(request);
            logger.trace( "Request info: " + requestInfo);
          }       

          String requestEncoding = request.getCharacterEncoding();
          // If we don't know what the request encoding is, assume it to be UTF-8
          if( StringUtils.isEmpty(requestEncoding)) {
            request.setCharacterEncoding(EncodingUtils.UTF8);
          }
          response.setCharacterEncoding(EncodingUtils.UTF8);

          RequestType type = getFromRequestContentType(request);
          processRequest(request, response, type);
        }
        finally {
          detachThreadLocalData();
        }
      }
      finally {
        timer.stop();
        timer.logDebugTimeInMilliseconds("Total servlet processing time");
      }

    }
    finally {
      NDC.pop();
View Full Code Here

TOP

Related Classes of com.softwarementors.extjs.djn.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.