org.mmbase.module.core
Class MMBase

java.lang.Object
  extended byorg.mmbase.util.functions.FunctionProvider
      extended byorg.mmbase.module.Module
          extended byorg.mmbase.module.ProcessorModule
              extended byorg.mmbase.module.core.MMBase
All Implemented Interfaces:
ProcessorInterface

public class MMBase
extends ProcessorModule

The module which provides access to the MMBase storage 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:
$Id: MMBase.java,v 1.200 2006/07/15 10:28:15 michiel Exp $
Author:
Daniel Ockeloen, Pierre van Rooden, Johannes Verelst, Ernst Bunders

Nested Class Summary
 
Nested classes inherited from class org.mmbase.module.ProcessorModule
ProcessorModule.GetNodeListFunction, ProcessorModule.ProcessFunction, ProcessorModule.ReplaceFunction
 
Field Summary
 String baseName
          Base name for the storage to be accessed using this instance of MMBase.
static int startTime
          Time in seconds, when mmbase was started.
 
Fields inherited from class org.mmbase.module.ProcessorModule
PARAM_PAGEINFO, PARAMS_PAGEINFO
 
Fields inherited from class org.mmbase.module.Module
getMaintainerFunction, getVersionFunction
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions, getFunctions
 
Constructor Summary
MMBase()
          Constructor to create the MMBase root module.
 
Method Summary
 MMObjectBuilder addBuilder(String name, MMObjectBuilder bul)
           
 boolean addLocalObserver(String type, MMBaseObserver obs)
          Adds a local observer to a specified builder.
 void addNodeRelatedEventsListener(String builder, EventListener listener)
          This is a conveniance method to help you register listeners to node and relation events.
 boolean addRemoteObserver(String type, MMBaseObserver obs)
          Adds a remote observer to a specified builder.
protected  void assertUp()
          Locks until init of mmbase is finished.
 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.
 String doGetAgeMarker(StringTokenizer tok)
          Deprecated. SCAN related, should not be in this module.
 String getAuthType()
          Retrieves the autorisation type.
 String getBaseName()
          Retrieves the storage base name
 MMObjectBuilder getBuilder(String name)
          Retrieves a specified builder.
 MMObjectBuilder getBuilderForNode(int number)
           
 ResourceLoader getBuilderLoader()
           
 String getBuilderNameForNode(int number)
           
 String getBuilderPath(String builderName, String path)
          Locate one specific builder within a given path, relative to the main builder config path, including sub-paths.
 BuilderReader getBuilderReader(String builderName)
           
 Collection getBuilders()
          Retrieves a Collection of loaded builders.
 ClusterBuilder getClusterBuilder()
          Returns a reference to the cluster builder, a virtual builder used to perform multilevel searches.
 int getDBKey()
          Deprecated. use getStorageManager().createKey()
 String getDTDBase()
          Deprecated. keesj: This method is not used. Document type definitions should contain a fully qualified url. I think the author was thinking of a dtdpath wich makes sence
 String getEncoding()
          Retrieves the encoding.
 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.
 String getLanguage()
          Retrieves the current language.
 Locale getLocale()
          Retrieves the current locale.
 String getMachineName()
          Retrieves the machine name.
static MMBase getMMBase()
          Retrieves the MMBase module('mmbaseroot').
 MMBaseCop getMMBaseCop()
          Retrieves the loaded security manager(MMBaseCop).
 MMObjectBuilder getMMObject(String name)
          Retrieves a specified builder.
 Enumeration getMMObjects()
          Deprecated. use getBuilders()
 OAlias getOAlias()
          Returns a reference to the OAlias builder.
 RelDef getRelDef()
          Returns a reference to the RelDef builder.
 MMObjectBuilder getRootBuilder()
          Returns a reference to the Object builder.
 int getRootType()
          Returns the otype of the Object builder, or -1 if it is not known.
 Hashtable getSearchHash(Vector se, String mapper)
          Converts a vector containing nodes to a hashmap, using a specified (unique) integer field as the hash key.
 SearchQueryHandler getSearchQueryHandler()
          Returns a SearchQueryHandler to access the storage..
 SendMailInterface getSendMail()
          Deprecated. use getModule("sendmail") instead SendMail will become a separate application. In MMBase 1.8. this method will be removed
 boolean getState()
          Retrieves whether this mmbase module is running.
 StorageManager getStorageManager()
          Returns a StorageManager to access the storage..
 StorageManagerFactory getStorageManagerFactory()
          Returns StorageManagerFactory class used to access the storage configuration.
 TimeZone getTimeZone()
          Retrieves the timezone asociated with this MMBase's 'DateTime' objects.
 TypeDef getTypeDef()
          Returns a reference to the TypeDef builder.
 TypeRel getTypeRel()
          Returns a reference to the TypeRel builder.
 String getWhereList(Vector se, String mapper)
          Converts a vector containing nodes to a comma seperated list of values, obtained from a specified integer field.
 boolean inDevelopment()
          Returns true when MMBase is in development mode.
 void init()
          Initalizes the MMBase module.
 void initBuilder(MMObjectBuilder builder)
          inits a builder
protected  void initializeStorage()
          Loads either the storage manager factory or the appropriate support class using the configuration parameters.
 boolean isShutdown()
           
 MMObjectBuilder loadBuilderFromXML(String builderName, String ipath)
          Create a new builder object using a xml configfile located in a given path relative to the main builder config path, and return the builder object.
 void maintainance()
          Performs periodic maintenance.
 void removeNodeRelatedEventsListener(String builder, EventListener listener)
           
protected  void shutdown()
          Shuts down the module.
 void unloadBuilder(MMObjectBuilder builder)
          Unloads a builders from MMBase.
 
Methods inherited from class org.mmbase.module.ProcessorModule
cacheCheck, getList, getListBuilder, getNodeList, onload, process, reload, replace, replace, unload
 
Methods inherited from class org.mmbase.module.Module
getInitParameter, getInitParameters, getMaintainer, getModule, getModule, getModuleInfo, getModuleLoader, getModuleReader, getModules, getName, getProperties, getProperty, getVersion, hasStarted, setInitParameter, setMaintainer, setName, setVersion, shutdownModules, startModule, startModules, state
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue, newFunctionInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startTime

public static final int startTime
Time in seconds, when mmbase was started.

Since:
MMBase-1.7

baseName

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

Warning: Scope will be changed to:
private
Constructor Detail

MMBase

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

Method Detail

init

public void init()
Initalizes the MMBase module. Evaluates the parameters loaded from the configuration file. Sets parameters (authorisation, language), loads the builders, and starts MultiCasting.

Overrides:
init in class ProcessorModule

shutdown

protected void shutdown()
Description copied from class: Module
Shuts down the module. This method is called by shutdownModules.

Overrides:
shutdown in class Module

isShutdown

public boolean isShutdown()
Since:
MMBase-1.7

inDevelopment

public boolean inDevelopment()
Returns true when MMBase is in development mode. This can be used to determine behavior with regards to common errors, such as whether or not to throw an exception when a non-existing field in a buidler is referenced. The value for this property ('true' or 'false') can be set in the "development" property in the mmbaseroot.xml configuration file. The default value is false.

Since:
MMBase-1.8.1

getBuilder

public MMObjectBuilder getBuilder(String name)
                           throws CircularReferenceException
Retrieves a specified builder. If the builder is not loaded, but the system is in the 'startup' state (i.e. it is in the process of loading builders), an attempt is made to directly load the builder. This allows for dependencies between builders to exist (i.e. inheritance). When circular reference occurs between two loading buidlers, an exception is thrown.

Parameters:
name - The name of the builder to retrieve
Returns:
a MMObjectBuilder for the specified builder
Throws:
CircularReferenceException - when circular reference is detected
BuilderConfigurationException - if the builder config file does not exist
Since:
MMBase-1.6

getBuilderNameForNode

public String getBuilderNameForNode(int number)

getBuilderForNode

public MMObjectBuilder getBuilderForNode(int number)

addBuilder

public MMObjectBuilder addBuilder(String name,
                                  MMObjectBuilder bul)
Since:
MMBase-1.8

getMMObject

public MMObjectBuilder getMMObject(String name)
Retrieves a specified builder. Note: may get deprecated in the future - use getBuilder instead.

Parameters:
name - The name of the builder to retrieve
Returns:
a MMObjectBuilder if found, null otherwise

getMMBase

public static MMBase getMMBase()
Retrieves the MMBase module('mmbaseroot').

Returns:
the active MMBase module

getMMBaseCop

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

Returns:
the loaded security manager(MMBaseCop)

getMMObjects

public Enumeration getMMObjects()
Deprecated. use getBuilders()

Retrieves the loaded builders.

Returns:
an Enumeration listing the loaded builders

getBuilders

public Collection getBuilders()
Retrieves a Collection of 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

getRootBuilder

public MMObjectBuilder getRootBuilder()
Returns a reference to the Object builder. The Object builder is the builder from which all other builders eventually extend.

Returns:
the Object builder.
Since:
MMBase-1.6

getRootType

public int getRootType()
Returns the otype of the Object builder, or -1 if it is not known. The Object builder is the builder from which all other builders eventually extend.

Since:
MMBase-1.6

getClusterBuilder

public ClusterBuilder getClusterBuilder()
Returns a reference to the cluster builder, a virtual builder used to perform multilevel searches.

Returns:
The cluster builder.
See Also:
ClusterBuilder

assertUp

protected void assertUp()
Locks until init of mmbase is finished.

Since:
MMBase-1.7

getBaseName

public String getBaseName()
Retrieves the storage base name

Returns:
the base name as a String

maintainance

public void maintainance()
Performs periodic maintenance.

Overrides:
maintainance in class Module

getSearchHash

public Hashtable getSearchHash(Vector se,
                               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 String getWhereList(Vector se,
                           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()
Deprecated. use getModule("sendmail") instead SendMail will become a separate application. In MMBase 1.8. this method will be removed

Retrieves a reference to the sendmail module.

Returns:
a SendMailInterface object if the module was loaded, null otherwise.

getMachineName

public String getMachineName()
Retrieves the machine name. This value is set using the configuration file.

Returns:
the machine name as a String

getHost

public String getHost()
Retrieves the host name or ip number This value is set using the configuration file.

Returns:
the host name as a String

addRemoteObserver

public boolean addRemoteObserver(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(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 String doGetAgeMarker(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()
Deprecated. use getStorageManager().createKey()

Retrieves an unique key to use for a new node's number. Calls the storage 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

initBuilder

public void initBuilder(MMObjectBuilder builder)
inits a builder

Parameters:
builder - The builder which has to be initialized

unloadBuilder

public void unloadBuilder(MMObjectBuilder builder)
Unloads a builders from MMBase. After this, the builder is gone

Parameters:
builder - the builder which has to be unloaded

getBuilderLoader

public ResourceLoader getBuilderLoader()
Since:
MMBase-1.8

getBuilderReader

public BuilderReader getBuilderReader(String builderName)
Since:
MMBase-1.8

getBuilderPath

public String getBuilderPath(String builderName,
                             String path)
Locate one specific builder within a given path, relative to the main builder config path, including sub-paths. Return the actual path.

Parameters:
builderName - name of the builder to find
path - the path to start searching. The path need be closed with a '/ character
Returns:
the file path to the builder xml, or null if the builder could not be created (i.e. is inactive).
Throws:
BuilderConfigurationException - if the builder config file does not exist
To Do:
The second argument (and perhaps the whole function) is silly, only exists because this function used to be implemented recursively (now delegated to ResourceLoader).

loadBuilderFromXML

public MMObjectBuilder loadBuilderFromXML(String builderName,
                                          String ipath)
Create a new builder object using a xml configfile located in a given path relative to the main builder config path, and return the builder object. If the builder already exists, the existing object is returned instead. Note that the builder's init() method is NOT called (since some builders need other builders in memory when their init() is called, this method is called seperately after all builders are loaded).

Parameters:
builderName - name of the builder to initialize
ipath - the path to start searching. The path need be closed with a '/' character.
Returns:
the loaded builder object.

getDTDBase

public String getDTDBase()
Deprecated. keesj: This method is not used. Document type definitions should contain a fully qualified url. I think the author was thinking of a dtdpath wich makes sence

Retrieves the DTD base url. This value is set using the configuration file.

Returns:
the dtd base as a String

initializeStorage

protected void initializeStorage()
Loads either the storage manager factory or the appropriate support class using the configuration parameters.

Since:
MMBase-1.7

getStorageManagerFactory

public StorageManagerFactory getStorageManagerFactory()
Returns StorageManagerFactory class used to access the storage configuration.

Returns:
a StorageManagerFactory class, or null if not configured
Since:
MMBase-1.7

getStorageManager

public StorageManager getStorageManager()
                                 throws StorageException
Returns a StorageManager to access the storage.. Equal to getStorageManagerFactory().getStorageManager().

Returns:
a StorageManager class
Throws:
StorageException - if no storage manager could be instantiated
Since:
MMBase-1.7

getSearchQueryHandler

public SearchQueryHandler getSearchQueryHandler()
                                         throws StorageException
Returns a SearchQueryHandler to access the storage.. Equal to getStorageManagerFactory().getSearchQueryHandler().

Returns:
a StorageManager class
Throws:
StorageException - if no storage manager could be instantiated
Since:
MMBase-1.8

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 the original node was not loaded accurately.


getAuthType

public 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 String getLanguage()
Retrieves the current language. This value is set using the configuration file. Examples are 'en' or 'nl'.

Returns:
the language as a String

getLocale

public Locale getLocale()
Retrieves the current locale.

Since:
MMBase-1.8

getTimeZone

public TimeZone getTimeZone()
Retrieves the timezone asociated with this MMBase's 'DateTime' objects. MMBase stores dates in storage as 'Date' but without time-zone information, and therefore to a certain degree open to interpretation. Together with this timezone the times can be defined absoletely (that is, of course, relative to the time frame of out planet). (

Since:
MMBase-1.8

getEncoding

public String getEncoding()
Retrieves the encoding. This value is set using the configuration file. Examples are 'UTF-8' (default) or 'ISO-8859-1'.

Returns:
the coding as a String
Since:
MMBase-1.6

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.


addNodeRelatedEventsListener

public void addNodeRelatedEventsListener(String builder,
                                         EventListener listener)
This is a conveniance method to help you register listeners to node and relation events. Becouse they are now separate listeners the method accepts an object that may have implemented either NodeEvent or RelationEvent. This method checks and registers accordingly.
the purpose of this method is that a straight node or relation event listeren will listen to any node or relation event. This method will wrap your event listener to make shure only the requested event types are forwarded.

Parameters:
builder - should be a valid builder name, the type for which you want to receive events
listener - some object implementing NodeEventListener, RelationEventListener, or both
Since:
MMBase-1.8
See Also:
TypedRelationEventListenerWrapper, TypedNodeEventListenerWrapper, NodeEventListener, RelationEventListener

removeNodeRelatedEventsListener

public void removeNodeRelatedEventsListener(String builder,
                                            EventListener listener)
Parameters:
builder -
listener -
Since:
MMBase-1.8
See Also:
addNodeRelatedEventsListener(java.lang.String, org.mmbase.core.event.EventListener)


MMBase build 1.8.1.20060716