Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha5
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.common.naming
Class SingletonInitialContext

    java.lang.Object
      org.modeshape.common.naming.SingletonInitialContext

All Implemented Interfaces:
  Context

    public class SingletonInitialContext

extends Object
implements Context

A simple and limited `JNDI naming context` that can be used in unit tests for code that `looks up` objects.

This can be used easily in a unit test by either using one of two methods. The first is using the convenient static `configure` method that takes one, two or three name/object pairs:

     SingletonInitialContext.register(name, obj);
     SingletonInitialContext.register(name1, obj1, name2, obj2);
     SingletonInitialContext.register(name1, obj1, name2, obj2, name3, obj3);

The other approach is to set the system property for the `InitialContextFactory`:

     System.setProperty("java.naming.factory.initial", "org.modeshape.common.mock.SingletonInitialContextFactory");

and then to `bind` an object.

Author:
  Luca Stancapiano, Randall Hauch
See Also:
  `SingletonInitialContextFactory`

Field Summary

Fields inherited from interface javax.naming.Context
`APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES`

Method Summary
`Object` | `addToEnvironment(String propName, Object propVal)`
`void` | `bind(Name name, Object obj)`
`void` | `bind(String name, Object obj)`
`void` | `close()`
`Name` | `composeName(Name name, Name prefix)`
`String` | `composeName(String name, String prefix)`
`Context` | `createSubcontext(Name name)`
`Context` | `createSubcontext(String name)`
`void` | `destroySubcontext(Name name)`
`void` | `destroySubcontext(String name)`
`Hashtable<?,?>` | `getEnvironment()`
`String` | `getNameInNamespace()`
`NameParser` | `getNameParser(Name name)`
`NameParser` | `getNameParser(String name)`
`NamingEnumeration<NameClassPair>` | `list(Name name)`
`NamingEnumeration<NameClassPair>` | `list(String name)`
`NamingEnumeration<Binding>` | `listBindings(Name name)`
`NamingEnumeration<Binding>` | `listBindings(String name)`
`Object` | `lookup(Name name)`
`Object` | `lookup(String name)`
`Object` | `lookupLink(Name name)`
`Object` | `lookupLink(String name)`
`void` | `rebind(Name name, Object obj)`
`void` | `rebind(String name, Object obj)`
`static void` | `register(String name, Object obj)` A convenience method that registers the supplied object with the supplied name.
`static void` | `register(String name1, Object obj1, String name2, Object obj2)` A convenience method that registers the supplied objects with the supplied names.
`static void` | `register(String name1, Object obj1, String name2, Object obj2, String name3, Object obj3)` A convenience method that registers the supplied objects with the supplied names.
`Object` | `removeFromEnvironment(String propName)`
`void` | `rename(Name oldName, Name newName)`
`void` | `rename(String oldName, String newName)`
`void` | `unbind(Name name)`
`void` | `unbind(String name)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### register

    public static void register(String name,
                                Object obj)

  A convenience method that registers the supplied object with the supplied name.

  Parameters:
    `name` - the JNDI name
    `obj` - the object to be registered

### register

    public static void register(String name1,
                                Object obj1,
                                String name2,
                                Object obj2)

  A convenience method that registers the supplied objects with the supplied names.

  Parameters:
    `name1` - the JNDI name for the first object
    `obj1` - the first object to be registered
    `name2` - the JNDI name for the second object
    `obj2` - the second object to be registered

### register

    public static void register(String name1,
                                Object obj1,
                                String name2,
                                Object obj2,
                                String name3,
                                Object obj3)

  A convenience method that registers the supplied objects with the supplied names.

  Parameters:
    `name1` - the JNDI name for the first object
    `obj1` - the first object to be registered
    `name2` - the JNDI name for the second object
    `obj2` - the second object to be registered
    `name3` - the JNDI name for the third object
    `obj3` - the third object to be registered

### addToEnvironment

    public Object addToEnvironment(String propName,
                                   Object propVal)

  Specified by:
    `addToEnvironment` in interface `Context`

### removeFromEnvironment

    public Object removeFromEnvironment(String propName)

  Specified by:
    `removeFromEnvironment` in interface `Context`

### bind

    public void bind(Name name,
                     Object obj)
              throws NamingException

  Specified by:
    `bind` in interface `Context`
  Throws:
    `NamingException`

### bind

    public void bind(String name,
                     Object obj)
              throws NamingException

  Specified by:
    `bind` in interface `Context`
  Throws:
    `NamingException`

### rebind

    public void rebind(Name name,
                       Object obj)

  Specified by:
    `rebind` in interface `Context`

### rebind

    public void rebind(String name,
                       Object obj)

  Specified by:
    `rebind` in interface `Context`

### unbind

    public void unbind(String name)

  Specified by:
    `unbind` in interface `Context`

### unbind

    public void unbind(Name name)

  Specified by:
    `unbind` in interface `Context`

### lookup

    public Object lookup(Name name)
                  throws NamingException

  Specified by:
    `lookup` in interface `Context`
  Throws:
    `NamingException`

### lookup

    public Object lookup(String name)
                  throws NamingException

  Specified by:
    `lookup` in interface `Context`
  Throws:
    `NamingException`

### lookupLink

    public Object lookupLink(String name)

  Specified by:
    `lookupLink` in interface `Context`

### lookupLink

    public Object lookupLink(Name name)

  Specified by:
    `lookupLink` in interface `Context`

### rename

    public void rename(Name oldName,
                       Name newName)

  Specified by:
    `rename` in interface `Context`

### rename

    public void rename(String oldName,
                       String newName)

  Specified by:
    `rename` in interface `Context`

### close

    public void close()

  Specified by:
    `close` in interface `Context`

### composeName

    public Name composeName(Name name,
                            Name prefix)

  Specified by:
    `composeName` in interface `Context`

### composeName

    public String composeName(String name,
                              String prefix)

  Specified by:
    `composeName` in interface `Context`

### createSubcontext

    public Context createSubcontext(Name name)

  Specified by:
    `createSubcontext` in interface `Context`

### createSubcontext

    public Context createSubcontext(String name)

  Specified by:
    `createSubcontext` in interface `Context`

### destroySubcontext

    public void destroySubcontext(Name name)

  Specified by:
    `destroySubcontext` in interface `Context`

### destroySubcontext

    public void destroySubcontext(String name)

  Specified by:
    `destroySubcontext` in interface `Context`

### getEnvironment

    public Hashtable<?,?> getEnvironment()

  Specified by:
    `getEnvironment` in interface `Context`

### getNameInNamespace

    public String getNameInNamespace()

  Specified by:
    `getNameInNamespace` in interface `Context`

### getNameParser

    public NameParser getNameParser(Name name)

  Specified by:
    `getNameParser` in interface `Context`

### getNameParser

    public NameParser getNameParser(String name)

  Specified by:
    `getNameParser` in interface `Context`

### list

    public NamingEnumeration<NameClassPair> list(Name name)

  Specified by:
    `list` in interface `Context`

### list

    public NamingEnumeration<NameClassPair> list(String name)

  Specified by:
    `list` in interface `Context`

### listBindings

    public NamingEnumeration<Binding> listBindings(Name name)

  Specified by:
    `listBindings` in interface `Context`

### listBindings

    public NamingEnumeration<Binding> listBindings(String name)

  Specified by:
    `listBindings` in interface `Context`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha5
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.