com.planet_ink.coffee_mud.core.threads
Class ServiceEngine

java.lang.Object
  extended by com.planet_ink.coffee_mud.core.threads.ServiceEngine
All Implemented Interfaces:
CMObject, CMLibrary, ThreadEngine, java.lang.Cloneable, java.lang.Comparable<CMObject>, java.lang.Runnable

public class ServiceEngine
extends java.lang.Object
implements ThreadEngine


Field Summary
protected  java.util.List<TickableGroup> allTicks
           
static long STATUS_ALLMISCTICKS
           
 
Constructor Summary
ServiceEngine()
           
 
Method Summary
 boolean activate()
          Activates the library.
protected  void addTickGroup(TickableGroup tock)
           
 void checkHealth()
           
 void clearDebri(Room room, int taskCode)
           
 int compareTo(CMObject o)
           
 CMObject copyOf()
          Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.
 void debugDumpStack(java.lang.String ID, java.lang.Thread theThread)
           
protected static void debugDumpThreadGroup(java.lang.ThreadGroup tGroup, java.lang.StringBuilder lines)
           
 boolean deleteAllTicks(Tickable ticker)
           
 boolean deleteTick(Tickable E, int tickID)
           
protected  void delTickGroup(TickableGroup tock)
           
 void executeRunnable(java.lang.Runnable R)
           
 void executeRunnable(java.lang.String threadGroupName, java.lang.Runnable R)
           
 java.lang.Runnable findRunnableByThread(java.lang.Thread thread)
           
 int getMaxObjectsPerThread()
           
 java.util.List<Tickable> getNamedTickingObjects(java.lang.String name)
           
protected  CMThreadPoolExecutor getPoolExecutor(char threadGroupNum)
           
protected  CMThreadPoolExecutor getPoolExecutor(java.lang.String threadGroupName)
           
 TickClient getServiceClient()
          If this library has a service thread, this method returns the TickClient object associated with that service.
 long getTicksEllapsedSinceStartup()
           
 java.lang.String getTickStatusSummary(Tickable obj)
           
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 void initializeClass()
          Called ONCE after all objects are loaded, but before the map is read in during initialization.
 void insertOrderDeathInOrder(DVector DV, long lastStart, java.lang.String msg, TickableGroup tock)
           
 boolean isAllSuspended()
           
 boolean isSuspended(Tickable E, int tickID)
           
 boolean isTicking(Tickable E, int tickID)
           
 java.lang.String L(java.lang.String str, java.lang.String... xs)
          Localize an internal string -- shortcut.
 long msToNextTick(Tickable E, int tickID)
           
 java.lang.String name()
          The displayable name of this object.
 CMObject newInstance()
          Returns a new instance of this class.
static void panicDumpAllThreads()
           
 void propertiesLoaded()
          This method is called whenever system properties are altered by the user.
 void rejuv(Room here, int tickID)
           
 void resumeAll()
           
 void resumeTicking(Tickable E, int tickID)
           
 void run()
           
 void scheduleRunnable(java.lang.Runnable R, long ellapsedMs)
           
 void setSupportStatus(java.lang.String s)
           
 boolean setTickPending(Tickable E, int tickID)
           
 boolean shutdown()
          Shuts down the library.
 TickClient startTickDown(java.lang.ThreadGroup group, Tickable E, int tickID, long tickTime, int numTicks)
           
 TickClient startTickDown(Tickable E, int tickID, int numTicks)
           
 TickClient startTickDown(Tickable E, int tickID, long TICK_TIME, int numTicks)
           
 void suspendAll(CMRunnable[] exceptRs)
           
 void suspendResumeRecurse(CMObject O, boolean skipEmbeddedAreas, boolean suspend)
           
protected  boolean suspendResumeTicking(Tickable E, int tickID, boolean suspend)
           
 void suspendTicking(Tickable E, int tickID)
           
 java.lang.String systemReport(java.lang.String itemCode)
           
 void tickAllTickers(Room here)
           
 java.util.Iterator<TickableGroup> tickGroups()
           
 java.lang.String tickInfo(java.lang.String which)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_ALLMISCTICKS

public static final long STATUS_ALLMISCTICKS
See Also:
Constant Field Values

allTicks

protected java.util.List<TickableGroup> allTicks
Constructor Detail

ServiceEngine

public ServiceEngine()
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, Tech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Returns:
the name of this class

name

public java.lang.String name()
Description copied from interface: CMObject
The displayable name of this object. May be modified by phyStats() object. Is derived from the Name().

Specified by:
name in interface CMObject
Returns:
the modified final name of this object on the map.
See Also:
Environmental.Name()

newInstance

public CMObject newInstance()
Description copied from interface: CMObject
Returns a new instance of this class.

Specified by:
newInstance in interface CMObject
Returns:
a new instance of this class

L

public java.lang.String L(java.lang.String str,
                          java.lang.String... xs)
Description copied from interface: CMLibrary
Localize an internal string -- shortcut. Same as calling:

Specified by:
L in interface CMLibrary
Parameters:
str - the string to translate
xs - the array of variables to replace
Returns:
the translated string, with all variables in place
See Also:
Call with the string to translate, which may contain variables of the form @x1, @x2, etc. The array in xs is then used to replace the variables AFTER the string is translated.

initializeClass

public void initializeClass()
Description copied from interface: CMObject
Called ONCE after all objects are loaded, but before the map is read in during initialization.

Specified by:
initializeClass in interface CMObject

copyOf

public CMObject copyOf()
Description copied from interface: CMObject
Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.

Specified by:
copyOf in interface CMObject
Returns:
a clone of this object

compareTo

public int compareTo(CMObject o)
Specified by:
compareTo in interface java.lang.Comparable<CMObject>

propertiesLoaded

public void propertiesLoaded()
Description copied from interface: CMLibrary
This method is called whenever system properties are altered by the user. This allows the library to react to any important properties they monitor.

Specified by:
propertiesLoaded in interface CMLibrary

getServiceClient

public TickClient getServiceClient()
Description copied from interface: CMLibrary
If this library has a service thread, this method returns the TickClient object associated with that service. Normally returns null, since most libraries don't set themselves up to receive thread time.

Specified by:
getServiceClient in interface CMLibrary
Returns:
null, or the TickClient for the service
See Also:
TickClient

getPoolExecutor

protected CMThreadPoolExecutor getPoolExecutor(char threadGroupNum)

getPoolExecutor

protected CMThreadPoolExecutor getPoolExecutor(java.lang.String threadGroupName)

tickGroups

public java.util.Iterator<TickableGroup> tickGroups()
Specified by:
tickGroups in interface ThreadEngine

findRunnableByThread

public java.lang.Runnable findRunnableByThread(java.lang.Thread thread)
Specified by:
findRunnableByThread in interface ThreadEngine

scheduleRunnable

public void scheduleRunnable(java.lang.Runnable R,
                             long ellapsedMs)
Specified by:
scheduleRunnable in interface ThreadEngine

executeRunnable

public void executeRunnable(java.lang.String threadGroupName,
                            java.lang.Runnable R)
Specified by:
executeRunnable in interface ThreadEngine

executeRunnable

public void executeRunnable(java.lang.Runnable R)
Specified by:
executeRunnable in interface ThreadEngine

getMaxObjectsPerThread

public int getMaxObjectsPerThread()

getTicksEllapsedSinceStartup

public long getTicksEllapsedSinceStartup()
Specified by:
getTicksEllapsedSinceStartup in interface ThreadEngine

delTickGroup

protected void delTickGroup(TickableGroup tock)

addTickGroup

protected void addTickGroup(TickableGroup tock)

startTickDown

public TickClient startTickDown(Tickable E,
                                int tickID,
                                int numTicks)
Specified by:
startTickDown in interface ThreadEngine

startTickDown

public TickClient startTickDown(Tickable E,
                                int tickID,
                                long TICK_TIME,
                                int numTicks)
Specified by:
startTickDown in interface ThreadEngine

startTickDown

public TickClient startTickDown(java.lang.ThreadGroup group,
                                Tickable E,
                                int tickID,
                                long tickTime,
                                int numTicks)

deleteTick

public boolean deleteTick(Tickable E,
                          int tickID)
Specified by:
deleteTick in interface ThreadEngine

setTickPending

public boolean setTickPending(Tickable E,
                              int tickID)
Specified by:
setTickPending in interface ThreadEngine

msToNextTick

public long msToNextTick(Tickable E,
                         int tickID)
Specified by:
msToNextTick in interface ThreadEngine

isTicking

public boolean isTicking(Tickable E,
                         int tickID)
Specified by:
isTicking in interface ThreadEngine

isAllSuspended

public boolean isAllSuspended()
Specified by:
isAllSuspended in interface ThreadEngine

suspendAll

public void suspendAll(CMRunnable[] exceptRs)
Specified by:
suspendAll in interface ThreadEngine

resumeAll

public void resumeAll()
Specified by:
resumeAll in interface ThreadEngine

suspendTicking

public void suspendTicking(Tickable E,
                           int tickID)
Specified by:
suspendTicking in interface ThreadEngine

resumeTicking

public void resumeTicking(Tickable E,
                          int tickID)
Specified by:
resumeTicking in interface ThreadEngine

suspendResumeTicking

protected boolean suspendResumeTicking(Tickable E,
                                       int tickID,
                                       boolean suspend)

isSuspended

public boolean isSuspended(Tickable E,
                           int tickID)
Specified by:
isSuspended in interface ThreadEngine

systemReport

public java.lang.String systemReport(java.lang.String itemCode)
Specified by:
systemReport in interface ThreadEngine

rejuv

public void rejuv(Room here,
                  int tickID)
Specified by:
rejuv in interface ThreadEngine

tickAllTickers

public void tickAllTickers(Room here)
Specified by:
tickAllTickers in interface ThreadEngine

suspendResumeRecurse

public void suspendResumeRecurse(CMObject O,
                                 boolean skipEmbeddedAreas,
                                 boolean suspend)
Specified by:
suspendResumeRecurse in interface ThreadEngine

deleteAllTicks

public boolean deleteAllTicks(Tickable ticker)
Specified by:
deleteAllTicks in interface ThreadEngine

tickInfo

public java.lang.String tickInfo(java.lang.String which)
Specified by:
tickInfo in interface ThreadEngine

shutdown

public boolean shutdown()
Description copied from interface: CMLibrary
Shuts down the library. Called at system shutdown time obviously, but is sometimes called just to reset the library.

Specified by:
shutdown in interface CMLibrary
Returns:
true if shutdown was successful, false if there's nothing you can do about it
See Also:
CMLibrary.activate()

clearDebri

public void clearDebri(Room room,
                       int taskCode)
Specified by:
clearDebri in interface ThreadEngine

getNamedTickingObjects

public java.util.List<Tickable> getNamedTickingObjects(java.lang.String name)
Specified by:
getNamedTickingObjects in interface ThreadEngine

getTickStatusSummary

public java.lang.String getTickStatusSummary(Tickable obj)
Specified by:
getTickStatusSummary in interface ThreadEngine

insertOrderDeathInOrder

public void insertOrderDeathInOrder(DVector DV,
                                    long lastStart,
                                    java.lang.String msg,
                                    TickableGroup tock)

setSupportStatus

public void setSupportStatus(java.lang.String s)

debugDumpStack

public void debugDumpStack(java.lang.String ID,
                           java.lang.Thread theThread)
Specified by:
debugDumpStack in interface ThreadEngine

debugDumpThreadGroup

protected static void debugDumpThreadGroup(java.lang.ThreadGroup tGroup,
                                           java.lang.StringBuilder lines)

checkHealth

public final void checkHealth()

run

public void run()
Specified by:
run in interface java.lang.Runnable

activate

public boolean activate()
Description copied from interface: CMLibrary
Activates the library. This is called after the mud is booted, but before connections are accepted.

Specified by:
activate in interface CMLibrary
Returns:
true if activation was successful, false if you're screwed
See Also:
CMLibrary.shutdown()

panicDumpAllThreads

public static void panicDumpAllThreads()