1 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 ; 37 import java.util.Map ; 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 message) { 55 throw new UnsupportedOperationException (); 56 } 57 58 public void closeAllSessions() { 59 throw new UnsupportedOperationException (); 60 } 61 62 public void checkNoSessions(String message) { 63 throw new UnsupportedOperationException (); 64 } 65 66 public void defineClass(Session session, ClassDescription classMetaDescription) { 67 String className = classMetaDescription.getClassName(); 68 Object clid = connexion.getClidFromClassName(className); 69 classMetas.put(clid, classMetaDescription); 70 classTable.put(className, clid); 71 } 72 73 public ClassDescription getMetaData(String className) { 74 return (ClassDescription) classMetas.get(classTable.get(className)); 75 } 76 77 public void removeClass(Session session, String className) { 78 if (!classTable.containsKey(className)) { 79 throw new SchemaException("Class " + className + " is not define in base"); 80 } 81 Object clid = classTable.remove(className); 82 classMetas.remove(clid); 83 } 84 85 public void addField(Session session, String className, FieldDescription fieldDescription) { 86 throw new UnsupportedOperationException (); 87 } 88 89 public String [] getFieldNames(String className) { 90 return getMetaData(className).getFieldNames(); 91 } 92 93 public void renameField(Session session, String className, String oldFieldName, String newFieldName) { 94 throw new UnsupportedOperationException (); 95 } 96 97 public void removeField(Session session, String className, String fieldName) { 98 throw new UnsupportedOperationException (); 99 } 100 101 public int getIndex(String className, String fieldName) { 102 throw new UnsupportedOperationException (); 103 } 104 105 public Collection getAllClassNames() { 106 return classTable.keySet(); 107 } 108 109 public void addSession(SessionInternal session) { 110 throw new UnsupportedOperationException (); 111 } 112 113 public void removeSession(SessionInternal session) { 114 throw new UnsupportedOperationException (); 115 } 116 117 public String getClassNameFromClid(Object clid) { 118 ClassDescription meta = (ClassDescription) classMetas.get(clid); 119 return meta.getClassName(); 120 } 121 122 public Object getClidFromClassName(String fullClassName) { 123 Object 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 clid) { 131 return (ClassDescriptionImpl) classMetas.get(clid); 132 } 133 134 135 private ClientCommunicationAgent connexion; 136 private Map classMetas; private Map classTable; } 139 | Popular Tags |