1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.composite;
17
18 import net.sf.composite.specialize.SpecializationException;
19
20 /***
21 * A composite that may be exposable as types in addition to those explicitly
22 * specified in the class declaration. For example, if some subset of the
23 * components of a composite all implement some interface that is not
24 * implemented by the composite itself, a new composite can be created that
25 * implements this interface that all the components implement. All that is
26 * needed is a method of choosing which component should perform the requested
27 * operation. This method of choosing is not specified by this interface;
28 * rather, this interface simply indicates that this composite may expose
29 * additional interfaces if those interfaces are implemented by some subset of
30 * the components of this composite.
31 *
32 * @author Matt Sgarlata
33 * @since Dec 27, 2004
34 */
35 public interface SpecializableComposite extends Composite {
36
37 /***
38 * Uses the components in this composite to dynamically create a composite
39 * that implements <code>type</code>.
40 *
41 * @param type
42 * the interface to be exposed
43 * @return the new composite that implements the requested interface
44 * @throws SpecializationException
45 * if an error occurs while creating the new, specialized,
46 * composite that implements the requested interface
47 */
48 public Object specialize(Class type) throws SpecializationException;
49
50 /***
51 * Indicates whether this composite can expose the given interface by
52 * dynamically creating a new composite.
53 *
54 * @param type
55 * the interface to be exposed
56 * @return whether this composite can expose the given interface by
57 * dynamically creating a new composite
58 * @throws SpecializationException
59 * if an error occurrs
60 */
61 public boolean isSpecializable(Class type) throws SpecializationException;
62
63 }