InfoCenter Home >
4: Developing applications >
4.4: Personalizing applications >
4.4.2: Keeping user profiles >
4.4.2.2: Customizing the base user profile support >
4.4.2.2.3: Extending the User Profile enterprise bean and importing legacy databases
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.
|
Read-only bean extension classes:
Read-write bean extension classes:
|
4. Define a deployment descriptor for your beans
Use the Jetace tool included with WebSphere Application Server
to define the container managed persistence (CMP) fields and properties of the
bean. Alternatively, use IBM VisualAge for Java to develop the bean
and define its deployment descriptor.
If using IBM VisualAge for Java,
you can mark the methods as read-only using the "Const" method option.
IBM VisualAge for Java also gives you the ability to map the fields to the existing
table, so that you can map both of the beans to same table.
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
|
EJB extension
|
6. Use a WebSphere Application Server administrative client to configure
user profile support.
The administrative configuration includes:
- The data wrapper class name
- JNDI lookup names
- Home and remote interfaces for the read-only and read-write beans
|
|
|
|