Java Doc for MockContext.java in  » Testing » MockEJB » org » mockejb » jndi » 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 » Testing » MockEJB » org.mockejb.jndi 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.mockejb.jndi.MockContext

MockContext
public class MockContext implements Context(Code)
Provides implementation of javax.naming.Context interface for hierarchical in memory single-namespace naming system. A name in the MockContext namespace is a sequence of one or more atomic names, relative to a root initial context. When a name consist of more than one atomic names it is a CompoundName where atomic names are separated with separator character - '/' or '.'. It is possible to use both separator characters in the same name. In such cases any occurrences of '.' are replaced with '/' before parsing.

Leading and terminal components of a CompoundName can not be empty - for example "name1/name2/name3" is a valid name, while the following names are not valid - "/name1/name2/name3", "name1/name2/name3/", "/name1/name2/name3/". If such name is passed, all empty leading/terminal components will be removed before the name is actually used (this will not affect the original value) - from the above three examples the actual name will be "name1/name2/name3". If a name contains intermediate empty components (for example "a//b") then InvalidNameException will be thrown.

Composite names (instances of CompositeName) must contain zero or one component from the MockContext namespace.

The namespace of MockContext can be represented as a tree of atomic names. Each name is bound to an instance of MockContext (subcontext) or to an arbitrary object. Each subcontext has collection of names bound to other subcontexts or arbitrary objects.

When instance of Name is used as parameter to any of the MockContext methods, if the object is not CompositeName then it is assumed that it is CompoundName

Example:


 myContext = initialContext.lookup("foo");
 myObject = myContext.lookup("bar");
 
 is equivalent to
 myObject = initialContext.lookup("foo/bar");
 

Instances of MockContext are created only through MockContextFactory, when InitialContext is instantiated.

If a remote context is provided, this class will search in that remote context if the object is not found locally.

For overloaded methods that accept name as String or Name only the version for Name is documented. The String version creates CompoundName, from the string name passed as parameter, and calls the Name version of the same method.
author:
   Alexander Ananiev
author:
   Dimitar Gospodinov




Constructor Summary
protected  MockContext(Context remoteContext)
     Creates a new instance of the context.

Method Summary
public  ObjectaddToEnvironment(String arg0, Object arg1)
    
public  voidbind(Name name, Object obj)
     Binds object obj to name name in this context. Intermediate contexts that do not exist will be created.
public  voidbind(String name, Object obj)
     Binds object obj to name name in this context.
public  voidclose()
     Does nothing.
public  NamecomposeName(Name name, Name prefix)
     Returns composition of prefix and name.
public  StringcomposeName(String name, String prefix)
     Composes the name of this context with a name relative to this context.
public  ContextcreateSubcontext(Name name)
     Creates subcontext with name name, relative to this Context.
Parameters:
  name - subcontext name.
public  ContextcreateSubcontext(String name)
     Creates subcontext with name name, relative to this Context.
public  voiddestroySubcontext(Name name)
     Destroys subcontext with name name The subcontext must be empty otherwise ContextNotEmptyException is thrown.
public  voiddestroySubcontext(String name)
    
 StringgetAtomicName()
     Returns the "atomic" (as opposed to "composite") name of the context.
 StringgetCompoundStringName()
     Returns the compound string name of this context. Suppose a/b/c/d is the full name and this context is "c".
public  HashtablegetEnvironment()
    
public  StringgetNameInNamespace()
    
public  NameParsergetNameParser(Name name)
     Retrieves name parser used to parse context with name name.
public  NameParsergetNameParser(String name)
     Retrieves name parser used to parse context with name name.
 MockContextgetParentContext()
    
 booleanisRootContext()
    
public  NamingEnumerationlist(Name name)
     The same as listBindings(String)
Parameters:
  name - name of Context, relative to this Context NamingEnumeration of all name-class pairs.
public  NamingEnumerationlist(String name)
     The same as listBindings(String)
Parameters:
  name - name of Context, relative to this Context NamingEnumeration of all name-class pairs.
public  NamingEnumerationlistBindings(Name name)
     Lists all bindings for Context with name name. If name is empty then this Context is assumed.
Parameters:
  name - name of Context, relative to this Context NamingEnumeration of all name-object pairs.
public  NamingEnumerationlistBindings(String name)
     Lists all bindings for Context with name name. If name is empty then this Context is assumed.
Parameters:
  name - name of Context, relative to this Context NamingEnumeration of all name-object pairs.
public  Objectlookup(Name name)
     Looks up object with name name in this context.
public  Objectlookup(String name)
     Looks up the object in this context.
public  ObjectlookupLink(Name arg0)
    
public  ObjectlookupLink(String arg0)
    
public  voidrebind(Name name, Object obj)
     Rebinds object obj to name name. If there is existing binding it will be overwritten.
Parameters:
  name - name of the object to rebind
Parameters:
  obj - object to add.
public  voidrebind(String name, Object obj)
     Same as bind except that if name is already bound in the context, it will be re-bound to object obj
Parameters:
  name - name of the object to rebind
Parameters:
  obj - object to add.
public  ObjectremoveFromEnvironment(String arg0)
    
public  voidrename(Name arg0, Name arg1)
    
public  voidrename(String arg0, String arg1)
    
public  voidunbind(Name name)
     Removes name and its associated object from the context.
public  voidunbind(String name)
    


Constructor Detail
MockContext
protected MockContext(Context remoteContext)(Code)
Creates a new instance of the context. This class can only be instantiated by its factory.
Parameters:
  remoteContext - remote context that MockContext will delegate to if it fails to lookup an object locally




Method Detail
addToEnvironment
public Object addToEnvironment(String arg0, Object arg1) throws NamingException(Code)
Not implemented
See Also:   javax.naming.Context.addToEnvironment(java.lang.Stringjava.lang.Object)



bind
public void bind(Name name, Object obj) throws NamingException(Code)
Binds object obj to name name in this context. Intermediate contexts that do not exist will be created.
Parameters:
  name - name of the object to bind
Parameters:
  obj - object to bind. Can be null.
throws:
  NoPermissionException - if this context has been destroyed
throws:
  InvalidNameException - if name is empty or isCompositeName that spans more than one naming system
throws:
  NotContextException - if name has more than oneatomic name and intermediate atomic name is bound to object that isnot context.
See Also:   javax.naming.Context.bind(javax.naming.Namejava.lang.Object)



bind
public void bind(String name, Object obj) throws NamingException(Code)
Binds object obj to name name in this context.
Parameters:
  name - name of the object to add
Parameters:
  obj - object to bind
throws:
  NamingException - if naming error occurs
See Also:   MockContext.bind(Name,Object)



close
public void close() throws NamingException(Code)
Does nothing.



composeName
public Name composeName(Name name, Name prefix) throws NamingException(Code)
Returns composition of prefix and name.
Parameters:
  name - name relative to this context
Parameters:
  prefix - name of this context
See Also:   javax.naming.Context.composeName(javax.naming.Namejavax.naming.Name)



composeName
public String composeName(String name, String prefix) throws NamingException(Code)
Composes the name of this context with a name relative to this context. Given a name (name) relative to this context, and the name (prefix) of this context relative to one of its ancestors, this method returns the composition of the two names using the syntax appropriate for the naming system(s) involved. Example: composeName("a","b") b/a composeName("a","") a
Parameters:
  name - name relative to this context
Parameters:
  prefix - name of this context
See Also:   javax.naming.Context.composeName(java.lang.Stringjava.lang.String)



createSubcontext
public Context createSubcontext(Name name) throws NamingException(Code)
Creates subcontext with name name, relative to this Context.
Parameters:
  name - subcontext name. new subcontext named name relative to this context
throws:
  NoPermissionException - if this context has been destroyed
throws:
  InvalidNameException - if name is empty or isCompositeName that spans more than one naming system
throws:
  NameAlreadyBoundException - if name is already bound in this Context
throws:
  NotContextException - if any intermediate name from nameis not bound to instance of javax.naming.Context
See Also:   javax.naming.Context.createSubcontext(javax.naming.Name)



createSubcontext
public Context createSubcontext(String name) throws NamingException(Code)
Creates subcontext with name name, relative to this Context.
Parameters:
  name - subcontext name new subcontext named name relative to this context
throws:
  NamingException - if naming error occurs
See Also:   MockContext.createSubcontext(javax.naming.Name)



destroySubcontext
public void destroySubcontext(Name name) throws NamingException(Code)
Destroys subcontext with name name The subcontext must be empty otherwise ContextNotEmptyException is thrown.

Once a context is destroyed, the instance should not be used.
Parameters:
  name - subcontext to destroy
throws:
  NoPermissionException - if this context has been destroyed
throws:
  InvalidNameException - if name is empty or isCompositeName that spans more than one naming system
throws:
  ContextNotEmptyException - if Context name is not empty
throws:
  NameNotFoundException - if subcontext with name name can not be found
throws:
  NotContextException - if name is not bound to instance ofMockContext
See Also:   javax.naming.Context.destroySubcontext(javax.naming.Name)




destroySubcontext
public void destroySubcontext(String name) throws NamingException(Code)
Destroys subcontext with name name
Parameters:
  name - name of subcontext to destroy
throws:
  NamingException - if naming error occurs
See Also:   MockContext.destroySubcontext(javax.naming.Name)



getAtomicName
String getAtomicName()(Code)
Returns the "atomic" (as opposed to "composite") name of the context. name of the context



getCompoundStringName
String getCompoundStringName() throws NamingException(Code)
Returns the compound string name of this context. Suppose a/b/c/d is the full name and this context is "c". It's compound string name is a/b/c compound string name of the context



getEnvironment
public Hashtable getEnvironment() throws NamingException(Code)
Not implemented
See Also:   javax.naming.Context.getEnvironment



getNameInNamespace
public String getNameInNamespace() throws NamingException(Code)
Not implemented
See Also:   javax.naming.Context.getNameInNamespace



getNameParser
public NameParser getNameParser(Name name) throws NamingException(Code)
Retrieves name parser used to parse context with name name.
Parameters:
  name - context name NameParser
throws:
  NoPermissionException - if this context has been destroyed
throws:
  NamingException - if any other naming error occurs
See Also:   javax.naming.Context.getNameParser(javax.naming.Name)



getNameParser
public NameParser getNameParser(String name) throws NamingException(Code)
Retrieves name parser used to parse context with name name.
Parameters:
  name - context name NameParser
throws:
  NamingException - if naming error occurs
See Also:   MockContext.getNameParser(javax.naming.Name)



getParentContext
MockContext getParentContext()(Code)
Returns parent context of this context



isRootContext
boolean isRootContext()(Code)
Returns true if this context is the root context true if the context is the root context



list
public NamingEnumeration list(Name name) throws NamingException(Code)
The same as listBindings(String)
Parameters:
  name - name of Context, relative to this Context NamingEnumeration of all name-class pairs. Eachelement from the enumeration is instance of NameClassPair
throws:
  NamingException - if naming error occurs
See Also:   MockContext.listBindings(javax.naming.Name)



list
public NamingEnumeration list(String name) throws NamingException(Code)
The same as listBindings(String)
Parameters:
  name - name of Context, relative to this Context NamingEnumeration of all name-class pairs. Eachelement from the enumeration is instance of NameClassPair
throws:
  NamingException - if naming error occurs
See Also:   MockContext.listBindings(java.lang.String)



listBindings
public NamingEnumeration listBindings(Name name) throws NamingException(Code)
Lists all bindings for Context with name name. If name is empty then this Context is assumed.
Parameters:
  name - name of Context, relative to this Context NamingEnumeration of all name-object pairs. Eachelement from the enumeration is instance of Binding
throws:
  NoPermissionException - if this context has been destroyed
throws:
  InvalidNameException - if name is CompositeNamethat spans more than one naming system
throws:
  NameNotFoundException - if name can not be found
throws:
  NotContextException - component of name is not bound to instance ofMockContext, when name is not an atomic name
throws:
  NamingException - if any other naming error occurs
See Also:   javax.naming.Context.listBindings(javax.naming.Name)



listBindings
public NamingEnumeration listBindings(String name) throws NamingException(Code)
Lists all bindings for Context with name name. If name is empty then this Context is assumed.
Parameters:
  name - name of Context, relative to this Context NamingEnumeration of all name-object pairs. Eachelement from the enumeration is instance of Binding
throws:
  NamingException - if naming error occurs
See Also:   MockContext.listBindings(javax.naming.Name)



lookup
public Object lookup(Name name) throws NamingException(Code)
Looks up object with name name in this context. If the object is not found and the remote context was provided, calls the remote context to lookup the object.
Parameters:
  name - name to look up object reference bound to name name
throws:
  NoPermissionException - if this context has been destroyed
throws:
  InvalidNameException - if name is CompositeNamethat spans more than one naming system
throws:
  NameNotFoundException - if name can not be found
throws:
  NotContextException - component of name is not bound to instance ofMockContext, when name is not atomic name.
throws:
  NamingException - if any other naming error occurs
See Also:   javax.naming.Context.lookup(javax.naming.Name)



lookup
public Object lookup(String name) throws NamingException(Code)
Looks up the object in this context. If the object is not found and the remote context was provided, calls the remote context to lookup the object.
Parameters:
  name - object to search object reference bound to name name
throws:
  NamingException - if naming error occurs
See Also:   MockContext.lookup(javax.naming.Name)



lookupLink
public Object lookupLink(Name arg0) throws NamingException(Code)
Not implemented
See Also:   javax.naming.Context.lookupLink(javax.naming.Name)



lookupLink
public Object lookupLink(String arg0) throws NamingException(Code)
Not implemented
See Also:   javax.naming.Context.lookupLink(java.lang.String)



rebind
public void rebind(Name name, Object obj) throws NamingException(Code)
Rebinds object obj to name name. If there is existing binding it will be overwritten.
Parameters:
  name - name of the object to rebind
Parameters:
  obj - object to add. Can be null
throws:
  NoPermissionException - if this context has been destroyed
throws:
  InvalidNameException - if name is empty or isCompositeName that spans more than one naming system
throws:
  NotContextException - if name has more than oneatomic name and intermediate context is not found
throws:
  NamingException - if any other naming error occurs
See Also:   javax.naming.Context.rebind(javax.naming.Namejava.lang.Object)



rebind
public void rebind(String name, Object obj) throws NamingException(Code)
Same as bind except that if name is already bound in the context, it will be re-bound to object obj
Parameters:
  name - name of the object to rebind
Parameters:
  obj - object to add. Can be null
throws:
  NamingException - if naming error occurs
See Also:   MockContext.rebind(javax.naming.Name,Object)



removeFromEnvironment
public Object removeFromEnvironment(String arg0) throws NamingException(Code)
Not implemented
See Also:   javax.naming.Context.removeFromEnvironment(java.lang.String)



rename
public void rename(Name arg0, Name arg1) throws NamingException(Code)
Not implemented
See Also:   javax.naming.Context.rename(javax.naming.Namejavax.naming.Name)



rename
public void rename(String arg0, String arg1) throws NamingException(Code)
Not implemented
See Also:   javax.naming.Context.rename(java.lang.Stringjava.lang.String)



unbind
public void unbind(Name name) throws NamingException(Code)
Removes name and its associated object from the context.
Parameters:
  name - name to remove
throws:
  NoPermissionException - if this context has been destroyed
throws:
  InvalidNameException - if name is empty or isCompositeName that spans more than one naming system
throws:
  NameNotFoundException - if intermediate context can not be found
throws:
  NotContextException - if name has more than oneatomic name and intermediate context is not found
throws:
  NamingException - if any other naming exception occurs
See Also:   javax.naming.Context.unbind(javax.naming.Name)



unbind
public void unbind(String name) throws NamingException(Code)
Removes object from the object map
Parameters:
  name - object to remove
throws:
  NamingException - if naming error occurs
See Also:   MockContext.unbind(javax.naming.Name)



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.