KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > Creator


1 /*****************************************************************************
2  * Copyright (C) Codehaus.org. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8 /*
9  * Created on Mar 4, 2005
10  *
11  * Author Ben Yu
12  * ZBS
13  */

14 package jfun.yan;
15
16 /**
17  * A creator is responsible for creating component instances.
18  * <p>
19  * Codehaus.org.
20  *
21  * @author Ben Yu
22  *
23  */

24 public interface Creator<T> extends Typeful, Verifiable, java.io.Serializable JavaDoc{
25   /**
26    * Create a component instance.
27    * @param dep the provider that provides all dependent data.
28    * @return the component instance.
29    * @throws IrresolveableArgumentException
30    * when any of the arguments is not resolveable.
31    * @throws ParameterTypeMismatchException
32    * when any of the arguments do not match the expectec type.
33    * @throws AmbiguousComponentResolutionException
34    * when resolution of any of the arguments has ambiguity.
35    * @throws ComponentInstantiationException
36    * The runtime exception wrapper for any error happens
37    * in the creation function.
38    * @throws ComponentException
39    * error when resolving any of the arguments.
40    * @throws YanException any error.
41    */

42   T create(Dependency dep)
43   throws IrresolveableArgumentException, ParameterTypeMismatchException,
44   AmbiguousComponentResolutionException, ComponentInstantiationException,
45   YanException;
46   
47   /**
48    * To get the compile time type of the instances created by this component.
49    * <p>
50    * A tolerant static type checking will be performed if this function returns a non-null type.
51    * </p>
52    */

53   Class JavaDoc getType();
54   
55   /**
56    * To determine if the type returned by getType() is the concrete type
57    * of the real instance.
58    * <p>
59    * A strict static type check will be performed on concrete types.
60    * </p>
61    */

62   boolean isConcrete();
63   /**
64    * Determines if the component always return the same instance
65    * and has no side-effect that causes difference when called the second time.
66    * <p>
67    * This information may be useful to certain optimizations.
68    * </p>
69    * @return true if it always return the same instance.
70    * False if not singleton or non-determinable.
71    */

72   boolean isSingleton();
73 }
74
Popular Tags