You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2003/02/26 19:52:12 UTC
cvs commit: jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/fs FileDirContext.java
costin 2003/02/26 10:52:12
Modified: naming build.xml
naming/src/org/apache/naming/ant JndiProperties.java
naming/src/org/apache/naming/core BaseContext.java
BaseDirContext.java BaseNaming.java
NamingContextEnumeration.java ServerAttribute.java
ServerAttributes.java
naming/src/org/apache/naming/modules/fs FileDirContext.java
Log:
Various updates and improvments.
It requires ant1.6 ( i.e. HEAD or recent build ) - since it uses and implements dynamic
properties.
Revision Changes Path
1.3 +18 -9 jakarta-tomcat-connectors/naming/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/naming/build.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- build.xml 8 Oct 2002 18:46:42 -0000 1.2
+++ build.xml 26 Feb 2003 18:52:11 -0000 1.3
@@ -51,36 +51,45 @@
</target>
<target name="test" >
- <systemPath pathRef="build-main.classpath" />
+ <classloader classpathRef="build-main.classpath" />
+
<taskdef name="jndiSet" classname="org.apache.naming.ant.JndiSet"/>
<taskdef name="jndiProperties" classname="org.apache.naming.ant.JndiProperties"/>
<taskdef name="jndiFileCtx" classname="org.apache.naming.modules.fs.FileDirContext"/>
+ <!-- Enable ${jndi:...} dynamic properties -->
<jndiProperties/>
+
+ <!-- memory context -->
<jndiSet context="/foo" value="bar" />
+ <echo message="Value: ${jndi:/foo}"/>
- <jndiFileCtx docBase="/tmp" id="docBaseId" />
- <jndiSet context="/test" refId="docBaseId" />
+ <property name="dirname" location="." />
- <echo message="Value: ${jndi:/foo}"/>
- <echo message="Value: ${jndi:/test/test}"/>
- <echo message="Value: ${jndi:fs:/tmp/test}"/>
+ <!-- Create a JNDI context for the current dir -->
+ <jndiFileCtx docBase="${dirname}" id="docBaseId" />
+
+ <!-- Bind the file context to /currentDir -->
+ <jndiSet context="/currentDir" refId="docBaseId" />
+
+ <echo message="Value: ${jndi:/currentDir/build.xml}"/>
+ <echo message="Value: ${jndi:fs:/tmp}"/>
</target>
<target name="browser">
<java classpathref="build-main.classpath"
classname="examples.browser.Browser" fork="true">
- <sysproperty key="java.naming.dns.url" value="dns://129.150.254.2/wyn.org"/>
+ <sysproperty key="java.naming.dns.url" value="dns://10.0.0.1/covalent.net"/>
<!-- LABEL|java.naming.factory.initial|java.naming.provider.url|root|auth( none, simple, etc ) |princ|pass -->
<arg value="LDAP|com.sun.jndi.ldap.LdapCtxFactory|ldap://localhost:389|dc=wyn,dc=org|simple|cn=Manager,dc=wyn,dc=org|secret" />
<!-- arg value="File|com.sun.jndi.fscontext.RefFSContextFactory|file:/" /-->
<arg value="DSML|com.sun.jndi.dsml.DsmlCtxFactory|file:/tmp/test.dsml.xml" />
<arg value="DNS|com.sun.jndi.dns.DnsContextFactory|dns://127.0.0.1/localhost" />
- <arg value="FS|org.apache.naming.fs.fsURLContextFactory|fs:/" />
- <arg value="Mem|org.apache.naming.memory.memoryURLContextFactory|memory:/" />
+ <arg value="FS|org.apache.naming.modules.fs.fsURLContextFactory|fs:/" />
+ <arg value="Mem|org.apache.naming.modules.memory.memoryURLContextFactory|memory:/" />
</java>
</target>
1.3 +43 -23 jakarta-tomcat-connectors/naming/src/org/apache/naming/ant/JndiProperties.java
Index: JndiProperties.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/ant/JndiProperties.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JndiProperties.java 8 Oct 2002 18:46:42 -0000 1.2
+++ JndiProperties.java 26 Feb 2003 18:52:12 -0000 1.3
@@ -70,11 +70,12 @@
*
* @author Costin Manolache
*/
-public class JndiProperties extends Task implements PropertyInterceptor {
+public class JndiProperties extends Task {
public static String PREFIX="jndi:";
private static org.apache.commons.logging.Log log=
org.apache.commons.logging.LogFactory.getLog( JndiProperties.class );
-
+ private JndiHelper helper=new JndiHelper();
+
public JndiProperties() {
initNaming();
}
@@ -87,32 +88,51 @@
// System.setProperty( "java.naming.factory.initial", "org.apache.naming.memory.MemoryInitialContextFactory" );
}
- public boolean setProperty( Object p, String ns, String name, Object value ) {
- return false;
- }
+ class JndiHelper extends PropertyHelper {
+ public boolean setPropertyHook( String ns, String name, Object v, boolean inh,
+ boolean user, boolean isNew)
+ {
+ if( ! name.startsWith(PREFIX) ) {
+ // pass to next
+ return super.setPropertyHook(ns, name, v, inh, user, isNew);
+ }
+ name=name.substring( PREFIX.length() );
+
+ // XXX later
+
+ return true;
+ }
+
+ public Object getPropertyHook( String ns, String name , boolean user) {
+ if( ! name.startsWith(PREFIX) ) {
+ // pass to next
+ return super.getPropertyHook(ns, name, user);
+ }
- public Object getProperty( Object p, String ns, String name ) {
- if( ! name.startsWith( PREFIX ) )
- return null;
-
- Object o=null;
- name=name.substring( PREFIX.length() );
- try {
- InitialContext ic=new InitialContext();
- // XXX lookup attribute in DirContext ?
- o=ic.lookup( name );
- if( log.isDebugEnabled() ) log.debug( "getProperty jndi: " + name + " " + o);
- } catch( Exception ex ) {
- log.error("getProperty " + name , ex);
- o=null;
+ Object o=null;
+ name=name.substring( PREFIX.length() );
+ try {
+ InitialContext ic=new InitialContext();
+ // XXX lookup attribute in DirContext ?
+ o=ic.lookup( name );
+ if( log.isDebugEnabled() ) log.debug( "getProperty jndi: " + name + " " + o);
+ } catch( Exception ex ) {
+ log.error("getProperty " + name , ex);
+ o=null;
+ }
+ return o;
}
- return o;
+
}
-
-
+
+
public void execute() {
PropertyHelper phelper=PropertyHelper.getPropertyHelper( project );
- phelper.addPropertyInterceptor( this );
+ helper.setProject( project );
+ helper.setNext( phelper.getNext() );
+ phelper.setNext( helper );
+
+ project.addReference( "jndiProperties", this );
}
}
1.3 +49 -72 jakarta-tomcat-connectors/naming/src/org/apache/naming/core/BaseContext.java
Index: BaseContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/BaseContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BaseContext.java 5 Nov 2002 19:06:59 -0000 1.2
+++ BaseContext.java 26 Feb 2003 18:52:12 -0000 1.3
@@ -62,14 +62,8 @@
import java.util.*;
import javax.naming.*;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
-import org.apache.tomcat.util.res.StringManager;
-
// Based on a merge of various catalina naming contexts
// Name is used - it provide better oportunities for reuse and optimizations
@@ -110,7 +104,7 @@
*
* @param name the name of the object to look up
* @return the object bound to name
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Object lookup(Name name)
throws NamingException {
@@ -122,7 +116,7 @@
*
* @param name the name of the object to look up
* @return the object bound to name
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Object lookup(String name)
throws NamingException {
@@ -137,10 +131,8 @@
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception NameAlreadyBoundException if name is already bound
- * @exception InvalidAttributesException if object did not supply all
- * mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NameAlreadyBoundException if name is already bound
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void bind(Name name, Object obj)
throws NamingException {
@@ -153,10 +145,8 @@
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception NameAlreadyBoundException if name is already bound
- * @exception InvalidAttributesException if object did not supply all
- * mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NameAlreadyBoundException if name is already bound
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void bind(String name, Object obj)
throws NamingException {
@@ -175,9 +165,7 @@
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception InvalidAttributesException if object did not supply all
- * mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void rebind(Name name, Object obj)
throws NamingException {
@@ -190,9 +178,7 @@
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception InvalidAttributesException if object did not supply all
- * mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void rebind(String name, Object obj)
throws NamingException {
@@ -210,9 +196,9 @@
* NameNotFoundException if any of the intermediate contexts do not exist.
*
* @param name the name to bind; may not be empty
- * @exception NameNotFoundException if an intermediate context does not
+ * @exception javax.naming.NameNotFoundException if an intermediate context does not
* exist
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void unbind(Name name)
throws NamingException {
@@ -233,8 +219,8 @@
*
* @param oldName the name of the existing binding; may not be empty
* @param newName the name of the new binding; may not be empty
- * @exception NameAlreadyBoundException if newName is already bound
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NameAlreadyBoundException if newName is already bound
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void rename(String oldName, String newName)
throws NamingException {
@@ -253,7 +239,7 @@
* @param name the name of the context to list
* @return an enumeration of the names and class names of the bindings in
* this context. Each element of the enumeration is of type NameClassPair.
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration list(String name)
throws NamingException {
@@ -262,7 +248,7 @@
public NamingEnumeration list(Name name)
throws NamingException {
- return new NamingContextEnumeration(super.getChildren(), this, false);
+ return new NamingContextEnumeration(getChildren(), this, false);
}
@@ -277,11 +263,11 @@
* @param name the name of the context to list
* @return an enumeration of the bindings in this context.
* Each element of the enumeration is of type Binding.
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration listBindings(Name name)
throws NamingException {
- return new NamingContextEnumeration(super.getChildren(), this, true);
+ return new NamingContextEnumeration(getChildren(), this, true);
}
public NamingEnumeration listBindings(String name)
@@ -310,9 +296,9 @@
* the foreign context's "native" naming system.
*
* @param name the name of the context to be destroyed; may not be empty
- * @exception NameNotFoundException if an intermediate context does not
+ * @exception javax.naming.NameNotFoundException if an intermediate context does not
* exist
- * @exception NotContextException if the name is bound but does not name
+ * @exception javax.naming.NotContextException if the name is bound but does not name
* a context, or does not name a context of the appropriate type
*/
public void destroySubcontext(Name name)
@@ -325,9 +311,9 @@
* Destroys the named context and removes it from the namespace.
*
* @param name the name of the context to be destroyed; may not be empty
- * @exception NameNotFoundException if an intermediate context does not
+ * @exception javax.naming.NameNotFoundException if an intermediate context does not
* exist
- * @exception NotContextException if the name is bound but does not name
+ * @exception javax.naming.NotContextException if the name is bound but does not name
* a context, or does not name a context of the appropriate type
*/
public void destroySubcontext(String name)
@@ -344,10 +330,8 @@
*
* @param name the name of the context to create; may not be empty
* @return the newly created context
- * @exception NameAlreadyBoundException if name is already bound
- * @exception InvalidAttributesException if creation of the subcontext
- * requires specification of mandatory attributes
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NameAlreadyBoundException if name is already bound
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Context createSubcontext(Name name)
throws NamingException {
@@ -359,6 +343,15 @@
return createSubcontext(string2Name(name), null);
}
+ public void rename(Name oldName, Name newName)
+ throws NamingException
+ {
+ // Override if needed
+ Object value = lookup(oldName, false);
+ bind(newName, value, null, false);
+ unbind(oldName, true);
+
+ }
/**
* Retrieves the named object, following links except for the terminal
@@ -368,7 +361,7 @@
* @param name the name of the object to look up
* @return the object bound to name, not following the terminal link
* (if any).
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Object lookupLink(Name name)
throws NamingException {
@@ -383,7 +376,7 @@
* @param name the name of the object to look up
* @return the object bound to name, not following the terminal link
* (if any).
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Object lookupLink(String name)
throws NamingException {
@@ -403,7 +396,7 @@
* @param name the name of the context from which to get the parser
* @return a name parser that can parse compound names into their atomic
* components
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NameParser getNameParser(Name name)
throws NamingException {
@@ -433,7 +426,7 @@
* @param name the name of the context from which to get the parser
* @return a name parser that can parse compound names into their atomic
* components
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NameParser getNameParser(String name)
throws NamingException {
@@ -453,7 +446,7 @@
* @param name a name relative to this context
* @param prefix the name of this context relative to one of its ancestors
* @return the composition of prefix and name
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Name composeName(Name name, Name prefix)
throws NamingException {
@@ -468,7 +461,7 @@
* @param name a name relative to this context
* @param prefix the name of this context relative to one of its ancestors
* @return the composition of prefix and name
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public String composeName(String name, String prefix)
throws NamingException {
@@ -483,7 +476,7 @@
* @param propName the name of the environment property to add; may not
* be null
* @param propVal the value of the property to add; may not be null
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Object addToEnvironment(String propName, Object propVal)
throws NamingException {
@@ -496,7 +489,7 @@
*
* @param propName the name of the environment property to remove;
* may not be null
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Object removeFromEnvironment(String propName)
throws NamingException {
@@ -512,7 +505,7 @@
* may be changed using addToEnvironment() and removeFromEnvironment().
*
* @return the environment of this context; never null
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Hashtable getEnvironment()
throws NamingException {
@@ -528,7 +521,7 @@
* been closed has no effect. Invoking any other method on a closed
* context is not allowed, and results in undefined behaviour.
*
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void close()
throws NamingException {
@@ -550,9 +543,9 @@
* OperationNotSupportedException is thrown.
*
* @return this context's name in its own namespace; never null
- * @exception OperationNotSupportedException if the naming system does
+ * @exception javax.naming.OperationNotSupportedException if the naming system does
* not have the notion of a full name
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public String getNameInNamespace()
throws NamingException {
@@ -572,11 +565,7 @@
* (new SearchControls())).
* @return an enumeration of SearchResults of the objects that satisfy
* the filter; never null
- * @exception InvalidSearchFilterException if the search filter specified
- * is not supported or understood by the underlying directory
- * @exception InvalidSearchControlsException if the search controls
- * contain invalid settings
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search
(Name name, String filter, SearchControls cons)
@@ -598,11 +587,7 @@
* (new SearchControls())).
* @return an enumeration of SearchResults of the objects that satisfy
* the filter; never null
- * @exception InvalidSearchFilterException if the search filter
- * specified is not supported or understood by the underlying directory
- * @exception InvalidSearchControlsException if the search controls
- * contain invalid settings
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(String name, String filter,
SearchControls cons)
@@ -627,13 +612,9 @@
* default search controls are used (equivalent to (new SearchControls())).
* @return an enumeration of SearchResults of the objects that satisy the
* filter; never null
- * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i}
+ * @exception java.lang.ArrayIndexOutOfBoundsException if filterExpr contains {i}
* expressions where i is outside the bounds of the array filterArgs
- * @exception InvalidSearchControlsException if cons contains invalid
- * settings
- * @exception InvalidSearchFilterException if filterExpr with filterArgs
- * represents an invalid search filter
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(Name name, String filterExpr,
Object[] filterArgs, SearchControls cons)
@@ -658,13 +639,9 @@
* default search controls are used (equivalent to (new SearchControls())).
* @return an enumeration of SearchResults of the objects that satisy the
* filter; never null
- * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i}
+ * @exception java.lang.ArrayIndexOutOfBoundsException if filterExpr contains {i}
* expressions where i is outside the bounds of the array filterArgs
- * @exception InvalidSearchControlsException if cons contains invalid
- * settings
- * @exception InvalidSearchFilterException if filterExpr with filterArgs
- * represents an invalid search filter
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(String name, String filterExpr,
Object[] filterArgs,
1.6 +29 -30 jakarta-tomcat-connectors/naming/src/org/apache/naming/core/BaseDirContext.java
Index: BaseDirContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/BaseDirContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BaseDirContext.java 5 Nov 2002 19:06:44 -0000 1.5
+++ BaseDirContext.java 26 Feb 2003 18:52:12 -0000 1.6
@@ -68,9 +68,8 @@
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
-import org.apache.tomcat.util.res.StringManager;
-//import org.apache.naming.NameParserImpl;
+//import org.apache.naming.core.NameParserImpl;
// Based on a merge of various catalina naming contexts
// Name is used - it provide better oportunities for reuse and optimizations
@@ -123,7 +122,7 @@
* @return the set of attributes associated with name.
* Returns an empty attribute set if name has no attributes; never null.
* @param name the name of the object from which to retrieve attributes
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Attributes getAttributes(Name name)
throws NamingException
@@ -137,7 +136,7 @@
*
* @return the set of attributes associated with name
* @param name the name of the object from which to retrieve attributes
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Attributes getAttributes(String name)
throws NamingException
@@ -155,7 +154,7 @@
* @param attrIds the identifiers of the attributes to retrieve. null
* indicates that all attributes should be retrieved; an empty array
* indicates that none should be retrieved
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public Attributes getAttributes(String name, String[] attrIds)
throws NamingException
@@ -192,7 +191,7 @@
* be null
* @exception AttributeModificationException if the modification cannot be
* completed successfully
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void modifyAttributes(Name name, int mod_op, Attributes attrs)
throws NamingException
@@ -232,7 +231,7 @@
* not be null
* @exception AttributeModificationException if the modification cannot be
* completed successfully
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void modifyAttributes(Name name, ModificationItem[] mods)
throws NamingException
@@ -266,10 +265,10 @@
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
* @param attrs the attributes to associate with the binding
- * @exception NameAlreadyBoundException if name is already bound
+ * @exception javax.naming.NameAlreadyBoundException if name is already bound
* @exception InvalidAttributesException if some "mandatory" attributes
* of the binding are not supplied
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void bind(Name name, Object obj, Attributes attrs)
throws NamingException
@@ -317,7 +316,7 @@
* @param attrs the attributes to associate with the binding
* @exception InvalidAttributesException if some "mandatory" attributes
* of the binding are not supplied
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public void rebind(Name name, Object obj, Attributes attrs)
throws NamingException
@@ -344,10 +343,10 @@
* @param name the name of the context to create; may not be empty
* @param attrs the attributes to associate with the newly created context
* @return the newly created context
- * @exception NameAlreadyBoundException if the name is already bound
+ * @exception javax.naming.NameAlreadyBoundException if the name is already bound
* @exception InvalidAttributesException if attrs does not contain all
* the mandatory attributes required for creation
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public DirContext createSubcontext(String name, Attributes attrs)
throws NamingException
@@ -366,8 +365,8 @@
*
* @param name the name of the object whose schema is to be retrieved
* @return the schema associated with the context; never null
- * @exception OperationNotSupportedException if schema not supported
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.OperationNotSupportedException if schema not supported
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public DirContext getSchema(Name name)
throws NamingException
@@ -381,8 +380,8 @@
*
* @param name the name of the object whose schema is to be retrieved
* @return the schema associated with the context; never null
- * @exception OperationNotSupportedException if schema not supported
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.OperationNotSupportedException if schema not supported
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public DirContext getSchema(String name)
throws NamingException
@@ -399,8 +398,8 @@
* be retrieved
* @return the DirContext containing the named object's class
* definitions; never null
- * @exception OperationNotSupportedException if schema not supported
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.OperationNotSupportedException if schema not supported
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public DirContext getSchemaClassDefinition(Name name)
throws NamingException
@@ -417,8 +416,8 @@
* be retrieved
* @return the DirContext containing the named object's class
* definitions; never null
- * @exception OperationNotSupportedException if schema not supported
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.OperationNotSupportedException if schema not supported
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public DirContext getSchemaClassDefinition(String name)
throws NamingException
@@ -442,7 +441,7 @@
* SearchResult contains the attributes identified by attributesToReturn
* and the name of the corresponding object, named relative to the
* context named by name.
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(Name name, Attributes matchingAttributes,
String[] attributesToReturn)
@@ -466,7 +465,7 @@
* SearchResult contains the attributes identified by attributesToReturn
* and the name of the corresponding object, named relative to the
* context named by name.
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(String name, Attributes matchingAttributes,
String[] attributesToReturn)
@@ -489,7 +488,7 @@
* SearchResult contains the attributes identified by attributesToReturn
* and the name of the corresponding object, named relative to the
* context named by name.
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(Name name, Attributes matchingAttributes)
throws NamingException
@@ -509,7 +508,7 @@
* SearchResult contains the attributes identified by attributesToReturn
* and the name of the corresponding object, named relative to the
* context named by name.
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(String name, Attributes matchingAttributes)
throws NamingException
@@ -534,7 +533,7 @@
* is not supported or understood by the underlying directory
* @exception InvalidSearchControlsException if the search controls
* contain invalid settings
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(Name name, String filter,
SearchControls cons)
@@ -561,7 +560,7 @@
* specified is not supported or understood by the underlying directory
* @exception InvalidSearchControlsException if the search controls
* contain invalid settings
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(String name, String filter,
SearchControls cons)
@@ -587,13 +586,13 @@
* default search controls are used (equivalent to (new SearchControls())).
* @return an enumeration of SearchResults of the objects that satisy the
* filter; never null
- * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i}
+ * @exception java.lang.ArrayIndexOutOfBoundsException if filterExpr contains {i}
* expressions where i is outside the bounds of the array filterArgs
* @exception InvalidSearchControlsException if cons contains invalid
* settings
* @exception InvalidSearchFilterException if filterExpr with filterArgs
* represents an invalid search filter
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(Name name, String filterExpr,
Object[] filterArgs, SearchControls cons)
@@ -619,13 +618,13 @@
* default search controls are used (equivalent to (new SearchControls())).
* @return an enumeration of SearchResults of the objects that satisy the
* filter; never null
- * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i}
+ * @exception java.lang.ArrayIndexOutOfBoundsException if filterExpr contains {i}
* expressions where i is outside the bounds of the array filterArgs
* @exception InvalidSearchControlsException if cons contains invalid
* settings
* @exception InvalidSearchFilterException if filterExpr with filterArgs
* represents an invalid search filter
- * @exception NamingException if a naming exception is encountered
+ * @exception javax.naming.NamingException if a naming exception is encountered
*/
public NamingEnumeration search(String name, String filterExpr,
Object[] filterArgs,
1.4 +37 -84 jakarta-tomcat-connectors/naming/src/org/apache/naming/core/BaseNaming.java
Index: BaseNaming.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/BaseNaming.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BaseNaming.java 5 Nov 2002 19:05:19 -0000 1.3
+++ BaseNaming.java 26 Feb 2003 18:52:12 -0000 1.4
@@ -64,10 +64,7 @@
import javax.naming.*;
import javax.naming.directory.DirContext;
import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.ModificationItem;
-import javax.naming.directory.SearchControls;
-import org.apache.tomcat.util.res.StringManager;
+
import org.apache.tomcat.util.IntrospectionUtils;
// Based on a merge of various catalina naming contexts
@@ -145,16 +142,6 @@
*/
protected final NameParser nameParser = new NameParserImpl();
- /**
- * Cached.
- * deprecated ? Should be implemented via notes or other mechanism.
- * Or via config.
- */
- protected boolean cached = true;
- protected int cacheTTL = 5000; // 5s
- protected int cacheObjectMaxSize = 32768; // 32 KB
-
-
/** Prefix used for URL-based namming lookup. It must be removed
* from all names.
* Deprecated ? Do we need it ?
@@ -169,86 +156,44 @@
public void setURLPrefix( String s ) {
urlPrefix=s;
}
-
- /**
- * Set cached attribute. If false, this context will be skipped from caching
- */
- public void setCached(boolean cached) {
- this.cached = cached;
- }
- /**
- * Is cached ?
- */
+ private boolean cached;
+ private int cacheTTL;
+ private int cacheObjectMaxSize;
+
public boolean isCached() {
return cached;
}
- public boolean getCached() {
- return cached;
- }
-
- /**
- * Set cache TTL.
- */
- public void setCacheTTL(int cacheTTL) {
- this.cacheTTL = cacheTTL;
+ public void setCached(boolean cached) {
+ this.cached = cached;
}
-
- /**
- * Get cache TTL.
- */
public int getCacheTTL() {
return cacheTTL;
}
-
- /**
- * Set cacheObjectMaxSize.
- */
- public void setCacheObjectMaxSize(int cacheObjectMaxSize) {
- this.cacheObjectMaxSize = cacheObjectMaxSize;
+ public void setCacheTTL(int cacheTTL) {
+ this.cacheTTL = cacheTTL;
}
-
- /**
- * Get cacheObjectMaxSize.
- */
public int getCacheObjectMaxSize() {
return cacheObjectMaxSize;
}
- // -------------------- Lifecycle methods ? --------------------
-
- /**
- * Allocate resources for this directory context.
- */
- public void allocate() {
- ; // No action taken by the default implementation
- }
-
-
- /**
- * Release any resources allocated for this directory context.
- */
- public void release() {
- ; // No action taken by the default implementation
+ public void setCacheObjectMaxSize(int cacheObjectMaxSize) {
+ this.cacheObjectMaxSize = cacheObjectMaxSize;
}
- public void recycle() {
- // nothing yet.
- }
-
- // -------------------- Not so Abstract methods --------------------
+ // -------------------- Not so Abstract methods --------------------
// This is what a subclass should implement.
// XXX Base resolveLinks() method ?? And then use lookup without resolveLinks flag
/** The lookup method. This is the main method you should implement.
*
- * @param Name
- * @param resolveLinks. If false, this is a lookupLink call.
+ * @param name
+ * @param resolveLinks If false, this is a lookupLink call.
*/
public Object lookup(Name name, boolean resolveLinks)
throws NamingException
@@ -305,16 +250,6 @@
throw new OperationNotSupportedException();
}
- public void rename(Name oldName, Name newName)
- throws NamingException
- {
- // Override if needed
- Object value = lookup(oldName, false);
- bind(newName, value, null, false);
- unbind(oldName, true);
-
- }
-
/** Implement for directories
*
*/
@@ -338,20 +273,21 @@
// -------------------- Utils --------------------
-
+ // XXX Implement this
/**
* Returns true if writing is allowed on this context.
*/
protected boolean isWritable(Name name) {
- return ContextAccessController.isWritable(name);
+ return true;
+ //return ContextAccessController.isWritable(name);
}
/**
* Throws a naming exception is Context is not writable.
*/
- protected void checkWritable(Name n)
+ protected void checkWritable(Name n)
throws NamingException
{
if (!isWritable(n))
@@ -368,10 +304,28 @@
// }
}
+ // -------------------- Lifecycle methods ? --------------------
+ /**
+ * Allocate resources for this directory context.
+ */
+ public void allocate() {
+ ; // No action taken by the default implementation
+ }
- //-------------------- Helpers --------------------
+ /**
+ * Release any resources allocated for this directory context.
+ */
+ public void release() {
+ ; // No action taken by the default implementation
+ }
+
+ public void recycle() {
+ // nothing yet.
+ }
+
+ //-------------------- Helpers --------------------
/** Just a hack so that all DirContexts can be used as tasks.
* They'll do nothing - the setters will be called ( just like
@@ -388,6 +342,5 @@
*/
public void execute() {
}
-
}
1.4 +2 -3 jakarta-tomcat-connectors/naming/src/org/apache/naming/core/NamingContextEnumeration.java
Index: NamingContextEnumeration.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/NamingContextEnumeration.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NamingContextEnumeration.java 5 Nov 2002 19:03:14 -0000 1.3
+++ NamingContextEnumeration.java 26 Feb 2003 18:52:12 -0000 1.4
@@ -60,8 +60,7 @@
package org.apache.naming.core;
-import java.util.Hashtable;
-import java.util.Vector;
+
import java.util.Enumeration;
import javax.naming.*;
@@ -83,7 +82,7 @@
* Bindings or Entries, we'll provide the wrapping if needed. For String
* the Class and value will be lazy-loaded.
*
- * @param ctx. The context where this enum belongs. Used to lazy-eval
+ * @param ctx The context where this enum belongs. Used to lazy-eval
* the class and value
*
* @param bindings If true, we'll wrap things as Binding ( true for
1.2 +2 -2 jakarta-tomcat-connectors/naming/src/org/apache/naming/core/ServerAttribute.java
Index: ServerAttribute.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/ServerAttribute.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServerAttribute.java 1 Oct 2002 18:42:16 -0000 1.1
+++ ServerAttribute.java 26 Feb 2003 18:52:12 -0000 1.2
@@ -60,7 +60,6 @@
package org.apache.naming.core;
-import javax.naming.*;
import javax.naming.directory.*;
/**
@@ -81,5 +80,6 @@
super(id);
}
-
+ public void recycle() {
+ }
}
1.2 +1 -2 jakarta-tomcat-connectors/naming/src/org/apache/naming/core/ServerAttributes.java
Index: ServerAttributes.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/core/ServerAttributes.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServerAttributes.java 1 Oct 2002 18:42:16 -0000 1.1
+++ ServerAttributes.java 26 Feb 2003 18:52:12 -0000 1.2
@@ -60,7 +60,6 @@
package org.apache.naming.core;
-import javax.naming.*;
import javax.naming.directory.*;
/**
@@ -78,5 +77,5 @@
public class ServerAttributes extends BasicAttributes
{
-
+ // no extra methods yet.
}
1.5 +22 -13 jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/fs/FileDirContext.java
Index: FileDirContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/modules/fs/FileDirContext.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FileDirContext.java 5 Nov 2002 19:07:59 -0000 1.4
+++ FileDirContext.java 26 Feb 2003 18:52:12 -0000 1.5
@@ -231,8 +231,12 @@
super.release();
}
+ public void setAttribute( String name, Object v ) {
+ new Throwable().printStackTrace();
+ System.out.println(name + " " + v );
+ }
- // -------------------- BaseDirContext implementation --------------------
+ // -------------------- BaseDirContext implementation --------------------
/**
* Retrieves the named object. The result is a File relative to the docBase
@@ -350,9 +354,10 @@
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(String name)
+ public NamingEnumeration list(Name nameN)
throws NamingException
{
+ String name=nameN.toString();
if( log.isDebugEnabled() ) log.debug( "list " + name );
File file = file(name);
@@ -380,9 +385,10 @@
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(String name)
+ public NamingEnumeration listBindings(Name nameN)
throws NamingException
{
+ String name=nameN.toString();
if( log.isDebugEnabled() ) log.debug( "listBindings " + name );
File file = file(name);
@@ -423,7 +429,7 @@
* @exception NotContextException if the name is bound but does not name
* a context, or does not name a context of the appropriate type
*/
- public void destroySubcontext(String name)
+ public void destroySubcontext(Name name)
throws NamingException
{
unbind(name);
@@ -468,9 +474,10 @@
* indicates that none should be retrieved
* @exception NamingException if a naming exception is encountered
*/
- public Attributes getAttributes(String name, String[] attrIds)
+ public Attributes getAttributes(Name nameN, String[] attrIds)
throws NamingException
{
+ String name=nameN.toString();
if( log.isDebugEnabled() ) log.debug( "getAttributes " + name );
// Building attribute list
@@ -499,9 +506,10 @@
* of the binding are not supplied
* @exception NamingException if a naming exception is encountered
*/
- public void bind(String name, Object obj, Attributes attrs)
+ public void bind(Name nameN, Object obj, Attributes attrs)
throws NamingException {
-
+
+ String name=nameN.toString();
// Note: No custom attributes allowed
File file = new File(base, name);
@@ -531,14 +539,15 @@
* of the binding are not supplied
* @exception NamingException if a naming exception is encountered
*/
- public void rebind(String name, Object obj, Attributes attrs)
+ public void rebind(Name nameN, Object obj, Attributes attrs)
throws NamingException {
-
+ String name=nameN.toString();
+
// Note: No custom attributes allowed
// Check obj type
-
+
File file = new File(base, name);
-
+
InputStream is = null;
// if (obj instanceof Resource) {
// try {
@@ -563,9 +572,9 @@
if (is == null)
throw new NamingException
(sm.getString("resources.bindFailed", name));
-
+
// Open os
-
+
try {
FileOutputStream os = null;
byte buffer[] = new byte[BUFFER_SIZE];
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org