01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: ClassCallTargetRetriever.java 3851 2007-07-12 18:49:59Z gbevin $
07: */
08: package com.uwyn.rife.continuations.basic;
09:
10: import com.uwyn.rife.continuations.CallState;
11: import com.uwyn.rife.continuations.ContinuableObject;
12: import com.uwyn.rife.continuations.exceptions.CallTargetNotFoundException;
13:
14: /**
15: * Retrieves the continuable for a call continuation where the call target is a
16: * class.
17: *
18: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
19: * @version $Revision: 3851 $
20: * @since 1.6
21: */
22: public class ClassCallTargetRetriever implements CallTargetRetriever {
23: /**
24: * Retrieves the continuable for a call continuation.
25: *
26: * @param target the call target object that will be used to retrieve the
27: * continuable
28: * @param state the call state
29: * @return the call continuable; or
30: * <p>{@code null} if no continuable should be executed immediately in
31: * response to this call
32: * @since 1.6
33: */
34: public ContinuableObject getCallTarget(Object target,
35: CallState state) {
36: try {
37: Class target_class = (Class) target;
38: Object target_instance = target_class.newInstance();
39: return (ContinuableObject) target_instance;
40: } catch (Throwable e) {
41: throw new CallTargetNotFoundException(target, e);
42: }
43: }
44: }
|