1 26 27 package org.objectweb.openccm.pss.demo1; 28 29 36 public class FormImpl 37 extends FormPOA 38 { 39 45 46 org.omg.CosPersistentState.Session _session; 47 48 49 SH_Person _person_home; 50 51 52 SH_Address _address_home; 53 54 60 65 public FormImpl(org.omg.CosPersistentState.Session session) 66 { 67 _session = session; 68 try 69 { 70 _person_home = (SH_Person) 71 _session.find_storage_home("PSDL:openccm.objectweb.org/pss/demo1/SH_Person:1.0"); 72 }catch(org.omg.CosPersistentState.NotFound e){ 73 e.printStackTrace(); 74 } 75 try 76 { 77 _address_home = (SH_Address) 78 _session.find_storage_home("PSDL:openccm.objectweb.org/pss/demo1/SH_Address:1.0"); 79 }catch(org.omg.CosPersistentState.NotFound e){ 80 e.printStackTrace(); 81 } 82 } 83 84 90 96 99 public void 100 createPerson( String first_name, 101 String last_name, 102 int age, 103 String address_line1, 104 String address_line2, 105 String address_city, 106 String address_zip) 107 { 108 Address a = null; 109 Person p = null; 110 111 try{ 112 a = _address_home._create( address_line1, address_line2, address_city, address_zip ); 113 114 p = _person_home.my_create( first_name, last_name ); 115 }catch( Exception e ){ 116 e.printStackTrace(); 117 } 118 119 try{ 120 org.omg.CosPersistentState.CatalogBase cat = null; 121 122 cat = p.get_storage_home().get_catalog(); 124 125 p.age(age); 127 p.adress( a.get_pid() ); 128 cat.flush(); 129 }catch(Exception e){ 130 e.printStackTrace(); 131 } 132 } 133 134 137 public void removePerson( java.lang.String first_name, 138 java.lang.String last_name ) 139 { 140 Person p = null; 141 Address adr = null; 142 143 try 144 { 145 p = _person_home.find_by_mykey( first_name, last_name ); 146 adr = p.adress(); 147 148 if ( adr != null ) 149 { 150 adr.destroy_object(); 151 } 152 p.destroy_object(); 153 } 154 catch ( org.omg.CosPersistentState.NotFound ex ) 155 { 156 System.out.println( "This person was not found..." ); 157 } 158 catch( Exception e ) 159 { 160 e.printStackTrace(); 161 } 162 } 163 164 167 public String showPerson( java.lang.String first_name, 168 java.lang.String last_name ) 169 { 170 try 171 { 172 Person p = _person_home.find_by_mykey( first_name, last_name ); 173 174 return p.print(); 175 } 176 catch ( org.omg.CosPersistentState.NotFound ex ) 177 { 178 return "This person was not found...\n"; 179 } 180 catch( Exception e ) 181 { 182 e.printStackTrace(); 183 } 184 return null; 185 } 186 } 187 | Popular Tags |