1 16 package org.apache.juddi.datastore.jdbc; 17 18 import java.sql.Connection ; 19 20 import org.apache.juddi.datatype.binding.AccessPoint; 21 import org.apache.juddi.datatype.binding.BindingTemplate; 22 import org.apache.juddi.datatype.business.BusinessEntity; 23 import org.apache.juddi.datatype.service.BusinessService; 24 import org.apache.juddi.util.Config; 25 import org.apache.juddi.util.jdbc.Transaction; 26 import org.apache.juddi.uuidgen.UUIDGen; 27 import org.apache.juddi.uuidgen.UUIDGenFactory; 28 29 32 class TestBindingTemplateTable 33 { 34 public static void main(String [] args) 35 throws Exception 36 { 37 Config.setStringProperty("juddi.useConnectionPool","true"); 40 41 Connection conn = null; 42 try { 43 conn = Database.aquireConnection(); 44 test(conn); 45 } 46 finally { 47 if (conn != null) 48 conn.close(); 49 } 50 } 51 52 public static void test(Connection connection) 53 throws Exception 54 { 55 Transaction txn = new Transaction(); 56 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 57 58 if (connection != null) 59 { 60 try 61 { 62 String businessKey = uuidgen.uuidgen(); 63 BusinessEntity business = new BusinessEntity(); 64 business.setBusinessKey(businessKey); 65 business.setAuthorizedName("sviens"); 66 business.setOperator("WebServiceRegistry.com"); 67 68 String serviceKey = uuidgen.uuidgen(); 69 BusinessService service = new BusinessService(); 70 service.setBusinessKey(businessKey); 71 service.setServiceKey(serviceKey); 72 73 String bindingKey = uuidgen.uuidgen(); 74 BindingTemplate binding = new BindingTemplate(); 75 binding.setServiceKey(serviceKey); 76 binding.setBindingKey(bindingKey); 77 binding.setAccessPoint(new AccessPoint("http","http://juddi.org/bindingtemplate.html")); 78 79 String authorizedUserID = "sviens"; 80 81 txn.begin(connection); 83 84 BusinessEntityTable.insert(business,authorizedUserID,connection); 86 87 BusinessServiceTable.insert(service,connection); 89 90 BindingTemplateTable.insert(binding,connection); 92 93 binding.setBindingKey(uuidgen.uuidgen()); 95 BindingTemplateTable.insert(binding,connection); 96 97 binding.setBindingKey(uuidgen.uuidgen()); 99 BindingTemplateTable.insert(binding,connection); 100 101 binding = BindingTemplateTable.select(bindingKey,connection); 103 104 BindingTemplateTable.delete(bindingKey,connection); 106 107 binding = BindingTemplateTable.select(bindingKey,connection); 109 110 BindingTemplateTable.selectByServiceKey(serviceKey,connection); 112 113 BindingTemplateTable.deleteByServiceKey(serviceKey,connection); 115 116 BindingTemplateTable.selectByServiceKey(serviceKey,connection); 118 119 txn.commit(); 121 } 122 catch(Exception ex) 123 { 124 try { txn.rollback(); } 125 catch(java.sql.SQLException sqlex) { sqlex.printStackTrace(); } 126 throw ex; 127 } 128 } 129 } 130 } | Popular Tags |