/** * 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()); }
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."); }
/** * 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); }
/** * Sets the child. * * @param child * The child. */ public void setChild(Restlet child) { this.child = child; setLogger(LogUtils.getLoggerName(this.parentContext.getLogger() .getName(), child)); }
/** * Returns the current context's logger. * * @return The current context's logger. */ public static Logger getCurrentLogger() { return (Context.getCurrent() != null) ? Context.getCurrent() .getLogger() : null; }
/** * 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; }
/** * 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()); } } }
/** * 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()); } } }
/** * 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()); } }
/** * 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; }
/** * 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; }
/** * Returns the logger. * * @return The logger. */ public Logger getLogger() { return getContext() != null ? getContext().getLogger() : Context .getCurrentLogger(); }
/** * 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"); }
/** * Returns the logger. * * @return The logger. */ public static Logger getLogger() { return getResourceContext() != null ? getResourceContext().getLogger() : Context .getCurrentLogger(); }
/** * Returns the logger to use. * * @return The logger to use. */ public Logger getLogger() { return (getContext() != null) ? getContext().getLogger() : Context .getCurrentLogger(); }
/** * Returns the logger. * * @return The logger. */ public Logger getLogger() { Logger result = (getContext() != null) ? getContext().getLogger() : null; return (result != null) ? result : Context.getCurrentLogger(); }
/** * 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; }
/** * Returns the helped Restlet logger. * * @return The helped Restlet logger. */ public Logger getLogger() { return (getHelped().getContext() != null) ? getHelped().getContext() .getLogger() : Context.getCurrentLogger(); }
/** * 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(); }
/** * 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())); } } }