Java Doc for NamingManager.java in  » Apache-Harmony-Java-SE » javax-package » javax » naming » spi » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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 geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » javax package » javax.naming.spi 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.naming.spi.NamingManager

All known Subclasses:   javax.naming.spi.DirectoryManager,
NamingManager
public class NamingManager (Code)
The NamingManager class should not be instantiated although it can be extended by classes within the javax.naming.spi package - see DirectoryManager . All its methods are static.

The methods are used by service providers for accessing object and state factories and for determining continuation contexts. Many of the methods create objects. These may be Context objects or objects referred to by the naming service.

The Name and Hashtable arguments passed to the NamingManager methods remain owned purely by the calling method. They must not be changed or referenced.

It should be noted that it is possible for an application to access a namespace other than that supplied by the default InitialContext (as specified by Context.INITIAL_CONTEXT_FACTORY). It is possible to call the following InitialContext methods passing a URL string either as the String or Name parameter: lookup, bin, rebind, unbind, rename, list, listBindings, destroySubcontext, createSubcontext, lookupLink, getNameParser. This allows you to have one InitialContext object where these methods usually use the default initial context but access a URL Context instead when invoked with a URL string.

A URL string is of the format abc:\nnnnnn where abc is the scheme of the URL. (See InitialContext where it refers to RFC1738.) When a URL string is supplied to those InitialContext methods, a URL context is used instead of the default initial context when performing that method. URL context factories are used to create URL contexts. A URL context factory is really just a service provider's implementation of an ObjectFactory. It is not essential that a service provider supplies one if they do not wish to support URL Contexts.

See the getURLContext method for a description of how a URL context factory is located.

Please note that multithreaded access to this class must be safe. For example, for thread safety, it should not be possible for one thread to read the installed InitialContextFactoryBuilder or ObjectFactoryBuilder while another thread is in the process of setting it.

Also note that privileges should be granted to get the context classloader and to read the resource files.


See Also:   DirectoryManager


Field Summary
final public static  StringCPE
     The property name of CannotProceedException in a context's environment.
static  InitialContextFactoryBuildericfb
    
static  ObjectFactoryBuilderofb
    

Constructor Summary
 NamingManager()
    

Method Summary
public static  ContextgetContinuationContext(CannotProceedException cpe)
     Create the next context when using federation.
public static  ContextgetInitialContext(Hashtable h)
     Create an InitialContext from either a previously installed InitialContextFactoryBuilder or from the Context.INITIAL_CONTEXT_FACTORY property in the supplied Hashtable h if no builder is installed.
public static  ObjectgetObjectInstance(Object o, Name n, Context c, Hashtable h)
     Create an object from either a previously installed ObjectFactoryBuilder or from a supplied reference or from the Context.OBJECT_FACTORIES property in the supplied Hashtable h.

An installed ObjectFactoryBuilder can generate a factory which can be used to create the object instance to return to caller.

public static  ObjectgetStateToBind(Object o, Name n, Context c, Hashtable h)
     Get the state of an Object.

The Context.STATE_FACTORIES property from the Hashtable h together with the Context.STATE_FACTORIES property from the provider resource file of the Context c provides the list of factories tried to get an object's state.

Each factory in the list is attempted to be loaded using the context class loader.

public static  ContextgetURLContext(String schema, Hashtable envmt)
     Creates a URL Context which can subsequently be used to resolve any URLs with the URL scheme s.
public static  booleanhasInitialContextFactoryBuilder()
     Returns true when an InitialContextFactoryBuilder has been installed.
public static  voidsetInitialContextFactoryBuilder(InitialContextFactoryBuilder icfb)
     Install an InitialContextFactoryBuilder.
public static synchronized  voidsetObjectFactoryBuilder(ObjectFactoryBuilder ofb)
     Install an ObjectFactoryBuilder.

Field Detail
CPE
final public static String CPE(Code)
The property name of CannotProceedException in a context's environment.



icfb
static InitialContextFactoryBuilder icfb(Code)



ofb
static ObjectFactoryBuilder ofb(Code)




Constructor Detail
NamingManager
NamingManager()(Code)




Method Detail
getContinuationContext
public static Context getContinuationContext(CannotProceedException cpe) throws NamingException(Code)
Create the next context when using federation. All the information required to do this is contained in the CannotProceedException e. If the resolved object is null then throw the supplied CannotProceedException e using the stack details from this thread. The resolved object in e may already be a Context. This is the case where the service provider gives an explicit pointer to the next naming system. A Context object is returned as the continuation context, but need not be the same object instance as the resolved object.

If the resolved object is not already a Context then it is necessary to use the resolved object together with the altName name, the altNameCtx context and the environment hashtable to get an instance of the object. This should then be a context which is returned as the continuation context. If an instance cannot be obtained then throw the supplied CannotProceedException using the stack details from this thread.

This method is responsible for setting the property denoted by the CPE string to be the supplied CannotProceedException for the exception e environment. The continuation context should then inherit this property.


Parameters:
  cpe - the CannotProceedException generated by thecontext of the previous naming system when it can proceed nofurther. the next Context when using federation
throws:
  NamingException - if the resolved object is null or if a context cannot beobtained from it either directly or indirectly.



getInitialContext
public static Context getInitialContext(Hashtable h) throws NoInitialContextException, NamingException(Code)
Create an InitialContext from either a previously installed InitialContextFactoryBuilder or from the Context.INITIAL_CONTEXT_FACTORY property in the supplied Hashtable h if no builder is installed. An installed InitialContextFactoryBuilder can generate a factory which can be used to create the InitialContext. The Context.INITIAL_CONTEXT_FACTORY property contains the class of a factory which can be used to create the InitialContext.
Parameters:
  h - a hashtable containing properties and values - may be null an InitialContext
throws:
  NoInitialContextException - if the InitialContext cannot be created.
throws:
  NamingException -



getObjectInstance
public static Object getObjectInstance(Object o, Name n, Context c, Hashtable h) throws NamingException, Exception(Code)
Create an object from either a previously installed ObjectFactoryBuilder or from a supplied reference or from the Context.OBJECT_FACTORIES property in the supplied Hashtable h.

An installed ObjectFactoryBuilder can generate a factory which can be used to create the object instance to return to caller. Any encountered exceptions are thrown.

If an ObjectFactoryBuilder has not been installed then the supplied Object o may provide a Reference or Referenceable object. If so, then that Object o may have an associated class in a factory which could be loaded and used to create the object instance. If the factory class cannot be loaded then the URLClassLoader may be able to load a class from the list of URLs specified in the reference's factory class location. Any exceptions encountered are passed up.

If a reference is supplied but no factory class can be loaded from it then this method returns the supplied object o.

If a factory class loads successfully and can then be used to create an object instance then that instance is returned to the caller.

If no factory name was associated with the Reference object o then see whether the Reference or Referenceable object has any StringRefAddrs of address type URL or url in its address list. For each entry in the list, in the order they appear in the list, it may be possible to use the URL factory to create the object. A URL in a StringRefAddr should have a scheme which can be used to locate the associated URL context factory in the same way as in the getURLContext method. (The scheme is the part which comes before :\. For example the URL http://www.apache.org has the scheme http.) A URL with no scheme would be ignored for these purposes.

If no ObjectFactoryBuilder was installed, no factory class name is supplied with a Reference and no URL contexts succeeded in creating an Object then try the factories in Context.OBJECT_FACTORIES for this environment. Also try the provider resource file belonging to the context c. (See Context description for details of Provider resource files.) If any factory throws an exception then pass that back to the caller - no further factories are tried.

If all factories fail to load or create the Object then return the argument object o as the returned object.


Parameters:
  o - an object which may provide reference or location information.May be null.
Parameters:
  n - The name of the Object relative to the defaultinitial context(or relative to the Context c if it issupplied)
Parameters:
  c - the Context to which the Name isrelative
Parameters:
  h - a Hashtable containing environment propertiesand values - may be null a new Object or the supplied Object oif one cannot be created.
throws:
  NamingException - if one is encountered
throws:
  Exception - if any other exception is encountered



getStateToBind
public static Object getStateToBind(Object o, Name n, Context c, Hashtable h) throws NamingException(Code)
Get the state of an Object.

The Context.STATE_FACTORIES property from the Hashtable h together with the Context.STATE_FACTORIES property from the provider resource file of the Context c provides the list of factories tried to get an object's state.

Each factory in the list is attempted to be loaded using the context class loader. Once a class is loaded then it can be used to create a new instance of it to obtain the factory which can then use its getStateToBind to find the return object. Once an object is found then it is not necessary to examine further factories and the object is returned it as the return parameter.

If no factory is loaded or all loaded factories fail to return an object then return the supplied Object o as the return param.

Note for service provider implementors: Classes which implement the StateFactory interface must be public with a public constructor that has no parameters.


Parameters:
  o - an object which may provide reference or location information.May be null.
Parameters:
  n - the name of the Object relative to the defaultinitial context (or relative to the Context c if it issupplied)
Parameters:
  c - the Context to which the Name isrelative
Parameters:
  h - a Hashtable containing environment propertiesand values - may be null the state of the specified object
throws:
  NamingException - if one is encountered



getURLContext
public static Context getURLContext(String schema, Hashtable envmt) throws NamingException(Code)
Creates a URL Context which can subsequently be used to resolve any URLs with the URL scheme s. A URLContextFactory is a type of ObjectFactory used to create a URLContext when getObjectInstance is invoked with the Object o set to null (see the description of ObjectFactory).

This getURLContext method tries to locate the URLContextFactory based on the Context.URL_PKG_PREFIXES property which contains the prefixes to be tried as the start of the package name. (See Context).

Each package prefix entry (and finally the default value) are tried to find the class which can be used to create the Context.

A full class name is derived as packageprefix.s.sURLContextFactory where s is the scheme.

For example if a scheme is abc and the package prefix to try is com.ibm then the factory class to try is com.ibm.abc.abcURLContextFactory. Once a factory is created then a Context is created using the special use of ObjectFactory.getObjectInstance.

Once a first factory is created, it is used to create the context, and NO further attempts will be made on other pkg prefixes.


Parameters:
  schema - the URL scheme to which the Context will relate
Parameters:
  envmt - a Hashtable containing environment propertiesand values - may be null the URL Context or null if noURLContextFactory instance can be created andtherefore a Context cannot be created.
throws:
  NamingException - if one is encountered.



hasInitialContextFactoryBuilder
public static boolean hasInitialContextFactoryBuilder()(Code)
Returns true when an InitialContextFactoryBuilder has been installed. true when an InitialContextFactoryBuilder has beeninstalled.



setInitialContextFactoryBuilder
public static void setInitialContextFactoryBuilder(InitialContextFactoryBuilder icfb) throws IllegalStateException, SecurityException, NamingException(Code)
Install an InitialContextFactoryBuilder. Once this has been set it cannot be reset. Attempts to do so cause an IllegalStateException. The builder can only be installed if the security policy allows the setting of the factory.
Parameters:
  icfb - the builder to be installed - can be null, but then no builderis installed.
throws:
  IllegalStateException - if an builder has already been installed.
throws:
  SecurityException - is a security error prevents the installation.
throws:
  NamingException - for other errors encountered.



setObjectFactoryBuilder
public static synchronized void setObjectFactoryBuilder(ObjectFactoryBuilder ofb) throws IllegalStateException, SecurityException, NamingException(Code)
Install an ObjectFactoryBuilder. Once this has been set it cannot be reset. Attempts to do so cause an IllegalStateException. The builder can only be installed if the security policy allows the setting of the factory.
Parameters:
  ofb - the ObjectFactoryBuilder to be installed - canbe null, but then no builder is installed.
throws:
  IllegalStateException - if an ObjectFactoryBuilder has already beeninstalled.
throws:
  SecurityException - is a security error prevents the installation.
throws:
  NamingException - for other errors encountered.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.