KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > spice > jndikit > test > TestStateFactory


1 /*
2  * Copyright (C) The Spice Group. All rights reserved.
3  *
4  * This software is published under the terms of the Spice
5  * Software License version 1.1, a copy of which has been included
6  * with this distribution in the LICENSE.txt file.
7  */

8 package org.codehaus.spice.jndikit.test;
9
10 import java.util.Hashtable JavaDoc;
11 import javax.naming.Context JavaDoc;
12 import javax.naming.Name JavaDoc;
13 import javax.naming.NamingException JavaDoc;
14 import javax.naming.spi.DirectoryManager JavaDoc;
15 import javax.naming.spi.NamingManager JavaDoc;
16 import javax.naming.spi.StateFactory JavaDoc;
17
18
19 /**
20  * Implementation of {@link StateFactory} for testing purposes.
21  *
22  * @author Tim Anderson
23  * @version $Revision: 1.1 $ $Date: 2005/06/30 04:22:16 $
24  */

25 public class TestStateFactory implements StateFactory JavaDoc
26 {
27
28     /**
29      * Retrieves the state of an object for binding.
30      *
31      * @param obj A non-null object whose state is to be retrieved.
32      * @param name The name of this object relative to <code>nameCtx</code>,
33      * or null if no name is specified.
34      * @param nameCtx The context relative to which the <code>name</code>
35      * parameter is specified, or null if <code>name</code>
36      * is relative to the default initial context.
37      * @param environment The possibly null environment to be used in the
38      * creation of the object's state.
39      * @return The object's state for binding; null if the factory is not
40      * returning any changes.
41      * @throws NamingException if this factory encountered an exception while
42      * attempting to get the object's state, and no
43      * other factories are to be tried.
44      * @see NamingManager#getStateToBind
45      * @see DirectoryManager#getStateToBind
46      */

47     public Object JavaDoc getStateToBind( Object JavaDoc obj, Name JavaDoc name, Context JavaDoc nameCtx,
48                                   Hashtable JavaDoc environment )
49         throws NamingException JavaDoc
50     {
51         Object JavaDoc result = null;
52         if( obj instanceof TestData )
53         {
54             TestData data = ( TestData ) obj;
55             TestDataReferenceable ref = new TestDataReferenceable(
56                 data.getValue() );
57             result = ref.getReference();
58         }
59         return result;
60     }
61 }
62
Popular Tags