de.fhg.igd.logging.sun
Class URLHandler

java.lang.Object
  extended byjava.util.logging.Handler
      extended byde.fhg.igd.logging.sun.URLHandler
All Implemented Interfaces:
Forwarder

public class URLHandler
extends Handler
implements Forwarder

Depending on the configured buffer size, this Handler will open a URLOutputStream which will be linked into either a simple StreamHandler or an AsynchronousStreamHandler which is being wrapped by this class. On dynamic configuration changes, this wrapped Handler might get exchanged accordingly.

Version:
"$Id: URLHandler.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Matthias Pressfreund

Field Summary
protected  Integer buffersize_
          The buffer size
private static Set cache_
          The storage for deployed URLHandler objects
private  Chronometer cm_
          The Chronometer that is assigned to the output destination of this Handler
private  int cnt_
          The reference counter
protected  StreamHandler sh_
          The wrapped target StreamHandler
 
Fields inherited from class java.util.logging.Handler
 
Constructor Summary
protected URLHandler(Chronometer cm)
          Hidden URLHandler construction.
 
Method Summary
 void close()
          This method will close underlying streams, remove this Handler from the cache in case no further reference exists.
private static StreamHandler createTarget(OutputStream os, Formatter formatter, int bufsize)
          Create the target StreamHandler.
 boolean equals(Object obj)
           
(package private) static URLHandler findFor(Chronometer cm)
          Find a URLHandler instance that has already been created before.
 void flush()
           
 Integer getBufferSize()
          Get the size of the internal message buffer.
 URL getOutputDestination()
          Get the output destination URL.
 int hashCode()
           
 void publish(LogRecord record)
          Hand over a record to the target Handler.
(package private) static URLHandler requestFor(Chronometer cm)
          Request a URLHandler.
 String toString()
           
 void updateBufferSize(Integer buffersize)
          Update the size of the internal message buffer.
 
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

cache_

private static Set cache_
The storage for deployed URLHandler objects


cnt_

private int cnt_
The reference counter


cm_

private Chronometer cm_
The Chronometer that is assigned to the output destination of this Handler


buffersize_

protected Integer buffersize_
The buffer size


sh_

protected StreamHandler sh_
The wrapped target StreamHandler

Constructor Detail

URLHandler

protected URLHandler(Chronometer cm)
Hidden URLHandler construction.

Parameters:
cm - The Chronometer that is assigned to the URL to create the Handler for
Throws:
LoggingException - if creating the corresponding URLOutputStream failed
Method Detail

requestFor

static URLHandler requestFor(Chronometer cm)
Request a URLHandler. In case the requested instance has been created before, a reference to the existing instance will be returned and counted.

Parameters:
cm - The Chronometer that is assigned to the URL that the Handler is requested for
Returns:
The requested Handler object

findFor

static URLHandler findFor(Chronometer cm)
Find a URLHandler instance that has already been created before. If no instance could be found for the given URL, null will be returned.

Parameters:
cm - The Chronometer that is assigned to the URL to find the corresponding Handler for
Returns:
The requested URLHandler or null if no instance for the given Chronometer has been created yet

createTarget

private static StreamHandler createTarget(OutputStream os,
                                          Formatter formatter,
                                          int bufsize)
Create the target StreamHandler.

Parameters:
os - The underlying output stream
formatter - The log record formatter
bufsize - The size of the internal message buffer

publish

public void publish(LogRecord record)
Hand over a record to the target Handler.

Parameters:
record - The log record to be published

flush

public void flush()

close

public void close()
This method will close underlying streams, remove this Handler from the cache in case no further reference exists.


getOutputDestination

public URL getOutputDestination()
Description copied from interface: Forwarder
Get the output destination URL.

Specified by:
getOutputDestination in interface Forwarder
Returns:
The output destination

getBufferSize

public Integer getBufferSize()
Description copied from interface: Forwarder
Get the size of the internal message buffer. For buffer sizes greater than zero, messages are dispatched asynchronously.

Specified by:
getBufferSize in interface Forwarder
Returns:
The internal message buffer size

updateBufferSize

public void updateBufferSize(Integer buffersize)
                      throws LoggingException
Description copied from interface: Forwarder
Update the size of the internal message buffer. For buffer sizes greater than zero, messages will be dispatched asynchronously.

Specified by:
updateBufferSize in interface Forwarder
Parameters:
buffersize - The new size of the internal message buffer
Throws:
LoggingException - in case updating the message buffer size failed

equals

public boolean equals(Object obj)

hashCode

public int hashCode()

toString

public String toString()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.