KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > util > xml > confix > ObjectCreationCallback


1 package org.sapia.util.xml.confix;
2
3
4 /**
5  * This interface is meant to be implemented by objects that are created by
6  * the Confix runtime, but are meant only for the sake of creating another object. This interface
7  * can also be implemented if a validation needs to be performed before actually returning the
8  * created object.
9  * <p>
10  * This allows objects that do not obey the Confix restrictions (adder and setter methods,
11  * no-args constructor, etc) to still be created with Confix. For example, the following
12  * code shows how a URL instance could be created:
13  *
14  * <pre>
15  *
16  * public class URLFactory implements ObjectCreationCallback{
17  *
18  * private _link;
19  *
20  * public void setLink(String link){
21  * _link = link;
22  * }
23  * public object onCreate() throws ConfigurationException{
24  * if(_link == null){
25  * throw new ConfigurationException("URL 'link' attribute not specified");
26  * }
27  * try{
28  * return new URL(_link);
29  * }catch(MalformedURLException e){
30  * throw new ConfigurationException("Invalid value for 'link' attribute in URL", e);
31  * }
32  * }
33  * }
34  * </pre>
35  *
36  * @author Yanick Duchesne
37  * <dl>
38  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
39  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
40  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
41  * </dl>
42  */

43 public interface ObjectCreationCallback {
44   /**
45    * Called by the Confix runtime when this instance has been created; allows
46    * it to return another object at its place. The method can also be used
47    * if validation needs to be performed before return this instance (or the
48    * object that this instance creates).
49    *
50    * @return an <code>Object</code>
51    * @throws ConfigurationException if a problem occurs.
52    */

53   public Object JavaDoc onCreate() throws ConfigurationException;
54 }
55
Popular Tags