Code, JavaEE

Product Processing Using Generic Lifecycle Configuration

/*
Product Processing Using Generic Lifecycle Configuration

The base interface for the lifecycle of a generic product
is based on the notion of generically defining a
request type of some kind and assumes in this
design, a generic return type, defined as follows:

Generic Return Type:
*/

public interface Result<T> {
 public T getResult();
 public void setResult(T result);

 public Boolean isErrorCondition();
 public void setErrorCondition(Boolean errorCondition);

 public Map<String, Object> getResultMap();
 public void setResultMap(Map<String, Object> resultMap);
}

/*
This design supports a series of products that have the
SAME method signature, thereby handling its processing
based on a combination of meta data and a request
key parameter as follows:
*/

public interface Product<T, R> {
 /**
 * process
 *
 * All lifecycle/activity methods pass in a request type T
 * and returns a type R, in addition meta data is given
 * for each request.
 *
 * @param requestType
 * @param metaData
 * @return
 */
 public R process(T requestType, Map<String, Object> metaData);

}

/*
T, represents a request type of some kind, where R is the generic
return/result type.

Product Lifecycle Methods/Definition

Each product will handle a number of lifecycle methods defined as
the basic create, delete, update and read for CRUD operations OR
custom methods named based on conventions such as,
process${Methodname}, validate${Methodname}.

From this emerges many lifecycle interfaces such that,
*/

public interface CrudLifecycle<T, R> {
 public R create(T requestType, Map<String, Object> metaData);
 public R read(T requestType, Map<String, Object> metaData);
 public R update(T requestType, Map<String, Object> metaData);
 public R delete(T requestType, Map<String, Object> metaData);
}

// Handles generic processing providing the method name
// to invoke on the product implementation
public interface ProductProcessLifecycle<T, R> {
 public void setMethodName(String methodName);

 public R process(String methodName, T requestType, Map<String, Object> metaData);
}

// Handles generic validation providing the method name
// to invoke on the product implementation
public interface ProductValidateLifecycle<T, R> {
 public void setMethodName(String methodName);

 public R validate(String methodName, T requestType, Map<String, Object> metaData);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s