1 26 27 package org.objectweb.openccm.pss.runtime.jdo.lib; 28 29 import javax.jdo.PersistenceManagerFactory; 31 import javax.jdo.PersistenceManager; 32 33 40 41 public class Connector 42 extends org.objectweb.openccm.pss.runtime.common.lib.ConnectorBase 43 implements org.objectweb.openccm.pss.runtime.jdo.api.Connector 44 { 45 51 57 60 public Connector() 61 { 62 super("org.objectweb.openccm.pss.runtime.JDO"); 63 } 64 65 71 77 83 86 public org.omg.CosPersistentState.Session 87 create_basic_session(short access_mode, 88 org.omg.CosPersistentState.Parameter[] additional_parameters) 89 { 90 String pmf_class = null, 91 db_url = null, 92 db_driver = null, 93 user_name = null, 94 password = null; 95 org.omg.CosPersistentState.Parameter param = null; 96 97 if (additional_parameters.length < 3) 98 return null; 99 100 for (int i=0; i<additional_parameters.length; i++) 101 { 102 param = additional_parameters[i]; 103 104 if (param.name.compareTo(Connector.PM_FACTORY_KEY) == 0) 105 { 106 pmf_class = param.val.extract_string(); 108 } 109 else if (param.name.compareTo(Connector.DB_URL_KEY) == 0) 110 { 111 db_url = param.val.extract_string(); 113 } 114 else if (param.name.compareTo(Connector.DB_DRIVER_KEY) == 0) 115 { 116 db_driver = param.val.extract_string(); 118 } 119 else if (param.name.compareTo(Connector.USER_NAME_KEY) == 0) 120 { 121 user_name = param.val.extract_string(); 123 } 124 else if (param.name.compareTo(Connector.PASSWORD_KEY) == 0) 125 { 126 password = param.val.extract_string(); 128 } 129 } 130 131 try { 133 PersistenceManagerFactory pmf = 134 (PersistenceManagerFactory) Class.forName(pmf_class).newInstance(); 135 pmf.setConnectionURL(db_url); 136 pmf.setConnectionDriverName(db_driver); 137 if (user_name != null) 138 pmf.setConnectionUserName(user_name); 139 if (password != null) 140 pmf.setConnectionPassword(password); 141 142 PersistenceManager pm = pmf.getPersistenceManager(); 143 144 return new org.objectweb.openccm.pss.runtime.jdo.lib.Session(get_free_id(), pm); 145 } catch (Exception e) { 146 e.printStackTrace(); 147 } 148 return null; 149 } 150 151 154 public org.omg.CosPersistentState.TransactionalSession 155 create_transactional_session(short access_mode, 156 short default_isolation_level, 157 org.omg.CosPersistentState.EndOfAssociationCallback callback, 158 org.omg.CosPersistentState.Parameter[] additional_parameters) 159 { 160 return null; 162 } 163 164 167 public org.omg.CosPersistentState.SessionPool 168 create_session_pool(short access_mode, 169 short tx_policy, 170 org.omg.CosPersistentState.Parameter[] additional_parameters) 171 { 172 return null; 174 } 175 176 179 public org.omg.CosPersistentState.TransactionalSession 180 current_session() 181 { 182 return null; 184 } 185 186 189 public org.omg.CosPersistentState.TransactionalSession[] 190 sessions(org.omg.CosTransactions.Coordinator transaction) 191 { 192 return null; 194 } 195 196 197 203 } 204 | Popular Tags |