From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../javax/naming/AuthenticationException.java | 55 ++ .../AuthenticationNotSupportedException.java | 56 ++ libjava/classpath/javax/naming/BinaryRefAddr.java | 158 +++++ libjava/classpath/javax/naming/Binding.java | 164 +++++ .../javax/naming/CannotProceedException.java | 107 ++++ .../javax/naming/CommunicationException.java | 55 ++ libjava/classpath/javax/naming/CompositeName.java | 343 +++++++++++ libjava/classpath/javax/naming/CompoundName.java | 523 ++++++++++++++++ .../javax/naming/ConfigurationException.java | 55 ++ libjava/classpath/javax/naming/Context.java | 492 +++++++++++++++ .../javax/naming/ContextNotEmptyException.java | 60 ++ libjava/classpath/javax/naming/InitialContext.java | 548 +++++++++++++++++ .../naming/InsufficientResourcesException.java | 55 ++ .../javax/naming/InterruptedNamingException.java | 55 ++ .../javax/naming/InvalidNameException.java | 68 +++ .../javax/naming/LimitExceededException.java | 55 ++ libjava/classpath/javax/naming/LinkException.java | 119 ++++ .../classpath/javax/naming/LinkLoopException.java | 55 ++ libjava/classpath/javax/naming/LinkRef.java | 67 ++ .../javax/naming/MalformedLinkException.java | 55 ++ libjava/classpath/javax/naming/Name.java | 206 +++++++ .../javax/naming/NameAlreadyBoundException.java | 55 ++ libjava/classpath/javax/naming/NameClassPair.java | 198 ++++++ .../javax/naming/NameNotFoundException.java | 55 ++ libjava/classpath/javax/naming/NameParser.java | 60 ++ .../classpath/javax/naming/NamingEnumeration.java | 89 +++ .../classpath/javax/naming/NamingException.java | 316 ++++++++++ .../javax/naming/NamingSecurityException.java | 55 ++ .../javax/naming/NoInitialContextException.java | 55 ++ .../javax/naming/NoPermissionException.java | 55 ++ .../javax/naming/NotContextException.java | 55 ++ .../naming/OperationNotSupportedException.java | 54 ++ .../javax/naming/PartialResultException.java | 59 ++ libjava/classpath/javax/naming/RefAddr.java | 142 +++++ libjava/classpath/javax/naming/Reference.java | 306 ++++++++++ libjava/classpath/javax/naming/Referenceable.java | 56 ++ .../classpath/javax/naming/ReferralException.java | 68 +++ .../javax/naming/ServiceUnavailableException.java | 55 ++ .../javax/naming/SizeLimitExceededException.java | 60 ++ libjava/classpath/javax/naming/StringRefAddr.java | 75 +++ .../javax/naming/TimeLimitExceededException.java | 55 ++ .../javax/naming/directory/Attribute.java | 70 +++ .../naming/directory/AttributeInUseException.java | 56 ++ .../directory/AttributeModificationException.java | 78 +++ .../javax/naming/directory/Attributes.java | 61 ++ .../javax/naming/directory/BasicAttribute.java | 358 +++++++++++ .../javax/naming/directory/BasicAttributes.java | 284 +++++++++ .../javax/naming/directory/DirContext.java | 103 ++++ .../javax/naming/directory/InitialDirContext.java | 272 +++++++++ .../InvalidAttributeIdentifierException.java | 56 ++ .../directory/InvalidAttributeValueException.java | 56 ++ .../directory/InvalidAttributesException.java | 56 ++ .../directory/InvalidSearchControlsException.java | 56 ++ .../directory/InvalidSearchFilterException.java | 56 ++ .../javax/naming/directory/ModificationItem.java | 81 +++ .../naming/directory/NoSuchAttributeException.java | 56 ++ .../naming/directory/SchemaViolationException.java | 56 ++ .../javax/naming/directory/SearchControls.java | 138 +++++ .../javax/naming/directory/SearchResult.java | 95 +++ .../classpath/javax/naming/directory/package.html | 46 ++ .../classpath/javax/naming/event/EventContext.java | 65 ++ .../javax/naming/event/EventDirContext.java | 65 ++ .../naming/event/NamespaceChangeListener.java | 51 ++ .../classpath/javax/naming/event/NamingEvent.java | 122 ++++ .../javax/naming/event/NamingExceptionEvent.java | 77 +++ .../javax/naming/event/NamingListener.java | 51 ++ .../javax/naming/event/ObjectChangeListener.java | 49 ++ libjava/classpath/javax/naming/event/package.html | 46 ++ libjava/classpath/javax/naming/ldap/Control.java | 56 ++ .../javax/naming/ldap/ControlFactory.java | 107 ++++ .../javax/naming/ldap/ExtendedRequest.java | 57 ++ .../javax/naming/ldap/ExtendedResponse.java | 52 ++ .../classpath/javax/naming/ldap/HasControls.java | 51 ++ .../javax/naming/ldap/InitialLdapContext.java | 135 +++++ .../classpath/javax/naming/ldap/LdapContext.java | 63 ++ .../javax/naming/ldap/LdapReferralException.java | 69 +++ .../javax/naming/ldap/StartTlsRequest.java | 108 ++++ .../javax/naming/ldap/StartTlsResponse.java | 119 ++++ .../javax/naming/ldap/UnsolicitedNotification.java | 52 ++ .../naming/ldap/UnsolicitedNotificationEvent.java | 70 +++ .../ldap/UnsolicitedNotificationListener.java | 51 ++ libjava/classpath/javax/naming/ldap/package.html | 46 ++ libjava/classpath/javax/naming/package.html | 46 ++ .../javax/naming/spi/DirObjectFactory.java | 56 ++ .../javax/naming/spi/DirStateFactory.java | 83 +++ .../javax/naming/spi/DirectoryManager.java | 243 ++++++++ .../javax/naming/spi/InitialContextFactory.java | 71 +++ .../naming/spi/InitialContextFactoryBuilder.java | 66 ++ .../classpath/javax/naming/spi/NamingManager.java | 671 +++++++++++++++++++++ .../classpath/javax/naming/spi/ObjectFactory.java | 76 +++ .../javax/naming/spi/ObjectFactoryBuilder.java | 70 +++ .../classpath/javax/naming/spi/ResolveResult.java | 182 ++++++ libjava/classpath/javax/naming/spi/Resolver.java | 62 ++ .../classpath/javax/naming/spi/StateFactory.java | 79 +++ libjava/classpath/javax/naming/spi/package.html | 46 ++ 95 files changed, 10621 insertions(+) create mode 100644 libjava/classpath/javax/naming/AuthenticationException.java create mode 100644 libjava/classpath/javax/naming/AuthenticationNotSupportedException.java create mode 100644 libjava/classpath/javax/naming/BinaryRefAddr.java create mode 100644 libjava/classpath/javax/naming/Binding.java create mode 100644 libjava/classpath/javax/naming/CannotProceedException.java create mode 100644 libjava/classpath/javax/naming/CommunicationException.java create mode 100644 libjava/classpath/javax/naming/CompositeName.java create mode 100644 libjava/classpath/javax/naming/CompoundName.java create mode 100644 libjava/classpath/javax/naming/ConfigurationException.java create mode 100644 libjava/classpath/javax/naming/Context.java create mode 100644 libjava/classpath/javax/naming/ContextNotEmptyException.java create mode 100644 libjava/classpath/javax/naming/InitialContext.java create mode 100644 libjava/classpath/javax/naming/InsufficientResourcesException.java create mode 100644 libjava/classpath/javax/naming/InterruptedNamingException.java create mode 100644 libjava/classpath/javax/naming/InvalidNameException.java create mode 100644 libjava/classpath/javax/naming/LimitExceededException.java create mode 100644 libjava/classpath/javax/naming/LinkException.java create mode 100644 libjava/classpath/javax/naming/LinkLoopException.java create mode 100644 libjava/classpath/javax/naming/LinkRef.java create mode 100644 libjava/classpath/javax/naming/MalformedLinkException.java create mode 100644 libjava/classpath/javax/naming/Name.java create mode 100644 libjava/classpath/javax/naming/NameAlreadyBoundException.java create mode 100644 libjava/classpath/javax/naming/NameClassPair.java create mode 100644 libjava/classpath/javax/naming/NameNotFoundException.java create mode 100644 libjava/classpath/javax/naming/NameParser.java create mode 100644 libjava/classpath/javax/naming/NamingEnumeration.java create mode 100644 libjava/classpath/javax/naming/NamingException.java create mode 100644 libjava/classpath/javax/naming/NamingSecurityException.java create mode 100644 libjava/classpath/javax/naming/NoInitialContextException.java create mode 100644 libjava/classpath/javax/naming/NoPermissionException.java create mode 100644 libjava/classpath/javax/naming/NotContextException.java create mode 100644 libjava/classpath/javax/naming/OperationNotSupportedException.java create mode 100644 libjava/classpath/javax/naming/PartialResultException.java create mode 100644 libjava/classpath/javax/naming/RefAddr.java create mode 100644 libjava/classpath/javax/naming/Reference.java create mode 100644 libjava/classpath/javax/naming/Referenceable.java create mode 100644 libjava/classpath/javax/naming/ReferralException.java create mode 100644 libjava/classpath/javax/naming/ServiceUnavailableException.java create mode 100644 libjava/classpath/javax/naming/SizeLimitExceededException.java create mode 100644 libjava/classpath/javax/naming/StringRefAddr.java create mode 100644 libjava/classpath/javax/naming/TimeLimitExceededException.java create mode 100644 libjava/classpath/javax/naming/directory/Attribute.java create mode 100644 libjava/classpath/javax/naming/directory/AttributeInUseException.java create mode 100644 libjava/classpath/javax/naming/directory/AttributeModificationException.java create mode 100644 libjava/classpath/javax/naming/directory/Attributes.java create mode 100644 libjava/classpath/javax/naming/directory/BasicAttribute.java create mode 100644 libjava/classpath/javax/naming/directory/BasicAttributes.java create mode 100644 libjava/classpath/javax/naming/directory/DirContext.java create mode 100644 libjava/classpath/javax/naming/directory/InitialDirContext.java create mode 100644 libjava/classpath/javax/naming/directory/InvalidAttributeIdentifierException.java create mode 100644 libjava/classpath/javax/naming/directory/InvalidAttributeValueException.java create mode 100644 libjava/classpath/javax/naming/directory/InvalidAttributesException.java create mode 100644 libjava/classpath/javax/naming/directory/InvalidSearchControlsException.java create mode 100644 libjava/classpath/javax/naming/directory/InvalidSearchFilterException.java create mode 100644 libjava/classpath/javax/naming/directory/ModificationItem.java create mode 100644 libjava/classpath/javax/naming/directory/NoSuchAttributeException.java create mode 100644 libjava/classpath/javax/naming/directory/SchemaViolationException.java create mode 100644 libjava/classpath/javax/naming/directory/SearchControls.java create mode 100644 libjava/classpath/javax/naming/directory/SearchResult.java create mode 100644 libjava/classpath/javax/naming/directory/package.html create mode 100644 libjava/classpath/javax/naming/event/EventContext.java create mode 100644 libjava/classpath/javax/naming/event/EventDirContext.java create mode 100644 libjava/classpath/javax/naming/event/NamespaceChangeListener.java create mode 100644 libjava/classpath/javax/naming/event/NamingEvent.java create mode 100644 libjava/classpath/javax/naming/event/NamingExceptionEvent.java create mode 100644 libjava/classpath/javax/naming/event/NamingListener.java create mode 100644 libjava/classpath/javax/naming/event/ObjectChangeListener.java create mode 100644 libjava/classpath/javax/naming/event/package.html create mode 100644 libjava/classpath/javax/naming/ldap/Control.java create mode 100644 libjava/classpath/javax/naming/ldap/ControlFactory.java create mode 100644 libjava/classpath/javax/naming/ldap/ExtendedRequest.java create mode 100644 libjava/classpath/javax/naming/ldap/ExtendedResponse.java create mode 100644 libjava/classpath/javax/naming/ldap/HasControls.java create mode 100644 libjava/classpath/javax/naming/ldap/InitialLdapContext.java create mode 100644 libjava/classpath/javax/naming/ldap/LdapContext.java create mode 100644 libjava/classpath/javax/naming/ldap/LdapReferralException.java create mode 100644 libjava/classpath/javax/naming/ldap/StartTlsRequest.java create mode 100644 libjava/classpath/javax/naming/ldap/StartTlsResponse.java create mode 100644 libjava/classpath/javax/naming/ldap/UnsolicitedNotification.java create mode 100644 libjava/classpath/javax/naming/ldap/UnsolicitedNotificationEvent.java create mode 100644 libjava/classpath/javax/naming/ldap/UnsolicitedNotificationListener.java create mode 100644 libjava/classpath/javax/naming/ldap/package.html create mode 100644 libjava/classpath/javax/naming/package.html create mode 100644 libjava/classpath/javax/naming/spi/DirObjectFactory.java create mode 100644 libjava/classpath/javax/naming/spi/DirStateFactory.java create mode 100644 libjava/classpath/javax/naming/spi/DirectoryManager.java create mode 100644 libjava/classpath/javax/naming/spi/InitialContextFactory.java create mode 100644 libjava/classpath/javax/naming/spi/InitialContextFactoryBuilder.java create mode 100644 libjava/classpath/javax/naming/spi/NamingManager.java create mode 100644 libjava/classpath/javax/naming/spi/ObjectFactory.java create mode 100644 libjava/classpath/javax/naming/spi/ObjectFactoryBuilder.java create mode 100644 libjava/classpath/javax/naming/spi/ResolveResult.java create mode 100644 libjava/classpath/javax/naming/spi/Resolver.java create mode 100644 libjava/classpath/javax/naming/spi/StateFactory.java create mode 100644 libjava/classpath/javax/naming/spi/package.html (limited to 'libjava/classpath/javax/naming') diff --git a/libjava/classpath/javax/naming/AuthenticationException.java b/libjava/classpath/javax/naming/AuthenticationException.java new file mode 100644 index 000000000..36310d3ad --- /dev/null +++ b/libjava/classpath/javax/naming/AuthenticationException.java @@ -0,0 +1,55 @@ +/* AuthenticationException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class AuthenticationException extends NamingSecurityException +{ + private static final long serialVersionUID = 3678497619904568096L; + + public AuthenticationException () + { + super (); + } + + public AuthenticationException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/AuthenticationNotSupportedException.java b/libjava/classpath/javax/naming/AuthenticationNotSupportedException.java new file mode 100644 index 000000000..9ebda40bb --- /dev/null +++ b/libjava/classpath/javax/naming/AuthenticationNotSupportedException.java @@ -0,0 +1,56 @@ +/* AuthenticationNotSupportedException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class AuthenticationNotSupportedException + extends NamingSecurityException +{ + private static final long serialVersionUID = - 7149033933259492300L; + + public AuthenticationNotSupportedException () + { + super (); + } + + public AuthenticationNotSupportedException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/BinaryRefAddr.java b/libjava/classpath/javax/naming/BinaryRefAddr.java new file mode 100644 index 000000000..373802a8c --- /dev/null +++ b/libjava/classpath/javax/naming/BinaryRefAddr.java @@ -0,0 +1,158 @@ +/* BinaryRefAddr.java -- RefAddr that uses a byte array as content. + Copyright (C) 2001 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.naming; + +import gnu.java.lang.CPStringBuilder; + +import java.util.Arrays; + +/** + * RefAddr that uses a byte array as content. + * This can be used to reference objects that can only be represented as + * byte arrays. + * + * @see Reference + * @since 1.3 + * @author Mark Wielaard (mark@klomp.org) + */ +public class BinaryRefAddr extends RefAddr +{ + static final long serialVersionUID = -3415254970957330361L; + + /** + * The possibly null content of this RefAddr. + * Set by the constructor and returned by getContent. + */ + private final byte[] buf; + + /** + * Contructs a new BinaryRefAddr with the given type and content. + * The complete content of the byte array is copied to a new array. + */ + public BinaryRefAddr (String addrType, byte[] buf) + { + this(addrType, buf, 0, buf.length); + } + + /** + * Contructs a new BinaryRefAddr with the given type and the content + * taken from the given byte array. + * The content of the byte array is copied to a new array. + */ + public BinaryRefAddr (String addrType, byte[] buf, int off, int length) + { + super(addrType); + this.buf = new byte[length]; + System.arraycopy(buf, off, this.buf, 0, length); + } + + /** + * Returns the byte array contents as given to the constructor. + * The returned byte array is shared with this object and other callers. + * Changing the content of the buffer is discouraged and should only be + * done when the byte array is locked. + */ + public Object getContent () + { + return buf; + } + + /** + * Checks if the object is a BinaryRefAddr with the same type and with the + * same bytes in the content. + * + * @return true if the given object is an instance of BinaryRefAddr, + * the addrType is the same as this addrType and the bytes of the + * content are the same. + */ + public boolean equals(Object o) + { + if (o instanceof BinaryRefAddr) + { + BinaryRefAddr refAddr = (BinaryRefAddr) o; + if (this.getType().equals(refAddr.getType())) + { + byte[] c1 = (byte[]) this.getContent(); + byte[] c2 = (byte[]) refAddr.getContent(); + return Arrays.equals(c1, c2); + } + } + return false; + } + + /** + * Returns the hashCode which is the hasCode of the String returned by + * getType() plus the hashCode of the byte array returned by + * getContent. The hashCode of the byte array is calculated + * by taking the xor of all the bytes in the array, or zero when there are + * no bytes in the array. + */ + public int hashCode() + { + int result = 0; + byte[] b = (byte[]) getContent(); + for (int i=0; i < b.length; i++) + result = result^b[i]; + + return getType().hashCode() + result; + } + + private static char[] hex = {'0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + /** + * Returns a String representation of the RefAddr. Only the first 32 bytes + * of the content are added as hex encoded characters. + * Should only be used for debugging purposes. + */ + public String toString() + { + CPStringBuilder sb = new CPStringBuilder("[RefAddr type: "); + sb.append(getType()); + sb.append(" content: 0x"); + byte[] b = (byte[]) getContent(); + for (int i=0; i < b.length && i < 32; i++) + { + sb.append(hex[(b[i]&0xf0)>>4]); + sb.append(hex[b[i]&0x0f]); + } + if (b.length > 32) + sb.append("..."); + sb.append("]"); + return sb.toString(); + } +} diff --git a/libjava/classpath/javax/naming/Binding.java b/libjava/classpath/javax/naming/Binding.java new file mode 100644 index 000000000..23bb4592e --- /dev/null +++ b/libjava/classpath/javax/naming/Binding.java @@ -0,0 +1,164 @@ +/* Binding.java -- + Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +/** + * Binding represents the name-object mapping of a + * binding in a context. + *

+ * Bindings are mappings of a name to an object and this class is used to + * specify such mappings. The bindings of a context are retrieved by the + * Context#listBindings() methods. + *

+ * + * @author Tom Tromey (tromey@redhat.com) + * @since 1.3 + */ +public class Binding extends NameClassPair +{ + private static final long serialVersionUID = 8839217842691845890L; + + /** + * Constructs an instance with the given name and object. + * + * @param name the name of the binding relative to the target context + * (may not be null) + * @param obj the bound object + */ + public Binding (String name, Object obj) + { + super (name, null); + boundObj = obj; + } + + /** + * Constructs an instance with the given name and object and a + * flag indicating if the name is relative to the target context. + * + * @param name the name of the binding relative to the target context + * (may not be null) + * @param obj the bound object + * @param isRelative flag indicating if the name is relative or not + */ + public Binding (String name, Object obj, boolean isRelative) + { + super (name, null, isRelative); + boundObj = obj; + } + + /** + * Constructs an instance with the given name, classname and object. + * + * @param name the name of the binding relative to the target context + * (may not be null) + * @param className the classname to set (maybe null) + * @param obj the bound object + */ + public Binding (String name, String className, Object obj) + { + super (name, className); + boundObj = obj; + } + + /** + * Constructs an instance with the given name, classname, object and a + * flag indicating if the name is relative to the target context. + * + * @param name the name of the binding relative to the target context + * (may not be null) + * @param className the classname to set (maybe null) + * @param isRelative flag indicating if the name is relative or not + * @param obj the bound object + */ + public Binding (String name, String className, Object obj, + boolean isRelative) + { + super (name, className, isRelative); + boundObj = obj; + } + + /** + * Returns the classname of the bound object. + *

+ * Returns the classname if set explicitly. If not and the bound object is + * not null the classname of the bound object is used. + *

+ * + * @return The fully qualified classname (may be null). + */ + public String getClassName () + { + String r = super.getClassName (); + if (r != null) + return r; + return boundObj == null ? null : boundObj.getClass ().getName (); + } + + /** + * Returns the bound object of this binding. + * @return The bound object (maybe null). + */ + public Object getObject () + { + return boundObj; + } + + /** + * Sets the bound object of this binding. + * @param obj the bound object. + */ + public void setObject (Object obj) + { + boundObj = obj; + } + + /** + * Returns the string representation. + * @return The string as given by the NameClassPair superclass plus + * the bound objects string representation seperated by a colon. + */ + public String toString () + { + // Format specified by the documentation. + return super.toString () + ":" + boundObj.toString (); + } + + // This name is fixed by the serialization spec. + private Object boundObj; +} diff --git a/libjava/classpath/javax/naming/CannotProceedException.java b/libjava/classpath/javax/naming/CannotProceedException.java new file mode 100644 index 000000000..26b1d0b0c --- /dev/null +++ b/libjava/classpath/javax/naming/CannotProceedException.java @@ -0,0 +1,107 @@ +/* CannotProceedException.java -- + Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +import java.util.Hashtable; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 14, 2001 + */ + +public class CannotProceedException extends NamingException +{ + private static final long serialVersionUID = 1219724816191576813L; + + // Serialized fields. + protected Name remainingNewName; + protected Hashtable environment; + protected Name altName; + protected Context altNameCtx; + + public CannotProceedException () + { + super (); + } + + public CannotProceedException (String msg) + { + super (msg); + } + + public Hashtable getEnvironment() + { + return environment; + } + + public void setEnvironment(Hashtable environment) + { + this.environment = environment; + } + + public Name getRemainingNewName() + { + return remainingNewName; + } + + public void setRemainingNewName(Name newName) + { + remainingNewName = (Name) newName.clone(); + } + + public Name getAltName() + { + return altName; + } + + public void setAltName(Name altName) + { + this.altName = altName; + } + + public Context getAltNameCtx() + { + return altNameCtx; + } + + public void setAltNameCtx(Context altNameCtx) + { + this.altNameCtx = altNameCtx; + } +} diff --git a/libjava/classpath/javax/naming/CommunicationException.java b/libjava/classpath/javax/naming/CommunicationException.java new file mode 100644 index 000000000..485e5cd1d --- /dev/null +++ b/libjava/classpath/javax/naming/CommunicationException.java @@ -0,0 +1,55 @@ +/* CommunicationException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class CommunicationException extends NamingException +{ + private static final long serialVersionUID = 3618507780299986611L; + + public CommunicationException () + { + super (); + } + + public CommunicationException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/CompositeName.java b/libjava/classpath/javax/naming/CompositeName.java new file mode 100644 index 000000000..7d4d362bd --- /dev/null +++ b/libjava/classpath/javax/naming/CompositeName.java @@ -0,0 +1,343 @@ +/* CompositeName.java -- + Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +import gnu.java.lang.CPStringBuilder; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Enumeration; +import java.util.NoSuchElementException; +import java.util.Vector; + +/** + * Represents names that may span over several namespaces. For instance, + * the composite name http://www.gnu.org/software/classpath/index.html spans + * over three namespaces (the protocol http, the web server location + * (www.gnu.org) and the index.html location on the server). + * + * @author Tom Tromey (tromey@redhat.com) + */ +public class CompositeName implements Name, Cloneable, Serializable +{ + private static final long serialVersionUID = 1667768148915813118L; + + private transient Vector elts; + + public CompositeName () + { + elts = new Vector (); + } + + protected CompositeName (Enumeration comps) + { + elts = new Vector (); + try + { + while (comps.hasMoreElements ()) + elts.add (comps.nextElement ()); + } + catch (NoSuchElementException ignore) + { + } + } + + public CompositeName (String n) throws InvalidNameException + { + elts = new Vector (); + // Parse the string into its components. + final char no_quote = 'x'; // Use 'x' to mean no quoting. + char quote = no_quote; + boolean escaped = false; + StringBuilder new_element = new StringBuilder (); + for (int i = 0; i < n.length (); ++i) + { + char c = n.charAt (i); + if (escaped) + escaped = false; + else if (c == '\\') + { + escaped = true; + continue; + } + else if (quote != no_quote) + { + if (quote == c) + { + // The quotes must surround a complete component. + if (i + 1 < n.length () && n.charAt (i + 1) != '/') + throw new InvalidNameException ("close quote before end of component"); + elts.add (new_element.toString ()); + new_element.setLength (0); + quote = no_quote; + continue; + } + // Otherwise, fall through. + } + // Quotes are only special at the start of a component. + else if (new_element.length () == 0 + && (c == '\'' || c == '"')) + { + quote = c; + continue; + } + else if (c == '/') + { + elts.add (new_element.toString ()); + new_element.setLength (0); + continue; + } + + new_element.append (c); + } + + if (new_element.length () != 0) + elts.add (new_element.toString ()); + + // Error checking. + if (quote != no_quote) + throw new InvalidNameException ("unterminated quote"); + if (escaped) + throw new InvalidNameException ("trailing escape character"); + } + + public Name add (int posn, String comp) throws InvalidNameException + { + elts.add (posn, comp); + return this; + } + + public Name add (String comp) throws InvalidNameException + { + elts.add (comp); + return this; + } + + public Name addAll (int posn, Name n) throws InvalidNameException + { + Enumeration e = n.getAll (); + try + { + while (e.hasMoreElements ()) + { + elts.add (posn, e.nextElement ()); + ++posn; + } + } + catch (NoSuchElementException ignore) + { + } + return this; + } + + public Name addAll (Name suffix) throws InvalidNameException + { + Enumeration e = suffix.getAll (); + try + { + while (e.hasMoreElements ()) + elts.add (e.nextElement ()); + } + catch (NoSuchElementException ignore) + { + } + return this; + } + + public Object clone () + { + return new CompositeName (elts.elements ()); + } + + public int compareTo (Object obj) + { + if (obj == null || ! (obj instanceof CompositeName)) + throw new ClassCastException ("CompositeName.compareTo() expected CompositeName"); + CompositeName cn = (CompositeName) obj; + int last = Math.min (cn.elts.size (), elts.size ()); + for (int i = 0; i < last; ++i) + { + String f = elts.get (i); + int comp = f.compareTo (cn.elts.get (i)); + if (comp != 0) + return comp; + } + return elts.size () - cn.elts.size (); + } + + public boolean endsWith (Name n) + { + if (! (n instanceof CompositeName)) + return false; + CompositeName cn = (CompositeName) n; + if (cn.elts.size () > elts.size ()) + return false; + int delta = elts.size () - cn.elts.size (); + for (int i = 0; i < cn.elts.size (); ++i) + { + if (! cn.elts.get (i).equals (elts.get (delta + i))) + return false; + } + return true; + } + + public boolean equals (Object obj) + { + if (! (obj instanceof CompositeName)) + return false; + CompositeName cn = (CompositeName) obj; + return elts.equals (cn.elts); + } + + public String get (int posn) + { + return elts.get (posn); + } + + public Enumeration getAll () + { + return elts.elements (); + } + + public Name getPrefix (int posn) + { + CompositeName cn = new CompositeName (); + for (int i = 0; i < posn; ++i) + cn.elts.add (elts.get (i)); + return cn; + } + + public Name getSuffix (int posn) + { + if (posn > elts.size ()) + throw new ArrayIndexOutOfBoundsException (posn); + CompositeName cn = new CompositeName (); + for (int i = posn; i < elts.size (); ++i) + cn.elts.add (elts.get (i)); + return cn; + } + + public int hashCode () + { + // Specified in documentation. + int h = 0; + for (int i = 0; i < elts.size (); ++i) + h += elts.get (i).hashCode (); + return h; + } + + public boolean isEmpty () + { + return elts.isEmpty (); + } + + public Object remove (int posn) throws InvalidNameException + { + return elts.remove (posn); + } + + public int size () + { + return elts.size (); + } + + public boolean startsWith (Name n) + { + if (! (n instanceof CompositeName)) + return false; + CompositeName cn = (CompositeName) n; + if (cn.elts.size () > elts.size ()) + return false; + for (int i = 0; i < cn.elts.size (); ++i) + { + if (! cn.elts.get (i).equals (elts.get (i))) + return false; + } + return true; + } + + public String toString () + { + CPStringBuilder result = new CPStringBuilder (); + for (int i = 0; i < elts.size (); ++i) + { + // For simplicity we choose to always quote using escapes and + // never quotes. + String elt = elts.get (i); + if (i > 0 + || (i == elts.size () - 1 && elt.equals (""))) + result.append ('/'); + for (int k = 0; k < elt.length (); ++k) + { + char c = elt.charAt (k); + // We must quote + // ... a leading quote, + if ((k == 0 && (c == '"' || c == '\'')) + // ... an escape preceding a meta character, + // or at the end of a component, + || (c == '\\' + && (k == elt.length () - 1 + || "\\'\"/".indexOf (elt.charAt (k + 1)) != -1)) + // ... or a component separator. + || c == '/') + result.append ('\\'); + result.append (c); + } + } + return result.toString (); + } + + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + int size = s.readInt(); + elts = new Vector(size); + for (int i = 0; i < size; i++) + elts.add((String) s.readObject()); + } + + private void writeObject(ObjectOutputStream s) throws IOException + { + s.writeInt(elts.size()); + for (int i = 0; i < elts.size(); i++) + s.writeObject(elts.get(i)); + } +} diff --git a/libjava/classpath/javax/naming/CompoundName.java b/libjava/classpath/javax/naming/CompoundName.java new file mode 100644 index 000000000..d410f6a97 --- /dev/null +++ b/libjava/classpath/javax/naming/CompoundName.java @@ -0,0 +1,523 @@ +/* CompoundName.java -- + Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +import gnu.java.lang.CPStringBuilder; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Enumeration; +import java.util.NoSuchElementException; +import java.util.Properties; +import java.util.Vector; + +/** + * Represents hierarchical names from the single namespace. For instance, + * the path /home/audriusa/classpath/file.txt is the compound name, using + * the filesystem namespace. + * + * @author Tom Tromey (tromey@redhat.com) + * @date May 16, 2001 + * + * FIXME: this class is underspecified. For instance, the `flat' + * direction is never described. If it means that the CompoundName + * can only have a single element, then the Enumeration-based + * constructor ought to throw InvalidNameException. + * + * @since 1.3 + */ +public class CompoundName implements Name, Cloneable, Serializable +{ + private static final long serialVersionUID = 3513100557083972036L; + + private CompoundName (Properties syntax) + { + elts = new Vector (); + mySyntax = syntax; + initializeSyntax (); + } + + protected CompoundName (Enumeration comps, Properties syntax) + { + elts = new Vector (); + mySyntax = syntax; + initializeSyntax (); + try + { + while (comps.hasMoreElements ()) + elts.add (comps.nextElement ()); + } + catch (NoSuchElementException ignore) + { + } + } + + public CompoundName (String n, Properties syntax) + throws InvalidNameException + { + elts = new Vector (); + mySyntax = syntax; + initializeSyntax (); + + StringBuilder new_element = new StringBuilder (); + int i = 0; + // QUOTE==null means no quoting right now. When it is set it is + // the value of the closing quote. + String quote = null; + while (i < n.length ()) + { + String special = isSpecial (n, i); + + if (special == escape && escape != null) + { + if (n.length () == i + special.length ()) + { + // A trailing escape is treated as itself. + new_element.append (special); + i += special.length (); + } + else + { + String eSpecial = isSpecial (n, i + special.length ()); + if (eSpecial != null) + { + // Treat the escape as an escape. + new_element.append (eSpecial); + i += special.length () + eSpecial.length (); + } + else + { + // Treat the escape as itself. + new_element.append (special); + i += special.length (); + } + continue; + } + } + else if (quote != null) + { + // It is safe to use == here. + if (quote == special) + { + // Quotes must surround a complete component. + if (i + quote.length () < n.length () + && ! n.startsWith (separator, i + quote.length ())) + throw new InvalidNameException ("close quote before end of component"); + elts.add (new_element.toString ()); + new_element.setLength (0); + i += quote.length (); + quote = null; + continue; + } + // Otherwise, fall through. + } + // Quotes are only special at the start of a component. + else if (new_element.length () == 0 + && special == beginQuote + && beginQuote != null) + { + quote = endQuote; + i += special.length (); + continue; + } + else if (new_element.length () == 0 + && special == beginQuote2 + && beginQuote2 != null) + { + quote = endQuote2; + i += special.length (); + continue; + } + else if (direction != FLAT && special == separator) + { + elts.add (new_element.toString ()); + new_element.setLength (0); + i += special.length (); + continue; + } + + // Nothing in particular, so try the next character. + new_element.append (n.charAt (i)); + ++i; + } + + if (new_element.length () != 0) + elts.add (new_element.toString ()); + + if (direction == RIGHT_TO_LEFT) + { + // Reverse the order of the elements. + int len = elts.size (); + for (i = 0; i < len / 2; ++i) + { + String t = elts.set (i, elts.get (len - i - 1)); + elts.set (len - i - 1, t); + } + } + + // Error checking. + if (quote != null) + throw new InvalidNameException ("unterminated quote"); + } + + public Name add (int posn, String comp) throws InvalidNameException + { + elts.add (posn, comp); + return this; + } + + public Name add (String comp) throws InvalidNameException + { + elts.add (comp); + return this; + } + + public Name addAll (int posn, Name n) throws InvalidNameException + { + Enumeration e = n.getAll (); + try + { + while (e.hasMoreElements ()) + { + elts.add (posn, e.nextElement ()); + ++posn; + } + } + catch (NoSuchElementException ignore) + { + } + return this; + } + + public Name addAll (Name suffix) throws InvalidNameException + { + Enumeration e = suffix.getAll (); + try + { + while (e.hasMoreElements ()) + elts.add (e.nextElement ()); + } + catch (NoSuchElementException ignore) + { + } + return this; + } + + public Object clone () + { + return new CompoundName (elts.elements (), mySyntax); + } + + public int compareTo (Object obj) + { + if (! (obj instanceof CompoundName)) + throw new ClassCastException ("CompoundName.compareTo() expected CompoundName"); + CompoundName cn = (CompoundName) obj; + int last = Math.min (cn.elts.size (), elts.size ()); + for (int i = 0; i < last; ++i) + { + String f = canonicalize (elts.get (i)); + int comp = f.compareTo (canonicalize (cn.elts.get (i))); + if (comp != 0) + return comp; + } + return elts.size () - cn.elts.size (); + } + + public boolean endsWith (Name n) + { + if (! (n instanceof CompoundName)) + return false; + CompoundName cn = (CompoundName) n; + if (cn.elts.size () > elts.size ()) + return false; + int delta = elts.size () - cn.elts.size (); + for (int i = 0; i < cn.elts.size (); ++i) + { + String f = canonicalize (elts.get (delta + i)); + if (! f.equals (canonicalize (cn.elts.get (i)))) + return false; + } + return true; + } + + public boolean equals (Object obj) + { + if (! (obj instanceof CompoundName)) + return false; + return compareTo (obj) == 0; + } + + public String get (int posn) + { + return elts.get (posn); + } + + public Enumeration getAll () + { + return elts.elements (); + } + + public Name getPrefix (int posn) + { + CompoundName cn = new CompoundName (mySyntax); + for (int i = 0; i < posn; ++i) + cn.elts.add (elts.get (i)); + return cn; + } + + public Name getSuffix (int posn) + { + if (posn > elts.size ()) + throw new ArrayIndexOutOfBoundsException (posn); + CompoundName cn = new CompoundName (mySyntax); + for (int i = posn; i < elts.size (); ++i) + cn.elts.add (elts.get (i)); + return cn; + } + + public int hashCode () + { + int h = 0; + for (int i = 0; i < elts.size (); ++i) + h += canonicalize (elts.get (i)).hashCode (); + return h; + } + + public boolean isEmpty () + { + return elts.isEmpty (); + } + + public Object remove (int posn) throws InvalidNameException + { + return elts.remove (posn); + } + + public int size () + { + return elts.size (); + } + + public boolean startsWith (Name n) + { + if (! (n instanceof CompoundName)) + return false; + CompoundName cn = (CompoundName) n; + if (cn.elts.size () > elts.size ()) + return false; + for (int i = 0; i < cn.elts.size (); ++i) + { + String f = canonicalize (elts.get (i)); + if (! f.equals (canonicalize (cn.elts.get (i)))) + return false; + } + return true; + } + + // If ELEMENT starts with some meta-sequence at OFFSET, then return + // the string representing the meta-sequence. Otherwise return + // null. + private String isSpecial (String element, int offset) + { + String special = null; + if (separator != null && element.startsWith (separator, offset)) + special = separator; + else if (escape != null && element.startsWith (escape, offset)) + special = escape; + else if (beginQuote != null && element.startsWith (beginQuote, offset)) + special = beginQuote; + else if (endQuote != null && element.startsWith (endQuote, offset)) + special = endQuote; + else if (beginQuote2 != null + && element.startsWith (beginQuote2, offset)) + special = beginQuote2; + else if (endQuote2 != null && element.startsWith (endQuote2, offset)) + special = endQuote2; + + return special; + } + + public String toString () + { + CPStringBuilder result = new CPStringBuilder (); + int size = elts.size (); + for (int i = 0; i < size; ++i) + { + // Find the appropriate element. FIXME: not clear what FLAT + // means. + int offset = (direction == RIGHT_TO_LEFT) ? (size - i - 1) : i; + String element = elts.get (offset); + if (i > 0 + || (i == size - 1 && element.equals (""))) + result.append (separator); + + int k = 0; + while (k < element.length ()) + { + String special = isSpecial (element, k); + if (special != null) + { + result.append (escape); + result.append (special); + k += special.length (); + } + else + { + result.append (element.charAt (k)); + ++k; + } + } + } + + return result.toString (); + } + + // This canonicalizes a String, based on the syntax, for comparison + // or other similar purposes. + private String canonicalize (String element) + { + String ret = element; + + if (ignoreCase) + ret = ret.toLowerCase (); + + if (trimBlanks) + { + int first = 0; + while (first < ret.length () + && Character.isWhitespace (ret.charAt (first))) + ++first; + + int last = ret.length () - 1; + while (last >= first + && Character.isWhitespace (ret.charAt (last))) + --last; + + ret = ret.substring (first, last); + } + + return ret; + } + + // This initializes all the syntax variables. This seems easier + // than re-querying the properties every time. We're allowed to do + // this because the spec says that subclasses should consider the + // syntax as being read-only. + private void initializeSyntax () + { + String t = mySyntax.getProperty ("jndi.syntax.direction", "flat"); + if (t.equals ("right_to_left")) + this.direction = RIGHT_TO_LEFT; + else if (t.equals ("left_to_right")) + this.direction = LEFT_TO_RIGHT; + else + { + // If we don't recognize it, default to flat. + this.direction = FLAT; + } + + // This is required unless the direction is FLAT. Unfortunately + // there is no way to report this error. + this.separator = mySyntax.getProperty ("jndi.syntax.separator", ""); + + this.ignoreCase + = Boolean.valueOf (mySyntax.getProperty ("jndi.syntax.ignorecase", + "false")).booleanValue (); + this.escape = mySyntax.getProperty ("jndi.syntax.escape", null); + this.beginQuote = mySyntax.getProperty ("jndi.syntax.beginquote", null); + this.endQuote = mySyntax.getProperty ("jndi.syntax.endquote", + this.beginQuote); + this.beginQuote2 = mySyntax.getProperty ("jndi.syntax.beginquote2", + null); + this.endQuote2 = mySyntax.getProperty ("jndi.syntax.endquote2", + this.beginQuote2); + this.trimBlanks + = Boolean.valueOf (mySyntax.getProperty ("jndi.syntax.trimblanks", + "false")).booleanValue (); + } + + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + mySyntax = (Properties) s.readObject(); + int count = s.readInt(); + elts = new Vector(count); + for (int i = 0; i < count; i++) + elts.addElement((String) s.readObject()); + } + + private void writeObject(ObjectOutputStream s) + throws IOException + { + s.writeObject(mySyntax); + s.writeInt(elts.size()); + for (int i = 0; i < elts.size(); i++) + s.writeObject(elts.elementAt(i)); + } + + // The spec specifies this but does not document it in any way (it + // is a package-private class). It is useless as far as I can tell. + // So we ignore it. + // protected transient NameImpl impl; + protected transient Properties mySyntax; + + // The actual elements. + private transient Vector elts; + + // The following are all used for syntax. + private transient int direction; + private transient String separator; + private transient boolean ignoreCase; + private transient String escape; + private transient String beginQuote; + private transient String endQuote; + private transient String beginQuote2; + private transient String endQuote2; + private transient boolean trimBlanks; + // We didn't need these for parsing, so they are gone. + // private transient String avaSeparator; + // private transient String typevalSeparator; + + private static final int RIGHT_TO_LEFT = -1; + private static final int LEFT_TO_RIGHT = 1; + private static final int FLAT = 0; +} diff --git a/libjava/classpath/javax/naming/ConfigurationException.java b/libjava/classpath/javax/naming/ConfigurationException.java new file mode 100644 index 000000000..eb2fbfeec --- /dev/null +++ b/libjava/classpath/javax/naming/ConfigurationException.java @@ -0,0 +1,55 @@ +/* ConfigurationException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class ConfigurationException extends NamingException +{ + private static final long serialVersionUID = - 2535156726228855704L; + + public ConfigurationException () + { + super (); + } + + public ConfigurationException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/Context.java b/libjava/classpath/javax/naming/Context.java new file mode 100644 index 000000000..35217ffc4 --- /dev/null +++ b/libjava/classpath/javax/naming/Context.java @@ -0,0 +1,492 @@ +/* Context.java -- A naming context + Copyright (C) 2000, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +import java.util.Hashtable; + +import javax.naming.directory.InvalidAttributesException; + +public interface Context +{ + /** + * Property with name of the inital context factory to use + */ + String INITIAL_CONTEXT_FACTORY = "java.naming.factory.initial"; + + /** + * Property with colon-separated list of object factories to use. + */ + String OBJECT_FACTORIES = "java.naming.factory.object"; + + /** + * Property with colon-separated list of state factories to use. + */ + String STATE_FACTORIES = "java.naming.factory.state"; + + /** + * Property with colon-separated list of package prefixes to use. + */ + String URL_PKG_PREFIXES = "java.naming.factory.url.pkgs"; + + /** + * Property with URL specifying configuration for the service provider to use. + */ + String PROVIDER_URL = "java.naming.provider.url"; + + /** + * Property with the DNS host and domain names to use. + */ + String DNS_URL = "java.naming.dns.url"; + + /** + * Property with the authoritativeness of the service requested. + */ + String AUTHORITATIVE = "java.naming.authoritative"; + + /** + * Property with the batch size to use when returning data via the service's + * protocol. + */ + String BATCHSIZE = "java.naming.batchsize"; + + /** + * Property defining how referrals encountered by the service provider are to + * be processed. + */ + String REFERRAL = "java.naming.referral"; + + /** + * Property specifying the security protocol to use. + */ + String SECURITY_PROTOCOL = "java.naming.security.protocol"; + + /** + * Property specifying the security level to use. + */ + String SECURITY_AUTHENTICATION = "java.naming.security.authentication"; + + /** + * Property for the identity of the principal for authenticating the caller to + * the service. + */ + String SECURITY_PRINCIPAL = "java.naming.security.principal"; + + /** + * Property specifying the credentials of the principal for authenticating the + * caller to the service. + */ + String SECURITY_CREDENTIALS = "java.naming.security.credentials"; + + /** + * Property for specifying the preferred language to use with the service. + */ + String LANGUAGE = "java.naming.language"; + + /** + * Property for the initial context constructor to use when searching for + * other properties. + */ + String APPLET = "java.naming.applet"; + + /** + * Give the specified name for the specified object. The passed name must not + * be already bound to some other object. + * + * @param name the name that will be given to the object (in the scope of this + * context). + * @param obj the object being named. + * @throws NameAlreadyBoundException if this name is already used to name some + * object. + * @throws InvalidAttributesException if the object does not supply all + * required attributes. + * @throws NamingException if the naming operation has failed due other + * reasons. + */ + void bind(Name name, Object obj) throws NamingException; + + /** + * Give the specified name for the specified object. The passed name must not + * be already bound to some other object. + * + * @param name the name that will be given to the object (in the scope of this + * context). + * @param obj the object being named. + * @throws NameAlreadyBoundException if this name is already used to name some + * object. + * @throws InvalidAttributesException if the object does not supply all + * required attributes. + * @throws NamingException if the naming operation has failed due other + * reasons. + */ + void bind(String name, Object obj) throws NamingException; + + /** + * Gets the previously named object by name. If the passed name is empty, the + * method should return a cloned instance of this naming context. + * + * @param name the name of the object being searched in this context + * @return the named object + * @throws NamingException if the naming fails. + */ + Object lookup(Name name) throws NamingException; + + /** + * Gets the previously named object by name. If the passed name is empty, the + * method should return a cloned instance of this naming context. + * + * @param name the name of the object being searched in this context + * @return the named object + * @throws NamingException if the naming fails. + */ + Object lookup(String name) throws NamingException; + + /** + * Give the specified name for the specified object. Unlike bind, this method + * silently replaces the existing binding for this name, if one exists. + * + * @param name the name that will be given to the object (in the scope of this + * context). + * @param obj the object being named. + * @throws InvalidAttributesException if the object does not supply all + * required attributes. + * @throws NamingException if the naming operation has failed due other + * reasons. + */ + void rebind(Name name, Object obj) throws NamingException; + + /** + * Give the specified name for the specified object. Unlike bind, this method + * silently replaces the existing binding for this name, if one exists. + * + * @param name the name that will be given to the object (in the scope of this + * context). + * @param obj the object being named. + * @throws InvalidAttributesException if the object does not supply all + * required attributes. + * @throws NamingException if the naming operation has failed due other + * reasons. + */ + void rebind(String name, Object obj) throws NamingException; + + /** + * Removes the name - object mapping from the current context. This method + * returns without action if the name is not bound to an object in the + * terminal context, but throws {@link NameNotFoundException} if one of the + * intermadiate contexts does not exist. + * + * @param name the name to be removed + * @throws NameNotFoundException if one of the intermediate naming contexts + * does not exist. Will not be thrown if just the terminal binding + * is missing. + * @throws NamingException if the naming operation has failed due other + * reasons. + */ + void unbind(Name name) throws NamingException; + + /** + * Removes the name - object mapping from the current context. This method + * returns without action if the name is not bound to an object in the + * terminal context, but throws {@link NameNotFoundException} if one of the + * intermadiate contexts does not exist. + * + * @param name the name to be removed + * @throws NameNotFoundException if one of the intermediate naming contexts + * does not exist. Will not be thrown if just the terminal binding + * is missing. + * @throws NamingException if the naming operation has failed due other + * reasons. + */ + void unbind(String name) throws NamingException; + + /** + * Renames the existing binding, removing the existing and giving the new name + * for the same object. + * + * @param oldName the existing name of the known object + * @param newName the new name of the same object + * @throws NameNotFoundException if the oldName is unknown for this context + * @throws NamingException if the naming operation has failed due other + * reasons. + */ + void rename(Name oldName, Name newName) throws NamingException; + + /** + * Renames the existing binding, removing the existing and giving the new name + * for the same object. + * + * @param oldName the existing name of the known object + * @param newName the new name of the same object + * @throws NameNotFoundException if the oldName is unknown for this context + * @throws NamingException if the naming operation has failed due other + * reasons. + */ + void rename(String oldName, String newName) throws NamingException; + + /** + * Creates and returns the enumeration over the name bindings that are present + * the given subcontext. The enumeration elements have the type of + * {@link NameClassPair}, providing also information about the class of the + * bound object. The behaviour in the case if the bindings are added or + * removed later is not defined. The contents of the subcontexts are not + * included. + * + * @param name the name of the subcontext + * @return the enumeration over the names, known for the given subcontext. + * @throws NamingException + */ + NamingEnumeration list(Name name) throws NamingException; + + /** + * Creates and returns the enumeration over the name bindings that are present + * the given subcontext. The enumeration elements have the type of + * {@link NameClassPair}, providing also information about the class of the + * bound object. The behaviour in the case if the bindings are added or + * removed later is not defined. The contents of the subcontexts are not + * included. + * + * @param name the name of the subcontext + * @return the enumeration over the names, known for the given subcontext. + * @throws NamingException + */ + NamingEnumeration list(String name) throws NamingException; + + /** + * Creates and returns the enumeration over the name - object bindings that + * are present the given subcontext. The enumeration elements have the type of + * {@link Binding}, providing also information about the class of the bound + * object. The behaviour in the case if the bindings are added or removed + * later is not defined. The contents of the subcontexts are not included. + * + * @param name the name of the subcontext + * @return the enumeration over the names, known for the given subcontext. + * @throws NamingException + */ + NamingEnumeration listBindings(Name name) throws NamingException; + + /** + * Creates and returns the enumeration over the name - object bindings that + * are present the given subcontext. The enumeration elements have the type of + * {@link Binding}, providing also information about the class of the bound + * object. The behaviour in the case if the bindings are added or removed + * later is not defined. The contents of the subcontexts are not included. + * + * @param name the name of the subcontext + * @return the enumeration over the names, known for the given subcontext. + * @throws NamingException + */ + NamingEnumeration listBindings(String name) throws NamingException; + + /** + * Creates the new naming subcontext and binds it to the current (this) + * context. + * + * @param name the name of the new context being created + * @return the newly created context, bound to the instance of the context on + * that the method has been called + * @throws NameAlreadyBoundException if this name is already bound + * @throws InvalidAttributesException if the creation of the new context + * requires the missing mandatory attributes + * @throws NamingException + */ + Context createSubcontext(Name name) throws NamingException; + + /** + * Creates the new naming subcontext and binds it to the current (this) + * context. + * + * @param name the name of the new context being created + * @return the newly created context, bound to the instance of the context on + * that the method has been called + * @throws NameAlreadyBoundException if this name is already bound + * @throws InvalidAttributesException if the creation of the new context + * requires the missing mandatory attributes + * @throws NamingException + */ + Context createSubcontext(String name) throws NamingException; + + /** + * Removes the naming subcontext from this naming context. Returns without + * action if such subcontext does not exist. The context being destroyed must + * be empty. + * + * @param name the name of the subcontext beig removed. + * @throws ContextNotEmptyException if the named context is not empty. + * @throws NamingException + */ + void destroySubcontext(Name name) throws NamingException; + + /** + * Removes the naming subcontext from this naming context. Returns without + * action if such subcontext does not exist. The context being destroyed must + * be empty. + * + * @param name the name of the subcontext beig removed. + * @throws ContextNotEmptyException if the named context is not empty. + * @throws NamingException + */ + void destroySubcontext(String name) throws NamingException; + + /** + * Retrieves the named object, not following the link of the terminal atomic + * component of the name. If the object, named by the passed name, is not a + * link, returns that object itself. The intermediate links, if present, are + * followed. + * + * @param name the name of the object that may be a link, leading to another + * object. + * @return the named object, not following the terminal link (if present). + * @throws NamingException + */ + Object lookupLink(Name name) throws NamingException; + + /** + * Retrieves the named object, not following the link of the terminal atomic + * component of the name. If the object, named by the passed name, is not a + * link, returns that object itself. The intermediate links, if present, are + * followed. + * + * @param name the name of the object that may be a link, leading to another + * object. + * @return the named object, not following the terminal link (if present). + * @throws NamingException + */ + Object lookupLink(String name) throws NamingException; + + /** + * Obtains the name parser for parsing the names of the given naming + * subcontext. + * + * @param name the name of the subcontext for that the parser must be obtained + * @return the parser to parse the names of that context + * @throws NamingException + */ + NameParser getNameParser(Name name) throws NamingException; + + /** + * Obtains the name parser for parsing the names of the given naming + * subcontext. + * + * @param name the name of the subcontext for that the parser must be obtained + * @return the parser to parse the names of that context + * @throws NamingException + */ + NameParser getNameParser(String name) throws NamingException; + + /** + * Composes the name of this context together with another name, related to + * this context. + * + * @param name a name, defined in the scope of this context + * @param prefix a name of this context itself, defined in the scope of some + * ancestor + * @return the name of the same object as named by the first parameter, but + * related to the context of the specified ancestor. + * @throws NamingException + */ + Name composeName(Name name, Name prefix) throws NamingException; + + /** + * Composes the name of this context together with another name, related to + * this context. + * + * @param name a name, defined in the scope of this context + * @param prefix a name of this context itself, defined in the scope of some + * ancestor + * @return the name of the same object as named by the first parameter, but + * related to the context of the specified ancestor. + * @throws NamingException + */ + String composeName(String name, String prefix) throws NamingException; + + /** + * Add new environment property to the environment of this context. Both name + * and value of the new property must not be null. If the property is already + * defined, is current value is replaced by the propVal. + * + * @param propName the name of the new property + * @param propVal the value of the new property + * @return the previous value of this property or null if the property has not + * been previously defined + * @throws NamingException + */ + Object addToEnvironment(String propName, Object propVal) + throws NamingException; + + /** + * Removes the property with the given name from the environment. Returns + * without action if this property is not defined. + * + * @param propName the name of the property being removed. + * @return the value of the property that has been removed or null if the + * property was not defined. + * @throws NamingException + */ + Object removeFromEnvironment(String propName) throws NamingException; + + /** + * Returns the environment, associated with this naming context. The returned + * table should never be modified by the caller. Use {@link #addToEnvironment} + * and {@link #removeFromEnvironment} to modify the environement, if needed. + * + * @return the table, representing the environment of this context + * @throws NamingException + */ + Hashtable getEnvironment() throws NamingException; + + /** + * Releases all resources, associated with this context. The close() method + * can be called several times, but after it has been once invoked, it is not + * allowed to call any other method of this context, + * + * @throws NamingException + */ + void close() throws NamingException; + + /** + * Returs the full name of this naming context. The returned string is not a + * JNDI composite name and should not be passed directly to the methods of the + * naming context. + * + * @return the full name of this naming context, in its own namespace. + * @throws OperationNotSupportedException if the naming system, represented by + * this context, does not support the notation of the full name. + * @throws NamingException + */ + String getNameInNamespace() throws NamingException; +} diff --git a/libjava/classpath/javax/naming/ContextNotEmptyException.java b/libjava/classpath/javax/naming/ContextNotEmptyException.java new file mode 100644 index 000000000..816e70312 --- /dev/null +++ b/libjava/classpath/javax/naming/ContextNotEmptyException.java @@ -0,0 +1,60 @@ +/* ContextNotEmptyException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +/** + * This exception is thrown in response to the attempt to destroy the non + * empty context. Only empty contexts (without bindings) can be destroyed. + * + * @see Context#destroySubcontext + */ +public class ContextNotEmptyException extends NamingException +{ + private static final long serialVersionUID = 1090963683348219877L; + + public ContextNotEmptyException () + { + super (); + } + + public ContextNotEmptyException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/InitialContext.java b/libjava/classpath/javax/naming/InitialContext.java new file mode 100644 index 000000000..c33122adf --- /dev/null +++ b/libjava/classpath/javax/naming/InitialContext.java @@ -0,0 +1,548 @@ +/* InitialContext.java -- Initial naming context. + Copyright (C) 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +import java.applet.Applet; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Properties; + +import javax.naming.spi.NamingManager; + +/** + * The starting context for performing naming operations. All naming operations + * are performed in the scope of some context. The initial context is the + * starting point for the name resolution. + */ +public class InitialContext implements Context +{ + /** + * Contains the default initial context. This value is returned by + * {@link NamingManager#getInitialContext}. It is set by this method + * when calling it first time. The subsequent calls return the value of + * this field. + */ + protected Context defaultInitCtx; + + /** + * Indicates if the initial context was obtained by calling + * {@link NamingManager#getInitialContext}. + */ + protected boolean gotDefault = false; + + /** + * The environment, associated with this initial context. + */ + protected Hashtable myProps; + + /** + * The list of the properties, to that the second alternative value must + * be appended after the colon to the first possible value. Used in + * {@link #merge(Hashtable, Hashtable)} + */ + static final HashSet colon_list; + static + { + colon_list = new HashSet(); + colon_list.add(Context.OBJECT_FACTORIES); + colon_list.add(Context.URL_PKG_PREFIXES); + colon_list.add(Context.STATE_FACTORIES); + } + + /** + * The properties that are searched in the agreed places in the + * {@link #init(Hashtable)} method. + */ + static final String[] use_properties = + { + Context.DNS_URL, + Context.INITIAL_CONTEXT_FACTORY, + Context.OBJECT_FACTORIES, + Context.PROVIDER_URL, + Context.STATE_FACTORIES, + Context.URL_PKG_PREFIXES, + }; + + + /** + * Creates the new initial context with the given properties. + * + * @param environment the properties, used by the initial context being + * created. + * @throws NamingException + */ + public InitialContext(Hashtable environment) throws NamingException + { + init(environment); + } + + /** + * Creates the initial context with the possibility to delay its + * initialisation. + * + * @param lazy specified if the initialization should not be performed by this + * constructor (true). If the valueis false, it works the same way as + * the parameterless constructor. + * @throws NamingException + */ + protected InitialContext(boolean lazy) throws NamingException + { + if (! lazy) + init(null); + } + + /** + * Creates teh new initial context with no properties. Same as + * InitialContext(null). + * + * @throws NamingException + */ + public InitialContext() throws NamingException + { + init(null); + } + + /** + *

+ * Initialises the context, using the properties, specified in the passed + * table. + *

+ * The missing properties are additionally obtained (in order) from the + * following locations: + *
    + *
  • If the passed parameter contains the key Context.APPLET, its value + * must be the instance of the {@link Applet}. Then the properties are + * requested via {@link Applet#getParameter(String)}.
  • + *
  • The value of the system property is used.
  • + *
  • The resource "jndi.properties" is requested from the context class + * loader of the current thread
  • + *
  • The property file "jndi.properties" is read from the location, + * specified by the system property "gnu.classpath.home.url". + *
+ *

+ * + * @param environment the table of the properties, may be null. The method + * modifies the table and stores the reference to it. The caller must + * not later reuse this structure for other purposes. + * @since 1.3 + */ + protected void init(Hashtable environment) throws NamingException + { + // If is documented that the caller should not modify the environment. + if (environment != null) + myProps = (Hashtable) environment; + else + myProps = new Hashtable(); + + Applet napplet = (Applet) myProps.get(Context.APPLET); + + Properties pApplet = null; + if (napplet != null) + pApplet = new Properties(); + Properties pSystem = new Properties(); + Object value; + + for (int i = use_properties.length - 1; i >= 0; i--) + { + String key = use_properties[i]; + if (napplet != null) + { + value = napplet.getParameter(key); + if (value != null) + pApplet.put(key, value); + } + + value = System.getProperty(key); + if (value != null) + pSystem.put(key, value); + } + + merge(myProps, pSystem); + if (pApplet != null) + merge(myProps, pApplet); + + try + { + Enumeration ep = Thread.currentThread(). + getContextClassLoader().getResources("jndi.properties"); + while (ep.hasMoreElements()) + { + URL url = (URL) ep.nextElement(); + Properties p = new Properties(); + + try + { + InputStream is = url.openStream(); + p.load(is); + is.close(); + } + catch (IOException e) + { + // Ignore. + } + + merge(myProps, p); + } + } + catch (IOException e) + { + // Ignore. + } + + String home = System.getProperty("gnu.classpath.home.url"); + if (home != null) + { + String url = home + "/jndi.properties"; + Properties p = new Properties(); + + try + { + InputStream is = new URL(url).openStream(); + p.load(is); + is.close(); + } + catch (IOException e) + { + // Ignore. + } + + merge(myProps, p); + } + } + + /** + * Merge the content of the two tables. If the second table contains the key + * that is missing in the first table, this key - value pair is copied to the + * first table. If both first and second tables contain the same key AND the + * {@link #colon_list} set also contains this key, the value from the second + * table is appended to the value from the first table after semicolon, and + * the resulted value replaces the value in the first table. + * + * @param primary the first table to merge. The merged result is also stored + * in this table. + * @param additional the second table, from where additional values are taken + */ + static void merge (Hashtable primary, + Hashtable additional) + { + Enumeration en = additional.keys(); + + while (en.hasMoreElements()) + { + String key2 = (String) en.nextElement(); + Object value1 = primary.get(key2); + if (value1 == null) + primary.put(key2, additional.get(key2)); + else if (colon_list.contains(key2)) + { + String value2 = (String) additional.get(key2); + primary.put(key2, (String) value1 + ":" + value2); + } + } + } + + /** + * Get the default initial context. If {@link #gotDefault} == false, this + * method obtains the initial context from the naming manager and sets + * gotDefault to true. Otherwise the cached value ({@link #defaultInitCtx} is + * returned. + * + * @return the default initial context + * @throws NamingException + */ + protected Context getDefaultInitCtx() throws NamingException + { + if (! gotDefault) + { + defaultInitCtx = NamingManager.getInitialContext(myProps); + gotDefault = true; + } + return defaultInitCtx; + } + + /** + * Obtains the context for resolving the given name. If the first component of + * the name is the URL string, this method tries to find the corressponding + * URL naming context. If it is not an URL string, or the URL context is not + * found, the default initial context is returned. + * + * @param name the name, for that it is required to obtain the context. + * @return the context for resolving the name. + * @throws NamingException + */ + protected Context getURLOrDefaultInitCtx(Name name) throws NamingException + { + if (name.size() > 0) + return getURLOrDefaultInitCtx(name.get(0)); + else + return getDefaultInitCtx(); + } + + /** + * Obtains the context for resolving the given name. If the first component of + * the name is the URL string, this method tries to find the corressponding + * URL naming context. If it is not an URL string, or the URL context is not + * found, the default initial context is returned. + * + * @param name the name, for that it is required to obtain the context. + * @return the context for resolving the name. + * @throws NamingException + */ + protected Context getURLOrDefaultInitCtx(String name) throws NamingException + { + String scheme = null; + + if (NamingManager.hasInitialContextFactoryBuilder()) + return getDefaultInitCtx(); + int colon = name.indexOf(':'); + int slash = name.indexOf('/'); + if (colon > 0 && (slash == - 1 || colon < slash)) + scheme = name.substring(0, colon); + if (scheme != null) + { + Context context = NamingManager.getURLContext(scheme, myProps); + if (context != null) + return context; + } + + return getDefaultInitCtx(); + } + + /** @inheritDoc */ + public void bind (Name name, Object obj) throws NamingException + { + getURLOrDefaultInitCtx (name).bind (name, obj); + } + + /** @inheritDoc */ + public void bind (String name, Object obj) throws NamingException + { + getURLOrDefaultInitCtx (name).bind (name, obj); + } + + /** @inheritDoc */ + public Object lookup (Name name) throws NamingException + { + try + { + return getURLOrDefaultInitCtx (name).lookup (name); + } + catch (CannotProceedException cpe) + { + Context ctx = NamingManager.getContinuationContext (cpe); + return ctx.lookup (cpe.getRemainingName()); + } + } + + /** @inheritDoc */ + public Object lookup (String name) throws NamingException + { + try + { + return getURLOrDefaultInitCtx (name).lookup (name); + } + catch (CannotProceedException cpe) + { + Context ctx = NamingManager.getContinuationContext (cpe); + return ctx.lookup (cpe.getRemainingName()); + } + } + + /** @inheritDoc */ + public void rebind (Name name, Object obj) throws NamingException + { + getURLOrDefaultInitCtx (name).rebind (name, obj); + } + + /** @inheritDoc */ + public void rebind (String name, Object obj) throws NamingException + { + getURLOrDefaultInitCtx (name).rebind (name, obj); + } + + /** @inheritDoc */ + public void unbind (Name name) throws NamingException + { + getURLOrDefaultInitCtx (name).unbind (name); + } + + /** @inheritDoc */ + public void unbind (String name) throws NamingException + { + getURLOrDefaultInitCtx (name).unbind (name); + } + + /** @inheritDoc */ + public void rename (Name oldName, Name newName) throws NamingException + { + getURLOrDefaultInitCtx (oldName).rename (oldName, newName); + } + + /** @inheritDoc */ + public void rename (String oldName, String newName) throws NamingException + { + getURLOrDefaultInitCtx (oldName).rename (oldName, newName); + } + + /** @inheritDoc */ + public NamingEnumeration list (Name name) throws NamingException + { + return getURLOrDefaultInitCtx (name).list (name); + } + + /** @inheritDoc */ + public NamingEnumeration list (String name) throws NamingException + { + return getURLOrDefaultInitCtx (name).list (name); + } + + /** @inheritDoc */ + public NamingEnumeration listBindings (Name name) throws NamingException + { + return getURLOrDefaultInitCtx (name).listBindings (name); + } + + /** @inheritDoc */ + public NamingEnumeration listBindings (String name) throws NamingException + { + return getURLOrDefaultInitCtx (name).listBindings (name); + } + + /** @inheritDoc */ + public void destroySubcontext (Name name) throws NamingException + { + getURLOrDefaultInitCtx (name).destroySubcontext (name); + } + + /** @inheritDoc */ + public void destroySubcontext (String name) throws NamingException + { + getURLOrDefaultInitCtx (name).destroySubcontext (name); + } + + /** @inheritDoc */ + public Context createSubcontext (Name name) throws NamingException + { + return getURLOrDefaultInitCtx (name).createSubcontext (name); + } + + /** @inheritDoc */ + public Context createSubcontext (String name) throws NamingException + { + return getURLOrDefaultInitCtx (name).createSubcontext (name); + } + + /** @inheritDoc */ + public Object lookupLink (Name name) throws NamingException + { + return getURLOrDefaultInitCtx (name).lookupLink (name); + } + + /** @inheritDoc */ + public Object lookupLink (String name) throws NamingException + { + return getURLOrDefaultInitCtx (name).lookupLink (name); + } + + /** @inheritDoc */ + public NameParser getNameParser (Name name) throws NamingException + { + return getURLOrDefaultInitCtx (name).getNameParser (name); + } + + /** @inheritDoc */ + public NameParser getNameParser (String name) throws NamingException + { + return getURLOrDefaultInitCtx (name).getNameParser (name); + } + + /** @inheritDoc */ + public Name composeName (Name name, Name prefix) throws NamingException + { + return getURLOrDefaultInitCtx (name).composeName (name, prefix); + } + + /** @inheritDoc */ + public String composeName (String name, + String prefix) throws NamingException + { + return getURLOrDefaultInitCtx (name).composeName (name, prefix); + } + + /** @inheritDoc */ + public Object addToEnvironment (String propName, + Object propVal) throws NamingException + { + return myProps.put (propName, propVal); + } + + /** @inheritDoc */ + public Object removeFromEnvironment (String propName) throws NamingException + { + return myProps.remove (propName); + } + + /** @inheritDoc */ + public Hashtable getEnvironment () throws NamingException + { + return myProps; + } + + /** @inheritDoc */ + public void close () throws NamingException + { + myProps = null; + defaultInitCtx = null; + } + + /** + * This operation is not supported for the initial naming context. + * + * @throws OperationNotSupportedException always, unless the method is + * overridden in the derived class. + */ + public String getNameInNamespace () throws NamingException + { + throw new OperationNotSupportedException (); + } +} diff --git a/libjava/classpath/javax/naming/InsufficientResourcesException.java b/libjava/classpath/javax/naming/InsufficientResourcesException.java new file mode 100644 index 000000000..a7bc3a85e --- /dev/null +++ b/libjava/classpath/javax/naming/InsufficientResourcesException.java @@ -0,0 +1,55 @@ +/* InsufficientResourcesException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class InsufficientResourcesException extends NamingException +{ + private static final long serialVersionUID = 6227672693037844532L; + + public InsufficientResourcesException () + { + super (); + } + + public InsufficientResourcesException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/InterruptedNamingException.java b/libjava/classpath/javax/naming/InterruptedNamingException.java new file mode 100644 index 000000000..e42981a6d --- /dev/null +++ b/libjava/classpath/javax/naming/InterruptedNamingException.java @@ -0,0 +1,55 @@ +/* InterruptedNamingException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class InterruptedNamingException extends NamingException +{ + private static final long serialVersionUID = 6404516648893194728L; + + public InterruptedNamingException () + { + super (); + } + + public InterruptedNamingException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/InvalidNameException.java b/libjava/classpath/javax/naming/InvalidNameException.java new file mode 100644 index 000000000..e76a152a8 --- /dev/null +++ b/libjava/classpath/javax/naming/InvalidNameException.java @@ -0,0 +1,68 @@ +/* InvalidNameException.java -- Exception indicating an invalid component/name + Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.naming; + +/** + * Exception indicating an invalid component or Name. + * Thrown when a Name or component of a name is encountered that + * does not follow the syntactic rules of a particular Name class. + * + * @author Anthony Green (green@redhat.com) + * @author Mark Wielaard (mark@klomp.org) + */ +public class InvalidNameException extends NamingException +{ + private static final long serialVersionUID = - 8370672380823801105L; + + /** + * Creates a new exception without setting any of its fields. + */ + public InvalidNameException () + { + super (); + } + + /** + * Creates a new exception and sets the detailed message field. + * All other fields are not set. + */ + public InvalidNameException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/LimitExceededException.java b/libjava/classpath/javax/naming/LimitExceededException.java new file mode 100644 index 000000000..64151193f --- /dev/null +++ b/libjava/classpath/javax/naming/LimitExceededException.java @@ -0,0 +1,55 @@ +/* LimitExceededException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class LimitExceededException extends NamingException +{ + private static final long serialVersionUID = - 776898738660207856L; + + public LimitExceededException () + { + super (); + } + + public LimitExceededException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/LinkException.java b/libjava/classpath/javax/naming/LinkException.java new file mode 100644 index 000000000..f5c661bbb --- /dev/null +++ b/libjava/classpath/javax/naming/LinkException.java @@ -0,0 +1,119 @@ +/* LinkException.java -- + Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 14, 2001 + */ + +public class LinkException extends NamingException +{ + private static final long serialVersionUID = - 7967662604076777712L; + + // Serialized fields. + protected Name linkResolvedName; + protected Object linkResolvedObj; + protected Name linkRemainingName; + protected String linkExplanation; + + public LinkException () + { + super (); + } + + public LinkException (String msg) + { + super (msg); + } + + public Name getLinkResolvedName() + { + return linkResolvedName; + } + + public Name getLinkRemainingName() + { + return linkRemainingName; + } + + public Object getLinkResolvedObj() + { + return linkResolvedObj; + } + + public String getLinkExplanation() + { + return linkExplanation; + } + + public void setLinkExplanation(String msg) + { + linkExplanation = msg; + } + + public void setLinkResolvedName(Name name) + { + linkResolvedName = (Name) name.clone(); + } + + public void setLinkRemainingName(Name name) + { + linkRemainingName = (Name) name.clone(); + } + + public void setLinkResolvedObj(Object obj) + { + linkResolvedObj = obj; + } + + public String toString () + { + return super.toString () + "; " + linkRemainingName.toString (); + } + + public String toString (boolean detail) + { + String r = super.toString (detail) + "; " + linkRemainingName.toString (); + if (detail) + r += "; " + linkResolvedObj.toString (); + return r; + } +} diff --git a/libjava/classpath/javax/naming/LinkLoopException.java b/libjava/classpath/javax/naming/LinkLoopException.java new file mode 100644 index 000000000..539294e84 --- /dev/null +++ b/libjava/classpath/javax/naming/LinkLoopException.java @@ -0,0 +1,55 @@ +/* LinkLoopException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class LinkLoopException extends LinkException +{ + private static final long serialVersionUID = - 3119189944325198009L; + + public LinkLoopException () + { + super (); + } + + public LinkLoopException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/LinkRef.java b/libjava/classpath/javax/naming/LinkRef.java new file mode 100644 index 000000000..35d9a406f --- /dev/null +++ b/libjava/classpath/javax/naming/LinkRef.java @@ -0,0 +1,67 @@ +/* LinkRef.java -- + Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +/** + * @author Tom Tromey (tromey@redhat.com) + * @date May 16, 2001 + */ +public class LinkRef extends Reference +{ + private static final long serialVersionUID = -5386290613498931298L; + + public LinkRef (Name name) + { + this (name.toString ()); + } + + public LinkRef (String name) + { + // FIXME: javax.naming.LinkRef? + super ("LinkRef", new StringRefAddr ("LinkAddress", name)); + } + + public String getLinkName () + throws NamingException + { + StringRefAddr sra = (StringRefAddr) get (0); + return (String) sra.getContent (); + } +} diff --git a/libjava/classpath/javax/naming/MalformedLinkException.java b/libjava/classpath/javax/naming/MalformedLinkException.java new file mode 100644 index 000000000..e665b34c3 --- /dev/null +++ b/libjava/classpath/javax/naming/MalformedLinkException.java @@ -0,0 +1,55 @@ +/* MalformedLinkException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class MalformedLinkException extends LinkException +{ + private static final long serialVersionUID = - 3066740437737830242L; + + public MalformedLinkException () + { + super (); + } + + public MalformedLinkException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/Name.java b/libjava/classpath/javax/naming/Name.java new file mode 100644 index 000000000..3b22ba5ee --- /dev/null +++ b/libjava/classpath/javax/naming/Name.java @@ -0,0 +1,206 @@ +/* Name.java -- Name build up from different components + Copyright (C) 2000, 2001, 2004, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.naming; + +import java.io.Serializable; +import java.util.Enumeration; + +/** + * Interface descriping a name build up from different components. + * The components are represented as Strings which are + * ordered from most significant to least significant. There are methods to + * get the number of components. Methods to get a particular component or group + * of components. Components can be added as Strings or + * Names and a component can be removed from any position in the + * Name. + * A Name can be compared to another Name and it can + * be checked if a particular Name starts or ends with the same + * components as another Name. Finally Names can be + * serialized and cloned. + *

+ * Since Names can be empty (have no components) methods that + * return a Name will never return null. + * + * @since 1.3 + * @author Anthony Green (green@redhat.com) + * @author Mark Wielaard (mark@klomp.org) + */ +public interface Name extends Cloneable, Serializable, Comparable +{ + // This class is implemented as gnu.javax.naming.ictxImpl.trans.GnuName + + long serialVersionUID = -3617482732056931635L; + + /** + * Returns the number of components of this Name. + * The returned number can be zero. + */ + int size(); + + /** + * Returns true if the number of components of this + * Name is zero, false otherwise. + */ + boolean isEmpty(); + + /** + * Returns a non-null (but possibly empty) Enumeration of the + * components of the Name as Strings. + */ + Enumeration getAll(); + + /** + * Gets the component at the given index. + * + * @exception ArrayIndexOutOfBoundsException if the given index is smaller + * then zero or greater then or equal to size(). + */ + String get(int i); + + /** + * Returns the components till the given index as a Name. + * The returned Name can be modified without changing the + * original. + * + * @param posn the ending position, exclusive + * + * @exception ArrayIndexOutOfBoundsException if the given index is smaller + * then zero or greater then or equal to size(). + */ + Name getPrefix(int posn); + + /** + * Returns the components from the given index till the end as a + * Name. + * The returned Name can be modified without changing the + * original. + * + * @param posn the starting position, inclusive. If it is equal to the size + * of the name, the empty name is returned. + * + * @exception ArrayIndexOutOfBoundsException if the given index is smaller + * then zero or greater then or equal to size(). + */ + Name getSuffix(int posn); + + /** + * Adds the given String component to the end of this + * Name. The method modifies the current Name and + * then returns it. + * + * @exception InvalidNameException if the given String is not a + * valid component for this Name. + */ + Name add(String comp) throws InvalidNameException; + + /** + * Inserts the given String component to this Name + * at the given index. The method modifies the current Name and + * then returns it. + * + * @exception ArrayIndexOutOfBoundsException if the given index is smaller + * then zero or greater then or equal to size(). + * @exception InvalidNameException if the given String is not a + * valid component for this Name. + */ + Name add(int posn, String comp) throws InvalidNameException; + + /** + * Adds all the components of the given Name to the end of this + * Name. The method modifies the current Name and + * then returns it. + * + * @exception InvalidNameException if any of the given components is not a + * valid component for this Name. + */ + Name addAll(Name suffix) throws InvalidNameException; + + /** + * Inserts all the components of the given Name to this + * Name at the given index. Components after this index + * (if any) are shifted up. The method modifies the current + * Name and then returns it. + * + * @exception ArrayIndexOutOfBoundsException if the given index is smaller + * then zero or greater then or equal to size(). + * @exception InvalidNameException if any of the given components is not a + * valid component for this Name. + */ + Name addAll(int posn, Name n) throws InvalidNameException; + + /** + * Removes the component at the given index from this Name. + * The method modifies the current Name and then returns it. + * + * @exception InvalidNameException if the given String is not a + * valid component for this Name. + */ + Object remove(int posn) throws InvalidNameException; + + /** + * Returns true if this Name starts with the + * components of the given Name, false otherwise. + */ + boolean startsWith(Name name); + + /** + * Returns true if this Name ends with the + * components of the given Name, false otherwise. + */ + boolean endsWith(Name name); + + /** + * Compares the given object to this Name. + * Returns a negative value if the given Object is smaller then + * this Name, a positive value if the Object is + * bigger, and zero if the are equal. If the Object is not of + * a class that can be compared to the class of this Name then + * a ClassCastException is thrown. Note that it is not + * guaranteed that Names implemented in different classes can + * be compared. The definition of smaller, bigger and equal is up to the + * actual implementing class. + */ + int compareTo(Object obj); + + /** + * Returns a clone of this Name. It will be a deep copy of + * all the components of the Name so that changes to components + * of the components does not change the component in this Name. + */ + Object clone(); +} diff --git a/libjava/classpath/javax/naming/NameAlreadyBoundException.java b/libjava/classpath/javax/naming/NameAlreadyBoundException.java new file mode 100644 index 000000000..07b92eee4 --- /dev/null +++ b/libjava/classpath/javax/naming/NameAlreadyBoundException.java @@ -0,0 +1,55 @@ +/* NameAlreadyBoundException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class NameAlreadyBoundException extends NamingException +{ + private static final long serialVersionUID = - 8491441000356780586L; + + public NameAlreadyBoundException () + { + super (); + } + + public NameAlreadyBoundException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/NameClassPair.java b/libjava/classpath/javax/naming/NameClassPair.java new file mode 100644 index 000000000..f4f9fda00 --- /dev/null +++ b/libjava/classpath/javax/naming/NameClassPair.java @@ -0,0 +1,198 @@ +/* NameClassPair.java -- + Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +import java.io.Serializable; + +/** + * NameClassPair represents the name-classname mapping pair + * of a binding in a context. + *

+ * Bindings are mappings of a name to an object and this class is used to + * specify the mapping of the name to the class type of the bound object. + * As classname the fully qualified classname is used. + *

+ * + * @author Tom Tromey (tromey@redhat.com) + * @since 1.3 + */ +public class NameClassPair implements Serializable +{ + private static final long serialVersionUID = 5620776610160863339L; + + /** + * Constructs an instance with the given name and classname. + * + * @param name the name of the binding relative to the target context + * (may not be null) + * @param className the name of the class. If null the bound + * object is also null + */ + public NameClassPair (String name, String className) + { + this (name, className, true); + } + + /** + * Constructs an instance with the given name and classname and a + * flag indicating if the name is relative to the target context. + * + * @param name the name of the binding (may not be null) + * @param className the name of the class. If null the bound + * object is also null + * @param isRelative flag indicating if the name is relative or not + */ + public NameClassPair (String name, String className, boolean isRelative) + { + this.name = name; + this.className = className; + this.isRel = isRelative; + } + + /** + * Returns the classname of the binding. + * @return The fully qualified classname or null if the + * bound object is null. + */ + public String getClassName () + { + return className; + } + + /** + * Returns the name of the binding. + * @return The name. + */ + public String getName () + { + return name; + } + + /** + * Checks whether the name is relative to the target context or not. + * @return true if the name is relative, + * false otherwise. + */ + public boolean isRelative () + { + return isRel; + } + + /** + * Sets the classname of the bound object. + * @param name the classname to set (maybe null) + */ + public void setClassName (String name) + { + this.className = name; + } + + /** + * Sets the name of the binding. + * @param name the name to set + */ + public void setName (String name) + { + this.name = name; + } + + /** + * Sets if the name is relative to the target context. + * @param r true to mark as relative + */ + public void setRelative (boolean r) + { + this.isRel = r; + } + + /** + * Sets the full name for this binding. Setting the full name by this + * method is the only way to initialize full names of bindings if + * supported by a specific naming system. + * + * @param fullName the full name of this binding. If not set or set to + * null the getNameInNamespace() method will + * throw an exception + * + * @see #getNameInNamespace() + * + * @since 1.5 + */ + public void setNameInNamespace(String fullName) + { + this.fullName = fullName; + } + + /** + * Returns the full name for this binding. The full name of a binding is + * defined as the absolute name in its own namespace and is not valid + * outside. + * + * @return The full name in the bindings namespace. + * @throws UnsupportedOperationException if no full name is applicable in + * the specific naming system. + * + * @see Context#getNameInNamespace() + * + * @since 1.5 + */ + public String getNameInNamespace() + { + if (this.fullName == null) + throw new UnsupportedOperationException(); + + return this.fullName; + } + + /** + * Returns the string representation. + * @return The string getName() + ":" + getClassName(). + */ + public String toString () + { + // Specified by class documentation. + return name + ":" + className; + } + + // These field names are fixed by the serialization spec. + private String name; + private String className; + private boolean isRel; + private String fullName; +} diff --git a/libjava/classpath/javax/naming/NameNotFoundException.java b/libjava/classpath/javax/naming/NameNotFoundException.java new file mode 100644 index 000000000..64e45f36f --- /dev/null +++ b/libjava/classpath/javax/naming/NameNotFoundException.java @@ -0,0 +1,55 @@ +/* NameNotFoundException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class NameNotFoundException extends NamingException +{ + private static final long serialVersionUID = - 8007156725367842053L; + + public NameNotFoundException () + { + super (); + } + + public NameNotFoundException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/NameParser.java b/libjava/classpath/javax/naming/NameParser.java new file mode 100644 index 000000000..c83200308 --- /dev/null +++ b/libjava/classpath/javax/naming/NameParser.java @@ -0,0 +1,60 @@ +/* NameParser.java -- JNDI name parser interface + Copyright (C) 2000, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +/** + * Parser the string representation of the given name into the {@link Name} + * representation. + * + * @see Context#getNameParser(String) + * @see Context#getNameParser(Name) + */ +public interface NameParser +{ + /** + * Parser the string name representation into the {@link Name} representation + * + * @param name the string representation of the name + * @return the {@link Name} representation of the name. + * @throws InvalidNameException if the name violates the syntax, expected by + * this parser + * @throws NamingException if some other naming exception occurs + */ + Name parse (String name) throws NamingException; +} diff --git a/libjava/classpath/javax/naming/NamingEnumeration.java b/libjava/classpath/javax/naming/NamingEnumeration.java new file mode 100644 index 000000000..cd0963d41 --- /dev/null +++ b/libjava/classpath/javax/naming/NamingEnumeration.java @@ -0,0 +1,89 @@ +/* NamingEnumeration.java -- The JNDI enumeration + Copyright (C) 2000, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +import java.util.Enumeration; + +/** + *

The specific type of enumeration that supports throwing various exceptions by + * the hasMore method. The exceptions are only thrown if the enumeration is + * scanned using {@link #next()} and {@link #hasMore()}. If the inherited + * {@link java.util.Enumeration#nextElement()} and + * {@link Enumeration#hasMoreElements()} are used instead, the exceptions are + * not throwed, and the enumeration is just iterated over available elements. + *

+ *

This enumeration becomes invalid after throwing the exception. If the + * exception has been thrown, not other method should be called of that + * enumeration.

+ */ +public interface NamingEnumeration extends Enumeration +{ + /** + * Returns the next element in this enumeration. The naming - specific + * exceptions are only throws after returning all still available elements of + * the enumeration. + * + * @return the next element of this enumeration + * @throws NamingException + */ + T next() throws NamingException; + + /** + * Checks if there are more unvisited elements in the enumeration, throwing + * exceptions if there are some unvisited, but not available elements. + * + * @return true if there are some unvisited elements, false otherwise. + * @throws PartialResultException if the enumeration, returned by the + * {@link Context#list(Name)} or other similar method contains only + * partial answer. + * @throws SizeLimitExceededException if remaining elements are not available + * because of the previously specified size limit. + * @throws NamingException + */ + boolean hasMore() throws NamingException; + + /** + * Immediately frees all resources, owned by this enumeration. If invoked, it + * must be the last method called for that enumeration. + * + * @throws NamingException + */ + void close() throws NamingException; + +} diff --git a/libjava/classpath/javax/naming/NamingException.java b/libjava/classpath/javax/naming/NamingException.java new file mode 100644 index 000000000..28b817210 --- /dev/null +++ b/libjava/classpath/javax/naming/NamingException.java @@ -0,0 +1,316 @@ +/* NamingException.java -- Superclass of all naming Exceptions + Copyright (C) 2000, 2001 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.naming; + +import gnu.java.lang.CPStringBuilder; + +import java.io.PrintStream; +import java.io.PrintWriter; + +/** + * Superclass of all naming Exceptions. + * Can contain extra information about the root cause of this exception + * (for example when the original exception was not a subclass of + * NamingException), the part of the Name that + * could be resolved (including the Object it resolved to) + * and the part of the Name that could not be resolved when + * the exception occured. + * + * @since 1.3 + * @author Anthony Green (green@redhat.com) + * @author Mark Wielaard (mark@klomp.org) + */ +public class NamingException extends Exception +{ + private static final long serialVersionUID = -1299181962103167177L; + + /** + * The root cause of this exception. Might be null. Set by calling + * setRootCause(), can be accessed by calling + * getRootCause(). + */ + protected Throwable rootException; + + /** + * If the exception was caused while resolving a Name then + * this field contains that part of the name that could be resolved. + * Field might be null. Set by calling setResolvedName(). + * Can be accessed by calling getResolvedName. + */ + protected Name resolvedName; + + /** + * If the exception was caused while resolving a Name then + * this field contains the object that part of the name could be resolved to. + * Field might be null. Set by calling setResolvedObj(). + * Can be accessed by calling getResolvedObj. + */ + protected Object resolvedObj; + + /** + * If the exception was caused while resolving a Name then + * this field contains that part of the name that could not be resolved. + * Field might be null. Set by calling setRemainingName(). + * The field can be extended by calling appendRemainingName() + * or appendRemainingComponent(). + * Can be accessed by calling getRemainingName. + */ + protected Name remainingName; + + /** + * Creates a new NamingException without a message. Does not set any of the + * rootException, resolvedName, + * resolvedObj or remainingObject fields. + * These fields can be set later. + */ + public NamingException () + { + super(); + } + + /** + * Creates a new NamingException with a detailed message. Does not set + * the rootException, resolvedName, + * resolvedObj or remainingObject, fields. + * These fields can be set later. + */ + public NamingException (String msg) + { + super(msg); + } + + /** + * Gets the root cause field rootException of this Exception. + */ + public Throwable getRootCause () + { + return rootException; + } + + /** + * Sets the root cause field rootException of this Exception. + */ + public void setRootCause (Throwable e) + { + rootException = e; + } + + /** + * Gets the part of the name that could be resolved before this exception + * happend. Returns the resolvedName field of this Exception. + */ + public Name getResolvedName () + { + return resolvedName; + } + + /** + * Sets the part of the name that could be resolved before this exception + * happend. Sets the resolvedName field of this Exception. + */ + public void setResolvedName (Name name) + { + resolvedName = name; + } + + /** + * Gets the Object to which (part of) the name could be resolved before this + * exception happend. Returns the resolvedObj field of this + * Exception. + */ + public Object getResolvedObj () + { + return resolvedObj; + } + + /** + * Sets the Object to which (part of) the name could be resolved before this + * exception happend. Sets the resolvedObj field of this + * Exception. + */ + public void setResolvedObj (Object o) + { + resolvedObj = o; + } + + /** + * Gets the part of the name that could not be resolved before this exception + * happend. Returns the remainingName field of this Exception. + */ + public Name getRemainingName () + { + return remainingName; + } + + /** + * Sets the part of the name that could be resolved before this exception + * happend. Sets the resolvedName field of this Exception. + * The field can be extended by calling appendRemainingName() + * or appendRemainingComponent(). + */ + public void setRemainingName (Name name) + { + remainingName = name; + } + + /** + * Adds the given Name to the remainingName field. + * Does nothing when name is null or when a + * InvalidNameException is thrown when adding the name. + * + * @see Name#addAll(Name) + */ + public void appendRemainingName (Name name) + { + if (name != null) + try + { + remainingName.addAll(name); + } + catch(InvalidNameException ine) { /* ignored */ } + } + + /** + * Adds the given String to the remainingName field. + * Does nothing when name is null or when a + * InvalidNameException is thrown when adding the component. + * + * @see Name#add(String) + */ + public void appendRemainingComponent (String name) + { + if (name != null) + try + { + remainingName.add(name); + } + catch(InvalidNameException ine) { /* ignored */ } + } + + /** + * Gets the message given to the constructor or null if no message was given. + * + * @see Throwable#getMessage() + */ + public String getExplanation() + { + return getMessage(); + } + + /** + * Returns a String representation of this exception and possibly including + * the part object that could be resolved if the given flag is set to true. + * Always includes the root cause and the remaining name if not null. + */ + public String toString(boolean objectInfo) + { + CPStringBuilder sb = new CPStringBuilder(super.toString()); + Throwable cause = getRootCause(); + if (cause != null) + { + sb.append(" caused by "); + sb.append(cause); + } + Name remaining = getRemainingName(); + if (remaining != null) + { + sb.append(" [remainingName: "); + sb.append(remaining); + } + Object resolved = getResolvedObj(); + if (objectInfo && resolved != null) + { + if (remainingName == null) + sb.append(" ["); + else + sb.append(", "); + sb.append("resolvedObj: "); + sb.append(resolved); + } + if ((remaining != null) || (objectInfo && resolved != null)) + sb.append(']'); + + return sb.toString(); + } + + /** + * Returns a string representation of this exception. + * Calls toString(false). + */ + public String toString() + { + return toString(false); + } + /** + * Prints the stacktrace of this exception or of the root cause if not null. + */ + public void printStackTrace() + { + Throwable cause = getRootCause(); + if (cause != null) + cause.printStackTrace(); + else + super.printStackTrace(); + } + + /** + * Prints the stacktrace of this exception or of the root cause if not null + * to the given PrintStream. + */ + public void printStackTrace(PrintStream ps) + { + Throwable cause = getRootCause(); + if (cause != null) + cause.printStackTrace(ps); + else + super.printStackTrace(ps); + } + + /** + * Prints the stacktrace of this exception or of the root cause if not null + * to the given PrintWriter. + */ + public void printStackTrace(PrintWriter pw) + { + Throwable cause = getRootCause(); + if (cause != null) + cause.printStackTrace(pw); + else + super.printStackTrace(pw); + } +} diff --git a/libjava/classpath/javax/naming/NamingSecurityException.java b/libjava/classpath/javax/naming/NamingSecurityException.java new file mode 100644 index 000000000..34ad6dfa4 --- /dev/null +++ b/libjava/classpath/javax/naming/NamingSecurityException.java @@ -0,0 +1,55 @@ +/* NamingSecurityException.java -- + Copyright (C) 2000, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public abstract class NamingSecurityException extends NamingException +{ + private static final long serialVersionUID = 5855287647294685775L; + + public NamingSecurityException () + { + super (); + } + + public NamingSecurityException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/NoInitialContextException.java b/libjava/classpath/javax/naming/NoInitialContextException.java new file mode 100644 index 000000000..a51f56766 --- /dev/null +++ b/libjava/classpath/javax/naming/NoInitialContextException.java @@ -0,0 +1,55 @@ +/* NoInitialContextException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class NoInitialContextException extends NamingException +{ + private static final long serialVersionUID = - 3413733186901258623L; + + public NoInitialContextException() + { + super(); + } + + public NoInitialContextException(String msg) + { + super(msg); + } +} diff --git a/libjava/classpath/javax/naming/NoPermissionException.java b/libjava/classpath/javax/naming/NoPermissionException.java new file mode 100644 index 000000000..7934e0906 --- /dev/null +++ b/libjava/classpath/javax/naming/NoPermissionException.java @@ -0,0 +1,55 @@ +/* NoPermissionException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class NoPermissionException extends NamingSecurityException +{ + private static final long serialVersionUID = 8395332708699751775L; + + public NoPermissionException () + { + super (); + } + + public NoPermissionException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/NotContextException.java b/libjava/classpath/javax/naming/NotContextException.java new file mode 100644 index 000000000..a543a38e3 --- /dev/null +++ b/libjava/classpath/javax/naming/NotContextException.java @@ -0,0 +1,55 @@ +/* NotContextException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class NotContextException extends NamingException +{ + private static final long serialVersionUID = 849752551644540417L; + + public NotContextException () + { + super (); + } + + public NotContextException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/OperationNotSupportedException.java b/libjava/classpath/javax/naming/OperationNotSupportedException.java new file mode 100644 index 000000000..d813403de --- /dev/null +++ b/libjava/classpath/javax/naming/OperationNotSupportedException.java @@ -0,0 +1,54 @@ +/* OperationNotSupportedException.java -- + Copyright (C) 2000, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +public class OperationNotSupportedException extends NamingException +{ + private static final long serialVersionUID = 5493232822427682064L; + + public OperationNotSupportedException() + { + super(); + } + + public OperationNotSupportedException(String msg) + { + super(msg); + } +} diff --git a/libjava/classpath/javax/naming/PartialResultException.java b/libjava/classpath/javax/naming/PartialResultException.java new file mode 100644 index 000000000..dd2813b4b --- /dev/null +++ b/libjava/classpath/javax/naming/PartialResultException.java @@ -0,0 +1,59 @@ +/* PartialResultException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +/** + * Thrown from the {@link javax.naming.NamingEnumeration}, this exception + * indicates that the enumeration represents only part of the existing + * elements that would be an answer to the specified request. + */ +public class PartialResultException extends NamingException +{ + private static final long serialVersionUID = 2572144970049426786L; + + public PartialResultException () + { + super (); + } + + public PartialResultException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/RefAddr.java b/libjava/classpath/javax/naming/RefAddr.java new file mode 100644 index 000000000..6e4de1cfc --- /dev/null +++ b/libjava/classpath/javax/naming/RefAddr.java @@ -0,0 +1,142 @@ +/* RefAddr.java -- Abstract superclass of addresses used in References + Copyright (C) 2000, 2001 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.naming; + +import java.io.Serializable; + +/** + * Abstract superclass of addresses used in References. + * A Reference object contains a Vector of + * RefAddrs which are used to reference/address the object. + * This abstract superclass keeps track of the type of address, which will be + * returned by getType(). And defines a abstract method + * getContent() which must be implemented in concrete subclasses + * such as BinaryRefAddr and StringRefAddr. + * + * @see Reference + * @see BinaryRefAddr + * @see StringRefAddr + * @since 1.3 + * @author Anthony Green (green@redhat.com) + * @author Mark Wielaard (mark@klomp.org) + */ +public abstract class RefAddr implements Serializable +{ + /** + * The string resprenstation of the type of address. + * Set by the constructor and returned by the getType() method. + */ + protected String addrType; + + /** + * Protected constructor for use by subclasses. + * Sets the addrType field of this object to the supplied String. + * + * @exception NullPointerException if the supplied String is null. + */ + protected RefAddr(String addrType) + { + if (addrType == null) + throw new NullPointerException("addrType cannot be null"); + + this.addrType = addrType; + } + + /** + * Returns the non-null address type given to the constructor. + */ + public String getType() + { + return addrType; + } + + /** + * Returns the possibly null content of this RefAddr. + * The actual value is defined by the non-abstract subclass. + */ + public abstract Object getContent(); + + /** + * Checks if the object is a RefAddr with the same type and content. + * + * @return true if the given object is an instance of RefAddr, the addrType + * is the same as this addrType and the content is equals to the + * content of this object. + */ + public boolean equals(Object o) + { + if (o instanceof RefAddr) + { + RefAddr refAddr = (RefAddr) o; + if (this.getType().equals(refAddr.getType())) + { + Object c1 = this.getContent(); + Object c2 = refAddr.getContent(); + if (c1 == null) + return c2 == null; + else + return c1.equals(c2); + } + } + return false; + } + + /** + * Returns the hashCode which is the hasCode of the String returned by + * getType() plus the hashCode of the Object returned by + * getContent (when not null). + */ + public int hashCode() + { + int result = getType().hashCode(); + Object o = getContent(); + if (o != null) + result += o.hashCode(); + + return result; + } + + /** + * Returns a String representation of the RefAddr. + * Should only be used for debugging purposes. + */ + public String toString() + { + return "[RefAddr type: " + getType() + " content: " + getContent() + ']'; + } +} diff --git a/libjava/classpath/javax/naming/Reference.java b/libjava/classpath/javax/naming/Reference.java new file mode 100644 index 000000000..6a2626da0 --- /dev/null +++ b/libjava/classpath/javax/naming/Reference.java @@ -0,0 +1,306 @@ +/* Reference.java -- + Copyright (C) 2000, 2001, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +import java.io.Serializable; +import java.util.Enumeration; +import java.util.Vector; + +/** + * This class represents a reference to an object that is located outside of the + * naming/directory system. + * + * @see Referenceable + * + * @author Tom Tromey (tromey@redhat.com) + */ +public class Reference implements Cloneable, Serializable +{ + private static final long serialVersionUID = - 1673475790065791735L; + + /** + * The list of addresses, stored in this reference. The object may be + * have by several different addresses. + */ + protected Vector addrs; + + /** + * The name of the class factory to create an instance of the object, + * referenced by this reference. + */ + protected String classFactory; + + /** + * The location, from where the class factory should be loaded. + */ + protected String classFactoryLocation; + + /** + * The name of the class of the object, to that this reference refers. + */ + protected String className; + + /** + * Create a new reference that is referencting to the object of the + * specified class. + */ + public Reference (String className) + { + this.className = className; + addrs = new Vector (); + } + + /** + * Create a new reference that is referencing to the object of the + * specified class with the given address. + */ + public Reference (String className, RefAddr addr) + { + this.className = className; + addrs = new Vector (); + addrs.add (addr); + } + + /** + * Create a new reference that is referencing to the object of the + * specified class, specifying the class and location of the factory that + * produces these objects. + * + * @param className the object class name + * @param factoryClassName the object factory class name + * @param factoryLocation the object factory location + */ + public Reference (String className, String factoryClassName, + String factoryLocation) + { + this.className = className; + this.classFactory = factoryClassName; + this.classFactoryLocation = factoryLocation; + addrs = new Vector (); + } + + /** + * Create a new reference that is referencing to the object of the + * specified class, specifying the class and location of the factory that + * produces these objects and also the address of this object. + * + * @param className the object class name + * @param addr the address of the object + * @param factoryClassName the object factory class name + * @param factoryLocation the object factory location + */ + public Reference (String className, RefAddr addr, + String factoryClassName, String factoryLocation) + { + this.className = className; + this.classFactory = factoryClassName; + this.classFactoryLocation = factoryLocation; + addrs = new Vector (); + addrs.add (addr); + } + + /** + * Add the new address for this object at the given position of the + * address list. + */ + public void add (int posn, RefAddr addr) + { + addrs.add (posn, addr); + } + + /** + * Appends the new object address to the end of the address list. + */ + public void add (RefAddr addr) + { + addrs.add (addr); + } + + /** + * Removes all defined addresses of the object. + */ + public void clear () + { + addrs.clear (); + } + + public Object clone () + { + Reference r = new Reference (className, classFactory, + classFactoryLocation); + r.addrs = (Vector) addrs.clone (); + return r; + } + + // Convenience function. + private boolean equals (String a, String b) + { + return (a == null) ? (b == null) : a.equals (b); + } + + /** + * Compares two addresses for equality, by value. + */ + public boolean equals (Object obj) + { + if (! (obj instanceof Reference)) + return false; + Reference r = (Reference) obj; + return (equals (classFactory, r.classFactory) + && equals (classFactoryLocation, r.classFactoryLocation) + && equals (className, r.className) + && addrs.equals (r.addrs)); + } + + /** + * Get the address of this object at the given position. + */ + public RefAddr get (int posn) + { + return addrs.get (posn); + } + + /** + * Get the given type of address for this object. + * + * @param addrType the needed type of address + * + * @return the address of this object, having the specified type. If there + * is no address of such type, null is returned. + */ + public RefAddr get (String addrType) + { + for (int i = 0; i < addrs.size (); ++i) + { + RefAddr r = addrs.get (i); + if (addrType.equals (r.getType ())) + return r; + } + return null; + } + + /** + * Get the enumeration over all defined addresses of the object. + */ + public Enumeration getAll () + { + return addrs.elements (); + } + + /** + * Get the name of the class of the referenced object. + * + * @see #className + */ + public String getClassName () + { + return className; + } + + /** + * Get the location of the factory class of the referenced object. + * + * @see #classFactoryLocation + */ + public String getFactoryClassLocation () + { + return classFactoryLocation; + } + + /** + * Get the name of the factory class of the referenced object + * + * @see #classFactory + */ + public String getFactoryClassName () + { + return classFactory; + } + + /** + * Get the hashcode of this reference. + * + * @return the sum of the hash codes of the addresses. + */ + public int hashCode () + { + // The spec says the hash code is the sum of the hash codes of the + // addresses. It does not mention the other fields. + int h = 0; + for (int i = 0; i < addrs.size (); ++i) + h += addrs.get (i).hashCode (); + return h; + } + + /** + * Remove the address at the given position. + * + * @param posn the position of the address to remove + * + * @return the removed address + */ + public Object remove (int posn) + { + return addrs.remove (posn); + } + + /** + * Return the number of the defined addresses. + */ + public int size () + { + return addrs.size (); + } + + /** + * Return the string representation. + */ + public String toString () + { + String x = getClass ().toString () + "["; + for (int i = 0; i < addrs.size (); ++i) + { + if (i > 0) + x += ","; + x += addrs.get (i).toString (); + } + return x + "]"; + } + +} diff --git a/libjava/classpath/javax/naming/Referenceable.java b/libjava/classpath/javax/naming/Referenceable.java new file mode 100644 index 000000000..ed8e4d444 --- /dev/null +++ b/libjava/classpath/javax/naming/Referenceable.java @@ -0,0 +1,56 @@ +/* Referenceable.java -- + Copyright (C) 2000, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +/** + * The object, implementing this interface, can provided the + * {@link Reference} about itself. + */ +public interface Referenceable +{ + /** + * Get the reference about this object. + * + * @return the reference about this object, cannot be null. + * + * @throws NamingException if the naming exception has been raised while + * retrieving the reference. + */ + Reference getReference() throws NamingException; +} diff --git a/libjava/classpath/javax/naming/ReferralException.java b/libjava/classpath/javax/naming/ReferralException.java new file mode 100644 index 000000000..b596af02e --- /dev/null +++ b/libjava/classpath/javax/naming/ReferralException.java @@ -0,0 +1,68 @@ +/* ReferralException.java -- + Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +import java.util.Hashtable; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 14, 2001 + */ + +public abstract class ReferralException extends NamingException +{ + private static final long serialVersionUID = -2881363844695698876L; + + protected ReferralException () + { + super (); + } + + protected ReferralException (String msg) + { + super (msg); + } + + public abstract Object getReferralInfo(); + public abstract Context getReferralContext() throws NamingException; + public abstract Context getReferralContext(Hashtable env) + throws NamingException; + public abstract boolean skipReferral(); + public abstract void retryReferral(); +} diff --git a/libjava/classpath/javax/naming/ServiceUnavailableException.java b/libjava/classpath/javax/naming/ServiceUnavailableException.java new file mode 100644 index 000000000..6a07bc613 --- /dev/null +++ b/libjava/classpath/javax/naming/ServiceUnavailableException.java @@ -0,0 +1,55 @@ +/* ServiceUnavailableException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class ServiceUnavailableException extends NamingException +{ + private static final long serialVersionUID = - 4996964726566773444L; + + public ServiceUnavailableException () + { + super (); + } + + public ServiceUnavailableException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/SizeLimitExceededException.java b/libjava/classpath/javax/naming/SizeLimitExceededException.java new file mode 100644 index 000000000..8f0523fa4 --- /dev/null +++ b/libjava/classpath/javax/naming/SizeLimitExceededException.java @@ -0,0 +1,60 @@ +/* SizeLimitExceededException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + +/** + * Thrown from the {@link javax.naming.NamingEnumeration}, this exception + * indicates that there are more elements than the previously specified + * size limit. Hence the enumeration represents only part of the existing + * elements that would be an answer to the specified request. + */ +public class SizeLimitExceededException extends LimitExceededException +{ + private static final long serialVersionUID = 7129289564879168579L; + + public SizeLimitExceededException () + { + super (); + } + + public SizeLimitExceededException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/StringRefAddr.java b/libjava/classpath/javax/naming/StringRefAddr.java new file mode 100644 index 000000000..02f072ecf --- /dev/null +++ b/libjava/classpath/javax/naming/StringRefAddr.java @@ -0,0 +1,75 @@ +/* StringRefAddr.java -- RefAddr that uses a String as content. + Copyright (C) 2000, 2001 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.naming; + +/** + * RefAddr that uses a String as content. + * This can for example be used to address things through URLs. + * + * @see Reference + * @since 1.3 + * @author Anthony Green (green@redhat.com) + * @author Mark Wielaard (mark@klomp.org) + */ +public class StringRefAddr extends RefAddr +{ + private static final long serialVersionUID = -8913762495138505527L; + + /** + * The possibly null content of this RefAddr. + * Set by the constructor and returned by getContent. + */ + private final String contents; + + /** + * Contructs a new StringRefAddr with the given type and content. + */ + public StringRefAddr (String addrType, String contents) + { + super(addrType); + this.contents = contents; + } + + /** + * Returns the String contents as given to the constructor. + */ + public Object getContent () + { + return contents; + } +} diff --git a/libjava/classpath/javax/naming/TimeLimitExceededException.java b/libjava/classpath/javax/naming/TimeLimitExceededException.java new file mode 100644 index 000000000..95188d259 --- /dev/null +++ b/libjava/classpath/javax/naming/TimeLimitExceededException.java @@ -0,0 +1,55 @@ +/* TimeLimitExceededException.java -- + Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming; + + +public class TimeLimitExceededException extends LimitExceededException +{ + private static final long serialVersionUID = - 3597009011385034696L; + + public TimeLimitExceededException () + { + super (); + } + + public TimeLimitExceededException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/directory/Attribute.java b/libjava/classpath/javax/naming/directory/Attribute.java new file mode 100644 index 000000000..d29e1eae0 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/Attribute.java @@ -0,0 +1,70 @@ +/* Attribute.java -- + Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import java.io.Serializable; + +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 14, 2001 + */ +public interface Attribute extends Cloneable, Serializable +{ + long serialVersionUID = 8707690322213556804L; + + NamingEnumeration getAll() throws NamingException; + Object get() throws NamingException; + int size(); + String getID(); + boolean contains(Object attrVal); + boolean add(Object attrVal); + boolean remove(Object attrval); + void clear(); + DirContext getAttributeSyntaxDefinition() throws NamingException; + DirContext getAttributeDefinition() throws NamingException; + Object clone(); + boolean isOrdered(); + Object get(int ix) throws NamingException; + Object remove(int ix); + void add(int ix, Object attrVal); + Object set(int ix, Object attrVal); +} diff --git a/libjava/classpath/javax/naming/directory/AttributeInUseException.java b/libjava/classpath/javax/naming/directory/AttributeInUseException.java new file mode 100644 index 000000000..08f337c5c --- /dev/null +++ b/libjava/classpath/javax/naming/directory/AttributeInUseException.java @@ -0,0 +1,56 @@ +/* AttributeInUseException.java -- + Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.NamingException; + +public class AttributeInUseException extends NamingException +{ + private static final long serialVersionUID = 4437710305529322564L; + + public AttributeInUseException () + { + super (); + } + + public AttributeInUseException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/directory/AttributeModificationException.java b/libjava/classpath/javax/naming/directory/AttributeModificationException.java new file mode 100644 index 000000000..9614bac13 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/AttributeModificationException.java @@ -0,0 +1,78 @@ +/* AttributeModificationException.java -- + Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.NamingException; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 14, 2001 + */ + +public class AttributeModificationException extends NamingException +{ + private static final long serialVersionUID = 8060676069678710186L; + // Serialized fields. + private ModificationItem[] unexecs; + + public AttributeModificationException () + { + super (); + } + + public AttributeModificationException (String msg) + { + super (msg); + } + + public void setUnexecutedModifications(ModificationItem[] e) + { + unexecs = e; + } + + public ModificationItem[] getUnexecutedModifications() + { + return unexecs; + } + + public String toString() + { + return super.toString () + ": " + unexecs[0].toString (); + } +} diff --git a/libjava/classpath/javax/naming/directory/Attributes.java b/libjava/classpath/javax/naming/directory/Attributes.java new file mode 100644 index 000000000..50df17c2d --- /dev/null +++ b/libjava/classpath/javax/naming/directory/Attributes.java @@ -0,0 +1,61 @@ +/* Attributes.java -- + Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import java.io.Serializable; + +import javax.naming.NamingEnumeration; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 14, 2001 + */ + +public interface Attributes extends Cloneable, Serializable +{ + boolean isCaseIgnored(); + int size(); + Attribute get(String attrID); + NamingEnumeration getAll(); + NamingEnumeration getIDs(); + Attribute put(String attrID, Object val); + Attribute put(Attribute attr); + Attribute remove(String attrID); + Object clone(); +} diff --git a/libjava/classpath/javax/naming/directory/BasicAttribute.java b/libjava/classpath/javax/naming/directory/BasicAttribute.java new file mode 100644 index 000000000..65b44169e --- /dev/null +++ b/libjava/classpath/javax/naming/directory/BasicAttribute.java @@ -0,0 +1,358 @@ +/* BasicAttribute.java -- + Copyright (C) 2000, 2001, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.NoSuchElementException; +import java.util.Vector; + +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.OperationNotSupportedException; + +/** + * @author Tom Tromey (tromey@redhat.com) + * @date June 20, 2001 + * @since 1.3 + */ +public class BasicAttribute implements Attribute +{ + private static final long serialVersionUID = 6743528196119291326L; + + /** The ID of this attribute. */ + protected String attrID; + /** True if this attribute's values are ordered. */ + protected boolean ordered; + /** Values for this attribute. */ + protected transient Vector values; + + // Used by cloning. + private BasicAttribute () + { + } + + public BasicAttribute (String id) + { + this (id, false); + } + + public BasicAttribute (String id, boolean ordered) + { + attrID = id; + this.ordered = ordered; + values = new Vector (); + } + + public BasicAttribute (String id, Object value) + { + this (id, value, false); + } + + public BasicAttribute (String id, Object value, boolean ordered) + { + attrID = id; + this.ordered = ordered; + values = new Vector (); + values.add (value); + } + + public void add (int index, Object val) + { + if (! ordered && contains (val)) + throw new IllegalStateException ("value already in attribute"); + values.add (index, val); + } + + public boolean add (Object val) + { + if (! ordered && contains (val)) + throw new IllegalStateException ("value already in attribute"); + return values.add (val); + } + + public void clear () + { + values.clear (); + } + + public Object clone () + { + BasicAttribute c = new BasicAttribute (); + c.attrID = attrID; + c.ordered = ordered; + c.values = (Vector) values.clone (); + return c; + } + + public boolean contains (Object val) + { + for (int i = 0; i < values.size (); ++i) + { + if (equals (val, values.get (i))) + return true; + } + + return false; + } + + public boolean equals (Object obj) + { + if (! (obj instanceof BasicAttribute)) + return false; + BasicAttribute b = (BasicAttribute) obj; + + if (ordered != b.ordered + || ! attrID.equals (b.attrID) + || values.size () != b.values.size ()) + return false; + + for (int i = 0; i < values.size (); ++i) + { + boolean ok = false; + if (ordered) + ok = equals (values.get (i), b.values.get (i)); + else + { + for (int j = 0; j < b.values.size (); ++j) + { + if (equals (values.get (i), b.values.get (j))) + { + ok = true; + break; + } + } + } + + if (! ok) + return false; + } + + return true; + } + + public Object get () + throws NamingException + { + if (values.size () == 0) + throw new NoSuchElementException ("no values"); + return get (0); + } + + public Object get (int index) + throws NamingException + { + return values.get (index); + } + + public NamingEnumeration getAll () + throws NamingException + { + return new BasicAttributeEnumeration (); + } + + public DirContext getAttributeDefinition () + throws OperationNotSupportedException, NamingException + { + throw new OperationNotSupportedException (); + } + + public DirContext getAttributeSyntaxDefinition () + throws OperationNotSupportedException, NamingException + { + throw new OperationNotSupportedException (); + } + + public String getID () + { + return attrID; + } + + public int hashCode () + { + int val = attrID.hashCode (); + for (int i = 0; i < values.size (); ++i) + { + Object o = values.get (i); + if (o == null) + { + // Nothing. + } + else if (o instanceof Object[]) + { + Object[] a = (Object[]) o; + for (int j = 0; j < a.length; ++j) + val += a[j].hashCode (); + } + else + val += o.hashCode (); + } + + return val; + } + + public boolean isOrdered () + { + return ordered; + } + + public Object remove (int index) + { + return values.remove (index); + } + + public boolean remove (Object val) + { + for (int i = 0; i < values.size (); ++i) + { + if (equals (val, values.get (i))) + { + values.remove (i); + return true; + } + } + + return false; + } + + public Object set (int index, Object val) + { + if (! ordered && contains (val)) + throw new IllegalStateException ("value already in attribute"); + return values.set (index, val); + } + + public int size () + { + return values.size (); + } + + public String toString () + { + String r = attrID; + for (int i = 0; i < values.size (); ++i) + r += ";" + values.get (i).toString (); + return r; + } + + // This is used for testing equality of two Objects according to our + // local rules. + private boolean equals (Object one, Object two) + { + if (one == null) + return two == null; + + if (one instanceof Object[]) + { + if (! (two instanceof Object[])) + return false; + + Object[] aone = (Object[]) one; + Object[] atwo = (Object[]) two; + + if (aone.length != atwo.length) + return false; + + for (int i = 0; i < aone.length; ++i) + { + if (! aone[i].equals (atwo[i])) + return false; + } + + return true; + } + + return one.equals (two); + } + + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + s.defaultReadObject(); + int size = s.readInt(); + values = new Vector(size); + for (int i=0; i < size; i++) + values.add(s.readObject()); + } + + private void writeObject(ObjectOutputStream s) throws IOException + { + s.defaultWriteObject(); + s.writeInt(values.size()); + for (int i=0; i < values.size(); i++) + s.writeObject(values.get(i)); + } + + // Used when enumerating this attribute. + private class BasicAttributeEnumeration implements NamingEnumeration + { + int where = 0; + + public BasicAttributeEnumeration () + { + } + + public void close () throws NamingException + { + } + + public boolean hasMore () throws NamingException + { + return hasMoreElements (); + } + + public Object next () throws NamingException + { + return nextElement (); + } + + public boolean hasMoreElements () + { + return where < values.size (); + } + + public Object nextElement () throws NoSuchElementException + { + if (where == values.size ()) + throw new NoSuchElementException ("no more elements"); + return values.get (where++); + } + } +} diff --git a/libjava/classpath/javax/naming/directory/BasicAttributes.java b/libjava/classpath/javax/naming/directory/BasicAttributes.java new file mode 100644 index 000000000..8b607a8cc --- /dev/null +++ b/libjava/classpath/javax/naming/directory/BasicAttributes.java @@ -0,0 +1,284 @@ +/* BasicAttributes.java -- + Copyright (C) 2000, 2001, 2004, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.NoSuchElementException; +import java.util.Vector; + +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; + +/** + * @author Tom Tromey (tromey@redhat.com) + * @date June 22, 2001 + */ +public class BasicAttributes implements Attributes +{ + private static final long serialVersionUID = 4980164073184639448L; + + public BasicAttributes () + { + this (false); + } + + public BasicAttributes (boolean ignoreCase) + { + this.ignoreCase = ignoreCase; + this.attributes = new Vector(); + } + + public BasicAttributes (String attrID, Object val) + { + this (attrID, val, false); + } + + public BasicAttributes (String attrID, Object val, boolean ignoreCase) + { + this.ignoreCase = ignoreCase; + attributes = new Vector(); + attributes.add (new BasicAttribute (attrID, val)); + } + + public Object clone () + { + // Slightly inefficient as we make a garbage Vector here. + BasicAttributes ba = new BasicAttributes (ignoreCase); + ba.attributes = (Vector) attributes.clone (); + return ba; + } + + /** + * Returns true if and only if the given Object is an instance of + * Attributes, the given attributes both do or don't ignore case for + * IDs and the collection of attributes is the same. + */ + public boolean equals (Object obj) + { + if (! (obj instanceof Attributes)) + return false; + + Attributes bs = (Attributes) obj; + if (ignoreCase != bs.isCaseIgnored() + || attributes.size () != bs.size ()) + return false; + + NamingEnumeration bas = bs.getAll(); + while (bas.hasMoreElements()) + { + Attribute a = (Attribute) bas.nextElement(); + Attribute b = get(a.getID ()); + if (! a.equals(b)) + return false; + } + + return true; + } + + public Attribute get (String attrID) + { + for (int i = 0; i < attributes.size (); ++i) + { + Attribute at = attributes.get (i); + if ((ignoreCase && attrID.equalsIgnoreCase (at.getID ())) + || (! ignoreCase && attrID.equals (at.getID ()))) + return at; + } + + return null; + } + + public NamingEnumeration getAll () + { + return new BasicAttributesEnumeration(); + } + + public NamingEnumeration getIDs () + { + final NamingEnumeration attrs = getAll(); + return new NamingEnumeration() { + public boolean hasMore() throws NamingException + { + return attrs.hasMore(); + } + + public boolean hasMoreElements() + { + return attrs.hasMoreElements(); + } + + public String next() throws NamingException + { + return attrs.next().getID(); + } + + public String nextElement() + { + return attrs.nextElement().getID(); + } + + public void close() throws NamingException + { + attrs.close(); + } + }; + } + + public int hashCode () + { + int val = 0; + for (int i = 0; i < attributes.size (); ++i) + val += attributes.get (i).hashCode (); + return val; + } + + public boolean isCaseIgnored () + { + return ignoreCase; + } + + public Attribute put (Attribute attr) + { + Attribute r = remove (attr.getID ()); + attributes.add (attr); + return r; + } + + public Attribute put (String attrID, Object val) + { + return put (new BasicAttribute (attrID, val)); + } + + public Attribute remove (String attrID) + { + for (int i = 0; i < attributes.size (); ++i) + { + Attribute at = (Attribute) attributes.get (i); + if ((ignoreCase && attrID.equalsIgnoreCase (at.getID ())) + || (! ignoreCase && attrID.equals (at.getID ()))) + { + attributes.remove (i); + return at; + } + } + + return null; + } + + public int size () + { + return attributes.size (); + } + + public String toString () + { + String r = ""; + for (int i = 0; i < attributes.size (); ++i) + { + if (i > 0) + r += "; "; + r += attributes.get (i).toString (); + } + return r; + } + + // This is set by the serialization spec. + private boolean ignoreCase; + // Package-private to avoid a trampoline. + transient Vector attributes; + + private void readObject(ObjectInputStream s) throws IOException, + ClassNotFoundException + { + s.defaultReadObject(); + int size = s.readInt(); + attributes = new Vector(size); + for (int i = 0; i < size; i++) + attributes.add((Attribute) s.readObject()); + } + + private void writeObject(ObjectOutputStream s) throws IOException + { + s.defaultWriteObject(); + s.writeInt(attributes.size()); + for (int i = 0; i < attributes.size(); i++) + s.writeObject(attributes.get(i)); + } + + // Used when enumerating. + private class BasicAttributesEnumeration + implements NamingEnumeration + { + int where = 0; + + public BasicAttributesEnumeration () + { + } + + public void close () throws NamingException + { + } + + public boolean hasMore () throws NamingException + { + return hasMoreElements (); + } + + public Attribute next () throws NamingException + { + return nextElement (); + } + + public boolean hasMoreElements () + { + return where < attributes.size (); + } + + public Attribute nextElement () throws NoSuchElementException + { + if (where >= attributes.size ()) + throw new NoSuchElementException ("no more elements"); + Attribute at = attributes.get (where); + ++where; + return at; + } + } +} diff --git a/libjava/classpath/javax/naming/directory/DirContext.java b/libjava/classpath/javax/naming/directory/DirContext.java new file mode 100644 index 000000000..d7d94a345 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/DirContext.java @@ -0,0 +1,103 @@ +/* DirContext.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 13, 2001 + */ + +public interface DirContext extends Context +{ + int ADD_ATTRIBUTE = 1; + int REPLACE_ATTRIBUTE = 2; + int REMOVE_ATTRIBUTE = 3; + + Attributes getAttributes (String name) throws NamingException; + Attributes getAttributes (String name, String[] attrIds) throws NamingException; + Attributes getAttributes (Name name) throws NamingException; + Attributes getAttributes(Name name, String[] attrIds) throws NamingException; + void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException; + void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException; + void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException; + void modifyAttributes(String name, ModificationItem[] mods) throws NamingException; + void bind(Name name, Object obj, Attributes attrs) throws NamingException; + void bind(String name, Object obj, Attributes attrs) throws NamingException; + void rebind(Name name, Object obj, Attributes attrs) throws NamingException; + void rebind(String name, Object obj, Attributes attrs) throws NamingException; + DirContext createSubcontext(Name name, Attributes attrs) throws NamingException; + DirContext createSubcontext(String name, Attributes attrs) throws NamingException; + DirContext getSchema(Name name) throws NamingException; + DirContext getSchema(String name) throws NamingException; + DirContext getSchemaClassDefinition(Name name) throws NamingException; + DirContext getSchemaClassDefinition(String name) throws NamingException; + NamingEnumeration search(Name name, + Attributes matchingAttributes, + String[] attributesToReturn) + throws NamingException; + NamingEnumeration search(String name, + Attributes matchingAttributes, + String[] attributesToReturn) + throws NamingException; + NamingEnumeration search(Name name, + Attributes matchingAttributes) + throws NamingException; + NamingEnumeration search(String name, + Attributes matchingAttributes) + throws NamingException; + NamingEnumeration search(Name name, String filter, + SearchControls cons) + throws NamingException; + NamingEnumeration search(String name, String filter, + SearchControls cons) + throws NamingException; + NamingEnumeration search(Name name, String filterExpr, + Object[] filterArgs, + SearchControls cons) + throws NamingException; + NamingEnumeration search(String name, String filterExpr, + Object[] filterArgs, + SearchControls cons) + throws NamingException; +} diff --git a/libjava/classpath/javax/naming/directory/InitialDirContext.java b/libjava/classpath/javax/naming/directory/InitialDirContext.java new file mode 100644 index 000000000..68130b28c --- /dev/null +++ b/libjava/classpath/javax/naming/directory/InitialDirContext.java @@ -0,0 +1,272 @@ +/* InitialDirContext.java -- + Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.Name; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.NoInitialContextException; +import javax.naming.NotContextException; + +/** + * @author Tom Tromey (tromey@redhat.com) + * @date June 25, 2001 + */ +public class InitialDirContext extends InitialContext implements DirContext +{ + public InitialDirContext () + throws NamingException + { + this (null); + } + + protected InitialDirContext (boolean lazy) + throws NamingException + { + super (lazy); + } + + public InitialDirContext (Hashtable environment) + throws NamingException + { + super (environment); + } + + // The InitialContext docs suggest that this exist. And it does + // seem like a good idea. but the InitialDirContext docs indicate + // it cannot be non-private. + private DirContext getURLOrDefaultInitDirCtx (Name name) + throws NamingException + { + Context c = getURLOrDefaultInitCtx (name); + if (c == null) + throw new NoInitialContextException (); + else if (! (c instanceof DirContext)) + throw new NotContextException (); + return (DirContext) c; + } + + private DirContext getURLOrDefaultInitDirCtx (String name) + throws NamingException + { + Context c = getURLOrDefaultInitCtx (name); + if (c == null) + throw new NoInitialContextException (); + else if (! (c instanceof DirContext)) + throw new NotContextException (); + return (DirContext) c; + } + + public Attributes getAttributes (String name) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).getAttributes (name); + } + + public Attributes getAttributes (String name, String[] attrIds) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).getAttributes (name, attrIds); + } + + public Attributes getAttributes (Name name) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).getAttributes (name); + } + + public Attributes getAttributes(Name name, String[] attrIds) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).getAttributes (name, attrIds); + } + + public void modifyAttributes(Name name, int mod_op, Attributes attrs) + throws NamingException + { + getURLOrDefaultInitDirCtx (name).modifyAttributes (name, mod_op, attrs); + } + + public void modifyAttributes(String name, int mod_op, Attributes attrs) + throws NamingException + { + getURLOrDefaultInitDirCtx (name).modifyAttributes (name, mod_op, attrs); + } + + public void modifyAttributes(Name name, ModificationItem[] mods) + throws NamingException + { + getURLOrDefaultInitDirCtx (name).modifyAttributes (name, mods); + } + + public void modifyAttributes(String name, ModificationItem[] mods) + throws NamingException + { + getURLOrDefaultInitDirCtx (name).modifyAttributes (name, mods); + } + + public void bind(Name name, Object obj, Attributes attrs) + throws NamingException + { + getURLOrDefaultInitDirCtx (name).bind (name, obj, attrs); + } + + public void bind(String name, Object obj, Attributes attrs) + throws NamingException + { + getURLOrDefaultInitDirCtx (name).bind (name, obj, attrs); + } + + public void rebind(Name name, Object obj, Attributes attrs) + throws NamingException + { + getURLOrDefaultInitDirCtx (name).rebind (name, obj, attrs); + } + + public void rebind(String name, Object obj, Attributes attrs) + throws NamingException + { + getURLOrDefaultInitDirCtx (name).rebind (name, obj, attrs); + } + + public DirContext createSubcontext(Name name, Attributes attrs) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).createSubcontext (name, attrs); + } + + public DirContext createSubcontext(String name, Attributes attrs) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).createSubcontext (name, attrs); + } + + public DirContext getSchema(Name name) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).getSchema (name); + } + + public DirContext getSchema(String name) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).getSchema (name); + } + + public DirContext getSchemaClassDefinition(Name name) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).getSchemaClassDefinition (name); + } + + public DirContext getSchemaClassDefinition(String name) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).getSchemaClassDefinition (name); + } + + public NamingEnumeration search(Name name, + Attributes matchingAttributes, + String[] attributesToReturn) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).search (name, matchingAttributes, + attributesToReturn); + } + + public NamingEnumeration search(String name, + Attributes matchingAttributes, + String[] attributesToReturn) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).search (name, matchingAttributes, + attributesToReturn); + } + + public NamingEnumeration search(Name name, + Attributes matchingAttributes) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).search (name, matchingAttributes); + } + + public NamingEnumeration search(String name, + Attributes matchingAttributes) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).search (name, matchingAttributes); + } + + public NamingEnumeration search(Name name, String filter, + SearchControls cons) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).search (name, filter, cons); + } + + public NamingEnumeration search(String name, String filter, + SearchControls cons) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).search (name, filter, cons); + } + + public NamingEnumeration search(Name name, String filterExpr, + Object[] filterArgs, + SearchControls cons) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).search (name, filterExpr, + filterArgs, cons); + } + + public NamingEnumeration search(String name, + String filterExpr, + Object[] filterArgs, + SearchControls cons) + throws NamingException + { + return getURLOrDefaultInitDirCtx (name).search (name, filterExpr, + filterArgs, cons); + } +} diff --git a/libjava/classpath/javax/naming/directory/InvalidAttributeIdentifierException.java b/libjava/classpath/javax/naming/directory/InvalidAttributeIdentifierException.java new file mode 100644 index 000000000..afd9a902b --- /dev/null +++ b/libjava/classpath/javax/naming/directory/InvalidAttributeIdentifierException.java @@ -0,0 +1,56 @@ +/* InvalidAttributeIdentifierException.java -- + Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.NamingException; + +public class InvalidAttributeIdentifierException extends NamingException +{ + private static final long serialVersionUID = - 9036920266322999923L; + + public InvalidAttributeIdentifierException () + { + super (); + } + + public InvalidAttributeIdentifierException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/directory/InvalidAttributeValueException.java b/libjava/classpath/javax/naming/directory/InvalidAttributeValueException.java new file mode 100644 index 000000000..a18adbfa2 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/InvalidAttributeValueException.java @@ -0,0 +1,56 @@ +/* InvalidAttributeValueException.java -- + Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.NamingException; + +public class InvalidAttributeValueException extends NamingException +{ + private static final long serialVersionUID = 8720050295499275011L; + + public InvalidAttributeValueException () + { + super (); + } + + public InvalidAttributeValueException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/directory/InvalidAttributesException.java b/libjava/classpath/javax/naming/directory/InvalidAttributesException.java new file mode 100644 index 000000000..ac540e2d0 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/InvalidAttributesException.java @@ -0,0 +1,56 @@ +/* InvalidAttributesException.java -- + Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.NamingException; + +public class InvalidAttributesException extends NamingException +{ + private static final long serialVersionUID = 2607612850539889765L; + + public InvalidAttributesException () + { + super (); + } + + public InvalidAttributesException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/directory/InvalidSearchControlsException.java b/libjava/classpath/javax/naming/directory/InvalidSearchControlsException.java new file mode 100644 index 000000000..9c716fa0f --- /dev/null +++ b/libjava/classpath/javax/naming/directory/InvalidSearchControlsException.java @@ -0,0 +1,56 @@ +/* InvalidSearchControlsException.java -- + Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.NamingException; + +public class InvalidSearchControlsException extends NamingException +{ + private static final long serialVersionUID = - 5124108943352665777L; + + public InvalidSearchControlsException () + { + super (); + } + + public InvalidSearchControlsException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/directory/InvalidSearchFilterException.java b/libjava/classpath/javax/naming/directory/InvalidSearchFilterException.java new file mode 100644 index 000000000..21843cc01 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/InvalidSearchFilterException.java @@ -0,0 +1,56 @@ +/* InvalidSearchFilterException.java -- + Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.NamingException; + +public class InvalidSearchFilterException extends NamingException +{ + private static final long serialVersionUID = 2902700940682875441L; + + public InvalidSearchFilterException () + { + super (); + } + + public InvalidSearchFilterException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/directory/ModificationItem.java b/libjava/classpath/javax/naming/directory/ModificationItem.java new file mode 100644 index 000000000..b7cb48e68 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/ModificationItem.java @@ -0,0 +1,81 @@ +/* ModificationItem.java -- + Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import java.io.Serializable; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 13, 2001 + */ + +public class ModificationItem implements Serializable +{ + private static final long serialVersionUID = 7573258562534746850L; + // Serialized fields. + private int mod_op; + private Attribute attr; + + public ModificationItem(int mod_op, Attribute attr) + { + if (attr == null) + throw new IllegalArgumentException("attr is null"); + if (mod_op != DirContext.ADD_ATTRIBUTE && + mod_op != DirContext.REPLACE_ATTRIBUTE && + mod_op != DirContext.REMOVE_ATTRIBUTE) + throw new IllegalArgumentException("mod_op is invalid"); + this.mod_op = mod_op; + this.attr = attr; + } + + public int getModificationOp() + { + return mod_op; + } + + public Attribute getAttribute() + { + return attr; + } + + public String toString() + { + return "mod_op=" + mod_op + ":" + "attr=" + attr.toString(); + } +} diff --git a/libjava/classpath/javax/naming/directory/NoSuchAttributeException.java b/libjava/classpath/javax/naming/directory/NoSuchAttributeException.java new file mode 100644 index 000000000..8eb5e9570 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/NoSuchAttributeException.java @@ -0,0 +1,56 @@ +/* NoSuchAttributeException.java -- + Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.NamingException; + +public class NoSuchAttributeException extends NamingException +{ + private static final long serialVersionUID = 4836415647935888137L; + + public NoSuchAttributeException () + { + super (); + } + + public NoSuchAttributeException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/directory/SchemaViolationException.java b/libjava/classpath/javax/naming/directory/SchemaViolationException.java new file mode 100644 index 000000000..f60f32aad --- /dev/null +++ b/libjava/classpath/javax/naming/directory/SchemaViolationException.java @@ -0,0 +1,56 @@ +/* SchemaViolationException.java -- + Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.NamingException; + +public class SchemaViolationException extends NamingException +{ + private static final long serialVersionUID = - 3041762429525049663L; + + public SchemaViolationException () + { + super (); + } + + public SchemaViolationException (String msg) + { + super (msg); + } +} diff --git a/libjava/classpath/javax/naming/directory/SearchControls.java b/libjava/classpath/javax/naming/directory/SearchControls.java new file mode 100644 index 000000000..805e97170 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/SearchControls.java @@ -0,0 +1,138 @@ +/* SearchControls.java -- + Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import java.io.Serializable; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 5, 2001 + */ + +public class SearchControls implements Serializable +{ + private static final long serialVersionUID = - 2480540967773454797L; + public static final int OBJECT_SCOPE = 0; + public static final int ONELEVEL_SCOPE = 1; + public static final int SUBTREE_SCOPE = 2; + + // Serialized fields. + private int searchScope; + private int timeLimit; + private boolean derefLink; + private boolean returnObj; + private long countLimit; + private String[] attributesToReturn; + + public SearchControls() + { + this(ONELEVEL_SCOPE, 0L, 0, null, false, false); + } + + public SearchControls(int scope, long countlim, int timelim, String[] attrs, + boolean retobj, boolean deref) + { + searchScope = scope; + timeLimit = timelim; + derefLink = deref; + returnObj = retobj; + countLimit = countlim; + attributesToReturn = attrs; + } + + public int getSearchScope() + { + return searchScope; + } + + public int getTimeLimit() + { + return timeLimit; + } + + public boolean getDerefLinkFlag() + { + return derefLink; + } + + public boolean getReturningObjFlag() + { + return returnObj; + } + + public long getCountLimit() + { + return countLimit; + } + + public String[] getReturningAttributes() + { + return attributesToReturn; + } + + public void setSearchScope(int scope) + { + searchScope = scope; + } + + public void setTimeLimit(int ms) + { + timeLimit = ms; + } + + public void setDerefLinkFlag(boolean on) + { + derefLink = on; + } + + public void setReturningObjFlag(boolean on) + { + returnObj = on; + } + + public void setCountLimit(long limit) + { + countLimit = limit; + } + + public void setReturningAttributes(String[] attrs) + { + attributesToReturn = attrs; + } +} diff --git a/libjava/classpath/javax/naming/directory/SearchResult.java b/libjava/classpath/javax/naming/directory/SearchResult.java new file mode 100644 index 000000000..5d6a2b1f8 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/SearchResult.java @@ -0,0 +1,95 @@ +/* SearchResult.java -- + Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.directory; + +import javax.naming.Binding; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 13, 2001 + */ + +public class SearchResult extends Binding +{ + private static final long serialVersionUID = - 9158063327699723172L; + // Serialized fields. + private Attributes attrs; + + public SearchResult(String name, Object obj, Attributes attrs) + { + super(name, obj); + this.attrs = attrs; + } + + public SearchResult(String name, Object obj, Attributes attrs, + boolean isRelative) + { + super(name, obj, isRelative); + this.attrs = attrs; + } + + public SearchResult(String name, String className, Object obj, + Attributes attrs) + { + super(name, className, obj); + this.attrs = attrs; + } + + public SearchResult(String name, String className, Object obj, + Attributes attrs, boolean isRelative) + { + super(name, className, obj, isRelative); + this.attrs = attrs; + } + + public Attributes getAttributes() + { + return attrs; + } + + public void setAttributes(Attributes attrs) + { + this.attrs = attrs; + } + + public String toString() + { + return super.toString() + ":" + attrs.toString(); + } +} diff --git a/libjava/classpath/javax/naming/directory/package.html b/libjava/classpath/javax/naming/directory/package.html new file mode 100644 index 000000000..6286dd2e4 --- /dev/null +++ b/libjava/classpath/javax/naming/directory/package.html @@ -0,0 +1,46 @@ + + + + +GNU Classpath - javax.naming.directory + + +

+ + + diff --git a/libjava/classpath/javax/naming/event/EventContext.java b/libjava/classpath/javax/naming/event/EventContext.java new file mode 100644 index 000000000..fbee9718d --- /dev/null +++ b/libjava/classpath/javax/naming/event/EventContext.java @@ -0,0 +1,65 @@ +/* EventContext.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.event; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NamingException; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ + +public interface EventContext extends Context +{ + int OBJECT_SCOPE = 0; + int ONELEVEL_SCOPE = 1; + int SUBTREE_SCOPE = 2; + + void addNamingListener (Name target, int scope, NamingListener l) + throws NamingException; + + void addNamingListener (String target, int scope, NamingListener l) + throws NamingException; + + void removeNamingListener (NamingListener l) throws NamingException; + + boolean targetMustExist() throws NamingException; +} diff --git a/libjava/classpath/javax/naming/event/EventDirContext.java b/libjava/classpath/javax/naming/event/EventDirContext.java new file mode 100644 index 000000000..d2883aec3 --- /dev/null +++ b/libjava/classpath/javax/naming/event/EventDirContext.java @@ -0,0 +1,65 @@ +/* EventDirContext.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package javax.naming.event; + +import javax.naming.Name; +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.naming.directory.SearchControls; + + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ +public interface EventDirContext extends EventContext, DirContext +{ + void addNamingListener(Name target, String filter, SearchControls ctls, + NamingListener l) throws NamingException; + + void addNamingListener(String target, String filter, SearchControls ctls, + NamingListener l) throws NamingException; + + void addNamingListener(Name target, String filter, Object[] filterArgs, + SearchControls ctls, NamingListener l) + throws NamingException; + + void addNamingListener(String target, String filter, Object[] filterArgs, + SearchControls ctls, NamingListener l) + throws NamingException; +} diff --git a/libjava/classpath/javax/naming/event/NamespaceChangeListener.java b/libjava/classpath/javax/naming/event/NamespaceChangeListener.java new file mode 100644 index 000000000..efe797e7a --- /dev/null +++ b/libjava/classpath/javax/naming/event/NamespaceChangeListener.java @@ -0,0 +1,51 @@ +/* NamespaceChangeListener.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.event; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ + +public interface NamespaceChangeListener extends NamingListener +{ + void objectAdded(NamingEvent evt); + void objectRemoved(NamingEvent evt); + void objectRenamed(NamingEvent evt); +} diff --git a/libjava/classpath/javax/naming/event/NamingEvent.java b/libjava/classpath/javax/naming/event/NamingEvent.java new file mode 100644 index 000000000..dcc8c89b1 --- /dev/null +++ b/libjava/classpath/javax/naming/event/NamingEvent.java @@ -0,0 +1,122 @@ +/* NamingEvent.java -- + Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.event; + +import java.util.EventObject; + +import javax.naming.Binding; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 5, 2001 + */ +public class NamingEvent extends EventObject +{ + private static final long serialVersionUID = - 7126752885365133499L; + + public static final int OBJECT_ADDED = 0; + public static final int OBJECT_REMOVED = 1; + public static final int OBJECT_RENAMED = 2; + public static final int OBJECT_CHANGED = 3; + + // Serialized fields. + protected Object changeInfo; + protected int type; + protected Binding oldBinding; + protected Binding newBinding; + + public NamingEvent(EventContext source, int type, Binding newBd, + Binding oldBd, Object changeInfo) + { + super(source); + this.type = type; + this.oldBinding = oldBd; + this.newBinding = newBd; + this.changeInfo = changeInfo; + // FIXME: for OBJECT_ADDED, newBd must not be null; + // FIXME: for OBJECT_CHANGED, newBd and oldBd must not be null; + // FIXME: for OBJECT_RENAMED, one of newBd or oldBd may be null if newBd or + // FIXME: oldBd is outside of the scope for which listener has registered. + // FIXME: namingExceptionThrown() is called for the listener in question. + } + + public int getType() + { + return type; + } + + public EventContext getEventContext() + { + return (EventContext) getSource(); + } + + public Binding getOldBinding() + { + return oldBinding; + } + + public Binding getNewBinding() + { + return newBinding; + } + + public Object getChangeInfo() + { + return changeInfo; + } + + public void dispatch(NamingListener listener) + { + switch (type) + { + case OBJECT_ADDED: + ((NamespaceChangeListener) listener).objectAdded(this); + break; + case OBJECT_REMOVED: + ((NamespaceChangeListener) listener).objectRemoved(this); + break; + case OBJECT_RENAMED: + ((NamespaceChangeListener) listener).objectRenamed(this); + break; + case OBJECT_CHANGED: + ((ObjectChangeListener) listener).objectChanged(this); + break; + } + } +} diff --git a/libjava/classpath/javax/naming/event/NamingExceptionEvent.java b/libjava/classpath/javax/naming/event/NamingExceptionEvent.java new file mode 100644 index 000000000..27a7552d8 --- /dev/null +++ b/libjava/classpath/javax/naming/event/NamingExceptionEvent.java @@ -0,0 +1,77 @@ +/* NamingExceptionEvent.java -- + Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.event; + +import java.util.EventObject; + +import javax.naming.NamingException; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 5, 2001 + */ + +public class NamingExceptionEvent extends EventObject +{ + private static final long serialVersionUID = - 4877678086134736336L; + + // Serialized fields. + private NamingException exception; + + public NamingExceptionEvent(EventContext source, NamingException exc) + { + super(source); + exception = exc; + } + + public NamingException getException() + { + return exception; + } + + public EventContext getEventContext() + { + return (EventContext) getSource(); + } + + public void dispatch(NamingListener listener) + { + listener.namingExceptionThrown(this); + } +} diff --git a/libjava/classpath/javax/naming/event/NamingListener.java b/libjava/classpath/javax/naming/event/NamingListener.java new file mode 100644 index 000000000..e820d55c3 --- /dev/null +++ b/libjava/classpath/javax/naming/event/NamingListener.java @@ -0,0 +1,51 @@ +/* NamingListener.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.event; + +import java.util.EventListener; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ + +public interface NamingListener extends EventListener +{ + void namingExceptionThrown(NamingExceptionEvent evt); +} diff --git a/libjava/classpath/javax/naming/event/ObjectChangeListener.java b/libjava/classpath/javax/naming/event/ObjectChangeListener.java new file mode 100644 index 000000000..63ccc5bab --- /dev/null +++ b/libjava/classpath/javax/naming/event/ObjectChangeListener.java @@ -0,0 +1,49 @@ +/* ObjectChangeListener.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.event; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ + +public interface ObjectChangeListener extends NamingListener +{ + void objectChanged(NamingEvent evt); +} diff --git a/libjava/classpath/javax/naming/event/package.html b/libjava/classpath/javax/naming/event/package.html new file mode 100644 index 000000000..a5d620e47 --- /dev/null +++ b/libjava/classpath/javax/naming/event/package.html @@ -0,0 +1,46 @@ + + + + +GNU Classpath - javax.naming.event + + +

+ + + diff --git a/libjava/classpath/javax/naming/ldap/Control.java b/libjava/classpath/javax/naming/ldap/Control.java new file mode 100644 index 000000000..b852c0063 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/Control.java @@ -0,0 +1,56 @@ +/* Control.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.io.Serializable; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ + +public interface Control extends Serializable +{ + boolean CRITICAL = true; + boolean NONCRITICAL = false; + + String getID(); + boolean isCritical(); + byte[] getEncodedValue(); +} diff --git a/libjava/classpath/javax/naming/ldap/ControlFactory.java b/libjava/classpath/javax/naming/ldap/ControlFactory.java new file mode 100644 index 000000000..05d53f9a8 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/ControlFactory.java @@ -0,0 +1,107 @@ +/* ControlFactory.java -- + Copyright (C) 2001, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.util.Hashtable; +import java.util.StringTokenizer; + +import javax.naming.Context; +import javax.naming.NamingException; + +/** + * @author Tom Tromey (tromey@redhat.com) + * @date June 22, 2001 + */ +public abstract class ControlFactory +{ + protected ControlFactory () + { + } + + public abstract Control getControlInstance (Control control) + throws NamingException; + + public static Control getControlInstance (Control control, + Context ctx, + Hashtable env) + throws NamingException + { + String path = (String) env.get (LdapContext.CONTROL_FACTORIES); + String path2 = null; + if (ctx != null) + path2 = (String) ctx.getEnvironment ().get (LdapContext.CONTROL_FACTORIES); + if (path == null) + path = path2; + else if (path2 != null) + path += ":" + path2; + + StringTokenizer tokens = new StringTokenizer (path, ":"); + while (tokens.hasMoreTokens ()) + { + String name = tokens.nextToken (); + try + { + Class k = Class.forName (name); + ControlFactory cf = (ControlFactory) k.newInstance (); + Control ctrl = cf.getControlInstance (control); + if (ctrl != null) + return ctrl; + } + catch (ClassNotFoundException _1) + { + // Ignore it. + } + catch (ClassCastException _2) + { + // Ignore it. + } + catch (InstantiationException _3) + { + // If we couldn't instantiate the factory we might get + // this. + } + catch (IllegalAccessException _4) + { + // Another possibility when instantiating. + } + } + + return control; + } +} diff --git a/libjava/classpath/javax/naming/ldap/ExtendedRequest.java b/libjava/classpath/javax/naming/ldap/ExtendedRequest.java new file mode 100644 index 000000000..43ddcd7d0 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/ExtendedRequest.java @@ -0,0 +1,57 @@ +/* ExtendedRequest.java -- + Copyright (C) 2001, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.io.Serializable; + +import javax.naming.NamingException; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ +public interface ExtendedRequest extends Serializable +{ + String getID(); + byte[] getEncodedValue(); + ExtendedResponse createExtendedResponse(String id, + byte[] berValue, int offset, + int length) + throws NamingException; +} diff --git a/libjava/classpath/javax/naming/ldap/ExtendedResponse.java b/libjava/classpath/javax/naming/ldap/ExtendedResponse.java new file mode 100644 index 000000000..18b222161 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/ExtendedResponse.java @@ -0,0 +1,52 @@ +/* ExtendedResponse.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.io.Serializable; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ + +public interface ExtendedResponse extends Serializable +{ + String getID(); + byte[] getEncodedValue(); +} diff --git a/libjava/classpath/javax/naming/ldap/HasControls.java b/libjava/classpath/javax/naming/ldap/HasControls.java new file mode 100644 index 000000000..f3b97fca4 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/HasControls.java @@ -0,0 +1,51 @@ +/* HasControls.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import javax.naming.NamingException; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ + +public interface HasControls +{ + Control[] getControls() throws NamingException; +} diff --git a/libjava/classpath/javax/naming/ldap/InitialLdapContext.java b/libjava/classpath/javax/naming/ldap/InitialLdapContext.java new file mode 100644 index 000000000..011ff5ab5 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/InitialLdapContext.java @@ -0,0 +1,135 @@ +/* InitialLdapContext.java -- + Copyright (C) 2001, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.NamingException; +import javax.naming.NoInitialContextException; +import javax.naming.NotContextException; +import javax.naming.directory.InitialDirContext; + +/** + * @author Tom Tromey (tromey@redhat.com) + * @date June 21, 2001 + */ +public class InitialLdapContext + extends InitialDirContext + implements LdapContext +{ + public InitialLdapContext () + throws NamingException + { + this (null, null); + } + + public InitialLdapContext (Hashtable environment, + Control[] connControls) + throws NamingException + { + super (false); + + Hashtable myenv = null; + if (connControls != null) + { + if (environment == null) + myenv = new Hashtable (); + else + myenv = (Hashtable) environment.clone (); + myenv.put ("java.naming.ldap.control.connect", + connControls); + } + + init (myenv); + } + + private LdapContext getDefaultInitLdapCtx () + throws NamingException + { + Context c = getDefaultInitCtx (); + if (c == null) + throw new NoInitialContextException (); + else if (! (c instanceof LdapContext)) + throw new NotContextException (); + return (LdapContext) c; + } + + public ExtendedResponse extendedOperation (ExtendedRequest request) + throws NamingException + { + return getDefaultInitLdapCtx ().extendedOperation (request); + } + + public Control[] getConnectControls () + throws NamingException + { + return getDefaultInitLdapCtx ().getConnectControls (); + } + + public Control[] getRequestControls () + throws NamingException + { + return getDefaultInitLdapCtx ().getRequestControls (); + } + + public Control[] getResponseControls () + throws NamingException + { + return getDefaultInitLdapCtx ().getResponseControls (); + } + + public LdapContext newInstance (Control[] reqControls) + throws NamingException + { + return getDefaultInitLdapCtx ().newInstance (reqControls); + } + + public void reconnect (Control[] connControls) + throws NamingException + { + getDefaultInitLdapCtx ().reconnect (connControls); + } + + public void setRequestControls (Control[] reqControls) + throws NamingException + { + getDefaultInitLdapCtx ().setRequestControls (reqControls); + } +} diff --git a/libjava/classpath/javax/naming/ldap/LdapContext.java b/libjava/classpath/javax/naming/ldap/LdapContext.java new file mode 100644 index 000000000..ff11259be --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/LdapContext.java @@ -0,0 +1,63 @@ +/* LdapContext.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ + +public interface LdapContext extends DirContext +{ + String CONTROL_FACTORIES = "java.naming.factory.control"; + + ExtendedResponse extendedOperation(ExtendedRequest request) + throws NamingException; + LdapContext newInstance(Control[] requestControls) + throws NamingException; + void reconnect(Control[] connCtls) throws NamingException; + Control[] getConnectControls() throws NamingException; + void setRequestControls(Control[] requestControls) + throws NamingException; + Control[] getRequestControls() throws NamingException; + Control[] getResponseControls() throws NamingException; +} diff --git a/libjava/classpath/javax/naming/ldap/LdapReferralException.java b/libjava/classpath/javax/naming/ldap/LdapReferralException.java new file mode 100644 index 000000000..faa719c36 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/LdapReferralException.java @@ -0,0 +1,69 @@ +/* LdapReferralException.java -- + Copyright (C) 2001, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.NamingException; +import javax.naming.ReferralException; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ +public abstract class LdapReferralException extends ReferralException +{ + protected LdapReferralException() + { + super(); + } + + protected LdapReferralException(String explanation) + { + super(explanation); + } + + public abstract Context getReferralContext() throws NamingException; + public abstract Context getReferralContext(Hashtable env) + throws NamingException; + public abstract Context getReferralContext(Hashtable env, + Control[] reqCtls) + throws NamingException; +} diff --git a/libjava/classpath/javax/naming/ldap/StartTlsRequest.java b/libjava/classpath/javax/naming/ldap/StartTlsRequest.java new file mode 100644 index 000000000..42ee8d774 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/StartTlsRequest.java @@ -0,0 +1,108 @@ +/* StartTlsRequest.java -- extended ldap TLS request + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.util.Iterator; + +import gnu.classpath.ServiceFactory; + +import javax.naming.NamingException; + +/** + * @since 1.4 + */ +public class StartTlsRequest + implements ExtendedRequest +{ + private static final long serialVersionUID = 4441679576360753397L; + + /** + * The assigned object identifier for this response. + */ + public static final String OID = "1.3.6.1.4.1.1466.20037"; + + /** + * Create a new instance. + */ + public StartTlsRequest() + { + } + + /** + * Return the response identifier. This is simply the value + * of the {@link #OID} field. + */ + public String getID() + { + return OID; + } + + /** + * Return the encoded value. This implementation always returns null. + */ + public byte[] getEncodedValue() + { + return null; + } + + /** + * Create a new extended reponse object, using the standard service + * provider approach to load a provider. The provider will be a subclass + * of StartTlsRequest with a no-argument constructor. The key is + * "javax.naming.ldap.StartTlsRequest". + * @param id the identifier, must be {@link #OID} or null + * @param berValue ignored + * @param offset ignored + * @param length ignored + * @throws NamingException if there is a problem creating the response + */ + public ExtendedResponse createExtendedResponse(String id, byte[] berValue, + int offset, int length) + throws NamingException + { + if (id != null && ! OID.equals(id)) + throw new NamingException("incorrect id: was \"" + id + + "\", but expected: \"" + OID + "\""); + Iterator it = ServiceFactory.lookupProviders(StartTlsRequest.class); + if (it.hasNext()) + return (ExtendedResponse) it.next(); + throw new NamingException("couldn't find provider for " + + "javax.naming.ldap.StartTlsRequest"); + } +} diff --git a/libjava/classpath/javax/naming/ldap/StartTlsResponse.java b/libjava/classpath/javax/naming/ldap/StartTlsResponse.java new file mode 100644 index 000000000..68cd5bf86 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/StartTlsResponse.java @@ -0,0 +1,119 @@ +/* StartTlsResponse.java -- extended ldap TLS response + Copyright (C) 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.io.IOException; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocketFactory; + +/** + * @since 1.4 + */ +public abstract class StartTlsResponse + implements ExtendedResponse +{ + private static final long serialVersionUID = 8372842182579276418L; + + /** + * The assigned object identifier for this response. + */ + public static final String OID = "1.3.6.1.4.1.1466.20037"; + + /** + * Create a new instance. + */ + protected StartTlsResponse() + { + } + + /** + * Return the response identifier. This is simply the value + * of the {@link #OID} field. + */ + public String getID() + { + return OID; + } + + /** + * Return the encoded value. This implementation always returns null. + */ + public byte[] getEncodedValue() + { + return null; + } + + /** + * Set the list of cipher suites to use. + * @param cipherSuites the list of suites + * @see SSLSocketFactory#getSupportedCipherSuites() + */ + public abstract void setEnabledCipherSuites(String[] cipherSuites); + + /** + * Set the hostname verifier to use. This must be called before + * {@link #negotiate()}. + * @param verifier the hostname verifier + */ + public abstract void setHostnameVerifier(HostnameVerifier verifier); + + /** + * Negotiate the TLS session using the default SSL socket factory. + * @return the SSL session + * @throws IOException if communication fails for some reason + */ + public abstract SSLSession negotiate() throws IOException; + + /** + * Negotiate the TLS session using the supplied SSL socket factory. + * @param factory the socket factory to use + * @return the SSL session + * @throws IOException if communication fails for some reason + */ + public abstract SSLSession negotiate(SSLSocketFactory factory) + throws IOException; + + /** + * Close the connection. + * @throws IOException if communication fails for some reason + */ + public abstract void close() throws IOException; +} diff --git a/libjava/classpath/javax/naming/ldap/UnsolicitedNotification.java b/libjava/classpath/javax/naming/ldap/UnsolicitedNotification.java new file mode 100644 index 000000000..ca911f541 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/UnsolicitedNotification.java @@ -0,0 +1,52 @@ +/* UnsolicitedNotification.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import javax.naming.NamingException; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ + +public interface UnsolicitedNotification extends ExtendedResponse, HasControls +{ + String[] getReferrals(); + NamingException getException(); +} diff --git a/libjava/classpath/javax/naming/ldap/UnsolicitedNotificationEvent.java b/libjava/classpath/javax/naming/ldap/UnsolicitedNotificationEvent.java new file mode 100644 index 000000000..52e591a61 --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/UnsolicitedNotificationEvent.java @@ -0,0 +1,70 @@ +/* UnsolicitedNotificationEvent.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import java.util.EventObject; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 5, 2001 + */ +public class UnsolicitedNotificationEvent extends EventObject +{ + private static final long serialVersionUID = -2382603380799883705L; + + // Serialized fields. + private UnsolicitedNotification notice; + + public UnsolicitedNotificationEvent(Object src, + UnsolicitedNotification notice) + { + super(src); + this.notice = notice; + } + + public UnsolicitedNotification getNotification() + { + return notice; + } + + public void dispatch(UnsolicitedNotificationListener listener) + { + listener.notificationReceived(this); + } +} diff --git a/libjava/classpath/javax/naming/ldap/UnsolicitedNotificationListener.java b/libjava/classpath/javax/naming/ldap/UnsolicitedNotificationListener.java new file mode 100644 index 000000000..f2a35da6c --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/UnsolicitedNotificationListener.java @@ -0,0 +1,51 @@ +/* UnsolicitedNotificationListener.java -- + Copyright (C) 2001, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.ldap; + +import javax.naming.event.NamingListener; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ + +public interface UnsolicitedNotificationListener extends NamingListener +{ + void notificationReceived(UnsolicitedNotificationEvent evt); +} diff --git a/libjava/classpath/javax/naming/ldap/package.html b/libjava/classpath/javax/naming/ldap/package.html new file mode 100644 index 000000000..0a4e45e6e --- /dev/null +++ b/libjava/classpath/javax/naming/ldap/package.html @@ -0,0 +1,46 @@ + + + + +GNU Classpath - javax.naming.ldap + + +

+ + + diff --git a/libjava/classpath/javax/naming/package.html b/libjava/classpath/javax/naming/package.html new file mode 100644 index 000000000..0794d3de8 --- /dev/null +++ b/libjava/classpath/javax/naming/package.html @@ -0,0 +1,46 @@ + + + + +GNU Classpath - javax.naming + + +

+ + + diff --git a/libjava/classpath/javax/naming/spi/DirObjectFactory.java b/libjava/classpath/javax/naming/spi/DirObjectFactory.java new file mode 100644 index 000000000..47fb7a1e7 --- /dev/null +++ b/libjava/classpath/javax/naming/spi/DirObjectFactory.java @@ -0,0 +1,56 @@ +/* DirObjectFactory.java -- + Copyright (C) 2001, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.directory.Attributes; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ +public interface DirObjectFactory extends ObjectFactory +{ + Object getObjectInstance(Object obj, Name name, Context nameCtx, + Hashtable environment, Attributes attrs) + throws Exception; +} diff --git a/libjava/classpath/javax/naming/spi/DirStateFactory.java b/libjava/classpath/javax/naming/spi/DirStateFactory.java new file mode 100644 index 000000000..1c0c21b13 --- /dev/null +++ b/libjava/classpath/javax/naming/spi/DirStateFactory.java @@ -0,0 +1,83 @@ +/* DirStateFactory.java -- + Copyright (C) 2001, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; + +/** + * @author Warren Levy (warrenl@redhat.com) + * @date June 1, 2001 + */ +public interface DirStateFactory extends StateFactory +{ + // Inner class + + public static class Result + { + private Object obj; + private Attributes outAttrs; + + public Result(Object obj, Attributes outAttrs) + { + this.obj = obj; + this.outAttrs = outAttrs; + } + + public Object getObject() + { + return obj; + } + + public Attributes getAttributes() + { + return outAttrs; + } + } + + DirStateFactory.Result getStateToBind(Object obj, Name name, + Context nameCtx, + Hashtable environment, + Attributes inAttrs) + throws NamingException; +} diff --git a/libjava/classpath/javax/naming/spi/DirectoryManager.java b/libjava/classpath/javax/naming/spi/DirectoryManager.java new file mode 100644 index 000000000..4abb5f1a6 --- /dev/null +++ b/libjava/classpath/javax/naming/spi/DirectoryManager.java @@ -0,0 +1,243 @@ +/* DirectoryManager.java -- + Copyright (C) 2000, 2001, 2004, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.StringTokenizer; + +import javax.naming.CannotProceedException; +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NamingException; +import javax.naming.RefAddr; +import javax.naming.Reference; +import javax.naming.Referenceable; +import javax.naming.StringRefAddr; +import javax.naming.directory.Attributes; +import javax.naming.directory.DirContext; + +/** + * @author Tom Tromey (tromey@redhat.com) + * @date June 25, 2001 + */ +public class DirectoryManager extends NamingManager +{ + // Can't instantiate this class. + DirectoryManager () + { + } + + public static DirContext getContinuationDirContext (CannotProceedException c) + throws NamingException + { + return (DirContext) getContinuationContext (c); + } + + // Try to create an object using the factory. Return null on + // failure. + private static Object tryCreateObject (ObjectFactory factory, + Object refInfo, + Name name, + Context nameCtx, + Hashtable environment, + Attributes attrs) + throws Exception + { + if (factory instanceof DirObjectFactory) + { + DirObjectFactory dof = (DirObjectFactory) factory; + return dof.getObjectInstance (refInfo, name, nameCtx, + environment, attrs); + } + else + return factory.getObjectInstance (refInfo, name, nameCtx, + environment); + } + + public static Object getObjectInstance (Object refInfo, Name name, + Context nameCtx, + Hashtable environment, + Attributes attrs) + throws Exception + { + ObjectFactory factory = null; + + if (ofb != null) + factory = ofb.createObjectFactory (refInfo, environment); + else + { + // First see if we have a Reference or a Referenceable. If so + // we do some special processing. + Object ref2 = refInfo; + if (refInfo instanceof Referenceable) + ref2 = ((Referenceable) refInfo).getReference (); + if (ref2 instanceof Reference) + { + Reference ref = (Reference) ref2; + + // If we have a factory class name then we use that. + String fClass = ref.getFactoryClassName (); + if (fClass != null) + { + // Exceptions here are passed to the caller. + Class k = Class.forName (fClass); + factory = (ObjectFactory) k.newInstance (); + } + else + { + // There's no factory class name. If the address is a + // StringRefAddr with address type `URL', then we try + // the URL's context factory. + Enumeration e = ref.getAll (); + while (e.hasMoreElements ()) + { + RefAddr ra = (RefAddr) e.nextElement (); + if (ra instanceof StringRefAddr + && "URL".equals (ra.getType ())) + { + factory + = (ObjectFactory) getURLContext (refInfo, + name, + nameCtx, + (String) ra.getContent (), + environment); + Object obj = tryCreateObject (factory, + refInfo, + name, + nameCtx, + environment, + attrs); + if (obj != null) + return obj; + } + } + + // Have to try the next step. + factory = null; + } + } + + // Now look at OBJECT_FACTORIES to find the factory. + if (factory == null) + { + StringTokenizer tokens = getPlusPath (Context.OBJECT_FACTORIES, + environment, nameCtx); + + while (tokens.hasMoreTokens ()) + { + String klassName = tokens.nextToken (); + Class k = Class.forName (klassName); + factory = (ObjectFactory) k.newInstance (); + Object obj = tryCreateObject (factory, refInfo, name, + nameCtx, environment, attrs); + if (obj != null) + return obj; + } + + // Failure. + return refInfo; + } + } + + if (factory == null) + return refInfo; + Object obj = tryCreateObject (factory, refInfo, name, + nameCtx, environment, attrs); + return obj == null ? refInfo : obj; + } + + public static DirStateFactory.Result getStateToBind (Object obj, + Name name, + Context nameCtx, + Hashtable environment, + Attributes attrs) + throws NamingException + { + StringTokenizer tokens = getPlusPath (Context.STATE_FACTORIES, + environment, nameCtx); + while (tokens.hasMoreTokens ()) + { + String klassName = tokens.nextToken (); + try + { + Class k = Class.forName (klassName); + StateFactory factory = (StateFactory) k.newInstance (); + + DirStateFactory.Result result = null; + if (factory instanceof DirStateFactory) + { + DirStateFactory dsf = (DirStateFactory) factory; + result = dsf.getStateToBind (obj, name, nameCtx, environment, + attrs); + } + else + { + Object o = factory.getStateToBind (obj, name, nameCtx, + environment); + if (o != null) + result = new DirStateFactory.Result (o, attrs); + } + if (result != null) + return result; + } + catch (ClassNotFoundException _1) + { + // Ignore it. + } + catch (ClassCastException _2) + { + // This means that the class we found was not an + // ObjectFactory or that the factory returned something + // which was not a Context. + } + catch (InstantiationException _3) + { + // If we couldn't instantiate the factory we might get + // this. + } + catch (IllegalAccessException _4) + { + // Another possibility when instantiating. + } + } + + return new DirStateFactory.Result (obj, attrs); + } +} diff --git a/libjava/classpath/javax/naming/spi/InitialContextFactory.java b/libjava/classpath/javax/naming/spi/InitialContextFactory.java new file mode 100644 index 000000000..bd13c6e38 --- /dev/null +++ b/libjava/classpath/javax/naming/spi/InitialContextFactory.java @@ -0,0 +1,71 @@ +/* InitialContextFactory.java -- + Copyright (C) 2000, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.NamingException; + +/** + *

+ * Defines a factory that creates the initial context for the beginning of the + * name resolution. JNDI allows to specify different implementations of the + * initial context at runtime. + *

+ *

+ * The class, implementing this interface, must be public and have a public + * parameterless constructor + *

+ */ +public interface InitialContextFactory +{ + /** + * Create a new initial context + * + * @param environment the properties, used when creating the context. The + * implementing class will not modify the table nor keep the + * reference to it. After the method returns, the caller can safely + * reuse the table for other purposes. + * @return the new initial context + * @throws NamingException if the naming exception has occured + */ + Context getInitialContext (Hashtable environment) + throws NamingException; +} diff --git a/libjava/classpath/javax/naming/spi/InitialContextFactoryBuilder.java b/libjava/classpath/javax/naming/spi/InitialContextFactoryBuilder.java new file mode 100644 index 000000000..12ee888ba --- /dev/null +++ b/libjava/classpath/javax/naming/spi/InitialContextFactoryBuilder.java @@ -0,0 +1,66 @@ +/* InitialContextFactoryBuilder.java -- + Copyright (C) 2000, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import java.util.Hashtable; + +import javax.naming.NamingException; + +/** + * Represents the builder that creates instances of the factories that produce + * initial naming contexts. JNDI allows to specifiy different initial contexts + * at runtime. The user program can install its own initial context factory + * builder. + * + * @see NamingManager#setInitialContextFactoryBuilder + */ +public interface InitialContextFactoryBuilder +{ + /** + * Create the new initial context factory + * + * @param environment the properties, used for creation of the initial + * context factory. The parameter is owned by the caller: it is safe to reuse + * the table for other purposes after the method returns. + * @return the created initial context factory, never null. + * @throws NamingException on failure + */ + InitialContextFactory createInitialContextFactory (Hashtable environment) + throws NamingException; +} diff --git a/libjava/classpath/javax/naming/spi/NamingManager.java b/libjava/classpath/javax/naming/spi/NamingManager.java new file mode 100644 index 000000000..d974513b3 --- /dev/null +++ b/libjava/classpath/javax/naming/spi/NamingManager.java @@ -0,0 +1,671 @@ +/* NamingManager.java -- Creates contexts and objects + Copyright (C) 2000, 2001, 2002, 2003, 2004, + 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import gnu.classpath.VMStackWalker; + +import gnu.java.lang.CPStringBuilder; + +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.StringTokenizer; + +import javax.naming.CannotProceedException; +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NamingException; +import javax.naming.NoInitialContextException; +import javax.naming.RefAddr; +import javax.naming.Reference; +import javax.naming.Referenceable; +import javax.naming.StringRefAddr; + +/** + * Contains methods for creating contexts and objects referred to by + * location information. The location is specified in the scope of the + * certain naming or directory service. This class only contais static + * methods and cannot be instantiated. + */ +public class NamingManager +{ + /** + * The environment property into which getContinuationContext() stores the + * value of the CannotProceedException parameter. The value of this field + * is java.naming.spi.CannotProceedException. + */ + public static final String CPE = "java.naming.spi.CannotProceedException"; + + private static InitialContextFactoryBuilder icfb; + + // Package private so DirectoryManager can access it. + static ObjectFactoryBuilder ofb; + + // This class cannot be instantiated. + NamingManager () + { + } + + /** + * Checks if the initial context factory builder has been set. + * + * @return true if the builder has been set + * + * @see #setInitialContextFactoryBuilder(InitialContextFactoryBuilder) + */ + public static boolean hasInitialContextFactoryBuilder () + { + return icfb != null; + } + + /** + * Creates the initial context. If the initial object factory builder has + * been set with {@link #setObjectFactoryBuilder(ObjectFactoryBuilder)}, + * the work is delegated to this builder. Otherwise, the method searches + * for the property Context.INITIAL_CONTEXT_FACTORY first in the passed + * table and then in the system properties. The value of this property is + * uses as a class name to install the context factory. The corresponding + * class must exist, be public and have the public parameterless constructor. + * + * @param environment the properties, used to create the context. + * + * @return the created context + * + * @throws NoInitialContextException if the initial builder is not set, + * the property Context.INITIAL_CONTEXT_FACTORY is missing of the + * class, named by this property, cannot be instantiated. + * @throws NamingException if throws by the context factory + */ + public static Context getInitialContext (Hashtable environment) + throws NamingException + { + InitialContextFactory icf = null; + + if (icfb != null) + icf = icfb.createInitialContextFactory(environment); + else + { + String java_naming_factory_initial = null; + if (environment != null) + java_naming_factory_initial + = (String) environment.get (Context.INITIAL_CONTEXT_FACTORY); + if (java_naming_factory_initial == null) + java_naming_factory_initial = + System.getProperty (Context.INITIAL_CONTEXT_FACTORY); + if (java_naming_factory_initial == null) + throw new + NoInitialContextException ("Can't find property: " + + Context.INITIAL_CONTEXT_FACTORY); + + try + { + icf = (InitialContextFactory)Class.forName + (java_naming_factory_initial, true, + Thread.currentThread().getContextClassLoader()) + .newInstance (); + } + catch (Exception exception) + { + NoInitialContextException e + = new NoInitialContextException + ("Can't load InitialContextFactory class: " + + java_naming_factory_initial); + e.setRootCause(exception); + throw e; + } + } + + return icf.getInitialContext (environment); + } + + /** + *

+ * Creates the URL context for the given URL scheme id. + *

+ *

+ * The class name of the factory that creates the context has the naming + * pattern scheme-idURLContextFactory. For instance, the factory for the "ftp" + * sheme should be named "ftpURLContextFactory". + *

+ *

+ * The Context.URL_PKG_PREFIXES environment property contains the + * colon-separated list of the possible package prefixes. The package name is + * constructed concatenating the package prefix with the scheme id. This + * property is searched in the passed environment parameter and later + * in the system properties. + *

+ *

+ * If the factory class cannot be found in the specified packages, system will + * try to use the default internal factory for the given scheme. + *

+ *

+ * After the factory is instantiated, its method + * {@link ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)} + * is called to create and return the object instance. + * + * @param refInfo passed to the factory + * @param name passed to the factory + * @param nameCtx passed to the factory + * @param scheme the url scheme that must be supported by the given context + * @param environment the properties for creating the factory and context (may + * be null) + * @return the created context + * @throws NamingException if thrown by the factory when creating the context. + */ + static Context getURLContext(Object refInfo, Name name, Context nameCtx, + String scheme, Hashtable environment) + throws NamingException + { + // Doc specifies com.sun.jndi.url as the final destination, but we cannot + // put our classes into such namespace. + String defaultPrefix = "gnu.javax.naming.jndi.url"; + + // The final default location, as specified in the documentation. + String finalPrefix = "com.sun.jndi.url"; + + CPStringBuilder allPrefixes = new CPStringBuilder(); + + String prefixes; + if (environment != null) + { + prefixes = (String) environment.get(Context.URL_PKG_PREFIXES); + if (prefixes != null) + allPrefixes.append(prefixes); + } + + prefixes = System.getProperty(Context.URL_PKG_PREFIXES); + if (prefixes != null) + { + if (allPrefixes.length() > 0) + allPrefixes.append(':'); + allPrefixes.append(prefixes); + } + + if (allPrefixes.length() > 0) + allPrefixes.append(':'); + allPrefixes.append(defaultPrefix); + allPrefixes.append(':'); + allPrefixes.append(finalPrefix); + + scheme = scheme + "." + scheme + "URLContextFactory"; + + StringTokenizer tokens = new StringTokenizer(allPrefixes.toString(), ":"); + while (tokens.hasMoreTokens()) + { + String aTry = tokens.nextToken(); + try + { + String tryClass = aTry + "." + scheme; + Class factoryClass = forName(tryClass); + if (factoryClass != null) + { + Object obj; + try + { + ObjectFactory factory = (ObjectFactory) factoryClass.newInstance(); + obj = factory.getObjectInstance(refInfo, name, nameCtx, + environment); + Context ctx = (Context) obj; + if (ctx != null) + return ctx; + } + catch (RuntimeException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + catch (ClassNotFoundException _1) + { + // Ignore it. + } + catch (ClassCastException _2) + { + // This means that the class we found was not an + // ObjectFactory or that the factory returned something + // which was not a Context. + } + catch (InstantiationException _3) + { + // If we couldn't instantiate the factory we might get + // this. + } + catch (IllegalAccessException _4) + { + // Another possibility when instantiating. + } + catch (NamingException _5) + { + throw _5; + } + catch (Exception _6) + { + // Anything from getObjectInstance. + } + } + + return null; + } + + /** + * Load the class with the given name. This method tries to use the context + * class loader first. If this fails, it searches for the suitable class + * loader in the caller stack trace. This method is a central point where all + * requests to find a class by name are delegated. + */ + static Class forName(String className) + { + try + { + return Class.forName(className, true, + Thread.currentThread().getContextClassLoader()); + } + catch (ClassNotFoundException nex) + { + /** + * Returns the first user defined class loader on the call stack, or + * null when no non-null class loader was found. + */ + Class[] ctx = VMStackWalker.getClassContext(); + for (int i = 0; i < ctx.length; i++) + { + // Since we live in a class loaded by the bootstrap + // class loader, getClassLoader is safe to call without + // needing to be wrapped in a privileged action. + ClassLoader cl = ctx[i].getClassLoader(); + try + { + if (cl != null) + return Class.forName(className, true, cl); + } + catch (ClassNotFoundException nex2) + { + // Try next. + } + } + } + return null; + } + + + /** + *

+ * Creates the URL context for the given URL scheme id. + *

+ *

+ * The class name of the factory that creates the context has the naming + * pattern scheme-idURLContextFactory. For instance, the factory for the + * "ftp" scheme should be named "ftpURLContextFactory". + * The Context.URL_PKG_PREFIXES environment property contains the + * colon-separated list of the possible package prefixes. The package name + * is constructed by concatenating the package prefix with the scheme id. + *

+ *

+ * If the factory class cannot be found in the specified packages, the + * system will try to use the default internal factory for the given scheme. + *

+ *

+ * After the factory is instantiated, its method + * {@link ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)} + * is called to create and return the object instance. + * + * @param scheme the url scheme that must be supported by the given context + * @param environment the properties for creating the factory and context + * (may be null) + * @return the created context + * @throws NamingException if thrown by the factory when creating the + * context. + */ + public static Context getURLContext (String scheme, + Hashtable environment) + throws NamingException + { + return getURLContext (null, null, null, scheme, environment); + } + + /** + * Sets the initial object factory builder. + * + * @param builder the builder to set + * + * @throws SecurityException if the builder cannot be installed due + * security restrictions. + * @throws NamingException if the builder cannot be installed due other + * reasons + * @throws IllegalStateException if setting the builder repeatedly + */ + public static void setObjectFactoryBuilder (ObjectFactoryBuilder builder) + throws NamingException + { + SecurityManager sm = System.getSecurityManager (); + if (sm != null) + sm.checkSetFactory (); + // Once the builder is installed it cannot be replaced. + if (ofb != null) + throw new IllegalStateException ("object factory builder already installed"); + if (builder != null) + ofb = builder; + } + + static StringTokenizer getPlusPath (String property, Hashtable env, + Context nameCtx) + throws NamingException + { + String path = (String) env.get (property); + if (nameCtx == null) + nameCtx = getInitialContext (env); + String path2 = (String) nameCtx.getEnvironment ().get (property); + if (path == null) + path = path2; + else if (path2 != null) + path += ":" + path2; + return new StringTokenizer (path != null ? path : "", ":"); + } + + /** + *

Creates an object for the specified name context, environment and + * referencing context object.

+ *

+ * If the builder factory is set by + * {@link #setObjectFactoryBuilder(ObjectFactoryBuilder)}, the call is + * delegated to that factory. Otherwise, the object is created using the + * following rules: + *

    + *
  • If the referencing object (refInfo) contains the factory class name, + * the object is created by this factory. If the creation fails, + * the parameter refInfo is returned as the method return value.
  • + *
  • If the referencing object has no factory class name, and the addresses + * are StringRefAddrs having the address type "URL", the object is + * created by the URL context factory. The used factory corresponds the + * the naming schema of the each URL. If the attempt to create + * the object this way is not successful, the subsequent rule is + * tried.
  • + *
  • If the refInfo is not an instance of Reference or Referencable + * (for example, null), the object is created by the factories, + * specified in the Context.OBJECT_FACTORIES property of the + * environment and the provider resource file, associated with the + * nameCtx. The value of this property is the colon separated list + * of the possible factories. If none of the factories can be + * loaded, the refInfo is returned. + *
+ *

+ *

The object factory must be public and have the public parameterless + * constructor.

+ * + * @param refInfo the referencing object, for which the new object must be + * created (can be null). If not null, it is usually an instance of + * the {@link Reference} or {@link Referenceable}. + * @param name the name of the object. The name is relative to + * the nameCtx naming context. The value of this parameter can be + * null if the name is not specified. + * @param nameCtx the naming context, in which scope the name of the new + * object is specified. If this parameter is null, the name is + * specified in the scope of the initial context. + * @param environment contains additional information for creating the object. + * This paramter can be null if there is no need to provide any + * additional information. + * + * @return the created object. If the creation fails, in some cases + * the parameter refInfo may be returned. + * + * @throws NamingException if the attempt to name the new object has failed + * @throws Exception if the object factory throws it. The object factory + * only throws an exception if it does not want other factories + * to be used to create the object. + */ + public static Object getObjectInstance (Object refInfo, + Name name, + Context nameCtx, + Hashtable environment) + throws Exception + { + ObjectFactory factory = null; + + if (ofb != null) + factory = ofb.createObjectFactory (refInfo, environment); + else + { + // First see if we have a Reference or a Referenceable. If so + // we do some special processing. + Object ref2 = refInfo; + if (refInfo instanceof Referenceable) + ref2 = ((Referenceable) refInfo).getReference (); + if (ref2 instanceof Reference) + { + Reference ref = (Reference) ref2; + + // If we have a factory class name then we use that. + String fClass = ref.getFactoryClassName (); + if (fClass != null) + { + // Exceptions here are passed to the caller. + Class k = Class.forName (fClass, + true, + Thread.currentThread().getContextClassLoader()); + factory = (ObjectFactory) k.newInstance (); + } + else + { + // There's no factory class name. If the address is a + // StringRefAddr with address type `URL', then we try + // the URL's context factory. + Enumeration e = ref.getAll (); + while (e.hasMoreElements ()) + { + RefAddr ra = (RefAddr) e.nextElement (); + if (ra instanceof StringRefAddr + && "URL".equals (ra.getType ())) + { + factory + = (ObjectFactory) getURLContext (refInfo, + name, + nameCtx, + (String) ra.getContent (), + environment); + Object obj = factory.getObjectInstance (refInfo, + name, + nameCtx, + environment); + if (obj != null) + return obj; + } + } + + // Have to try the next step. + factory = null; + } + } + + // Now look at OBJECT_FACTORIES to find the factory. + if (factory == null) + { + StringTokenizer tokens = getPlusPath (Context.OBJECT_FACTORIES, + environment, nameCtx); + + while (tokens.hasMoreTokens ()) + { + String klassName = tokens.nextToken (); + Class k = Class.forName (klassName, + true, + Thread.currentThread().getContextClassLoader()); + factory = (ObjectFactory) k.newInstance (); + Object obj = factory.getObjectInstance (refInfo, name, + nameCtx, environment); + if (obj != null) + return obj; + } + + // Failure. + return refInfo; + } + } + + if (factory == null) + return refInfo; + Object obj = factory.getObjectInstance (refInfo, name, + nameCtx, environment); + return obj == null ? refInfo : obj; + } + + /** + * Sets the initial context factory builder. + * + * @param builder the builder to set + * + * @throws SecurityException if the builder cannot be installed due + * security restrictions. + * @throws NamingException if the builder cannot be installed due other + * reasons + * @throws IllegalStateException if setting the builder repeatedly + * + * @see #hasInitialContextFactoryBuilder() + */ + public static void setInitialContextFactoryBuilder + (InitialContextFactoryBuilder builder) + throws NamingException + { + SecurityManager sm = System.getSecurityManager (); + if (sm != null) + sm.checkSetFactory (); + // Once the builder is installed it cannot be replaced. + if (icfb != null) + throw new IllegalStateException ("ctx factory builder already installed"); + if (builder != null) + icfb = builder; + } + + /** + * Creates a context in which the context operation must be continued. + * This method is used by operations on names that span multiple namespaces. + * + * @param cpe the exception that triggered this continuation. This method + * obtains the environment ({@link CannotProceedException#getEnvironment()} + * and sets the environment property {@link #CPE} = cpe. + * + * @return a non null context for continuing the operation + * + * @throws NamingException if the naming problems have occured + */ + public static Context getContinuationContext (CannotProceedException cpe) + throws NamingException + { + Hashtable env = cpe.getEnvironment (); + if (env != null) + env.put (CPE, cpe); + + // TODO: Check if this implementation matches the API specification + try + { + Object obj = getObjectInstance (cpe.getResolvedObj(), + cpe.getAltName (), + cpe.getAltNameCtx (), + env); + if (obj != null) + return (Context) obj; + } + catch (Exception _) + { + } + + // fix stack trace for re-thrown exception (message confusing otherwise) + cpe.fillInStackTrace(); + + throw cpe; + } + + /** + * Get the object state for binding. + * + * @param obj the object, for that the binding state must be retrieved. Cannot + * be null. + * @param name the name of this object, related to the nameCtx. Can be null if + * not specified. + * @param nameCtx the naming context, to that the object name is related. Can + * be null if the name is related to the initial default context. + * @param environment the properties for creating the object state. Can be + * null if no properties are provided. + * @return the object state for binding, may be null if no changes are + * returned by the factory + * @throws NamingException + */ + public static Object getStateToBind (Object obj, Name name, + Context nameCtx, Hashtable environment) + throws NamingException + { + StringTokenizer tokens = getPlusPath (Context.STATE_FACTORIES, + environment, nameCtx); + while (tokens.hasMoreTokens ()) + { + String klassName = tokens.nextToken (); + try + { + Class k = Class.forName (klassName, + true, + Thread.currentThread().getContextClassLoader()); + StateFactory factory = (StateFactory) k.newInstance (); + Object o = factory.getStateToBind (obj, name, nameCtx, + environment); + if (o != null) + return o; + } + catch (ClassNotFoundException _1) + { + // Ignore it. + } + catch (ClassCastException _2) + { + // This means that the class we found was not an + // ObjectFactory or that the factory returned something + // which was not a Context. + } + catch (InstantiationException _3) + { + // If we couldn't instantiate the factory we might get + // this. + } + catch (IllegalAccessException _4) + { + // Another possibility when instantiating. + } + } + + return obj; + } +} diff --git a/libjava/classpath/javax/naming/spi/ObjectFactory.java b/libjava/classpath/javax/naming/spi/ObjectFactory.java new file mode 100644 index 000000000..d44d2ff65 --- /dev/null +++ b/libjava/classpath/javax/naming/spi/ObjectFactory.java @@ -0,0 +1,76 @@ +/* ObjectFactory.java -- + Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.Name; + +/** + * Represents a factory for creating the object. ObjectFactory performs the + * operation, that is the opposite to the operation, performed by the + * {@link StateFactory}. Classes, implementing this interface, must be public + * and have public parameterless constructor. + */ +public interface ObjectFactory +{ + /** + * Creates the object, using the specified name and location information. The + * call of this method must be thread safe. + * + * @param refObj may provide the reference and location information. Can be null. + * @param name the name of the new object in the scope of the specified naming + * context. Can be null if the name is not specified. + * @param nameCtx the context, in which the object name is specified. Can be + * null if the name is specified in the scope of the default initial + * context. + * @param environment the properties, providing additional information on how + * to create an object. Can be null if not additional information is + * provided. + * @return the newly created object or null if the object cannot be created + * @throws Exception if this factory suggest not to try creating of this + * object by other alternative factories + * + * @see NamingManager#getObjectInstance(Object, Name, Context, Hashtable) + */ + Object getObjectInstance (Object refObj, Name name, Context nameCtx, + Hashtable environment) + throws Exception; +} diff --git a/libjava/classpath/javax/naming/spi/ObjectFactoryBuilder.java b/libjava/classpath/javax/naming/spi/ObjectFactoryBuilder.java new file mode 100644 index 000000000..e0886d144 --- /dev/null +++ b/libjava/classpath/javax/naming/spi/ObjectFactoryBuilder.java @@ -0,0 +1,70 @@ +/* ObjectFactoryBuilder.java -- the builder that creates the object factories. + Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import java.util.Hashtable; + +import javax.naming.NamingException; +import javax.naming.Reference; +import javax.naming.Referenceable; + +/** + * Represents the builder that creates the object factories. + * + * @see NamingManager#setObjectFactoryBuilder(ObjectFactoryBuilder) + * + * @author Warren Levy (warrenl@redhat.com) + */ +public interface ObjectFactoryBuilder +{ + /** + * Create a new object using the supplied environment. + * + * @param refInfo the referencing object, for which the new object must be + * created (can be null). If not null, it is usually an instance of + * the {@link Reference} or {@link Referenceable}. + * @param environment contains the additional information about the factory + * being created. Can be null. + * @return the created object factory. The null is never returned. + * @throws NamingException + */ + ObjectFactory createObjectFactory(Object refInfo, + Hashtable environment) + throws NamingException; +} diff --git a/libjava/classpath/javax/naming/spi/ResolveResult.java b/libjava/classpath/javax/naming/spi/ResolveResult.java new file mode 100644 index 000000000..3945b9b43 --- /dev/null +++ b/libjava/classpath/javax/naming/spi/ResolveResult.java @@ -0,0 +1,182 @@ +/* ResolveResult.java -- + Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import java.io.Serializable; + +import javax.naming.CompositeName; +import javax.naming.InvalidNameException; +import javax.naming.Name; + +/** + * Stores the partial resolution of the name. This class contains the + * object to which part of the name has been resolved and the remaining, + * unresolved part of this name. + * + * @author Warren Levy (warrenl@redhat.com) + */ + +public class ResolveResult implements Serializable +{ + private static final long serialVersionUID = - 4552108072002407559L; + + // Serialized fields. + /** + * The object, to that part of the name has been resolved. + */ + protected Object resolvedObj; + + /** + * The remaining, unresolved part of the name. + */ + protected Name remainingName; + + /** + * Create the unitialised instance with both parts being null. + */ + protected ResolveResult() + { + } + + /** + * Create the initialised instance + * + * @param resolved the object, to that the name is partially resolved + * @param remaining the remaining unresolved part of the name. + */ + public ResolveResult(Object resolved, String remaining) + { + if (resolved == null || remaining == null) + throw new IllegalArgumentException (); + resolvedObj = resolved; + remainingName = new CompositeName (); + try + { + remainingName.add (remaining); + } + catch (InvalidNameException _) + { + } + } + + /** + * Create the initialised instance + * + * @param resolved the object, to that the name is partially resolved + * @param remaining the remaining unresolved part of the name. + */ + public ResolveResult(Object resolved, Name remaining) + { + resolvedObj = resolved; + remainingName = remaining; + } + + /** + * Get the remaining unresolved part of the name + * + * @return the remaining unresolved part of the name. + */ + public Name getRemainingName() + { + return remainingName; + } + + /** + * Get the object to that the name was partially resolved + * + * @return the object, to that the name is partially resolved + */ + public Object getResolvedObj() + { + return resolvedObj; + } + + /** + * Set the remaining unresolved name. + * + * @param name the name being set. The passed parameter is cloned, so the + * caller can reuse or modify it after the method returns. + */ + public void setRemainingName(Name name) + { + remainingName = (Name) name.clone(); + } + + /** + * Append the name to the end of the resolved name. + * + * @param name the name to append + */ + public void appendRemainingName(Name name) + { + try + { + remainingName.addAll(name); + } + catch (InvalidNameException _) + { + } + } + + /** + * Append the name to the end of the resolved name. + * + * @param name the name to append + */ + public void appendRemainingComponent(String name) + { + try + { + remainingName.add(name); + } + catch (InvalidNameException _) + { + } + } + + /** + * Set the object to that the part of the name has been resolved. + * + * @param obj the object, to that the name has been partially resolved. + */ + public void setResolvedObj(Object obj) + { + resolvedObj = obj; + } +} diff --git a/libjava/classpath/javax/naming/spi/Resolver.java b/libjava/classpath/javax/naming/spi/Resolver.java new file mode 100644 index 000000000..7a009fabc --- /dev/null +++ b/libjava/classpath/javax/naming/spi/Resolver.java @@ -0,0 +1,62 @@ +/* Resolver.java -- + Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NamingException; + +/** + *

Represents the object, capable for the at least partial name resolution. + * The object is not necessay capable for the complete name resolution and + * need not implement the {@link Context}.

+ *

+ * Both passed parameters and returned results are owned by the caller.

+ * + * @author Warren Levy (warrenl@redhat.com) + */ +public interface Resolver +{ + ResolveResult resolveToClass(Name name, + Class contextType) + throws NamingException; + ResolveResult resolveToClass(String name, + Class contextType) + throws NamingException; +} diff --git a/libjava/classpath/javax/naming/spi/StateFactory.java b/libjava/classpath/javax/naming/spi/StateFactory.java new file mode 100644 index 000000000..d674803a4 --- /dev/null +++ b/libjava/classpath/javax/naming/spi/StateFactory.java @@ -0,0 +1,79 @@ +/* StateFactory.java -- + Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.naming.spi; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NamingException; + +/** + * Represents a factory, producing the object states for binding. The operation, + * performed by this factory, is the reverse operation with related to the + * operation, performed by the {@link ObjectFactory}. Classes, implementing + * this interface, must be public and have public parameterless constructor. + * + * @see DirStateFactory + * @see ObjectFactory + * @author Warren Levy (warrenl@redhat.com) + */ +public interface StateFactory +{ + /** + * Get the object state for binding. + * + * @param obj the object, for that the binding state must be retrieved. Cannot + * be null. + * @param name the name of this object, related to the nameCtx. Can be null if + * not specified. + * @param nameCtx the naming context, to that the object name is related. Can + * be null if the name is related to the initial default context. + * @param environment the properties for creating the object state. Can be + * null if no properties are provided. + * @return the object state for binding, may be null if no changes are + * returned by the factory + * @throws NamingException + * + * @see NamingManager#getStateToBind + * @see DirectoryManager#getStateToBind + */ + Object getStateToBind(Object obj, Name name, Context nameCtx, + Hashtable environment) throws NamingException; +} diff --git a/libjava/classpath/javax/naming/spi/package.html b/libjava/classpath/javax/naming/spi/package.html new file mode 100644 index 000000000..b55e97a40 --- /dev/null +++ b/libjava/classpath/javax/naming/spi/package.html @@ -0,0 +1,46 @@ + + + + +GNU Classpath - javax.naming.spi + + +

+ + + -- cgit v1.2.3