congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ContextualInstanceStrategy
Code IndexAdd Tabnine to your IDE (free)

How to use
ContextualInstanceStrategy
in
org.jboss.weld.bean

Best Java code snippets using org.jboss.weld.bean.ContextualInstanceStrategy (Showing top 20 results out of 315)

Refine searchRefine arrow

  • RIBean
  • ContextualInstance
origin: org.jboss.weld.se/weld-se

protected RIBean(BeanAttributes<T> attributes, BeanIdentifier identifier, BeanManagerImpl beanManager) {
  super(attributes, identifier);
  this.beanManager = beanManager;
  this.contextualInstanceStrategy = ContextualInstanceStrategy.create(attributes, beanManager);
}
origin: weld/core

  private static <T> ContextualInstanceStrategy<T> getStrategy(Bean<T> bean) {
    if (bean instanceof RIBean<?>) {
      return ((RIBean<T>) bean).getContextualInstanceStrategy();
    }
    return ContextualInstanceStrategy.defaultStrategy();
  }
}
origin: weld/core

  @Override
  public void destroy(T instance, CreationalContext<T> creationalContext) {
    contextualInstanceStrategy.destroy(this);
  }
}
origin: weld/core

/**
 * Shortcut for obtaining contextual instances with semantics equivalent to:
 * <code>
 * manager.getContext(bean.getScope()).get(bean);
 * </code>
 * @param bean the given bean
 * @param manager the beanManager
 * @return contextual instance of a given bean or null if none exists
 */
public static <T> T getIfExists(Bean<T> bean, BeanManagerImpl manager) {
  return getStrategy(bean).getIfExists(bean, manager);
}
origin: org.jboss.weld.se/weld-se

public static <T> T getIfExists(RIBean<T> bean, BeanManagerImpl manager) {
  return bean.getContextualInstanceStrategy().getIfExists(bean, manager);
}
origin: weld/core

public static <T> T get(RIBean<T> bean, BeanManagerImpl manager, CreationalContext<?> ctx) {
  return bean.getContextualInstanceStrategy().get(bean, manager, ctx);
}
origin: weld/core

/**
 * Shortcut for obtaining contextual instances with semantics equivalent to:
 * <code>
 * if (ctx == null) {
 *     ctx = manager.createCreationalContext(bean);
 * }
 * manager.getContext(bean.getScope()).get(bean, ctx);
 * </code>
 *
 * @param bean the given bean
 * @param manager the beanManager
 * @param ctx {@link CreationalContext} to be used for creation of a new instance - may be null
 * @return contextual instance of a given bean
 */
public static <T> T get(Bean<T> bean, BeanManagerImpl manager, CreationalContext<?> ctx) {
  return getStrategy(bean).get(bean, manager, ctx);
}
origin: org.jboss.weld.se/weld-se

public static <T> ContextualInstanceStrategy<T> create(BeanAttributes<T> bean, BeanManagerImpl manager) {
  if (ApplicationScoped.class == bean.getScope() || Singleton.class == bean.getScope()) {
    return new ApplicationScopedContextualInstanceStrategy<T>();
  } else if (CachingContextualInstanceStrategy.CACHEABLE_SCOPES.contains(bean.getScope())) {
    return new CachingContextualInstanceStrategy<T>();
  }
  return defaultStrategy();
}
origin: org.jboss.weld.se/weld-se

/**
 * Shortcut for obtaining contextual instances with semantics equivalent to:
 * <code>
 * manager.getContext(bean.getScope()).get(bean);
 * </code>
 * @param bean the given bean
 * @param manager the beanManager
 * @return contextual instance of a given bean or null if none exists
 */
public static <T> T getIfExists(Bean<T> bean, BeanManagerImpl manager) {
  return getStrategy(bean).getIfExists(bean, manager);
}
origin: weld/core

public static <T> T getIfExists(RIBean<T> bean, BeanManagerImpl manager) {
  return bean.getContextualInstanceStrategy().getIfExists(bean, manager);
}
origin: weld/core

public static <T> T get(RIBean<T> bean, BeanManagerImpl manager, CreationalContext<?> ctx) {
  return bean.getContextualInstanceStrategy().get(bean, manager, ctx);
}
origin: org.jboss.weld.servlet/weld-servlet-shaded

/**
 * Shortcut for obtaining contextual instances with semantics equivalent to:
 * <code>
 * if (ctx == null) {
 *     ctx = manager.createCreationalContext(bean);
 * }
 * manager.getContext(bean.getScope()).get(bean, ctx);
 * </code>
 *
 * @param bean the given bean
 * @param manager the beanManager
 * @param ctx {@link CreationalContext} to be used for creation of a new instance - may be null
 * @return contextual instance of a given bean
 */
public static <T> T get(Bean<T> bean, BeanManagerImpl manager, CreationalContext<?> ctx) {
  return getStrategy(bean).get(bean, manager, ctx);
}
origin: weld/core

public static <T> ContextualInstanceStrategy<T> create(BeanAttributes<T> bean, BeanManagerImpl manager) {
  if (ApplicationScoped.class == bean.getScope() || Singleton.class == bean.getScope()) {
    return new ApplicationScopedContextualInstanceStrategy<T>();
  } else if (CachingContextualInstanceStrategy.CACHEABLE_SCOPES.contains(bean.getScope())) {
    return new CachingContextualInstanceStrategy<T>();
  }
  return defaultStrategy();
}
origin: org.jboss.weld.servlet/weld-servlet-shaded

  private static <T> ContextualInstanceStrategy<T> getStrategy(Bean<T> bean) {
    if (bean instanceof RIBean<?>) {
      return ((RIBean<T>) bean).getContextualInstanceStrategy();
    }
    return ContextualInstanceStrategy.defaultStrategy();
  }
}
origin: weld/core

/**
 * Shortcut for obtaining contextual instances with semantics equivalent to:
 * <code>
 * manager.getContext(bean.getScope()).get(bean);
 * </code>
 * @param bean the given bean
 * @param manager the beanManager
 * @return contextual instance of a given bean or null if none exists
 */
public static <T> T getIfExists(Bean<T> bean, BeanManagerImpl manager) {
  return getStrategy(bean).getIfExists(bean, manager);
}
origin: weld/core

public static <T> T getIfExists(RIBean<T> bean, BeanManagerImpl manager) {
  return bean.getContextualInstanceStrategy().getIfExists(bean, manager);
}
origin: weld/core

public static <T> T get(RIBean<T> bean, BeanManagerImpl manager, CreationalContext<?> ctx) {
  return bean.getContextualInstanceStrategy().get(bean, manager, ctx);
}
origin: weld/core

/**
 * Shortcut for obtaining contextual instances with semantics equivalent to:
 * <code>
 * if (ctx == null) {
 *     ctx = manager.createCreationalContext(bean);
 * }
 * manager.getContext(bean.getScope()).get(bean, ctx);
 * </code>
 *
 * @param bean the given bean
 * @param manager the beanManager
 * @param ctx {@link CreationalContext} to be used for creation of a new instance - may be null
 * @return contextual instance of a given bean
 */
public static <T> T get(Bean<T> bean, BeanManagerImpl manager, CreationalContext<?> ctx) {
  return getStrategy(bean).get(bean, manager, ctx);
}
origin: weld/core

protected RIBean(BeanAttributes<T> attributes, BeanIdentifier identifier, BeanManagerImpl beanManager) {
  super(attributes, identifier);
  this.beanManager = beanManager;
  this.contextualInstanceStrategy = ContextualInstanceStrategy.create(attributes, beanManager);
}
origin: weld/core

public static <T> ContextualInstanceStrategy<T> create(BeanAttributes<T> bean, BeanManagerImpl manager) {
  if (ApplicationScoped.class == bean.getScope() || Singleton.class == bean.getScope()) {
    return new ApplicationScopedContextualInstanceStrategy<T>();
  } else if (CachingContextualInstanceStrategy.CACHEABLE_SCOPES.contains(bean.getScope())) {
    return new CachingContextualInstanceStrategy<T>();
  }
  return defaultStrategy();
}
org.jboss.weld.beanContextualInstanceStrategy

Javadoc

This component allows optimized strategies for obtaining contextual instances of a given bean to be plugged in. By default a contextual instance of a bean is obtained by first obtaining the context for bean's scope and then by calling Context#get(javax.enterprise.context.spi.Contextual) or Context#get(javax.enterprise.context.spi.Contextual,CreationalContext)on the given context. This algorithm matches the #defaultStrategy() implementation. In addition, specialized implementations are provided. For ApplicationScoped beans a special strategy is used which caches application-scoped bean instances in a volatile field. This implementation respects the possibility of an instance being destroyed via AlterableContext and the cached instance is flushed in such case. For SessionScoped, ConversationScoped and RequestScoped beans a special strategy is used which caches contextual bean instances in a ThreadLocal. This implementation respects the possibility of an instance being destroyed via AlterableContext and the cached instance is flushed in such case. This is done indirectly by RequestScopedCache.

Most used methods

  • create
  • defaultStrategy
  • destroy
  • get
  • getIfExists

Popular in Java

  • Start an intent from android
  • getSharedPreferences (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • getExternalFilesDir (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Github Copilot alternatives
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