final ScopeData scopeData = scopeDataInspector.inspectClassScopes(actionClass); final ScopeData paramsScopeData = scopeDataInspector.inspectMethodParameterScopes(paramName, paramType, parameterAnnotations); paramTypes[ndx], paramName, scopeDataInspector.detectAnnotationType(parameterAnnotations), paramsScopeData, mapperFunction
final Class<? extends MadvocScope> scope = resolveScopeClassFromAnnotations(annotations); final InjectionPoint scopeDataIn = buildInjectionPoint(in.value(), name, type, scope); if (scopeDataIn != null) { count++; final InjectionPoint scopeDataOut = buildInjectionPoint(out.value(), name, type, scope); if (scopeDataOut != null) { count++;
@Test void testInAnnotations() { ScopeDataInspector scopeDataInspector = new ScopeDataInspector(); PetiteContainer madpc = new PetiteContainer(); scopeDataInspector.scopeResolver = new ScopeResolver(); scopeDataInspector.scopeResolver.madpc = madpc; madpc.addBean("madvocEncoding", new MadvocEncoding()); ScopeData scopeData = scopeDataInspector.inspectClassScopes(Action.class); InjectionPoint[] in1 = scopeData.in(); InjectionPoint in = in1[0]; assertEquals("input", in.name()); assertEquals(String.class, in.type()); }
/** * Cached version of {@link #inspectClassScopes(Class)}. Use it in runtime when * configuration is not known yet. */ public ScopeData inspectClassScopesWithCache(final Class actionClass) { return scopeDataTypeCache.get(actionClass, () -> inspectClassScopes(actionClass)); }
/** * Inject context into target. */ public void injectContext(final Object targetObject) { final Class targetType = targetObject.getClass(); final ScopeData scopeData = scopeDataInspector.inspectClassScopesWithCache(targetType); final Targets targets = new Targets(targetObject, scopeData); // inject no context scopeResolver.forEachScope(madvocScope -> madvocScope.inject(targets)); // inject special case scopeResolver.forScope(ParamsScope.class, scope -> scope.inject(targets)); // inject servlet context final ServletContext servletContext = madvocController.getApplicationContext(); if (servletContext != null) { scopeResolver.forEachScope(madvocScope -> madvocScope.inject(servletContext, targets)); } }
private InterceptorsManager createInterceptorManager() { PetiteContainer madpc = new PetiteContainer(); madpc.addSelf("madpc"); madpc.addBean("madvocEncoding", new MadvocEncoding()); InterceptorsManager im = new InterceptorsManager(); im.contextInjectorComponent = new ContextInjectorComponent(); im.contextInjectorComponent.madvocController = new MadvocController(); im.contextInjectorComponent.madvocController.servletContextProvider = new ServletContextProvider(null); im.contextInjectorComponent.scopeDataInspector = new ScopeDataInspector(); im.contextInjectorComponent.scopeResolver = new ScopeResolver(); im.contextInjectorComponent.scopeResolver.madpc = madpc; return im; }
@Test void testGenericAction() { ScopeDataInspector scopeDataInspector = new ScopeDataInspector(); PetiteContainer madpc = new PetiteContainer(); scopeDataInspector.scopeResolver = new ScopeResolver(); scopeDataInspector.scopeResolver.madpc = madpc; madpc.addBean("madvocEncoding", new MadvocEncoding()); ScopeData scopeData = scopeDataInspector.inspectClassScopes(GenAction.class); InjectionPoint[] in1 = scopeData.in(); InjectionPoint[] out1 = scopeData.out(); InjectionPoint in = in1[0]; InjectionPoint out = out1[0]; assertEquals("input", in.name()); assertEquals(String.class, in.type()); assertEquals("output", out.name()); assertEquals(Integer.class, out.type()); }
final ScopeData newScopeData = methodParam.scopeData().inspector().inspectClassScopesWithCache(paramType); paramTarget = Target.ofValue(createActionMethodArgument(paramType, action), newScopeData);
scope = resolveScopeClassFromAnnotations(field.getAnnotations()); scope = resolveScopeClassFromAnnotations(method.getAnnotations()); scope = resolveScopeClassFromAnnotations(method.getAnnotations()); final InjectionPoint ii = in == null ? null : buildInjectionPoint(in.value(), pd.getName(), pd.getType(), scope); if (ii != null) { listIn.add(ii); final InjectionPoint oi = out == null ? null : buildInjectionPoint(out.value(), pd.getName(), pd.getType(), scope); if (oi != null) { listOut.add(oi);