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 javax.naming.NameParser; 12 import javax.naming.Name; 13 import javax.naming.Context; 14 import javax.naming.NamingException; 15 import javax.naming.spi.InitialContextFactory; 16 import javax.naming.spi.ObjectFactory; 17 import javax.naming.spi.StateFactory; 18 19 /*** 20 * This is the class to extend that provides 21 * basic facilities for Namespace management. 22 * 23 * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> 24 * @version $Revision: 1.2 $ 25 */ 26 public abstract class AbstractNamespace 27 implements Namespace 28 { 29 protected ObjectFactory[] m_objectFactorySet; 30 protected StateFactory[] m_stateFactorySet; 31 32 public Object getStateToBind( final Object object, 33 final Name name, 34 final Context parent, 35 final Hashtable environment ) 36 throws NamingException 37 { 38 //for thread safety so that member variable can be updated 39 //at any time 40 final StateFactory[] stateFactorySet = m_stateFactorySet; 41 42 for( int i = 0; i < stateFactorySet.length; i++ ) 43 { 44 final Object result = 45 stateFactorySet[ i ].getStateToBind( object, name, parent, environment ); 46 47 if( null != result ) 48 { 49 return result; 50 } 51 } 52 53 return object; 54 } 55 56 public Object getObjectInstance( final Object object, 57 final Name name, 58 final Context parent, 59 final Hashtable environment ) 60 throws Exception 61 { 62 //for thread safety so that member variable can be updated 63 //at any time 64 final ObjectFactory[] objectFactorySet = m_objectFactorySet; 65 66 for( int i = 0; i < objectFactorySet.length; i++ ) 67 { 68 final Object result = 69 objectFactorySet[ i ].getObjectInstance( object, name, parent, environment ); 70 71 if( null != result ) 72 { 73 return result; 74 } 75 } 76 77 return object; 78 } 79 }

This page was automatically generated by Maven