| java.lang.Object org.apache.naming.core.BaseNaming
All known Subclasses: org.apache.naming.core.BaseContext,
BaseNaming | public class BaseNaming (Code) | | This is the base class for our naming operations, for easy reading.
Creating a new context:
- Create a new class, extending BaseContext or BaseDirContext ( second
if you want to support attributes ).
- Add setters for configuration. The setters will be called autmatically,
like in ant, from the initial env settings.
- Override methods that are defined in BaseNaming. Default behavior
is provided for all.
- If performance is a concern or have special behavior - override Context and
DirContext methods. That shouldn't be needed in most cases.
This class is designed to minimize the ammount of code that is required to
create a new context. The usual DirContext interface has way too many methods,
so implementation requires a lot of typing.
Our contexts are mostly wrappers for files or in memory structures. That means
some operations are cheaper, and we're far from the features that would be
exposed for an LDAP or real Directory server.
author: Remy Maucherat author: Costin Manolache |
Constructor Summary | |
public | BaseNaming() Builds a base directory context. | public | BaseNaming(Hashtable env) Builds a base directory context using the given environment. |
Method Summary | |
public void | allocate() Allocate resources for this directory context. | public void | bind(Name name, Object obj, Attributes attrs, boolean rebind) The setter method. | protected void | checkWritable(Name n) Throws a naming exception is Context is not writable. | public DirContext | createSubcontext(Name name, Attributes attrs) | public void | execute() Just a hack so that all DirContexts can be used as tasks. | public Object | getAttribute(Name name, String attName) | public String[] | getAttributeNames(Name name) | public int | getCacheObjectMaxSize() | public int | getCacheTTL() | public Enumeration | getChildren() Return the child elements, if any.
This is a String or Name or Binding or NameClassPari enumeration -
the Context implementation will wrap it as a NamingEnumeration and
construct the right information.
XXX name is all we need - all other info can be extracted - with some
penalty. | public boolean | isCached() | protected boolean | isWritable(Name name) Returns true if writing is allowed on this context. | public Object | lookup(Name name, boolean resolveLinks) The lookup method. | public void | recycle() | public void | release() Release any resources allocated for this directory context. | public void | setAttribute(Name name, String attName, Object value) | public void | setCacheObjectMaxSize(int cacheObjectMaxSize) | public void | setCacheTTL(int cacheTTL) | public void | setCached(boolean cached) | public void | setURLPrefix(String s) | protected Name | string2Name(String s) | public void | unbind(Name name, boolean isContext) Remove a binding. |
nameParser | final protected NameParser nameParser(Code) | | Default name parser for this context.
XXX This should be combined with the Tomcat mapper, and
optimized for MessageBytes.
|
urlPrefix | protected String urlPrefix(Code) | | Prefix used for URL-based namming lookup. It must be removed
from all names.
Deprecated ? Do we need it ?
|
BaseNaming | public BaseNaming()(Code) | | Builds a base directory context.
|
BaseNaming | public BaseNaming(Hashtable env)(Code) | | Builds a base directory context using the given environment.
|
allocate | public void allocate()(Code) | | Allocate resources for this directory context.
|
bind | public void bind(Name name, Object obj, Attributes attrs, boolean rebind) throws NamingException(Code) | | The setter method. Implement it if the context is read/write.
Parameters: name - Parameters: obj - The object to be bound. Parameters: attrs - Attributes - if this is a dir context, null otherwise Parameters: rebind - What to do if the name is already bound. XXX can be further simplified - do a lookup and implement it. |
checkWritable | protected void checkWritable(Name n) throws NamingException(Code) | | Throws a naming exception is Context is not writable.
|
execute | public void execute()(Code) | | Just a hack so that all DirContexts can be used as tasks.
They'll do nothing - the setters will be called ( just like
new Context(Hashtable) - since we use introspection ) and the
context can be registred as a reference in the Project ns.
Then other tasks could manipulate it by name.
In a future version of ant we should have the 'references'
pluggable and a possible impl should be JNDI.
Alternative: there is a way to use tasks without this method,
but for now it's simpler.
|
getCacheObjectMaxSize | public int getCacheObjectMaxSize()(Code) | | |
getCacheTTL | public int getCacheTTL()(Code) | | |
getChildren | public Enumeration getChildren() throws NamingException(Code) | | Return the child elements, if any.
This is a String or Name or Binding or NameClassPari enumeration -
the Context implementation will wrap it as a NamingEnumeration and
construct the right information.
XXX name is all we need - all other info can be extracted - with some
penalty. It's easy to do some instanceof tricks to avoid it, if possible,
but the goal is to make it easy to write contexts, and name should be
enough.
|
isCached | public boolean isCached()(Code) | | |
isWritable | protected boolean isWritable(Name name)(Code) | | Returns true if writing is allowed on this context.
|
lookup | public Object lookup(Name name, boolean resolveLinks) throws NamingException(Code) | | The lookup method. This is the main method you should implement.
Parameters: name - Parameters: resolveLinks - If false, this is a lookupLink call. |
recycle | public void recycle()(Code) | | |
release | public void release()(Code) | | Release any resources allocated for this directory context.
|
setCacheObjectMaxSize | public void setCacheObjectMaxSize(int cacheObjectMaxSize)(Code) | | |
setCacheTTL | public void setCacheTTL(int cacheTTL)(Code) | | |
setCached | public void setCached(boolean cached)(Code) | | |
unbind | public void unbind(Name name, boolean isContext) throws NamingException(Code) | | Remove a binding. XXX do we need the isContext case ?
|
|
|