public void initialize(ContainerContext context) { try { WeldForwardingInstanceManager.replaceInstanceManager(context.getServletContext(), context.getManager()); if(Boolean.TRUE.equals(context.getServletContext().getAttribute(EnhancedListener.ENHANCED_LISTENER_USED_ATTRIBUTE_NAME))) { TomcatLogger.LOG.allInjectionsAvailable(); } else { TomcatLogger.LOG.listenersInjectionsNotAvailable(); } } catch (Exception e) { TomcatLogger.LOG.unableToReplaceTomcat(e); } } }
private static StandardContext getStandardContext(ServletContext context) { try { // Hack into Tomcat to replace the InstanceManager using // reflection to access private fields ApplicationContext appContext = (ApplicationContext) getContextFieldValue((ApplicationContextFacade) context, ApplicationContextFacade.class); return (StandardContext) getContextFieldValue(appContext, ApplicationContext.class); } catch (Exception e) { throw TomcatLogger.LOG.cannotGetStandardContext(e); } }
private static void setInstanceManager(StandardContext stdContext, InstanceManager instanceManager) { try { Method method = SecurityActions.lookupMethod(stdContext.getClass(), INSTANCE_MANAGER_SETTER_NAME, InstanceManager.class); SecurityActions.ensureAccessible(method); try { method.invoke(stdContext, instanceManager); return; } catch (Exception e) { TomcatLogger.LOG.errorInvokingMethod(method.getName(), stdContext, instanceManager); } } catch (NoSuchMethodException e1) { // Getter/setter not found } try { Field field = SecurityActions.lookupField(stdContext.getClass(), INSTANCE_MANAGER_FIELD_NAME); SecurityActions.ensureAccessible(field); try { field.set(stdContext, instanceManager); return; } catch (Exception e) { TomcatLogger.LOG.errorWritingField(field.getName(), stdContext, instanceManager); } } catch (NoSuchFieldException e1) { // Field not found } throw TomcatLogger.LOG.neitherFieldNorGetterSetterFound(stdContext.getClass()); }
private static InstanceManager getInstanceManager(StandardContext stdContext) { try { Method method = SecurityActions.lookupMethod(stdContext.getClass(), INSTANCE_MANAGER_GETTER_NAME); SecurityActions.ensureAccessible(method); try { return Reflections.cast(method.invoke(stdContext)); } catch (Exception e) { TomcatLogger.LOG.errorInvokingMethod(method.getName(), stdContext, Arrays2.EMPTY_ARRAY); } } catch (NoSuchMethodException e1) { // Getter/setter not found } try { Field field = SecurityActions.lookupField(stdContext.getClass(), INSTANCE_MANAGER_FIELD_NAME); SecurityActions.ensureAccessible(field); try { return Reflections.cast(field.get(stdContext)); } catch (Exception e) { TomcatLogger.LOG.errorReadingField(field.getName(), stdContext); } } catch (NoSuchFieldException e1) { // Field not found } throw TomcatLogger.LOG.neitherFieldNorGetterSetterFound(stdContext.getClass()); }
private static WeldForwardingInstanceManager createInstance(WeldManager manager, StandardContext stdContext) { try { InstanceManager weldProcessor = new WeldInstanceManager(manager); return new WeldForwardingInstanceManager(getInstanceManager(stdContext), weldProcessor); } catch (Exception e) { throw TomcatLogger.LOG.cannotCreatWeldForwardingAnnotationProcessor(e); } }
private static InstanceManager getInstanceManager(StandardContext stdContext) { try { Method method = SecurityActions.lookupMethod(stdContext.getClass(), INSTANCE_MANAGER_GETTER_NAME); SecurityActions.ensureAccessible(method); try { return Reflections.cast(method.invoke(stdContext)); } catch (Exception e) { TomcatLogger.LOG.errorInvokingMethod(method.getName(), stdContext, Arrays2.EMPTY_ARRAY); } } catch (NoSuchMethodException e1) { // Getter/setter not found } try { Field field = SecurityActions.lookupField(stdContext.getClass(), INSTANCE_MANAGER_FIELD_NAME); SecurityActions.ensureAccessible(field); try { return Reflections.cast(field.get(stdContext)); } catch (Exception e) { TomcatLogger.LOG.errorReadingField(field.getName(), stdContext); } } catch (NoSuchFieldException e1) { // Field not found } throw TomcatLogger.LOG.neitherFieldNorGetterSetterFound(stdContext.getClass()); }
private static WeldForwardingInstanceManager createInstance(WeldManager manager, StandardContext stdContext) { try { InstanceManager weldProcessor = new WeldInstanceManager(manager); return new WeldForwardingInstanceManager(getInstanceManager(stdContext), weldProcessor); } catch (Exception e) { throw TomcatLogger.LOG.cannotCreatWeldForwardingAnnotationProcessor(e); } }
public void initialize(ContainerContext context) { try { WeldForwardingInstanceManager.replaceInstanceManager(context.getServletContext(), context.getManager()); if(Boolean.TRUE.equals(context.getServletContext().getAttribute(EnhancedListener.ENHANCED_LISTENER_USED_ATTRIBUTE_NAME))) { TomcatLogger.LOG.allInjectionsAvailable(); } else { TomcatLogger.LOG.listenersInjectionsNotAvailable(); } } catch (Exception e) { TomcatLogger.LOG.unableToReplaceTomcat(e); } } }
private static InstanceManager getInstanceManager(StandardContext stdContext) { try { Method method = SecurityActions.lookupMethod(stdContext.getClass(), INSTANCE_MANAGER_GETTER_NAME); SecurityActions.ensureAccessible(method); try { return Reflections.cast(method.invoke(stdContext)); } catch (Exception e) { TomcatLogger.LOG.errorInvokingMethod(method.getName(), stdContext, Arrays2.EMPTY_ARRAY); } } catch (NoSuchMethodException e1) { // Getter/setter not found } try { Field field = SecurityActions.lookupField(stdContext.getClass(), INSTANCE_MANAGER_FIELD_NAME); SecurityActions.ensureAccessible(field); try { return Reflections.cast(field.get(stdContext)); } catch (Exception e) { TomcatLogger.LOG.errorReadingField(field.getName(), stdContext); } } catch (NoSuchFieldException e1) { // Field not found } throw TomcatLogger.LOG.neitherFieldNorGetterSetterFound(stdContext.getClass()); }
private static void setInstanceManager(StandardContext stdContext, InstanceManager instanceManager) { try { Method method = SecurityActions.lookupMethod(stdContext.getClass(), INSTANCE_MANAGER_SETTER_NAME, InstanceManager.class); SecurityActions.ensureAccessible(method); try { method.invoke(stdContext, instanceManager); return; } catch (Exception e) { TomcatLogger.LOG.errorInvokingMethod(method.getName(), stdContext, instanceManager); } } catch (NoSuchMethodException e1) { // Getter/setter not found } try { Field field = SecurityActions.lookupField(stdContext.getClass(), INSTANCE_MANAGER_FIELD_NAME); SecurityActions.ensureAccessible(field); try { field.set(stdContext, instanceManager); return; } catch (Exception e) { TomcatLogger.LOG.errorWritingField(field.getName(), stdContext, instanceManager); } } catch (NoSuchFieldException e1) { // Field not found } throw TomcatLogger.LOG.neitherFieldNorGetterSetterFound(stdContext.getClass()); }
private static WeldForwardingInstanceManager createInstance(WeldManager manager, StandardContext stdContext) { try { InstanceManager weldProcessor = new WeldInstanceManager(manager); return new WeldForwardingInstanceManager(getInstanceManager(stdContext), weldProcessor); } catch (Exception e) { throw TomcatLogger.LOG.cannotCreatWeldForwardingAnnotationProcessor(e); } }
private static StandardContext getStandardContext(ServletContext context) { try { // Hack into Tomcat to replace the InstanceManager using // reflection to access private fields ApplicationContext appContext = (ApplicationContext) getContextFieldValue((ApplicationContextFacade) context, ApplicationContextFacade.class); return (StandardContext) getContextFieldValue(appContext, ApplicationContext.class); } catch (Exception e) { throw TomcatLogger.LOG.cannotGetStandardContext(e); } }
public void initialize(ContainerContext context) { try { WeldForwardingInstanceManager.replaceInstanceManager(context.getServletContext(), context.getManager()); if(Boolean.TRUE.equals(context.getServletContext().getAttribute(EnhancedListener.ENHANCED_LISTENER_USED_ATTRIBUTE_NAME))) { TomcatLogger.LOG.allInjectionsAvailable(); } else { TomcatLogger.LOG.listenersInjectionsNotAvailable(); } } catch (Exception e) { TomcatLogger.LOG.unableToReplaceTomcat(e); } } }
private static void setInstanceManager(StandardContext stdContext, InstanceManager instanceManager) { try { Method method = SecurityActions.lookupMethod(stdContext.getClass(), INSTANCE_MANAGER_SETTER_NAME, InstanceManager.class); SecurityActions.ensureAccessible(method); try { method.invoke(stdContext, instanceManager); return; } catch (Exception e) { TomcatLogger.LOG.errorInvokingMethod(method.getName(), stdContext, instanceManager); } } catch (NoSuchMethodException e1) { // Getter/setter not found } try { Field field = SecurityActions.lookupField(stdContext.getClass(), INSTANCE_MANAGER_FIELD_NAME); SecurityActions.ensureAccessible(field); try { field.set(stdContext, instanceManager); return; } catch (Exception e) { TomcatLogger.LOG.errorWritingField(field.getName(), stdContext, instanceManager); } } catch (NoSuchFieldException e1) { // Field not found } throw TomcatLogger.LOG.neitherFieldNorGetterSetterFound(stdContext.getClass()); }
private static StandardContext getStandardContext(ServletContext context) { try { // Hack into Tomcat to replace the InstanceManager using // reflection to access private fields ApplicationContext appContext = (ApplicationContext) getContextFieldValue((ApplicationContextFacade) context, ApplicationContextFacade.class); return (StandardContext) getContextFieldValue(appContext, ApplicationContext.class); } catch (Exception e) { throw TomcatLogger.LOG.cannotGetStandardContext(e); } }