jdk/src/java.naming/share/classes/javax/naming/spi/StateFactory.java
author sspitsyn
Wed, 07 Sep 2016 03:35:45 +0000
changeset 40963 c7c990c4ec68
parent 36511 9d0388c6b336
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.naming.spi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import javax.naming.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
  * This interface represents a factory for obtaining the state of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
  * object for binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
  *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  * The JNDI framework allows for object implementations to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  * be loaded in dynamically via <em>object factories</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  * For example, when looking up a printer bound in the name space,
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    37
  * if the print service binds printer names to {@code Reference}s, the printer
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    38
  * {@code Reference} could be used to create a printer object, so that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  * the caller of lookup can directly operate on the printer object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  * after the lookup.
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    41
  * <p>An {@code ObjectFactory} is responsible
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  * for creating objects of a specific type.  In the above example,
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    43
  * you may have a {@code PrinterObjectFactory} for creating
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    44
  * {@code Printer} objects.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  * For the reverse process, when an object is bound into the namespace,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  * JNDI provides <em>state factories</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  * Continuing with the printer example, suppose the printer object is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
  * updated and rebound:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
  * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  * ctx.rebind("inky", printer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  * </pre></blockquote>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    53
  * The service provider for {@code ctx} uses a state factory
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    54
  * to obtain the state of {@code printer} for binding into its namespace.
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    55
  * A state factory for the {@code Printer} type object might return
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  * a more compact object for storage in the naming system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    58
  * A state factory must implement the {@code StateFactory} interface.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
  * In addition, the factory class must be public and must have a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
  * public constructor that accepts no parameters.
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 32029
diff changeset
    61
  * Note that in cases where the factory is in a named module then it must be
9d0388c6b336 8142968: Module System implementation
alanb
parents: 32029
diff changeset
    62
  * in a package which is exported by that module to the {@code java.naming}
9d0388c6b336 8142968: Module System implementation
alanb
parents: 32029
diff changeset
    63
  * module.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
  *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    65
  * The {@code getStateToBind()} method of a state factory may
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
  * be invoked multiple times, possibly using different parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
  * The implementation is thread-safe.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    69
  * {@code StateFactory} is intended for use with service providers
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    70
  * that implement only the {@code Context} interface.
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    71
  * {@code DirStateFactory} is intended for use with service providers
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    72
  * that implement the {@code DirContext} interface.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
  * @author Scott Seligman
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
  * @see NamingManager#getStateToBind
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  * @see DirectoryManager#getStateToBind
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
  * @see ObjectFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  * @see DirStateFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
  * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
public interface StateFactory {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * Retrieves the state of an object for binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    87
 * {@code NamingManager.getStateToBind()}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * successively loads in state factories and invokes this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * on them until one produces a non-null answer.
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    90
 * {@code DirectoryManager.getStateToBind()}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * successively loads in state factories.  If a factory implements
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    92
 * {@code DirStateFactory}, then {@code DirectoryManager}
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    93
 * invokes {@code DirStateFactory.getStateToBind()}; otherwise
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    94
 * it invokes {@code StateFactory.getStateToBind()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *<p> When an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * is thrown by a factory, the exception is passed on to the caller
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    97
 * of {@code NamingManager.getStateToBind()} and
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    98
 * {@code DirectoryManager.getStateToBind()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * The search for other factories
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * that may produce a non-null answer is halted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * A factory should only throw an exception if it is sure that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * it is the only intended factory and that no other factories
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * should be tried.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * If this factory cannot create an object using the arguments supplied,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * it should return null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * The <code>name</code> and <code>nameCtx</code> parameters may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * optionally be used to specify the name of the object being created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * See the description of "Name and Context Parameters" in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * {@link ObjectFactory#getObjectInstance ObjectFactory.getObjectInstance()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * for details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * If a factory uses <code>nameCtx</code> it should synchronize its use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * against concurrent access, since context implementations are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * guaranteed to be thread-safe.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * <p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   116
 * The {@code name} and {@code environment} parameters
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * are owned by the caller.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * The implementation will not modify these objects or keep references
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * to them, although it may keep references to clones or copies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * @param obj A non-null object whose state is to be retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * @param name The name of this object relative to <code>nameCtx</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 *              or null if no name is specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * @param nameCtx The context relative to which the <code>name</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 *              parameter is specified, or null if <code>name</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 *              relative to the default initial context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * @param environment The possibly null environment to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 *              be used in the creation of the object's state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * @return The object's state for binding;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *              null if the factory is not returning any changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * @exception NamingException if this factory encountered an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * while attempting to get the object's state, and no other factories are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * to be tried.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * @see NamingManager#getStateToBind
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * @see DirectoryManager#getStateToBind
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public Object getStateToBind(Object obj, Name name, Context nameCtx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                                 Hashtable<?,?> environment)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
}