Example: UserProfileExtended.java

package com.ibm.servlet.personalization.userprofile;
/* -----------------------------------------------------------------
**
** -----------------------------------------------------------------
*/
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);
    }
}

 

See Also

Managing user profiles
User profile development options