com.dynamide.resource
Class ResourceManager

java.lang.Object
  extended by com.dynamide.DynamideObject
      extended by com.dynamide.resource.ContextNode
          extended by com.dynamide.resource.Pool
              extended by com.dynamide.resource.ResourceManager
All Implemented Interfaces:
IContext, IGet

public final class ResourceManager
extends Pool

The ResourceManager is required by all Dynamide applications; the servlet calls installSingletonRootResourceManager() while command line applications should call createStandalone(). The ResourceManager holds an instance of the SessionPool in its own pool. You need to have the correct permissions to be able to get the SessionPool, or to ask the SessionPool for a Session. SessionPool extends Pool.


Nested Class Summary
 class ResourceManager.JobMasterThread
           
 
Field Summary
static java.lang.String CACHE
           
static java.lang.String CACHE_ICONTEXT_NAME
           
static java.lang.String CACHE_IS_PUBLISH_CACHE
           
static java.lang.String CACHE_ON
          Call isCacheOn() to see if caching is on -- that is, disk won't be checked for objects once they are in cache.
static java.lang.String CACHE_PREFIX
           
static java.lang.String CACHE_PREFIX_URI
           
static java.lang.String CACHE_URI
           
static java.lang.String CAT_CACHE
           
static java.lang.String ERROR_LOGS_REL
           
static int JOB_MASTER_INTERVAL_DEFAULT
          Fallback value, in milliseconds, of how often the ResourceManager will check for Jobs that need to run, unless /conf/ResourceManager/jobMasterInterval is set in context.xml
protected static boolean LOG_CACHING
           
static int POOL_ACTION_REMOVE
           
static int POOL_ACTION_REPOOL
           
static java.lang.String RESOURCE_ROOT_KEY
           
static java.lang.String ROOT_KEY
           
static java.lang.String SESSIONS_POOLED_NAME
           
 
Fields inherited from class com.dynamide.resource.Pool
DEFAULT_POOL_TIMEOUT
 
Fields inherited from class com.dynamide.DynamideObject
m_id
 
Constructor Summary
protected ResourceManager(DynamideObject owner)
           
 
Method Summary
 void addContextToTree(int id, IContext context, TreeBean t, java.lang.String tmpl)
           
static IContext addElementToContext(org.jdom.Element elem, IContext ctx, java.lang.String fullpath)
           
 IContext addElementToContext(org.jdom.Element elem, java.lang.String path, java.lang.String fullpath)
           
 void addSession(java.lang.String id, java.lang.Object sessionData)
           
 void addUserSession(java.lang.String userSessionContextName, java.lang.String USER, Session session)
           
 void addWebApp(Assembly assembly, java.lang.String uri, java.lang.String appname, boolean loadOnStartup)
           
 void addWebApp(java.lang.String uri, java.lang.String appname, java.lang.String home, java.lang.String assemblyBasename, java.lang.String assemblyInterfaceNumber, java.lang.String build, boolean loadOnStartup)
           
 java.lang.Object callStaticMethod(java.lang.Class theClass, java.lang.String methodName)
           
 java.lang.Object callStaticMethod(java.lang.Class theClass, java.lang.String methodName, java.lang.Class[] params, java.lang.Object[] invokeParams)
           
 java.lang.Object callStaticMethod(java.lang.String className, java.lang.String methodName)
           
 void checkDirectoryWrite(Session session, java.lang.String directoryPath)
           
 void checkMailPermission(java.lang.String host)
           
 java.lang.Object clone()
          This is specifically denied.
static void configureLog(java.lang.String RESOURCE_ROOT, java.lang.String logConfFilename)
           
static void configureLogForTest()
          Use this when running in JUnit
 void createApplication(Assembly assembly, java.lang.String appName)
           
 Assembly createAssembly(DynamideObject owner, java.lang.String id, java.lang.String account, java.lang.String RESOURCE_ROOT)
          This is the only legal way to create an Assembly.
 IContext createPublishCache(java.lang.String cachePrefix, java.lang.String cachePrefixURI)
          Ordinarily, cache points to ResourceManager.CACHE_ICONTEXT_NAME, but with this method, you can create your own cache, so that you can publish to it in Session.MODE_PUBLISH.
 Session createSession(java.lang.String urlpath)
           
static ResourceManager createStandalone()
          Use this when you wish to simply run from the command line (using the environment var or java system property named by Constants.RESOURCE_ROOT_ENV for the RESOURCE_ROOT), and not in a web framework.
static ResourceManager createStandalone(java.lang.String resourceRoot)
           
static ResourceManager createStandalone(java.lang.String resourceRoot, java.lang.String contextFilename, java.lang.String staticRoot, java.lang.String logConfFilename)
          Use this when you wish to simply run from the command line, and not in a web framework.
static void createStandaloneForTest()
          Use this when running in JUnit
 TreeBean createTestTree()
           
static java.lang.String crypt(java.lang.String passwd)
           
 void destroyPublishCache(java.lang.String cachePrefix)
           
 void doPoolAction(int action, Session session)
           
 java.lang.String dumpAddedContexts()
           
 java.lang.String dumpConnectionPoolStats(boolean full)
           
static java.lang.String dumpContext(IContext context, java.lang.String indent, boolean html)
           
static java.lang.String dumpContext(IContext context, java.lang.String indent, boolean html, java.lang.String pathString)
           
 java.lang.String dumpContext(java.lang.String search, java.lang.String indent, boolean html)
           
 java.lang.String dumpRootContext()
           
 java.lang.String dumpRootContext(boolean html)
           
 java.lang.String dumpRootContextPage()
           
static IContext ensureContext(IContext cur, java.lang.String name)
           
 IContext ensureContext(java.lang.String name)
           
static IContext ensureContextPath(IContext rm, java.lang.String path)
           
 IContext ensureContextPath(java.lang.String path)
           
 java.lang.String errorIDToFilename(java.lang.String id)
           
static java.lang.String errorIDToHref(java.lang.String id)
           
 IContext findAssembliesInAccount(java.lang.String account)
           
 Assembly findAssembly(Assembly caller, java.lang.String basename, java.lang.String interfaceNumber, java.lang.String build)
           
 Assembly findAssembly(java.lang.String account, java.lang.String basename, java.lang.String interfaceNumber, java.lang.String build)
           
 Assembly findAssemblyInAccount(java.lang.String account, java.lang.String basename, java.lang.String interfaceNumber, java.lang.String build)
           
 Job findJob(java.lang.String installedName)
           
 IContext findOrCreateCache(java.lang.String cachePrefix, java.lang.String cachePrefixURI)
          Ordinarily, cache points to ResourceManager.CACHE_ICONTEXT_NAME, but with this method, you can create your own cache, to store in-memory content.
 Session findPooledSession(java.lang.String uri)
           
 Session findPooledSession(WebAppEntry entry)
           
 IContext findSharedAssemblies()
           
 Assembly findSharedAssembly(java.lang.String basename, java.lang.String interfaceNumber, java.lang.String build)
           
 IContext findStaticResource(java.lang.String fullURI)
           
 IContext findWebAppsInAccount(java.lang.String account)
           
 IContext findWebAppsInAssembly(IContext assembly)
           
 IContext findWebAppsRoot()
           
 void flushErrorLog()
           
 java.util.List getAddedContexts()
           
 IContext getCache()
           
 IContext getCache(java.lang.String cachePrefix)
           
 IContext getCachedResource(java.lang.String cacheRelName)
          Safe to call with either /cache/yada/yada or /yada/yada
 IContext getCachedResource(java.lang.String cachePrefix, java.lang.String cacheRelName)
          Don't include the leading slash on the cachePrefix, e.g. send "cache" NOT "/cache"
 java.lang.String getCachePrefixURI(java.lang.String cachePrefix)
           
 java.lang.String getCategoryID()
           
static com.bitmechanic.sql.ConnectionPoolManager getConnectionPoolManager()
           
 java.lang.String getDynamideContextConf()
           
static java.lang.String getDynamideHomeFromEnv()
           
 Assembly getDynamideLibAssembly()
           
static java.lang.String getEnvironmentVariable(java.lang.String key)
          Publicly allow all to see env vars for now.
static ILogger getErrorLogger()
           
 java.lang.String getErrorLogsDir()
           
static java.lang.String getErrorLogsURI()
           
 java.lang.String getHostName()
          The hostname value is cached for the life of the ResourceManager.
static long getNextErrorID()
           
 java.lang.String getNextSessionID()
           
 java.lang.Object getResource(java.lang.String name)
           
static java.lang.String getResourceRoot()
           
static java.lang.String getResourceRootFromEnv()
           
static java.lang.String getResourceRootFromHome()
          lookup the RESOURCE_ROOT from the dynamide.local.properties file in the ${DYNAMIDE_HOME}/bin directory, using ${DYNAMIDE_HOME} from the environment.
static java.lang.String getResourceRootFromHome(java.lang.String home)
          lookup the RESOURCE_ROOT from the dynamide.local.properties file in the home directory specified.
static ResourceManager getRootResourceManager()
           
 java.lang.String getSadd()
           
 Session getSession(java.lang.String sessionID)
           
static java.lang.String getStaticPrefix()
           
 java.lang.String getStaticRoot()
           
static java.lang.String getStaticRootFromHome()
           
static java.lang.String getStaticRootFromHome(java.lang.String home)
           
 boolean hasResource(java.lang.String key)
           
 void initHome(IContext homes, java.lang.String path, java.lang.String accountName)
           
 void initPool(java.lang.String uri)
           
 Job installJob(Session session, java.lang.String installedName, java.lang.Object inputObject)
          Call this to install a Job or to re-install a Job -- if a Job with the same ID (which is Session.getFullAppname()) is currently running, it is removed first -- be sure that closeOnJobClose is false if you do this from the Session, otherwise the Session will be closed for you.
 Job installJob(java.lang.String applicationURI, java.lang.Object inputObject)
           
static ResourceManager installSingletonRootResourceManager(java.lang.String RESOURCE_ROOT, java.lang.String DYNAMIDE_CONTEXT_CONF, java.lang.String DYNAMIDE_STATIC_ROOT)
           
static ResourceManager installSingletonRootResourceManager(java.lang.String RESOURCE_ROOT, java.lang.String DYNAMIDE_CONTEXT_CONF, java.lang.String DYNAMIDE_STATIC_ROOT, java.lang.String logConfFilename)
           
 boolean isCacheOn()
          This calls getAttribute(CACHE_ON) to see if the value is "true" (resource caching is on for the global cache), else will contain the value "false" if the filesystem or resource database is to be read on each request.
 boolean isPoolMaxed(java.lang.String applicationPath)
           
 boolean isUserLocalDeveloper(java.lang.String USER)
           
 java.lang.Object loadClass(java.lang.String className)
           
 java.lang.Class loadClassStatic(java.lang.String className)
           
 void logCaching(java.lang.String msg)
           
static void main(java.lang.String[] args)
           
 RDBDatabase openDatabase(java.lang.String dbContextName, Session session)
           
 IContext putCachedResource(java.lang.String cacheRelName, IContext resource)
          Safe to call with either /cache/yada/yada or /yada/yada
 IContext putCachedResource(java.lang.String cachePrefix, java.lang.String cacheRelName, IContext resource)
           
static java.util.Properties readPropertiesFromHome(java.lang.String home)
          ================================================== NOTE: this case is illegal : ${DYNAMIDE_RESOURCE_ROOT}/foobar/${DYNAMIDE_HOME}/foo !!
 void rebindSession(java.lang.String id, java.lang.Object sessionData)
           
 void reconfigureLog()
           
 void reinitHome(java.lang.String accountName)
          Re-initialize the context entries associated with a home directory/account.
 java.lang.String reloadRootWebApps()
           
 void reloadSettings()
          All pretty benign stuff in here.
 Job removeInstalledJob(java.lang.String installedName, boolean closeJob)
           
 void removeSession(Session session)
          Can only be called from com.dynamide.Session.close(), otherwise throws SecurityException.
 void removeSessionFromPool(Session session)
           
 void repoolSession(Session session)
           
 IContext rereadResource(Session session, java.lang.String appname, java.lang.String resourceID)
          Re-read a resource.
 void setAddedContexts(java.util.List new_value)
           
 void setDynamideContextConf(java.lang.String m_dynamideContextConf)
           
 void setKey(java.lang.String new_value)
           
 void setStaticRoot(java.lang.String staticRoot)
           
static void shutdown()
           
 Job startJob(Session session, java.lang.String eventName, java.lang.Object inputObject)
          Only application events can be started as Jobs -- Page and Widget events are not supported.
 Job startJob(Session session, java.lang.String eventName, java.lang.Object inputObject, long startDelay)
           
 void startLoadOnStartupApps()
           
 void updateCache()
          Kick the global cache.
 WebAppEntry uriToApp(java.lang.String uri)
           
 com.dynamide.resource.ResourceManager.UriToAppForHomeResult uriToAppForHome(java.lang.String uri, java.lang.String home, java.lang.String where)
           
static void usage()
           
static IContext wrapContext(DynamideObject owner, java.lang.String key, java.lang.Object object, java.util.Map attributes)
           
static IContext wrapContext(DynamideObject owner, java.lang.String key, java.lang.Object object, java.util.Map attributes, java.security.Permissions permissions)
          Take any arbitrary object and wrap it in an IContext implementation, so that it can be added to an IContext as a node.
static IContext wrapContext(java.lang.String key, java.lang.Object object)
           
 java.io.File writeCache(java.lang.String prefix, java.lang.String rootdir)
           
static java.lang.String writeErrorLog(Session session, java.lang.String id, java.lang.String resourcename, java.lang.String message, java.lang.String stackTrace, java.lang.String errorClassname)
           
static java.lang.String writeErrorLog(Session session, java.lang.String id, java.lang.String resourcename, java.lang.String message, java.lang.Throwable t)
           
 
Methods inherited from class com.dynamide.resource.Pool
getPooledObject, getPoolMax, setPoolMax, setPoolMax
 
Methods inherited from class com.dynamide.resource.ContextNode
bind, bind, bindAll, bindAllAttributes, bindAttribute, dump, dumpAttributes, dumpContext, find, find, find, firstContext, get, getAttribute, getAttributeCount, getAttributes, getContext, getContextCount, getContexts, getKey, getPermission, hasAttribute, hasContext, listAttributeNames, listAttributeNames, listContextNames, listContextNames, lockPermissions, rebind, rebind, rebindAttribute, remove, removeAttribute, removeFirstContext, toString, unlockPermissions, update, writeCache
 
Methods inherited from class com.dynamide.DynamideObject
clearProfiler, dump, dumpHTML, expand, finalize, findParentExpander, findParentPage, findParentSession, findTopParentPage, getDotName, getID, getNextGetter, getObjectID, getOwner, getProfiler, isDebugEnabled, isInfoEnabled, logDebug, logDebug, logDebug, logDebug, logError, logError, logError, logError, logInfo, logInfo, logInfo, logInfo, logWarn, logWarn, logWarn, logWarn, popLogContext, printf, printProfiler, profileEnter, profileLeave, pushLogContext, setDotName, setID, setNextGetter, setObjectID, setOwner, sprintf, useProfiler, walkParents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.dynamide.resource.IContext
bind, bind, bindAll, bindAllAttributes, bindAttribute, dumpAttributes, dumpContext, find, find, find, firstContext, getAttribute, getAttributeCount, getAttributes, getContext, getContextCount, getContexts, getKey, getPermission, hasAttribute, hasContext, lockPermissions, rebind, rebind, rebindAttribute, remove, removeAttribute, removeFirstContext, unlockPermissions, update
 

Field Detail

CAT_CACHE

public static final java.lang.String CAT_CACHE
See Also:
Constant Field Values

LOG_CACHING

protected static boolean LOG_CACHING

RESOURCE_ROOT_KEY

public static final java.lang.String RESOURCE_ROOT_KEY
See Also:
Constant Field Values

CACHE

public static final java.lang.String CACHE
See Also:
Constant Field Values

CACHE_URI

public static final java.lang.String CACHE_URI
See Also:
Constant Field Values

CACHE_ICONTEXT_NAME

public static final java.lang.String CACHE_ICONTEXT_NAME
See Also:
Constant Field Values

CACHE_IS_PUBLISH_CACHE

public static final java.lang.String CACHE_IS_PUBLISH_CACHE
See Also:
Constant Field Values

CACHE_PREFIX

public static final java.lang.String CACHE_PREFIX
See Also:
Constant Field Values

CACHE_PREFIX_URI

public static final java.lang.String CACHE_PREFIX_URI
See Also:
Constant Field Values

SESSIONS_POOLED_NAME

public static final java.lang.String SESSIONS_POOLED_NAME
See Also:
Constant Field Values

CACHE_ON

public static final java.lang.String CACHE_ON
Call isCacheOn() to see if caching is on -- that is, disk won't be checked for objects once they are in cache.

See Also:
Constant Field Values

ROOT_KEY

public static final java.lang.String ROOT_KEY
See Also:
Constant Field Values

ERROR_LOGS_REL

public static java.lang.String ERROR_LOGS_REL

JOB_MASTER_INTERVAL_DEFAULT

public static final int JOB_MASTER_INTERVAL_DEFAULT
Fallback value, in milliseconds, of how often the ResourceManager will check for Jobs that need to run, unless /conf/ResourceManager/jobMasterInterval is set in context.xml

See Also:
Constant Field Values

POOL_ACTION_REPOOL

public static final int POOL_ACTION_REPOOL
See Also:
Constant Field Values

POOL_ACTION_REMOVE

public static final int POOL_ACTION_REMOVE
See Also:
Constant Field Values
Constructor Detail

ResourceManager

protected ResourceManager(DynamideObject owner)
Method Detail

logCaching

public final void logCaching(java.lang.String msg)

getErrorLogsDir

public java.lang.String getErrorLogsDir()

getErrorLogsURI

public static java.lang.String getErrorLogsURI()

clone

public java.lang.Object clone()
This is specifically denied.

Overrides:
clone in class java.lang.Object
Throws:
java.lang.SecurityException

installSingletonRootResourceManager

public static ResourceManager installSingletonRootResourceManager(java.lang.String RESOURCE_ROOT,
                                                                  java.lang.String DYNAMIDE_CONTEXT_CONF,
                                                                  java.lang.String DYNAMIDE_STATIC_ROOT)
                                                           throws java.lang.Exception
Throws:
java.lang.Exception
Factory Method:

installSingletonRootResourceManager

public static ResourceManager installSingletonRootResourceManager(java.lang.String RESOURCE_ROOT,
                                                                  java.lang.String DYNAMIDE_CONTEXT_CONF,
                                                                  java.lang.String DYNAMIDE_STATIC_ROOT,
                                                                  java.lang.String logConfFilename)
                                                           throws java.lang.Exception
Throws:
java.lang.Exception
Factory Method:

shutdown

public static void shutdown()

createStandalone

public static ResourceManager createStandalone()
                                        throws java.lang.Exception
Use this when you wish to simply run from the command line (using the environment var or java system property named by Constants.RESOURCE_ROOT_ENV for the RESOURCE_ROOT), and not in a web framework. NOTE: once you do this, you must explicitly call System.exit(code) when you are done, because the ResourceManager singleton hangs around in memory.

Throws:
java.lang.Exception
Factory Method:

createStandalone

public static ResourceManager createStandalone(java.lang.String resourceRoot)
                                        throws java.lang.Exception
Throws:
java.lang.Exception
Factory Method:

createStandalone

public static ResourceManager createStandalone(java.lang.String resourceRoot,
                                               java.lang.String contextFilename,
                                               java.lang.String staticRoot,
                                               java.lang.String logConfFilename)
                                        throws java.lang.Exception
Use this when you wish to simply run from the command line, and not in a web framework. NOTE: once you do this, you must explicitly call System.exit(code) when you are done, because the ResourceManager singleton hangs around in memory.

Parameters:
resourceRoot - would be something like: "C:/dynamide/build/DYNAMIDE_RESOUCE_ROOT"
Throws:
java.lang.Exception
Factory Method:

createStandaloneForTest

public static void createStandaloneForTest()
                                    throws java.lang.Exception
Use this when running in JUnit

Throws:
java.lang.Exception
Factory Method:

getRootResourceManager

public static ResourceManager getRootResourceManager()
                                              throws java.lang.SecurityException
Returns:
null if not initialized by a call to installSingletonRootResourceManage()
Throws:
java.lang.SecurityException

configureLog

public static void configureLog(java.lang.String RESOURCE_ROOT,
                                java.lang.String logConfFilename)
                         throws java.lang.Exception
Throws:
java.lang.Exception

configureLogForTest

public static void configureLogForTest()
                                throws java.lang.Exception
Use this when running in JUnit

Throws:
java.lang.Exception

reconfigureLog

public void reconfigureLog()
                    throws java.lang.Exception
Throws:
java.lang.Exception

reloadSettings

public void reloadSettings()
                    throws java.lang.Exception
All pretty benign stuff in here. Won't damage anything to call this again, just reloads the log.conf file, etc. You must not be in a worker thread, however.

Throws:
java.lang.Exception

checkMailPermission

public void checkMailPermission(java.lang.String host)
                         throws java.lang.SecurityException
Throws:
java.lang.SecurityException

getCategoryID

public java.lang.String getCategoryID()
Overrides:
getCategoryID in class DynamideObject

setKey

public void setKey(java.lang.String new_value)
Specified by:
setKey in interface IContext
Overrides:
setKey in class ContextNode

getEnvironmentVariable

public static java.lang.String getEnvironmentVariable(java.lang.String key)
Publicly allow all to see env vars for now.


getDynamideHomeFromEnv

public static java.lang.String getDynamideHomeFromEnv()

getResourceRootFromHome

public static java.lang.String getResourceRootFromHome()
                                                throws java.lang.Exception
lookup the RESOURCE_ROOT from the dynamide.local.properties file in the ${DYNAMIDE_HOME}/bin directory, using ${DYNAMIDE_HOME} from the environment.

Throws:
java.lang.Exception

getResourceRootFromHome

public static java.lang.String getResourceRootFromHome(java.lang.String home)
                                                throws java.lang.Exception
lookup the RESOURCE_ROOT from the dynamide.local.properties file in the home directory specified.

Throws:
java.lang.Exception
To do:
Optimize this so that it is not read every time.

getStaticRootFromHome

public static java.lang.String getStaticRootFromHome()
                                              throws java.lang.Exception
Throws:
java.lang.Exception

getStaticRootFromHome

public static java.lang.String getStaticRootFromHome(java.lang.String home)
                                              throws java.lang.Exception
Throws:
java.lang.Exception

setDynamideContextConf

public void setDynamideContextConf(java.lang.String m_dynamideContextConf)

getDynamideContextConf

public java.lang.String getDynamideContextConf()
                                        throws java.lang.Exception
Throws:
java.lang.Exception

readPropertiesFromHome

public static java.util.Properties readPropertiesFromHome(java.lang.String home)
                                                   throws java.lang.Exception
==================================================
 NOTE: this case is illegal :
   ${DYNAMIDE_RESOURCE_ROOT}/foobar/${DYNAMIDE_HOME}/foo         !! ILLEGAL !!

 These can nest DYNAMIDE_HOME > DYNAMIDE_BUILD > DYNAMIDE_RESOURCE_ROOT
  but they can't be in the same definition.
 One of the levels has a rooted directory.
 EXAMPLES:
  DYNAMIDE_BUILD
        ${DYNAMIDE_HOME}/build
        /usr/local/dynamide/build

 DYNAMIDE_RESOURCE_ROOT
       ${DYNAMIDE_HOME}/build/dynamide_resource_root
       ${DYNAMIDE_BUILD}/dynamide_resource_root
       /usr/local/dynamide/build/dynamide_resource_root

 DYNAMIDE_CONTEXT_CONF
      ${DYNAMIDE_HOME}/build/dynamide_resource_root/context.xml
      ${DYNAMIDE_BUILD}/dynamide_resource_root/context.xml
      ${DYNAMIDE_RESOURCE_ROOT}t/context.xml
      /usr/local/dynamide/build/dynamide_resource_root /context.xml
 ==================================================
 Expands macros:
  DYNAMIDE_BUILD can reference DYNAMIDE_HOME
  DYNAMIDE_RESOURCE_ROOT can reference DYNAMIDE_HOME and DYNAMIDE_BUILD
  DYNAMIDE_CONTEXT_CONF   can reference DYNAMIDE_HOME and DYNAMIDE_BUILD and DYNAMIDE_RESOURCE_ROOT
   

Throws:
java.lang.Exception

getResourceRoot

public static java.lang.String getResourceRoot()
                                        throws java.lang.Exception
Throws:
java.lang.Exception

getResourceRootFromEnv

public static java.lang.String getResourceRootFromEnv()
                                               throws java.lang.Exception
Throws:
java.lang.Exception

setStaticRoot

public void setStaticRoot(java.lang.String staticRoot)

getStaticRoot

public java.lang.String getStaticRoot()
                               throws java.lang.Exception
Throws:
java.lang.Exception

getStaticPrefix

public static java.lang.String getStaticPrefix()

getResource

public java.lang.Object getResource(java.lang.String name)
                             throws java.lang.SecurityException
Throws:
java.lang.SecurityException

hasResource

public boolean hasResource(java.lang.String key)

wrapContext

public static IContext wrapContext(java.lang.String key,
                                   java.lang.Object object)

wrapContext

public static IContext wrapContext(DynamideObject owner,
                                   java.lang.String key,
                                   java.lang.Object object,
                                   java.util.Map attributes)
                            throws ObjectAlreadyBoundException
Throws:
ObjectAlreadyBoundException

wrapContext

public static IContext wrapContext(DynamideObject owner,
                                   java.lang.String key,
                                   java.lang.Object object,
                                   java.util.Map attributes,
                                   java.security.Permissions permissions)
                            throws ObjectAlreadyBoundException
Take any arbitrary object and wrap it in an IContext implementation, so that it can be added to an IContext as a node. You can also just add the object to the parent context as a non-IContext object with the key, using bind(String, Object).

Throws:
ObjectAlreadyBoundException

dumpRootContext

public java.lang.String dumpRootContext()

dumpRootContext

public java.lang.String dumpRootContext(boolean html)

dumpContext

public java.lang.String dumpContext(java.lang.String search,
                                    java.lang.String indent,
                                    boolean html)

dumpContext

public static java.lang.String dumpContext(IContext context,
                                           java.lang.String indent,
                                           boolean html)

dumpContext

public static java.lang.String dumpContext(IContext context,
                                           java.lang.String indent,
                                           boolean html,
                                           java.lang.String pathString)

getAddedContexts

public java.util.List getAddedContexts()

setAddedContexts

public void setAddedContexts(java.util.List new_value)

dumpAddedContexts

public java.lang.String dumpAddedContexts()

addElementToContext

public IContext addElementToContext(org.jdom.Element elem,
                                    java.lang.String path,
                                    java.lang.String fullpath)
                             throws DynamideException
Throws:
DynamideException

addElementToContext

public static IContext addElementToContext(org.jdom.Element elem,
                                           IContext ctx,
                                           java.lang.String fullpath)

ensureContext

public IContext ensureContext(java.lang.String name)

ensureContext

public static IContext ensureContext(IContext cur,
                                     java.lang.String name)

ensureContextPath

public IContext ensureContextPath(java.lang.String path)

ensureContextPath

public static IContext ensureContextPath(IContext rm,
                                         java.lang.String path)

createTestTree

public TreeBean createTestTree()

addContextToTree

public void addContextToTree(int id,
                             IContext context,
                             TreeBean t,
                             java.lang.String tmpl)

reinitHome

public void reinitHome(java.lang.String accountName)
                throws java.lang.Exception
Re-initialize the context entries associated with a home directory/account. Does NOT remove running sessions or add assemblies.

Throws:
java.lang.Exception

initHome

public void initHome(IContext homes,
                     java.lang.String path,
                     java.lang.String accountName)
              throws java.io.IOException,
                     ObjectAlreadyBoundException,
                     org.jdom.JDOMException
Parameters:
accountName - is the name of the directory of the account, e.g. "dynamide"
Throws:
java.io.IOException
ObjectAlreadyBoundException
org.jdom.JDOMException
See Also:
reinitHome(String)

createAssembly

public Assembly createAssembly(DynamideObject owner,
                               java.lang.String id,
                               java.lang.String account,
                               java.lang.String RESOURCE_ROOT)
This is the only legal way to create an Assembly.


getDynamideLibAssembly

public Assembly getDynamideLibAssembly()

reloadRootWebApps

public java.lang.String reloadRootWebApps()

addWebApp

public void addWebApp(java.lang.String uri,
                      java.lang.String appname,
                      java.lang.String home,
                      java.lang.String assemblyBasename,
                      java.lang.String assemblyInterfaceNumber,
                      java.lang.String build,
                      boolean loadOnStartup)
               throws java.lang.Exception
Throws:
java.lang.Exception

addWebApp

public void addWebApp(Assembly assembly,
                      java.lang.String uri,
                      java.lang.String appname,
                      boolean loadOnStartup)
               throws java.lang.Exception
Throws:
java.lang.Exception

findWebAppsRoot

public IContext findWebAppsRoot()

findWebAppsInAccount

public IContext findWebAppsInAccount(java.lang.String account)

findWebAppsInAssembly

public IContext findWebAppsInAssembly(IContext assembly)

findSharedAssemblies

public IContext findSharedAssemblies()

findAssembliesInAccount

public IContext findAssembliesInAccount(java.lang.String account)

findSharedAssembly

public Assembly findSharedAssembly(java.lang.String basename,
                                   java.lang.String interfaceNumber,
                                   java.lang.String build)

findAssemblyInAccount

public Assembly findAssemblyInAccount(java.lang.String account,
                                      java.lang.String basename,
                                      java.lang.String interfaceNumber,
                                      java.lang.String build)

findAssembly

public Assembly findAssembly(java.lang.String account,
                             java.lang.String basename,
                             java.lang.String interfaceNumber,
                             java.lang.String build)

findAssembly

public Assembly findAssembly(Assembly caller,
                             java.lang.String basename,
                             java.lang.String interfaceNumber,
                             java.lang.String build)

isCacheOn

public boolean isCacheOn()
This calls getAttribute(CACHE_ON) to see if the value is "true" (resource caching is on for the global cache), else will contain the value "false" if the filesystem or resource database is to be read on each request.


updateCache

public void updateCache()
Kick the global cache.


rereadResource

public IContext rereadResource(Session session,
                               java.lang.String appname,
                               java.lang.String resourceID)
                        throws java.io.FileNotFoundException
Re-read a resource.

Throws:
java.io.FileNotFoundException

writeCache

public java.io.File writeCache(java.lang.String prefix,
                               java.lang.String rootdir)
                        throws java.lang.Exception
Returns:
The File handle to the rootdir if successful, else null
Throws:
java.lang.Exception

findOrCreateCache

public IContext findOrCreateCache(java.lang.String cachePrefix,
                                  java.lang.String cachePrefixURI)
Ordinarily, cache points to ResourceManager.CACHE_ICONTEXT_NAME, but with this method, you can create your own cache, to store in-memory content. See also createPublishCache.


createPublishCache

public IContext createPublishCache(java.lang.String cachePrefix,
                                   java.lang.String cachePrefixURI)
                            throws ObjectAlreadyBoundException
Ordinarily, cache points to ResourceManager.CACHE_ICONTEXT_NAME, but with this method, you can create your own cache, so that you can publish to it in Session.MODE_PUBLISH.

Throws:
ObjectAlreadyBoundException

destroyPublishCache

public void destroyPublishCache(java.lang.String cachePrefix)
                         throws java.lang.Exception
Throws:
java.lang.Exception
To do:
Lock this down a bit more, by Account.

checkDirectoryWrite

public void checkDirectoryWrite(Session session,
                                java.lang.String directoryPath)
                         throws java.lang.SecurityException
Throws:
java.lang.SecurityException

getCache

public IContext getCache()

getCache

public IContext getCache(java.lang.String cachePrefix)

getCachePrefixURI

public java.lang.String getCachePrefixURI(java.lang.String cachePrefix)

getCachedResource

public IContext getCachedResource(java.lang.String cacheRelName)
Safe to call with either /cache/yada/yada or /yada/yada


getCachedResource

public IContext getCachedResource(java.lang.String cachePrefix,
                                  java.lang.String cacheRelName)
Don't include the leading slash on the cachePrefix, e.g. send "cache" NOT "/cache"


putCachedResource

public IContext putCachedResource(java.lang.String cacheRelName,
                                  IContext resource)
Safe to call with either /cache/yada/yada or /yada/yada


putCachedResource

public IContext putCachedResource(java.lang.String cachePrefix,
                                  java.lang.String cacheRelName,
                                  IContext resource)

findStaticResource

public IContext findStaticResource(java.lang.String fullURI)
                            throws ResourceException,
                                   ApplicationNotFoundException
Throws:
ResourceException
ApplicationNotFoundException

uriToApp

public WebAppEntry uriToApp(java.lang.String uri)
                     throws ApplicationNotFoundException,
                            ResourceException
Throws:
ApplicationNotFoundException
ResourceException

uriToAppForHome

public com.dynamide.resource.ResourceManager.UriToAppForHomeResult uriToAppForHome(java.lang.String uri,
                                                                                   java.lang.String home,
                                                                                   java.lang.String where)
                                                                            throws ApplicationNotFoundException,
                                                                                   ResourceException
Throws:
ApplicationNotFoundException
ResourceException

startJob

public Job startJob(Session session,
                    java.lang.String eventName,
                    java.lang.Object inputObject)
Only application events can be started as Jobs -- Page and Widget events are not supported. Partly, this is for security: only application code should be able to kick off background threads, not necessarily imported pages and widgets. Be sure not to hang on to the returned reference after you need to, since it keeps the Job/Thread object in memory.


startJob

public Job startJob(Session session,
                    java.lang.String eventName,
                    java.lang.Object inputObject,
                    long startDelay)

installJob

public Job installJob(java.lang.String applicationURI,
                      java.lang.Object inputObject)
               throws java.lang.Exception
Throws:
java.lang.Exception

installJob

public Job installJob(Session session,
                      java.lang.String installedName,
                      java.lang.Object inputObject)
               throws java.lang.Exception
Call this to install a Job or to re-install a Job -- if a Job with the same ID (which is Session.getFullAppname()) is currently running, it is removed first -- be sure that closeOnJobClose is false if you do this from the Session, otherwise the Session will be closed for you.

Throws:
java.lang.Exception

findJob

public Job findJob(java.lang.String installedName)

removeInstalledJob

public Job removeInstalledJob(java.lang.String installedName,
                              boolean closeJob)

startLoadOnStartupApps

public void startLoadOnStartupApps()

crypt

public static java.lang.String crypt(java.lang.String passwd)

getSadd

public java.lang.String getSadd()

getNextSessionID

public java.lang.String getNextSessionID()

getHostName

public java.lang.String getHostName()
                             throws java.net.UnknownHostException
The hostname value is cached for the life of the ResourceManager.

Throws:
java.net.UnknownHostException

isUserLocalDeveloper

public boolean isUserLocalDeveloper(java.lang.String USER)

getSession

public Session getSession(java.lang.String sessionID)

rebindSession

public void rebindSession(java.lang.String id,
                          java.lang.Object sessionData)

addSession

public void addSession(java.lang.String id,
                       java.lang.Object sessionData)
                throws ObjectAlreadyBoundException
Throws:
ObjectAlreadyBoundException

addUserSession

public void addUserSession(java.lang.String userSessionContextName,
                           java.lang.String USER,
                           Session session)
                    throws SessionBusyException
Throws:
SessionBusyException

removeSession

public void removeSession(Session session)
                   throws java.lang.SecurityException
Can only be called from com.dynamide.Session.close(), otherwise throws SecurityException.

Throws:
java.lang.SecurityException - if not called from com.dynamide.Session.close()

initPool

public void initPool(java.lang.String uri)

repoolSession

public void repoolSession(Session session)

removeSessionFromPool

public void removeSessionFromPool(Session session)

doPoolAction

public void doPoolAction(int action,
                         Session session)

isPoolMaxed

public boolean isPoolMaxed(java.lang.String applicationPath)

findPooledSession

public Session findPooledSession(WebAppEntry entry)

findPooledSession

public Session findPooledSession(java.lang.String uri)

getConnectionPoolManager

public static com.bitmechanic.sql.ConnectionPoolManager getConnectionPoolManager()
                                                                          throws java.sql.SQLException
Throws:
java.sql.SQLException

dumpConnectionPoolStats

public java.lang.String dumpConnectionPoolStats(boolean full)

openDatabase

public RDBDatabase openDatabase(java.lang.String dbContextName,
                                Session session)
Parameters:
dbContextName - The name of an element in the context /conf/databases in the root Dynamide context tree. This tree is protected by the RootResourceManager. In the element are the username, driver name, password, and so on.

getNextErrorID

public static long getNextErrorID()

errorIDToFilename

public java.lang.String errorIDToFilename(java.lang.String id)

errorIDToHref

public static java.lang.String errorIDToHref(java.lang.String id)

writeErrorLog

public static java.lang.String writeErrorLog(Session session,
                                             java.lang.String id,
                                             java.lang.String resourcename,
                                             java.lang.String message,
                                             java.lang.String stackTrace,
                                             java.lang.String errorClassname)
Returns:
the id of the error - which can be turned into a URL with

writeErrorLog

public static java.lang.String writeErrorLog(Session session,
                                             java.lang.String id,
                                             java.lang.String resourcename,
                                             java.lang.String message,
                                             java.lang.Throwable t)

flushErrorLog

public void flushErrorLog()

getErrorLogger

public static ILogger getErrorLogger()
                              throws java.lang.Exception
Throws:
java.lang.Exception

dumpRootContextPage

public java.lang.String dumpRootContextPage()

createSession

public final Session createSession(java.lang.String urlpath)
                            throws java.lang.Exception
Throws:
java.lang.Exception

createApplication

public final void createApplication(Assembly assembly,
                                    java.lang.String appName)
                             throws java.lang.Exception
Throws:
java.lang.Exception

loadClass

public final java.lang.Object loadClass(java.lang.String className)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

loadClassStatic

public final java.lang.Class loadClassStatic(java.lang.String className)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

callStaticMethod

public final java.lang.Object callStaticMethod(java.lang.String className,
                                               java.lang.String methodName)
                                        throws java.lang.Exception
Throws:
java.lang.Exception

callStaticMethod

public final java.lang.Object callStaticMethod(java.lang.Class theClass,
                                               java.lang.String methodName)
                                        throws java.lang.Exception
Throws:
java.lang.Exception

callStaticMethod

public final java.lang.Object callStaticMethod(java.lang.Class theClass,
                                               java.lang.String methodName,
                                               java.lang.Class[] params,
                                               java.lang.Object[] invokeParams)
                                        throws java.lang.Exception
Throws:
java.lang.Exception

usage

public static void usage()

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception


Copyright 2001-2013 DYNAMIDE.COM. All Rights Reserved.