/** * Adds object instance to the container as singleton bean using default * wiring mode and default init method flag. */ public void addBean(final String name, final Object bean) { addBean(name, bean, null); }
/** * Adds self instance to the container so internal beans may fetch * container for further usage. No wiring is used and no init methods are invoked. */ public void addSelf() { addBean(PETITE_CONTAINER_REF_NAME, this, WiringMode.NONE); }
/** * Adds self instance to the container so internal beans may fetch * container for further usage. No wiring is used and no init methods are invoked. */ public void addSelf(final String name) { addBean(name, this, WiringMode.NONE); }
/** * Registers component instance and wires it with internal container. * Warning: in this moment we can not guarantee that all other components * are registered, replaced or configuration is update; therefore DO NOT * USE injection, unless you are absolutely sure it works. */ public void registerComponentInstance(final String name, final Object componentInstance) { log.debug(() -> "Madvoc WebApp component: [" + name + "] --> " + componentInstance.getClass().getName()); madpc.removeBean(name); madpc.addBean(name, componentInstance); }
@Test void testScopeRegistration() { final ScopeResolver scopeResolver = new ScopeResolver(); scopeResolver.madpc = new PetiteContainer(); scopeResolver.madpc.addBean("madvocEncoding", new MadvocEncoding()); final MadvocScope requestScope = scopeResolver.defaultOrScopeType(RequestScope.class); final MadvocScope requestScope2 = scopeResolver.defaultOrScopeType(RequestScope.class); assertEquals(requestScope2, requestScope); final MyScope myScope = scopeResolver.defaultOrScopeType(MyScope.class); assertEquals(2, scopeResolver.allScopes.size()); }
@Test void testAdd() { PetiteContainer pc = new PetiteContainer(); Foo foo = new Foo(); pc.addBean("foo", foo); Foo foo2 = (Foo) pc.getBean("foo"); assertNotNull(foo2); assertSame(foo, foo2); }
@Test void testScopeClassLookup() { final ScopeResolver scopeResolver = new ScopeResolver(); scopeResolver.madpc = new PetiteContainer(); scopeResolver.madpc.addBean("madvocEncoding", new MadvocEncoding()); final MadvocScope madvocScope = scopeResolver.defaultOrScopeType(MyScope.class); assertNotNull(madvocScope); assertTrue(madvocScope instanceof MyScope); final MadvocScope madvocScope2 = scopeResolver.defaultOrScopeType(MyScope.class); assertEquals(madvocScope2, madvocScope); } }
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 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()); }
@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()); }
/** * Adds self instance to the container so internal beans may fetch * container for further usage. No wiring is used and no init methods are invoked. */ public void addSelf(String name) { addBean(name, this, WiringMode.NONE); }
/** * Adds self instance to the container so internal beans may fetch * container for further usage. No wiring is used and no init methods are invoked. */ public void addSelf() { addBean(PETITE_CONTAINER_REF_NAME, this, WiringMode.NONE); }
/** * Adds object instance to the container as singleton bean using default * wiring mode and default init method flag. */ public void addBean(final String name, final Object bean) { addBean(name, bean, null); }
/** * Adds object instance to the container as singleton bean using default * wiring mode and default init method flag. */ public void addBean(String name, Object bean) { addBean(name, bean, null); }
/** * Adds self instance to the container so internal beans may fetch * container for further usage. No wiring is used and no init methods are invoked. */ public void addSelf() { addBean(PETITE_CONTAINER_REF_NAME, this, WiringMode.NONE); }
/** * Adds self instance to the container so internal beans may fetch * container for further usage. No wiring is used and no init methods are invoked. */ public void addSelf(final String name) { addBean(name, this, WiringMode.NONE); }
/** * Registers component instance and wires it with internal container. */ public final void registerComponent(String name, Object componentInstance) { if (log.isDebugEnabled()) { log.debug("Registering component '" + name + "' instance of " + componentInstance.getClass().getName()); } madpc.removeBean(name); madpc.addBean(name, componentInstance); }