Example: UserProfileExtended.java

package com.ibm.servlet.personalization.userprofile;
/* -----------------------------------------------------------------
** Copyright 1997-99 IBM Corporation.  All rights reserved.
**
** -----------------------------------------------------------------
*/
import java.util.*;

import com.ibm.servlet.personalization.userprofile.UserProfile;

import com.ibm.websphere.userprofile.UserProfileExtender;
import com.ibm.websphere.userprofile.UserProfileProperties;

public class UserProfileExtended extends UserProfile implements UserProfileExtender,
   UserProfileProperties {
    //New column that is being added by this
    //derived class.
    public Hashtable properties;

    static String  propCol ="properties";

    //Manager Class will call this  method to append new Column types
    //to SQL Strings. If UserProfile class is extended to append new columns
    //it should implement UserProfileExtender.
    //COLUMNS: Base Class columns + columns returned by this class

    public  String[]  getNewColumns() {
        //if variable name is properties, you need to 
        //return "properties" . JDBC equivalent will be
        //generated automatically. 
        String[] newCol={propCol};
        return newCol;
    }

    public Object getValue(String key) {
        // Need to call this method to
        // get the things from persistent store
        properties = (Hashtable) getByType(propCol);

        if(properties != null)
            return properties.get(key);

        else return null;

    }

    public  void putValue(String key, Object value) {

        properties =(Hashtable) getByType(propCol);

        if(properties == null)
            properties = new Hashtable();

        properties.put(key,value);

        //store in persistent store
        setByType(propCol, properties); 
    }

    public void removeValue(String key) {
        properties = (Hashtable) getByType(propCol);

        if(properties == null)
            return;

        properties.remove(key);

        //store in persistent store
        setByType(propCol, properties);
    }
}

Related tasks
Using user profiles
Related reference
User profile development options



Searchable topic ID:   UserProfileExtended_java
Last updated: Jun 21, 2007 4:55:42 PM CDT    WebSphere Application Server Network Deployment, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/rprs_user_profile_extended_java.html

Library | Support | Terms of Use | Feedback