001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * docs/licenses/cddl.txt
011     * or http://www.opensource.org/licenses/cddl1.php.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * docs/licenses/cddl.txt.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2010-2012 UnboundID Corp.
026     */
027    package com.unboundid.directory.sdk.ds.types;
028    
029    
030    
031    import com.unboundid.directory.sdk.common.types.ServerContext;
032    import com.unboundid.directory.sdk.ds.api.BackendInitializationListener;
033    import com.unboundid.ldap.sdk.LDAPException;
034    import com.unboundid.util.NotExtensible;
035    import com.unboundid.util.ThreadSafety;
036    import com.unboundid.util.ThreadSafetyLevel;
037    
038    
039    
040    /**
041     * This interface may be used to obtain information about the Directory Server
042     * (or related product) in which an extension is running.
043     */
044    @NotExtensible()
045    @ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
046    public interface DirectoryServerContext extends ServerContext
047    {
048      /**
049       * Returns an array of all the backends defined in the Directory Server.
050       *
051       * @return an array of {@link BackendContext} objects. This will never
052       *         be null.
053       */
054      BackendContext[] getAllBackends();
055    
056    
057    
058      /**
059       * Returns the {@link BackendContext} for the backend which should handle the
060       * specified entry, or null if there is no backend that handles this entry.
061       * Note that the entry does not need to exist. If a BackendContext is
062       * returned, it will return true for
063       * {@link BackendContext#handlesEntry(String)} when given the specified DN.
064       *
065       * @param dn The DN for which to make the determination. It must not be
066       *             {@code null}.
067       *
068       * @return The {@link BackendContext} for the given entry, or null if no such
069       *         backend exists.
070       *
071       * @throws  LDAPException  If the provided string cannot be parsed as a valid
072       *                         DN or if a problem is encountered while attempting
073       *                         to retrieve the BackendContext.
074       */
075      BackendContext getBackendForEntry(String dn) throws LDAPException;
076    
077    
078    
079      /**
080       * Registers the provided backend initialization listener with the server so
081       * that it may be notified of any backends coming online or going offline.
082       *
083       * @param  listener     The backend initialization listener to be registered
084       *                      with the server. It must not be {@code null}.
085       *
086       * @return  An object representing the backend initialization listener that
087       *          has been registered with the server.
088       */
089      RegisteredBackendInitializationListener registerBackendInitializationListener(
090                          final BackendInitializationListener listener);
091    
092    
093    
094      /**
095       * Deregisters the provided backend initialization listener with the server.
096       * This will have no effect if the provided listener is not registered.
097       *
098       * @param  listener  The listener to be deregistered.  It must not be
099       *                   {@code null}.
100       */
101      void deregisterBackendInitializationListener(
102              final RegisteredBackendInitializationListener listener);
103    }