|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.dynamide.DynamideObject com.dynamide.resource.ContextNode com.dynamide.resource.Pool com.dynamide.resource.Assembly
public class Assembly
Each assembly turns into a cache of resources at runtime. This Assembly class extends Pool, and keeps each resource in an IContext node.
The context key is the path of the resource name of the resource, which is the name relative to the assembly root or to the resources directories inside the assembly or application. When the resource is not in cache, the context object is null, but the key is present. So hasContext() will return true, but getContext will still return null. When the resource is in cache, the IContext returned by getContext(key) will have information about the resource's contents. It will have the following attributes:
Attributes associated with this object are:
Field Summary | |
---|---|
static java.lang.String |
ACCESSED
|
static java.lang.String |
ASSEMBLY
|
static java.lang.String |
ASSEMBLY_STANDARD_NAME
|
static java.lang.String |
ASSEMBLYDIR
|
static java.lang.String |
BASENAME
|
static java.lang.String |
BASENAMES
key for the collection of basenames IContexts, which hold the list of assembly-build names that provide this basename. |
static java.lang.String |
BINARY
|
static java.lang.String |
BUILD
|
static java.lang.String |
CACHE_REL
|
static java.lang.String |
CACHED
|
static java.lang.String |
CAT_CACHE
|
static java.lang.String |
CONTENT
|
static java.lang.String |
DEFAULT_INTERFACE_NUMBER
|
static java.lang.String |
FALSE
|
static java.lang.String |
FULLPATH
|
static java.lang.String |
HITS
|
static java.lang.String |
IMPORTS
|
static java.lang.String |
IN_MEMORY_RESOURCE
|
static java.lang.String |
INTERFACE
|
protected static boolean |
LOG_CACHING
|
static java.lang.String |
MODIFIED
|
static java.lang.String |
NAME
|
static java.lang.String |
TRUE
|
static java.lang.String |
WIDGETS_DIR_REL_RESOURCES
|
Fields inherited from class com.dynamide.resource.Pool |
---|
DEFAULT_POOL_TIMEOUT |
Fields inherited from class com.dynamide.DynamideObject |
---|
m_id |
Constructor Summary | |
---|---|
Assembly(DynamideObject owner)
Illegal to call directly - use ResourceManger.createAssembly() instead, from the Root ResourceManger. |
|
Assembly(DynamideObject owner,
java.lang.String key,
java.lang.String account,
java.lang.String RESOURCE_ROOT)
Illegal to call directly - use ResourceManger.createAssembly() instead, from the Root ResourceManger. |
Method Summary | |
---|---|
static void |
accessed(IContext context)
|
static Assembly |
createAssembly(ResourceManager resourceManager,
IContext assemblies,
java.io.File assemblyDir,
java.lang.String assemblyName,
java.lang.String account,
java.lang.String RESOURCE_ROOT,
boolean isCacheOn)
|
static byte[] |
extractBinaryResourceContent(IContext node)
Get the content of the resource as a byte array. |
static java.lang.String |
extractResourceContent(IContext node)
Get the content of the resource as a String from an IContext node. |
java.lang.String |
extractResourceContent(java.lang.String resourceID)
Get the content of the resource as a String, by resourceID. |
static Assembly |
findAssembly(IContext assemblies,
java.lang.String basename,
java.lang.String interfaceNumber,
java.lang.String build)
Find Assembly in "assemblies" IContext param, matching basename param, with these rules: First rule: find assembly for build number Second rule: find assembly for interface number |
Assembly |
findImport(java.lang.String assemblyName,
java.lang.String assemblyInterfaceNumber,
java.lang.String assemblyBuild)
|
java.lang.String |
getAccount()
|
IContext |
getApplicationResource(java.lang.String applicationName,
java.lang.String resourceID)
Each assembly has two places to look for resources: in the resources folder of the assembly in the apps/${appname}/resources folder of the assembly So resources that are not things like page1.xml or application.xml should go in one of those folders and thus begin with "resources/". |
java.lang.String |
getAssemblyDirectory()
The name of the directory that the Assembly expanded to. |
java.lang.String |
getBuildName()
|
java.util.List |
getImports()
|
java.lang.String |
getImportsFullPath()
|
java.lang.String |
getImportsFullPath(java.lang.String separator)
|
IContext |
getImportsFullPathAsContext()
|
java.lang.String |
getImportsPath()
|
java.lang.String |
getInclude(java.lang.String applicationPath,
java.lang.String applicationName,
java.lang.String includeName)
Turn a relative resource name into an include statement for HTML. |
java.lang.String |
getInclude(java.lang.String applicationPath,
java.lang.String applicationName,
java.lang.String includeName,
java.lang.String cachePrefix)
|
static java.lang.String |
getMimeType(java.lang.String key)
|
IContext |
getResource(java.lang.String key)
Get the IContext node that contains the references to the resource named by key, where key is relative to the root of this assembly. |
IContext |
getResource(java.lang.String resourceID,
boolean checkImports)
Get a resource, optionally looking in all imported assemblies. |
java.lang.String |
getResourceFilename(java.lang.String resourceID)
|
boolean |
hasManifestEntry(java.lang.String key)
Resources are listed in the manifest of this Assembly at run time only, and that entry indicates that the resource can be found in this Assembly context. |
boolean |
hasResource(java.lang.String key)
|
void |
invalidate(java.lang.String key)
Removes the resources content from the cache. |
static boolean |
isBinaryResource(IContext node)
This override operates on an IContext node that represents a resource in the Assembly cache. |
static boolean |
isBinaryResource(java.lang.String key)
This override operates on a String resource name, and inspects the "extension" (the characters after the last dot in the name) to determine if the resourcetype is binary. |
boolean |
isCacheOn()
|
static java.lang.String |
listResource(IContext context)
|
java.lang.String |
listResource(java.lang.String key)
Produces a listing showing the attributes of this cached resource. |
StringList |
listResourceNames()
Produces a StringList containing a bare listing of relative path resource names that have been read into the memory cache. |
java.lang.String |
listResourceNames(java.lang.String lineBreak)
Produces a bare listing of relative path resource names that have been read into the memory cache. |
java.lang.String |
listResourceNamesInCache()
Produces a bare listing of relative path resource names that have been read into the memory cache. |
java.util.Map |
listTemplates(java.lang.String relDirectory)
|
void |
logCaching(java.lang.String msg)
|
static void |
main(java.lang.String[] args)
|
boolean |
onDirectory(java.lang.String diveID,
java.io.File directory,
java.lang.String dirname,
java.lang.String relativePath)
From: IFileDiverListener interface, and is for internal use only. |
void |
onFile(java.lang.String diveID,
java.io.File directory,
java.io.File file,
java.lang.String filename,
java.lang.String relativePath)
From: IFileDiverListener interface, and is for internal use only. |
static IContext |
readResource(IContext context)
|
protected static IContext |
readResource(IContext context,
java.lang.String key,
java.lang.String fullpath)
Important: doesn't rebind the ASSEMBLYDIR attribute, since this method is static. |
IContext |
registerApplicationResource(java.lang.String applicationName,
java.lang.String resourceID)
Enter the resource into the Assembly's tree, but even though the file may not exist on disk yet, though it is best to save the resource to disk and then call registerApplicationResource. |
void |
setAssemblyDirectory(java.lang.String new_value)
The name of the directory that the Assembly expanded to. |
static IContext |
setBinaryContent(IContext context,
byte[] buff,
java.lang.String fullpath,
java.lang.Long lastModified,
boolean inMemory)
|
static IContext |
setContent(IContext context,
java.lang.String content,
java.lang.String fullpath,
java.lang.Long lastModified,
boolean inMemory)
|
java.lang.String |
toString()
|
void |
update()
(Optional) Implementations should re-read resources and lists of resources, e.g. files from disk. |
void |
updateResource(java.lang.String relativePath)
|
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, setKey, unlockPermissions, writeCache |
Methods inherited from class com.dynamide.DynamideObject |
---|
clearProfiler, dump, dumpHTML, expand, finalize, findParentExpander, findParentPage, findParentSession, findTopParentPage, getCategoryID, 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 |
---|
clone, 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, setKey, unlockPermissions |
Field Detail |
---|
public static final java.lang.String ACCESSED
public static final java.lang.String BINARY
public static final java.lang.String CACHED
public static final java.lang.String CACHE_REL
public static final java.lang.String CONTENT
public static final java.lang.String FULLPATH
public static final java.lang.String HITS
public static final java.lang.String MODIFIED
public static final java.lang.String ASSEMBLY
public static final java.lang.String ASSEMBLY_STANDARD_NAME
public static final java.lang.String ASSEMBLYDIR
public static final java.lang.String BASENAME
public static final java.lang.String BUILD
public static final java.lang.String IMPORTS
public static final java.lang.String INTERFACE
public static final java.lang.String NAME
public static final java.lang.String BASENAMES
public static final java.lang.String CAT_CACHE
public static final java.lang.String DEFAULT_INTERFACE_NUMBER
public static final java.lang.String FALSE
public static final java.lang.String TRUE
public static final java.lang.String IN_MEMORY_RESOURCE
protected static boolean LOG_CACHING
public static final java.lang.String WIDGETS_DIR_REL_RESOURCES
Constructor Detail |
---|
public Assembly(DynamideObject owner) throws java.lang.SecurityException
java.lang.SecurityException
- if the direct caller is not ResourceManger.createAssembly() on the Root ResourceManger.public Assembly(DynamideObject owner, java.lang.String key, java.lang.String account, java.lang.String RESOURCE_ROOT) throws java.lang.SecurityException
java.lang.SecurityException
- if the direct caller is not ResourceManger.createAssembly() on the Root ResourceManger.Method Detail |
---|
public static Assembly createAssembly(ResourceManager resourceManager, IContext assemblies, java.io.File assemblyDir, java.lang.String assemblyName, java.lang.String account, java.lang.String RESOURCE_ROOT, boolean isCacheOn) throws java.lang.Exception
java.lang.Exception
public static byte[] extractBinaryResourceContent(IContext node) throws ResourceException
ResourceException
public static java.lang.String extractResourceContent(IContext node) throws ResourceException
ResourceException
public static Assembly findAssembly(IContext assemblies, java.lang.String basename, java.lang.String interfaceNumber, java.lang.String build)
public static boolean isBinaryResource(IContext node)
public static boolean isBinaryResource(java.lang.String key)
public static java.lang.String getMimeType(java.lang.String key)
public static java.lang.String listResource(IContext context)
public static IContext readResource(IContext context)
protected static IContext readResource(IContext context, java.lang.String key, java.lang.String fullpath)
public static IContext setBinaryContent(IContext context, byte[] buff, java.lang.String fullpath, java.lang.Long lastModified, boolean inMemory)
inMemory
- Indicates that the resource is not to be found on disk,
so subsequent calls to getResource will NOT attempt to look for the latest resource from disk,
which is useful if you construct a resource in memory or pull if off a socket, etc.public static IContext setContent(IContext context, java.lang.String content, java.lang.String fullpath, java.lang.Long lastModified, boolean inMemory)
inMemory
- Indicates that the resource is not to be found on disk,
so subsequent calls to getResource will NOT attempt to look for the latest resource from disk,
which is useful if you construct a resource in memory or pull if off a socket, etc.public static void accessed(IContext context)
public java.lang.String extractResourceContent(java.lang.String resourceID) throws ResourceException
ResourceException
public Assembly findImport(java.lang.String assemblyName, java.lang.String assemblyInterfaceNumber, java.lang.String assemblyBuild)
public java.lang.String getAccount()
public IContext getApplicationResource(java.lang.String applicationName, java.lang.String resourceID)
public java.lang.String getAssemblyDirectory()
public java.lang.String getBuildName()
public java.util.List getImports()
public java.lang.String getImportsFullPath()
public java.lang.String getImportsFullPath(java.lang.String separator)
public IContext getImportsFullPathAsContext()
public java.lang.String getImportsPath()
public java.lang.String getInclude(java.lang.String applicationPath, java.lang.String applicationName, java.lang.String includeName)
js/page.js images/map.jpg
public java.lang.String getInclude(java.lang.String applicationPath, java.lang.String applicationName, java.lang.String includeName, java.lang.String cachePrefix)
public java.lang.String getResourceFilename(java.lang.String resourceID)
public IContext getResource(java.lang.String key)
Get the IContext node that contains the references to the resource named by key, where key is
relative to the root of this assembly. Use the functions in Assembly, namely isBinaryResource(IContext),
extractBinaryResourceContent, and extractResourceContent to get to the actual resource content.
For example:
IContext context = assembly.getResource("css/dynamide.css"); String mycss = Assembly.extractResourceContent(context);
Also, this would be legal if you didn't know if the resource were binary:
IContext context = assembly.getResource("css/dynamide.css"); if (Assembly.isBinaryResource(context)){ String mycontents = Assembly.extractResourceContent(context); ... } else { byte [] mybytes = Assembly.extractBinaryResourceContent(context); ... }
public IContext getResource(java.lang.String resourceID, boolean checkImports)
public boolean hasManifestEntry(java.lang.String key)
public boolean hasResource(java.lang.String key)
public void invalidate(java.lang.String key)
key
- If key is currently cached, remove the contents from the cache, but keep the key
to imply that the resource is found in our manifest, but since the value is null, the
Assembly should once again look on disk or other repository for the resource.public boolean isCacheOn()
public java.lang.String listResource(java.lang.String key)
public StringList listResourceNames()
listResourceNames()
public java.lang.String listResourceNames(java.lang.String lineBreak)
listResourceNames()
public java.lang.String listResourceNamesInCache()
listResourceNames()
public java.util.Map listTemplates(java.lang.String relDirectory) throws java.lang.Exception
java.lang.Exception
public final void logCaching(java.lang.String msg)
public boolean onDirectory(java.lang.String diveID, java.io.File directory, java.lang.String dirname, java.lang.String relativePath)
onDirectory
in interface IFileDiverListener
diveID
- This identifies the callback so that you know which thing you are doing if you use the
callback interface for two tasks within one class, or within multiple threads.
FileTools.directoryDiver(java.lang.String, java.lang.String, com.dynamide.util.IFileDiverListener)
public void onFile(java.lang.String diveID, java.io.File directory, java.io.File file, java.lang.String filename, java.lang.String relativePath)
onFile
in interface IFileDiverListener
diveID
- This identifies the callback so that you know which thing you are doing if you use the
callback interface for two tasks within one class, or within multiple threads.FileTools.directoryDiver(java.lang.String, java.lang.String, com.dynamide.util.IFileDiverListener)
public IContext registerApplicationResource(java.lang.String applicationName, java.lang.String resourceID)
public void setAssemblyDirectory(java.lang.String new_value) throws java.lang.Exception
java.lang.Exception
public java.lang.String toString()
toString
in class ContextNode
public void update()
IContext
update
in interface IContext
update
in class ContextNode
public void updateResource(java.lang.String relativePath)
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |