org.restlet.Context.getLogger()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中org.restlet.Context.getLogger()方法的一些代码示例,展示了Context.getLogger()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getLogger()方法的具体详情如下:
包路径:org.restlet.Context
类名称:Context
方法名:getLogger

Context.getLogger介绍

[英]Returns the logger.
[中]返回记录器。

代码示例

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the current context's logger.
 * 
 * @return The current context's logger.
 */
public static Logger getCurrentLogger() {
  return (Context.getCurrent() != null) ? Context.getCurrent()
      .getLogger() : Logger.getLogger(Context.class
      .getCanonicalName());
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server

public XWikiJaxRsApplication(Context context)
{
  this.jaxRsClasses = new HashSet<Class< ? >>();
  ComponentManager componentManager =
    (ComponentManager) context.getAttributes().get(Constants.XWIKI_COMPONENT_MANAGER);
  /* Look up all the component that are markes as XWikiRestComponent. */
  List<ComponentDescriptor<XWikiRestComponent>> cds =
    componentManager.getComponentDescriptorList(XWikiRestComponent.class);
  for (ComponentDescriptor<XWikiRestComponent> cd : cds) {
    this.jaxRsClasses.add(cd.getImplementation());
    context.getLogger().log(Level.FINE, String.format("%s registered.", cd.getImplementation().getName()));
  }
  context.getLogger().log(Level.INFO, "RESTful API subsystem initialized.");
}

代码示例来源:origin: org.restlet.osgi/org.restlet.ext.oauth

/**
 * Returns the value of the "authSkipApproved" parameter.
 * 
 * @param c
 *            The context where to find the parameter.
 * @return The value of the "authSkipApproved" parameter.
 */
public static boolean getAuthSkipApproved(Context c) {
  c.getLogger().fine("Trying to get auth page template");
  String skip = c.getParameters().getFirstValue("authSkipApproved");
  if (skip == null)
    return false;
  return Boolean.parseBoolean(skip);
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Sets the child.
 * 
 * @param child
 *            The child.
 */
public void setChild(Restlet child) {
  this.child = child;
  setLogger(LogUtils.getLoggerName(this.parentContext.getLogger()
      .getName(), child));
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Returns the current context's logger.
 * 
 * @return The current context's logger.
 */
public static Logger getCurrentLogger() {
  return (Context.getCurrent() != null) ? Context.getCurrent()
      .getLogger() : 
      null;
}

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the context's logger.
 * 
 * @return The context's logger.
 */
public Logger getLogger() {
  Logger result = null;
  Context context = getContext();
  if (context == null) {
    context = Context.getCurrent();
  }
  if (context != null) {
    result = context.getLogger();
  }
  if (result == null) {
    result = Logger.getLogger(getClass().getCanonicalName());
  }
  if (result == null) {
    result = Logger.getLogger("org.restlet.Restlet");
  }
  return result;
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Indicates that a Restlet's context has changed.
 * 
 * @param restlet
 *            The Restlet with a changed context.
 * @param context
 *            The new context.
 */
private static void fireContextChanged(Restlet restlet, Context context) {
  if (context != null) {
    if (context instanceof org.restlet.engine.util.ChildContext) {
      org.restlet.engine.util.ChildContext childContext = (org.restlet.engine.util.ChildContext) context;
      if (childContext.getChild() == null) {
        childContext.setChild(restlet);
      }
    } else if (!(restlet instanceof Component)
        && (context instanceof org.restlet.engine.component.ComponentContext)) {
      context.getLogger()
          .severe("For security reasons, don't pass the component context to child Restlets anymore. Use the Context#createChildContext() method instead. "
              + restlet.getClass());
    }
  }
}

代码示例来源:origin: org.restlet.jse/org.restlet.ext.thymeleaf

/**
   * Writes the datum as a stream of characters.
   * 
   * @param writer
   *            The writer to use when writing.
   */
  @Override
  public void write(Writer writer) throws IOException {
    try {
      // Load the template
      // Process the template
      engine.process(templateName, context, writer);

    } catch (Exception e) {
      final org.restlet.Context context = org.restlet.Context
          .getCurrent();

      if (context != null) {
        context.getLogger().log(Level.WARNING,
            "Unable to process the template", e);
      }

      e.printStackTrace();

      throw new IOException("Template processing error. "
          + e.getMessage());
    }
  }
}

代码示例来源:origin: org.restlet.jse/org.restlet.ext.velocity

/**
 * Writes the datum as a stream of characters.
 * 
 * @param writer
 *            The writer to use when writing.
 */
@Override
public void write(Writer writer) throws IOException {
  try {
    // Load the template
    // Process the template
    getTemplate().merge(getContext(), writer);
  } catch (Exception e) {
    final Context context = Context.getCurrent();
    if (context != null) {
      context.getLogger().log(Level.WARNING,
          "Unable to process the template", e);
    }
    e.printStackTrace();
    throw new IOException("Template processing error. "
        + e.getMessage());
  }
}

代码示例来源:origin: org.restlet/org.restlet.ext.velocity

/**
 * Returns the Velocity template.
 * 
 * @return The Velocity template.
 */
public Template getTemplate() {
  if (this.template == null) {
    if (this.templateName != null) {
      try {
        getEngine().init();
        this.template = getEngine().getTemplate(this.templateName);
      } catch (Exception e) {
        final Context context = Context.getCurrent();
        if (context != null) {
          context.getLogger().log(Level.WARNING,
              "Unable to get template", e);
        }
      }
    }
  }
  return this.template;
}

代码示例来源:origin: org.restlet.jse/org.restlet.ext.velocity

/**
 * Returns the Velocity template.
 * 
 * @return The Velocity template.
 */
public Template getTemplate() {
  if (this.template == null) {
    if (this.templateName != null) {
      try {
        getEngine().init();
        this.template = getEngine().getTemplate(this.templateName);
      } catch (Exception e) {
        final Context context = Context.getCurrent();
        if (context != null) {
          context.getLogger().log(Level.WARNING,
              "Unable to get template", e);
        }
      }
    }
  }
  return this.template;
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the logger.
 * 
 * @return The logger.
 */
public Logger getLogger() {
  return getContext() != null ? getContext().getLogger() : Context
      .getCurrentLogger();
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the current context's logger.
 * 
 * @return The current context's logger.
 */
public static Logger getCurrentLogger() {
  return (Context.getCurrent() != null) ? Context.getCurrent()
      .getLogger() : Engine.getLogger("org.restlet");
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Returns the logger.
 * 
 * @return The logger.
 */
public static Logger getLogger() {
  return getResourceContext() != null ? getResourceContext().getLogger() : Context
      .getCurrentLogger();
}

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the logger to use.
 * 
 * @return The logger to use.
 */
public Logger getLogger() {
  return (getContext() != null) ? getContext().getLogger() : Context
      .getCurrentLogger();
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the logger.
 * 
 * @return The logger.
 */
public Logger getLogger() {
  Logger result = (getContext() != null) ? getContext().getLogger()
      : null;
  return (result != null) ? result : Context.getCurrentLogger();
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the context's logger.
 * 
 * @return The context's logger.
 */
public Logger getLogger() {
  Logger result = null;
  Context context = getContext();
  if (context == null) {
    context = Context.getCurrent();
  }
  if (context != null) {
    result = context.getLogger();
  }
  if (result == null) {
    result = Engine.getLogger(this, "org.restlet");
  }
  return result;
}

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the helped Restlet logger.
 * 
 * @return The helped Restlet logger.
 */
public Logger getLogger() {
  return (getHelped().getContext() != null) ? getHelped().getContext()
      .getLogger() : Context.getCurrentLogger();
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the helped Restlet logger.
 * 
 * @return The helped Restlet logger.
 */
public Logger getLogger() {
  if (getHelped() != null && getHelped().getContext() != null) {
    return getHelped().getContext().getLogger();
  }
  return Context.getCurrentLogger();
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Constructor.
 * 
 * @param context
 *            The context.
 * @param logService
 *            The log service descriptor.
 */
public LogFilter(Context context, LogService logService) {
  super(context);
  this.logService = logService;
  if (logService != null) {
    if (logService.getLoggerName() != null) {
      this.logLogger = Engine.getLogger(logService.getLoggerName());
    } else if ((context != null)
        && (context.getLogger().getParent() != null)) {
      this.logLogger = Engine.getLogger(context.getLogger()
          .getParent().getName()
          + "."
          + LogUtils.getBestClassName(logService.getClass()));
    } else {
      this.logLogger = Engine.getLogger(LogUtils
          .getBestClassName(logService.getClass()));
    }
  }
}

相关文章