I use the decorator pattern to describe Actions, and I would like to use those Actions in RPC calls
public abstract class Action implement Serializable
{
boolean isDecorated = false;
public Action() {} // default constructor for Serialization
}
public abstract class ActionDecorator extends Action
{
private Action _decoratedAction;
public ActionDecorator() // default constructor for Serialization
{}
public ActionDecorator(Action action)
{
_decoratedAction = action;
_decoratedAction.isDecorated = true;
}
}
After the transaction, I do receive a DecoratorAction wich contains an Action, but the isDecorated member of _decoratedAction is set to false.
Since the default (zero-arg) constructor is called to re-construct my object, both my decorator AND my decorated actions get the default value of isDecorated (false).
I can't copy the "_decoratedAction.isDecorated = true;" in the zero-arg constructor of ActionDecorator, because _decoratedAction is not initialized (null) at that time.
Sure I could manually set the boolean after each transaction, but it would be better to avoid extra object initialization (wich can be forgot) each time my co-workers want to use the Action object...