Source Code Cross Referenced for ObjectFactory.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
026        package javax.naming.spi;
027
028        import java.util.Hashtable;
029
030        import javax.naming.*;
031
032        /**
033         * This interface represents a factory for creating an object.
034         *<p>
035         * The JNDI framework allows for object implementations to
036         * be loaded in dynamically via <em>object factories</em>.
037         * For example, when looking up a printer bound in the name space,
038         * if the print service binds printer names to References, the printer
039         * Reference could be used to create a printer object, so that
040         * the caller of lookup can directly operate on the printer object
041         * after the lookup.  
042         * <p>An <tt>ObjectFactory</tt> is responsible
043         * for creating objects of a specific type.  In the above example,
044         * you may have a PrinterObjectFactory for creating Printer objects.
045         *<p>
046         * An object factory must implement the <tt>ObjectFactory</tt> interface.
047         * In addition, the factory class must be public and must have a 
048         * public constructor that accepts no parameters.
049         *<p>
050         * The <tt>getObjectInstance()</tt> method of an object factory may
051         * be invoked multiple times, possibly using different parameters.
052         * The implementation is thread-safe.
053         *<p>
054         * The mention of URL in the documentation for this class refers to
055         * a URL string as defined by RFC 1738 and its related RFCs. It is
056         * any string that conforms to the syntax described therein, and
057         * may not always have corresponding support in the java.net.URL
058         * class or Web browsers.
059         *
060         * @author Rosanna Lee
061         * @author Scott Seligman
062         * @version 1.17 07/05/05
063         *
064         * @see NamingManager#getObjectInstance
065         * @see NamingManager#getURLContext
066         * @see ObjectFactoryBuilder
067         * @see StateFactory
068         * @since 1.3
069         */
070
071        public interface ObjectFactory {
072            /**
073             * Creates an object using the location or reference information
074             * specified.  
075             * <p>
076             * Special requirements of this object are supplied
077             * using <code>environment</code>.
078             * An example of such an environment property is user identity
079             * information. 
080             *<p>
081             * <tt>NamingManager.getObjectInstance()</tt>
082             * successively loads in object factories and invokes this method
083             * on them until one produces a non-null answer.  When an exception
084             * is thrown by an object factory, the exception is passed on to the caller
085             * of <tt>NamingManager.getObjectInstance()</tt>
086             * (and no search is made for other factories
087             * that may produce a non-null answer).
088             * An object factory should only throw an exception if it is sure that
089             * it is the only intended factory and that no other object factories
090             * should be tried.
091             * If this factory cannot create an object using the arguments supplied,
092             * it should return null. 
093             *<p>
094             * A <em>URL context factory</em> is a special ObjectFactory that
095             * creates contexts for resolving URLs or objects whose locations
096             * are specified by URLs.  The <tt>getObjectInstance()</tt> method
097             * of a URL context factory will obey the following rules.
098             * <ol>
099             * <li>If <code>obj</code> is null, create a context for resolving URLs of the
100             * scheme associated with this factory. The resulting context is not tied
101             * to a specific URL:  it is able to handle arbitrary URLs with this factory's
102             * scheme id.  For example, invoking <tt>getObjectInstance()</tt> with
103             * <code>obj</code> set to null on an LDAP URL context factory would return a
104             * context that can resolve LDAP URLs
105             * such as "ldap://ldap.wiz.com/o=wiz,c=us" and
106             * "ldap://ldap.umich.edu/o=umich,c=us".
107             * <li>
108             * If <code>obj</code> is a URL string, create an object (typically a context)
109             * identified by the URL.  For example, suppose this is an LDAP URL context
110             * factory.  If <code>obj</code> is "ldap://ldap.wiz.com/o=wiz,c=us",
111             * getObjectInstance() would return the context named by the distinguished
112             * name "o=wiz, c=us" at the LDAP server ldap.wiz.com.  This context can
113             * then be used to resolve LDAP names (such as "cn=George")
114             * relative to that context.
115             * <li>
116             * If <code>obj</code> is an array of URL strings, the assumption is that the
117             * URLs are equivalent in terms of the context to which they refer.
118             * Verification of whether the URLs are, or need to be, equivalent is up
119             * to the context factory. The order of the URLs in the array is
120             * not significant.
121             * The object returned by getObjectInstance() is like that of the single
122             * URL case.  It is the object named by the URLs.
123             * <li>
124             * If <code>obj</code> is of any other type, the behavior of
125             * <tt>getObjectInstance()</tt> is determined by the context factory
126             * implementation.
127             * </ol>
128             *
129             * <p>
130             * The <tt>name</tt> and <tt>environment</tt> parameters
131             * are owned by the caller.
132             * The implementation will not modify these objects or keep references
133             * to them, although it may keep references to clones or copies.
134             *
135             * <p>
136             * <b>Name and Context Parameters.</b> &nbsp;&nbsp;&nbsp;
137             * <a name=NAMECTX></a>
138             *
139             * The <code>name</code> and <code>nameCtx</code> parameters may
140             * optionally be used to specify the name of the object being created.
141             * <code>name</code> is the name of the object, relative to context
142             * <code>nameCtx</code>.
143             * If there are several possible contexts from which the object
144             * could be named -- as will often be the case -- it is up to
145             * the caller to select one.  A good rule of thumb is to select the
146             * "deepest" context available.
147             * If <code>nameCtx</code> is null, <code>name</code> is relative
148             * to the default initial context.  If no name is being specified, the
149             * <code>name</code> parameter should be null.
150             * If a factory uses <code>nameCtx</code> it should synchronize its use
151             * against concurrent access, since context implementations are not
152             * guaranteed to be thread-safe.
153             * <p>
154             *
155             * @param obj The possibly null object containing location or reference 
156             * 		information that can be used in creating an object.
157             * @param name The name of this object relative to <code>nameCtx</code>,
158             *		or null if no name is specified.
159             * @param nameCtx The context relative to which the <code>name</code>
160             *		parameter is specified, or null if <code>name</code> is
161             *		relative to the default initial context.
162             * @param environment The possibly null environment that is used in
163             * 		creating the object.
164             * @return The object created; null if an object cannot be created.
165             * @exception Exception if this object factory encountered an exception
166             * while attempting to create an object, and no other object factories are
167             * to be tried.
168             *
169             * @see NamingManager#getObjectInstance
170             * @see NamingManager#getURLContext
171             */
172            public Object getObjectInstance(Object obj, Name name,
173                    Context nameCtx, Hashtable<?, ?> environment)
174                    throws Exception;
175        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.