1 29 30 package com.caucho.jsp.el; 31 32 import com.caucho.jsp.TaglibManager; 33 import com.caucho.server.webapp.WebApp; 34 import com.caucho.util.L10N; 35 36 import javax.el.ELContextListener; 37 import javax.el.ELResolver; 38 import javax.el.ExpressionFactory; 39 import javax.servlet.jsp.JspApplicationContext ; 40 41 public class JspApplicationContextImpl implements JspApplicationContext 42 { 43 private static final L10N L = new L10N(JspApplicationContextImpl.class); 44 45 private final WebApp _webApp; 46 47 private final ExpressionFactory _expressionFactory; 48 49 private TaglibManager _taglibManager; 50 51 private ELResolver []_resolverArray = new ELResolver[0]; 52 private ELContextListener []_listenerArray = new ELContextListener[0]; 53 54 private boolean _hasRequest; 55 56 public JspApplicationContextImpl(WebApp webApp) 57 { 58 _webApp = webApp; 59 60 _expressionFactory = new JspExpressionFactoryImpl(this); 61 } 62 63 67 WebApp getWebApp() 68 { 69 return _webApp; 70 } 71 72 public TaglibManager getTaglibManager() 73 { 74 return _taglibManager; 75 } 76 77 public void setTaglibManager(TaglibManager taglibManager) 78 { 79 _taglibManager = taglibManager; 80 } 81 82 86 89 public void addELContextListener(ELContextListener listener) 90 { 91 if (_hasRequest) 92 throw new IllegalStateException (L.l("Cannot add ELContextListener after requests have started.")); 93 94 ELContextListener []listenerArray 95 = new ELContextListener[_listenerArray.length + 1]; 96 System.arraycopy(_listenerArray, 0, 97 listenerArray, 0, 98 _listenerArray.length); 99 100 listenerArray[_listenerArray.length] = listener; 101 102 _listenerArray = listenerArray; 103 } 104 105 public ELContextListener []getELListenerArray() 106 { 107 _hasRequest = true; 108 109 return _listenerArray; 110 } 111 112 115 public void addELResolver(ELResolver resolver) 116 { 117 if (_hasRequest) 118 throw new IllegalStateException (L.l("Can't add ELResolver after starting request.")); 119 120 ELResolver []resolverArray = new ELResolver[_resolverArray.length + 1]; 121 System.arraycopy(_resolverArray, 0, 122 resolverArray, 0, 123 _resolverArray.length); 124 125 resolverArray[_resolverArray.length] = resolver; 126 127 _resolverArray = resolverArray; 128 } 129 130 public ELResolver []getELResolverArray() 131 { 132 return _resolverArray; 133 } 134 135 138 public ExpressionFactory getExpressionFactory() 139 { 140 return _expressionFactory; 141 } 142 143 public String toString() 144 { 145 return "JspApplicationContextImpl[" + _webApp + "]"; 146 } 147 } 148 | Popular Tags |