IPageBeanFactory.java :  » Web-Framework » jucas » org » jucas » Java Open Source

Java Open Source » Web Framework » jucas 
jucas » org » jucas » IPageBeanFactory.java
/*
 * License
 *
 *
 * Copyright (c) 2003 Essl Christian.  All rights 
 * reserved.
 * 
 * 
 * This Licence is based on the Apache Software Licence Version 1.1.
 *
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:  
 *       "This product includes software developed by Christian Essl 
 *        and others for project Jucas (http://www.jucas.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Jucas" and "Christian Essl" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written 
 *    permission, please contact essl_christian@jucas.org.
 *
 * 5. Products derived from this software may not be called "Jucas"
 *    or "Christian Essl", nor may "Jucas" or "Christian Essl"
 *    appear in their name, without prior written permission
 *    of Christian Essl (jucas@esslchristian.de).
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL CHRISTIAN ESSL OR
 * OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * 
 */
package org.jucas;

import java.net.URI;

import javax.servlet.ServletContext;

import org.jaul.JaulContext;
import org.jaul.ScriptBody;


/**
 *An array of IPageBeanFactory is used by the BeanManager to instantiate
 *PageBeans There two serveral default implementations. Which implementations
 *are used is defined in the jucas-config.xml file.
 * <br><br>
 * Normally the default implementions of this class are used. However it is not
 * hard to implement the interface. Care must be taken that the implementations
 * must be threadsave concerining the methods defined in this interface.
 
 *<br><br>
 * The BeanManager mantains an array of IPageBeanFactories. When a new PageBean
 * is to be created each Factory in the array is asked to create the PageBean
 * (createPageBean) if it can create the Page bean it should return it. If can not
 * it should return null (It should not throw any Exception). If null is
 * returned the next Factory is asked.
 *<br><br>
 *When a PageBean was created the PageBean is setUp by the beanManager (setting JucasServices) and after
 *this the setUpPageBean method is called on the creating PageBeanFactory to do
 *further setup of the IJucasBean when necessery. 
 *<br><br>
 *
 *Parameters can be given to an IPageBeanFactory in the jucas-config.xml file.
 *When the IPageBeanFactory is specified in this file. The SciptBody of the specifying
 *tag <IPageBeanFactory> is given to the {@link #init(ServletContext, ScriptBody, JaulContext)}
 *method. The IPageBeanFactory is than responsible to process this body. Normally the
 *IPageBeanFactory will have JavaBeans properties and will call body.execute.
 *
 *<br><br>
 *<b> implementations are used multithreaded and must be threadsave</b><br><br>
 *<b> to be instantiated must have a default constructor (public no arguments)
 * </b>
 * @author chris
 */
public interface IPageBeanFactory
{
  
  /**
   * Called to create a page Bean
   * 
   * @param definingURI the uri specifieing the resource of the PageBean may
   * be freely interpreted by the Factory
   * @param beanManager the beanManager
   * @param beanName the name given to the Bean
   * @return IJucasBean either a created Bean if it was possible to interpret
   * the uri or null (never throw an exception)
   */
  public IJucasBean createPageBean(URI definingURI,BeanManager beanManager,URI beanName);
  
  /**
   * Used to setup a created PageBean after the BeanManager has set the
   * services. When createPageBean returned an IJucasBean, the IJucasBean will
   * be setup first by the BeanManager and afterwards this method will be
   * called with the same arguments as the createPageBean
   * @param pageBean the createdPageBean    
   * @param definingURI same instance as createPageBean
   * @param beanManager same instance as createPageBean
   * @param beanName same instance as createPageBean
   * @throws Exception if something goes wrong in the setup 
   */
  public void setUpPageBean(IJucasBean pageBean,URI definingURI,BeanManager beanManager,URI beanName) throws Exception; 
  
  /**
   * after instantiated with new Instance() (default constructur needed). This method is invoked
   * @param param the value of the parameter
   * @param servletContext the servletContext
   */
  public void init(ServletContext servletContext, ScriptBody body,JaulContext initContext);

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.