KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > se > impl > client > InternalMetaRepositoryClientImpl


1 /*
2  * Jalisto - JAva LIght STOrage
3  * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Xcalia
20  * 71, rue Desnouettes
21  * 75014 Paris - France
22  * http://www.xcalia.com
23  */

24 package org.objectweb.jalisto.se.impl.client;
25
26 import org.objectweb.jalisto.se.api.Session;
27 import org.objectweb.jalisto.se.exception.SchemaException;
28 import org.objectweb.jalisto.se.api.*;
29 import org.objectweb.jalisto.se.api.remote.ClientCommunicationAgent;
30 import org.objectweb.jalisto.se.impl.meta.ClassDescriptionImpl;
31 import org.objectweb.jalisto.se.api.ClassDescription;
32 import org.objectweb.jalisto.se.api.query.FieldDescription;
33 import org.objectweb.jalisto.se.api.internal.SessionInternal;
34 import org.objectweb.jalisto.se.api.internal.InternalMetaRepository;
35
36 import java.util.Collection JavaDoc;
37 import java.util.Map JavaDoc;
38
39 public class InternalMetaRepositoryClientImpl implements InternalMetaRepository {
40
41     public InternalMetaRepositoryClientImpl(JalistoProperties properties, ClientCommunicationAgent connexion) {
42         this.connexion = connexion;
43     }
44
45     public void init() {
46         if (classMetas == null) {
47             this.classMetas = connexion.getClassMetas();
48         }
49         if (classTable == null) {
50             this.classTable = connexion.getClassTable();
51         }
52     }
53
54     public void checkNoActive(String JavaDoc message) {
55         throw new UnsupportedOperationException JavaDoc();
56     }
57
58     public void closeAllSessions() {
59         throw new UnsupportedOperationException JavaDoc();
60     }
61
62     public void checkNoSessions(String JavaDoc message) {
63         throw new UnsupportedOperationException JavaDoc();
64     }
65
66     public void defineClass(Session session, ClassDescription classMetaDescription) {
67         String JavaDoc className = classMetaDescription.getClassName();
68         Object JavaDoc clid = connexion.getClidFromClassName(className);
69         classMetas.put(clid, classMetaDescription);
70         classTable.put(className, clid);
71     }
72
73     public ClassDescription getMetaData(String JavaDoc className) {
74         return (ClassDescription) classMetas.get(classTable.get(className));
75     }
76
77     public void removeClass(Session session, String JavaDoc className) {
78         if (!classTable.containsKey(className)) {
79             throw new SchemaException("Class " + className + " is not define in base");
80         }
81         Object JavaDoc clid = classTable.remove(className);
82         classMetas.remove(clid);
83     }
84
85     public void addField(Session session, String JavaDoc className, FieldDescription fieldDescription) {
86         throw new UnsupportedOperationException JavaDoc();
87     }
88
89     public String JavaDoc[] getFieldNames(String JavaDoc className) {
90         return getMetaData(className).getFieldNames();
91     }
92
93     public void renameField(Session session, String JavaDoc className, String JavaDoc oldFieldName, String JavaDoc newFieldName) {
94         throw new UnsupportedOperationException JavaDoc();
95     }
96
97     public void removeField(Session session, String JavaDoc className, String JavaDoc fieldName) {
98         throw new UnsupportedOperationException JavaDoc();
99     }
100
101     public int getIndex(String JavaDoc className, String JavaDoc fieldName) {
102         throw new UnsupportedOperationException JavaDoc();
103     }
104
105     public Collection JavaDoc getAllClassNames() {
106         return classTable.keySet();
107     }
108
109     public void addSession(SessionInternal session) {
110         throw new UnsupportedOperationException JavaDoc();
111     }
112
113     public void removeSession(SessionInternal session) {
114         throw new UnsupportedOperationException JavaDoc();
115     }
116
117     public String JavaDoc getClassNameFromClid(Object JavaDoc clid) {
118         ClassDescription meta = (ClassDescription) classMetas.get(clid);
119         return meta.getClassName();
120     }
121
122     public Object JavaDoc getClidFromClassName(String JavaDoc fullClassName) {
123         Object JavaDoc clid = classTable.get(fullClassName);
124         if (clid == null) {
125             throw new SchemaException("Class " + fullClassName + " is not define in base");
126         }
127         return clid;
128     }
129
130     public ClassDescription getPersistentClassMetaDescription(Object JavaDoc clid) {
131         return (ClassDescriptionImpl) classMetas.get(clid);
132     }
133
134
135     private ClientCommunicationAgent connexion;
136     private Map JavaDoc classMetas; // clid -> classMeta
137
private Map JavaDoc classTable; // classname -> clid
138
}
139
Popular Tags