org.mmbase.module.core
Class MMBase

java.lang.Object
  |
  +--org.mmbase.module.Module
        |
        +--org.mmbase.module.ProcessorModule
              |
              +--org.mmbase.module.core.MMBase
All Implemented Interfaces:
ProcessorInterface

public class MMBase
extends ProcessorModule

The module which provides access to the MMBase database defined by the provided name/setup. It holds the overal object cloud made up of builders, objects and relations and all the needed tools to use them.

Version:
31 januari 2001
Author:
Daniel Ockeloen, Pierre van Rooden, Johan Verelst

Field Summary
 java.lang.String baseName
          Base name for the database to be accessed using this instance of MMBase.
 InsRel InsRel
          Reference to the InsRel builder.
 MMBaseChangeInterface mmc
          Builds a MultiCast Thread to receive and send changes from other MMBase Servers.
 java.util.Hashtable mmobjs
          The table that contains all loaded builders.
static java.lang.String multicasthost
          Defines what 'channel' we are talking to when using multicast.
static int multicastport
          Determines on what port does this multicast talking between nodes take place.
 OAlias OAlias
          Reference to the OALias builder.
 RelDef RelDef
          Reference to the RelDef builder.
 TypeDef TypeDef
          Reference to the TypeDef builder.
 TypeRel TypeRel
          Reference to the TypeRel builder.
 
Constructor Summary
MMBase()
          Constructor to create the MMBase root module.
 
Method Summary
 boolean addLocalObserver(java.lang.String type, MMBaseObserver obs)
          Adds a local observer to a specified builder.
 boolean addRemoteObserver(java.lang.String type, MMBaseObserver obs)
          Adds a remote observer to a specified builder.
 MMObjectNode castNode(MMObjectNode node)
          Deprecated. Not necessary in most cases, with the possible exception of lists obtained from InsRel. However, in the later case using this method is probably too costly.
 void checkUserLevel()
          Checks and switches the user/grouplevel in which MMBase runs.
 void closeConnection(MultiConnection con, java.sql.Statement stmt)
          Safely close a database connection and/or a database statement.
 java.lang.String doGetAgeMarker(java.util.StringTokenizer tok)
          Deprecated. SCAN related, should not be in this module.
 void doProbeRun()
          Callback method, called from MMBaseProbe.
 java.lang.String getAuthType()
          Retrieves the autorisation type.
 java.lang.Object getBaseModule(java.lang.String name)
          Retrieves a (mmbase) module by name.
 java.lang.String getBaseName()
          Retrieves the database base name
 ClusterBuilder getClusterBuilder()
          Returns a reference to the cluster builder.
 MultiConnection getConnection()
          Get a database connection that is multiplexed and checked.
 java.lang.String getCookieDomain()
          Retrieves the cookiedomain (whatever that is) This value is set using the configuration file.
 MMJdbc2NodeInterface getDatabase()
          Returns a reference to the database used.
 int getDBKey()
          Retrieves an unique key to use for a new node's number.
 java.sql.Connection getDirectConnection()
          Get a direct database connection.
 java.lang.String getDTDBase()
          Retrieves the DTD base url.
 java.lang.String getHost()
          Retrieves the host name or ip number This value is set using the configuration file.
 InsRel getInsRel()
          Returns a reference to the InsRel builder.
 java.lang.String getLanguage()
          Retrieves the current language.
 java.lang.String getMachineName()
          Retrieves the machine name.
 MMBaseCop getMMBaseCop()
          Retrieves the loaded security manager(MMBaseCop).
 MMObjectBuilder getMMObject(java.lang.String name)
          Retrieves a specified builder
 java.util.Enumeration getMMObjects()
          Retrieves the loaded builders.
 OAlias getOAlias()
          Returns a reference to the OAlias builder.
 RelDef getRelDef()
          Returns a reference to the RelDef builder.
 java.util.Hashtable getSearchHash(java.util.Vector se, java.lang.String mapper)
          Converts a vector containing nodes to a hashmap, using a specified (unique) integer field as the hash key.
 SendMailInterface getSendMail()
          Retrieves a reference to the sendmail module.
 boolean getState()
          Retrieves whether this mmbase module is running.
 TypeDef getTypeDef()
          Returns a reference to the TypeDef builder.
 TypeRel getTypeRel()
          Returns a reference to the TypeRel builder.
 java.lang.String getWhereList(java.util.Vector se, java.lang.String mapper)
          Converts a vector containing nodes to a comma seperated list of values, obtained from a specified integer field.
 void init()
          Initializes the MMBase module.
 void maintainance()
          Performs periodic maintenance.
 void onload()
          Started when the module is loaded.
 void shutdown()
          unused (?)
 void stop()
          Unused.
 void unload()
          unused (?)
 
Methods inherited from class org.mmbase.module.ProcessorModule
cacheCheck, getList, getListBuilder, getNodeList, process, reload, replace, replace
 
Methods inherited from class org.mmbase.module.Module
getClassName, getInitParameter, getInitParameters, getMaintainer, getMimeType, getMimeTypeFile, getModule, getModule, getModuleInfo, getModules, getName, getProperties, getProperty, getVersion, hasStarted, loadModulesFromDisk, setClassName, setInitParameter, setMaintainer, setName, setVersion, startModule, startModules, state
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

multicasthost

public static java.lang.String multicasthost
Defines what 'channel' we are talking to when using multicast.

multicastport

public static int multicastport
Determines on what port does this multicast talking between nodes take place. This can be set to any port but check if something else on your network is allready using multicast when you have problems.

mmc

public MMBaseChangeInterface mmc
Builds a MultiCast Thread to receive and send changes from other MMBase Servers.

baseName

public java.lang.String baseName
Base name for the database to be accessed using this instance of MMBase. Retrieved from the mmbaseroot module configuration file. If not specified the default is "def1" Should be made private and accessed instead using getBaseName()

TypeDef

public TypeDef TypeDef
Reference to the TypeDef builder. Should be made private and accessed instead using getTypeDef()

RelDef

public RelDef RelDef
Reference to the RelDef builder. Should be made private and accessed instead using getRelDef()

OAlias

public OAlias OAlias
Reference to the OALias builder. Should be made private and accessed instead using getOAlias()

InsRel

public InsRel InsRel
Reference to the InsRel builder. Should be made private and accessed instead using getInsRel()

TypeRel

public TypeRel TypeRel
Reference to the TypeRel builder. Should be made private and accessed instead using getTypeRel()

mmobjs

public java.util.Hashtable mmobjs
The table that contains all loaded builders. Includes virtual builders such as "multirelations". Should be made private and accessed using getMMObjects()
Constructor Detail

MMBase

public MMBase()
Constructor to create the MMBase root module.
Method Detail

init

public void init()
Initializes the MMBase module. Evaluates the parameters loaded from the configuration file. Sets parameters (authorisation, langauge), loads the builders, and starts MultiCasting.
Overrides:
init in class ProcessorModule

onload

public void onload()
Started when the module is loaded. Doesn't do anything (so why bother?)
Overrides:
onload in class ProcessorModule

unload

public void unload()
unused (?)
Overrides:
unload in class ProcessorModule

shutdown

public void shutdown()
unused (?)
Overrides:
shutdown in class ProcessorModule

getMMObject

public MMObjectBuilder getMMObject(java.lang.String name)
Retrieves a specified builder
Parameters:
name - The name of the builder to retrieve
Returns:
a MMObjectBuilder if found, null otherwise

getMMBaseCop

public MMBaseCop getMMBaseCop()
Retrieves the loaded security manager(MMBaseCop).
Returns:
the loaded security manager(MMBaseCop)

getMMObjects

public java.util.Enumeration getMMObjects()
Retrieves the loaded builders.
Returns:
an Enumeration listing the loaded builders

getInsRel

public InsRel getInsRel()
Returns a reference to the InsRel builder.
Returns:
the InsRel builder if defined, null otherwise

getRelDef

public RelDef getRelDef()
Returns a reference to the RelDef builder.
Returns:
the RelDef builder if defined, null otherwise

getTypeDef

public TypeDef getTypeDef()
Returns a reference to the TypeDef builder.
Returns:
the TypeDef builder if defined, null otherwise

getTypeRel

public TypeRel getTypeRel()
Returns a reference to the TypeRel builder.
Returns:
the TypeRel builder if defined, null otherwise

getOAlias

public OAlias getOAlias()
Returns a reference to the OAlias builder.
Returns:
the OAlias builder if defined, null otherwise

getClusterBuilder

public ClusterBuilder getClusterBuilder()
Returns a reference to the cluster builder.
Returns:
an instantiation of the ClusterBuilder

getConnection

public MultiConnection getConnection()
Get a database connection that is multiplexed and checked.
Returns:
a MultiConnection if the connection succeeded, null if it failed.

closeConnection

public void closeConnection(MultiConnection con,
                            java.sql.Statement stmt)
Safely close a database connection and/or a database statement.
Parameters:
con - The connection to close. Can be null.
stmt - The statement to close, prior to closing the connection. Can be null.

getDirectConnection

public java.sql.Connection getDirectConnection()
Get a direct database connection. Should only be used if you want to do database specific things that use non-jdbc interface calls. Use very sparingly.

getBaseName

public java.lang.String getBaseName()
Retrieves the database base name
Returns:
the base name as a String

doProbeRun

public void doProbeRun()
Callback method, called from MMBaseProbe. The probe is a seperate thread taht is created every 10 minutes by the module's maintainance() call.

maintainance

public void maintainance()
Performs periodic maintenance. Starts a separate thread that probes the builders by calling doProbeRun(). The reference to the thread is cleared when it dies (scehduled every 10 minutes), prompting the system to start a new thread.
Overrides:
maintainance in class Module
See Also:
MMBaseProbe

getSearchHash

public java.util.Hashtable getSearchHash(java.util.Vector se,
                                         java.lang.String mapper)
Converts a vector containing nodes to a hashmap, using a specified (unique) integer field as the hash key.
Parameters:
se - The vector containing the nodes
mapper - the name of the (integer) field that determines the hash key, i.e. "number"
Returns:
the node list mapped to a Hashtable

getWhereList

public java.lang.String getWhereList(java.util.Vector se,
                                     java.lang.String mapper)
Converts a vector containing nodes to a comma seperated list of values, obtained from a specified integer field.
Parameters:
se - The vector containing the nodes
mapper - the name of the (integer) field whose value to include in the list
Returns:
a parenthised, comma-seperated list of values, as a String

getSendMail

public SendMailInterface getSendMail()
Retrieves a reference to the sendmail module.
Returns:
a SendMailInterface object if the module was loaded, null otherwise.

getMachineName

public java.lang.String getMachineName()
Retrieves the machine name. This value is set using the configuration file.
Returns:
the machine name as a String

getHost

public java.lang.String getHost()
Retrieves the host name or ip number This value is set using the configuration file.
Returns:
the host name as a String

getCookieDomain

public java.lang.String getCookieDomain()
Retrieves the cookiedomain (whatever that is) This value is set using the configuration file.
Returns:
the cookie domain as a String

addRemoteObserver

public boolean addRemoteObserver(java.lang.String type,
                                 MMBaseObserver obs)
Adds a remote observer to a specified builder. The observer is notified whenever an object of that builder is changed, added, or removed.
Returns:
true if adding the observer succeeded, false otherwise.

addLocalObserver

public boolean addLocalObserver(java.lang.String type,
                                MMBaseObserver obs)
Adds a local observer to a specified builder. The observer is notified whenever an object of that builder is changed, added, or removed.
Returns:
true if adding the observer succeeded, false otherwise.

doGetAgeMarker

public java.lang.String doGetAgeMarker(java.util.StringTokenizer tok)
Deprecated. SCAN related, should not be in this module.

Returns the number of marked days from a specified daycount (?)

getDBKey

public int getDBKey()
Retrieves an unique key to use for a new node's number. Calls the database to request the key. Sychronized so the same number cannot be dealt out to different nodes. Does possibly not work well with multiple mmbase systems that work on the same database.
Returns:
the new unique key as an int value

getBaseModule

public java.lang.Object getBaseModule(java.lang.String name)
Retrieves a (mmbase) module by name. # @return the module as an Object if it exists, null otherwise

stop

public void stop()
Unused.

getDTDBase

public java.lang.String getDTDBase()
Retrieves the DTD base url. This value is set using the configuration file.
Returns:
the dtd base as a String

getDatabase

public MMJdbc2NodeInterface getDatabase()
Returns a reference to the database used. If needed, it loads the appropriate support class using the configuration parameters.
Returns:
a MMJdbc2NodeInterface which holds the appropriate database class

castNode

public MMObjectNode castNode(MMObjectNode node)
Deprecated. Not necessary in most cases, with the possible exception of lists obtained from InsRel. However, in the later case using this method is probably too costly.

Loads a Node again, using its 'right' parent. Reloading may retrieve extra fields if teh originalw a snot loaded accurately.

getAuthType

public java.lang.String getAuthType()
Retrieves the autorisation type. This value is set using the configuration file. Examples are 'none' or 'basic'.
Returns:
a String identifying the type

getLanguage

public java.lang.String getLanguage()
Retrieves the current language. This value is set using the configuration file. Examples are 'us' or 'nl'.
Returns:
the language as a String

getState

public boolean getState()
Retrieves whether this mmbase module is running.
Returns:
true if the module has been initialized and all builders loaded, false otherwise.

checkUserLevel

public void checkUserLevel()
Checks and switches the user/grouplevel in which MMBase runs. The userlevel is set using the -Dmmbase:userlevel=user:group commandline parameter. Should probably be changed to private.


MMBase 2001