1 26 27 package org.objectweb.openccm.pss.runtime.jdo.kodo; 28 29 30 37 38 public class Connector 39 extends org.objectweb.openccm.pss.runtime.jdo.lib.Connector 40 { 41 47 48 java.util.Properties props_ = null; 49 50 56 59 public Connector() 60 { 61 super(); 62 } 63 64 70 75 private void 76 load_kodo_properties(String file) 77 { 78 props_ = new java.util.Properties (); 79 80 try { 81 java.io.InputStream propStream = null; 82 83 propStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(file); 84 props_.load(propStream); 85 }catch (Exception e) { 86 throw new RuntimeException (e); 87 } 88 89 System.getProperties().putAll(props_); 90 } 91 92 97 private org.omg.CosPersistentState.Parameter[] 98 get_session_parameters() 99 { 100 org.omg.CosPersistentState.Parameter[] parameters = null; 101 org.omg.CosPersistentState.Parameter param = null; 102 org.omg.CORBA.Any a = null; 103 String value = null; 104 105 parameters = new org.omg.CosPersistentState.Parameter[5]; 107 108 a = org.objectweb.openccm.corba.TheORB.getORB().create_any(); 109 value = System.getProperty("javax.jdo.option.ConnectionURL"); 110 a.insert_string(value); 111 param = new org.omg.CosPersistentState.Parameter("DB_URL", a); 112 parameters[0] = param; 113 114 a = org.objectweb.openccm.corba.TheORB.getORB().create_any(); 115 value = System.getProperty("javax.jdo.option.ConnectionDriverName"); 116 a.insert_string(value); 117 param = new org.omg.CosPersistentState.Parameter("DB_DRIVER", a); 118 parameters[1] = param; 119 120 a = org.objectweb.openccm.corba.TheORB.getORB().create_any(); 121 value = System.getProperty("javax.jdo.PersistenceManagerFactoryClass"); 122 a.insert_string(value); 123 param = new org.omg.CosPersistentState.Parameter("PM_FACTORY", a); 124 parameters[2] = param; 125 126 a = org.objectweb.openccm.corba.TheORB.getORB().create_any(); 127 value = System.getProperty("javax.jdo.option.ConnectionUserName"); 128 a.insert_string(value); 129 param = new org.omg.CosPersistentState.Parameter("USER_NAME", a); 130 parameters[3] = param; 131 132 a = org.objectweb.openccm.corba.TheORB.getORB().create_any(); 133 value = System.getProperty("javax.jdo.option.ConnectionPassword"); 134 a.insert_string(value); 135 param = new org.omg.CosPersistentState.Parameter("PASSWORD", a); 136 parameters[4] = param; 137 138 return parameters; 139 } 140 141 147 153 156 public org.omg.CosPersistentState.Session 157 create_basic_session(short access_mode, 158 org.omg.CosPersistentState.Parameter[] additional_parameters) 159 { 160 if (additional_parameters.length == 1) 161 { 162 org.omg.CosPersistentState.Parameter param = additional_parameters[0]; 163 164 if (param.name.compareTo(Connector.CONF_FILE_KEY) == 0) 165 { 166 load_kodo_properties( param.val.extract_string() ); 167 } 168 else 169 throw new RuntimeException ("CONF_FILE parameter is missing!"); 170 } 171 else 172 throw new RuntimeException ("CONF_FILE parameter is missing!"); 173 174 return super.create_basic_session(access_mode, get_session_parameters()); 175 } 176 177 180 public org.omg.CosPersistentState.TransactionalSession 181 create_transactional_session(short access_mode, 182 short default_isolation_level, 183 org.omg.CosPersistentState.EndOfAssociationCallback callback, 184 org.omg.CosPersistentState.Parameter[] additional_parameters) 185 { 186 return null; 188 } 189 190 193 public org.omg.CosPersistentState.SessionPool 194 create_session_pool(short access_mode, 195 short tx_policy, 196 org.omg.CosPersistentState.Parameter[] additional_parameters) 197 { 198 return null; 200 } 201 202 208 } 209 210 | Popular Tags |