Source Code Cross Referenced for DirStateFactory.java in  » 6.0-JDK-Core » naming » javax » naming » spi » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » naming » javax.naming.spi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1999-2004 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025        package javax.naming.spi;
026
027        import javax.naming.*;
028        import javax.naming.directory.Attributes;
029        import java.util.Hashtable;
030
031        /**
032         * This interface represents a factory for obtaining the state of an
033         * object and corresponding attributes for binding.
034         *<p>
035         * The JNDI framework allows for object implementations to
036         * be loaded in dynamically via <tt>object factories</tt>.
037         * <p>
038         * A <tt>DirStateFactory</tt> extends <tt>StateFactory</tt> 
039         * by allowing an <tt>Attributes</tt> instance
040         * to be supplied to and be returned by the <tt>getStateToBind()</tt> method.
041         * <tt>DirStateFactory</tt> implementations are intended to be used by 
042         * <tt>DirContext</tt> service providers.
043         * When a caller binds an object using <tt>DirContext.bind()</tt>,
044         * he might also specify a set of attributes to be bound with the object.
045         * The object and attributes to be bound are passed to 
046         * the <tt>getStateToBind()</tt> method of a factory. 
047         * If the factory processes the object and attributes, it returns
048         * a corresponding pair of object and attributes to be bound.
049         * If the factory does not process the object, it must return null.
050         *<p>
051         * For example, a caller might bind a printer object with some printer-related
052         * attributes.
053         *<blockquote><pre>
054         * ctx.rebind("inky", printer, printerAttrs);
055         *</pre></blockquote>
056         * An LDAP service provider for <tt>ctx</tt> uses a <tt>DirStateFactory</tt>
057         * (indirectly via <tt>DirectoryManager.getStateToBind()</tt>)
058         * and gives it <tt>printer</tt> and <tt>printerAttrs</tt>. A factory for
059         * an LDAP directory might turn <tt>printer</tt> into a set of attributes
060         * and merge that with <tt>printerAttrs</tt>. The service provider then
061         * uses the resulting attributes to create an LDAP entry and updates
062         * the directory.
063         *
064         * <p> Since <tt>DirStateFactory</tt> extends <tt>StateFactory</tt>, it
065         * has two <tt>getStateToBind()</tt> methods, where one
066         * differs from the other by the attributes
067         * argument. <tt>DirectoryManager.getStateToBind()</tt> will only use
068         * the form that accepts the attributes argument, while
069         * <tt>NamingManager.getStateToBind()</tt> will only use the form that
070         * does not accept the attributes argument.
071         *
072         * <p> Either form of the <tt>getStateToBind()</tt> method of a
073         * DirStateFactory may be invoked multiple times, possibly using different
074         * parameters.  The implementation is thread-safe.
075         *
076         * @author Rosanna Lee
077         * @author Scott Seligman
078         * @version 1.18 07/05/05
079         *
080         * @see DirectoryManager#getStateToBind
081         * @see DirObjectFactory
082         * @since 1.3
083         */
084        public interface DirStateFactory extends StateFactory {
085            /**
086             * Retrieves the state of an object for binding given the object and attributes
087             * to be transformed.
088             *<p>
089             * <tt>DirectoryManager.getStateToBind()</tt>
090             * successively loads in state factories. If a factory implements
091             * <tt>DirStateFactory</tt>, <tt>DirectoryManager</tt> invokes this method;
092             * otherwise, it invokes <tt>StateFactory.getStateToBind()</tt>.
093             * It does this until a factory produces a non-null answer.
094             *<p>
095             * When an exception is thrown by a factory, 
096             * the exception is passed on to the caller
097             * of <tt>DirectoryManager.getStateToBind()</tt>. The search for other factories
098             * that may produce a non-null answer is halted. 
099             * A factory should only throw an exception if it is sure that
100             * it is the only intended factory and that no other factories
101             * should be tried.
102             * If this factory cannot create an object using the arguments supplied,
103             * it should return null. 
104             * <p>
105             * The <code>name</code> and <code>nameCtx</code> parameters may
106             * optionally be used to specify the name of the object being created.
107             * See the description of "Name and Context Parameters" in
108             * {@link ObjectFactory#getObjectInstance ObjectFactory.getObjectInstance()}
109             * for details.
110             * If a factory uses <code>nameCtx</code> it should synchronize its use
111             * against concurrent access, since context implementations are not
112             * guaranteed to be thread-safe.
113             *<p>
114             * The <tt>name</tt>, <tt>inAttrs</tt>, and <tt>environment</tt> parameters
115             * are owned by the caller.
116             * The implementation will not modify these objects or keep references
117             * to them, although it may keep references to clones or copies.
118             * The object returned by this method is owned by the caller.
119             * The implementation will not subsequently modify it.
120             * It will contain either a new <tt>Attributes</tt> object that is
121             * likewise owned by the caller, or a reference to the original
122             * <tt>inAttrs</tt> parameter.
123             *
124             * @param obj A possibly null object whose state is to be retrieved.
125             * @param name The name of this object relative to <code>nameCtx</code>,
126             *		or null if no name is specified.
127             * @param nameCtx The context relative to which the <code>name</code>
128             *		parameter is specified, or null if <code>name</code> is
129             *		relative to the default initial context.
130             * @param environment The possibly null environment to 
131             *		be used in the creation of the object's state.
132             * @param inAttrs The possibly null attributes to be bound with the object.
133             * 	The factory must not modify <tt>inAttrs</tt>.
134             * @return A <tt>Result</tt> containing the object's state for binding
135             * and the corresponding
136             * attributes to be bound; null if the object don't use this factory.
137             * @exception NamingException If this factory encountered an exception
138             * while attempting to get the object's state, and no other factories are
139             * to be tried.
140             *
141             * @see DirectoryManager#getStateToBind
142             */
143            public Result getStateToBind(Object obj, Name name,
144                    Context nameCtx, Hashtable<?, ?> environment,
145                    Attributes inAttrs) throws NamingException;
146
147            /**
148             * An object/attributes pair for returning the result of 
149             * DirStateFactory.getStateToBind().
150             */
151            public static class Result {
152                /**
153                 * The possibly null object to be bound.
154                 */
155                private Object obj;
156
157                /**
158                 * The possibly null attributes to be bound.
159                 */
160                private Attributes attrs;
161
162                /**
163                 * Constructs an instance of Result.
164                 *
165                 * @param obj The possibly null object to be bound.
166                 * @param outAttrs The possibly null attributes to be bound.
167                 */
168                public Result(Object obj, Attributes outAttrs) {
169                    this .obj = obj;
170                    this .attrs = outAttrs;
171                }
172
173                /**
174                 * Retrieves the object to be bound.
175                 * @return The possibly null object to be bound.
176                 */
177                public Object getObject() {
178                    return obj;
179                };
180
181                /**
182                 * Retrieves the attributes to be bound.
183                 * @return The possibly null attributes to be bound.
184                 */
185                public Attributes getAttributes() {
186                    return attrs;
187                };
188
189            }
190        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.