org.mmbase.module.core
Class MMBase

Package class diagram package MMBase
java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
      extended by org.mmbase.util.functions.DescribedFunctionProvider
          extended by org.mmbase.module.Module
              extended by org.mmbase.module.ProcessorModule
                  extended by org.mmbase.module.core.MMBase
All Implemented Interfaces:
Descriptor

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 45413 2011-02-24 12:54:53Z michiel $
Author:
Daniel Ockeloen, Pierre van Rooden, Johannes Verelst, Ernst Bunders

Nested Class Summary
 
Nested classes/interfaces 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
configurationPath, getMaintainerFunction, getVersionFunction, properties, STATE_START_TIME
 
Fields inherited from class org.mmbase.util.functions.DescribedFunctionProvider
description, guiName, name
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions, getFunctions
 
Constructor Summary
MMBase(String name)
          Constructor to create the MMBase root module.
 
Method Summary
 MMObjectBuilder addBuilder(String name, MMObjectBuilder bul)
           
 void addNodeRelatedEventsListener(String builder, EventListener listener)
          This is a conveniance method to help you register listeners to node and relation events.
protected  void assertUp()
          Locks until initialization of mmbase is finished.
(package private)  boolean checkMMBase()
          Checks whether the storage to be used exists.
protected  void configureOSCache()
          This method tries to configure the persistence directory of OSCache, if possible (OSCache is available, and necessary (no 'cache.path' property is configured for OSCache).
(package private)  boolean createMMBase()
          Create a new MMBase persistent storage instance.
 String getAuthType()
           
 String getBaseName()
          Retrieves the storage base name
 MMObjectBuilder getBuilder(String name)
          Retrieves a specified builder.
 MMObjectBuilder getBuilderForNode(int number)
           
 ResourceLoader getBuilderLoader()
          The (base)path to the builder configuration files
 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<MMObjectBuilder> getBuilders()
          Retrieves a Collection of loaded builders.
 ClusterBuilder getClusterBuilder()
          Returns a reference to the cluster builder, a virtual builder used to perform multilevel searches.
 File getDataDir()
          A setting 'datadir' can be specified in mmbaseroot.xml (and hence in your context xml).
 DataSource getDataSource()
          Returns the datasource as was configured with mmbaseroot.xml properties.
 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.
 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.
 CoreSearchQueryHandler getSearchQueryHandler()
          Returns a SearchQueryHandler to access the storage..
 boolean getState()
          Retrieves whether this mmbase module is running.
 StorageManager<?> getStorageManager()
          Returns a StorageManager to access the storage..
 StorageManagerFactory<? extends StorageManager> 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.
 boolean inDevelopment()
          Returns true when MMBase is in development mode.
 void init()
          Initializes the MMBase module.
 void initBuilder(MMObjectBuilder builder)
          inits a builder
(package private)  boolean initBuilders()
          Initializes the builders, using the builder xml files in the config directory
protected  void initializeStorage()
          Loads either the storage manager factory or the appropriate support class using the configuration parameters.
 boolean isShutdown()
           
(package private)  MMObjectBuilder loadBuilder(String builderName)
          Locate one specific builder withing the main builder config path, including sub-paths.
(package private)  MMObjectBuilder loadBuilder(String builderName, String ipath)
          Locate one specific builder within a given path, relative to the main builder config path, including sub-paths.
 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 removeNodeRelatedEventsListener(String builder, EventListener listener)
           
 boolean runStartupChecks()
          Whether to perform sanity checks during startup.
protected  void setMMEntities(boolean logEnts)
           
 void shutdown()
           
 void unloadBuilder(MMObjectBuilder builder)
          Unloads a builders from MMBase.
 
Methods inherited from class org.mmbase.module.ProcessorModule
getList, getListBuilder, getNodeList, onload, process, reload, replace, replace, unload
 
Methods inherited from class org.mmbase.module.Module
addInitParameters, checkModules, getInitParameter, getInitParameter, getInitParameter, getInitParameters, getInitParameters, getMaintainer, getModule, getModule, getModule, getModule, getModuleInfo, getModuleLoader, getModuleReader, getModuleReader, getModules, getState, getStates, getVersion, hasModule, hasStarted, loadInitParameters, loadInitParameters, maintainance, setInitParameter, setMaintainer, setState, setVersion, shutdownModules, startModule, startModules
 
Methods inherited from class org.mmbase.util.functions.DescribedFunctionProvider
getDefaultLocale, getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName, setLocalizedDescription, setLocalizedGUIName, setName
 
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. If not specified the default is "def1". Should be made private and accessed instead using getBaseName()

Scope:
private
Constructor Detail

MMBase

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

Method Detail

configureOSCache

protected void configureOSCache()
This method tries to configure the persistence directory of OSCache, if possible (OSCache is available, and necessary (no 'cache.path' property is configured for OSCache). Then, a directory named 'oscache' in the mmbase data directory is used to set the 'cache.path' property of the ServletCacheAdminidstrator class of OSCache.

Since:
MMBase-1.9

setMMEntities

protected void setMMEntities(boolean logEnts)
Since:
MMBase-2.0

init

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

Overrides:
init in class ProcessorModule

shutdown

public void shutdown()
Overrides:
shutdown in class Module
See Also:
Module.shutdown()

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

checkMMBase

boolean checkMMBase()
Checks whether the storage to be used exists. The system determines whether the object table exists for the baseName provided in the configuration file.

Returns:
true if the storage exists and is accessible, false otherwise.

createMMBase

boolean createMMBase()
Create a new MMBase persistent storage instance. The storage instance created is based on the baseName provided in the configuration file. This call automatically creates an object table. The fields in the table are either specified in an object builder xml, or from a default setup existing of a number field and a owner field. Note: If specified, the object builder is instantiated and its table created, but the builder is not registered in the TypeDef builder, as this builder does not exist yet. Registration happens when the other builders are registered.

Returns:
true if the storage was succesfully created, otherwise a runtime exception is thrown (shouldn't it return false instead?)

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.

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

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)

getBuilders

public Collection<MMObjectBuilder> 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 initialization of mmbase is finished.

Since:
MMBase-1.7

getBaseName

public String getBaseName()
Retrieves the storage base name

Returns:
the base name as a String

getMachineName

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

Returns:
the machine name as a String. Or null if not yet determined.

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

initBuilders

boolean initBuilders()
Initializes the builders, using the builder xml files in the config directory

Returns:
Always true

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()
The (base)path to the builder configuration files

Since:
MMBase-1.8

getBuilderReader

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

loadBuilder

MMObjectBuilder loadBuilder(String builderName)
Locate one specific builder withing the main builder config path, including sub-paths. If the builder already exists, the existing object is returned instead. If the builder cannot be found in this path, a BuilderConfigurationException is thrown.

Parameters:
builderName - name of the builder to initialize
Returns:
the initialized builder object, or null if the builder could not be created (i.e. is inactive).
Throws:
BuilderConfigurationException - if the builder config file does not exist
Since:
MMBase-1.6

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).

loadBuilder

MMObjectBuilder loadBuilder(String builderName,
                            String ipath)
Locate one specific builder within a given path, relative to the main builder config path, including sub-paths. If the builder already exists, the existing object is returned instead.

Parameters:
builderName - name of the builder to initialize
ipath - the path to start searching. The path need be closed with a File.seperator character.
Returns:
the initialized builder object, or null if the builder could not be created (i.e. is inactive).
Throws:
BuilderConfigurationException - if the builder config file does not exist

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.
Deprecation-used:
uses deprecated builder methods, contains commented-out code

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<? extends StorageManager> 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 CoreSearchQueryHandler 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

getAuthType

public String getAuthType()

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.

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)

getDataDir

public File getDataDir()
A setting 'datadir' can be specified in mmbaseroot.xml (and hence in your context xml). This serves as a default for the 'blobs on disk' directory, but it can be used on other spots as well.

Since:
MMBase-1.8.6

getDataSource

public DataSource getDataSource()
Returns the datasource as was configured with mmbaseroot.xml properties. since MMBase-1.9


runStartupChecks

public boolean runStartupChecks()
Whether to perform sanity checks during startup. Most prominently used by DatabaseStorageManager to check the database tables.

Since:
MMBase-1.8.7


MMBase2 Core 2.0-SNAPSHOT - 2013-03-30T06:36