Exercise 3.5: Modeling the framework component layer

In this exercise, you model the framework layer of the itso.ad.business package. The framework component layer separates the client interface from both the persistent application data and the implementation of the application. The framework component layer contains the transfer object and delegate interfaces, as well as the delegate factory classes and exceptions.

The framework component layer contains the design subpackages in the following table:

Package Description
exception This subpackage contains the ServiceException and DataAccessException exception classes that provide error recovery for the PiggyBank online banking system.
factory This subpackage contains the BusinessDelegateFactory class that is used to dynamically create a business delegate.
interfaces.delegates This subpackage contains the interfaces for the business delagate.
interfaces.to This subpackage contains the interfaces for the transfer objects.

Modeling the transfer object interfaces

Transfer objects are used as return types for remote procedure calls. The PiggyBank transfer objects transport customer and account information between layers in the PiggyBank design. This exercise models the transfer object interfaces.

To model the ICustomerTO interface:
  1. In the Model Explorer view, and expand Enterprise IT Design Model, expand PiggyBank Implementation Designs.
  2. In the itso.ad.business subpackage, right-click the framework package; then click Add UML > Package
  3. Name the new package interfaces.to.
  4. In the Model Explorer view, double-click the Main diagram and add the title interfaces.to - Transfer Object Interfaces.
  5. In the Palette, double-click Interface and name the interface ICustomerTO.
  6. In the diagram editor, right-click the ICustomerTO class; then click Add UML > Operation.
  7. Name the operation getId.
  8. In the Properties view, on the General page, click Set return type.
  9. In the Select Element window, click String.
  10. In the diagram editor, right-click the ICustomerTO class; then click Add UML > Operation.
  11. Name the operation getName.
  12. In the Properties view, on the General page, click Set return type.
  13. In the Select Element window, click String.

To model the IAccountTO interface:
  1. In the Palette, double-click Interface and name the interface IAccountTO.
  2. In the diagram editor, right-click the IAccountTO class; then click Add UML > Operation.
  3. Name the operation getBalance.
  4. In the Properties view, on the General page, click Set return type.
  5. In the Select Element window, click Integer.
  6. In the diagram editor, right-click the IAccountTO class; then click Add UML > Operation.
  7. Name the operation getNumber.
  8. In the Properties view, on the General page, click Set return type.
  9. In the Select Element window, click String.

You have modeled the transfer object interfaces. Your diagram should look similar to the following figure:

The transfer object interfaces diagram.

Modeling the delegate interfaces

The business delegate interface definitions describe the business delegate methods and factory components that are used to generate a business delegate implementation instance. The IPiggyBankBusinessDelegate interface defines an interface to the PiggyBank business logic. The AbstractBusinessDelegateFactory class instantiates IPiggyBankBusinessDelegate instances.

To model the IPiggyBankBusinessDelegate interface:
  1. In the Model Explorer view, expand Enterprise IT Design Model and expand PiggyBank Implementation Designs.
  2. In the itso.ad.business subpackage, right-click the framework package; then click Add UML > Package.
  3. Name the new package interfaces.delegates.
  4. In the Model Explorer view, double-click the Main diagram and add the title interfaces.delegates - Delegate Interfaces.
  5. In the Palette, double-click Interface and name the interface IPiggyBankBusinessDelegate.

To model the cashCheck operation:
  1. In the diagram editor, right-click the IPiggyBankBusinessDelegate class; then click Add UML > Operation.
  2. Name the operation cashCheck ( accountToCredit, checkAmount, checkReference ).
  3. In the Properties view, on the Parameters page, click the Type field for the accountToCredit parameter and change the parameter type to String.
  4. Click the Type field for the checkAmount parameter and change the parameter type to Integer.
  5. Click the Type field for the checkReference parameter and change the parameter type to String.

To model the getAccountByCustomer operation:
  1. In the diagram editor, right-click the IPiggyBankBusinessDelegate class; then click Add UML > Operation.
  2. Name the operation getAccountByCustomer ( customer ).
  3. In the Properties view, on the Advanced page, beside Multiplicity, click the down arrow beside 1..-1, and click 1..*.
  4. On the General page, select the Ordered check box, clear the Unique check box and click Set return type.
  5. In the Select Element window, expand itso.ad.business, expand framework and, in the interfaces.to package, click IAccountTO.

To model the getBalance operation:
  1. In the diagram editor, right-click the IPiggyBankBusinessDelegate class; then click Add UML > Operation.
  2. Name the operation getBalance ( accountNumber, customer ).
  3. In the Properties view, on the Parameters page, click the Type field for the accountNumber parameter and change the parameter type to String.
  4. Click the Type field for the customer parameter and change the parameter type to ICustomerTO.
  5. In the Properties view, on the General page, click Set return type.
  6. In the Select Element window, click Integer.

To model the getCustomerById operation:
  1. In the diagram editor, right-click the IPiggyBankBusinessDelegate class; then click Add UML > Operation.
  2. Name the operation getCustomerById ( customerId ).
  3. In the Properties view, on the Parameters page, click the Type field for the customerId parameter and change the parameter type to String.
  4. In the Properties view, on the General page, click Set return type.
  5. In the Select Element window, expand itso.ad.business, expand framework and, in the interfaces.to package, click ICustomerTO.

To model the transfer operation:
  1. In the diagram editor, right-click the IPiggyBankBusinessDelegate class; then click Add UML > Operation.
  2. Name the operation transfer ( amountToTransfer, creditAccount, customer, debitAccount ).
  3. In the Properties view, on the Parameters page, click the Type field for the amountToTransfer parameter and change the parameter type to Integer.
  4. Click the Type field for the creditAccount parameter and change the parameter type to String.
  5. Click the Type field for the customer parameter and change the parameter type to ICustomerTO.
  6. Click the Type field for the debitAccount parameter and change the parameter type to String.
  7. In the Properties view, on the General page, click Set return type.
  8. In the Select Element window, click Boolean.

To model the AbstractBusinessDelegateFactory interface:
  1. In the Palette, double-click Interface and name the interface AbstractBusinessDelegateFactory.
  2. In the diagram editor, right-click the AbstractBusinessDelegateFactory class; then click Add UML > Operation.
  3. Name the operation createPiggyBankBusinessDelegate.
  4. In the Properties view, on the General page, click Set return type.
  5. In the Select Element window, expand itso.ad.business, expand framework and, in the interfaces.delegates package, click IPiggyBankBusinessDelegate and click OK.

You have modeled the delegate interfaces. Note that the getAccountsByCustomer and getCustomerById operations return the transfer object interfaces that you created in the previous exercise. Your diagrams should look similar to the following figure:

The business delegate interfaces diagram.

Modeling the business delegate factory

The BusinessDelegateFactory class is used to dynamically create a delegate factory instance.

To model the BusinessDelegateFactoryClass interface:
  1. In the Model Explorer view, expand Enterprise IT Design Model and expand PiggyBank Implementation Designs.
  2. In the itso.ad.business subpackage, right-click the framework package; then click Add UML > Package.
  3. Name the new package factory.
  4. In the Model Explorer, double-click the Main diagram and add the title factory - Business Delegate Factory abstract implementation.
  5. In the Palette, double-click Class and name the class BusinessDelegateFactory.
  6. In the Properties view, on the General page, select the Abstract check box.

To model the delegateFactory attribute:
  1. In the diagram editor, right-click the BusinessDelegateFactory class; then click Add UML > Attribute.
  2. Name the attribute delegateFactory.
  3. In the Properties view, on the General page, click Select type.
  4. In the Select Element window, expand itso.ad.business, expand framework, and in the interfaces.delegates package, click AbstractBusinessDelegateFactory.
  5. In the Properties view, on the General page, click Static.

To model the getInstance operation:
  1. In the diagram editor, right-click the BusinessDelegateFactory class; then click Add UML > Operation.
  2. Name the operation getInstance.
  3. In the Select Element window, expand itso.ad.business, expand framework and, in the interfaces.delegates package, click AbstractBusinessDelegateFactory.
  4. In the Properties view, on the General page, click Static.

To model the init operation:
  1. In the diagram editor, right-click the BusinessDelegateFactory class; then click Add UML > Operation.
  2. Name the operation init ( factoryClassName ).
  3. In the Properties view, on the Parameters page, click the Type field for the factoryClassName parameter and change the parameter type to String.
  4. In the Properties view, on the General page, click Static.
  5. In the Model Explorer view, in the interfaces.delegate subpackage, click the AbstractBusinessDelegateFactory interface and drag it into the diagram.
  6. In the Palette, click Implements.
  7. In the diagram editor, click the BusinessDelegateFactory class and drag it to the AbstractBusinessDelegateFactory class.

You have modeled the itso.ad.business layer factory classes. Your diagram should look similar to the following figure:

The business delagate factory abstract implementation.

Modeling the itso.ad.business framework exceptions

The framework component layer contains the implementation of two exceptions: DataAccessException, which is thrown whenever an error occurs in the business layer, and ServiceException, which occurs because of a loss of service.

To model the DataAccessException and ServiceException classes:
  1. In the Model Explorer view, expand Enterprise IT Design Model and expand PiggyBank Implementation Designs.
  2. In the itso.ad.business subpackage, right-click the framework package; then click Add UML > Package.
  3. Name the new package exception.
  4. In the Model Explorer view, double-click the Main diagram and add the title exception.
  5. In the Palette, double-click Class and name the class DataAccessException.
  6. In the Palette, double-click Class and name the class ServiceException.

You have modeled the itso.ad.business framework component layer. The framework layer is an isolation layer that hides the PiggyBank client interface from the PiggyBank implementation. You can now complete the itso.ad.business design elements diagram by dragging the factory package into the diagram. Connect the delegate.ejb package to the factory package with a usage relationship. Connect the factory package to the framework package with an association relationship. Your diagram should look similar to the following figure:

The itso.ad.business design elements package diagram.

To continue, proceed to Exercise 3.6: Modeling the EJB component subpackage .

Terms of use | Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.