Methods Summary |
---|
public void | ejbActivate()No need for us to activate anything in this bean, but we need to
provide an implementation.
// Entity bean methods
System.out.println("ProfileBean activated.");
|
public void | ejbCreate(java.lang.String name)Create method with name of profile owner.
mName = name;
System.out.println("ProfileBean created for " + mName + ".");
|
public void | ejbCreate()Create method (corresponds to each create() method on the
home interface, ProfileHome). Nothing to initialize in this case.
System.out.println("Nameless ProfileBean created.");
|
public void | ejbLoad()Load bean from persistent store. Since the profile entries are stored in
a non-primitive object (Properties), they are stored in the database as a
raw byte array. In this load method, we convert the serialized bytes
loaded by the container into the Properties object.
try {
ByteArrayInputStream byteIn = new ByteArrayInputStream(mEntriesBytes);
ObjectInputStream objIn = new ObjectInputStream(byteIn);
mEntries = (Properties)objIn.readObject();
}
catch (Exception e) {
System.out.println("Failed to load ProfileBean: ");
e.printStackTrace();
throw new RemoteException("ejbLoad failed: ", e);
}
System.out.println("ProfileBean load finished.");
|
public void | ejbPassivate()No state to store on passivation.
System.out.println("ProfileBean passivated.");
|
public void | ejbPostCreate(java.lang.String name)Post-creation notification. Nothing to do here, what we need
to provide an implementation.
System.out.println("ProfileBean post-create called.");
|
public void | ejbPostCreate()Post-creation notification. Nothing to do here, but we need
to provide an implementation.
System.out.println("ProfileBean post-create called.");
|
public void | ejbRemove()Nothing to do on a remove.
System.out.println("ProfileBean removed.");
|
public void | ejbStore()Store bean to persistent store. We store our Properties object in the
database as a serialized byte array. Here, we serialize the Properties
object so that the container can store it.
try {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream objOut = new ObjectOutputStream(byteOut);
objOut.writeObject(mEntries);
mEntriesBytes = byteOut.toByteArray();
}
catch (Exception e) {
System.out.println("Failed to store ProfileBean: ");
e.printStackTrace();
throw new RemoteException("ejbStore failed: ", e);
}
System.out.println("ProfileBean store finished.");
|
public java.lang.String | getEntry(java.lang.String key)
return mEntries.getProperty(key);
|
public java.lang.String | getName()
return mName;
|
public boolean | isDirty()
return mDirtyBit;
|
public void | setEntityContext(EntityContext context)Get context from container.
System.out.println("ProfileBean context set.");
mContext = context;
|
public void | setEntry(java.lang.String key, java.lang.String value)
mEntries.put(key, value);
mDirtyBit = true;
|
public void | setName(java.lang.String name)
mName = name;
mDirtyBit = true;
|
public void | unsetEntityContext()Container is removing our context.
System.out.println("ProfileBean context unset.");
mContext = null;
|