|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IContext
Defines the node of a tree of IContext nodes, implementing the Composite pattern.
Method Summary | |
---|---|
IContext |
bind(IContext context)
Binds an IContext node by the name in node.getKey(). |
IContext |
bind(java.lang.String key,
IContext context)
Accepts IContext items. |
void |
bindAll(java.util.Map Children)
Add children en masse. |
void |
bindAllAttributes(java.util.Map attributes)
Set the attributes en masse. |
void |
bindAttribute(java.lang.String attributeName,
java.lang.Object value)
|
java.lang.String |
dumpAttributes(boolean html)
|
java.lang.String |
dumpContext(boolean html)
|
java.lang.Object |
find(java.lang.String path)
Find an object based on the path from the current context, using "/" as the path element separator. |
java.lang.Object |
find(java.lang.String[] path)
Find an object, based on a path that is an array of strings, one for each context, starting from "this" object, For example, if you already have a handle to the root WebApps context, called "webapps" here: webapps.find({"/dynamide/demo"}); Or, String[] path = {"/dynamide/demo"}; webapps.find(path); To search from the root, use ResourceManager.find(String[]), which it gets from ContextNode. |
java.lang.Object |
find(java.lang.String path,
java.lang.String separator)
Find an object based on the path from the current context, using "separator" as the path element separator. |
IContext |
firstContext()
simply return the first context in list of contexts, or null if list is empty. |
java.lang.Object |
getAttribute(java.lang.String attributeName)
|
int |
getAttributeCount()
You can use this method to return zero if you have not yet instantiated a collection of attributes. |
java.util.Map |
getAttributes()
You must not return null if the attributes are empty, but rather always return an empty Map. |
IContext |
getContext(java.lang.String key)
You either use the concrete com.dynamide.resource.ContextNode as a node in the context tree, or you implement this IContext interface. |
int |
getContextCount()
|
java.util.Map |
getContexts()
You must not return null if the contexts collection is empty, but rather always return an empty Map. |
java.lang.String |
getKey()
|
java.security.Permission |
getPermission(java.lang.String permissionName)
|
boolean |
hasAttribute(java.lang.String attributeName)
|
boolean |
hasContext(java.lang.String key)
|
void |
lockPermissions(java.security.Permissions permissions)
Once permissions are set using lockPermissions, impls should not allow them to be changed. |
IContext |
rebind(IContext context)
Binds an IContext node by the name in context.getKey(). |
IContext |
rebind(java.lang.String key,
IContext context)
Won't throw an ObjectAlreadyBoundException if one exists with the same key, just silently replaces it. |
void |
rebindAttribute(java.lang.String attributeName,
java.lang.Object value)
|
IContext |
remove(java.lang.String key)
|
java.lang.Object |
removeAttribute(java.lang.String key)
|
IContext |
removeFirstContext()
simply return the first context in list of contexts, and remove it, or null if list is empty. |
void |
setKey(java.lang.String key)
|
void |
unlockPermissions(java.security.Permissions permissions)
|
void |
update()
(Optional) Implementations should re-read resources and lists of resources, e.g. files from disk. |
Method Detail |
---|
java.lang.String getKey()
void setKey(java.lang.String key)
void lockPermissions(java.security.Permissions permissions) throws java.lang.SecurityException
java.lang.SecurityException
void unlockPermissions(java.security.Permissions permissions) throws java.lang.SecurityException
java.lang.SecurityException
java.security.Permission getPermission(java.lang.String permissionName)
java.lang.Object getAttribute(java.lang.String attributeName)
boolean hasAttribute(java.lang.String attributeName)
int getAttributeCount()
java.util.Map getAttributes()
void bindAttribute(java.lang.String attributeName, java.lang.Object value) throws java.lang.SecurityException, ObjectAlreadyBoundException
java.lang.SecurityException
ObjectAlreadyBoundException
void rebindAttribute(java.lang.String attributeName, java.lang.Object value) throws java.lang.SecurityException
java.lang.SecurityException
void bindAllAttributes(java.util.Map attributes) throws java.lang.SecurityException, ObjectAlreadyBoundException
java.lang.SecurityException
ObjectAlreadyBoundException
IContext firstContext()
IContext removeFirstContext()
IContext getContext(java.lang.String key)
You either use the concrete com.dynamide.resource.ContextNode as a node in the context tree, or you implement this IContext interface. Then for getResource, return the "this" pointer to your implementation object. Optionally, you can perform some other operation to get the actual resource, in which case your concrete class is a proxy, lazy-loader, etc.
All implementations should check for the special cases: "." means "this context", as does the empty string, "". For both, return the current context, which in most implementations means:
public IContext getContext(String key){ if ( key.equals(".") || key.length() == 0 ) { return this; } ... }
boolean hasContext(java.lang.String key)
java.util.Map getContexts()
int getContextCount()
void bindAll(java.util.Map Children) throws java.lang.SecurityException, ObjectAlreadyBoundException
java.lang.SecurityException
ObjectAlreadyBoundException
IContext bind(java.lang.String key, IContext context) throws java.lang.SecurityException, ObjectAlreadyBoundException
java.lang.SecurityException
ObjectAlreadyBoundException
IContext bind(IContext context) throws java.lang.SecurityException, ObjectAlreadyBoundException
IContext root = new ContextNode(null, "root"); root.bind(new ContextNode(null, "child1")).bind(new ContextNode(null, "child2"));
java.lang.SecurityException
ObjectAlreadyBoundException
bind(String,IContext)
IContext rebind(java.lang.String key, IContext context) throws java.lang.SecurityException
java.lang.SecurityException
bind(String,IContext)
IContext rebind(IContext context) throws java.lang.SecurityException
java.lang.SecurityException
rebind(String,IContext)
IContext remove(java.lang.String key) throws java.lang.SecurityException
java.lang.SecurityException
java.lang.Object removeAttribute(java.lang.String key) throws java.lang.SecurityException
java.lang.SecurityException
java.lang.Object find(java.lang.String[] path)
Find an object, based on a path that is an array of strings, one for each context, starting from "this" object,
For example, if you already have a handle to the root WebApps context, called "webapps" here:
webapps.find({"/dynamide/demo"});Or,
String[] path = {"/dynamide/demo"}; webapps.find(path);To search from the root, use ResourceManager.find(String[]), which it gets from ContextNode.
String [] path= {"web-apps", "/dynamide/demo"}; Object o = ResourceManager.find(path)
Same rules as getContext(), which include: if the path is "" or ".', return a pointer to "this".
path
- An array of strings, each one naming a context.find(String,String)
,
ContextNode.find(String [] path)
,
getContext(String)
java.lang.Object find(java.lang.String path)
Find an object based on the path from the current context, using "/" as the path element separator. This method will return the wrong result if the context id's can contain slashes themselves, such as resource locations within the Assembly tree.
java.lang.Object find(java.lang.String path, java.lang.String separator)
Find an object based on the path from the current context, using "separator" as the path element separator. Take care that separator does not appear in element names. If you cannot ensure this, use find(String[] path) instead.
Same rules as getContext(String), which include: if the path is "" or ".', return a pointer to "this".
find(String [] path)
,
ContextNode.find(String [] path)
,
getContext(String)
void update()
java.lang.String dumpContext(boolean html)
java.lang.String dumpAttributes(boolean html)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |