Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 98908 invoked from network); 23 Jun 2007 20:54:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Jun 2007 20:54:54 -0000 Received: (qmail 73965 invoked by uid 500); 23 Jun 2007 20:54:56 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 73918 invoked by uid 500); 23 Jun 2007 20:54:55 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 73889 invoked by uid 99); 23 Jun 2007 20:54:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Jun 2007 13:54:55 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Jun 2007 13:54:41 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id DCA691A9877; Sat, 23 Jun 2007 13:53:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r550106 [15/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... Date: Sat, 23 Jun 2007 20:53:48 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070623205354.DCA691A9877@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResolverCache.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResolverCache.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/ResolverCache.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResolverCache.java Sat Jun 23 13:53:42 2007 @@ -30,8 +30,6 @@ /** * A cache for received resource records. Common for all active resolvers. * - * @author Alexei Zakharov - * @version $Revision: 1.1.2.4 $ * TODO handling of records with TTL set to 0; should not be cached. */ class ResolverCache { @@ -39,9 +37,9 @@ /** keys - zone & host names; values - vectors with RRs */ HashMap> names = new HashMap>(); - /** + /** * Since ResolverCache is singleton class its constructor - * should be hidden. + * should be hidden. */ private ResolverCache() { names = new HashMap>(); @@ -51,6 +49,7 @@ /** * ResolverCache is a singleton class. + * * @return active instance of ResolverCache */ static ResolverCache getInstance() { @@ -59,15 +58,16 @@ } return instance; } - + /** * Looks through the cache and returns all suitable resource records - * @param question a question record that determines which records we want - * to get from the cache + * + * @param question + * a question record that determines which records we want to get + * from the cache * @return Enumeration of found Resource Records. */ - synchronized Enumeration get(QuestionRecord question) - { + synchronized Enumeration get(QuestionRecord question) { String name = question.getQName().toLowerCase(); Vector vect = names.get(name); int qClass = question.getQClass(); @@ -84,12 +84,12 @@ vect.removeElementAt(i--); continue; } - if (qClass == ProviderConstants.ANY_QCLASS || - qClass != curRR.getRRClass()) { + if (qClass == ProviderConstants.ANY_QCLASS + || qClass != curRR.getRRClass()) { continue; } - if (qType == ProviderConstants.ANY_QTYPE || - qType != curRR.getRRType()) { + if (qType == ProviderConstants.ANY_QTYPE + || qType != curRR.getRRType()) { continue; } resVect.addElement(curRR); @@ -99,12 +99,13 @@ } /** - * Puts element into the cache. Doesn't put records with zero TTLs. - * Doesn't put records with bad TTLs. - * @param record a resource record to insert + * Puts element into the cache. Doesn't put records with zero TTLs. Doesn't + * put records with bad TTLs. + * + * @param record + * a resource record to insert */ - synchronized void put(ResourceRecord record) - { + synchronized void put(ResourceRecord record) { String name = record.getName().toLowerCase(); Vector vect = names.get(name); long curTime = System.currentTimeMillis(); @@ -119,7 +120,7 @@ if (record.getTtl() >> 31 != 0) { record.setTtl(0); } - // skip records with wildcards in names or with zero TTL + // skip records with wildcards in names or with zero TTL if (record.getTtl() > 0 && (record.getName().indexOf('*') == -1)) { entry = new CacheEntry(record, curTime + record.getTtl()); // remove old occurrence if any @@ -127,12 +128,12 @@ CacheEntry exEntry = vect.elementAt(i); ResourceRecord exRec = exEntry.rr; - if (ProviderMgr.namesAreEqual(record.getName(), exRec.getName()) + if (ProviderMgr + .namesAreEqual(record.getName(), exRec.getName()) && record.getRRClass() == exRec.getRRClass() - && record.getRRType() == exRec.getRRType()) - { - if (record.getRData() != null && exRec.getRData() != null && - record.getRData().equals(exRec.getRData())) { + && record.getRRType() == exRec.getRRType()) { + if (record.getRData() != null && exRec.getRData() != null + && record.getRData().equals(exRec.getRData())) { vect.remove(i); break; } @@ -149,34 +150,35 @@ names = new HashMap>(); } - // additional class - /** * Represents SLIST cache entry. - * @author Alexei Zakharov */ static class CacheEntry { private ResourceRecord rr; + private long bestBefore; /** * Constructs new cache entry. - * @param rr Resource Record - * @param bestBefore best before (time in millis) + * + * @param rr + * Resource Record + * @param bestBefore + * best before (time in millis) */ public CacheEntry(ResourceRecord rr, long bestBefore) { this.rr = rr; this.bestBefore = bestBefore; } - /** * @return Returns the bestBefore. */ public long getBestBefore() { return bestBefore; } + /** * @return Returns the Resource Record. */ @@ -184,5 +186,5 @@ return rr; } } - + } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResourceRecord.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResourceRecord.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/ResourceRecord.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResourceRecord.java Sat Jun 23 13:53:42 2007 @@ -30,73 +30,74 @@ /** * Represents domain protocol Resource Record * - * @author Alexei Zakharov - * @version $Revision: 1.1.2.4 $ * @see RFC 1035 */ public class ResourceRecord { - + /** a domain name */ private String name; - + /** resource record type */ private int rrType; - - /** resource record class*/ + + /** resource record class */ private int rrClass; - + /** time to live */ private long ttl; - + /** resource data length */ -// private int rdLength; - + // private int rdLength; /** resource data itself */ private Object rData; /** empty constructor */ - public ResourceRecord() {} + public ResourceRecord() { + } /** * Constructs new ResourceRecord object from given values. * - * @param name a domain name - * @param rrType resource record type - * @param rrClass resource record class - * @param ttl time to live - * @param rdLength resource data length - * @param rData resource data itself - */ - public ResourceRecord( - String name, - int rrType, - int rrClass, - long ttl, - //int rdLength, - Object rData) - { + * @param name + * a domain name + * @param rrType + * resource record type + * @param rrClass + * resource record class + * @param ttl + * time to live + * @param rdLength + * resource data length + * @param rData + * resource data itself + */ + public ResourceRecord(String name, int rrType, int rrClass, long ttl, + /* int rdLength, */ + Object rData) { this.name = name; this.rrType = rrType; this.rrClass = rrClass; this.ttl = ttl; - //this.rdLength = rdLength; + // this.rdLength = rdLength; this.rData = rData; } - + /** * Creates the sequence of bytes that represents the current resource - * record. + * record. * - * @param buffer the buffer to write the bytes into - * @param startIdx starting index + * @param buffer + * the buffer to write the bytes into + * @param startIdx + * starting index * @return updated index - * @throws DomainProtocolException if something went wrong - * @throws ArrayIndexOutOfBoundsException if the buffer border unpredictably - * encountered + * @throws DomainProtocolException + * if something went wrong + * @throws ArrayIndexOutOfBoundsException + * if the buffer border unpredictably encountered */ public int writeBytes(byte[] buffer, int startIdx) - throws DomainProtocolException - { + throws DomainProtocolException { int idx = startIdx; // basic checking @@ -113,10 +114,9 @@ // TTL idx = ProviderMgr.write32Int(ttl, buffer, idx); // RDLENGTH & RDATA - if (rrType == ProviderConstants.NS_TYPE || - rrType == ProviderConstants.CNAME_TYPE || - rrType == ProviderConstants.PTR_TYPE) - { + if (rrType == ProviderConstants.NS_TYPE + || rrType == ProviderConstants.CNAME_TYPE + || rrType == ProviderConstants.PTR_TYPE) { int idx0 = idx; idx += 2; @@ -124,8 +124,7 @@ idx = ProviderMgr.writeName((String) rData, buffer, idx); // RDLENGTH ProviderMgr.write16Int(idx - 2 - idx0, buffer, idx0); - } - else if (rrType == ProviderConstants.A_TYPE) { + } else if (rrType == ProviderConstants.A_TYPE) { byte[] ipBytes = ProviderMgr.parseIpStr((String) rData); // RDLENGTH @@ -133,8 +132,7 @@ for (byte element : ipBytes) { buffer[idx++] = element; } - } - else if (rrType == ProviderConstants.SOA_TYPE) { + } else if (rrType == ProviderConstants.SOA_TYPE) { StringTokenizer st = new StringTokenizer((String) rData, " "); //$NON-NLS-1$ String token; int idx0 = idx; // saving RDLENGTH position @@ -159,35 +157,31 @@ try { for (int i = 0; i < 5; i++) { token = st.nextToken(); - idx = ProviderMgr.write32Int( - Long.parseLong(token), buffer, idx); + idx = ProviderMgr.write32Int(Long.parseLong(token), buffer, + idx); } - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // jndi.36=Error while parsing SOA record throw new DomainProtocolException( Messages.getString("jndi.36"), e); //$NON-NLS-1$ } // RDLENGTH ProviderMgr.write16Int(idx - 2 - idx0, buffer, idx0); - } - else if (rrType == ProviderConstants.MX_TYPE) { + } else if (rrType == ProviderConstants.MX_TYPE) { StringTokenizer st = new StringTokenizer((String) rData, " "); //$NON-NLS-1$ String token; int idx0 = idx; // saving RDLENGTH position if (st.countTokens() != 2) { // jndi.37=Invalid number of fields while parsing MX record - throw new DomainProtocolException( - Messages.getString("jndi.37")); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.37")); //$NON-NLS-1$ } idx += 2; // skip RDLENGTH for now // PREFERENCE token = st.nextToken(); try { ProviderMgr.write16Int(Integer.parseInt(token), buffer, idx); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // jndi.38=Error while parsing MX record throw new DomainProtocolException( Messages.getString("jndi.38"), e); //$NON-NLS-1$ @@ -197,16 +191,14 @@ idx = ProviderMgr.writeName(token, buffer, idx); // RDLENGTH ProviderMgr.write16Int(idx - 2 - idx0, buffer, idx0); - } - else if (rrType == ProviderConstants.HINFO_TYPE) { + } else if (rrType == ProviderConstants.HINFO_TYPE) { StringTokenizer st = new StringTokenizer((String) rData, " "); //$NON-NLS-1$ String token; int idx0 = idx; // saving RDLENGTH position if (st.countTokens() != 2) { // jndi.39=Invalid number of fields while parsing HINFO record - throw new DomainProtocolException( - Messages.getString("jndi.39")); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.39")); //$NON-NLS-1$ } idx += 2; // skip RDLENGTH for now // CPU @@ -217,8 +209,7 @@ } // RDLENGTH ProviderMgr.write16Int(idx - 2 - idx0, buffer, idx0); - } - else if (rrType == ProviderConstants.TXT_TYPE) { + } else if (rrType == ProviderConstants.TXT_TYPE) { // character string with preceding length octet int idx0 = idx; StringTokenizer st = new StringTokenizer((String) rData, " "); //$NON-NLS-1$ @@ -230,20 +221,18 @@ if (token.getBytes().length > 255) { // jndi.3A=The length of character string exceed 255 octets - throw new DomainProtocolException( - Messages.getString("jndi.3A")); //$NON-NLS-1$ + throw new DomainProtocolException(Messages + .getString("jndi.3A")); //$NON-NLS-1$ } idx = ProviderMgr.writeCharString(token, buffer, idx); } if (idx - 2 - idx0 > 65535) { // jndi.3B=Length of TXT field exceed 65535 - throw new DomainProtocolException( - Messages.getString("jndi.3B")); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.3B")); //$NON-NLS-1$ } // RDLENGTH ProviderMgr.write16Int(idx - 2 - idx0, buffer, idx0); - } - else if (rrType == ProviderConstants.SRV_TYPE) { + } else if (rrType == ProviderConstants.SRV_TYPE) { StringTokenizer st = new StringTokenizer((String) rData, " "); //$NON-NLS-1$ String token; int idx0 = idx; // saving RDLENGTH position @@ -251,8 +240,7 @@ idx += 2; if (st.countTokens() != 4) { // jndi.3C=Invalid number of fields while parsing SRV record - throw new DomainProtocolException( - Messages.getString("jndi.3C")); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.3C")); //$NON-NLS-1$ } // RDATA @@ -262,11 +250,10 @@ try { for (int i = 0; i < 3; i++) { token = st.nextToken(); - idx = ProviderMgr.write16Int( - Integer.parseInt(token), buffer, idx); + idx = ProviderMgr.write16Int(Integer.parseInt(token), + buffer, idx); } - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // jndi.3D=Error while parsing SRV record throw new DomainProtocolException( Messages.getString("jndi.3D"), e); //$NON-NLS-1$ @@ -280,11 +267,12 @@ // TODO add more Resource Record types here else { byte[] bytes; - + if (!(rData instanceof byte[])) { - // jndi.3E=RDATA for unknown record type {0} should have value of byte[] type - throw new DomainProtocolException( - Messages.getString("jndi.3E", rrType)); //$NON-NLS-1$ + // jndi.3E=RDATA for unknown record type {0} should have value + // of byte[] type + throw new DomainProtocolException(Messages.getString( + "jndi.3E", rrType)); //$NON-NLS-1$ } bytes = (byte[]) rData; // RDLENGTH @@ -299,23 +287,26 @@ /** * Parses given sequence of bytes and constructs a resource record from it. * - * @param mesBytes the byte array that should be parsed - * @param startIdx an index of mesBytes array to start the - * parsing at - * @param resultRR an object the result of the operation will be stored into + * @param mesBytes + * the byte array that should be parsed + * @param startIdx + * an index of mesBytes array to start the parsing + * at + * @param resultRR + * an object the result of the operation will be stored into * @return updated index of mesBytes array - * @throws DomainProtocolException if something went wrong - * @throws ArrayIndexOutOfBoundsException if the array border unpredictably - * encountered + * @throws DomainProtocolException + * if something went wrong + * @throws ArrayIndexOutOfBoundsException + * if the array border unpredictably encountered */ public static int parseRecord(byte[] mesBytes, int startIdx, - ResourceRecord resultRR) throws DomainProtocolException - { + ResourceRecord resultRR) throws DomainProtocolException { int idx = startIdx; StringBuffer nameSB = new StringBuffer(); int rrType; int rdLen; - Object rDat = null; + Object rDat = null; if (resultRR == null) { // jndi.3F=Given resultRR is null @@ -338,28 +329,24 @@ rdLen = ProviderMgr.parse16Int(mesBytes, idx); idx += 2; // RDATA - if (rrType == ProviderConstants.NS_TYPE || - rrType == ProviderConstants.CNAME_TYPE || - rrType == ProviderConstants.PTR_TYPE) - { + if (rrType == ProviderConstants.NS_TYPE + || rrType == ProviderConstants.CNAME_TYPE + || rrType == ProviderConstants.PTR_TYPE) { // let's parse the domain name StringBuffer name = new StringBuffer(); idx = ProviderMgr.parseName(mesBytes, idx, name); rDat = ProviderMgr.normalizeName(name.toString()); - } - else if (rrType == ProviderConstants.A_TYPE) { + } else if (rrType == ProviderConstants.A_TYPE) { // let's parse the 32 bit Internet address byte tmpArr[] = new byte[4]; - for (int i = 0; i < 4 ; i++) { + for (int i = 0; i < 4; i++) { tmpArr[i] = mesBytes[idx + i]; } rDat = ProviderMgr.getIpStr(tmpArr); idx += 4; - } - else if (rrType == ProviderConstants.MX_TYPE) - { + } else if (rrType == ProviderConstants.MX_TYPE) { // 16 bit integer (preference) followed by domain name int preference; StringBuffer name = new StringBuffer(); @@ -369,8 +356,7 @@ idx = ProviderMgr.parseName(mesBytes, idx, name); rDat = "" + preference + " " + //$NON-NLS-1$ //$NON-NLS-2$ ProviderMgr.normalizeName(name.toString()); - } - else if (rrType == ProviderConstants.SOA_TYPE) { + } else if (rrType == ProviderConstants.SOA_TYPE) { StringBuffer mName = new StringBuffer(); StringBuffer rName = new StringBuffer(); long serial; @@ -395,8 +381,7 @@ ProviderMgr.normalizeName(rName.toString()) + " " + //$NON-NLS-1$ serial + " " + refresh + " " + retry + " " + expire + " " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ minimum; - } - else if (rrType == ProviderConstants.TXT_TYPE) { + } else if (rrType == ProviderConstants.TXT_TYPE) { StringBuffer sbuf = new StringBuffer(); int idx0 = idx; @@ -410,12 +395,11 @@ if (sbuf.length() > 0) { sbuf.append(' '); } - sbuf.append(new String(mesBytes, idx, len11)); + sbuf.append(new String(mesBytes, idx, len11)); idx += len11; } rDat = sbuf.toString(); - } - else if (rrType == ProviderConstants.HINFO_TYPE) { + } else if (rrType == ProviderConstants.HINFO_TYPE) { // two character strings with preceding length octets StringBuffer res = new StringBuffer(); @@ -423,8 +407,7 @@ res.append(" "); //$NON-NLS-1$ idx = ProviderMgr.parseCharString(mesBytes, idx, res); rDat = res.toString(); - } - else if (rrType == ProviderConstants.SRV_TYPE) { + } else if (rrType == ProviderConstants.SRV_TYPE) { int priority; int weight; int port; @@ -468,77 +451,91 @@ return sb.toString(); } - // getters and setters - + /** * @return Returns the name. */ public String getName() { return name; } + /** - * @param name The name to set. + * @param name + * The name to set. */ public void setName(String name) { this.name = name; } + /** * @return Returns the rData. */ public Object getRData() { return rData; } + /** - * @param data The rData to set. + * @param data + * The rData to set. */ public void setRData(Object data) { rData = data; } + /** * @return Returns the rdLength. */ - //public int getRDLength() { - // return rdLength; - //} - /** - * @param rdLength The rdLength to set. - */ - //public void setRDLength(int rdLength) { - // this.rdLength = rdLength; - //} + // public int getRDLength() { + // return rdLength; + // } + /** + * @param rdLength + * The rdLength to set. + */ + // public void setRDLength(int rdLength) { + // this.rdLength = rdLength; + // } /** * @return Returns the rrClass. */ public int getRRClass() { return rrClass; } + /** - * @param rrClass The rrClass to set. + * @param rrClass + * The rrClass to set. */ public void setRRClass(int rrClass) { this.rrClass = rrClass; } + /** * @return Returns the rrType. */ public int getRRType() { return rrType; } + /** - * @param rrType The rrType to set. + * @param rrType + * The rrType to set. */ public void setRRType(int rrType) { this.rrType = rrType; } + /** * @return Returns the TTL. */ public long getTtl() { return ttl; } + /** - * @param ttl The TTL to set. + * @param ttl + * The TTL to set. */ public void setTtl(long ttl) { this.ttl = ttl; Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.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/SList.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java Sat Jun 23 13:53:42 2007 @@ -16,11 +16,6 @@ * limitations under the License. */ -/** - * @author Alexei Y. Zakharov - * @version $Revision: 1.1.2.5 $ - */ - package org.apache.harmony.jndi.provider.dns; import java.util.Enumeration; @@ -29,29 +24,29 @@ import org.apache.harmony.jndi.internal.nls.Messages; - /** * Represents DNS resolver's SLIST - the structure to keep the collected - * information about active DNS servers and zones they contain information - * about. - * @author Alexei Zakharov - * @version $Revision: 1.1.2.5 $ - * @see RFC 1034 - * TODO some methods can be optimized + * information about active DNS servers and zones they contain information + * about. + * + * @see RFC 1034 TODO some methods can be optimized */ class SList { - + public static int NETWORK_FAILURE = Integer.MAX_VALUE - 3; + public static int TIMEOUT = Integer.MAX_VALUE - 2; + public static int SERVER_FAILURE = Integer.MAX_VALUE - 1; + public static int UNKNOWN = 0; // Hash with vectors; one vector of server entries per zone private Hashtable> zones; - + // the array with known DNS servers information private Vector servers; - + /** * @see #getInstance() */ @@ -64,6 +59,7 @@ /** * SList is a singleton class. + * * @return instance of SList */ static SList getInstance() { @@ -71,47 +67,47 @@ } /** - * Updates existent SLIST entry or creates a new one. S-List will - * be sorted according the response time. Entries with bigger response will - * be placed father from the beginning of the list. + * Updates existent SLIST entry or creates a new one. S-List will be sorted + * according the response time. Entries with bigger response will be placed + * father from the beginning of the list. * - * @param zone the name of DNS zone - * @param server the server that is known to have the information about - * given zone - * @param responseTime response time for server for this particular DNS zone - */ - void updateEntry(String zone, Server server, int responseTime) - { - String normZoneName = ProviderMgr.normalizeName(zone); + * @param zone + * the name of DNS zone + * @param server + * the server that is known to have the information about given + * zone + * @param responseTime + * response time for server for this particular DNS zone + */ + void updateEntry(String zone, Server server, int responseTime) { + String normZoneName = ProviderMgr.normalizeName(zone); Vector vect; - Entry entryToAdd = - new Entry(normZoneName, getServerNum(server), responseTime); + Entry entryToAdd = new Entry(normZoneName, getServerNum(server), + responseTime); synchronized (zones) { - vect = - zones.get(ProviderMgr.normalizeName(normZoneName)); + vect = zones.get(ProviderMgr.normalizeName(normZoneName)); if (vect == null) { vect = new Vector(); vect.addElement(entryToAdd); zones.put(normZoneName, vect); - } - else { + } else { boolean added = false; - + // delete previous occurrence of given server for (int i = 0; i < vect.size(); i++) { Entry curEntry = vect.elementAt(i); - + if (server.equals(serverAtNum(curEntry.getServerNum()))) { vect.removeElementAt(i); break; } } - + // and insert a new one with updated response time for (int i = 0; i < vect.size(); i++) { Entry curEntry = vect.elementAt(i); - + if (responseTime < curEntry.getResponseTime()) { vect.insertElementAt(entryToAdd, i); added = true; @@ -128,10 +124,12 @@ /** * Returns the best guess about that DNS server should be chosen to send the - * request concerning the particular DNS zone. - * @param zone the name of DNS zone + * request concerning the particular DNS zone. + * + * @param zone + * the name of DNS zone * @return best guess - a SList.Server object; - * null if the information is not found + * null if the information is not found */ Server getBestGuess(String zone, Hashtable serversToIgnore) { Vector vect; @@ -141,11 +139,10 @@ if (vect != null && vect.size() > 0) { for (int i = 0; i < vect.size(); i++) { Entry entry = vect.elementAt(i); - + if (serversToIgnore != null) { - if (serversToIgnore.get( - serverAtNum(entry.getServerNum())) != null) - { + if (serversToIgnore.get(serverAtNum(entry + .getServerNum())) != null) { continue; } } @@ -157,9 +154,12 @@ } /** - * Removes occurrence of given server related to given zone from the SLIST. - * @param zone DNS zone - * @param server the server to remove + * Removes occurrence of given server related to given zone from the SLIST. + * + * @param zone + * DNS zone + * @param server + * the server to remove */ void dropServer(String zone, Server server) { Vector vect; @@ -169,7 +169,7 @@ if (vect != null) { for (int i = 0; i < vect.size(); i++) { Entry entry = vect.elementAt(i); - + if (server.equals(serverAtNum(entry.getServerNum()))) { vect.removeElementAt(i); break; @@ -180,10 +180,12 @@ } /** - * @param zone the name of zone - * @param server DNS server + * @param zone + * the name of zone + * @param server + * DNS server * @return true if SList has information about specified - * server & zone combination; false otherwise + * server & zone combination; false otherwise */ boolean hasServer(String zone, Server server) { Vector vect; @@ -193,7 +195,7 @@ if (vect != null) { for (int i = 0; i < vect.size(); i++) { Entry entry = vect.elementAt(i); - + if (server.equals(serverAtNum(entry.getServerNum()))) { return true; } @@ -204,9 +206,12 @@ } /** - * @param zone the name DNS zone - * @param srvName the name of the server - * @param srvPort the port of the server + * @param zone + * the name DNS zone + * @param srvName + * the name of the server + * @param srvPort + * the port of the server * @return Server object with specified attributes */ Server getServerByName(String zone, String name, int port) { @@ -217,12 +222,11 @@ if (vect != null) { for (int i = 0; i < vect.size(); i++) { Entry entry = vect.elementAt(i); - - if (ProviderMgr.namesAreEqual(name, - serverAtNum(entry.getServerNum()).getName()) - && port == serverAtNum( - entry.getServerNum()).getPort()) - { + + if (ProviderMgr.namesAreEqual(name, serverAtNum( + entry.getServerNum()).getName()) + && port == serverAtNum(entry.getServerNum()) + .getPort()) { return serverAtNum(entry.getServerNum()); } } @@ -230,11 +234,14 @@ } return null; } - + /** - * @param zone name of DNS zone - * @param srvIP IPv4 address of server - * @param srvPort port on server + * @param zone + * name of DNS zone + * @param srvIP + * IPv4 address of server + * @param srvPort + * port on server * @return Server object with specified attributes */ Server getServerByIP(String zone, String ip, int port) { @@ -245,10 +252,10 @@ if (vect != null) { for (int i = 0; i < vect.size(); i++) { Entry entry = vect.elementAt(i); - - if (ip.equals(serverAtNum(entry.getServerNum()).getIP()) && - port == serverAtNum(entry.getServerNum()).getPort()) - { + + if (ip.equals(serverAtNum(entry.getServerNum()).getIP()) + && port == serverAtNum(entry.getServerNum()) + .getPort()) { return serverAtNum(entry.getServerNum()); } } @@ -258,27 +265,25 @@ } /** - * @param zone the name of DNS zone to query SLIST with - * @param server the server to compare with + * @param zone + * the name of DNS zone to query SLIST with + * @param server + * the server to compare with * @return first Server object from SLIST that equals to - * specified server in terms of equals() method; - * null if not found. + * specified server in terms of equals() method; + * null if not found. * @see SList.Server#equals(SList.Server) */ Server getServerByServer(String zone, Server server) { Vector vect; - + synchronized (zones) { vect = zones.get(ProviderMgr.normalizeName(zone)); - + if (vect != null) { for (int i = 0; i < vect.size(); i++) { Entry entry = vect.elementAt(i); - if (server.equals(serverAtNum(entry.getServerNum()))) { - ; - } - { return serverAtNum(entry.getServerNum()); } } @@ -286,7 +291,7 @@ } return null; } - + /** * Clears the SLIST. */ @@ -297,13 +302,13 @@ } // --- managing local list of servers --- - + // since the list of servers is add-only entity a write synchronization // should be enough - + /** * @return number of given server in the internal array of servers; add the - * server if not found + * server if not found */ private int getServerNum(Server server) { if (servers.contains(server)) { @@ -316,7 +321,8 @@ } /** - * @param num internal number of server + * @param num + * internal number of server * @return Server object found at specified index */ private Server serverAtNum(int num) { @@ -328,8 +334,9 @@ /** * Checks if given server is present in the internal list of known servers. - * - * @param hostname host name of server + * + * @param hostname + * host name of server * @return true or false */ boolean hasServer(String hostname) { @@ -339,43 +346,45 @@ /** * Returns all occurrences of server with specified - * @param name hostname + * + * @param name + * hostname * @return found server object or null if not found */ Enumeration getServersByName(String name) { Vector result = new Vector(); - + if (name == null) { // jndi.34=hostname is null throw new NullPointerException(Messages.getString("jndi.34")); //$NON-NLS-1$ } for (int i = 0; i < servers.size(); i++) { Server curServ = servers.get(i); - - if (curServ.getName() != null && - ProviderMgr.namesAreEqual(name, curServ.getName())) - { + + if (curServ.getName() != null + && ProviderMgr.namesAreEqual(name, curServ.getName())) { result.addElement(curServ); } } return result.elements(); } - + /** - * Add IP information of server in list. Affects only servers with IP set - * to null. - * @param hostname hostname of server - * @param newIP new IP + * Add IP information of server in list. Affects only servers with IP set to + * null. + * + * @param hostname + * hostname of server + * @param newIP + * new IP */ void setServerIP(String hostname, String newIP) { String nameNorm = ProviderMgr.normalizeName(hostname); - + for (int i = 0; i < servers.size(); i++) { SList.Server serv = servers.elementAt(i); - if (nameNorm.equals(serv.getName()) && - serv.getIP() == null) - { + if (nameNorm.equals(serv.getName()) && serv.getIP() == null) { serv.setIP(newIP); break; } @@ -383,19 +392,21 @@ } // --- additional classes --- - + /** - * Represents an SLIST entry. - * @author Alexei Zakharov + * Represents an SLIST entry. */ static class Entry { private String zoneName; + private int serverNum; + private int responseTime; /** * Creates new SLIST entry. + * * @param zoneName * @param server * @param respTime @@ -403,7 +414,7 @@ public Entry(String zoneName, int serverNum, int respTime) { this.zoneName = zoneName; this.serverNum = serverNum; - this.responseTime = respTime; + this.responseTime = respTime; } /** @@ -412,32 +423,40 @@ public int getResponseTime() { return responseTime; } + /** - * @param responseTime The responseTime to set. + * @param responseTime + * The responseTime to set. */ public void setResponseTime(int responseTime) { this.responseTime = responseTime; } + /** * @return Returns the server. */ public int getServerNum() { return serverNum; } + /** - * @param server The server to set. + * @param server + * The server to set. */ public void setServerNum(int serverNum) { this.serverNum = serverNum; } + /** * @return Returns the zoneName. */ public String getZoneName() { return zoneName; } + /** - * @param zoneName The zoneName to set. + * @param zoneName + * The zoneName to set. */ public void setZoneName(String zoneName) { this.zoneName = zoneName; @@ -446,20 +465,24 @@ /** * Represents a DNS server. - * @author Alexei Zakharov */ static class Server { private String serverName; + private String serverIP; + private int serverPort; /** * Constructs new Server object with given parameters. * - * @param serverName the name of the server - * @param serverIP IP address of the server - * @param serverPort a port number + * @param serverName + * the name of the server + * @param serverIP + * IP address of the server + * @param serverPort + * a port number */ public Server(String serverName, String serverIP, int serverPort) { this.serverName = ProviderMgr.normalizeName(serverName); @@ -469,8 +492,10 @@ /** * Returns true if two servers are equal, - * false otherwise. - * @param obj a Server object to compare with + * false otherwise. + * + * @param obj + * a Server object to compare with * @return true or false */ @Override @@ -485,46 +510,53 @@ if (this.getName() == null || srv.getName() == null) { return false; } - return ProviderMgr.namesAreEqual( - this.getName(), srv.getName()) && - this.getPort() == srv.getPort(); + return ProviderMgr.namesAreEqual(this.getName(), srv.getName()) + && this.getPort() == srv.getPort(); } - return this.getIP().equals(srv.getIP()) && - this.getPort() == srv.getPort(); + return this.getIP().equals(srv.getIP()) + && this.getPort() == srv.getPort(); } - + /** * @return Returns the serverIP. */ public String getIP() { return serverIP; } + /** * @return Returns the serverName. */ public String getName() { return serverName; } + /** * @return Returns the serverPort. */ public int getPort() { return serverPort; } + /** - * @param serverIP The serverIP to set. + * @param serverIP + * The serverIP to set. */ public void setIP(String serverIP) { this.serverIP = serverIP; } + /** - * @param serverName The serverName to set. + * @param serverName + * The serverName to set. */ public void setName(String serverName) { this.serverName = ProviderMgr.normalizeName(serverName); } + /** - * @param serverPort The serverPort to set. + * @param serverPort + * The serverPort to set. */ public void setPort(int serverPort) { this.serverPort = serverPort; @@ -533,7 +565,7 @@ @Override public String toString() { if (this.serverName != null) { - return serverName + ":" + serverPort; //$NON-NLS-1$ + return serverName + ":" + serverPort; //$NON-NLS-1$ } return serverIP + ":" + serverPort; //$NON-NLS-1$ } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/TransportMgr.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/TransportMgr.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/TransportMgr.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/TransportMgr.java Sat Jun 23 13:53:42 2007 @@ -36,76 +36,74 @@ import org.apache.harmony.jndi.internal.nls.Messages; /** - * Contains service methods that are used for transporting DNS messages from - * DNS client to DNS server and vice versa. - * @author Alexei Zakharov - * @version $Revision: 1.1.2.4 $ + * Contains service methods that are used for transporting DNS messages from DNS + * client to DNS server and vice versa. */ public class TransportMgr { /** - * Sends the packet contained in outBuf, receives - * the answer and stores it in inBuf array. + * Sends the packet contained in outBuf, receives the answer + * and stores it in inBuf array. * - * @param server server's IP-address in string form - * @param serverPort server port - * @param outBuf bytes of the message to send - * @param outBufLen length of the outBuf - * @param inBuf buffer to store received bytes at - * @param inBufLen length of the inBuf - * @param timeout time to wait for an answer, in milliseconds; - * 0 stands for infinite timeout + * @param server + * server's IP-address in string form + * @param serverPort + * server port + * @param outBuf + * bytes of the message to send + * @param outBufLen + * length of the outBuf + * @param inBuf + * buffer to store received bytes at + * @param inBufLen + * length of the inBuf + * @param timeout + * time to wait for an answer, in milliseconds; 0 stands for + * infinite timeout * @return number of received bytes - * @throws SocketTimeoutException in case of timeout - * @throws SecurityException if security violation error occured; normally - * this happens if the access to the network subsystem has not been granted - * @throws DomainProtocolException if some configuration or network - * problem encountered + * @throws SocketTimeoutException + * in case of timeout + * @throws SecurityException + * if security violation error occured; normally this happens if + * the access to the network subsystem has not been granted + * @throws DomainProtocolException + * if some configuration or network problem encountered */ - public static int sendReceiveUDP(String server, - int serverPort, - byte[] outBuf, - int outBufLen, - byte[] inBuf, - int inBufLen, - int timeout) - throws DomainProtocolException, - SocketTimeoutException, - SecurityException - { + public static int sendReceiveUDP(String server, int serverPort, + byte[] outBuf, int outBufLen, byte[] inBuf, int inBufLen, + int timeout) throws DomainProtocolException, + SocketTimeoutException, SecurityException { + byte srvAddrArr[] = null; InetAddress srvAddr = null; DatagramSocket dSocket = null; DatagramPacket inPacket = null; DatagramPacket outPacket = null; - + try { srvAddrArr = ProviderMgr.parseIpStr(server); } catch (IllegalArgumentException e) { // jndi.40=Unable to connect: bad IP address - throw new DomainProtocolException( - Messages.getString("jndi.40")); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.40")); //$NON-NLS-1$ } try { dSocket = new DatagramSocket(); srvAddr = InetAddress.getByAddress(srvAddrArr); dSocket.connect(srvAddr, serverPort); - outPacket = new DatagramPacket( - outBuf, outBufLen, srvAddr, serverPort); + outPacket = new DatagramPacket(outBuf, outBufLen, srvAddr, + serverPort); dSocket.setSoTimeout(timeout); dSocket.send(outPacket); inPacket = new DatagramPacket(inBuf, inBufLen, srvAddr, serverPort); dSocket.receive(inPacket); } catch (IllegalStateException e) { // jndi.41=Error while querying DNS server - throw new DomainProtocolException( - Messages.getString("jndi.41"), e); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.41"), e); //$NON-NLS-1$ } catch (SocketTimeoutException e) { throw (e); } catch (IOException e) { // jndi.41=Error while querying DNS server - throw new DomainProtocolException( - Messages.getString("jndi.41"), e); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.41"), e); //$NON-NLS-1$ } finally { if (dSocket != null) { dSocket.close(); @@ -122,33 +120,36 @@ * Establishes TCP connection, transmit bytes from inBuf, * stores received answer in outBuf. * - * @param server the server's IP-address in string form - * @param serverPort server port - * @param outBuf bytes of the message to send - * @param outBufLen length of the outBuf - * @param inBuf buffer to store received bytes at - * @param inBufLen length of the inBuf - * @param timeout time to wait for an answer, in milliseconds; - * 0 stands for infinite timeout + * @param server + * the server's IP-address in string form + * @param serverPort + * server port + * @param outBuf + * bytes of the message to send + * @param outBufLen + * length of the outBuf + * @param inBuf + * buffer to store received bytes at + * @param inBufLen + * length of the inBuf + * @param timeout + * time to wait for an answer, in milliseconds; 0 stands for + * infinite timeout * @return number of received bytes - * @throws SocketTimeoutException in case of timeout - * @throws SecurityException if security violation error occured; normally - * this happens if the access to the network subsystem has not been granted - * @throws DomainProtocolException if some configuration or network - * problem encountered - * TODO pool of connections may speed up things + * @throws SocketTimeoutException + * in case of timeout + * @throws SecurityException + * if security violation error occured; normally this happens if + * the access to the network subsystem has not been granted + * @throws DomainProtocolException + * if some configuration or network problem encountered TODO + * pool of connections may speed up things */ - public static int sendReceiveTCP(String server, - int serverPort, - byte[] outBuf, - int outBufLen, - byte[] inBuf, - int inBufLen, - int timeout) - throws DomainProtocolException, - SocketTimeoutException, - SecurityException - { + public static int sendReceiveTCP(String server, int serverPort, + byte[] outBuf, int outBufLen, byte[] inBuf, int inBufLen, + int timeout) throws DomainProtocolException, + SocketTimeoutException, SecurityException { + byte srvAddrArr[] = null; InetAddress srvAddr = null; Socket socket = null; @@ -162,8 +163,7 @@ srvAddrArr = ProviderMgr.parseIpStr(server); } catch (IllegalArgumentException e) { // jndi.40=Unable to connect: bad IP address - throw new DomainProtocolException( - Messages.getString("jndi.40")); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.40")); //$NON-NLS-1$ } try { srvAddr = InetAddress.getByAddress(srvAddrArr); @@ -184,24 +184,22 @@ actualLen = iStream.read(inBuf, 0, inLen); if (actualLen != inLen) { // jndi.44=Error while receiving message over TCP - throw new DomainProtocolException( - Messages.getString("jndi.44")); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.44")); //$NON-NLS-1$ } } catch (IllegalStateException e) { // jndi.41=Error while querying DNS server - throw new DomainProtocolException( - Messages.getString("jndi.41"), e); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.41"), e); //$NON-NLS-1$ } catch (SocketTimeoutException e) { throw (e); } catch (IOException e) { // jndi.41=Error while querying DNS server - throw new DomainProtocolException( - Messages.getString("jndi.41"), e); //$NON-NLS-1$ + throw new DomainProtocolException(Messages.getString("jndi.41"), e); //$NON-NLS-1$ } finally { if (socket != null && !socket.isClosed()) { try { socket.close(); - } catch (IOException e) {} + } catch (IOException e) { + } } } return actualLen; @@ -210,6 +208,7 @@ /** * Tries to determine IP address by hostname using * Inet4Address.getByName(String) method. + * * @return determined address or null if not found * @see java.net.InetAddress#getByName(String) */ @@ -223,4 +222,5 @@ } return addr; } + } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContext.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContext.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/dnsURLContext.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContext.java Sat Jun 23 13:53:42 2007 @@ -37,80 +37,97 @@ /** * DNS context that is capable of serving requests with DNS URL's given as * names. - * - * @author Alexei Zakharov - * @version $Revision: 1.1.2.4 $ */ public class dnsURLContext extends DNSContext { /** * Constructs new DNS URL context. - * @param env environment - * @throws NamingException if such exception was encountered + * + * @param env + * environment + * @throws NamingException + * if such exception was encountered */ public dnsURLContext(Hashtable env) throws NamingException { super(env); } /** - * @param name well formed DNS URL that points to some context - * @param attrNames array of attribute identifiers + * @param name + * well formed DNS URL that points to some context + * @param attrNames + * array of attribute identifiers * @return collection of attributes - * @throws NamingException if such exception was encountered - * @throws NullPointerException if name is null + * @throws NamingException + * if such exception was encountered + * @throws NullPointerException + * if name is null * @see DNSContext#getAttributes(String, String[]) */ @Override public Attributes getAttributes(String name, String[] attrNames) - throws NamingException - { + throws NamingException { process(name); return super.getAttributes(new DNSName(), attrNames); } - + /** - * @param name well formed DNS URL + * @param name + * well formed DNS URL * @return retrieved collection of attributes - * @throws NamingException if such exception was encountered - * @throws NullPointerException if name is null - * @see DNSContext#getAttributes(String) + * @throws NamingException + * if such exception was encountered + * @throws NullPointerException + * if name is null + * @see DNSContext#getAttributes(String) */ @Override public Attributes getAttributes(String name) throws NamingException { return getAttributes(name, null); } - + /** - * @param name well formed DNS URL - * @return collection of NameClassPair - * @throws NamingException if such exception was encountered - * @throws NullPointerException if name is null + * @param name + * well formed DNS URL + * @return collection of NameClassPair + * @throws NamingException + * if such exception was encountered + * @throws NullPointerException + * if name is null * @see DNSContext#list(String) */ @Override - public NamingEnumeration list(String name) throws NamingException { + public NamingEnumeration list(String name) + throws NamingException { process(name); return super.list(new DNSName()); } /** - * @param name well formed DNS URL - * @return collection of Binding - * @throws NamingException if such exception was encountered - * @throws NullPointerException if name is null + * @param name + * well formed DNS URL + * @return collection of Binding + * @throws NamingException + * if such exception was encountered + * @throws NullPointerException + * if name is null * @see DNSContext#listBindings(String) */ @Override - public NamingEnumeration listBindings(String name) throws NamingException { + public NamingEnumeration listBindings(String name) + throws NamingException { process(name); return super.listBindings(new DNSName()); } /** - * @param name well formed DNS URL + * @param name + * well formed DNS URL * @return found object - * @throws NamingException if such exception was encountered - * @throws NullPointerException if name is null + * @throws NamingException + * if such exception was encountered + * @throws NullPointerException + * if name is null * @see DNSContext#lookup(String) */ @Override @@ -120,10 +137,13 @@ } /** - * @param name well formed DNS URL + * @param name + * well formed DNS URL * @return found object - * @throws NamingException if such exception was encountered - * @throws NullPointerException if name is null + * @throws NamingException + * if such exception was encountered + * @throws NullPointerException + * if name is null * @see DNSContext#lookupLink(String) */ @Override @@ -133,9 +153,13 @@ /** * Service method - * @param name DNS URL - * @throws NamingException if was encountered - * @throws NullPointerException if name is null + * + * @param name + * DNS URL + * @throws NamingException + * if was encountered + * @throws NullPointerException + * if name is null */ private void process(String name) throws NamingException { if (name == null) { @@ -144,4 +168,5 @@ } addToEnvironment(Context.PROVIDER_URL, name); } + } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContextFactory.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContextFactory.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/dnsURLContextFactory.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContextFactory.java Sat Jun 23 13:53:42 2007 @@ -32,40 +32,45 @@ import org.apache.harmony.jndi.internal.nls.Messages; - /** * Factory to create DNS URL contexts. - * @author Alexei Zakharov - * @version $Revision: 1.1.2.4 $ */ public class dnsURLContextFactory implements ObjectFactory { - + /** * Returns new instance of DNS URL context. - * @param obj either null, URL in string form or array - * of URL in string form - * @param name ignored - * @param nameCtx ignored - * @param environment is passed to the context being created + * + * @param obj + * either null, URL in string form or array of + * URL in string form + * @param name + * ignored + * @param nameCtx + * ignored + * @param environment + * is passed to the context being created * @return created DNS context, an instance of either - * dnsURLContext or DNSContext class - * @throws IllegalArgumentException if bad obj is given - * @throws NamingException if such exception was encountered + * dnsURLContext or DNSContext class + * @throws IllegalArgumentException + * if bad obj is given + * @throws NamingException + * if such exception was encountered * @see ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable) */ - @SuppressWarnings("unchecked") //$NON-NLS-1$ + @SuppressWarnings("unchecked") public Object getObjectInstance(Object obj, Name name, Context nameCtx, - Hashtable environment) throws NamingException - { + Hashtable environment) throws NamingException { if (obj == null) { return new dnsURLContext(environment); } else if (obj instanceof String) { - Hashtable newEnv = (Hashtable) environment.clone(); + Hashtable newEnv = (Hashtable) environment + .clone(); newEnv.put(Context.PROVIDER_URL, obj); return new DNSContext(newEnv); } else if (obj instanceof String[]) { - Hashtable newEnv = (Hashtable) environment.clone(); + Hashtable newEnv = (Hashtable) environment + .clone(); StringBuffer sb = new StringBuffer(); String urlArr[] = (String[]) obj; Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/AtomicNameParser.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/AtomicNameParser.java?view=diff&rev=550106&r1=550105&r2=550106 ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/AtomicNameParser.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/AtomicNameParser.java Sat Jun 23 13:53:42 2007 @@ -20,6 +20,7 @@ * @author Vasily Zakharov * @version $Revision: 1.1.2.3 $ */ + package org.apache.harmony.jndi.provider.rmi.registry; import java.util.Properties; @@ -29,18 +30,14 @@ import javax.naming.NameParser; import javax.naming.NamingException; - /** * Parser for flat case-sensitive atomic names used by {@link RegistryContext}. - * - * @author Vasily Zakharov - * @version $Revision: 1.1.2.3 $ */ public class AtomicNameParser implements NameParser { /** - * Syntax, defines a flat case-sensitive context, - * initialized in static initialization block. + * Syntax, defines a flat case-sensitive context, initialized in static + * initialization block. */ private static final Properties syntax = new Properties(); @@ -54,20 +51,22 @@ /** * Creates instance of this class. */ - public AtomicNameParser() {} + public AtomicNameParser() { + } /** * Returns flat {@link CompoundName} constructed from the specified string. - * - * @param name - * Name to parse, cannot be null. - * - * @return Flat {@link CompoundName} constructed from the specified string. - * - * @throws NamingException - * If some error occured. + * + * @param name + * Name to parse, cannot be null. + * + * @return Flat {@link CompoundName} constructed from the specified string. + * + * @throws NamingException + * If some error occured. */ public Name parse(String name) throws NamingException { return new CompoundName(name, syntax); } + } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/BindingEnumeration.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/BindingEnumeration.java?view=diff&rev=550106&r1=550105&r2=550106 ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/BindingEnumeration.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/BindingEnumeration.java Sat Jun 23 13:53:42 2007 @@ -20,6 +20,7 @@ * @author Vasily Zakharov * @version $Revision: 1.1.2.2 $ */ + package org.apache.harmony.jndi.provider.rmi.registry; import java.rmi.registry.Registry; @@ -34,9 +35,6 @@ /** * Enumeration of {@link Binding} objects, used by * {@link RegistryContext#listBindings(Name)} method. - * - * @author Vasily Zakharov - * @version $Revision: 1.1.2.2 $ */ class BindingEnumeration implements NamingEnumeration { @@ -58,9 +56,11 @@ /** * Creates this enumeration. * - * @param names Binding names returned from {@link Registry#list()} method. + * @param names + * Binding names returned from {@link Registry#list()} method. * - * @param context RegistryContext to extract bindings from. + * @param context + * RegistryContext to extract bindings from. */ public BindingEnumeration(String[] names, RegistryContext context) { super(); @@ -95,7 +95,8 @@ try { return next(); } catch (NamingException e) { - throw (NoSuchElementException) new NoSuchElementException().initCause(e); + throw (NoSuchElementException) new NoSuchElementException() + .initCause(e); } } @@ -103,4 +104,5 @@ index = names.length; context.close(); } + } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/NameClassPairEnumeration.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/NameClassPairEnumeration.java?view=diff&rev=550106&r1=550105&r2=550106 ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/NameClassPairEnumeration.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/NameClassPairEnumeration.java Sat Jun 23 13:53:42 2007 @@ -20,6 +20,7 @@ * @author Vasily Zakharov * @version $Revision: 1.1.2.2 $ */ + package org.apache.harmony.jndi.provider.rmi.registry; import java.rmi.registry.Registry; @@ -34,9 +35,6 @@ /** * Enumeration of {@link NameClassPair} objects, used by * {@link RegistryContext#list(Name)} method. - * - * @author Vasily Zakharov - * @version $Revision: 1.1.2.2 $ */ class NameClassPairEnumeration implements NamingEnumeration { @@ -53,7 +51,8 @@ /** * Creates this enumeration. * - * @param names Binding names returned from {@link Registry#list()} method. + * @param names + * Binding names returned from {@link Registry#list()} method. */ public NameClassPairEnumeration(String[] names) { this.names = names; @@ -82,11 +81,13 @@ try { return next(); } catch (NamingException e) { - throw (NoSuchElementException) new NoSuchElementException().initCause(e); + throw (NoSuchElementException) new NoSuchElementException() + .initCause(e); } } public void close() { index = names.length; } + }