org.apache.shale.examples.mailreaderjpa
Class Logic

java.lang.Object
  extended by org.apache.shale.view.AbstractFacesBean
      extended by org.apache.shale.view.AbstractApplicationBean
          extended by org.apache.shale.examples.mailreaderjpa.Logic

public class Logic
extends org.apache.shale.view.AbstractApplicationBean

Business logic for this example application. This bean is designed to be a managed bean with scope "application", so the implementation of each public method must be done in a threadsafe manner.

USAGE NOTE: The public methods of this class may throw unchecked exceptions if the underlying persistence framework has problems. If you intend to create graceful UIs for such exceptions, be sure to enclose calls to these methods in try/catch blocks.


Constructor Summary
Logic()
           
 
Method Summary
 org.apache.mailreaderjpa.User authenticate(String username, String password)
          Authenticate the specified logon credentials, returning a corresponding User if they are valid or null otherwise.
 void bootstrap()
          Bootstrap the contents of the database, if necessary.
 void createSubscription(org.apache.mailreaderjpa.Subscription subscription)
          Add the specified Subscription to the persistent database.
 void createUser(org.apache.mailreaderjpa.User user)
          Add the specified User (and any associated child Subscriptions) to the persistent database.
 void deleteSubscription(org.apache.mailreaderjpa.Subscription subscription)
          Delete the specified Subscription from the persistent database.
 void deleteUser(org.apache.mailreaderjpa.User user)
          Delete the specified User (and any associated child Subscriptions) from the persistent database.
 void destroy()
          On application shutdown, close the entity manager factory.
 org.apache.mailreaderjpa.Protocol findProtocolById(int id)
          Return the Protocol with the specified id, if any; otherwise, return null.
 org.apache.mailreaderjpa.Subscription findSubscriptionById(int id)
          Return the Subscription with the specified id, if any; otherwise, return null.
 org.apache.mailreaderjpa.User findUserById(int id)
          Return the User with the specified id, if any; otherwise, return null.
 org.apache.mailreaderjpa.User findUserByUsername(String username)
          Return the User with the specified username, if any; otherwise, return null.
 List<org.apache.mailreaderjpa.Protocol> getProtocols()
          Return a List of the valid Protocols for this application.
 void init()
          Log initialization of this business logic bean.
 org.apache.mailreaderjpa.Subscription updateSubscription(org.apache.mailreaderjpa.Subscription subscription)
          Update the specified Subscription in the persistent database.
 org.apache.mailreaderjpa.User updateUser(org.apache.mailreaderjpa.User user)
          Update the specified User (and any associated child Subscriptions) in the persistent database.
 
Methods inherited from class org.apache.shale.view.AbstractFacesBean
erase, error, error, fatal, fatal, getApplication, getApplicationMap, getBean, getExternalContext, getFacesContext, getLifecycle, getRequestHeaderMap, getRequestMap, getRequestParameter, getRequestParameterMap, getRequestParameterValues, getSessionMap, getValue, info, info, log, log, retrieveData, saveData, setBean, setValue, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Logic

public Logic()
Method Detail

init

public void init()

Log initialization of this business logic bean.

Overrides:
init in class org.apache.shale.view.AbstractApplicationBean

destroy

public void destroy()

On application shutdown, close the entity manager factory.

Overrides:
destroy in class org.apache.shale.view.AbstractApplicationBean

getProtocols

public List<org.apache.mailreaderjpa.Protocol> getProtocols()

Return a List of the valid Protocols for this application. If no valid protocols are defined, a zero length list will be returned.


authenticate

public org.apache.mailreaderjpa.User authenticate(String username,
                                                  String password)

Authenticate the specified logon credentials, returning a corresponding User if they are valid or null otherwise.

Parameters:
username - Username to authenticate
password - Password to authenticate

bootstrap

public void bootstrap()

Bootstrap the contents of the database, if necessary. This is strictly a convenience mechanism so that the out-of-the-box content of the data matches that in the original demo. This is not typical of what you would need in a normal application.


createSubscription

public void createSubscription(org.apache.mailreaderjpa.Subscription subscription)

Add the specified Subscription to the persistent database.

Parameters:
subscription - Subscription to be added

createUser

public void createUser(org.apache.mailreaderjpa.User user)

Add the specified User (and any associated child Subscriptions) to the persistent database.

Parameters:
user - User to be added

deleteSubscription

public void deleteSubscription(org.apache.mailreaderjpa.Subscription subscription)

Delete the specified Subscription from the persistent database.

Parameters:
subscription - Subscription to be deleted

deleteUser

public void deleteUser(org.apache.mailreaderjpa.User user)

Delete the specified User (and any associated child Subscriptions) from the persistent database.

Parameters:
user - User to be deleted

findProtocolById

public org.apache.mailreaderjpa.Protocol findProtocolById(int id)

Return the Protocol with the specified id, if any; otherwise, return null.

Parameters:
id - Protocol id to look up

findSubscriptionById

public org.apache.mailreaderjpa.Subscription findSubscriptionById(int id)

Return the Subscription with the specified id, if any; otherwise, return null.

Parameters:
id - Subscription id to look up

findUserById

public org.apache.mailreaderjpa.User findUserById(int id)

Return the User with the specified id, if any; otherwise, return null.

Parameters:
id - User id to look up

findUserByUsername

public org.apache.mailreaderjpa.User findUserByUsername(String username)

Return the User with the specified username, if any; otherwise, return null.

Parameters:
username - Username to look up

updateSubscription

public org.apache.mailreaderjpa.Subscription updateSubscription(org.apache.mailreaderjpa.Subscription subscription)

Update the specified Subscription in the persistent database.

Parameters:
subscription - Subscription to be updated
Returns:
The updated instance

updateUser

public org.apache.mailreaderjpa.User updateUser(org.apache.mailreaderjpa.User user)

Update the specified User (and any associated child Subscriptions) in the persistent database.

Parameters:
user - User to be updated
Returns:
The updated instance


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.