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; 9 10 import java.util.Hashtable; 11 import java.util.Iterator; 12 import java.util.NoSuchElementException; 13 import javax.naming.Binding; 14 import javax.naming.Context; 15 import javax.naming.Name; 16 import javax.naming.NameClassPair; 17 import javax.naming.NamingEnumeration; 18 import javax.naming.NamingException; 19 import javax.naming.spi.NamingManager; 20 21 /*** 22 * Class for building NamingEnumerations. 23 * 24 * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> 25 * @version $Revision: 1.2 $ 26 */ 27 public abstract class AbstractNamingEnumeration 28 implements NamingEnumeration 29 { 30 protected Context m_owner; 31 protected Namespace m_namespace; 32 33 public AbstractNamingEnumeration( final Context owner, final Namespace namespace ) 34 { 35 m_owner = owner; 36 m_namespace = namespace; 37 } 38 39 public boolean hasMore() 40 throws NamingException 41 { 42 return hasMoreElements(); 43 } 44 45 public Object nextElement() 46 { 47 try { return next(); } 48 catch( final NamingException ne ) 49 { 50 throw new NoSuchElementException( ne.toString() ); 51 } 52 } 53 54 protected Object resolve( final String name, final Object object ) 55 throws NamingException 56 { 57 // Call getObjectInstance for using any object factories 58 try 59 { 60 final Name atom = m_owner.getNameParser( name ).parse( name ); 61 return m_namespace. 62 getObjectInstance( object, atom, m_owner, m_owner.getEnvironment() ); 63 } 64 catch( final Exception e ) 65 { 66 final NamingException ne = new NamingException( "getObjectInstance failed" ); 67 ne.setRootCause( e ); 68 throw ne; 69 } 70 } 71 72 public void close() 73 { 74 m_namespace = null; 75 m_owner = null; 76 } 77 }

This page was automatically generated by Maven