Methods Summary |
---|
private void | clearEntries()
// Initialize our profile properties to an empty set, and
// transfer the empty collection to the byte array
this.mEntries = new Properties();
try {
transferToBytes();
}
catch (IOException ioe) {
System.out.println("Failed to initialize binary entries: "
+ ioe.getMessage());
}
|
public void | ejbActivate()
try {
transferToProps();
System.out.println("ProfileBean activated.");
}
catch (IOException ioe) {
System.out.println("Failed to convert entries during activation.");
ioe.printStackTrace();
}
|
public java.lang.String | ejbCreate()
System.out.println("Nameless ProfileBean created.");
setName(" ");
clearEntries();
return null;
|
public java.lang.String | ejbCreate(java.lang.String name)
setName(name);
clearEntries();
System.out.println("ProfileBean created for " + name + ".");
return null;
|
public void | ejbLoad()
try {
transferToProps();
}
catch (IOException e) {
System.out.println("Failed to load ProfileBean: ");
e.printStackTrace();
throw new EJBException("ejbLoad failed: ", e);
}
System.out.println("ProfileBean load finished.");
|
public void | ejbPassivate()
try {
transferToBytes();
System.out.println("ProfileBean being passivated.");
}
catch (IOException ioe) {
System.out.println("Failed to convert entries during activation.");
ioe.printStackTrace();
}
|
public void | ejbPostCreate()
System.out.println("ProfileBean post-create called.");
|
public void | ejbPostCreate(java.lang.String name)
System.out.println("ProfileBean post-create called.");
|
public void | ejbRemove()
System.out.println("ProfileBean removed.");
|
public void | ejbStore()
try {
transferToBytes();
}
catch (IOException e) {
System.out.println("Failed to store ProfileBean: ");
e.printStackTrace();
throw new EJBException("ejbStore failed: ", e);
}
System.out.println("ProfileBean store finished.");
|
public abstract byte[] | getEntriesBytes()
|
public java.lang.String | getEntry(java.lang.String key)
System.out.println("getEntry(): principle = " +
mContext.getCallerPrincipal().getName());
return mEntries.getProperty(key);
|
public abstract java.lang.String | getName()
|
public abstract PersonLocal | getPersonLocal()
|
public void | setEntityContext(javax.ejb.EntityContext context)
System.out.println("ProfileBean context set.");
mContext = context;
|
public abstract void | setEntriesBytes(byte[] entries)
|
public void | setEntry(java.lang.String key, java.lang.String value)
mEntries.put(key, value);
|
public abstract void | setName(java.lang.String name)
|
public abstract void | setPersonLocal(PersonLocal person)
|
private void | transferToBytes()
//--------------------------------------------------
// Utility methods
//--------------------------------------------------
// Transfer the list of entries from our Properties member to the byte
// array.
// Serialize the Properties into a byte array using an ObjectOutputStream
if (mEntries != null) {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream objOut = new ObjectOutputStream(byteOut);
objOut.writeObject(mEntries);
setEntriesBytes(byteOut.toByteArray());
}
|
private void | transferToProps()
// Take the raw byte array and de-serialize it
// back into a Properties object using an ObjectInputStream
try {
if (getEntriesBytes() != null) {
ByteArrayInputStream byteIn =
new ByteArrayInputStream(getEntriesBytes());
ObjectInputStream objIn = new ObjectInputStream(byteIn);
mEntries = (Properties)objIn.readObject();
}
// If no entries in database, set properties to a new, empty collection
else {
mEntries = new Properties();
}
}
catch (ClassNotFoundException cnfe) {
System.out.println("Properties class not found during de-serialization");
}
|
public void | unsetEntityContext()
System.out.println("ProfileBean context unset.");
mContext = null;
|