org.sapia.util.xml.confix
Interface ObjectCreationCallback


public interface ObjectCreationCallback

This interface is meant to be implemented by objects that are created by the Confix runtime, but are meant only for the sake of creating another object. This interface can also be implemented if a validation needs to be performed before actually returning the created object.

This allows objects that do not obey the Confix restrictions (adder and setter methods, no-args constructor, etc) to still be created with Confix. For example, the following code shows how a URL instance could be created:


 public class URLFactory implements ObjectCreationCallback{

   private _link;

   public void setLink(String link){
     _link = link;
   }
    public object onCreate() throws ConfigurationException{
     if(_link == null){
       throw new ConfigurationException("URL 'link' attribute not specified");
     }
     try{
        return new URL(_link);
     }catch(MalformedURLException e){
       throw new ConfigurationException("Invalid value for 'link' attribute in URL", e);
     }
   }
 }
 

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Method Summary
 Object onCreate()
          Called by the Confix runtime when this instance has been created; allows it to return another object at its place.
 

Method Detail

onCreate

public Object onCreate()
                throws ConfigurationException
Called by the Confix runtime when this instance has been created; allows it to return another object at its place. The method can also be used if validation needs to be performed before return this instance (or the object that this instance creates).

Returns:
an Object
Throws:
ConfigurationException - if a problem occurs.


Copyright © 2002 Sapia Open Source Software. All Rights Reserved.