View Javadoc

1   /*
2    * Copyright (C) The Apache Software Foundation. All rights reserved.
3    *
4    * This software is published under the terms of the Apache Software License
5    * version 1.1, a copy of which has been included with this distribution in
6    * the LICENSE file.
7    */
8   package org.apache.avalon.excalibur.naming.memory;
9   
10  import java.util.Hashtable;
11  import java.util.NoSuchElementException;
12  import javax.naming.Context;
13  import javax.naming.NamingException;
14  import javax.naming.spi.InitialContextFactory;
15  import org.apache.avalon.excalibur.naming.DefaultNameParser;
16  import org.apache.avalon.excalibur.naming.DefaultNamespace;
17  
18  /***
19   * Initial context factory for memorycontext.
20   *
21   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
22   * @version $Revision: 1.2 $
23   */
24  public class MemoryInitialContextFactory
25      implements InitialContextFactory
26  {
27      public Context getInitialContext( final Hashtable environment )
28          throws NamingException
29      {
30          final DefaultNameParser parser = new DefaultNameParser();
31          final DefaultNamespace namespace = new DefaultNamespace( parser );
32          return new MemoryContext( namespace, environment, null );
33      }
34  }
35