1 23 24 package com.sun.enterprise.web.jsp; 25 26 import java.security.AccessController ; 27 import java.security.PrivilegedAction ; 28 29 import javax.servlet.ServletContext ; 30 import javax.servlet.jsp.tagext.JspTag ; 31 32 import org.apache.catalina.core.ApplicationContextFacade; 33 import org.apache.catalina.core.StandardContext; 34 import org.apache.jasper.runtime.ResourceInjector; 35 36 import com.sun.enterprise.Switch; 37 import com.sun.enterprise.deployment.JndiNameEnvironment; 38 import com.sun.enterprise.InjectionManager; 39 40 46 public class ResourceInjectorImpl implements ResourceInjector { 47 48 private InjectionManager injectionMgr; 49 private JndiNameEnvironment desc; 50 51 54 public ResourceInjectorImpl() { 55 injectionMgr = Switch.getSwitch().getInjectionManager(); 56 } 57 58 59 65 public void setContext(ServletContext servletContext) { 66 67 if (!(servletContext instanceof ApplicationContextFacade)) { 68 return; 69 } 70 71 final ApplicationContextFacade contextFacade = 72 (ApplicationContextFacade) servletContext; 73 74 StandardContext context = null; 75 76 context = (StandardContext) AccessController.doPrivileged( 77 new PrivilegedAction () { 78 public Object run() { 79 return contextFacade.getUnwrappedContext(); 80 } 81 }); 82 83 if (context != null) { 84 desc = (JndiNameEnvironment) 85 Switch.getSwitch().getDescriptorFor(context); 86 } 87 } 88 89 90 99 public void inject(JspTag handler) throws Exception { 100 101 if( desc != null ) { 102 injectionMgr.injectInstance(handler, desc); 103 } 104 } 105 106 } 107 | Popular Tags |