/** * Return a logger associated with this context. This logger records only those activities within the context and provide a * way to capture the context-specific activities. All log messages are also sent to the system logger, so classes that log * via this mechanism should <i>not</i> also {@link Logger#getLogger(Class) obtain a system logger}. * * @param clazz the class that is doing the logging * @return the logger, named after <code>clazz</code>; never null * @see #getLogger(String) */ public Logger getLogger( Class<?> clazz ) { return Logger.getLogger(clazz); }
/** * Return a logger associated with this context. This logger records only those activities within the context and provide a * way to capture the context-specific activities. All log messages are also sent to the system logger, so classes that log * via this mechanism should <i>not</i> also {@link Logger#getLogger(Class) obtain a system logger}. * * @param name the name for the logger * @return the logger, named after <code>clazz</code>; never null * @see #getLogger(Class) */ public Logger getLogger( String name ) { return Logger.getLogger(name); }
/** * Gets the logger for this system * * @return the logger */ public synchronized Logger getLogger() { if (logger == null) { logger = Logger.getLogger(getClass()); } return logger; }
/** * Gets the logger for this system * * @return the logger */ public synchronized Logger getLogger() { if (logger == null) { logger = Logger.getLogger(getClass()); } return logger; }
protected AbstractServiceAdministrator( I18n serviceName, State initialState ) { assert initialState != null; assert serviceName != null; this.state = initialState; this.serviceName = serviceName; this.logger = Logger.getLogger(getClass()); }
protected byte[] computeHash( byte[] content ) { try { return SecureHash.getHash(ALGORITHM, content); } catch (NoSuchAlgorithmException e) { if (ALGORITHMS_NOT_FOUND_AND_LOGGED.add(ALGORITHM.digestName())) { Logger.getLogger(getClass()).error(e, GraphI18n.messageDigestNotFound, ALGORITHM.digestName()); } return NO_HASH; } }
protected boolean setBeanPropertyIfExistsAndNotSet( Object target, String propertyName, Object value ) { Reflection reflection = new Reflection(target.getClass()); try { if (reflection.invokeGetterMethodOnTarget(propertyName, target) == null) { reflection.invokeSetterMethodOnTarget(propertyName, target, value); return true; } return false; } catch (Exception e) { // Log that the property was not found ... Logger.getLogger(getClass()) .debug("Unknown property '{0}' on '{1}' class", propertyName, target.getClass().getName()); return false; } }
protected byte[] computeHash( InputStream stream ) { try { return SecureHash.getHash(ALGORITHM, stream); } catch (NoSuchAlgorithmException e) { if (ALGORITHMS_NOT_FOUND_AND_LOGGED.add(ALGORITHM.digestName())) { Logger.getLogger(getClass()).error(e, GraphI18n.messageDigestNotFound, ALGORITHM.digestName()); } return NO_HASH; } catch (IOException e) { if (ALGORITHMS_NOT_FOUND_AND_LOGGED.add(ALGORITHM.digestName())) { Logger.getLogger(getClass()).error(e, GraphI18n.messageDigestNotFound, ALGORITHM.digestName()); } return NO_HASH; } }
protected byte[] computeHash( File file ) { try { return SecureHash.getHash(ALGORITHM, file); } catch (NoSuchAlgorithmException e) { if (ALGORITHMS_NOT_FOUND_AND_LOGGED.add(ALGORITHM.digestName())) { Logger.getLogger(getClass()).error(e, GraphI18n.messageDigestNotFound, ALGORITHM.digestName()); } return NO_HASH; } catch (IOException e) { if (ALGORITHMS_NOT_FOUND_AND_LOGGED.add(ALGORITHM.digestName())) { Logger.getLogger(getClass()).error(e, GraphI18n.messageDigestNotFound, ALGORITHM.digestName()); } return NO_HASH; } }
/** * Close this indexer and release all resources. This method has no effect if it is called when this indexer is alread closed. * * @see #isClosed() */ public void close() { if (closed) return; closed = true; // Close the channel ... try { channel.close(); } finally { // And shut down the executor service ... try { service.shutdown(); service.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { // Log this ... I18n msg = GraphI18n.errorShuttingDownExecutorServiceInSearchEngineIndexer; Logger.getLogger(getClass()).error(msg, sourceName); // Clear the interrupted status of the thread ... Thread.interrupted(); } finally { // Close the search engine processor ... processor.close(); } } }
/** * Method called by {@link #unregister()} that actually does the unregistering. This method is final. */ protected final void doUnregister() { // Unregister this listener from each source ... for (ChangeSourceReference sourceReference : sources) { Observable source = sourceReference.get(); if (source != null) { try { source.unregister(this); } catch (Throwable t) { Logger.getLogger(getClass()).debug(t, "Error while unregistering {0} from {1}", this, source); } } } }
public CallLoadMultipleTimes( int count ) { Logger.getLogger(RepositorySourceLoadHarness.class).debug("Creating repository operation to call {0} times", count); this.count = count; }
/** * Broadcast the supplied changes to the registered observers. * * @param changes the changes to broadcast * @throws IllegalArgumentException if the changes reference is null */ public void broadcast( Changes changes ) { CheckArg.isNotNull(changes, "changes"); for (ObserverReference observerReference : observers) { Observer observer = observerReference.get(); if (observer == null) { observers.remove(observerReference); continue; } try { observer.notify(changes); } catch (Throwable t) { Logger.getLogger(getClass()).debug(t, "Exception while notifying"); } } }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.ValueFactory#create(org.modeshape.graph.property.Binary) */ public String create( Binary value ) throws ValueFormatException, IoException { if (value == null) return null; try { value.acquire(); InputStream stream = value.getStream(); try { return create(stream, value.getSize()); } finally { try { stream.close(); } catch (IOException e) { Logger.getLogger(getClass()).debug(e, "Error closing the stream while converting from Binary to String"); } } } finally { value.release(); } }
/** * {@inheritDoc} * * @see org.modeshape.graph.connector.RepositoryOperation#run(org.modeshape.graph.ExecutionContext, * org.modeshape.graph.connector.RepositoryConnection) */ public Integer run( ExecutionContext context, RepositoryConnection connection ) throws RepositorySourceException { Logger.getLogger(RepositorySourceLoadHarness.class).debug("Running {0} operation", this.getClass().getSimpleName()); int total = count; for (int i = 0; i != count; ++i) { // Add two random numbers ... int int1 = random(this.hashCode() ^ (int)System.nanoTime() * i); if (i % 2 == 0) { Thread.yield(); } connection.execute(context, new ReadNodeRequest(Location.create(RootPath.INSTANCE), "workspace1")); int int2 = random(this.hashCode() ^ (int)System.nanoTime() + i); total += Math.min(Math.abs(Math.max(int1, int2) + int1 * int2 / 3), count); } Logger.getLogger(RepositorySourceLoadHarness.class).debug("Finishing {0} operation", this.getClass().getSimpleName()); return total < count ? total : count; // should really always return count } }
if (!clientPool.awaitTermination(5, TimeUnit.SECONDS)) { String msg = "Unable to shutdown clients after 5 seconds"; Logger.getLogger(RepositorySourceLoadHarness.class).error(MockI18n.passthrough, msg);
@After public void afterEach() throws Exception { service.getAdministrator().shutdown(); service.getAdministrator().awaitTermination(4, TimeUnit.SECONDS); Logger.getLogger(getClass()).trace(""); }
final Logger logger = Logger.getLogger(getClass()); Queue<GarbageCollectedSource> sourcesToGc = new LinkedList<GarbageCollectedSource>(); for (RepositorySource source : getRepositoryLibrary().getSources()) {
Logger.getLogger(getClass()).warn(err, msg, delegate().getName()); composite.setError(err);
protected ModeShapeEngine( ExecutionContext context, ModeShapeConfiguration.ConfigurationDefinition configuration ) { this.problems = new SimpleProblems(); this.logger = Logger.getLogger(getClass());