You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/06/23 22:53:48 UTC
svn commit: r550106 [12/16] - in
/harmony/enhanced/classlib/branches/java6/modules:
beans/src/main/java/java/beans/ jndi/META-INF/
jndi/src/main/java/javax/naming/ jndi/src/main/java/javax/naming/directory/
jndi/src/main/java/javax/naming/event/ jndi/s...
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContext.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContext.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContext.java Sat Jun 23 13:53:42 2007
@@ -61,9 +61,7 @@
/**
* This class represents DNS context. This is the main class and the main entry
* point to DNS service provider for JNDI.
- *
- * @author Alexei Zakharov
- * @version $Revision: 1.1.2.5 $
+ *
* @see dnsURLContext
* @see DNSName
* @see DNSNameParser
@@ -71,57 +69,70 @@
public class DNSContext implements DirContext, Cloneable {
// some environment property names
- public static final String LOOKUP_ATTR =
- "org.apache.harmony.jndi.provider.dns.lookup.attr"; //$NON-NLS-1$
- public static final String RECURSION =
- "org.apache.harmony.jndi.provider.dns.recursion"; //$NON-NLS-1$
- public static final String TIMEOUT_INITIAL =
- "org.apache.harmony.jndi.provider.dns.timeout.initial"; //$NON-NLS-1$
- public static final String TIMEOUT_RETRIES =
- "org.apache.harmony.jndi.provider.dns.timeout.retries"; //$NON-NLS-1$
- public static final String THREADS_MAX =
- "org.apache.harmony.jndi.provider.dns.threads.max"; //$NON-NLS-1$
+ public static final String LOOKUP_ATTR = "org.apache.harmony.jndi.provider.dns.lookup.attr"; //$NON-NLS-1$
+
+ public static final String RECURSION = "org.apache.harmony.jndi.provider.dns.recursion"; //$NON-NLS-1$
+
+ public static final String TIMEOUT_INITIAL = "org.apache.harmony.jndi.provider.dns.timeout.initial"; //$NON-NLS-1$
+
+ public static final String TIMEOUT_RETRIES = "org.apache.harmony.jndi.provider.dns.timeout.retries"; //$NON-NLS-1$
+
+ public static final String THREADS_MAX = "org.apache.harmony.jndi.provider.dns.threads.max"; //$NON-NLS-1$
// used in internal methods
private static final int NAME_CLASS_SWT = 1;
+
private static final int BINDING_SWT = 2;
-
+
private DNSNameParser nameParser;
+
private Hashtable<Object, Object> environment;
+
private Resolver resolver;
private DNSName contextName;
// default values for properties that has been read from the environment
private boolean authoritative = ProviderConstants.DEFAULT_AUTHORITATIVE;
+
private int lookupAttrType = ProviderConstants.DEFAULT_LOOKUP_ATTR_TYPE;
+
private int lookupAttrClass = ProviderConstants.DEFAULT_LOOKUP_ATTR_CLASS;
+
private boolean recursion = ProviderConstants.DEFAULT_RECURSION;
+
private int timeoutInitial = ProviderConstants.DEFAULT_INITIAL_TIMEOUT;
+
private int timeoutRetries = ProviderConstants.DEFAULT_TIMEOUT_RETRIES;
+
private int maxThreads = ProviderConstants.DEFAULT_MAX_THREADS;
// <--- start of constructor section
-
+
/**
* A DNS context constructor. Should not be accessed directly.
- * @param env the hash table with environment variables. The context
- * will make a clone of given hash table.
- * @throws InvalidNameException something wrong with domain names given in
- * <code>java.naming.provider.url</code> property
- * @throws ConfigurationException if some error occurred during parsing of
- * configuration parameters
- * @throws NamingException if some parse error occurred
- * @throws NullPointerException if the environment is null
- *
- */
- @SuppressWarnings("unchecked") //$NON-NLS-1$
- DNSContext(Hashtable<?, ?> env) throws NamingException
- {
+ *
+ * @param env
+ * the hash table with environment variables. The context will
+ * make a clone of given hash table.
+ * @throws InvalidNameException
+ * something wrong with domain names given in
+ * <code>java.naming.provider.url</code> property
+ * @throws ConfigurationException
+ * if some error occurred during parsing of configuration
+ * parameters
+ * @throws NamingException
+ * if some parse error occurred
+ * @throws NullPointerException
+ * if the environment is null
+ *
+ */
+ @SuppressWarnings("unchecked")
+ DNSContext(Hashtable<?, ?> env) throws NamingException {
nameParser = new DNSNameParser();
if (env == null) {
- // jndi.45=environment is null
- throw new NullPointerException(Messages.getString("jndi.45")); //$NON-NLS-1$
+ // jndi.45=environment is null
+ throw new NullPointerException(Messages.getString("jndi.45")); //$NON-NLS-1$
}
this.environment = (Hashtable<Object, Object>) env.clone();
parseBoolProp(Context.AUTHORITATIVE);
@@ -144,12 +155,13 @@
/**
* Parses integer environment property and fills appropriate internal
* variable if necessary.
- * @param paramName name of parameter
- * @throws NumberFormatException if error encountered while parsing
+ *
+ * @param paramName
+ * name of parameter
+ * @throws NumberFormatException
+ * if error encountered while parsing
*/
- private void parseIntProp(String paramName)
- throws NumberFormatException
- {
+ private void parseIntProp(String paramName) throws NumberFormatException {
Object tmp = environment.get(paramName);
if (tmp != null && tmp instanceof String) {
@@ -162,7 +174,7 @@
timeoutInitial = n;
} else if (paramName.equals(THREADS_MAX)) {
maxThreads = n;
- }
+ }
} catch (NumberFormatException e) {
throw e;
}
@@ -172,10 +184,11 @@
/**
* Parses boolean environment property and fills appropriate internal
* variable if necessary.
- * @param paramName name of parameter
+ *
+ * @param paramName
+ * name of parameter
*/
- private void parseBoolProp(String paramName)
- {
+ private void parseBoolProp(String paramName) {
Object tmp = environment.get(paramName);
boolean val = false;
@@ -194,7 +207,9 @@
/**
* Parses "lookup attribute" environment property and fills appropriate
* internal variable.
- * @throws ConfigurationException if some DNS type or DNS class is unknown
+ *
+ * @throws ConfigurationException
+ * if some DNS type or DNS class is unknown
*/
private void parseLookupProp() throws ConfigurationException {
Object tmp;
@@ -212,42 +227,43 @@
if (k > -1) {
recClassName = lookupAttr.substring(0, k);
- lookupAttrClass = ProviderMgr.getRecordClassNumber(
- recClassName);
+ lookupAttrClass = ProviderMgr
+ .getRecordClassNumber(recClassName);
if (lookupAttrClass == -1) {
// jndi.46=DNS class {0} is not supported
- throw new ConfigurationException(Messages.getString("jndi.46", recClassName));//$NON-NLS-1$
+ throw new ConfigurationException(Messages.getString(
+ "jndi.46", recClassName));//$NON-NLS-1$
}
recTypeName = lookupAttr.substring(k).trim();
- }
- else {
- lookupAttrClass =
- ProviderConstants.DEFAULT_LOOKUP_ATTR_CLASS;
+ } else {
+ lookupAttrClass = ProviderConstants.DEFAULT_LOOKUP_ATTR_CLASS;
recTypeName = lookupAttr.trim();
}
lookupAttrType = ProviderMgr.getRecordTypeNumber(recTypeName);
if (lookupAttrType == -1) {
// jndi.47=DNS type {0} is not supported
- throw new ConfigurationException(
- Messages.getString("jndi.47", recTypeName)); //$NON-NLS-1$
+ throw new ConfigurationException(Messages.getString(
+ "jndi.47", recTypeName)); //$NON-NLS-1$
}
}
}
}
/**
- * Parses "provider URL" environment property and fills appropriate
- * internal variable.
- * @throws NamingException if such exception encountered while parsing
+ * Parses "provider URL" environment property and fills appropriate internal
+ * variable.
+ *
+ * @throws NamingException
+ * if such exception encountered while parsing
*/
private void parseProviderUrlProp() throws NamingException {
Object tmp;
-
+
if (environment.containsKey(Context.PROVIDER_URL)) {
tmp = environment.get(Context.PROVIDER_URL);
if (tmp instanceof String) {
StringTokenizer st = new StringTokenizer((String) tmp, " "); //$NON-NLS-1$
-
+
while (st.hasMoreTokens()) {
String token = st.nextToken();
DNSPseudoURL dnsURL;
@@ -257,29 +273,28 @@
if (dnsURL.isHostIpGiven()) {
resolver.addInitialServer(null, dnsURL.getHost(),
dnsURL.getPort(), dnsURL.getDomain());
- }
- else {
- resolver.addInitialServer(dnsURL.getHost(), null,
+ } else {
+ resolver.addInitialServer(dnsURL.getHost(), null,
dnsURL.getPort(), dnsURL.getDomain());
}
if (contextName == null) {
- contextName = (DNSName)
- nameParser.parse(dnsURL.getDomain());
- }
- else {
- DNSName name2 = (DNSName)
- nameParser.parse(dnsURL.getDomain());
+ contextName = (DNSName) nameParser.parse(dnsURL
+ .getDomain());
+ } else {
+ DNSName name2 = (DNSName) nameParser.parse(dnsURL
+ .getDomain());
if (name2.compareTo(contextName) != 0) {
// jndi.48=conflicting domains: {0} and {1}
- throw new ConfigurationException(
- Messages.getString("jndi.48", contextName, name2)); //$NON-NLS-1$
+ throw new ConfigurationException(Messages
+ .getString(
+ "jndi.48", contextName, name2)); //$NON-NLS-1$
}
}
} catch (IllegalArgumentException e) {
// jndi.49=Unable to parse DNS URL {0}. {1}
- throw new ConfigurationException(
- Messages.getString("jndi.49", token, e.getMessage())); //$NON-NLS-1$
+ throw new ConfigurationException(Messages.getString(
+ "jndi.49", token, e.getMessage())); //$NON-NLS-1$
}
}
}
@@ -288,19 +303,22 @@
}
}
-
/**
- * Constructs new DNS context with given name. This
- * constructor will read all private properties from its ancestor context.
- * The environment will not be parsed.
- * @param ancestorCtx an ancestor context to read all internal properties from
- * @param name name of newly created context in the ancestor context
+ * Constructs new DNS context with given name. This constructor will read
+ * all private properties from its ancestor context. The environment will
+ * not be parsed.
+ *
+ * @param ancestorCtx
+ * an ancestor context to read all internal properties from
+ * @param name
+ * name of newly created context in the ancestor context
*/
- @SuppressWarnings("unchecked") //$NON-NLS-1$
+ @SuppressWarnings("unchecked")
DNSContext(DNSContext ancestorCtx, DNSName name) {
this.contextName = (DNSName) name.clone();
this.nameParser = ancestorCtx.nameParser;
- this.environment = (Hashtable<Object, Object>) ancestorCtx.environment.clone();
+ this.environment = (Hashtable<Object, Object>) ancestorCtx.environment
+ .clone();
this.resolver = ancestorCtx.resolver;
this.authoritative = ancestorCtx.authoritative;
this.lookupAttrType = ancestorCtx.lookupAttrType;
@@ -310,249 +328,265 @@
this.timeoutRetries = ancestorCtx.timeoutRetries;
this.maxThreads = ancestorCtx.maxThreads;
}
-
- // <----- end of constructor section
/**
* Obtains all attributes associated with given name.
- * @param name domain name or composite name in string form
+ *
+ * @param name
+ * domain name or composite name in string form
* @return collection of found attributes
- * @throws NamingException or its subtype if such has been encountered
- * @see DNSContext#getAttributes(Name, String[]) for more details
+ * @throws NamingException
+ * or its subtype if such has been encountered
+ * @see DNSContext#getAttributes(Name, String[]) for more details
* @see javax.naming.directory.DirContext#getAttributes(java.lang.String)
*/
public Attributes getAttributes(String name) throws NamingException {
return getAttributes(convertNameFromStringForm(name), null);
}
- /**
+ /**
* This method is not supported by the DNS provider.
- * @see javax.naming.directory.DirContext#modifyAttributes(java.lang.String, int, javax.naming.directory.Attributes)
+ *
+ * @see javax.naming.directory.DirContext#modifyAttributes(java.lang.String,
+ * int, javax.naming.directory.Attributes)
*/
public void modifyAttributes(String arg0, int arg1, Attributes arg2)
- throws NamingException
- {
+ throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
((DirContext) obj).modifyAttributes("", arg1, arg2); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
/**
* Determines all attributes associated with given name.
*
- * @param name the name to look for; should be an instance of either
- * <code>DNSName</code> class or <code>CompositeName</code> class
+ * @param name
+ * the name to look for; should be an instance of either
+ * <code>DNSName</code> class or <code>CompositeName</code>
+ * class
* @return collection of found attributes
- * @throws NamingException or its subtype if such has been encountered
- * @see DNSContext#getAttributes(Name, String[]) for more details
+ * @throws NamingException
+ * or its subtype if such has been encountered
+ * @see DNSContext#getAttributes(Name, String[]) for more details
* @see javax.naming.directory.DirContext#getAttributes(javax.naming.Name)
*/
public Attributes getAttributes(Name name) throws NamingException {
return getAttributes(name, null);
}
- /**
+ /**
* This method is not supported by the DNS provider.
- * @see javax.naming.directory.DirContext#modifyAttributes(javax.naming.Name, int, javax.naming.directory.Attributes)
+ *
+ * @see javax.naming.directory.DirContext#modifyAttributes(javax.naming.Name,
+ * int, javax.naming.directory.Attributes)
*/
public void modifyAttributes(Name arg0, int arg1, Attributes arg2)
- throws NamingException
- {
+ throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
((DirContext) obj).modifyAttributes("", arg1, arg2); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported by the DNS provider.
+ *
* @see javax.naming.directory.DirContext#getSchema(java.lang.String)
*/
public DirContext getSchema(String arg0) throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).getSchema(""); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.directory.DirContext#getSchemaClassDefinition(java.lang.String)
*/
public DirContext getSchemaClassDefinition(String arg0)
- throws NamingException
- {
+ throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).getSchemaClassDefinition(""); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.directory.DirContext#getSchema(javax.naming.Name)
*/
public DirContext getSchema(Name arg0) throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).getSchema(""); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.directory.DirContext#getSchemaClassDefinition(javax.naming.Name)
*/
public DirContext getSchemaClassDefinition(Name arg0)
- throws NamingException
- {
+ throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).getSchemaClassDefinition(""); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#modifyAttributes(java.lang.String, javax.naming.directory.ModificationItem[])
+ *
+ * @see javax.naming.directory.DirContext#modifyAttributes(java.lang.String,
+ * javax.naming.directory.ModificationItem[])
*/
public void modifyAttributes(String arg0, ModificationItem[] arg1)
- throws NamingException
- {
+ throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
((DirContext) obj).modifyAttributes("", arg1); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#modifyAttributes(javax.naming.Name, javax.naming.directory.ModificationItem[])
+ *
+ * @see javax.naming.directory.DirContext#modifyAttributes(javax.naming.Name,
+ * javax.naming.directory.ModificationItem[])
*/
public void modifyAttributes(Name arg0, ModificationItem[] arg1)
throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
((DirContext) obj).modifyAttributes("", arg1); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#search(java.lang.String, javax.naming.directory.Attributes)
+ *
+ * @see javax.naming.directory.DirContext#search(java.lang.String,
+ * javax.naming.directory.Attributes)
*/
public NamingEnumeration<SearchResult> search(String arg0, Attributes arg1)
- throws NamingException
- {
+ throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).search("", arg1); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#search(javax.naming.Name, javax.naming.directory.Attributes)
+ *
+ * @see javax.naming.directory.DirContext#search(javax.naming.Name,
+ * javax.naming.directory.Attributes)
*/
public NamingEnumeration<SearchResult> search(Name arg0, Attributes arg1)
- throws NamingException
- {
+ throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).search("", arg1); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#bind(java.lang.String, java.lang.Object, javax.naming.directory.Attributes)
+ *
+ * @see javax.naming.directory.DirContext#bind(java.lang.String,
+ * java.lang.Object, javax.naming.directory.Attributes)
*/
public void bind(String arg0, Object arg1, Attributes arg2)
- throws NamingException
- {
+ throws NamingException {
bind(convertNameFromStringForm(arg0), arg1, arg2);
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#rebind(java.lang.String, java.lang.Object, javax.naming.directory.Attributes)
+ *
+ * @see javax.naming.directory.DirContext#rebind(java.lang.String,
+ * java.lang.Object, javax.naming.directory.Attributes)
*/
public void rebind(String arg0, Object arg1, Attributes arg2)
- throws NamingException
- {
+ throws NamingException {
rebind(convertNameFromStringForm(arg0), arg1, arg2);
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#bind(javax.naming.Name, java.lang.Object, javax.naming.directory.Attributes)
+ *
+ * @see javax.naming.directory.DirContext#bind(javax.naming.Name,
+ * java.lang.Object, javax.naming.directory.Attributes)
*/
public void bind(Name arg0, Object arg1, Attributes arg2)
- throws NamingException
- {
+ throws NamingException {
ContextNamePair pair;
-
+
try {
pair = getTargetNamespaceContextNamePair(arg0);
} catch (IllegalArgumentException e) {
@@ -562,19 +596,20 @@
((DirContext) pair.context).bind(pair.name, arg1, arg2);
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#rebind(javax.naming.Name, java.lang.Object, javax.naming.directory.Attributes)
+ *
+ * @see javax.naming.directory.DirContext#rebind(javax.naming.Name,
+ * java.lang.Object, javax.naming.directory.Attributes)
*/
public void rebind(Name arg0, Object arg1, Attributes arg2)
- throws NamingException
- {
+ throws NamingException {
ContextNamePair pair;
-
+
try {
pair = getTargetNamespaceContextNamePair(arg0);
} catch (IllegalArgumentException e) {
@@ -584,20 +619,24 @@
((DirContext) pair.context).rebind(pair.name, arg1, arg2);
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
/**
* Retrieves attributes associated with given name.
- * @param name name to look for; should be either domain name or composite
- * name in string form
- * @param attrNames array of attribute names that should be retrieved
+ *
+ * @param name
+ * name to look for; should be either domain name or composite
+ * name in string form
+ * @param attrNames
+ * array of attribute names that should be retrieved
* @return collection of found attributes
- * @throws NamingException or its subtypes if such have been encountered
- * @see #getAttributes(Name) for details
+ * @throws NamingException
+ * or its subtypes if such have been encountered
+ * @see #getAttributes(Name) for details
* @see javax.naming.directory.DirContext#getAttributes(java.lang.String,
- * java.lang.String[])
+ * java.lang.String[])
*/
public Attributes getAttributes(String name, String[] attrNames)
throws NamingException {
@@ -607,37 +646,44 @@
/**
* Obtains attributes associated with the given name. Each members of
* <code>attrNames</code> array should be the correct name of DNS resource
- * record type (possibly prefixed with correct DNS resource record class)
- * as specified in RFC 1035. If class name is given then it should be
- * separated with space from the type name. If class name is missed then
- * IN class is used by default.
- *
- * @param name the name to look for; should have either <code>DNSName</code>
- * type or <code>CompositeName</code> type
- * @param attrNames the array with names of attributes to look for; if
- * null then all attributes will be retrieved; if
- * empty then none of attributes will be retrieved
- * @throws InvalidNameException if <code>name</code> is neither the instance
- * of <code>DNSName</code> nor <code>CompositeName</code> class or the first
- * component of composite name is not a domain name
- * @throws InvalidAttributeIdentifierException if the name of DNS type or
- * DNS class given in <code>attrNames</code> array is invalid
- * @throws NameNotFoundException if authoritative server for desired
- * zone was contacted but given name has not been found in that zone
- * @throws ServiceUnavailableException if no authoritative server for
- * desired name was found or all servers are dead or malfunction
- * @throws NoPermissionException if no appropriate permissions on using
- * network resources were granted
- * @throws NullPointerException if <code>name</code> is null
- * @throws NamingException if some other type of problem has been
- * encountered
+ * record type (possibly prefixed with correct DNS resource record class) as
+ * specified in RFC 1035. If class name is given then it should be separated
+ * with space from the type name. If class name is missed then IN class is
+ * used by default.
+ *
+ * @param name
+ * the name to look for; should have either <code>DNSName</code>
+ * type or <code>CompositeName</code> type
+ * @param attrNames
+ * the array with names of attributes to look for; if null then
+ * all attributes will be retrieved; if empty then none of
+ * attributes will be retrieved
+ * @throws InvalidNameException
+ * if <code>name</code> is neither the instance of
+ * <code>DNSName</code> nor <code>CompositeName</code> class
+ * or the first component of composite name is not a domain name
+ * @throws InvalidAttributeIdentifierException
+ * if the name of DNS type or DNS class given in
+ * <code>attrNames</code> array is invalid
+ * @throws NameNotFoundException
+ * if authoritative server for desired zone was contacted but
+ * given name has not been found in that zone
+ * @throws ServiceUnavailableException
+ * if no authoritative server for desired name was found or all
+ * servers are dead or malfunction
+ * @throws NoPermissionException
+ * if no appropriate permissions on using network resources were
+ * granted
+ * @throws NullPointerException
+ * if <code>name</code> is null
+ * @throws NamingException
+ * if some other type of problem has been encountered
* @see javax.naming.directory.DirContext#getAttributes(javax.naming.Name,
- * java.lang.String[])
+ * java.lang.String[])
* @see RFC 1035
*/
public Attributes getAttributes(Name name, String[] attrNames)
- throws NamingException
- {
+ throws NamingException {
int[] types;
int[] classes;
DNSName nameToLookFor = null;
@@ -649,35 +695,32 @@
if (name == null) {
// jndi.2E=The name is null
throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$
- }
- else if (name.size() == 0) {
+ } else if (name.size() == 0) {
// attributes of the current context are requested
nameToLookFor = (DNSName) contextName.clone();
- }
- else if (name instanceof CompositeName) {
+ } else if (name instanceof CompositeName) {
// treat the first component of the given composite name as
// a domain name and the rest as a Next Naming System name
String tmp = name.get(0);
// check if it is really a domain name
altName = (DNSName) nameParser.parse(tmp);
- //if (!altName.isAbsolute()) {
+ // if (!altName.isAbsolute()) {
nameToLookFor = (DNSName) composeName(altName, contextName);
- //} else {
- // nameToLookFor = (DNSName) altName.clone();
- //}
+ // } else {
+ // nameToLookFor = (DNSName) altName.clone();
+ // }
if (name.size() > 1) {
remainingName = (CompositeName) name.getSuffix(1);
}
- }
- else if (name instanceof DNSName) {
- //if (!((DNSName) name).isAbsolute()) {
+ } else if (name instanceof DNSName) {
+ // if (!((DNSName) name).isAbsolute()) {
nameToLookFor = (DNSName) composeName(name, contextName);
- //} else {
- // nameToLookFor = (DNSName) name.clone();
- //}
- }
- else {
- // jndi.4B=Only instances of CompositeName class or DNSName class are acceptable
+ // } else {
+ // nameToLookFor = (DNSName) name.clone();
+ // }
+ } else {
+ // jndi.4B=Only instances of CompositeName class or DNSName class
+ // are acceptable
throw new InvalidNameException(Messages.getString("jndi.4B")); //$NON-NLS-1$
}
@@ -685,11 +728,11 @@
if (remainingName != null) {
CannotProceedException cpe = constructCannotProceedException(
altName, remainingName);
- DirContext nnsContext =
- DirectoryManager.getContinuationDirContext(cpe);
+ DirContext nnsContext = DirectoryManager
+ .getContinuationDirContext(cpe);
attrs = nnsContext.getAttributes(remainingName, attrNames);
- } else {
+ } else {
// analyze given attrNames object
if (attrNames == null) {
// this means that all attributes should be obtained
@@ -697,8 +740,7 @@
classes = new int[1];
types[0] = ProviderConstants.ANY_QTYPE;
classes[0] = ProviderConstants.ANY_QCLASS;
- }
- else {
+ } else {
HashSet<Integer> classesSet = new HashSet<Integer>();
HashSet<Integer> typesSet = new HashSet<Integer>();
Iterator<Integer> iter;
@@ -709,31 +751,27 @@
String typeStr = null;
int classInt;
int typesInt;
-
+
if (k > 0) {
String classStr = element.substring(0, k);
- classInt =
- ProviderMgr.getRecordClassNumber(classStr);
+ classInt = ProviderMgr.getRecordClassNumber(classStr);
if (classInt == -1) {
// jndi.4C=Unknown record class: {0}
throw new InvalidAttributeIdentifierException(
Messages.getString("jndi.4C", classStr)); //$NON-NLS-1$
}
classesSet.add(new Integer(classInt));
- typeStr = element.substring(k, element.length())
- .trim();
- }
- else {
- classesSet.add(new Integer(
- ProviderConstants.IN_CLASS));
+ typeStr = element.substring(k, element.length()).trim();
+ } else {
+ classesSet.add(new Integer(ProviderConstants.IN_CLASS));
typeStr = element.trim();
}
typesInt = ProviderMgr.getRecordTypeNumber(typeStr);
if (typesInt == -1) {
// jndi.4D=Unknown record type: {0}
- throw new InvalidAttributeIdentifierException(
- Messages.getString("jndi.4D", typeStr)); //$NON-NLS-1$
+ throw new InvalidAttributeIdentifierException(Messages
+ .getString("jndi.4D", typeStr)); //$NON-NLS-1$
}
typesSet.add(new Integer(typesInt));
}
@@ -756,12 +794,13 @@
types[j++] = n.intValue();
}
}
-
- // we should have correct nameToLookFor, classes and types at this point
+
+ // we should have correct nameToLookFor, classes and types at this
+ // point
// let's look for attributes
try {
- Enumeration<ResourceRecord> records = resolver.lookup(nameToLookFor.toString(),
- types, classes);
+ Enumeration<ResourceRecord> records = resolver.lookup(
+ nameToLookFor.toString(), types, classes);
attrs = createAttributesFromRecords(records);
} catch (SecurityException e) {
@@ -781,153 +820,165 @@
return attrs;
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#createSubcontext(java.lang.String, javax.naming.directory.Attributes)
+ *
+ * @see javax.naming.directory.DirContext#createSubcontext(java.lang.String,
+ * javax.naming.directory.Attributes)
*/
public DirContext createSubcontext(String arg0, Attributes arg1)
- throws NamingException
- {
+ throws NamingException {
return createSubcontext(convertNameFromStringForm(arg0), arg1);
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#createSubcontext(javax.naming.Name, javax.naming.directory.Attributes)
+ *
+ * @see javax.naming.directory.DirContext#createSubcontext(javax.naming.Name,
+ * javax.naming.directory.Attributes)
*/
public DirContext createSubcontext(Name arg0, Attributes arg1)
- throws NamingException
- {
+ throws NamingException {
ContextNamePair pair;
-
+
try {
pair = getTargetNamespaceContextNamePair(arg0);
} catch (IllegalArgumentException e) {
throw new OperationNotSupportedException();
}
if (pair.context instanceof DirContext) {
- return ((DirContext) pair.context).createSubcontext(pair.name, arg1);
+ return ((DirContext) pair.context)
+ .createSubcontext(pair.name, arg1);
}
// jndi.4A=found object is not a DirContext
throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#search(java.lang.String, javax.naming.directory.Attributes, java.lang.String[])
+ *
+ * @see javax.naming.directory.DirContext#search(java.lang.String,
+ * javax.naming.directory.Attributes, java.lang.String[])
*/
- public NamingEnumeration<SearchResult> search(String arg0, Attributes arg1, String[] arg2)
- throws NamingException
- {
+ public NamingEnumeration<SearchResult> search(String arg0, Attributes arg1,
+ String[] arg2) throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).search("", arg1, arg2); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#search(javax.naming.Name, javax.naming.directory.Attributes, java.lang.String[])
+ *
+ * @see javax.naming.directory.DirContext#search(javax.naming.Name,
+ * javax.naming.directory.Attributes, java.lang.String[])
*/
- public NamingEnumeration<SearchResult> search(Name arg0, Attributes arg1, String[] arg2)
- throws NamingException
- {
+ public NamingEnumeration<SearchResult> search(Name arg0, Attributes arg1,
+ String[] arg2) throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).search("", arg1, arg2); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#search(java.lang.String, java.lang.String, javax.naming.directory.SearchControls)
+ *
+ * @see javax.naming.directory.DirContext#search(java.lang.String,
+ * java.lang.String, javax.naming.directory.SearchControls)
*/
public NamingEnumeration<SearchResult> search(String arg0, String arg1,
- SearchControls arg2) throws NamingException
- {
+ SearchControls arg2) throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).search("", arg1, arg2); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#search(javax.naming.Name, java.lang.String, javax.naming.directory.SearchControls)
+ *
+ * @see javax.naming.directory.DirContext#search(javax.naming.Name,
+ * java.lang.String, javax.naming.directory.SearchControls)
*/
- public NamingEnumeration<SearchResult> search(Name arg0, String arg1, SearchControls arg2)
- throws NamingException
- {
+ public NamingEnumeration<SearchResult> search(Name arg0, String arg1,
+ SearchControls arg2) throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).search("", arg1, arg2); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#search(java.lang.String, java.lang.String, java.lang.Object[], javax.naming.directory.SearchControls)
+ *
+ * @see javax.naming.directory.DirContext#search(java.lang.String,
+ * java.lang.String, java.lang.Object[],
+ * javax.naming.directory.SearchControls)
*/
- public NamingEnumeration<SearchResult> search(String arg0, String arg1, Object[] arg2,
- SearchControls arg3) throws NamingException
- {
+ public NamingEnumeration<SearchResult> search(String arg0, String arg1,
+ Object[] arg2, SearchControls arg3) throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).search("", arg1, arg2, arg3); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
- * @see javax.naming.directory.DirContext#search(javax.naming.Name, java.lang.String, java.lang.Object[], javax.naming.directory.SearchControls)
+ *
+ * @see javax.naming.directory.DirContext#search(javax.naming.Name,
+ * java.lang.String, java.lang.Object[],
+ * javax.naming.directory.SearchControls)
*/
- public NamingEnumeration<SearchResult> search(Name arg0, String arg1, Object[] arg2,
- SearchControls arg3) throws NamingException
- {
+ public NamingEnumeration<SearchResult> search(Name arg0, String arg1,
+ Object[] arg2, SearchControls arg3) throws NamingException {
Object obj = lookup(arg0);
-
+
if (obj instanceof DNSContext) {
throw new OperationNotSupportedException();
} else if (obj instanceof DirContext) {
return ((DirContext) obj).search("", arg1, arg2, arg3); //$NON-NLS-1$
} else {
// jndi.4A=found object is not a DirContext
- throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4A")); //$NON-NLS-1$
}
}
/**
* Frees all resources obtained by the current context.
+ *
* @see javax.naming.Context#close()
*/
public void close() throws NamingException {
@@ -942,16 +993,18 @@
return contextName.toString();
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#destroySubcontext(java.lang.String)
*/
public void destroySubcontext(String arg0) throws NamingException {
destroySubcontext(convertNameFromStringForm(arg0));
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#unbind(java.lang.String)
*/
public void unbind(String arg0) throws NamingException {
@@ -960,6 +1013,7 @@
/**
* Returns a clone of the environment associated with this context.
+ *
* @return a hash table with the context's environment
* @see javax.naming.Context#getEnvironment()
*/
@@ -967,13 +1021,14 @@
return (Hashtable<?, ?>) environment.clone();
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#destroySubcontext(javax.naming.Name)
*/
public void destroySubcontext(Name arg0) throws NamingException {
ContextNamePair pair;
-
+
try {
pair = getTargetNamespaceContextNamePair(arg0);
} catch (IllegalArgumentException e) {
@@ -983,17 +1038,18 @@
((Context) pair.context).destroySubcontext(pair.name);
} else {
// jndi.4E=found object is not a Context
- throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#unbind(javax.naming.Name)
*/
public void unbind(Name arg0) throws NamingException {
ContextNamePair pair;
-
+
try {
pair = getTargetNamespaceContextNamePair(arg0);
} catch (IllegalArgumentException e) {
@@ -1003,30 +1059,33 @@
((Context) pair.context).unbind(pair.name);
} else {
// jndi.4E=found object is not a Context
- throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
}
}
/**
- * Performs the lookup operation for given name.
- * The method will try to construct a composite name from given argument
- * value. If it is succeed and resulting composite name has the size more than
- * one then the <code>lookup(Name)</code> version of <code>lookup</code>
- * method will be
- * called with constructed composite name as an argument. If the size of
+ * Performs the lookup operation for given name. The method will try to
+ * construct a composite name from given argument value. If it is succeed
+ * and resulting composite name has the size more than one then the
+ * <code>lookup(Name)</code> version of <code>lookup</code> method will
+ * be called with constructed composite name as an argument. If the size of
* constructed composite name equals to one then the value of given argument
- * will be treated as a string form of a domain name and an attempt
- * to create an instance of <code>DNSName</code> class will be made.
- * The <code>lookup(Name)</code> will be called after this.
- *
- * @param name the name to look for
+ * will be treated as a string form of a domain name and an attempt to
+ * create an instance of <code>DNSName</code> class will be made. The
+ * <code>lookup(Name)</code> will be called after this.
+ *
+ * @param name
+ * the name to look for
* @return an object associated with given name
- * @throws InvalidNameException if given argument is a string
- * representation of neither a composite name nor a domain name; or the
- * first component of the composite name is not a domain name.
- * @throws NamingException if some other type of
- * <code>NamingException</code> was encountered
- * @throws NullPointerException if the name is null
+ * @throws InvalidNameException
+ * if given argument is a string representation of neither a
+ * composite name nor a domain name; or the first component of
+ * the composite name is not a domain name.
+ * @throws NamingException
+ * if some other type of <code>NamingException</code> was
+ * encountered
+ * @throws NullPointerException
+ * if the name is null
* @see #lookup(Name)
* @see javax.naming.Context#lookup(java.lang.String)
*/
@@ -1035,18 +1094,19 @@
}
/**
- * @param nameStr string representation of a name
+ * @param nameStr
+ * string representation of a name
* @return an instance of <code>CompositeName</code> or
- * <code>DNSName</code> class
- * @throws InvalidNameException if <code>nameStr</code> is neither a string
- * representation of <code>CompositeName</code> class nor an instance of
- * <code>DNSName</code> class.
+ * <code>DNSName</code> class
+ * @throws InvalidNameException
+ * if <code>nameStr</code> is neither a string representation
+ * of <code>CompositeName</code> class nor an instance of
+ * <code>DNSName</code> class.
*/
private Name convertNameFromStringForm(String nameStr)
- throws InvalidNameException
- {
+ throws InvalidNameException {
Name nameObj = null;
-
+
if (nameStr == null) {
// jndi.2E=The name is null
throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$
@@ -1054,20 +1114,22 @@
nameObj = new CompositeName(nameStr);
if (nameObj.size() == 1) {
nameObj = nameParser.parse(nameStr);
- }
- else if (nameObj.size() == 0) {
+ } else if (nameObj.size() == 0) {
nameObj = new DNSName();
}
return nameObj;
}
-
+
/**
* Looks for a object associated with the given name. This methods just
* forwards the request to <code>#lookup(String)</code> method and do
* nothing more.
- * @param name name to look for
+ *
+ * @param name
+ * name to look for
* @return found object
- * @throws NamingException if encountered
+ * @throws NamingException
+ * if encountered
* @see #lookup(String) for details
* @see javax.naming.Context#lookupLink(javax.naming.Name)
*/
@@ -1078,23 +1140,27 @@
/**
* Removes the property with given name from the context's environment.
- * @param name the name of the property to remove
+ *
+ * @param name
+ * the name of the property to remove
* @see javax.naming.Context#removeFromEnvironment(java.lang.String)
*/
public Object removeFromEnvironment(String name) {
return environment.remove(name);
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#bind(java.lang.String, java.lang.Object)
*/
public void bind(String arg0, Object arg1) throws NamingException {
bind(convertNameFromStringForm(arg0), arg1);
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#rebind(java.lang.String, java.lang.Object)
*/
public void rebind(String arg0, Object arg1) throws NamingException {
@@ -1103,20 +1169,29 @@
/**
* Performs the lookup operation for the given name in the current context.
- * @param name this method looks for object associated with given name
+ *
+ * @param name
+ * this method looks for object associated with given name
* @return found object
- * @throws InvalidNameException if the argument is not a valid type, e.g.
- * <code>CompositeName</code> or <code>DNSName</code>;
- * or the first component of given composite name is not a domain name
- * @throws NameNotFoundException if authoritative server for desired
- * zone was contacted but given name has not been found in that zone
- * @throws ServiceUnavailableException if no authoritative server for
- * desired name was found or all servers are dead or malfunction
- * @throws NoPermissionException if no appropriate permissions on using
- * network resources were granted
- * @throws NullPointerException if <code>name</code> is null
- * @throws NamingException if some other type of
- * <code>NamingException</code> was encountered
+ * @throws InvalidNameException
+ * if the argument is not a valid type, e.g.
+ * <code>CompositeName</code> or <code>DNSName</code>; or
+ * the first component of given composite name is not a domain
+ * name
+ * @throws NameNotFoundException
+ * if authoritative server for desired zone was contacted but
+ * given name has not been found in that zone
+ * @throws ServiceUnavailableException
+ * if no authoritative server for desired name was found or all
+ * servers are dead or malfunction
+ * @throws NoPermissionException
+ * if no appropriate permissions on using network resources were
+ * granted
+ * @throws NullPointerException
+ * if <code>name</code> is null
+ * @throws NamingException
+ * if some other type of <code>NamingException</code> was
+ * encountered
* @see javax.naming.Context#lookup(javax.naming.Name)
*/
public Object lookup(Name name) throws NamingException {
@@ -1131,35 +1206,32 @@
if (name == null) {
// jndi.2E=The name is null
throw new NullPointerException(Messages.getString("jndi.2E")); //$NON-NLS-1$
- }
- else if (name.size() == 0) {
+ } else if (name.size() == 0) {
// attributes of the current context are requested
nameToLookFor = (DNSName) contextName.clone();
- }
- else if (name instanceof CompositeName) {
+ } else if (name instanceof CompositeName) {
// treat the first component of the given composite name as
// a domain name and the rest as a Next Naming System name
String tmp = name.get(0);
// check if it is really a domain name
altName = (DNSName) nameParser.parse(tmp);
- //if (!altName.isAbsolute()) {
+ // if (!altName.isAbsolute()) {
nameToLookFor = (DNSName) composeName(altName, contextName);
- //} else {
- // nameToLookFor = (DNSName) altName.clone();
- //}
+ // } else {
+ // nameToLookFor = (DNSName) altName.clone();
+ // }
if (name.size() > 1) {
remainingName = (CompositeName) name.getSuffix(1);
}
- }
- else if (name instanceof DNSName) {
- //if (!((DNSName) name).isAbsolute()) {
+ } else if (name instanceof DNSName) {
+ // if (!((DNSName) name).isAbsolute()) {
nameToLookFor = (DNSName) composeName(name, contextName);
- //} else {
- // nameToLookFor = (DNSName) name.clone();
- //}
- }
- else {
- // jndi.4B=Only instances of CompositeName class or DNSName class are acceptable
+ // } else {
+ // nameToLookFor = (DNSName) name.clone();
+ // }
+ } else {
+ // jndi.4B=Only instances of CompositeName class or DNSName class
+ // are acceptable
throw new InvalidNameException(Messages.getString("jndi.4B")); //$NON-NLS-1$
}
// we should have correct nameToLookFor at this point
@@ -1174,15 +1246,15 @@
} else {
try {
DNSContext resolvedCtx = new DNSContext(this, nameToLookFor);
- Enumeration<ResourceRecord> records = resolver.lookup(nameToLookFor.toString(),
- types, classes);
+ Enumeration<ResourceRecord> records = resolver.lookup(
+ nameToLookFor.toString(), types, classes);
Attributes attrs = createAttributesFromRecords(records);
- result = DirectoryManager.getObjectInstance(
- resolvedCtx, name, this, environment, attrs);
+ result = DirectoryManager.getObjectInstance(resolvedCtx, name,
+ this, environment, attrs);
} catch (SecurityException e) {
- NoPermissionException e2 =
- new NoPermissionException(e.getMessage());
+ NoPermissionException e2 = new NoPermissionException(e
+ .getMessage());
e2.setRootCause(e);
throw e2;
@@ -1190,7 +1262,7 @@
throw e;
} catch (Exception e) {
NamingException ne = new NamingException(e.getMessage());
-
+
ne.setRootCause(e);
throw ne;
}
@@ -1199,53 +1271,48 @@
}
/**
- * Constructs <code>CannotProcessException</code> object and fills it
- * with necessary information. Values of some instance variables of the
- * current context are used.
- *
- * @param name the portion of name that belongs to DNS namespace
- * @param remainingName the remainder of the name that belongs to NNS
- * namespace
+ * Constructs <code>CannotProcessException</code> object and fills it with
+ * necessary information. Values of some instance variables of the current
+ * context are used.
+ *
+ * @param name
+ * the portion of name that belongs to DNS namespace
+ * @param remainingName
+ * the remainder of the name that belongs to NNS namespace
* @return newly constructed exception object
- * @throws NamingException if <code>NamingException</code> was encountered
- * somewhere
+ * @throws NamingException
+ * if <code>NamingException</code> was encountered somewhere
*/
private CannotProceedException constructCannotProceedException(
- DNSName name, CompositeName remainingName)
- throws NamingException
- {
+ DNSName name, CompositeName remainingName) throws NamingException {
DNSName nameToLookFor = (DNSName) composeName(name, contextName);
final DNSContext resolvedCtx = new DNSContext(this, nameToLookFor);
// namespace border violation, need to ask NNS
RefAddr refAddr = new RefAddr("nns") { //$NON-NLS-1$
private static final long serialVersionUID = 8654740210501193418L;
-
+
DNSContext context = (DNSContext) resolvedCtx.clone();
-
+
@Override
public Object getContent() {
return context;
}
};
- Reference ref = new Reference(
- this.getClass().getName(), refAddr);
+ Reference ref = new Reference(this.getClass().getName(), refAddr);
CannotProceedException cpe = null;
CompositeName resolvedName = null;
if (environment.containsKey(NamingManager.CPE)) {
- cpe = (CannotProceedException)
- environment.get(NamingManager.CPE);
+ cpe = (CannotProceedException) environment.get(NamingManager.CPE);
resolvedName = (CompositeName) cpe.getResolvedName();
// remove the last component if it is ""
// (the sign of the next naming system)
- if (resolvedName != null &&
- resolvedName.get(resolvedName.size() - 1)
- .equals("")) //$NON-NLS-1$
+ if (resolvedName != null
+ && resolvedName.get(resolvedName.size() - 1).equals("")) //$NON-NLS-1$
{
resolvedName.remove(resolvedName.size() - 1);
}
- }
- else {
+ } else {
cpe = new CannotProceedException();
}
cpe.setEnvironment((Hashtable) environment.clone());
@@ -1262,64 +1329,70 @@
cpe.setResolvedObj(ref);
return cpe;
}
-
+
/**
- * Creates an <code>Attributes</code> object from the given enumeration
- * of resource records.
- * @param recs enumeration of resource records received from the resolver
+ * Creates an <code>Attributes</code> object from the given enumeration of
+ * resource records.
+ *
+ * @param recs
+ * enumeration of resource records received from the resolver
* @return corresponding instance of <code>Attributes</code>
*/
- private static Attributes createAttributesFromRecords(Enumeration<ResourceRecord> recs) {
+ private static Attributes createAttributesFromRecords(
+ Enumeration<ResourceRecord> recs) {
Attributes attrs = new BasicAttributes(true);
-
+
while (recs.hasMoreElements()) {
ResourceRecord curRec = recs.nextElement();
String clssTypeStr = null;
Attribute oldAttr = null;
-
+
if (curRec.getRRClass() == ProviderConstants.IN_CLASS) {
clssTypeStr = ProviderConstants.rrTypeNames[curRec.getRRType()];
- }
- else {
- clssTypeStr =
- ProviderConstants.rrClassNames[curRec.getRRClass()] +
- " " + //$NON-NLS-1$
+ } else {
+ clssTypeStr = ProviderConstants.rrClassNames[curRec
+ .getRRClass()]
+ + " " + //$NON-NLS-1$
ProviderConstants.rrTypeNames[curRec.getRRType()];
}
oldAttr = attrs.get(clssTypeStr);
if (oldAttr != null) {
oldAttr.add(oldAttr.size(), curRec.getRData());
} else {
- BasicAttribute attr = new BasicAttribute(clssTypeStr,
- curRec.getRData(), false);
+ BasicAttribute attr = new BasicAttribute(clssTypeStr, curRec
+ .getRData(), false);
- attrs.put(attr);
+ attrs.put(attr);
}
}
return attrs;
}
-
+
/**
* Looks for a object associated with the given name. This methods just
- * forwards the request to <code>#lookup(Name)</code> method and do nothing
- * more.
- * @param name name to look for
+ * forwards the request to <code>#lookup(Name)</code> method and do
+ * nothing more.
+ *
+ * @param name
+ * name to look for
* @return found object
- * @throws NamingException if encountered
+ * @throws NamingException
+ * if encountered
* @see #lookup(Name) for details
* @see javax.naming.Context#lookupLink(javax.naming.Name)
*/
public Object lookupLink(Name name) throws NamingException {
return lookup(name);
}
-
- /**
+
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#bind(javax.naming.Name, java.lang.Object)
*/
public void bind(Name arg0, Object arg1) throws NamingException {
ContextNamePair pair;
-
+
try {
pair = getTargetNamespaceContextNamePair(arg0);
} catch (IllegalArgumentException e) {
@@ -1329,17 +1402,18 @@
((Context) pair.context).bind(pair.name, arg1);
} else {
// jndi.4E=found object is not a Context
- throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#rebind(javax.naming.Name, java.lang.Object)
*/
public void rebind(Name arg0, Object arg1) throws NamingException {
ContextNamePair pair;
-
+
try {
pair = getTargetNamespaceContextNamePair(arg0);
} catch (IllegalArgumentException e) {
@@ -1349,34 +1423,36 @@
((Context) pair.context).rebind(pair.name, arg1);
} else {
// jndi.4E=found object is not a Context
- throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
+ throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
}
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#rename(java.lang.String, java.lang.String)
*/
public void rename(String arg0, String arg1) throws NamingException {
- rename(convertNameFromStringForm(arg0),
- convertNameFromStringForm(arg1));
+ rename(convertNameFromStringForm(arg0), convertNameFromStringForm(arg1));
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#createSubcontext(java.lang.String)
*/
public Context createSubcontext(String arg0) throws NamingException {
return createSubcontext(convertNameFromStringForm(arg0));
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#createSubcontext(javax.naming.Name)
*/
public Context createSubcontext(Name arg0) throws NamingException {
ContextNamePair pair;
-
+
try {
pair = getTargetNamespaceContextNamePair(arg0);
} catch (IllegalArgumentException e) {
@@ -1389,40 +1465,45 @@
throw new NotContextException(Messages.getString("jndi.4E")); //$NON-NLS-1$
}
- /**
+ /**
* This method is not supported.
+ *
* @see javax.naming.Context#rename(javax.naming.Name, javax.naming.Name)
*/
public void rename(Name arg0, Name arg1) throws NamingException {
ContextNamePair pair1;
ContextNamePair pair2;
-
+
try {
pair1 = getTargetNamespaceContextNamePair(arg0);
pair2 = getTargetNamespaceContextNamePair(arg1);
} catch (IllegalArgumentException e) {
throw new OperationNotSupportedException();
}
- if (pair1.context instanceof Context &&
- pair1.context.getClass().getName().equals(
- pair2.context.getClass().getName()) &&
- ((Context) pair1.context).getNameInNamespace().equals(
- ((Context) pair2.context).getNameInNamespace()))
- {
+ if (pair1.context instanceof Context
+ && pair1.context.getClass().getName().equals(
+ pair2.context.getClass().getName())
+ && ((Context) pair1.context).getNameInNamespace().equals(
+ ((Context) pair2.context).getNameInNamespace())) {
((Context) pair1.context).rename(pair1.name, pair2.name);
} else {
- // jndi.4F=found object is not a Context or target contexts are not equal
+ // jndi.4F=found object is not a Context or target contexts are not
+ // equal
throw new NotContextException(Messages.getString("jndi.4F")); //$NON-NLS-1$
}
}
/**
* Returns the name parser for given name.
- * @param name a name in the string form to return a name parser for
+ *
+ * @param name
+ * a name in the string form to return a name parser for
* @return the name parser found
- * @throws NotContextException if found object is not a context
- * @throws NamingException if such exception was encountered during lookup
- * @see DNSContext#getNameParser(Name) for details
+ * @throws NotContextException
+ * if found object is not a context
+ * @throws NamingException
+ * if such exception was encountered during lookup
+ * @see DNSContext#getNameParser(Name) for details
* @see javax.naming.Context#getNameParser(java.lang.String)
*/
public NameParser getNameParser(String name) throws NamingException {
@@ -1435,8 +1516,7 @@
obj = lookup(name);
if (obj instanceof DNSContext) {
return nameParser;
- }
- else if (obj instanceof Context) {
+ } else if (obj instanceof Context) {
return ((Context) obj).getNameParser(""); //$NON-NLS-1$
}
// jndi.4E=found object is not a Context
@@ -1447,12 +1527,16 @@
* Tries to look for the context associated with the given name and returns
* the appropriate name parser. For <code>DNSContext</code> this method
* will return an instance of <code>DNSNameParser</code> class.
- * @param a name to return a name parser for
+ *
+ * @param a
+ * name to return a name parser for
* @return a name parser for the naming system the found context is
- * associated with
- * @throws NotContextException if found object is not a context so we
- * cannot obtain a name parser from it
- * @throws NamingException if such exception was encountered during lookup
+ * associated with
+ * @throws NotContextException
+ * if found object is not a context so we cannot obtain a name
+ * parser from it
+ * @throws NamingException
+ * if such exception was encountered during lookup
* @see javax.naming.Context#getNameParser(javax.naming.Name)
*/
public NameParser getNameParser(Name name) throws NamingException {
@@ -1465,8 +1549,7 @@
obj = lookup(name);
if (obj instanceof DNSContext) {
return nameParser;
- }
- else if (obj instanceof Context) {
+ } else if (obj instanceof Context) {
return ((Context) obj).getNameParser(""); //$NON-NLS-1$
}
// jndi.4E=found object is not a Context
@@ -1476,53 +1559,69 @@
/**
* Lists all names along with corresponding class names contained by given
* context.
- * @param name context name to list
- * @return enumeration of <code>NameClassPair</code> objects
- * @throws NamingException if an error was encountered
+ *
+ * @param name
+ * context name to list
+ * @return enumeration of <code>NameClassPair</code> objects
+ * @throws NamingException
+ * if an error was encountered
* @see javax.naming.Context#list(javax.naming.Name)
*/
- public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
+ public NamingEnumeration<NameClassPair> list(String name)
+ throws NamingException {
return list_common(convertNameFromStringForm(name), NAME_CLASS_SWT);
}
/**
* Lists all names along with corresponding objects contained by given
* context.
- * @param name context name to list
- * @return enumeration of <code>Binding</code> objects
- * @throws NamingException if an error was encountered
+ *
+ * @param name
+ * context name to list
+ * @return enumeration of <code>Binding</code> objects
+ * @throws NamingException
+ * if an error was encountered
* @see javax.naming.Context#listBindings(java.lang.String)
*/
- public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
+ public NamingEnumeration<Binding> listBindings(String name)
+ throws NamingException {
return list_common(convertNameFromStringForm(name), BINDING_SWT);
}
/**
* Lists all names along with corresponding class names contained by given
* context.
- * @param name context name to list
- * @return enumeration of <code>NameClassPair</code> objects
- * @throws NoPermissionException if the resolver is not allowed to use a
- * network subsystem
- * @throws NameNotFoundException if authoritative server(s) was not found
- * @throws ServiceUnavailableException if none of found servers permits zone
- * transfers
- * @throws DomainProtocolException if some DNS specific error has occurred
- * @throws NamingException if other type of error has occurred
+ *
+ * @param name
+ * context name to list
+ * @return enumeration of <code>NameClassPair</code> objects
+ * @throws NoPermissionException
+ * if the resolver is not allowed to use a network subsystem
+ * @throws NameNotFoundException
+ * if authoritative server(s) was not found
+ * @throws ServiceUnavailableException
+ * if none of found servers permits zone transfers
+ * @throws DomainProtocolException
+ * if some DNS specific error has occurred
+ * @throws NamingException
+ * if other type of error has occurred
* @see javax.naming.Context#list(javax.naming.Name)
*/
- public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
+ public NamingEnumeration<NameClassPair> list(Name name)
+ throws NamingException {
return list_common(name, NAME_CLASS_SWT);
}
-
/**
* Lists all names along with corresponding class names contained by given
* context.
- * @param name context name to list
- * @param contentSwt method will return enumeration of
- * <code>NameClassPair</code> objects if this switch is set to
- * <code>1<code>; enumeration of <code>Binding</code> if the switch is set
+ *
+ * @param name
+ * context name to list
+ * @param contentSwt
+ * method will return enumeration of <code>NameClassPair</code>
+ * objects if this switch is set to
+ * <code>1<code>; enumeration of <code>Binding</code> if the switch is set
* to <code>2</code>
* @return enumeration of <code>NameClassPair</code> or
* <code>Binding</code> objects
@@ -1533,10 +1632,9 @@
* resolver's cache since we are sure the cache is up to date and contains
* absolutely all records from target zone
*/
- @SuppressWarnings("unchecked") //$NON-NLS-1$
+ @SuppressWarnings("unchecked")
private <T> NamingEnumeration<T> list_common(Name name, int contentSwt)
- throws NamingException
- {
+ throws NamingException {
DNSName nameToList = null;
DNSName altName = null;
CompositeName remainingName = null;
@@ -1554,30 +1652,27 @@
else if (name.size() == 0) {
// attributes of the current context are requested
nameToList = (DNSName) contextName.clone();
- }
- else if (name instanceof CompositeName) {
+ } else if (name instanceof CompositeName) {
// treat the first component of the given composite name as
// a domain name and the rest as a Next Naming System name
String tmp = name.get(0);
// check if it is really a domain name
altName = (DNSName) nameParser.parse(tmp);
- //if (!altName.isAbsolute()) {
+ // if (!altName.isAbsolute()) {
nameToList = (DNSName) composeName(altName, contextName);
- //} else {
- // nameToList = (DNSName) altName.clone();
- //}
+ // } else {
+ // nameToList = (DNSName) altName.clone();
+ // }
if (name.size() > 1) {
remainingName = (CompositeName) name.getSuffix(1);
}
- }
- else if (name instanceof DNSName) {
- //if (!((DNSName) name).isAbsolute()) {
+ } else if (name instanceof DNSName) {
+ // if (!((DNSName) name).isAbsolute()) {
nameToList = (DNSName) composeName(name, contextName);
- //} else {
- // nameToList = (DNSName) name.clone();
- //}
- }
- else {
+ // } else {
+ // nameToList = (DNSName) name.clone();
+ // }
+ } else {
throw new InvalidNameException(Messages.getString("jndi.4B")); //$NON-NLS-1$
}
// we should have correct nameToLookFor at this point
@@ -1586,14 +1681,15 @@
altName, remainingName);
Context nnsContext = DirectoryManager.getContinuationContext(cpe);
- result = (NamingEnumeration<T>)nnsContext.list(remainingName);
+ result = (NamingEnumeration<T>) nnsContext.list(remainingName);
} else {
// do the job
try {
- Enumeration<ResourceRecord> resEnum = resolver.list(nameToList.toString());
+ Enumeration<ResourceRecord> resEnum = resolver.list(nameToList
+ .toString());
Hashtable<String, T> entries = new Hashtable<String, T>();
- DNSContext targetCtx = new DNSContext(this, nameToList);
-
+ DNSContext targetCtx = new DNSContext(this, nameToList);
+
// collecting direct children
while (resEnum.hasMoreElements()) {
ResourceRecord rr = resEnum.nextElement();
@@ -1601,13 +1697,12 @@
Name curName = nameParser.parse(rr.getName());
// if contains direct child of current context
- if (curName.startsWith(nameToList) &&
- curName.size() > nameToList.size())
- {
- // extract relative name of direct child
+ if (curName.startsWith(nameToList)
+ && curName.size() > nameToList.size()) {
+ // extract relative name of direct child
String elNameStr = curName.get(nameToList.size());
- // if we don't have such child yet
+ // if we don't have such child yet
if (!entries.containsKey(elNameStr)) {
Object elObj;
T objToPut = null;
@@ -1626,15 +1721,16 @@
elObj = DirectoryManager.getObjectInstance(elCtx,
elNameRel, targetCtx, environment, null);
switch (contentSwt) {
- case 1:
- // NameClassPair
- objToPut = (T)new NameClassPair(elNameStr,
- elObj.getClass().getName(), true);
- break;
- case 2:
- // Binding
- objToPut = (T)new Binding(elNameStr, elObj, true);
- break;
+ case 1:
+ // NameClassPair
+ objToPut = (T) new NameClassPair(elNameStr,
+ elObj.getClass().getName(), true);
+ break;
+ case 2:
+ // Binding
+ objToPut = (T) new Binding(elNameStr,
+ elObj, true);
+ break;
}
entries.put(elNameStr, objToPut);
}
@@ -1647,11 +1743,11 @@
throw e;
} catch (Exception e) {
NamingException e2 = new NamingException(e.getMessage());
-
+
e2.setRootCause(e);
throw e2;
}
-
+
}
return result;
}
@@ -1659,28 +1755,37 @@
/**
* Lists all names along with corresponding objects contained by given
* context.
- * @param name context name to list
- * @return enumeration of <code>Binding</code> objects
- * @throws NamingException if an error was encountered
+ *
+ * @param name
+ * context name to list
+ * @return enumeration of <code>Binding</code> objects
+ * @throws NamingException
+ * if an error was encountered
* @see javax.naming.Context#listBindings(javax.naming.Name)
*/
- public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
+ public NamingEnumeration<Binding> listBindings(Name name)
+ throws NamingException {
return list_common(name, BINDING_SWT);
}
/**
* Add a new property to the environment.
- * @param propName a name for the new property
- * @param propValue a value of the new property
+ *
+ * @param propName
+ * a name for the new property
+ * @param propValue
+ * a value of the new property
* @return an old value of this property; <code>null</code> if not found
- * @throws NullPointerException if <code>propName</code> or
- * <code>propValue</code> is null.
- * @throws NamingException if such was encountered
- * @see javax.naming.Context#addToEnvironment(java.lang.String, java.lang.Object)
+ * @throws NullPointerException
+ * if <code>propName</code> or <code>propValue</code> is
+ * null.
+ * @throws NamingException
+ * if such was encountered
+ * @see javax.naming.Context#addToEnvironment(java.lang.String,
+ * java.lang.Object)
*/
public Object addToEnvironment(String propName, Object propValue)
- throws NamingException
- {
+ throws NamingException {
Object oldVal = environment.put(propName, propValue);
if (propName.equals(Context.AUTHORITATIVE)) {
@@ -1708,30 +1813,32 @@
/**
* Appends one name to another. The method initially tries to construct
- * composite names from given strings. If it succeeds and resulting composite
- * names have length more than 1 then the method
- * <code>composeName(Name, Name)</code> will be called
- * with constructed composite names as arguments. If one of constructed
- * composite names (or both) have the length less or equal to 1 then
- * it will be treated as a string representation of DNS name. The
- * <code>DNSNameParser.parse</code> method will be called with given string
- * as an argument. If no exception is thrown then the
- * <code>composeName(Name, Name)</code> will be called with the parsed
- * <code>DNSName</code> as an argument.
- * @param name a name relative to the current context
- * @param prefix the name of the current context in one of its ancestors
+ * composite names from given strings. If it succeeds and resulting
+ * composite names have length more than 1 then the method
+ * <code>composeName(Name, Name)</code> will be called with constructed
+ * composite names as arguments. If one of constructed composite names (or
+ * both) have the length less or equal to 1 then it will be treated as a
+ * string representation of DNS name. The <code>DNSNameParser.parse</code>
+ * method will be called with given string as an argument. If no exception
+ * is thrown then the <code>composeName(Name, Name)</code> will be called
+ * with the parsed <code>DNSName</code> as an argument.
+ *
+ * @param name
+ * a name relative to the current context
+ * @param prefix
+ * the name of the current context in one of its ancestors
* @return a composition of <code>prefix</code> and <code>name</code>
- * @throws NamingException
- * @throws NullPointerException if the value of any argument is null
+ * @throws NamingException
+ * @throws NullPointerException
+ * if the value of any argument is null
* @see DNSContext#composeName(Name, Name)
* @see javax.naming.Context#composeName(java.lang.String, java.lang.String)
*/
public String composeName(String name, String prefix)
- throws NamingException
- {
+ throws NamingException {
Name name1 = null;
Name name2 = null;
-
+
if (name == null || prefix == null) {
// jndi.51=Given name of prefix is null
throw new NullPointerException(Messages.getString("jndi.51")); //$NON-NLS-1$
@@ -1745,8 +1852,8 @@
try {
name1 = new CompositeName(name);
name2 = new CompositeName(prefix);
+ } catch (InvalidNameException e) {
}
- catch (InvalidNameException e) {}
if (name1 == null || name1.size() <= 1) {
name1 = nameParser.parse(name);
}
@@ -1757,29 +1864,36 @@
}
/**
- * Adds <code>name</code> to the end of <code>prefix</code>.
- * Following cases are checked:
+ * Adds <code>name</code> to the end of <code>prefix</code>. Following
+ * cases are checked:
* <ol>
* <li><code>suffix</code> is a composite name, <code>name</code> is
- * compound one</li>
+ * compound one</li>
* <li><code>suffix</code> is a compound name, <code>name</code> is
[... 242 lines stripped ...]