Package juzu.impl.common

Examples of juzu.impl.common.Logger


    if (path == null) {
      throw new ServletException("Juzu servlet should be mounted on an url pattern");
    }

    //
    Logger servletLogger = JUL.getLogger(ServletBridge.class + "." + getServletConfig().getServletName());

    //
    final ServletConfig servletConfig = getServletConfig();

    //
    BridgeConfig config;
    try {
      config = new BridgeConfig(servletLogger, new SimpleMap<String, String>() {
        @Override
        protected Iterator<String> keys() {
          return BridgeConfig.NAMES.iterator();
        }
        @Override
        public String get(Object key) {
          if (BridgeConfig.APP_NAME.equals(key)) {
            return getApplicationName(servletConfig);
          } else if (BridgeConfig.INJECT.equals(key)) {
            // Cascade:
            // 1/ portlet init param
            // 2/ serlvet context init param
            String inject = servletConfig.getInitParameter((String)key);
            if (inject == null) {
              inject = servletConfig.getServletContext().getInitParameter((String)key);
            }
            return inject;
          } else if (BridgeConfig.REQUEST_ENCODING.equals(key)) {
            return servletConfig.getServletContext().getInitParameter((String)key);
          } else {
            return null;
          }
        }
      });
    }
    catch (Exception e) {
      throw wrap(e);
    }

    //
    if (config.name == null) {
      throw new ServletException("No application configured");
    }

    // Create and configure bridge
    InjectorProvider injectorProvider = config.injectorProvider;
    if (injectorProvider == null) {
      throw new UnavailableException("No inject implementation selected");
    } else {
      servletLogger.info("Using inject implementation " + injectorProvider.getValue());
    }

    //
    BridgeContext bridgeContext = new AbstractBridgeContext() {
      final ResourceResolver resolver = new ResourceResolver() {
View Full Code Here


  public void close() {
  }

  public final ScopedContext getScopedContext(Scope scope, boolean create) {
    Logger log = bridge.context.getLogger(ServletScopedContext.class.getName());
    ScopedContext context;
    switch (scope) {
      case REQUEST:
        context = (ScopedContext)req.getAttribute("juzu.request_scope");
        if (context == null && create) {
View Full Code Here

      server = new AssetServer();
      context.setAttribute("asset.server", server);
    }

    // The portlet logger
    Logger portletLogger = JUL.getLogger(JuzuPortlet.class.getName() + "." + config.getPortletName());

    //
    BridgeConfig bridgeConfig;
    try {
      bridgeConfig = new BridgeConfig(portletLogger, new SimpleMap<String, String>() {
        @Override
        protected Iterator<String> keys() {
          return BridgeConfig.NAMES.iterator();
        }

        @Override
        public String get(Object key) {
          if (BridgeConfig.APP_NAME.equals(key)) {
            return getApplicationName(config);
          } else if (BridgeConfig.INJECT.equals(key)) {
            // Cascade:
            // 1/ portlet init param
            // 2/ servket context init param
            String inject = config.getInitParameter((String)key);
            if (inject == null) {
              inject = context.getInitParameter((String)key);
            }
            return inject;
          } else if (BridgeConfig.NAMES.contains(key)) {
            return config.getInitParameter((String)key);
          } else {
            return null;
          }
        }
      });
    }
    catch (Exception e) {
      String msg = "Could not find an application to start";
      if (e instanceof PortletException) {
        String nested = e.getMessage();
        if (nested != null) {
          msg += ":" + nested;
        }
        throw Tools.initCause(new UnavailableException(msg), e.getCause());
      } else {
        throw new PortletException(msg, e);
      }
    }

    //
    final BridgeContext bridgeContext = new AbstractBridgeContext() {
      final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      final ResourceResolver resolver = new ResourceResolver() {
        public URL resolve(String uri) {
          try {
            return context.getResource(uri);
          }
          catch (MalformedURLException e) {
            return null;
          }
        }
      };
      public ReadFileSystem<?> getResourcePath() {
        return WarFileSystem.create(context, "/WEB-INF/");
      }
      public ReadFileSystem<?> getClassPath() {
        return WarFileSystem.create(context, "/WEB-INF/classes/");
      }
      public ClassLoader getClassLoader() {
        return classLoader;
      }
      public String getInitParameter(String name) {
        return context.getInitParameter(name);
      }
      public ResourceResolver getResolver() {
        return resolver;
      }
      public Object getAttribute(String key) {
        return context.getAttribute(key);
      }
      public void setAttribute(String key, Object value) {
        context.setAttribute(key, value);
      }
    };

    //
    InjectorProvider injectorProvider = bridgeConfig.injectorProvider;
    if (injectorProvider == null) {
      throw new UnavailableException("No inject implementation selected");
    } else {
      portletLogger.info("Using inject implementation " + injectorProvider.getValue());
    }

    //
    Injector injector = injectorProvider.get();
    if (injector instanceof SpringInjector) {
View Full Code Here

  public static Logger getLogger(Class<?> type) {

    String key = type.getName();
    final String name = type.getSimpleName();
    Logger logger = loggers.get(key);
    if (logger == null) {
      logger = new Logger() {
        @Override
        protected void send(Level level, CharSequence msg, Throwable t) {
          BaseProcessor.log(name, level, msg, t);
        }
      };
View Full Code Here

TOP

Related Classes of juzu.impl.common.Logger

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.