harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r386087 [8/45] - in /incubator/harmony/enhanced/classlib/trunk: make/ make/patternsets/ modules/jndi/ modules/jndi/META-INF/ modules/jndi/make/ modules/jndi/make/common/ modules/jndi/src/ modules/jndi/src/main/ modules/jndi/src/main/java/ m...
Date Wed, 15 Mar 2006 14:57:17 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/InitialLdapContext.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/InitialLdapContext.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/InitialLdapContext.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/InitialLdapContext.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,167 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.ldap;
+
+import java.util.Hashtable;
+import javax.naming.directory.InitialDirContext;
+import javax.naming.NamingException;
+import javax.naming.NotContextException;
+
+/**
+ * This is used as the starting context when the LDAPv3 extended functionality
+ * provided by the <code>javax.naming.ldap</code> package is required.
+ *
+ * See <code>LdapContext</code> for a description of the Request and Response 
+ * controls.
+ * 
+ * @see LdapContext
+ * 
+ */
+public class InitialLdapContext
+    extends InitialDirContext
+    implements LdapContext {
+
+    /*
+     * -------------------------------------------------------------------
+     * Constants
+     * -------------------------------------------------------------------
+     */
+
+    /*
+     * This is set to the environment property java.naming.ldap.version. 
+     */
+    private static final String LDAP_VERSION = "java.naming.ldap.version"; //$NON-NLS-1$
+
+    /*
+     * This is set to the environment property java.naming.ldap.control.connect.
+     */
+    private static final String CONNECT_CONTROL =
+        "java.naming.ldap.control.connect"; //$NON-NLS-1$
+
+    /*
+     * The version of this LDAP context implementaton. 
+     */
+    private static final String THIS_LDAP_VERSION = "3"; //$NON-NLS-1$
+
+    /*
+     * -------------------------------------------------------------------
+     * Constructors
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Constructs an <code>InitialLdapContext</code> instance without using 
+     * any environment properties or connection controls.
+     * 
+     * @throws NamingException  If an error is encountered. 
+     */
+    public InitialLdapContext() throws NamingException {
+        this(null, null);
+    }
+
+    /**
+     * Constructs an <code>InitialLdapContext</code> instance using the supplied
+     * environment properties and connection controls.
+     * 
+     * @param h                 the environment properties which may be null
+     * @param cs                the connection controls which may be null
+     * @throws NamingException  If an error is encountered.
+     */
+    public InitialLdapContext(Hashtable h, Control[] cs)
+        throws NamingException {
+        super(true);
+
+        /* 
+         * Prepare the environment properties to be inherited by the 
+         * service provider.
+         */
+        Hashtable newEnvironment = null;
+        if (null == h) {
+            newEnvironment = new Hashtable();
+        } else {
+            newEnvironment = (Hashtable) h.clone();
+        }
+
+        // Set the environment property java.naming.ldap.control.connect
+        if (null != cs) {
+            Control[] cloneOfCs = new Control[cs.length];
+            System.arraycopy(cs, 0, cloneOfCs, 0, cs.length);
+            newEnvironment.put(CONNECT_CONTROL, cloneOfCs);
+        }
+
+        // Set the enviroment property java.naming.ldap.version to be 3
+        newEnvironment.put(LDAP_VERSION, THIS_LDAP_VERSION);
+
+        // Initialize the initial context
+        super.init(newEnvironment);
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /*
+     * Gets the default initial context and verify that it's an instance of
+     * LdapContext.
+     */
+    private LdapContext getDefaultInitLdapContext() throws NamingException {
+        if (!(super.defaultInitCtx instanceof LdapContext)) {
+            throw new NotContextException("Expected an LdapContext object."); //$NON-NLS-1$
+        }
+        return (LdapContext) super.defaultInitCtx;
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods of Interface LdapContext
+     * -------------------------------------------------------------------
+     */
+
+    public ExtendedResponse extendedOperation(ExtendedRequest e)
+        throws NamingException {
+        return getDefaultInitLdapContext().extendedOperation(e);
+    }
+
+    public LdapContext newInstance(Control[] ac) throws NamingException {
+        return getDefaultInitLdapContext().newInstance(ac);
+    }
+
+    public void reconnect(Control[] ac) throws NamingException {
+        getDefaultInitLdapContext().reconnect(ac);
+    }
+
+    public Control[] getConnectControls() throws NamingException {
+        return getDefaultInitLdapContext().getConnectControls();
+    }
+
+    public void setRequestControls(Control[] ac) throws NamingException {
+        getDefaultInitLdapContext().setRequestControls(ac);
+    }
+
+    public Control[] getRequestControls() throws NamingException {
+        return getDefaultInitLdapContext().getRequestControls();
+    }
+
+    public Control[] getResponseControls() throws NamingException {
+        return getDefaultInitLdapContext().getResponseControls();
+    }
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapContext.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapContext.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapContext.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapContext.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,136 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.ldap;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+/**
+ * An <code>LdapContext</code> is used when LDAPv3 extended operations and/or
+ * controls are required.
+ * <p>
+ * Extended operations are dealt with by the <code>extendedOperation</code> 
+ * method. All other methods relate to the use of controls. Controls are extra 
+ * information provided to or from an LDAP v3 server. Controls are either of the
+ * type <code>Request</code> or <code>Reponse</code>. There is a special type of
+ * request controls known as connection controls.</p>
+ * <p>
+ * Connection controls are used by a service provider when connecting or
+ * reconnecting to an LDAP server. These are associated with connections and are
+ * inherited by derived <code>Context</code>. It should be noted however that
+ * subsequent changes to a derived <code>Context</code>'s own connection 
+ * controls has no impact on the <code>Context</code> from which it inherited.
+ * There are a number of environment properties which relate specifically to
+ * LDAP service providers. The one which is important here is:
+ * <code>java.naming.ldap.control.connect</code> which holds the array of 
+ * connection controls for a <code>Context</code>. Service providers rely on
+ * this to pass on the connection controls to derived <code>Context</code>.</p>
+ * <p>
+ * Request controls are used by a service provider when performing operations
+ * other than connecting or reconnecting. These are referred to as Context
+ * Request Controls as they relate to the specific <code>Context</code> 
+ * instance. It must be noted that, unlike connection controls, they are not
+ * inherited. Connection and request controls being split like this allows 
+ * service provider implementations to pool connections.</p> 
+ * <p>
+ * Response controls are generated by an LDAPv3 server.</p>
+ * 
+ * @see DirContext
+ *
+ */
+public interface LdapContext extends DirContext {
+
+    /*
+     * -------------------------------------------------------------------
+     * Constants
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * This is set to the environment property java.naming.factory.control. 
+     */
+    static final String CONTROL_FACTORIES = "java.naming.factory.control"; //$NON-NLS-1$
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Deals with extended operations of LDAPv3.
+     * 
+     * @param e                 an extended request
+     * @return                  an extended response for the supplied request
+     * @throws NamingException  If an error is encountered.
+     */
+    ExtendedResponse extendedOperation(ExtendedRequest e)
+        throws NamingException;
+
+    /**
+     * Creates a new instance of <code>LdapContext</code> using the supplied
+     * controls.
+     * 
+     * @param ac                an array of controls
+     * @return                  a new <code>LdapContext</code> instance
+     * @throws NamingException  If an error is encountered.
+     */
+    LdapContext newInstance(Control[] ac) throws NamingException;
+
+    /**
+     * Reconnects using the supplied controls.
+     * 
+     * @param ac                an array of controls
+     * @throws NamingException  If an error is encountered.
+     */
+    void reconnect(Control[] ac) throws NamingException;
+
+    /**
+     * Gets an array of connection controls.
+     * 
+     * @return                  an array of connection controls
+     * @throws NamingException  If an error is encountered.
+     */
+    Control[] getConnectControls() throws NamingException;
+
+    /**
+     * Sets the request controls.
+     * 
+     * @param ac                an array of request controls
+     * @throws NamingException  If an error is encountered.
+     */
+    void setRequestControls(Control[] ac) throws NamingException;
+
+    /**
+     * Gets the request controls.
+     * 
+     * @return                  an array of request controls
+     * @throws NamingException  If an error is encountered.
+     */
+    Control[] getRequestControls() throws NamingException;
+
+    /**
+     * Gets the response controls.
+     * 
+     * @return                  an array of response controls
+     * @throws NamingException  If an error is encountered.
+     */
+    Control[] getResponseControls() throws NamingException;
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapReferralException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapReferralException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapReferralException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapReferralException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,107 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.ldap;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.ReferralException;
+
+/**
+ * <code>LdapReferralException</code> is an abstract exception which extends
+ * <code>ReferralException</code> to handle LDAPv3 request controls.
+ * 
+ */
+public abstract class LdapReferralException extends ReferralException {
+
+    /*
+     * -------------------------------------------------------------------
+     * Constants
+     * -------------------------------------------------------------------
+     */
+
+    /* 
+     * This constant is used during deserialization to check the J2SE version which
+     * created the serialized object.
+     */
+    static final long serialVersionUID = -1668992791764950804L; // J2SE 1.4.2
+
+    /*
+     * -------------------------------------------------------------------
+     * Constructors
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Default constructor.
+     */
+    protected LdapReferralException() {
+    	super();
+    }
+
+    /**
+     * Constructs an LdapReferralException instance using the supplied text of
+     * the message
+     * @param s				the supplied text of the message, which may be null
+     */
+    protected LdapReferralException(String s) {
+        super(s);
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Gets referal context without environment properties.
+     * 
+     * @return 				referral context
+     * @throws NamingException
+     * 						If cannot get referral context correctly.
+     */
+    public abstract Context getReferralContext() throws NamingException;
+
+    /**
+     * Gets referal context with environment properties.
+     * 
+     * @param h				environment properties			
+     * @return 				referral context
+     * @throws NamingException
+     * 						If cannot get referral context correctly.
+     */
+    public abstract Context getReferralContext(Hashtable h)
+        throws NamingException;
+
+    /**
+     * Gets referal context with environment properties and an array of LDAPv3
+     * controls.
+     * 
+     * @param h				environment properties
+     * @param cs			array of LDAPv3 controls
+     * @return 				referral context
+     * @throws NamingException
+     * 						If cannot get referral context correctly.
+     */
+    public abstract Context getReferralContext(Hashtable h, Control[] cs)
+        throws NamingException;
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotification.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotification.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotification.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotification.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,57 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.ldap;
+
+import javax.naming.NamingException;
+
+/**
+ * See RFC2251 for the definition of an <code>UnsolicitedNotification</code>.
+ * 
+ * @see ExtendedResponse
+ * @see HasControls
+ * 
+ */
+public interface UnsolicitedNotification
+    extends ExtendedResponse, HasControls {
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Gets the referrals associated with this <code>UnsolicitedNotification
+     * </code> instance.
+     * 
+     * @return  the referrals associated with this <code>
+     *          UnsolicitedNotification</code> instance
+     */
+    String[] getReferrals();
+
+    /**
+     * Gets the naming exception associated with this <code>
+     * UnsolicitedNotification</code> instance.
+     * 
+     * @return  the naming exception associated with this <code>
+     *          UnsolicitedNotification</code> instance
+     */
+    NamingException getException();
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotificationEvent.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotificationEvent.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotificationEvent.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotificationEvent.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,102 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.ldap;
+
+import java.util.EventObject;
+
+/**
+ * This event is fired when an LDAP server sends an unsolited notification.
+ * (See RFC2251). 
+ * 
+ * 
+ */
+public class UnsolicitedNotificationEvent extends EventObject {
+
+    /*
+     * -------------------------------------------------------------------
+     * Constants
+     * -------------------------------------------------------------------
+     */
+
+    /* 
+     * This constant is used during deserialization to check the J2SE version 
+     * which created the serialized object.
+     */
+    static final long serialVersionUID = -2382603380799883705L; //J2SE 1.4.2
+
+    /*
+     * -------------------------------------------------------------------
+     * Instance variables
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * The specific notification.
+     * 
+     * @serial
+     */ 
+    private UnsolicitedNotification notice;
+
+    /*
+     * -------------------------------------------------------------------
+     * Constructors
+     * -------------------------------------------------------------------
+     */
+    
+    /**
+     * Constructs an <code>UnsolicitedNotificationEvent</code> instance using
+     * the supplied <code>UnsolicitedNotification</code> instance.
+     * 
+     * @param o     the source of the event which cannot be null
+     * @param un    the <code>UnsolicitedNotification</code> instance which
+     *              cannot be null
+     */ 
+    public UnsolicitedNotificationEvent(Object o, UnsolicitedNotification un) {
+        super(o);
+        this.notice = un;
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Returns the <code>UnsolicitedNotification</code> instance associated with
+     * this event. 
+     * 
+     * @return      the <code>UnsolicitedNotification</code> instance associated 
+     *              with this event
+     */
+    public UnsolicitedNotification getNotification() {
+        return notice;
+    }
+
+    /**
+     * Uses this event to trigger a notification received on the supplied 
+     * listener.
+     * 
+     * @param unl   the listener to dispatch this event to. It cannot be null.
+     */
+    public void dispatch(UnsolicitedNotificationListener unl) {
+        unl.notificationReceived(this);
+    }
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotificationListener.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotificationListener.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotificationListener.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/UnsolicitedNotificationListener.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,45 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.ldap;
+
+import javax.naming.event.NamingListener;
+
+/**
+ * A listener that wishes to receive unsolicited notifications.
+ * See RFC2251 for the definition of an <code>UnsolicitedNotification</code>.
+ * 
+ * @see UnsolicitedNotification
+ * 
+ */
+public interface UnsolicitedNotificationListener extends NamingListener {
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Accepts an unsolicited notification.
+     * 
+     * @param e     an unsolicited notification
+     */
+    void notificationReceived(UnsolicitedNotificationEvent e);
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirObjectFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirObjectFactory.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirObjectFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirObjectFactory.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,63 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.spi;
+
+import java.util.Hashtable;
+import javax.naming.Name;
+import javax.naming.Context;
+import javax.naming.directory.Attributes;
+
+/**
+ * An <code>DirObjectFactory</code> creates objects of a specified type. 
+ * <code>DirObjectFactory</code> is a specific version of 
+ * <code>ObjectFactory</code> for <code>DirectoryManager</code>.
+ * 
+ * @see ObjectFactory
+ * @see DirectoryManager
+ */
+public interface DirObjectFactory extends ObjectFactory {
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Similar to <code>ObjectFactory.getObjectInstance</code>, with an 
+     * additional <code>attributes</code> parameter.
+     * 
+     * @param o     an object
+     * @param n     a name
+     * @param c     a context
+     * @param envmt a context environment
+     * @param a     some attributes
+     * @return      the created object
+     * @throws Exception if an exception occurs
+     * @see ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)
+     */
+    Object getObjectInstance(
+        Object o,
+        Name n,
+        Context c,
+        Hashtable envmt,
+        Attributes a)
+        throws Exception;
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirStateFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirStateFactory.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirStateFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirStateFactory.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,134 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.spi;
+
+import java.util.Hashtable;
+import javax.naming.Name;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+
+/**
+ * The <code>DirStateFactory</code> interface describes a factory used to get 
+ * the state of an object to be bound. <code>DirStateFactory</code> is a 
+ * specific version of <code>StateFactory</code> for 
+ * <code>DirectoryManager</code>.
+ * 
+ * @see StateFactory
+ * @see DirectoryManager
+ */
+public interface DirStateFactory extends StateFactory {
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Similar to <code>StateFactory.getStateToBind</code> with an additional
+     * <code>attributes</code> parameter.
+     * 
+     * @param o     an object
+     * @param n     a name
+     * @param c     a context
+     * @param envmt a context environment
+     * @param a     some attributes
+     * @return      the state as a <code>Result</code> instance, containing
+     *              an object and associated attributes.
+     * @throws NamingException if an exception occurs
+     * @see StateFactory#getStateToBind(Object, Name, Context, Hashtable)
+     */
+    Result getStateToBind(
+        Object o,
+        Name n,
+        Context c,
+        Hashtable envmt,
+        Attributes a)
+        throws NamingException;
+
+    /*
+     * -------------------------------------------------------------------
+     * Inner classes
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Used by the <code>DirectoryManager.getStateToBind</code> method as
+     * the returning value.
+     */
+    public static class Result {
+
+        /*
+         * -------------------------------------------------------------------
+         * Instance variables
+         * -------------------------------------------------------------------
+         */
+
+        // the Object returned by DirectoryManager.getStateToBind.
+        private Object obj;
+
+        // the Attributes returned by DirectoryManager.getStateToBind.
+        private Attributes attrs;
+
+        /*
+         * -------------------------------------------------------------------
+         * Constructors
+         * -------------------------------------------------------------------
+         */
+
+        /**
+         * Creates an instance of <code>DirStateFactory.Result</code>
+         * 
+         * @param o the object returned by 
+         *          <code>DirectoryManager.getStateToBind</code>. May be null.
+         * @param a the attributes returned by 
+         *          <code>DirectoryManager.getStateToBind</code>. May be null.
+         */
+        public Result(Object o, Attributes a) {
+            this.obj = o;
+            this.attrs = a;
+        }
+
+        /*
+         * -------------------------------------------------------------------
+         * Methods
+         * -------------------------------------------------------------------
+         */
+
+        /**
+         * Returns the object associated with this result.
+         * 
+         * @return the object associated with this result.
+         */
+        public Object getObject() {
+            return this.obj;
+        }
+
+        /**
+         * Returns the attributes associated with this result.
+         * 
+         * @return the attributes associated with this result.
+         */
+        public Attributes getAttributes() {
+            return this.attrs;
+        }
+    }
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirectoryManager.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirectoryManager.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirectoryManager.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirectoryManager.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,1116 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.spi;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+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.NameParser;
+import javax.naming.NamingEnumeration;
+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;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+import javax.naming.spi.DirStateFactory.Result;
+
+import com.ibm.jndi.EnvironmentReader;
+import com.ibm.jndi.UrlParser;
+
+/**
+ * The <code>DirectoryManager</code> class cannot be instantiated. All its
+ * methods are static. The methods are used by service providers for accessing
+ * object and state factories and for determining continuation contexts.
+ * <p>
+ * The <code>Name</code> and <code>Hashtable</code> arguments passed to the
+ * <code>DirectoryManager</code> methods remain owned purely by the calling
+ * method. They must not be changed or referenced.</p>
+ * <p>
+ * Multithreaded access to this class must be safe.</p>
+ *
+ */
+public class DirectoryManager extends NamingManager {
+
+    /*
+     * -------------------------------------------------------------------
+     * Class variables
+     * -------------------------------------------------------------------
+     */
+    /*
+     * -------------------------------------------------------------------
+     * Constructors
+     * -------------------------------------------------------------------
+     */
+    private DirectoryManager(){//private to prevent it being instanced        
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Create an object using an object factory.
+     * Returns a new <code>Object</code> or the supplied <code>Object o</code>
+     * if one cannot be created.
+     *
+     * The behaviour is like that for the
+     * <code>getObjectInstance</code> method of <code>NamingManager</code>
+     * however it should be noted that the intermediate object factory may be
+     * either of type <code>DirObjectFactory</code> or of type
+     * <code>ObjectFactory</code>; in the former case, the supplied
+     * <code>Attributes</code> must be passed when getting the object,
+     * otherwise the supplied <code>Attributes</code> are ignored.
+     *
+     * @param o An object which may provide reference or location information.
+     *          May be null.
+     * @param n The name of the <code>Object</code> relative to the default
+     *          initial context (or relative to the Context c if it is supplied)
+     * @param c The <code>Context</code> to which the Name is relative
+     * @param h a <code>Hashtable</code> containing environment properties and
+     *          values - may be null
+     * @param a <code>Attributes</code> - if some or all of the attributes of
+     *          <code>Object o</code> are already known they can be supplied so
+     *          that the factory does not have to do the work of looking them up.
+     * @return  the created object
+     * @throws NamingException if one is encountered
+     * @throws Exception if any other exception is encountered
+     */
+    public static Object getObjectInstance(
+        Object o,
+        Name n,
+        Context c,
+        Hashtable h,
+        Attributes a)
+        throws NamingException, Exception {
+
+        // 1. try ObjectFactoryBuilder, if it is set
+        if (null != ofb) {
+            // use the builder to create an object factory
+            ObjectFactory factory = ofb.createObjectFactory(o, h);
+            // get object instance using the factory and return
+            return getObjectInstanceFromGivenFactory(factory, o, n, c, h, a);
+        }
+
+        // 2. see whether o is a Referenceable or a Reference
+        Reference ref = null;
+        if (o instanceof Referenceable) {
+            ref = ((Referenceable) o).getReference();
+        }
+        if (o instanceof Reference) {
+            ref = (Reference) o;
+        }
+        // if o is a Referenceable or a Reference
+        if (null != ref) {
+            // if a factory class name is supplied by the reference, use it to create
+            if (null != ref.getFactoryClassName()) {
+                return getObjectInstanceByFactoryInReference(ref, o, n, c, h, a);
+            }
+            // see if ref has any StringRefAddrs of address type URL, 
+            Object result = getObjectInstanceByUrlRefAddr(n, c, h, ref);
+            // if success, return it
+            if (null != result) {
+                return result;
+            }
+        }
+
+        // 3. try Context.OBJECT_FACTORIES
+        Object result = getObjectInstanceByObjectFactory(o, n, c, h, a);
+        if (null != result) {
+            return result;
+        }
+
+        // all failed, just return o
+        return o;
+    }
+
+    /*
+     * Check the type of factory, DirObjectFactory or ObjectFactory, and
+     * call getObjectInstance() on the property type.
+     */
+    private static Object getObjectInstanceFromGivenFactory(
+        ObjectFactory factory,
+        Object o,
+        Name n,
+        Context c,
+        Hashtable h,
+        Attributes a) throws Exception {
+        if (factory instanceof DirObjectFactory) {
+            return ((DirObjectFactory) factory).getObjectInstance(o, n, c, h, a);
+        }
+		return factory.getObjectInstance(o, n, c, h);
+    }
+
+    private static Object getObjectInstanceByObjectFactory(
+        Object o,
+        Name n,
+        Context c,
+        Hashtable h,
+        Attributes a)
+        throws NamingException, Exception {
+        // obtain object factories from hashtable and service provider resource file
+        String fnames[] =
+            EnvironmentReader.getFactoryNamesFromEnvironmentAndProviderResource(
+                h,
+                c,
+                Context.OBJECT_FACTORIES);
+        // for each object factory
+        for (int i = 0; i < fnames.length; i++) {
+            // new factory instance by its class name
+            ObjectFactory factory = null;
+            try {
+                factory = (ObjectFactory) classForName(fnames[i]).newInstance();
+            } catch (Exception e) {
+                continue;
+            }
+            // create object using factory
+            Object obj = getObjectInstanceFromGivenFactory(factory, o, n, c, h, a);
+            if (null != obj) {
+                return obj;
+            }
+        }
+        // no object factory succeeded, return null
+        return null;
+    }
+
+    private static Object getObjectInstanceByUrlRefAddr(
+        Name n,
+        Context c,
+        Hashtable h,
+        Reference ref)
+        throws NamingException {
+        // obtain pkg prefixes from hashtable and service provider resource file
+        String pkgPrefixes[] =
+            EnvironmentReader.getFactoryNamesFromEnvironmentAndProviderResource(
+                h,
+                c,
+                Context.URL_PKG_PREFIXES);
+        // for each RefAddr
+        Enumeration enumeration = ref.getAll();
+        while (enumeration.hasMoreElements()) {
+            RefAddr addr = (RefAddr) enumeration.nextElement();
+            // if it is StringRefAddr and type is URL
+            if (addr instanceof StringRefAddr
+                && addr.getType().equalsIgnoreCase("URL")) { //$NON-NLS-1$
+                // get the url address
+                String url = (String) ((StringRefAddr) addr).getContent();
+                // try create using url context factory
+                Object obj =
+                    getObjectInstanceByUrlContextFactory(
+                        url,
+                        n,
+                        c,
+                        h,
+                        pkgPrefixes,
+                        UrlParser.getScheme(url));
+                // if success, return the created obj
+                if (null != obj) {
+                    return obj;
+                }
+            }
+        }
+        // failed to create using any StringRefAddr of address type URL, return null
+        return null;
+    }
+
+    private static Object getObjectInstanceByUrlContextFactory(
+        String url,
+        Name n,
+        Context c,
+        Hashtable h,
+        String pkgPrefixes[],
+        String schema)
+        throws NamingException {
+        // if schema is empty or null, fail, return null
+        if (null == schema || 0 == schema.length()) {
+            return null;
+        }
+
+        // for each pkg prefix
+        for (int i = 0; i < pkgPrefixes.length; i++) {
+            ObjectFactory factory = null;
+            try {
+                // create url context factory instance
+                String clsName =
+                    pkgPrefixes[i] + "." + schema + "." + schema + "URLContextFactory"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                factory = (ObjectFactory) classForName(clsName).newInstance();
+            } catch (Exception e) {
+                // failed to create factory, continue trying
+                continue;
+            }
+            try {
+                // create obj using url context factory
+                /*
+                 * Unit test shows it is ObjectFactory here, not DirObjectFactory
+                 * // Object obj = factory.getObjectInstance(url, n, c, h, a);
+                 */
+                Object obj = factory.getObjectInstance(url, n, c, h);
+                // if create success, return it
+                if (null != obj) {
+                    return obj;
+                }
+            } catch (Exception e) {
+                // throw NamingException, if factory fails
+                if (e instanceof NamingException) {
+                    throw (NamingException) e;
+                }
+                NamingException nex =
+                    new NamingException("Failed to create object instance"); //$NON-NLS-1$
+                nex.setRootCause(e);
+                throw nex;
+            }
+        }
+        // fail to create using url context factory, return null
+        return null;
+    }
+
+    private static Object getObjectInstanceByFactoryInReference(
+        Reference ref,
+        Object o,
+        Name n,
+        Context c,
+        Hashtable h,
+        Attributes a)
+        throws Exception {
+        ObjectFactory factory = null;
+
+        // try load the factory by its class name
+        try {
+            factory =
+                (ObjectFactory) classForName(ref.getFactoryClassName()).newInstance();
+        } catch (ClassNotFoundException e) {
+        	// Ignored.
+        }
+
+        // try load the factory from its class location
+        if (null == factory && null != ref.getFactoryClassLocation()) {
+            factory =
+                (ObjectFactory) loadFactoryFromLocation(ref.getFactoryClassName(),
+                    ref.getFactoryClassLocation());
+        }
+        // if factory cannot be loaded
+        if (null == factory) {
+            // return o
+            return o;
+        }
+
+        // get object instance using the factory and return it
+        return getObjectInstanceFromGivenFactory(factory, ref, n, c, h, a);
+    }
+
+    /*
+     * If cannot load class, return null.
+     * Throws any exceptions except ClassNotFoundException
+     */
+    private static Object loadFactoryFromLocation(String clsName, String location)
+        throws Exception {
+
+        // convert location into an array of URL, separated by ' '
+        StringTokenizer st = new StringTokenizer(location, " "); //$NON-NLS-1$
+        URL urls[] = new URL[st.countTokens()];
+        for (int i = 0; i < urls.length; i++) {
+            urls[i] = new URL(st.nextToken());
+        }
+
+        // new a URLClassLoader from the URLs
+        URLClassLoader l = new URLClassLoader(urls);
+
+        // try load factory by URLClassLoader
+        try {
+            // return the new instance
+            return l.loadClass(clsName).newInstance();
+        } catch (ClassNotFoundException e) {
+            // return null if class loading failed
+            return null;
+        }
+    }
+
+    /**
+     * Get the state of an Object.
+     * Returns a <code>DirStateFactory</code>. Result which cannot be null. It
+     * contains the attributes and object to be bound, either of which may be
+     * null. Once returned the caller is the owner of it.
+     * The behaviour is like that for the <code>getStateToBind</code> method of
+     * <code>NamingManager</code> however it should be noted that the
+     * intermediate state factory may be of type <code>DirStateFactory</code>
+     * rather than just <code>StateFactory</code> in which case it should also
+     * use the supplied <code>Attributes</code> when getting the state.
+     *
+     * @param o An object which may provide reference or location information.
+     *          May be null.
+     * @param n The name of the <code>Object</code> relative to the default
+     *          initial context (or relative to the Context c if it is supplied)
+     * @param c The <code>Context</code> to which the <code>Name</code> is
+     *          relative
+     * @param h a <code>Hashtable</code> containing environment properties and
+     *          values - may be null
+     * @param a <code>Attributes</code> - if some or all of the attributes of
+     *          <code>Object o</code> are already known they can be supplied so
+     *          that the factory does not have to do the work of looking them up.
+     * @return  the state of the object
+     * @throws NamingException if one is encountered
+     */
+    public static DirStateFactory.Result getStateToBind(
+        Object o,
+        Name n,
+        Context c,
+        Hashtable h,
+        Attributes a)
+        throws NamingException {
+
+        // obtain state factories from hashtable and service provider resource file
+        String fnames[] =
+            EnvironmentReader.getFactoryNamesFromEnvironmentAndProviderResource(
+                h,
+                c,
+                Context.STATE_FACTORIES);
+
+        // for each state factory
+        for (int i = 0; i < fnames.length; i++) {
+            // new factory instance by its class name
+            StateFactory factory = null;
+            try {
+                factory = (StateFactory) classForName(fnames[i]).newInstance();
+            } catch (Exception e) {
+                continue;
+            }
+            if (factory instanceof DirStateFactory) {
+                // try obtain state using the DirStateFactory
+                Result r = ((DirStateFactory) factory).getStateToBind(o, n, c, h, a);
+                // if the result is not null, return it
+                if (null != r) {
+                    return r;
+                }
+            } else {
+                // try obtain state using the StateFactory
+                Object state = factory.getStateToBind(o, n, c, h);
+                // if a state obtained successfully, return it
+                if (null != state) {
+                    return new Result(state, a);
+                }
+            }
+        }
+
+        // all factories failed, return the input argument o
+        return new Result(o, a);
+    }
+
+    /**
+     * Create the next <code>DirContext</code> when using federation so that 
+     * the <code>DirContext</code> operation can be reinvoked.
+     * This should work similarly to 
+     * <code>NamingManager.getContinuationContext</code> except that a 
+     * reference to a <code>DirContext</code> is returned.
+     * <p>
+     * This method is also responsible for setting the property denoted by the
+     * <code>CPE</code> string to be the supplied
+     * <code>CannotProceedException</code> for that environment.</p>
+     *
+     * @param cpe   the <code>CannotProceedException</code> generated by the
+     *              <code>DirContext</code> of the previous naming system when
+     *              it can proceed no further.
+     * @return      the next <code>DirContext</code> when using federation
+     * @throws  NamingException if the resolved object is not set or if a
+     *          <code>DirContext</code>  cannot be obtained from it either
+     *          directly or indirectly.
+     */
+    public static DirContext getContinuationDirContext(CannotProceedException cpe)
+        throws NamingException {
+        // obtain next context using NamingManager
+        Context nextContext = null;
+        try {
+            nextContext = NamingManager.getContinuationContext(cpe);
+        } catch (CannotProceedException e) {
+            // tolerate CannotProceedException here
+        }
+        
+        // if it is a DirContext
+        if (nextContext instanceof DirContext) {
+            // return as DirContext
+            return (DirContext) nextContext;
+        } else if (nextContext instanceof Context) {
+            // in case it's Context but not DirContext, wrap it as DirContext and return
+            return new Context2DirContextWrapper(nextContext, cpe);
+        } else {
+            // return a dummy DirContext, even if no context is obtained
+            return new Context2DirContextWrapper(null, cpe);
+        }
+    }
+
+    private static Class classForName(final String className)
+        throws ClassNotFoundException {
+
+        Class cls = (Class) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                // try thread context class loader first
+                try {
+                    return Class.forName(
+                        className,
+                        true,
+                        Thread.currentThread().getContextClassLoader());
+                } catch (ClassNotFoundException e) {
+                	// Could happen.
+                }
+                // try system class loader second
+                try {
+                    return Class.forName(
+                        className,
+                        true,
+                        ClassLoader.getSystemClassLoader());
+                } catch (ClassNotFoundException e1) {
+                	// Not found here either.
+                }
+                // return null, if fail to load class
+                return null;
+            }
+        });
+
+        if (cls == null) {
+            throw new ClassNotFoundException("class " + className + " not found"); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
+        return cls;
+
+    }
+    
+    /**
+     * An inner class that transforms a Context instance into DirContext.
+     */
+    private static class Context2DirContextWrapper implements DirContext {
+        private Context ctx;
+        private CannotProceedException cpe;
+        
+        public Context2DirContextWrapper(Context ctx, CannotProceedException cpe) {
+            this.ctx = ctx;
+            this.cpe = cpe;
+        }
+        
+        private Context getContext() throws CannotProceedException {
+            if (ctx instanceof Context) {
+                return ctx;
+            }
+            cpe.fillInStackTrace();
+            throw cpe;
+        }
+        
+        private DirContext getDirContext() throws CannotProceedException {
+            if (ctx instanceof DirContext) {
+                return (DirContext) ctx;
+            }
+            cpe.fillInStackTrace();
+            throw cpe;
+        }
+        
+        /**
+         * @param s
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration listBindings(String s) throws NamingException {
+            return getContext().listBindings(s);
+        }
+
+        /**
+         * @param s
+         * @return
+         * @throws NamingException
+         */
+        public Object removeFromEnvironment(String s) throws NamingException {
+            return getContext().removeFromEnvironment(s);
+        }
+
+        /**
+         * @param s
+         * @return
+         * @throws NamingException
+         */
+        public Object lookupLink(String s) throws NamingException {
+            return getContext().lookupLink(s);
+        }
+
+        /**
+         * @param n
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration list(Name n) throws NamingException {
+            return getContext().list(n);
+        }
+
+        /**
+         * @param s
+         * @return
+         * @throws NamingException
+         */
+        public Object lookup(String s) throws NamingException {
+            return getContext().lookup(s);
+        }
+
+        /**
+         * @param s
+         * @param o
+         * @return
+         * @throws NamingException
+         */
+        public Object addToEnvironment(String s, Object o) throws NamingException {
+            return getContext().addToEnvironment(s, o);
+        }
+
+        /* (non-Javadoc)
+         * @see java.lang.Object#toString()
+         */
+        public String toString() {
+            try {
+                return getContext().toString();
+            } catch (CannotProceedException e) {
+                return super.toString();
+            }
+        }
+
+        /**
+         * @param s
+         * @return
+         * @throws NamingException
+         */
+        public Context createSubcontext(String s) throws NamingException {
+            return getContext().createSubcontext(s);
+        }
+
+        /**
+         * @param nOld
+         * @param nNew
+         * @throws NamingException
+         */
+        public void rename(Name nOld, Name nNew) throws NamingException {
+            getContext().rename(nOld, nNew);
+        }
+
+        /* (non-Javadoc)
+         * @see java.lang.Object#hashCode()
+         */
+        public int hashCode() {
+            try {
+                return getContext().hashCode();
+            } catch (CannotProceedException e) {
+                return super.hashCode();
+            }
+        }
+
+        /**
+         * @param n
+         * @param o
+         * @throws NamingException
+         */
+        public void rebind(Name n, Object o) throws NamingException {
+            getContext().rebind(n, o);
+        }
+
+        /**
+         * @param sOld
+         * @param sNew
+         * @throws NamingException
+         */
+        public void rename(String sOld, String sNew) throws NamingException {
+            getContext().rename(sOld, sNew);
+        }
+
+        /**
+         * @param n
+         * @return
+         * @throws NamingException
+         */
+        public Context createSubcontext(Name n) throws NamingException {
+            return getContext().createSubcontext(n);
+        }
+
+        /**
+         * @param s
+         * @return
+         * @throws NamingException
+         */
+        public NameParser getNameParser(String s) throws NamingException {
+            return getContext().getNameParser(s);
+        }
+
+        /**
+         * @param s
+         * @param o
+         * @throws NamingException
+         */
+        public void rebind(String s, Object o) throws NamingException {
+            getContext().rebind(s, o);
+        }
+
+        /**
+         * @param n
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration listBindings(Name n) throws NamingException {
+            return getContext().listBindings(n);
+        }
+
+        /**
+         * @param n
+         * @return
+         * @throws NamingException
+         */
+        public NameParser getNameParser(Name n) throws NamingException {
+            return getContext().getNameParser(n);
+        }
+
+        /**
+         * @param s
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration list(String s) throws NamingException {
+            return getContext().list(s);
+        }
+
+        /**
+         * @return
+         * @throws NamingException
+         */
+        public String getNameInNamespace() throws NamingException {
+            return getContext().getNameInNamespace();
+        }
+
+        /**
+         * @param n
+         * @throws NamingException
+         */
+        public void unbind(Name n) throws NamingException {
+            getContext().unbind(n);
+        }
+
+        /**
+         * @param n
+         * @param pfx
+         * @return
+         * @throws NamingException
+         */
+        public Name composeName(Name n, Name pfx) throws NamingException {
+            return getContext().composeName(n, pfx);
+        }
+
+        /**
+         * @param n
+         * @param o
+         * @throws NamingException
+         */
+        public void bind(Name n, Object o) throws NamingException {
+            getContext().bind(n, o);
+        }
+
+        /**
+         * @param s
+         * @throws NamingException
+         */
+        public void unbind(String s) throws NamingException {
+            getContext().unbind(s);
+        }
+
+        /**
+         * @throws NamingException
+         */
+        public void close() throws NamingException {
+            getContext().close();
+        }
+
+        /**
+         * @param n
+         * @return
+         * @throws NamingException
+         */
+        public Object lookupLink(Name n) throws NamingException {
+            return getContext().lookupLink(n);
+        }
+
+        /**
+         * @param n
+         * @throws NamingException
+         */
+        public void destroySubcontext(Name n) throws NamingException {
+            getContext().destroySubcontext(n);
+        }
+
+        /**
+         * @param s
+         * @param pfx
+         * @return
+         * @throws NamingException
+         */
+        public String composeName(String s, String pfx) throws NamingException {
+            return getContext().composeName(s, pfx);
+        }
+
+        /**
+         * @param s
+         * @param o
+         * @throws NamingException
+         */
+        public void bind(String s, Object o) throws NamingException {
+            getContext().bind(s, o);
+        }
+
+        /**
+         * @param n
+         * @return
+         * @throws NamingException
+         */
+        public Object lookup(Name n) throws NamingException {
+            return getContext().lookup(n);
+        }
+
+        /* (non-Javadoc)
+         * @see java.lang.Object#equals(java.lang.Object)
+         */
+        public boolean equals(Object arg0) {
+            try {
+                return getContext().equals(arg0);
+            } catch (CannotProceedException e) {
+                return super.equals(arg0);
+            }
+        }
+
+        /**
+         * @param s
+         * @throws NamingException
+         */
+        public void destroySubcontext(String s) throws NamingException {
+            getContext().destroySubcontext(s);
+        }
+
+        /**
+         * @return
+         * @throws NamingException
+         */
+        public Hashtable getEnvironment() throws NamingException {
+            return getContext().getEnvironment();
+        }
+
+        /**
+         * @param name
+         * @param obj
+         * @param attributes
+         * @throws NamingException
+         */
+        public void bind(Name name, Object obj, Attributes attributes)
+            throws NamingException {
+            getDirContext().bind(name, obj, attributes);
+        }
+
+        /**
+         * @param s
+         * @param obj
+         * @param attributes
+         * @throws NamingException
+         */
+        public void bind(String s, Object obj, Attributes attributes)
+            throws NamingException {
+            getDirContext().bind(s, obj, attributes);
+        }
+
+        /**
+         * @param name
+         * @param attributes
+         * @return
+         * @throws NamingException
+         */
+        public DirContext createSubcontext(Name name, Attributes attributes)
+            throws NamingException {
+            return getDirContext().createSubcontext(name, attributes);
+        }
+
+        /**
+         * @param s
+         * @param attributes
+         * @return
+         * @throws NamingException
+         */
+        public DirContext createSubcontext(String s, Attributes attributes)
+            throws NamingException {
+            return getDirContext().createSubcontext(s, attributes);
+        }
+
+        /**
+         * @param name
+         * @return
+         * @throws NamingException
+         */
+        public Attributes getAttributes(Name name) throws NamingException {
+            return getDirContext().getAttributes(name);
+        }
+
+        /**
+         * @param name
+         * @param as
+         * @return
+         * @throws NamingException
+         */
+        public Attributes getAttributes(Name name, String[] as) throws NamingException {
+            return getDirContext().getAttributes(name, as);
+        }
+
+        /**
+         * @param s
+         * @return
+         * @throws NamingException
+         */
+        public Attributes getAttributes(String s) throws NamingException {
+            return getDirContext().getAttributes(s);
+        }
+
+        /**
+         * @param s
+         * @param as
+         * @return
+         * @throws NamingException
+         */
+        public Attributes getAttributes(String s, String[] as) throws NamingException {
+            return getDirContext().getAttributes(s, as);
+        }
+
+        /**
+         * @param name
+         * @return
+         * @throws NamingException
+         */
+        public DirContext getSchema(Name name) throws NamingException {
+            return getDirContext().getSchema(name);
+        }
+
+        /**
+         * @param s
+         * @return
+         * @throws NamingException
+         */
+        public DirContext getSchema(String s) throws NamingException {
+            return getDirContext().getSchema(s);
+        }
+
+        /**
+         * @param name
+         * @return
+         * @throws NamingException
+         */
+        public DirContext getSchemaClassDefinition(Name name) throws NamingException {
+            return getDirContext().getSchemaClassDefinition(name);
+        }
+
+        /**
+         * @param s
+         * @return
+         * @throws NamingException
+         */
+        public DirContext getSchemaClassDefinition(String s) throws NamingException {
+            return getDirContext().getSchemaClassDefinition(s);
+        }
+
+        /**
+         * @param name
+         * @param i
+         * @param attributes
+         * @throws NamingException
+         */
+        public void modifyAttributes(Name name, int i, Attributes attributes)
+            throws NamingException {
+            getDirContext().modifyAttributes(name, i, attributes);
+        }
+
+        /**
+         * @param name
+         * @param modificationItems
+         * @throws NamingException
+         */
+        public void modifyAttributes(Name name, ModificationItem[] modificationItems)
+            throws NamingException {
+            getDirContext().modifyAttributes(name, modificationItems);
+        }
+
+        /**
+         * @param s
+         * @param i
+         * @param attributes
+         * @throws NamingException
+         */
+        public void modifyAttributes(String s, int i, Attributes attributes)
+            throws NamingException {
+            getDirContext().modifyAttributes(s, i, attributes);
+        }
+
+        /**
+         * @param s
+         * @param modificationItems
+         * @throws NamingException
+         */
+        public void modifyAttributes(String s, ModificationItem[] modificationItems)
+            throws NamingException {
+            getDirContext().modifyAttributes(s, modificationItems);
+        }
+
+        /**
+         * @param name
+         * @param obj
+         * @param attributes
+         * @throws NamingException
+         */
+        public void rebind(Name name, Object obj, Attributes attributes)
+            throws NamingException {
+            getDirContext().rebind(name, obj, attributes);
+        }
+
+        /**
+         * @param s
+         * @param obj
+         * @param attributes
+         * @throws NamingException
+         */
+        public void rebind(String s, Object obj, Attributes attributes)
+            throws NamingException {
+            getDirContext().rebind(s, obj, attributes);
+        }
+
+        /**
+         * @param name
+         * @param attributes
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration search(Name name, Attributes attributes)
+            throws NamingException {
+            return getDirContext().search(name, attributes);
+        }
+
+        /**
+         * @param name
+         * @param attributes
+         * @param as
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration search(Name name, Attributes attributes, String[] as)
+            throws NamingException {
+            return getDirContext().search(name, attributes, as);
+        }
+
+        /**
+         * @param name
+         * @param filter
+         * @param objs
+         * @param searchControls
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration search(
+            Name name,
+            String filter,
+            Object[] objs,
+            SearchControls searchControls)
+            throws NamingException {
+            return getDirContext().search(name, filter, objs, searchControls);
+        }
+
+        /**
+         * @param name
+         * @param filter
+         * @param searchControls
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration search(
+            Name name,
+            String filter,
+            SearchControls searchControls)
+            throws NamingException {
+            return getDirContext().search(name, filter, searchControls);
+        }
+
+        /**
+         * @param name
+         * @param attributes
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration search(String name, Attributes attributes)
+            throws NamingException {
+            return getDirContext().search(name, attributes);
+        }
+
+        /**
+         * @param name
+         * @param attributes
+         * @param as
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration search(String name, Attributes attributes, String[] as)
+            throws NamingException {
+            return getDirContext().search(name, attributes, as);
+        }
+
+        /**
+         * @param name
+         * @param filter
+         * @param objs
+         * @param searchControls
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration search(
+            String name,
+            String filter,
+            Object[] objs,
+            SearchControls searchControls)
+            throws NamingException {
+            return getDirContext().search(name, filter, objs, searchControls);
+        }
+
+        /**
+         * @param name
+         * @param filter
+         * @param searchControls
+         * @return
+         * @throws NamingException
+         */
+        public NamingEnumeration search(
+            String name,
+            String filter,
+            SearchControls searchControls)
+            throws NamingException {
+            return getDirContext().search(name, filter, searchControls);
+        }
+
+    }
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/InitialContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/InitialContextFactory.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/InitialContextFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/InitialContextFactory.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,53 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.spi;
+
+import java.util.Hashtable;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+/**
+ * An implementation of <code>InitialContextFactory</code> creates an initial 
+ * context so that the JNDI application can begin to invoke naming operations 
+ * on that context. The class implementing this interface should be public and 
+ * should also provide a public constructor taking no arguments.
+ * 
+ */
+public interface InitialContextFactory {
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Returns a non-null initial context object on which naming operations can be
+     * invoked. The specified <code>envmt</code> parameter may be null or may be 
+     * used to customise the requested <code>Context</code> object.  The 
+     * implementation may clone or copy the <code>envmt</code> object, 
+     * but will not modify the original object.
+     * 
+     * @param envmt the context environment as a <code>Hashtable</code>
+     * @return a non-null initial context object
+     * @throws NamingException if a naming exception occurs
+     */
+    Context getInitialContext(Hashtable envmt) throws NamingException;
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/InitialContextFactoryBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/InitialContextFactoryBuilder.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/InitialContextFactoryBuilder.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/InitialContextFactoryBuilder.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,56 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.spi;
+
+import java.util.Hashtable;
+import javax.naming.NamingException;
+
+/**
+ * An initial context factory builder creates an initial context factory, and
+ * an initial context factory creates initial contexts. A variety of different
+ * initial context implementations may be used by a JNDI application. The
+ * application uses <code>NamingManager.setInitialContextFactoryBuilder()</code> 
+ * to specify its own or its preferred builder to override JNDI default policies.
+ * Any such builder must implement the <code>InitialContextFactoryBuilder</code>
+ * interface.
+ * 
+ */
+public interface InitialContextFactoryBuilder {
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Uses the environment properties in the specified <code>envmt</code> 
+     * parameter to create an initial context factory. If the implementation 
+     * needs to keep a copy of <code>envmt</code> or to change it, it will 
+     * clone or copy the specified object and use that instead.
+     * The <code>envmt</code> parameter may be null.
+     * 
+     * @param envmt the context environment as a <code>Hashtable</code>
+     * @return an initial context factory - cannot be null.
+     * @throws NamingException if an initial context factory could not be created.
+     */
+    InitialContextFactory createInitialContextFactory(Hashtable envmt)
+        throws NamingException;
+
+}
+
+



Mime
View raw message