1 17 package org.apache.jasper.compiler; 18 19 20 import java.util.HashMap ; 21 22 import org.apache.jasper.JasperException; 23 24 30 public class BeanRepository { 31 32 protected HashMap <String , String > beanTypes; 33 protected ClassLoader loader; 34 protected ErrorDispatcher errDispatcher; 35 36 39 public BeanRepository(ClassLoader loader, ErrorDispatcher err) { 40 this.loader = loader; 41 this.errDispatcher = err; 42 beanTypes = new HashMap <String , String >(); 43 } 44 45 public void addBean(Node.UseBean n, String s, String type, String scope) 46 throws JasperException { 47 48 if (!(scope == null || scope.equals("page") || scope.equals("request") 49 || scope.equals("session") || scope.equals("application"))) { 50 errDispatcher.jspError(n, "jsp.error.usebean.badScope"); 51 } 52 53 beanTypes.put(s, type); 54 } 55 56 public Class getBeanType(String bean) 57 throws JasperException { 58 Class clazz = null; 59 try { 60 clazz = loader.loadClass(beanTypes.get(bean)); 61 } catch (ClassNotFoundException ex) { 62 throw new JasperException (ex); 63 } 64 return clazz; 65 } 66 67 public boolean checkVariable(String bean) { 68 return beanTypes.containsKey(bean); 69 } 70 71 } 72 73 74 75 76 | Popular Tags |