4.4.2.2.3: Extending the User Profile enterprise bean and importing legacy databases
IBM WebSphere Application Server implements user profile support as an
entity bean. Although you can extend the base user profile by adding columns to
it, you can also extend the user profile enterprise bean itself as an
alternative customization approach.
Extending the User Profile enterprise bean
is more involved than extending the base user profile.
You should be familiar with the concepts that underlie enterprise beans
(Java components written to the EJB specification). For detailed information regarding
enterprise beans and their implementation in IBM WebSphere Application Server,
see section 4.3.
The table below summarizes the procedure for extending the user profile enterprise bean
and importing data from an enterprise (legacy) database, with links to example code.
Importing data requires an enterprise bean
that maps to the legacy database. For simplicity, the examples assume that the
primary keys of the
two enterprise beans are identical, although there is no such requirement. The
primary key of the legacy enterprise bean does not have to match
the primary key of the user profile enterprise bean (the userName column).
Extending the user profile bean to set and get user cell phone data
Task
Examples
1. Start with the base user profile bean and its remote interface.
These contain the methods for setting and getting the base user profile fields
2. Define a home interface and finder helper for the UPBaseChild bean. Specify
the create and finder methods for the bean.
Because inheritance between home
interfaces is not supported in WebSphere Application Server, you
will need to define all of the methods found in the UPBaseHome interface in
order to use the managerial functions of the User Profile Manager.
You can also add more methods as necessary to further customize the
User Profile.
3. Create read-only and read-write extensions of the UPBaseChild bean.
In the base implementation of the User Profile beans provided, read-only and
read-write beans are simple extensions of the UPBase bean. You would similarly
extend your UPBaseChild bean with read-only and read-write extensions.
Using the Application Assembly Tool or IBM VisualAge for Java,
map both beans to the same table (that is, the same user profile table)
and corresponding columns.
Then define the deployment descriptor.
In the base read-only
implementation provided, all of the business methods are marked as read-only, so
updating the fields using setter methods on the read-only bean does not update
the persistent store.
Mark all the business methods in this example as constant (read-only):
Assuming you are not updating any instance variables in getter methods, you may
also mark all your getter methods this example as constant to improve performance:
Mark some or all of the fields (except the
remote interface to the legacy bean) as container managed fields. Define other
properties to your beans depending on your requirements.
5. Extend the User Profile data wrapper to include the new
methods
The example shows how to extend the base User Profile data wrapper class to include the
methods for setting and getting cell phone information in the User Profile