Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.scoja.server.source
Class Internal  view Internal download Internal.java

java.lang.Object
  extended byorg.scoja.server.core.LinkableAtPython
      extended byorg.scoja.server.core.FullLinkAtPython
          extended byorg.scoja.server.core.Link
              extended byorg.scoja.server.source.Internal
All Implemented Interfaces:
org.scoja.server.core.DecoratedLink, org.scoja.server.core.Linkable

public class Internal
extends org.scoja.server.core.Link

This is the source of internal events. It is a singleton. At configuration scripts, it is accesible through "internal" variable. All scripts see the same object; so, it is only necessary to configure its logging (filters + targets) at one script.

Logging at Scoja library should use this singleton. This logging class use a trick to avoid endless chains of internal events. As an inevitable side effect, this trick can cut the generation of some internal logs. It is important to read carefully this class documentation.

Energy There are two kinds of threads at Scoja. More frecuent and active threads are those that process events. But threre are a few threads that do other activies, not directly related to event processing. For instance, the thread that check whether configurations files has changed. When event A processing produce an internal event B, we say that A is guilty or referece event of B.

Most internal events are generated at event (external or internal) processing threads. So, it is possible that processing an internal event produce another similar internal event, that produce another similar event, and so on. To avoid this endless event chains, every event has an energy. When an event E1 produces an internal event E2, this class ensures that E2 its more critical than E1 (its level is strict less than E1 level) or than its energy is one less than E1 energy. Each time that an event produces another event, at least one of level or energy is decreased. So, there is no way to produce an endless chain of events.

Sometimes, an event processing thread is executing a code that wants to produce an internal event but has no way to access to the event currently been processing. This is no problem, because event processing threads are not normal Thread but org.scoja.server.core.ScojaThread. These special threads always referer to the event they are processing. This class has methods with and without explicit event that is currenlty been processed; when a method without this argument is used, the current thread is explored to find out the current event.

Internal events produced by non-event-processing threads are the only one that have no guilty event. But this events cannot produce an endless chain of events because other internal events produced during processing this internal event will have a guilty.

Easy methods To make code short an more readable, static methods for every level are defined. There are two versions: with and without reference event. Version with reference event should be used whenever possible.

Statically removing unimportant internal events Internals events to levels less critical than PriorityUtils.NOTICE>PriorityUtils.NOTICE 55 (not included) should be statically removable, to enhance performance. So, when sending to PriorityUtils.INFO>PriorityUtils.INFO 55 and PriorityUtils.DEBUG>PriorityUtils.DEBUG 55 , it is necessary to nest the calls inside a conditional like:

 if (pretendedLevel <= Internal.LOG_DETAIL) {
     Internal.getInstance().log(guiltyEvent, pretendedLevel, "Message");
 }
 
For instance:
   if (PriorityUtils.DEBUG <= Internal.LOG_DETAIL) {
       Internal.getInstance().log(env, PriorityUtils.DEBUG, "Message");
   }
 
or better:
   if (PriorityUtils.DEBUG <= Internal.LOG_DETAIL) {
       Internal.debug(env, "Message");
   }
 


Field Summary
private static Internal internal
           
protected  java.net.InetAddress localhost
           
static int LOG_DETAIL
           
 
Fields inherited from class org.scoja.server.core.Link
queue, targets, used
 
Constructor Summary
private Internal()
           
 
Method Summary
static void alert(org.scoja.server.core.EventContext env, java.lang.String message)
           
static void alert(java.lang.String message)
           
static void crit(org.scoja.server.core.EventContext env, java.lang.String message)
           
static void crit(java.lang.String message)
           
static void debug(org.scoja.server.core.EventContext env, java.lang.String message)
           
static void debug(java.lang.String message)
           
static void emerg(org.scoja.server.core.EventContext env, java.lang.String message)
           
static void emerg(java.lang.String message)
           
static void err(org.scoja.server.core.EventContext env, java.lang.String message)
           
static void err(java.lang.String message)
           
static Internal getInstance()
           
static void info(org.scoja.server.core.EventContext env, java.lang.String message)
           
static void info(java.lang.String message)
           
 void log(org.scoja.server.core.EventContext guilty, int level, java.lang.String message)
           
 void log(int energy, int level, java.lang.String message)
           
 void log(int level, java.lang.String message)
           
static void notice(org.scoja.server.core.EventContext env, java.lang.String message)
           
static void notice(java.lang.String message)
           
static void warning(org.scoja.server.core.EventContext env, java.lang.String message)
           
static void warning(java.lang.String message)
           
 
Methods inherited from class org.scoja.server.core.Link
addSimpleSource, addSimpleTarget, addTarget, getLinkable, getTargetSize, process, propagate, removeTarget, setQueue
 
Methods inherited from class org.scoja.server.core.FullLinkAtPython
__or__
 
Methods inherited from class org.scoja.server.core.LinkableAtPython
__rshift__
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

internal

private static final Internal internal

LOG_DETAIL

public static final int LOG_DETAIL
See Also:
Constant Field Values

localhost

protected final java.net.InetAddress localhost
Constructor Detail

Internal

private Internal()
          throws java.net.UnknownHostException
Method Detail

getInstance

public static Internal getInstance()

log

public void log(int level,
                java.lang.String message)

log

public void log(org.scoja.server.core.EventContext guilty,
                int level,
                java.lang.String message)

log

public void log(int energy,
                int level,
                java.lang.String message)

emerg

public static void emerg(org.scoja.server.core.EventContext env,
                         java.lang.String message)

emerg

public static void emerg(java.lang.String message)

alert

public static void alert(org.scoja.server.core.EventContext env,
                         java.lang.String message)

alert

public static void alert(java.lang.String message)

crit

public static void crit(org.scoja.server.core.EventContext env,
                        java.lang.String message)

crit

public static void crit(java.lang.String message)

err

public static void err(org.scoja.server.core.EventContext env,
                       java.lang.String message)

err

public static void err(java.lang.String message)

warning

public static void warning(org.scoja.server.core.EventContext env,
                           java.lang.String message)

warning

public static void warning(java.lang.String message)

notice

public static void notice(org.scoja.server.core.EventContext env,
                          java.lang.String message)

notice

public static void notice(java.lang.String message)

info

public static void info(org.scoja.server.core.EventContext env,
                        java.lang.String message)

info

public static void info(java.lang.String message)

debug

public static void debug(org.scoja.server.core.EventContext env,
                         java.lang.String message)

debug

public static void debug(java.lang.String message)