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.Description; 22 import org.apache.juddi.datatype.binding.AccessPoint; 23 import org.apache.juddi.datatype.binding.BindingTemplate; 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 TestBindingDescTable 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(); 65 BusinessEntity business = new BusinessEntity(); 66 business.setBusinessKey(businessKey); 67 business.setAuthorizedName("sviens"); 68 business.setOperator("WebServiceRegistry.com"); 69 70 String serviceKey = uuidgen.uuidgen(); 72 BusinessService service = new BusinessService(); 73 service.setServiceKey(serviceKey); 74 service.setBusinessKey(businessKey); 75 76 String bindingKey = uuidgen.uuidgen(); 78 BindingTemplate binding = new BindingTemplate(); 79 binding.setAccessPoint( 80 new AccessPoint("http://www.juddi.org/binding.html", "http")); 81 binding.setHostingRedirector(null); 82 binding.setBindingKey(bindingKey); 83 binding.setServiceKey(serviceKey); 84 85 Vector descList = new Vector (); 86 descList.add(new Description("blah, blah, blah", "en")); 87 descList.add(new Description("Yadda, Yadda, Yadda", "it")); 88 descList.add(new Description("WhoobWhoobWhoobWhoob", "cy")); 89 descList.add(new Description("Haachachachacha", "km")); 90 91 String authorizedUserID = "sviens"; 92 93 txn.begin(connection); 95 96 BusinessEntityTable.insert(business, authorizedUserID, connection); 98 99 BusinessServiceTable.insert(service, connection); 101 102 BindingTemplateTable.insert(binding, connection); 104 105 BindingDescTable.insert(bindingKey, descList, connection); 107 108 descList = BindingDescTable.select(bindingKey, connection); 110 111 BindingDescTable.delete(bindingKey, connection); 113 114 descList = BindingDescTable.select(bindingKey, connection); 116 117 txn.commit(); 119 } 120 catch (Exception ex) 121 { 122 try 123 { 124 txn.rollback(); 125 } 126 catch (java.sql.SQLException sqlex) 127 { 128 sqlex.printStackTrace(); 129 } 130 throw ex; 131 } 132 } 133 } 134 } 135 | Popular Tags |