Codota Logo
PetiteContainer.registerPetiteBean
Code IndexAdd Codota to your IDE (free)

How to use
registerPetiteBean
method
in
jodd.petite.PetiteContainer

Best Java code snippets using jodd.petite.PetiteContainer.registerPetiteBean (Showing top 20 results out of 315)

  • Common ways to obtain PetiteContainer
private void myMethod () {
PetiteContainer p =
  • Codota Iconnew PetiteContainer()
  • Smart code suggestions by Codota
}
origin: oblac/jodd

/**
 * Registers Madvoc component with given name.
 */
public <T> void registerComponent(final String name, final Class<T> component, final Consumer<T> consumer) {
  log.debug(() -> "Madvoc WebApp component: [" + name + "] --> " + component.getName());
  madpc.removeBean(name);
  madpc.registerPetiteBean(component, name, null, null, false, consumer);
}
origin: oblac/jodd

/**
 * Adds object instance to the container as singleton bean.
 */
public void addBean(final String name, final Object bean, WiringMode wiringMode) {
  wiringMode = petiteConfig.resolveWiringMode(wiringMode);
  registerPetiteBean(bean.getClass(), name, SingletonScope.class, wiringMode, false, null);
  BeanDefinition def = lookupExistingBeanDefinition(name);
  registerBeanAndWireAndInjectParamsAndInvokeInitMethods(new BeanData(this, def, bean));
}
origin: oblac/jodd

@Test
void testWireMode_strict() {
  PetiteContainer pc = new PetiteContainer();
  final WiringMode wiringMode = WiringMode.STRICT;
  pc.registerPetiteBean(Green.class, null, null, wiringMode, false, null);
  pc.registerPetiteBean(Blue.class, null, null, wiringMode, false, null);
  pc.registerPetiteBean(Yellow.class, null, null, wiringMode, false, null);
  assertThrows(PetiteException.class, () -> pc.getBean("green"));
}
origin: oblac/jodd

@BeforeEach
void setupPetiteContainer() {
  PetiteConfig petiteConfig = PetiteHelper.createPetiteConfig();
  ProxyProxetta proxyProxetta = PetiteHelper.createProxyProxetta();
  petiteContainer = new PetiteProxettaContainer(proxyProxetta, petiteConfig);
  //AutomagicPetiteConfigurator petiteConfigurator = new AutomagicPetiteConfigurator();
  //petiteConfigurator.configure(petiteContainer);
  petiteContainer.registerPetiteBean(Bean1.class);
  petiteContainer.registerPetiteBean(Bean2.class);
}
origin: oblac/jodd

@Test
void test244() {
  PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(BeanOne.class, null, null, null, false, null);
  pc.registerPetiteBean(BeanTwo.class, null, null, null, false, null);
  BeanOne petiteBean = pc.getBean(BeanOne.class);
  assertTrue(petiteBean.ctor != petiteBean.setter);
}
origin: oblac/jodd

  @Test
  void testPrivateInjection() {
    PetiteContainer pc = new PetiteContainer();

    pc.registerPetiteBean(Loo.class);
    pc.registerPetiteBean(YujinpingBaseService.class);
    pc.registerPetiteBean(YujinpingUserService.class);

    YujinpingUserService service = pc.getBean(YujinpingUserService.class);

    assertTrue(service.check2());
    assertTrue(service.check());
  }
}
origin: oblac/jodd

  @Test
  void testConsumer() {
    PetiteContainer pc = new PetiteContainer();
    pc.registerPetiteBean(SomeService.class, null, null, null, false, null);
    pc.registerPetiteBean(PojoBean.class, "pojo", null, null, false, pb -> pb.count = 7);
    pc.registerPetiteCtorInjectionPoint("pojo", null, null);

    PojoBean pb = pc.getBean("pojo");
    assertEquals(7, pb.count);
  }
}
origin: oblac/jodd

@Test
void testInstanceStaticMethodProvider() {
  PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(Solar3.class, null, null, null, false, null);	// still needs to be a bean
  pc.registerPetiteBean(Sun.class, null, null, null, false, null);
  Sun sun = pc.getBean(Sun.class);
  assertEquals("Sun{Earth}", sun.toString());
}
origin: oblac/jodd

@Test
void testSingletonDestroyMethods() {
  PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(Foo.class, null, null, null, false, null);
  pc.registerPetiteBean(Zoo.class, null, null, null, false, null);
  pc.registerPetiteBean(Boo.class, null, null, null, false, null);
  Boo boo = (Boo) pc.getBean("boo");
  assertEquals(0, boo.getCount2());
  pc.shutdown();
  assertEquals(2, boo.getCount2());
}
origin: oblac/jodd

@Test
void testCollection() {
  final PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(Superman.class, null, null, null, false, null);
  pc.registerPetiteBean(Metropolis.class, null, null, null, false, null);
  Metropolis metropolis = pc.getBean(Metropolis.class);
  assertNotNull(metropolis.superHeros);
  assertFalse(metropolis.superHeros.isEmpty());
  assertEquals(1, metropolis.superHeros.size());
  String str = metropolis.whoIsThere();
  assertTrue(str.contains("Superman"));
}
origin: oblac/jodd

@Test
void testOneHero() {
  final PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(Batman.class, null, null, null, false, null);
  pc.registerPetiteBean(GothamCity.class, null, null, null, false, null);
  GothamCity gothamCity = pc.getBean(GothamCity.class);
  assertNotNull(gothamCity.superHeros);
  assertFalse(gothamCity.superHeros.isEmpty());
  assertEquals(1, gothamCity.superHeros.size());
  String str = gothamCity.whoIsThere();
  assertEquals("Batman", str);
}
origin: oblac/jodd

@Test
void testInstanceMethodProviderManualRegistration() {
  PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(Solar2.class, null, null, null, false, null);
  pc.registerPetiteBean(Sun2.class, null, null, null, false, null);
  pc.registerPetiteProvider("planet", "solar2", "planetProvider", ClassUtil.EMPTY_CLASS_ARRAY);
  pc.registerPetitePropertyInjectionPoint("sun2", "planet", null);
  Sun2 sun = pc.getBean(Sun2.class);
  assertEquals("Sun{Earth}", sun.toString());
}
origin: oblac/jodd

  @Test
  void testShutdown() {
    PetiteContainer pc = new PetiteContainer();

    pc.registerPetiteBean(SomeService.class, null, null, null, false, null);
    pc.registerPetiteBean(PojoBean.class, "pojo", null, null, false, null);

    assertEquals(2, pc.beansCount());

    pc.shutdown();

    assertEquals(0, pc.beansCount());
  }
}
origin: oblac/jodd

  @Test
  void testSingleImplementation() {
    final PetiteContainer pc = new PetiteContainer();
    pc.registerPetiteBean(BizUser.class, null, null, null, false, null);
    pc.registerPetiteBean(OneBiz.class, null, null, null, false, null);
    assertEquals(2, pc.beansCount());

    final BizUser bizUser = pc.getBean(BizUser.class);
    assertNotNull(bizUser);
    assertNotNull(bizUser.biz);
    assertTrue(bizUser.biz instanceof OneBiz);
  }
}
origin: oblac/jodd

@Test
void testProviderLookup() {
  PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(Solar3.class, null, null, null, false, null);
  Planet earth = pc.getBean("planet");
  assertEquals("Earth", earth.toString());
}
origin: oblac/jodd

@Test
void testGet() {
  PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(PojoBean2.class, null, null, null, false, null);
  PojoBean2 pojo2 = pc.getBean("pojoBean2");
  pojo2.setVal1("value");
  pojo2.setVal2(Integer.valueOf(173));
  pc.setBeanProperty("pojoBean2.val1", "value");
  pc.setBeanProperty("pojoBean2.val2", "173");
  assertEquals("value", pc.getBeanProperty("pojoBean2.val1"));
  assertEquals(Integer.valueOf(173), pc.getBeanProperty("pojoBean2.val2"));
}
origin: oblac/jodd

@Test
void testSet() {
  PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(PojoBean2.class, null, null, null, false, null);
  pc.setBeanProperty("pojoBean2.val1", "value");
  pc.setBeanProperty("pojoBean2.val2", "173");
  PojoBean2 pojo2 = pc.getBean("pojoBean2");
  assertEquals("value", pojo2.getVal1());
  assertEquals(173, pojo2.getVal2().intValue());
}
origin: oblac/jodd

@Test
void testSimpleParams() {
  PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(Foo.class, null, null, null, false, null);
  pc.defineParameter("foo.name", "FOONAME");
  Foo foo = pc.getBean("foo");
  assertNotNull(foo);
  assertEquals("FOONAME", foo.getName());
}
origin: oblac/jodd

@Test
void testEmptyParam() {
  final PetiteContainer pc = new PetiteContainer();
  pc.registerPetiteBean(Val.class, null, null, null, false, null);
  pc.config().setImplicitParamInjection(false);
  pc.defineParameter("someValue", "173");
  pc.defineParameter("justValue", "aaa");
  Val val = pc.getBean("val");
  assertNotNull(val);
  assertEquals("aaa", val.getJustValue());
}
origin: oblac/jodd

@Test
void testRefParamsNoResolve() {
  PetiteContainer pc = new PetiteContainer();
  pc.config().setResolveReferenceParameters(false);
  pc.registerPetiteBean(Foo.class, null, null, null, false, null);
  pc.defineParameter("foo.name", "${name}");
  pc.defineParameter("name", "${name2}");
  pc.defineParameter("name2", "FOONAME");
  Foo foo = pc.getBean("foo");
  assertNotNull(foo);
  assertEquals("${name}", foo.getName());
}
jodd.petitePetiteContainerregisterPetiteBean

Popular methods of PetiteContainer

  • addBean
    Adds object instance to the container as singleton bean.
  • getBean
    Returns Petite bean instance named as one of the provided names.
  • createBean
    Creates and wires a bean within the container and optionally invokes init methods. However, bean isn
  • defineParameters
  • wire
    Wires provided bean with the container and optionally invokes init methods. Bean is not registered.
  • <init>
    Creates new Petite container using PetiteContainer.
  • addSelf
    Adds self instance to the container so internal beans may fetch container for further usage. No wiri
  • lookupBeanDefinition
  • resolveBeanName
  • shutdown
    Shutdowns container. After container is down, it can't be used anymore.
  • beansCount
  • config
  • beansCount,
  • config,
  • createBeanDefinitionForRegistration,
  • forEachBeanType,
  • lookupExistingBeanDefinition,
  • registerPetiteCtorInjectionPoint,
  • registerPetiteInitMethods,
  • registerPetiteMethodInjectionPoint,
  • registerPetitePropertyInjectionPoint

Popular in Java

  • Reactive rest calls using spring rest template
  • notifyDataSetChanged (ArrayAdapter)
  • addToBackStack (FragmentTransaction)
  • setContentView (Activity)
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • ResourceBundle (java.util)
    Resource bundles contain locale-specific objects. When your program needs a locale-specific resource
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • TreeMap (java.util)
    A Red-Black tree based NavigableMap implementation. The map is sorted according to the Comparable of
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now