< Previous | Next >

Lesson 3.5: Create the framework component layer

In this lesson, 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.

About this task

The following table lists the design subpackages that the framework component layer contains:

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 delegate.
interfaces.to This subpackage contains the interfaces for the transfer objects.

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 lesson models the transfer object interfaces.

Create the ICustomerTO interface

Procedure

  1. In the Project 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.to.
  4. In the Project 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.

Create the IAccountTO interface

Procedure

  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.

Results

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

The transfer object interfaces.

Create the delegate interfaces

The business-delegate interface-definition classes describe the business-delegate methods and factory components that generate the business-delegate implementation. The IPiggyBankBusinessDelegate interface defines an interface to the PiggyBank business logic. The AbstractBusinessDelegateFactory class instantiates IPiggyBankBusinessDelegate instances.

Create the IPiggyBankBusinessDelegate interface

Procedure

  1. In the Project 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 Project 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.

Create the cashCheck operation

Procedure

  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, for the accountToCredit parameter, click the Type field and change the parameter type to String.
  4. For the checkAmount parameter, click the Type field and change the parameter type to Integer.
  5. For the checkReference parameter, click the Type field and change the parameter type to String.

Create the getAccountByCustomer operation

Procedure

  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 Parameters page, for the getAccountByCustomer parameter, beside Multiplicity, click the down arrow beside 1..-1, and click 1..*.
  4. On the General page, click Set return type.
  5. In the Select Element window, click the Browse tab, expand itso.ad.business, expand framework and, in the interfaces.to package, click IAccountTO.
  6. On the General page, select the Ordered check box, and clear the Unique check box.

Create the getBalance operation

Procedure

  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, for the accountNumber parameter, click the Type field and change the parameter type to String.
  4. For the customer parameter, click the Type field 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.

Create the getCustomerById operation

Procedure

  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, for the customerId parameter, click the Type field 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, click the Browse tab, expand Enterprise IT Design Model, expand PiggyBank Implementation Design, expand itso.ad.business, expand framework and, in the interfaces.to package, click ICustomerTO.

Create the transfer operation

Procedure

  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, for the amountToTransfer parameter, click the Type field and change the parameter type to Integer.
  4. For the creditAccount parameter, click the Type field and change the parameter type to String.
  5. For the customer parameter, click the Type field and change the parameter type to ICustomerTO.
  6. For the debitAccount parameter, click the Type field 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.

Create the AbstractBusinessDelegateFactory interface:

Procedure

  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, click the Browse tab, expand Enterprise IT Design Model, expand PiggyBank Implementation Design, expand itso.ad.business, expand framework and, in the interfaces.delegates package, click IPiggyBankBusinessDelegate, and click OK.

Results

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

The business delegate interfaces diagram.

Create the business-delegate factory

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

Create the BusinessDelegateFactoryClass interface

Procedure

  1. In the Project 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 Project Explorer view, 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. Click the BusinessDelegateFactory class.
  7. In the Properties view, on the General page, select the Abstract check box.

Create the delegateFactory attribute

Procedure

  1. In the diagram editor, right-click the BusinessDelegateFactory class; then click Add UML > Attribute.
  2. Name the attribute delegateFactory.
  3. Click the delegateFactory attribute.
  4. In the Properties view, on the General page, click Select type.
  5. In the Select Element window, click the Browse tab, expand Enterprise IT Design Model, expand PiggyBank Implementation Design, expand itso.ad.business, expand framework, and in the interfaces.delegates package, click AbstractBusinessDelegateFactory.
  6. In the Properties view, on the General page, click Static.

Create the getInstance operation

Procedure

  1. In the diagram editor, right-click the BusinessDelegateFactory class; then click Add UML > Operation.
  2. Name the operation getInstance.
  3. Click the getInstance operation.
  4. In the Properties view, on the General page, click Select type.
  5. In the Select Element window, click the Browse tab, expand Enterprise IT Design Model, expand PiggyBank Implementation Design, expand itso.ad.business, expand framework and, in the interfaces.delegates package, click AbstractBusinessDelegateFactory.
  6. In the Properties view, on the General page, click Static.

Create the init operation

Procedure

  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, for the factoryClassName parameter, click the Type field and change the parameter type to String.
  4. In the Properties view, on the General page, click Static.
  5. In the Project 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 the cursor to the AbstractBusinessDelegateFactory class.

Results

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

The BusinessDelegatefactory abstract imlpementation.

Create 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.

Create the DataAccessException and ServiceException classes

Procedure

  1. In the Project 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 Project 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.
  7. In the Project Explorer view, click and drag the factory and exception packages into the itso.ad.business Design Elements diagram.
  8. In the Palette, click the Usage relationship and click delegate.ejb package and drag the cursor to the ejb package.
  9. In the Palette, click the Association relationship and click factory package and drag the cursor to the framework package.

Results

You 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. Your diagram should look similar to the following figure:

The itso.ad.business framework component layer

< Previous | Next >

Feedback