|
Oracle Fusion Middleware Java API Reference for Oracle ADF Model 11g Release 1 (11.1.1.9.0) E52932-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.adfinternal.model.logging.contextual.ContextualLoggingManager<L>
L
- The specific BasicContextualLogger
implementation to be used by the manager, as determined by the managed logging domain.public class ContextualLoggingManager<L extends BasicContextualLogger>
This is the central component of the contextual logging framework.
Instances of the manager are accessed by providing a valid LogDomain to getInstance(LogDomain)
. There will be 1 single manager instance per LogDomain and each instance will be lazily created, on demand, and will be stored in the ADFContext's scope defined in the LogDomain.
The main purpose of this manager is to keep track of the contextual loggers created for each LogDomain. New loggers must be created via method openLogger(LoggerProvider)
and will be immediately stacked in the manager, obeying the LIFO storage method. Therefore, the lastly created logger will always be the current, which may be accessed via getCurrentLogger()
. A call to closeCurrentLogger()
will trigger a call to BasicContextualLogger.close()
on the current logger and will also cause it to be removed from the top of the logger stack maintained by the manager, thus promoting its precursor to current, if any.
It is important and expected that consumers will be responsible for matching every call to method openLogger with a corresponding call to closeCurrentLogger()
.
This component should allow consumers to easily define the logger to be used by multiple methods and/or classes throughout the flow delimited by latest matching calls to openLogger and closeCurrentLogger.
Bellow is an example of the recommended use pattern:
public class MyClass
{
public static final LogDomain<ContextualLogger> domain = new LogDomain<ContextualLogger>("My Domain", "foo.bar");
public void method1()
{LoggerProvider<ContextualLogger> provider = new LoggerProvider<ContextualLogger>(domain, "foo.bar.log1");
CurrentLoggingManager<ContextualLogger> mgr = CurrentLoggingManager.getInstance(domain);
try
{Util.method2();
}
finally
{mgr.closeCurrentLogger();
}
}
}
public class Util
{
public void method2()
{CurrentLoggingManager<ContextualLogger> mgr = CurrentLoggingManager.getInstance(MyClass.domain);
ContextualLogger logger = mgr.getCurrentLogger(); logger.info("I'm logging using the current contextual logger");}
}
LogDomain
, LoggerProvider
Method Summary | ||
---|---|---|
void |
closeAllLoggers() Close all managed loggers that might still be open. |
|
void |
closeCurrentLogger() Close the current logger, if any, remove it from the internal logger stack and promote the precursor logger to current, if any. |
|
L |
getCurrentLogger() Get the current logger, resulting from the last call to openLogger(oracle.adfinternal.model.logging.contextual.LoggerProvider<L>) . |
|
LogDomain<L> |
getDomain() Get the logging domain managed by this manager. |
|
static
|
getInstance(LogDomain<L> domain) Get the right manager instance for the given domain. |
|
L |
openLogger(LoggerProvider<L> provider) This method will use the given provider to create a new logger of the given type L and immediately set it as current. |
|
java.lang.String |
toString() Will return the key used to store the manager in the ADFContext's scope defined by its managed logging domain. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public final LogDomain<L> getDomain()
public final L openLogger(LoggerProvider<L> provider)
provider
- The logger provider which will be used to create the new loggerjava.lang.IllegalArgumentException
- If the given provider does not belong to the managed logging domainpublic final void closeCurrentLogger()
public final L getCurrentLogger()
openLogger(oracle.adfinternal.model.logging.contextual.LoggerProvider<L>)
.public final void closeAllLoggers()
As a best practice, we recommend calling this method in a finally block in the code that controls the life cycle where this manager is inserted. This will make sure that any pending end/close messages will be properly published in the right sequence.
In the most common use case, when the manager instance will be stored in ADFContext's request scope, this method will be called automatically by the framework whenever the scope gets invalidated. This will actually be true for any other container-managed scope implementing ADFScope
.
public java.lang.String toString()
toString
in class java.lang.Object
public static <L extends BasicContextualLogger> ContextualLoggingManager<L> getInstance(LogDomain<L> domain)
L
- The type of ContextualLogger associated with the domaindomain
- The logging domain to be managed. When null, this method will also return null.
|
Oracle Fusion Middleware Java API Reference for Oracle ADF Model 11g Release 1 (11.1.1.9.0) E52932-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |