Tabnine Logo
BeanDefinition
Code IndexAdd Tabnine to your IDE (free)

How to use
BeanDefinition
in
jodd.petite

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

origin: oblac/jodd

  if (bd1.name().startsWith(prefix)) {
    if (bd2.name().startsWith(prefix)) {
      return bd1.name().compareTo(bd2.name());
  if (bd2.name().startsWith(prefix)) {
    if (bd1.name().startsWith(prefix)) {
      return bd1.name().compareTo(bd2.name());
  return bd1.name().compareTo(bd2.name());
})
.forEach(beanDefinition -> {
    Chalk256.chalk().green(), beanDefinition.name(),
    Chalk256.chalk().blue(), ClassUtil.getShortClassName(beanDefinition.type(), 2),
    width - 10 - 1
  );
origin: oblac/jodd

/**
 * Creates {@link jodd.petite.BeanDefinition} on
 * {@link #registerPetiteBean(Class, String, Class, WiringMode, boolean, Consumer) bean registration}.
 * This is a hook for modifying the bean data, like passing proxifed class etc.
 * By default returns new instance of {@link jodd.petite.BeanDefinition}.
 */
protected <T> BeanDefinition createBeanDefinitionForRegistration(
    final String name,
    final Class<T> type,
    final Scope scope,
    final WiringMode wiringMode,
    final Consumer<T> consumer) {
  return new BeanDefinition<>(name, type, scope, wiringMode, consumer);
}
origin: oblac/jodd

/**
 * Registers property injection point.
 *
 * @param beanName bean name
 * @param property property name
 * @param reference explicit injection reference, may be <code>null</code>
 */
public void registerPetitePropertyInjectionPoint(final String beanName, final String property, final String reference) {
  BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
  ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
  PropertyDescriptor propertyDescriptor = cd.getPropertyDescriptor(property, true);
  if (propertyDescriptor == null) {
    throw new PetiteException("Property not found: " + beanDefinition.type.getName() + '#' + property);
  }
  BeanReferences ref = referencesResolver.resolveReferenceFromValue(propertyDescriptor, reference);
  PropertyInjectionPoint pip = new PropertyInjectionPoint(propertyDescriptor, ref);
  beanDefinition.addPropertyInjectionPoint(pip);
}
origin: oblac/jodd

@Override
public void register(final BeanDefinition beanDefinition, final Object bean) {
  instances.put(beanDefinition.name(), new BeanData(pc, beanDefinition, bean));
}
origin: oblac/jodd

Class type = beanDefinition.type();
origin: org.jodd/jodd-wot

bean = def.scopeLookup();
if (bean == null) {
  injectParams(bean, def);
  invokeInitMethods(bean, def, Boolean.FALSE);
  def.scopeRegister(bean);
origin: oblac/jodd

/**
 * Registers scope.
 */
public void scopeRegister() {
  beanDefinition.scopeRegister(bean);
}
origin: oblac/jodd

/**
 * Removes bean and returns definition of removed bean.
 * All resolvers references are deleted, too.
 * Returns bean definition of removed bean or <code>null</code>.
 */
public BeanDefinition removeBean(final String name) {
  BeanDefinition bd = beans.remove(name);
  if (bd == null) {
    return null;
  }
  bd.scopeRemove();
  return bd;
}
origin: oblac/jodd

/**
 * Registers set injection point.
 *
 * @param beanName bean name
 * @param property set property name
 */
public void registerPetiteSetInjectionPoint(final String beanName, final String property) {
  BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
  ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
  PropertyDescriptor propertyDescriptor = cd.getPropertyDescriptor(property, true);
  if (propertyDescriptor == null) {
    throw new PetiteException("Property not found: " + beanDefinition.type.getName() + '#' + property);
  }
  SetInjectionPoint sip = new SetInjectionPoint(propertyDescriptor);
  beanDefinition.addSetInjectionPoint(sip);
}
origin: oblac/jodd

/**
 * Registers init method.
 *
 * @param beanName bean name
 * @param invocationStrategy moment of invocation
 * @param initMethodNames init method names
 */
public void registerPetiteInitMethods(final String beanName, final InitMethodInvocationStrategy invocationStrategy, String... initMethodNames) {
  BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
  ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
  if (initMethodNames == null) {
    initMethodNames = StringPool.EMPTY_ARRAY;
  }
  int total = initMethodNames.length;
  InitMethodPoint[] initMethodPoints = new InitMethodPoint[total];
  int i;
  for (i = 0; i < initMethodNames.length; i++) {
    MethodDescriptor md = cd.getMethodDescriptor(initMethodNames[i], ClassUtil.EMPTY_CLASS_ARRAY, true);
    if (md == null) {
      throw new PetiteException("Init method not found: " + beanDefinition.type.getName() + '#' + initMethodNames[i]);
    }
    initMethodPoints[i] = new InitMethodPoint(md.getMethod(), i, invocationStrategy);
  }
  beanDefinition.addInitMethodPoints(initMethodPoints);
}
origin: oblac/jodd

beanDefinition.addMethodInjectionPoint(mip);
origin: oblac/jodd

/**
 * Returns Petite bean instance.
 * Petite container will find the bean in corresponding scope and all its dependencies,
 * either by constructor or property injection. When using constructor injection, cyclic dependencies
 * can not be prevented, but at least they are detected.
 *
 * @see PetiteContainer#createBean(Class)
 */
public <T> T getBean(final String name) {
  // Lookup for registered bean definition.
  BeanDefinition def = lookupBeanDefinition(name);
  if (def == null) {
    // try provider
    ProviderDefinition providerDefinition = providers.get(name);
    if (providerDefinition != null) {
      return (T) invokeProvider(providerDefinition);
    }
    return null;
  }
  // Find the bean in its scope
  Object bean = def.scopeLookup();
  if (bean == null) {
    // Create new bean in the scope
    initBeanDefinition(def);
    final BeanData beanData = new BeanData(this, def);
    registerBeanAndWireAndInjectParamsAndInvokeInitMethods(beanData);
    bean = beanData.bean();
  }
  return (T) bean;
}
origin: oblac/jodd

@Override
public void register(final BeanDefinition beanDefinition, final Object bean) {
  Map<String, BeanData> threadLocalMap = context.get();
  threadLocalMap.put(beanDefinition.name(), new BeanData(pc, beanDefinition, bean));
}
origin: oblac/jodd

beanDefinition.ctor = petiteResolvers.resolveCtorInjectionPoint(beanDefinition.type());
beanDefinition.properties = PropertyInjectionPoint.EMPTY;
beanDefinition.methods = MethodInjectionPoint.EMPTY;
origin: org.jodd/jodd-petite

/**
 * Registers scope.
 */
public void scopeRegister() {
  beanDefinition.scopeRegister(bean);
}
origin: org.jodd/jodd-petite

/**
 * Removes bean and returns definition of removed bean.
 * All resolvers references are deleted, too.
 * Returns bean definition of removed bean or <code>null</code>.
 */
public BeanDefinition removeBean(final String name) {
  BeanDefinition bd = beans.remove(name);
  if (bd == null) {
    return null;
  }
  bd.scopeRemove();
  return bd;
}
origin: org.jodd/jodd-wot

/**
 * Single point of property injection point registration.
 */
protected void registerPetiteSetInjectionPoint(String beanName, String property) {
  BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
  SetInjectionPoint sip = defineSetInjectionPoint(
      beanDefinition.type,
      property);
  beanDefinition.addSetInjectionPoint(sip);
}
origin: org.jodd/jodd-wot

/**
 * Single point of init method registration.
 */
protected void registerPetiteInitMethods(String beanName, String[] beforeMethodNames, String[] afterMethodNames) {
  BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
  InitMethodPoint[] methods = defineInitMethods(beanDefinition.type, beforeMethodNames, afterMethodNames);
  beanDefinition.addInitMethodPoints(methods);
}
origin: org.jodd/jodd-wot

/**
 * Single point of method injection point registration.
 */
protected void registerPetiteMethodInjectionPoint(String beanName, String methodName, Class[] arguments, String[] references) {
  BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
  String[][] ref = PetiteUtil.convertRefToReferences(references);
  MethodInjectionPoint mip = defineMethodInjectionPoint(beanDefinition.type, methodName, arguments, ref);
  beanDefinition.addMethodInjectionPoint(mip);
}
origin: org.jodd/jodd-petite

/**
 * Returns Petite bean instance.
 * Petite container will find the bean in corresponding scope and all its dependencies,
 * either by constructor or property injection. When using constructor injection, cyclic dependencies
 * can not be prevented, but at least they are detected.
 *
 * @see PetiteContainer#createBean(Class)
 */
public <T> T getBean(final String name) {
  // Lookup for registered bean definition.
  BeanDefinition def = lookupBeanDefinition(name);
  if (def == null) {
    // try provider
    ProviderDefinition providerDefinition = providers.get(name);
    if (providerDefinition != null) {
      return (T) invokeProvider(providerDefinition);
    }
    return null;
  }
  // Find the bean in its scope
  Object bean = def.scopeLookup();
  if (bean == null) {
    // Create new bean in the scope
    initBeanDefinition(def);
    final BeanData beanData = new BeanData(this, def);
    registerBeanAndWireAndInjectParamsAndInvokeInitMethods(beanData);
    bean = beanData.bean();
  }
  return (T) bean;
}
jodd.petiteBeanDefinition

Javadoc

Petite bean definition and cache. Consist of bean data that defines a bean and cache, that might not be initialized (if null). To initialize cache, get the bean instance from container.

Most used methods

  • name
    Returns bean name.
  • type
    Returns bean type.
  • <init>
  • addInitMethodPoints
    Adds init methods.
  • addMethodInjectionPoint
    Adds method injection point.
  • addPropertyInjectionPoint
    Adds property injection point.
  • addSetInjectionPoint
    Adds set injection point.
  • scopeLookup
    Delegates to jodd.petite.scope.Scope#lookup(String).
  • scopeRegister
    Delegates to jodd.petite.scope.Scope#register(jodd.petite.BeanDefinition,Object)if scope is defined.
  • scopeRemove
    Delegates to jodd.petite.scope.Scope#remove(String).
  • addDestroyMethodPoints
    Adds destroy methods.
  • consumer
    Returns an optional consumer.
  • addDestroyMethodPoints,
  • consumer,
  • destroyMethodPoints,
  • initMethodPoints,
  • scope

Popular in Java

  • Running tasks concurrently on multiple threads
  • runOnUiThread (Activity)
  • setRequestProperty (URLConnection)
  • getSupportFragmentManager (FragmentActivity)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Path (java.nio.file)
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • JPanel (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now