1 16 package org.apache.juddi.datastore.jdbc; 17 18 import java.sql.Connection ; 19 import java.util.Vector ; 20 21 import org.apache.juddi.datatype.binding.AccessPoint; 22 import org.apache.juddi.datatype.binding.BindingTemplate; 23 import org.apache.juddi.datatype.binding.TModelInstanceInfo; 24 import org.apache.juddi.datatype.business.BusinessEntity; 25 import org.apache.juddi.datatype.service.BusinessService; 26 import org.apache.juddi.util.Config; 27 import org.apache.juddi.util.jdbc.Transaction; 28 import org.apache.juddi.uuidgen.UUIDGen; 29 import org.apache.juddi.uuidgen.UUIDGenFactory; 30 31 34 class TestTModelInstanceInfoTable 35 { 36 public static void main(String [] args) 37 throws Exception 38 { 39 Config.setStringProperty("juddi.useConnectionPool","true"); 42 43 Connection conn = null; 44 try { 45 conn = Database.aquireConnection(); 46 test(conn); 47 } 48 finally { 49 if (conn != null) 50 conn.close(); 51 } 52 } 53 54 public static void test(Connection connection) throws Exception 55 { 56 Transaction txn = new Transaction(); 57 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 58 59 if (connection != null) 60 { 61 try 62 { 63 String businessKey = uuidgen.uuidgen(); 64 BusinessEntity business = new BusinessEntity(); 65 business.setBusinessKey(businessKey); 66 business.setAuthorizedName("mleblanc"); 67 business.setOperator("XMLServiceRegistry.com"); 68 69 String serviceKey = uuidgen.uuidgen(); 70 BusinessService service = new BusinessService(); 71 service.setBusinessKey(businessKey); 72 service.setServiceKey(serviceKey); 73 74 String bindingKey = uuidgen.uuidgen(); 75 BindingTemplate binding = new BindingTemplate(); 76 binding.setServiceKey(serviceKey); 77 binding.setBindingKey(bindingKey); 78 binding.setAccessPoint( 79 new AccessPoint( 80 "http://www.juddi.org/tmodelinstanceinfo.html", 81 "http")); 82 83 Vector infoList = new Vector (); 84 infoList.add(new TModelInstanceInfo(uuidgen.uuidgen())); 85 infoList.add(new TModelInstanceInfo(uuidgen.uuidgen())); 86 infoList.add(new TModelInstanceInfo(uuidgen.uuidgen())); 87 infoList.add(new TModelInstanceInfo(uuidgen.uuidgen())); 88 89 String authorizedUserID = "sviens"; 90 91 txn.begin(connection); 93 94 BusinessEntityTable.insert(business, authorizedUserID, connection); 96 97 BusinessServiceTable.insert(service, connection); 99 100 BindingTemplateTable.insert(binding, connection); 102 103 TModelInstanceInfoTable.insert(bindingKey, infoList, connection); 105 106 infoList = TModelInstanceInfoTable.select(bindingKey, connection); 108 109 TModelInstanceInfoTable.delete(bindingKey, connection); 111 112 infoList = TModelInstanceInfoTable.select(bindingKey, connection); 114 115 txn.commit(); 117 } 118 catch (Exception ex) 119 { 120 try 121 { 122 txn.rollback(); 123 } 124 catch (java.sql.SQLException sqlex) 125 { 126 sqlex.printStackTrace(); 127 } 128 throw ex; 129 } 130 } 131 } 132 } 133 | Popular Tags |