1 package com.sri.emo.wizard;
2
3 import java.io.Serializable;
4
5 /***
6 * This interface is for controllers to allow Wizards to be transformed between
7 * usable wizards and opaque serializable objects that are meant to be as
8 * 'slim' as possible. Ex:
9 * <p/>
10 * <code><pre>
11 * request.getSession().setPersistentAttribute("MyWizardKey", mementoConverter.toMomento(myWizard));
12 * <p/>
13 * and
14 * <p/>
15 * //Cast to serializable is necessary because session says it needs objects,
16 * //even though it really needs Serializable.
17 * Wizard myWizard = myMementoConverter.fromMemento((Serializable)request.getSession().getPersistentAttribute("MyWizardKey"));
18 * </pre></code>
19 * </p>
20 *
21 * @author Michael Rimov
22 * @version 1.0
23 */
24 public interface WizardMementoConverter {
25
26 /***
27 * Breaks the wizard down into minimal component state parts that can
28 * be stored in the session or client. Similar to the dehydration process
29 * in the natural -- all the fluff is removed.
30 * Implementations do not have to do anything with the underlying wizard,
31 * they may just return the wizard proper if everything is properly
32 * serializable.
33 *
34 * @param target Wizard the wizard being 'dehydrated'
35 * @return Serializable
36 * @throws WizardException
37 */
38 Serializable toMemento(Wizard target) throws WizardException;
39
40
41 /***
42 * Re-fleshes out the wizard into usable forms. Again, the underlying
43 * factory implementation may not do anything with it. It doesn't really
44 * matter in the end.
45 *
46 * @param previouslyExternalized Serializable
47 * @return Wizard
48 * @throws WizardException
49 */
50 Wizard fromMemento(Serializable previouslyExternalized) throws WizardException;
51 }