boolean setTubelineHead(Tube newHead) { if (newHead == head || newHead == adaptedHead) { return false; } head = newHead; tubes.add(head); adaptedHead = null; if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer(MessageFormat.format("Added '{0}' tube instance to the tubeline.", (newHead == null) ? null : newHead.getClass().getName())); } return true; }
protected void report(String msg) { if (out == null) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "No output set for web service annotation processor reporting."); } return; } out.println(msg); out.flush(); }
private Boolean getBooleanValue(String propertyName) { Boolean retVal = null; String stringValue = System.getProperty(propertyName); if (stringValue != null) { retVal = Boolean.valueOf(stringValue); LOGGER.fine(TubelineassemblyMessages.MASM_0018_MSG_LOGGING_SYSTEM_PROPERTY_SET_TO_VALUE(propertyName, retVal)); } return retVal; }
@Override public URL getResource(String resource) throws MalformedURLException { LOGGER.entering(resource); URL resourceUrl = null; try { if (parentLoader != null) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(TubelineassemblyMessages.MASM_0011_LOADING_RESOURCE(resource, parentLoader)); } resourceUrl = parentLoader.getResource(resource); } if (resourceUrl == null) { resourceUrl = loadViaClassLoaders("META-INF/" + resource); } if (resourceUrl == null && container != null) { // TODO: we should remove this code path, the config file should be loaded using ResourceLoader only resourceUrl = loadFromServletContext(resource); } return resourceUrl; } finally { LOGGER.exiting(resourceUrl); } }
/** * This method contains main task loop. It should not be called directly from outside. */ public void run() { LOGGER.entering(); if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer(String.format("Starting delayed execution of [ %s ]", task.getName())); } try { task.run(DelayedTaskManager.this); } catch (Exception ex) { LOGGER.warning(String.format("An exception occured during execution of [ %s ]", task.getName()), ex); } finally { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer(String.format("Delayed execution of [ %s ] finished", task.getName())); } LOGGER.exiting(); } } }
/** * Return ManagedService assertion if there is one associated with the endpoint. * * @param endpoint The endpoint. Must not be null. * @return The policy assertion if found. Null otherwise. * @throws WebServiceException If computing the effective policy of the endpoint failed. */ public static ManagedServiceAssertion getAssertion(WSEndpoint endpoint) throws WebServiceException { LOGGER.entering(endpoint); // getPolicyMap is deprecated because it is only supposed to be used by Metro code // and not by other clients. @SuppressWarnings("deprecation") final PolicyMap policyMap = endpoint.getPolicyMap(); final ManagedServiceAssertion assertion = ManagementAssertion.getAssertion(MANAGED_SERVICE_QNAME, policyMap, endpoint.getServiceName(), endpoint.getPortName(), ManagedServiceAssertion.class); LOGGER.exiting(assertion); return assertion; }
private URL loadFromServletContext(String resource) throws RuntimeException { Object context = null; try { final Class<?> contextClass = Class.forName("javax.servlet.ServletContext"); context = container.getSPI(contextClass); if (context != null) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(TubelineassemblyMessages.MASM_0012_LOADING_VIA_SERVLET_CONTEXT(resource, context)); } try { final Method method = context.getClass().getMethod("getResource", String.class); final Object result = method.invoke(context, "/WEB-INF/" + resource); return URL.class.cast(result); } catch (Exception e) { throw LOGGER.logSevereException(new RuntimeException(TubelineassemblyMessages.MASM_0013_ERROR_INVOKING_SERVLET_CONTEXT_METHOD("getResource()")), e); } } } catch (ClassNotFoundException e) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(TubelineassemblyMessages.MASM_0014_UNABLE_TO_LOAD_CLASS("javax.servlet.ServletContext")); } } return null; } }
public void info(final String message) { if (!this.logger.isLoggable(Level.INFO)) { return; } logger.logp(Level.INFO, componentClassName, getCallerMethodName(), message); }
LOGGER.log(Level.WARNING, "Unexpected exception occured while dumping message", e); } finally { if (writer != null) { writer.close(); } catch (XMLStreamException ignored) { LOGGER.fine("Unexpected exception occured while closing XMLStreamWriter", ignored); stringOut.close(); } catch (IOException ex) { LOGGER.finest("An exception occured when trying to close StringWriter", ex);
public static void removeSessionManager(WSEndpoint endpoint){ synchronized (LOCK) { try { LOGGER.entering(); Object o = SESSION_MANAGERS.remove(endpoint); LOGGER.config(String.format("removeSessionManager(%s): %s", endpoint, o)); SessionManager sessionManager = (SessionManager) o; if (sessionManager != null && sessionManager.isRegisteredAtMOM()) { listener.unregisterFromMOM(sessionManager, endpoint); } } finally { LOGGER.exiting(); } } }
private Level getLevelValue(String propertyName) { Level retVal = null; String stringValue = System.getProperty(propertyName); if (stringValue != null) { // if value is not null => property is set, we will try to override the default logging level LOGGER.fine(TubelineassemblyMessages.MASM_0018_MSG_LOGGING_SYSTEM_PROPERTY_SET_TO_VALUE(propertyName, stringValue)); try { retVal = Level.parse(stringValue); } catch (IllegalArgumentException ex) { LOGGER.warning(TubelineassemblyMessages.MASM_0019_MSG_LOGGING_SYSTEM_PROPERTY_ILLEGAL_VALUE(propertyName, stringValue), ex); } } return retVal; }
/** * <p> * The factory method returns preconfigured Logger wrapper for the class. Method calls * {@link #getSystemLoggerName(java.lang.Class)} to generate default logger name. * </p> * <p> * Since there is no caching implemented, it is advised that the method is called only once * per a class in order to initialize a final static logger variable, which is then used * through the class to perform actual logging tasks. * </p> * * @param componentClass class of the component that will use the logger instance. Must not be {@code null}. * @return logger instance preconfigured for use with the component * @throws NullPointerException if the componentClass parameter is {@code null}. */ public static @NotNull Logger getLogger(final @NotNull Class<?> componentClass) { return new Logger(getSystemLoggerName(componentClass), componentClass.getName()); }
/** * Wraps {@link javax.xml.stream.XMLStreamWriter} by an indentation engine if possible. * * <p> * We can do this only when we have {@code stax-utils.jar} in the class path. */ private static XMLStreamWriter createIndenter(XMLStreamWriter writer) { try { Class<?> clazz = Converter.class.getClassLoader().loadClass("javanet.staxutils.IndentingXMLStreamWriter"); Constructor<?> c = clazz.getConstructor(XMLStreamWriter.class); writer = XMLStreamWriter.class.cast(c.newInstance(writer)); } catch (Exception ex) { // if stax-utils.jar is not in the classpath, this will fail // so, we'll just have to do without indentation if (logMissingStaxUtilsWarning.compareAndSet(false, true)) { LOGGER.log(Level.WARNING, "Put stax-utils.jar to the classpath to indent the dump output", ex); } } return writer; } }
LOGGER.config(TubelineassemblyMessages.MASM_0002_DEFAULT_CFG_FILE_LOCATED(defaultFileName, defaultConfigUrl)); throw LOGGER.logSevereException(new IllegalStateException(TubelineassemblyMessages.MASM_0003_DEFAULT_CFG_FILE_NOT_LOADED(defaultFileName))); throw LOGGER.logSevereException(new IllegalStateException(TubelineassemblyMessages.MASM_0004_NO_TUBELINES_SECTION_IN_DEFAULT_CFG_FILE(defaultFileName))); throw LOGGER.logSevereException(new IllegalStateException(TubelineassemblyMessages.MASM_0005_NO_DEFAULT_TUBELINE_IN_DEFAULT_CFG_FILE(defaultFileName))); LOGGER.config(TubelineassemblyMessages.MASM_0006_APP_CFG_FILE_LOCATED(appConfigUrl)); this.appConfig = MetroConfigLoader.loadMetroConfig(appConfigUrl); } else { LOGGER.config(TubelineassemblyMessages.MASM_0007_APP_CFG_FILE_NOT_FOUND()); this.appConfig = null;
/** * Function returns the name of the caller method for the method executing this * function. * * @return caller method name from the call stack of the current {@link Thread}. */ private static String getCallerMethodName() { return getStackMethodName(5); }
/** * The factory method returns preconfigured Logger wrapper for the class. Since there is no caching implemented, * it is advised that the method is called only once per a class in order to initialize a final static logger variable, * which is then used through the class to perform actual logging tasks. * * This method should be only used in a special cases when overriding of a default logger name derived from the * package of the component class is needed. For all common use cases please use {@link #getLogger(java.lang.Class)} * method. * * @param customLoggerName custom name of the logger. * @param componentClass class of the component that will use the logger instance. Must not be {@code null}. * @return logger instance preconfigured for use with the component * @throws NullPointerException if the componentClass parameter is {@code null}. * * @see #getLogger(java.lang.Class) */ public static @NotNull Logger getLogger(final @NotNull String customLoggerName, final @NotNull Class<?> componentClass) { return new Logger(customLoggerName, componentClass.getName()); }
public boolean register(@NotNull DelayedTask task, long delay, TimeUnit timeUnit) { if (isClosed()) { LOGGER.finer(String.format("Attempt to register a new task has failed. This '%s' instance has already been closed", this.getClass().getName())); return false; } assert task != null; getExecutorService().schedule(new Worker(task), delay, timeUnit); return true; }
@Override public URL getResource(String resource) throws MalformedURLException { LOGGER.entering(resource); URL resourceUrl = null; try { if (parentLoader != null) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(TubelineassemblyMessages.MASM_0011_LOADING_RESOURCE(resource, parentLoader)); } resourceUrl = parentLoader.getResource(resource); } if (resourceUrl == null) { resourceUrl = loadViaClassLoaders("META-INF/" + resource); } if (resourceUrl == null && container != null) { // TODO: we should remove this code path, the config file should be loaded using ResourceLoader only resourceUrl = loadFromServletContext(resource); } return resourceUrl; } finally { LOGGER.exiting(resourceUrl); } }
/** * Return ManagedService assertion if there is one associated with the endpoint. * * @param endpoint The endpoint. Must not be null. * @return The policy assertion if found. Null otherwise. * @throws WebServiceException If computing the effective policy of the endpoint failed. */ public static ManagedServiceAssertion getAssertion(WSEndpoint endpoint) throws WebServiceException { LOGGER.entering(endpoint); // getPolicyMap is deprecated because it is only supposed to be used by Metro code // and not by other clients. @SuppressWarnings("deprecation") final PolicyMap policyMap = endpoint.getPolicyMap(); final ManagedServiceAssertion assertion = ManagementAssertion.getAssertion(MANAGED_SERVICE_QNAME, policyMap, endpoint.getServiceName(), endpoint.getPortName(), ManagedServiceAssertion.class); LOGGER.exiting(assertion); return assertion; }
private URL loadFromServletContext(String resource) throws RuntimeException { Object context = null; try { final Class<?> contextClass = Class.forName("javax.servlet.ServletContext"); context = container.getSPI(contextClass); if (context != null) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(TubelineassemblyMessages.MASM_0012_LOADING_VIA_SERVLET_CONTEXT(resource, context)); } try { final Method method = context.getClass().getMethod("getResource", String.class); final Object result = method.invoke(context, "/WEB-INF/" + resource); return URL.class.cast(result); } catch (Exception e) { throw LOGGER.logSevereException(new RuntimeException(TubelineassemblyMessages.MASM_0013_ERROR_INVOKING_SERVLET_CONTEXT_METHOD("getResource()")), e); } } } catch (ClassNotFoundException e) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(TubelineassemblyMessages.MASM_0014_UNABLE_TO_LOAD_CLASS("javax.servlet.ServletContext")); } } return null; } }