Dashboard > RIFE > ... > Web engine > Reloading manually declared sites by site listeners
RIFE Log In | Sign Up   View a printable version of the current page.
Reloading manually declared sites by site listeners


Added by Geert Bevin, last edited by Geert Bevin on Aug 20, 2006  (view change)
Labels: 
(None)

When you create a site through the Java API of the SiteBuilder class, you're able to include sub-sites that are declared with XML. These are registered as reloadable resources and their modification time is stored and checked regularly if the SITE_AUTO_RELOAD configuration parameter is set to true. The same happens for the compiled class files of the element implementations. However, since you manually declared the main site using Java, RIFE can't automatically rebuild it (which is what it does when you create a site using XML). You can now however add a SiteListener to your site that will receive a notification whenever RIFE detects that any of the site's resources has been modified. In your SiteListener implementation you can then rebuild the site and make it the new default instance that is used by RIFE.

For example, this is a custom site participant that does just that:

public class MySiteParticipant extends BlockingParticipant {
    private Site    site;
      
    public void initialize() {
        SiteBuilder builder = new SiteBuilder("main");
        builder
            .enterElement("YourElement")
                // ...
            .leaveElement()
          
            // ... other elements and sub sites
            ;
                  
        site = builder.getSite();
        site.addListener(new SiteListener() {
                public void modified(Site modifiedSite) {
                    initialize();
                    modifiedSite.populateFromOther(site);
                }
            });
    }
      
    protected Object _getObject() {
        return site;
    }
}



Are you enjoying Confluence? Please consider purchasing it today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.1a Build:#515 May 19, 2006) - Bug/feature request - Contact Administrators