KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > naming > AbstractModel


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.naming;
31
32 import javax.naming.NamingException JavaDoc;
33 import java.util.List JavaDoc;
34
35 /**
36  * Abstract data model behind Resin's JNDI.
37  */

38 abstract public class AbstractModel {
39   protected AbstractModel create()
40   {
41     throw new UnsupportedOperationException JavaDoc();
42   }
43   
44   /**
45    * This is a deep copy.
46    *
47    * @return a deep copy of the context
48    */

49   public AbstractModel copy()
50     throws NamingException JavaDoc
51   {
52     AbstractModel copy = create();
53
54     List JavaDoc names = list();
55     for (int i = 0; i < names.size(); i++) {
56       String JavaDoc name = (String JavaDoc) names.get(i);
57       Object JavaDoc value = lookup(name);
58
59       if (value instanceof AbstractModel)
60         copy.bind(name, ((AbstractModel) value).copy());
61       else
62         copy.bind(name, value);
63     }
64
65     return copy;
66   }
67
68   /**
69    * Returns the object from looking up a single link.
70    *
71    * @param name the name segment.
72    *
73    * @return the object stored in the map.
74    */

75   public Object JavaDoc lookup(String JavaDoc name)
76     throws NamingException JavaDoc
77   {
78     throw new UnsupportedOperationException JavaDoc();
79   }
80
81   /**
82    * Binds an object as a child to the model.
83    */

84   public void bind(String JavaDoc name, Object JavaDoc obj)
85     throws NamingException JavaDoc
86   {
87     throw new UnsupportedOperationException JavaDoc(getClass().getName());
88   }
89
90   /**
91    * Unbinds an object as a child to the model.
92    */

93   public void unbind(String JavaDoc name)
94     throws NamingException JavaDoc
95   {
96     throw new UnsupportedOperationException JavaDoc(getClass().getName());
97   }
98
99   /**
100    * Creates a subcontext for the model.
101    */

102   public AbstractModel createSubcontext(String JavaDoc name)
103     throws NamingException JavaDoc
104   {
105     throw new UnsupportedOperationException JavaDoc();
106   }
107
108   /**
109    * Lists the child names.
110    */

111   public List JavaDoc list()
112     throws NamingException JavaDoc
113   {
114     throw new UnsupportedOperationException JavaDoc();
115   }
116 }
117
Popular Tags