E N D
Chapter 21 Application Servers Outline21.1 Introduction21.2 J2EE Specification and Benefits21.3 Commercial Application Servers21.3.1 BEA WebLogic 6.021.3.2 iPlanet Application Server 6.021.3.3 IBM WebSphere Advanced Application Server 4.021.3.4 JBoss 2.2.2 Application Server21.4 Deploying the Deitel Bookstore on BEA WebLogic21.5 Deploying the Deitel Bookstore on IBM WebSphere21.6 Internet and World Wide Web Resources
21.1 Introduction • Java 2 Enterprise Edition • BEA WebLogic • IBM WebSphere • iPlanet Application Server • JBoss open-source application server
21.2 J2EE Specification and Benefits • Java 2 Enterprise Edition • Portable application-server platform • J2EE specification • API support • Security • Transaction management • Deployment processes
21.3 Commercial Application Servers • Popular application servers • BEA WebLogic • iPlanet Application Server • IBM WebSphere • JBoss
21.3.1 BEA WebLogic 6.0 • WebLogic features • Data pools • Hot deployment • Failover support • Multi-pooling • Advanced security
21.3.2 iPlanet Application Server 6.0 • iPlanet features • Web connector • Sticky load balancing • Lightweight Directory Access Protocol (LDAP) • Download • www.iplanet.com/ias_deitel
21.3.3 IBM WebSphere Advanced Application Server 4.0 • WebSphere features • Failover support • Data pooling • User-level security controls
21.3.4 JBoss 2.2.2 Application Server • JBoss features • Hot deployment • Small memory footprint
21.4 Deploying the Deitel Bookstore on BEA WebLogic • Installation • WebLogic • e-docs.bea.com/wls/docs60/install/instprg.html • Cloudscape • CLASSPATH • weblogic_sp.jar • weblogic.jar • cloudscape.jar • Administration console • localhost:7001/console
21.4 Deploying the Deitel Bookstore on BEA WebLogic (Cont.) Fig. 21.2 WebLogic administration console. (Courtesy BEA Systems.)
21.4 Deploying the Deitel Bookstore on BEA WebLogic (Cont.) • JDBC data pool and data source configuration Fig. 21.3 JDBC Connection pool properties. (Courtesy of BEA Systems, Inc.)
21.4 Deploying the Deitel Bookstore on BEA WebLogic (Cont.) • Deployment descriptors • bookstore.ear • jar xvf bookstore.ear
Elementejb-name specifies the name of this bean. Elementweblogic-ejb-jar contains deployment information for all EJBs in the EJB JAR. Elementweblogic-enterprise-bean contains deployment information for the Customer EJB. Elementmac-beans-in-cache defines the maximum number of active instances the container should allow. Elementcache-strategy sets how EJBs should cache data. Elementpersistence-descriptor defines the EJBs persistence properties. Elementpersistence-type contains the elements type-identifier, which must be WebLogic_CMP_RDBMS. Elementtype-storage specifies the location of the CMP descriptor. Contain the descriptions of caching properties Specify the DTD for the descriptor. 1 <?xml version = "1.0" encoding = "UTF-8"?> 2 3 <!-- weblogic-ejb-jar.xml deployment descriptor for bookstore --> 4 <!-- describes weblogic specific properties of each bean --> 5 6 <!DOCTYPE weblogic-ejb-jar PUBLIC 7 '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN' 8 'http://www.bea.com/servers/wls510/dtd/weblogic-ejb-jar.dtd'> 9 10 <!-- Customer EJB weblogic descriptor --> 11 <weblogic-ejb-jar> 12 13 <weblogic-enterprise-bean> 14 <ejb-name>Customer</ejb-name> 15 16 <!-- determines caching properties --> 17 <caching-descriptor> 18 <max-beans-in-cache>100</max-beans-in-cache> 19 <cache-strategy>Read-Write</cache-strategy> 20 <read-timeout-seconds>0</read-timeout-seconds> 21 </caching-descriptor> 22 23 <!-- maps cmp types for bean --> 24 <persistence-descriptor> 25 26 <persistence-type> 27 <type-identifier> 28 WebLogic_CMP_RDBMS 29 </type-identifier> 30 <type-version>5.1.0</type-version> 31 <type-storage> 32 META-INF/weblogic-cmp-rdbms-jar-Customer.xml 33 </type-storage> 34 </persistence-type> 35 Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.Lines 6-8Lines 11-356Lines 13-71Line 14Lines 17-21Line 18Line 19Lines 24-42Lines 26-34Lines 27-29Lines 31-33
Tell WebLogic to use the persistence given in the previous element. Elementreference-descriptor maps each reference to the current JNDI name. 36 <persistence-use> 37 <type-identifier> 38 WebLogic_CMP_RDBMS 39 </type-identifier> 40 <type-version>5.1.0</type-version> 41 </persistence-use> 42 </persistence-descriptor> 43 44 <!-- transaction paramaters --> 45 <transaction-descriptor> 46 <trans-timeout-seconds>200</trans-timeout-seconds> 47 </transaction-descriptor> 48 49 <!-- maps references to ejb names --> 50 <reference-descriptor> 51 <ejb-reference-description> 52 <ejb-ref-name>ejb/Order</ejb-ref-name> 53 <jndi-name>ejb/Order</jndi-name> 54 </ejb-reference-description> 55 56 <ejb-reference-description> 57 <ejb-ref-name>ejb/SequenceFactory</ejb-ref-name> 58 <jndi-name>ejb/SequenceFactory</jndi-name> 59 </ejb-reference-description> 60 61 <ejb-reference-description> 62 <ejb-ref-name>ejb/Address</ejb-ref-name> 63 <jndi-name>ejb/Address</jndi-name> 64 </ejb-reference-description> 65 66 </reference-descriptor> 67 68 <!-- assigns JNDI name to EJB --> 69 <jndi-name>ejb/Customer</jndi-name> 70 Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.Lines 36-41Lines 50-66
71 </weblogic-enterprise-bean> <!-- end customer descriptor --> 72 73 <!-- Sequence factory EJB weblogic descriptor --> 74 <weblogic-enterprise-bean> 75 76 <ejb-name>SequenceFactory</ejb-name> 77 78 <!-- manages beans caching behavior --> 79 <caching-descriptor> 80 <max-beans-in-cache>100</max-beans-in-cache> 81 <idle-timeout-seconds>20</idle-timeout-seconds> 82 <cache-strategy>Read-Write</cache-strategy> 83 <read-timeout-seconds>0</read-timeout-seconds> 84 </caching-descriptor> 85 86 <!-- map bean to CMP descriptor --> 87 <persistence-descriptor> 88 <persistence-type> 89 <type-identifier> 90 WebLogic_CMP_RDBMS 91 </type-identifier> 92 <type-version>5.1.0</type-version> 93 <type-storage> 94 META-INF/weblogic-cmp-rdbms-jar-Sequence.xml 95 </type-storage> 96 </persistence-type> 97 98 <persistence-use> 99 <type-identifier> 100 WebLogic_CMP_RDBMS 101 </type-identifier> 102 <type-version>5.1.0</type-version> 103 </persistence-use> 104 </persistence-descriptor> 105 Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.
106 <!-- transaction management properties --> 107 <transaction-descriptor> 108 <trans-timeout-seconds>200</trans-timeout-seconds> 109 </transaction-descriptor> 110 111 <!-- assigns JNDI name to bean --> 112 <jndi-name>ejb/SequenceFactory</jndi-name> 113 114 </weblogic-enterprise-bean> 115 <!-- end SequenceFactory descriptor --> 116 117 <!-- Order EJB weblogic descriptor --> 118 <weblogic-enterprise-bean> 119 <ejb-name>Order</ejb-name> 120 121 <!-- defines caching properties, set to defaults --> 122 <caching-descriptor> 123 <max-beans-in-cache>100</max-beans-in-cache> 124 <idle-timeout-seconds>20</idle-timeout-seconds> 125 <cache-strategy>Read-Write</cache-strategy> 126 <read-timeout-seconds>0</read-timeout-seconds> 127 </caching-descriptor> 128 129 <!-- maps bean to specific CMP descriptor --> 130 <persistence-descriptor> 131 <persistence-type> 132 <type-identifier> 133 WebLogic_CMP_RDBMS 134 </type-identifier> 135 <type-version>5.1.0</type-version> 136 <type-storage> 137 META-INF/weblogic-cmp-rdbms-jar-order.xml 138 </type-storage> 139 </persistence-type> 140 Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.
141 <persistence-use> 142 <type-identifier> 143 WebLogic_CMP_RDBMS 144 </type-identifier> 145 <type-version>5.1.0</type-version> 146 </persistence-use> 147 </persistence-descriptor> 148 149 <!-- defines transaction attributes --> 150 <transaction-descriptor> 151 <trans-timeout-seconds>200</trans-timeout-seconds> 152 </transaction-descriptor> 153 154 <!-- maps bean references to JNDI names --> 155 <reference-descriptor> 156 <ejb-reference-description> 157 <ejb-ref-name>ejb/SequenceFactory</ejb-ref-name> 158 <jndi-name>ejb/SequenceFactory</jndi-name> 159 </ejb-reference-description> 160 161 162 <ejb-reference-description> 163 <ejb-ref-name>ejb/OrderProduct</ejb-ref-name> 164 <jndi-name>ejb/OrderProduct</jndi-name> 165 </ejb-reference-description> 166 167 <ejb-reference-description> 168 <ejb-ref-name>ejb/Customer</ejb-ref-name> 169 <jndi-name>ejb/Customer</jndi-name> 170 </ejb-reference-description> 171 172 </reference-descriptor> 173 <jndi-name>ejb/Order</jndi-name> 174 175 </weblogic-enterprise-bean> <!-- end Order descriptor --> Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.
176 177 <!-- Address EJB weblogic deployment descriptor --> 178 <weblogic-enterprise-bean> 179 <ejb-name>Address</ejb-name> 180 181 <!-- defines caching properties for bean --> 182 <caching-descriptor> 183 <max-beans-in-cache>100</max-beans-in-cache> 184 <idle-timeout-seconds>20</idle-timeout-seconds> 185 <cache-strategy>Read-Write</cache-strategy> 186 <read-timeout-seconds>0</read-timeout-seconds> 187 </caching-descriptor> 188 189 <!-- maps EJB to specific cmp descriptor --> 190 <persistence-descriptor> 191 <persistence-type> 192 <type-identifier> 193 WebLogic_CMP_RDBMS 194 </type-identifier> 195 <type-version>5.1.0</type-version> 196 <type-storage> 197 META-INF/weblogic-cmp-rdbms-jar-address.xml 198 </type-storage> 199 </persistence-type> 200 201 <persistence-use> 202 <type-identifier> 203 WebLogic_CMP_RDBMS 204 </type-identifier> 205 <type-version>5.1.0</type-version> 206 </persistence-use> 207 </persistence-descriptor> 208 Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.
209 <!-- defines transaction properties --> 210 <transaction-descriptor> 211 <trans-timeout-seconds>200</trans-timeout-seconds> 212 </transaction-descriptor> 213 214 <!-- maps referenced to JNDI names of beans --> 215 <reference-descriptor> 216 <ejb-reference-description> 217 <ejb-ref-name>ejb/SequenceFactory</ejb-ref-name> 218 <jndi-name>ejb/SequenceFactory</jndi-name> 219 </ejb-reference-description> 220 </reference-descriptor> 221 222 <!-- assigns JNDI name to this bean --> 223 <jndi-name>ejb/Address</jndi-name> 224 225 </weblogic-enterprise-bean> <!-- end Address descriptor --> 226 227 <!-- OrderProduct EJB weblogic deployment descriptor --> 228 <weblogic-enterprise-bean> 229 <ejb-name>OrderProduct</ejb-name> 230 231 <!-- sets default caching properties --> 232 <caching-descriptor> 233 <max-beans-in-cache>100</max-beans-in-cache> 234 <idle-timeout-seconds>20</idle-timeout-seconds> 235 <cache-strategy>Read-Write</cache-strategy> 236 <read-timeout-seconds>0</read-timeout-seconds> 237 </caching-descriptor> 238 Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.
239 <!-- maps this bean to specific cmp descriptor --> 240 <persistence-descriptor> 241 <persistence-type> 242 <type-identifier> 243 WebLogic_CMP_RDBMS 244 </type-identifier> 245 <type-version>5.1.0</type-version> 246 <type-storage> 247 META-INF/weblogic-cmp-rdbms-jar-orderProduct.xml 248 </type-storage> 249 </persistence-type> 250 251 <persistence-use> 252 <type-identifier> 253 WebLogic_CMP_RDBMS 254 </type-identifier> 255 <type-version>5.1.0</type-version> 256 </persistence-use> 257 </persistence-descriptor> 258 259 <!-- maps references to JNDI names of beans --> 260 <reference-descriptor> 261 <ejb-reference-description> 262 <ejb-ref-name>ejb/Product</ejb-ref-name> 263 <jndi-name>ejb/Product</jndi-name> 264 </ejb-reference-description> 265 </reference-descriptor> 266 267 <!-- assigns JNDI name of this bean --> 268 <jndi-name>ejb/OrderProduct</jndi-name> 269 270 </weblogic-enterprise-bean> 271 <!-- end OrderProduct Descriptor --> 272 Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.
273 <!-- Product EJB weblogic deployment descriptor --> 274 <weblogic-enterprise-bean> 275 <ejb-name>Product</ejb-name> 276 277 <!-- defines caching properties for EJB --> 278 <caching-descriptor> 279 <idle-timeout-seconds>20</idle-timeout-seconds> 280 <cache-strategy>Read-Write</cache-strategy> 281 <read-timeout-seconds>0</read-timeout-seconds> 282 </caching-descriptor> 283 284 <!-- maps this bean to its CMP descriptor --> 285 <persistence-descriptor> 286 <persistence-type> 287 <type-identifier> 288 WebLogic_CMP_RDBMS 289 </type-identifier> 290 <type-version>5.1.0</type-version> 291 <type-storage> 292 META-INF/weblogic-cmp-rdbms-jar-product.xml 293 </type-storage> 294 </persistence-type> 295 296 <persistence-use> 297 <type-identifier> 298 WebLogic_CMP_RDBMS 299 </type-identifier> 300 <type-version>5.1.0</type-version> 301 </persistence-use> 302 </persistence-descriptor> 303 Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.
Stateful session EJB ShoppingCart requires slightly different deployment information. 304 <!-- defines transaction properties --> 305 <transaction-descriptor> 306 <trans-timeout-seconds>200</trans-timeout-seconds> 307 </transaction-descriptor> 308 309 <!-- assigns JNDI name --> 310 <jndi-name>ejb/Product</jndi-name> 311 312 </weblogic-enterprise-bean> <!-- end Product descriptor --> 313 314 <!-- ShoppingCart EJB weblogic deployment descriptor --> 315 <weblogic-enterprise-bean> 316 <ejb-name>ShoppingCart</ejb-name> 317 318 <!-- defines chaching properties, set to defaults --> 319 <caching-descriptor> 320 <max-beans-in-cache>100</max-beans-in-cache> 321 <idle-timeout-seconds>20</idle-timeout-seconds> 322 <cache-strategy>Read-Write</cache-strategy> 323 <read-timeout-seconds>0</read-timeout-seconds> 324 </caching-descriptor> 325 326 <!-- assigns a store directory for bean --> 327 <persistence-descriptor> 328 <stateful-session-persistent-store-dir> 329 /config/deitel/ 330 </stateful-session-persistent-store-dir> 331 </persistence-descriptor> 332 333 <!-- defines transaction attributes --> 334 <transaction-descriptor> 335 <trans-timeout-seconds>200</trans-timeout-seconds> 336 </transaction-descriptor> 337 Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.Lines 315-354
338 <!-- maps EJB references to JNDI names --> 339 <reference-descriptor> 340 341 <ejb-reference-description> 342 <ejb-ref-name>ejb/Product</ejb-ref-name> 343 <jndi-name>ejb/Product</jndi-name> 344 </ejb-reference-description> 345 346 <ejb-reference-description> 347 <ejb-ref-name>ejb/Order</ejb-ref-name> 348 <jndi-name>ejb/Order</jndi-name> 349 </ejb-reference-description> 350 351 </reference-descriptor> 352 <jndi-name>ejb/ShoppingCart</jndi-name> 353 354 </weblogic-enterprise-bean> <!-- end ShoppingCart descriptor --> 355 356 </weblogic-ejb-jar> <!-- end weblogic descriptor --> Fig. 21.4 Weblogic-ejb-jar.xml defines WebLogic deployment properties for Bookstore case study.
21.4 Deploying the Deitel Bookstore on BEA WebLogic (Cont.) Fig. 21.5 (Part 1 of 3) Optional tags for weblogic-ejb-jar.xml not used in text
21.4 Deploying the Deitel Bookstore on BEA WebLogic (Cont.) Fig. 21.5 (Part 2 of 3) Optional tags for weblogic-ejb-jar.xml not used in text
Elementpool-name must contain the name for a data pool already defined in WebLogic. EJB Address writes to table Address. Elementweblogic-rdbms-bean is the base element for the descriptor. Elementobject-link contains the mappings between the EJB fields and database fields for zipCode. 1 <?xml version = "1.0" encoding = "UTF-8" ?> 2 3 <!-- weblogic-cmp-rdbms-jar-address.xml rdbms deployment --> 4 <!-- descriptor for EJB Address. Defines database properties --> 5 6 <!DOCTYPE weblogic-rdbms-bean PUBLIC 7 '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB RDBMS Persistence//EN' 8 'http://www.bea.com/servers/wls510/dtd/weblogic-rdbms- persistence.dtd'> 9 10 <!-- main block for rdbms descriptor --> 11 <weblogic-rdbms-bean> 12 13 <!-- Sets data pool to BookstorePool --> 14 <pool-name>BookstorePool</pool-name> 15 16 <!-- Sets database table to ADDRESS --> 17 <table-name>Address</table-name> 18 19 <!-- maps EJB fields to database fields --> 20 <attribute-map> 21 <object-link> 22 <bean-field>zipCode</bean-field> 23 <dbms-column>zipCode</dbms-column> 24 </object-link> 25 26 <object-link> 27 <bean-field>state</bean-field> 28 <dbms-column>state</dbms-column> 29 </object-link> 30 31 <object-link> 32 <bean-field>addressID</bean-field> 33 <dbms-column>addressID</dbms-column> Fig. 21.6 Weblogic-cmp-rdbms-jar-address.xml defines WebLogic CMP database properties for EJB Address.Line 11Line 14Line 17Lines 21-24
34 </object-link> 35 36 <object-link> 37 <bean-field>streetAddressLine2</bean-field> 38 <dbms-column>streetAddressLine2</dbms-column> 39 </object-link> 40 41 <object-link> 42 <bean-field>country</bean-field> 43 <dbms-column>country</dbms-column> 44 </object-link> 45 46 <object-link> 47 <bean-field>streetAddressLine1</bean-field> 48 <dbms-column>streetAddressLine1</dbms-column> 49 </object-link> 50 51 <object-link> 52 <bean-field>city</bean-field> 53 <dbms-column>city</dbms-column> 54 </object-link> 55 56 <object-link> 57 <bean-field>firstName</bean-field> 58 <dbms-column>firstName</dbms-column> 59 </object-link> 60 61 <object-link> 62 <bean-field>lastName</bean-field> 63 <dbms-column>lastName</dbms-column> 64 </object-link> 65 66 <object-link> 67 <bean-field>phoneNumber</bean-field> 68 <dbms-column>phoneNumber</dbms-column> Fig. 21.6 Weblogic-cmp-rdbms-jar-address.xml defines WebLogic CMP database properties for EJB Address.
69 </object-link> 70 </attribute-map> 71 72 <options> 73 <use-quoted-names>false</use-quoted-names> 74 </options> 75 76 </weblogic-rdbms-bean> <!-- end Address RDBMS descriptor --> Fig. 21.6 Weblogic-cmp-rdbms-jar-address.xml defines WebLogic CMP database properties for EJB Address.
1 <?xml version = "1.0" encoding = "UTF-8"?> 2 3 <!-- weblogic-cmp-rdbms-jar-Customer.xml ejb descriptor for --> 4 <!-- CustomerEJB defines rdbms properties for WebLogic --> 5 6 <!DOCTYPE weblogic-rdbms-bean PUBLIC 7 '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB RDBMS Persistence//EN' 8 'http://www.bea.com/servers/wls510/dtd/weblogic-rdbms-persistence.dtd'> 9 10 <!-- element containing rdbms properties for Customer EJB --> 11 <weblogic-rdbms-bean> 12 13 <!-- assigns this bean to pool named BookstorePool --> 14 <pool-name>BookstorePool</pool-name> 15 16 <!-- assigns this bean to table named CUSTOMER --> 17 <table-name>Customer</table-name> 18 19 <!-- element containing field mappings --> 20 <attribute-map> 21 22 <!-- field mapping for customerID --> 23 <object-link> 24 <bean-field>customerID</bean-field> 25 <dbms-column>customerID</dbms-column> 26 </object-link> 27 28 <!-- field mapping for creditCardExpirationDate --> 29 <object-link> 30 <bean-field>creditCardExpirationDate</bean-field> 31 <dbms-column>creditCardExpirationDate</dbms-column> 32 </object-link> 33 Fig. 21.7 WebLogic-cmp-rdbm-jar-Customer.xml defines WebLogic CMP database properties for EJB CustomerEJB.
34 <!-- field mapping for shippingAddressID --> 35 <object-link> 36 <bean-field>shippingAddressID</bean-field> 37 <dbms-column>shippingAddressID</dbms-column> 38 </object-link> 39 40 <!-- field mapping for billingAddressID --> 41 <object-link> 42 <bean-field>billingAddressID</bean-field> 43 <dbms-column>billingAddressID</dbms-column> 44 </object-link> 45 46 <!-- field mapping for passwordHint --> 47 <object-link> 48 <bean-field>passwordHint</bean-field> 49 <dbms-column>passwordHint</dbms-column> 50 </object-link> 51 52 <!-- field mapping for creditCardName --> 53 <object-link> 54 <bean-field>creditCardName</bean-field> 55 <dbms-column>creditCardName</dbms-column> 56 </object-link> 57 58 <!-- field mapping for firstName --> 59 <object-link> 60 <bean-field>firstName</bean-field> 61 <dbms-column>firstName</dbms-column> 62 </object-link> 63 64 <!-- field mapping for password --> 65 <object-link> 66 <bean-field>password</bean-field> 67 <dbms-column>password</dbms-column> 68 </object-link> Fig. 21.7 WebLogic-cmp-rdbm-jar-Customer.xml defines WebLogic CMP database properties for EJB CustomerEJB.
Elementfinder-list contains finder methods for the customer EJB. Elementmethod-name is a string that matches a finder method defined in the home interface. Elementmethod-params contains element method-param, which specifies the fully qualified type of any passed parameters. 70 <!-- field mapping for lastName --> 71 <object-link> 72 <bean-field>lastName</bean-field> 73 <dbms-column>lastName</dbms-column> 74 </object-link> 75 76 <!-- field mapping for userID --> 77 <object-link> 78 <bean-field>userID</bean-field> 79 <dbms-column>userID</dbms-column> 80 </object-link> 81 82 <!-- field mapping for creditCardNumber --> 83 <object-link> 84 <bean-field>creditCardNumber</bean-field> 85 <dbms-column>creditCardNumber</dbms-column> 86 </object-link> 87 88 </attribute-map> 89 90 <!-- list of custom finders --> 91 <finder-list> 92 93 <!-- finder for findByUserID --> 94 <finder> 95 <method-name>findByUserID</method-name> 96 <method-params> 97 <method-param>java.lang.String</method-param> 98 </method-params> 99 100 <!-- get fields where userID matches argument string --> 101 <finder-query> 102 <![CDATA[( like userID $0 )]]> 103 </finder-query> 104 </finder> Fig. 21.7 WebLogic-cmp-rdbm-jar-Customer.xml defines WebLogic CMP database properties for EJB CustomerEJB.Lines 91-120Line 95Lines 96-98
Define findByLogin, which takes two arguments and returns only the fields that match both. 105 106 <!-- finder for findByLogin --> 107 <finder> 108 <method-name>findByLogin</method-name> 109 <method-params> 110 <method-param>java.lang.String</method-param> 111 <method-param>java.lang.String</method-param> 112 </method-params> 113 114 <!-- fields where userID and password match arguments --> 115 <finder-query> 116 <![CDATA[(& ( like userID $0 )( like password $1 ))]]> 117 </finder-query> 118 </finder> 119 120 </finder-list> 121 122 <!-- additional options --> 123 <options> 124 <use-quoted-names>false</use-quoted-names> 125 </options> 126 127 </weblogic-rdbms-bean> 128 <!-- end rdbms descriptor for CustomerEJB --> Fig. 21.7 WebLogic-cmp-rdbm-jar-Customer.xml defines WebLogic CMP database properties for EJB CustomerEJB.Lines 107-118
1 <?xml version = "1.0" encoding = "UTF-8"?> 2 3 <!-- weblogic-cmp-rdbms-jar-order.xml ejb descriptor for --> 4 <!-- OrderEJB defines rdbms properties for WebLogic --> 5 6 <!DOCTYPE weblogic-rdbms-bean PUBLIC 7 '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB RDBMS Persistence//EN' 8 'http://www.bea.com/servers/wls510/dtd/weblogic-rdbms- persistence.dtd'> 9 10 11 <!-- element containing rdbms properties for OrderEJB --> 12 <weblogic-rdbms-bean> 13 14 <!-- assigns this bean to pool named BookstorePool --> 15 <pool-name>BookstorePool</pool-name> 16 17 18 <!-- assigns this bean to table named CUSTOMERORDERS --> 19 <table-name>CustomerOrders</table-name> 20 21 <!-- element containing field mappings --> 22 <attribute-map> 23 24 25 <!-- field mapping for orderDate --> 26 <object-link> 27 <bean-field>orderDate</bean-field> 28 <dbms-column>orderDate</dbms-column> 29 </object-link> 30 31 32 <!-- field mapping for shipped --> 33 <object-link> Fig. 21.9 Weblogic-cmp-rdbms-jar-order.xml defines WebLogic CMP database properties for EJB OrderEJB.
34 <bean-field>shipped</bean-field> 35 <dbms-column>shipped</dbms-column> 36 </object-link> 37 38 39 <!-- field mapping for customerID --> 40 <object-link> 41 <bean-field>customerID</bean-field> 42 <dbms-column>customerID</dbms-column> 43 </object-link> 44 45 <!-- field mapping for orderID --> 46 <object-link> 47 <bean-field>orderID</bean-field> 48 <dbms-column>orderID</dbms-column> 49 </object-link> 50 51 </attribute-map> 52 53 <finder-list> 54 55 <!-- finder for findByCustomerID --> 56 <finder> 57 <method-name>findByCustomerID</method-name> 58 <method-params> 59 <method-param>java.lang.Integer</method-param> 60 </method-params> 61 62 <!-- return enumeration where customerID = argument --> 63 <finder-query> 64 <![CDATA[( = customerID $0 )]]> 65 </finder-query> 66 </finder> 67 68 </finder-list> Fig. 21.9 Weblogic-cmp-rdbms-jar-order.xml defines WebLogic CMP database properties for EJB OrderEJB.
69 70 <!-- additional options --> 71 <options> 72 <use-quoted-names>false</use-quoted-names> 73 </options> 74 75 </weblogic-rdbms-bean> 76 <!-- end rdbms descriptor for OrderEJB --> Fig. 21.9 Weblogic-cmp-rdbms-jar-order.xml defines WebLogic CMP database properties for EJB OrderEJB.
1 <?xml version = "1.0" encoding = "UTF-8"?> 2 3 <!-- weblogic-cmp-rdbms-jar-orderProduct.xml ejb descriptor for --> 4 <!-- OrderProductEJB defines rdbms properties for WebLogic --> 5 6 <!DOCTYPE weblogic-rdbms-bean PUBLIC 7 '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB RDBMS Persistence//EN' 8 'http://www.bea.com/servers/wls510/dtd/weblogic-rdbms- persistence.dtd'> 9 10 <!-- element containing rdbms properties for OrderProductsEJB --> 11 <weblogic-rdbms-bean> 12 13 <!-- assigns this bean to pool named BookstorePool --> 14 <pool-name>BookstorePool</pool-name> 15 16 <!-- assigns this bean to table named ORDERPRODUCT --> 17 <table-name>OrderProduct</table-name> 18 19 <!-- element containing field mappings --> 20 <attribute-map> 21 22 <!-- field mapping for quantity --> 23 <object-link> 24 <bean-field>quantity</bean-field> 25 <dbms-column>quantity</dbms-column> 26 </object-link> 27 28 <!-- field mapping for ISBN --> 29 <object-link> 30 <bean-field>ISBN</bean-field> 31 <dbms-column>ISBN</dbms-column> 32 </object-link> 33 Fig. 21.10 Weblogic-cmp-rdbms-jar-orderProduct.xml defines WebLogic CMP database properties for the OrderProduct EJB.
34 <!-- field mapping for orderID --> 35 <object-link> 36 <bean-field>orderID</bean-field> 37 <dbms-column>orderID</dbms-column> 38 </object-link> 39 40 </attribute-map> 41 42 43 <finder-list> 44 45 <!-- finder for findByOrderID --> 46 <finder> 47 <method-name>findByOrderID</method-name> 48 <method-params> 49 <method-param>java.lang.Integer</method-param> 50 </method-params> 51 52 <!-- select fields where orderID matches argument --> 53 <finder-query> 54 <![CDATA[( like orderID $0 )]]> 55 </finder-query> 56 </finder> 57 58 </finder-list> 59 60 <!-- additional options --> 61 <options> 62 <use-quoted-names>false</use-quoted-names> 63 </options> 64 65 </weblogic-rdbms-bean> <!-- end OrderProduct Descriptor --> Fig. 21.10 Weblogic-cmp-rdbms-jar-orderProduct.xml defines WebLogic CMP database properties for the OrderProduct EJB.
1 <?xml version = "1.0" encoding = "UTF-8"?> 2 3 <!-- weblogic-cmp-rdbms-jar-product.xml ejb descriptor for --> 4 <!-- ProductEJB defines rdbms properties for WebLogic --> 5 6 <!DOCTYPE weblogic-rdbms-bean PUBLIC 7 '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB RDBMS Persistence//EN' 8 'http://www.bea.com/servers/wls510/dtd/weblogic-rdbms- persistence.dtd'> 9 10 <!-- element containing rdbms properties for ProductEJB --> 11 <weblogic-rdbms-bean> 12 13 <!-- assigns this bean to pool named BookstorePool --> 14 <pool-name>BookstorePool</pool-name> 15 16 <!-- assigns this bean to table named PRODUCT --> 17 <table-name>Product</table-name> 18 19 <!-- element containing field mappings --> 20 <attribute-map> 21 22 <!-- field mapping for pages --> 23 <object-link> 24 <bean-field>pages</bean-field> 25 <dbms-column>pages</dbms-column> 26 </object-link> 27 28 <!-- field mapping for author --> 29 <object-link> 30 <bean-field>author</bean-field> 31 <dbms-column>author</dbms-column> 32 </object-link> 33 Fig. 21.11 Weblogic-cmp-rdbms-jar-product.xml defines WebLogic CMP database properties for the Product EJB.
34 <!-- field mapping for publisher --> 35 <object-link> 36 <bean-field>publisher</bean-field> 37 <dbms-column>publisher</dbms-column> 38 </object-link> 39 40 <!-- field mapping for price --> 41 <object-link> 42 <bean-field>price</bean-field> 43 <dbms-column>price</dbms-column> 44 </object-link> 45 46 <!-- field mapping for image --> 47 <object-link> 48 <bean-field>image</bean-field> 49 <dbms-column>image</dbms-column> 50 </object-link> 51 52 <!-- field mapping for ISBN --> 53 <object-link> 54 <bean-field>ISBN</bean-field> 55 <dbms-column>ISBN</dbms-column> 56 </object-link> 57 58 <!-- field mapping for title --> 59 <object-link> 60 <bean-field>title</bean-field> 61 <dbms-column>title</dbms-column> 62 </object-link> 63 64 </attribute-map> 65 66 <finder-list> 67 Fig. 21.11 Weblogic-cmp-rdbms-jar-product.xml defines WebLogic CMP database properties for the Product EJB.
68 <!-- finder for findAllProducts --> 69 <finder> 70 <method-name>findAllProducts</method-name> 71 72 <!-- select fields where ISBN is not null --> 73 <finder-query> 74 <![CDATA[( isNotNull ISBN )]]> 75 </finder-query> 76 </finder> 77 78 <!-- finder for findByTitle --> 79 <finder> 80 <method-name>findByTitle</method-name> 81 <method-params> 82 <method-param>java.lang.String</method-param> 83 </method-params> 84 85 <!-- select fields that title matches argument --> 86 <finder-query> 87 <![CDATA[( like title $0 )]]> 88 </finder-query> 89 </finder> 90 91 </finder-list> 92 93 94 <!-- additional options --> 95 <options> 96 <use-quoted-names>false</use-quoted-names> 97 </options> 98 99 </weblogic-rdbms-bean> <!-- end ProductEJB Descriptor --> Fig. 21.11 Weblogic-cmp-rdbms-jar-product.xml defines WebLogic CMP database properties for the Product EJB.
1 <?xml version = "1.0" encoding = "UTF-8"?> 2 3 <!-- weblogic-cmp-rdbms-jar-sequence.xml ejb descriptor for --> 4 <!-- SequenceFactory defines rdbms properties for WebLogic --> 5 6 <!DOCTYPE weblogic-rdbms-bean PUBLIC 7 '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB RDBMS Persistence//EN' 8 'http://www.bea.com/servers/wls510/dtd/weblogic-rdbms- persistence.dtd'> 9 10 <!-- element containing rdbms properties for SequenceFactoryEJB --> 11 <weblogic-rdbms-bean> 12 13 <!-- assigns this bean to pool named BookstorePool --> 14 <pool-name>BookstorePool</pool-name> 15 16 <!-- assigns this bean to table SEQUENCEFACTORY --> 17 <table-name>SequenceFactory</table-name> 18 19 <!-- element containing field mappings --> 20 <attribute-map> 21 22 <!-- field mapping for addressID --> 23 <object-link> 24 <bean-field>tableName</bean-field> 25 <dbms-column>tableName</dbms-column> 26 </object-link> 27 28 <!-- field mapping for primaryKey --> 29 <object-link> 30 <bean-field>nextID</bean-field> 31 <dbms-column>nextID</dbms-column> 32 </object-link> 33 Fig. 21.12 Weblogic-cmp-rdbms-jar-sequence.xml defines WebLogic CMP database properties for the SequenceFactory EJB.
34 </attribute-map> 35 36 <options> 37 <use-quoted-names>false</use-quoted-names> 38 </options> 39 40 </weblogic-rdbms-bean> Fig. 21.12 Weblogic-cmp-rdbms-jar-sequence.xml defines WebLogic CMP database properties for the SequenceFactory EJB.
Map the ShoppingCart EJB reference to its JNDI name. 1 <?xml version = "1.0" encoding = "UTF-8"?> 2 3 <!-- weblogic.xml Deployment descriptor for servlets --> 4 <!-- maps ejb references to JNDI names --> 5 6 <!DOCTYPE weblogic-web-app PUBLIC 7 "-//BEA Systems, Inc.//DTD Web Application 6.0//EN" 8 "http://www.bea.com/servers/wls600/dtd/weblogic-web-jar.dtd"> 9 10 <!-- main block for descriptor --> 11 <weblogic-web-app> 12 13 <!-- optional, provides description for war file. --> 14 <description> 15 Bookstore servlets 16 </description> 17 18 <!-- block contains ejb reference maps --> 19 <reference-descriptor> 20 21 <!-- individual reference map --> 22 <ejb-reference-description> 23 24 <!-- reference name defined in web.xml --> 25 <ejb-ref-name>ejb/ShoppingCart</ejb-ref-name> 26 27 <!-- JNDI name specified within weblogic-ejb-jar.xml --> 28 <jndi-name>ejb/ShoppingCart</jndi-name> 29 </ejb-reference-description> 30 31 <!-- individual reference map --> 32 <ejb-reference-description> 33 <ejb-ref-name>ejb/Product</ejb-ref-name> 34 <jndi-name>ejb/Product</jndi-name> 35 </ejb-reference-description> Fig. 21.13 Weblogic.xml Web application deployment descriptor.Lines 22-29
36 37 <!-- individual reference map --> 38 <ejb-reference-description> 39 <ejb-ref-name>ejb/Customer</ejb-ref-name> 40 <jndi-name>ejb/Customer</jndi-name> 41 </ejb-reference-description> 42 43 <!-- individual reference map --> 44 <ejb-reference-description> 45 <ejb-ref-name>ejb/Order</ejb-ref-name> 46 <jndi-name>ejb/Order</jndi-name> 47 </ejb-reference-description> 48 49 </reference-descriptor> 50 51 </weblogic-web-app> 52 <!-- end servlet descriptor --> Fig. 21.13 Weblogic.xml Web application deployment descriptor.
21.5 Deploying the Deitel Bookstore on IBM WebSphere • Installation • Cloudscape • WebSphere application server • IBM HTTP Server • XML parser and XSL transformer • xalan.jar and xerces.jar • Application server admin • Localhost:9090/admin • JDBC driver and data source configuration • Deployment descriptors
21.5 Deploying the Deitel Bookstore on IBM WebSphere (Cont.)