1 package net.trajano.twiff.internal.servlet; 2 3 import javax.servlet.ServletRequest; 4 import net.trajano.twiff.InstantiationException; 5 import net.trajano.twiff.adapter.RequestAdapter; 6 import org.picocontainer.MutablePicoContainer; 7 8 /*** 9 * Utilty class to provide helper methods in making renderers. 10 * 11 * @author Archimedes Trajano 12 */ 13 public class RendererUtil { 14 /*** 15 * Registers a page bean in the request container. 16 * 17 * @param request 18 * servlet request. 19 * @param pageBeanClass 20 * page bean class to register. 21 */ 22 public static void registerPageBean(final ServletRequest request, final Class pageBeanClass) { 23 RequestAdapter requestAdapter = new RequestAdapter(request); 24 MutablePicoContainer container = requestAdapter.getContainer(); 25 container.registerComponentImplementation(pageBeanClass); 26 } 27 28 /*** 29 * Registers a page bean in the request container. 30 * 31 * @deprecated 32 * @param request 33 * servlet request. 34 * @param pageBeanClassName 35 * page bean class to register. 36 */ 37 public static void registerPageBean(final ServletRequest request, final String pageBeanClassName) { 38 try { 39 RequestAdapter requestAdapter = new RequestAdapter(request); 40 MutablePicoContainer container = requestAdapter.getContainer(); 41 Class pageBeanClass = Class.forName(pageBeanClassName); 42 container.registerComponentImplementation(pageBeanClass); 43 } catch (ClassNotFoundException e) { 44 throw new InstantiationException(e); 45 } 46 } 47 48 /*** 49 * Private constructor to prevent instantiation of utility class. 50 */ 51 private RendererUtil() { 52 } 53 }