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

How to use
HaCdiCommons
in
org.hotswap.agent.plugin.cdi

Best Java code snippets using org.hotswap.agent.plugin.cdi.HaCdiCommons (Showing top 13 results out of 315)

origin: HotswapProjects/HotswapAgent

  /**
   * Add custom tracker field to session context
   *
   * @param ctClass the class
   * @throws NotFoundException the not found exception
   * @throws CannotCompileException the cannot compile exception
   */
  @OnClassLoadEvent(classNameRegexp = "org.jboss.weld.context.AbstractContext")
  public static void transformHttpSessionContext(ClassPool classPool, CtClass ctClass) throws NotFoundException, CannotCompileException {
    HaCdiCommons.transformContext(classPool, ctClass);
  }
}
origin: HotswapProjects/HotswapAgent

@SuppressWarnings("rawtypes")
private static void doReinjectRegisteredBeanInstances(BeanManagerImpl beanManager, AbstractClassBean bean) {
  for (Object instance: HaCdiCommons.getBeanInstances(bean)) {
    if (instance != null) {
      doCallInject(beanManager, bean, instance);
    }
  }
}
origin: HotswapProjects/HotswapAgent

/**
 * Add bean registry field to context, register bean instances in get(...) methods
 *
 * @param classPool the class pool
 * @param ctClass the ct class
 * @throws CannotCompileException the cannot compile exception
 * @throws NotFoundException the not found exception
 */
public static void transformContext(ClassPool classPool, CtClass ctClass) throws CannotCompileException, NotFoundException {
  addBeanRegistryToContext(classPool, ctClass);
  transformGet1(classPool, ctClass);
  transformGet2(classPool, ctClass);
  LOGGER.debug(ctClass.getName() + " - patched by bean registration.");
}
origin: HotswapProjects/HotswapAgent

private static void doReinjectBean(BeanManagerImpl beanManager, AbstractClassBean<?> bean) {
  try {
    if (!bean.getScope().equals(ApplicationScoped.class) && HaCdiCommons.isRegisteredScope(bean.getScope())) {
      doReinjectRegisteredBeanInstances(beanManager, bean);
    } else {
      doReinjectBeanInstance(beanManager, bean, beanManager.getContext(bean.getScope()));
    }
  } catch (Exception e) {
    if (e.getClass().getSimpleName().equals("ContextNotActiveException")) {
      LOGGER.info("No active contexts for bean '{}'", bean.getBeanClass().getName());
    } else {
      throw e;
    }
  }
}
origin: HotswapProjects/HotswapAgent

/**
 * Return all bean instances.
 *
 * @param bean the bean
 * @return the bean instances
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static List<Object> getBeanInstances(Bean<?> bean) {
  List<Object> result = new ArrayList<>();
  Class<? extends Context> contextClass = getContextClass(bean.getScope());
  Map beanRegistry = (Map) getBeanRegistry(contextClass);
  if (beanRegistry != null) {
    Map m = (Map) beanRegistry.get(bean.getBeanClass().getName());
    if (m != null) {
      result.addAll(m.keySet());
    } else {
      LOGGER.debug("BeanRegistry is empty for bean class '{}'", bean.getBeanClass().getName());
    }
  } else {
    LOGGER.error("BeanRegistry field not found in context class '{}'", contextClass.getName());
  }
  return result;
}
origin: HotswapProjects/HotswapAgent

/**
 * Checks if scope is registered
 *
 * @param scope the scope
 * @return true, if is registered scope
 */
public static boolean isRegisteredScope(Class<? extends Annotation> scope) {
  return getContextClass(scope) != null;
}
origin: HotswapProjects/HotswapAgent

private static void doReinjectBean(BeanManagerImpl beanManager, InjectionTargetBean<?> bean) {
  try {
    if (!bean.getScope().equals(ApplicationScoped.class) && HaCdiCommons.isRegisteredScope(bean.getScope())) {
      doReinjectRegisteredBeanInstances(beanManager, bean);
    } else {
      doReinjectBeanInstance(beanManager, bean, beanManager.getContext(bean.getScope()));
    }
  } catch (ContextNotActiveException e) {
    LOGGER.info("No active contexts for bean '{}'", bean.getBeanClass().getName());
  }
}
origin: HotswapProjects/HotswapAgent

  @OnClassLoadEvent(classNameRegexp = "org.apache.deltaspike.core.util.context.AbstractContext")
  public static void patchWindowContext(ClassPool classPool, CtClass ctClass) throws CannotCompileException, NotFoundException {
    HaCdiCommons.transformContext(classPool, ctClass);
  }
}
origin: HotswapProjects/HotswapAgent

@SuppressWarnings({ "unchecked", "rawtypes" })
private static void doReinjectRegisteredBeanInstances(BeanManagerImpl beanManager, InjectionTargetBean bean) {
  for (Object instance: HaCdiCommons.getBeanInstances(bean)) {
    if (instance != null) {
      bean.getProducer().inject(instance, beanManager.createCreationalContext(bean));
      LOGGER.info("Bean '{}' injection points was reinjected.", bean.getBeanClass().getName());
    } else {
      LOGGER.info("Unexpected 'null' bean instance in registry. bean='{}'", bean.getBeanClass().getName());
    }
  }
}
origin: HotswapProjects/HotswapAgent

@OnClassLoadEvent(classNameRegexp = "org.apache.myfaces.cdi.view.ViewScopeContextImpl")
public static void patchViewScopeContext(ClassPool classPool, CtClass ctClass) throws CannotCompileException, NotFoundException {
  HaCdiCommons.transformContext(classPool, ctClass);
}
origin: HotswapProjects/HotswapAgent

@OnClassLoadEvent(classNameRegexp = "org.omnifaces.cdi.viewscope.ViewScopeContext")
public static void patchViewScopeContext(ClassPool classPool, CtClass ctClass) throws CannotCompileException, NotFoundException {
  HaCdiCommons.transformContext(classPool, ctClass);
}
origin: HotswapProjects/HotswapAgent

@OnClassLoadEvent(classNameRegexp = "org.apache.webbeans.context.AbstractContext")
public static void transformAbstractContext(ClassPool classPool, CtClass ctClass) throws NotFoundException, CannotCompileException {
  HaCdiCommons.transformContext(classPool, ctClass);
}
origin: HotswapProjects/HotswapAgent

@OnClassLoadEvent(classNameRegexp = "com.sun.faces.application.view.ViewScopeContext")
public static void patchViewScopeContext(ClassPool classPool, CtClass ctClass) throws CannotCompileException, NotFoundException {
  HaCdiCommons.transformContext(classPool, ctClass);
}
org.hotswap.agent.plugin.cdiHaCdiCommons

Javadoc

Helper class for common names definition for CDI plugins

Most used methods

  • transformContext
    Add bean registry field to context, register bean instances in get(...) methods
  • getBeanInstances
    Return all bean instances.
  • isRegisteredScope
    Checks if scope is registered
  • addBeanRegistryToContext
    Adds the bean registry to context.
  • getBeanRegistry
  • getContextClass
    Gets the context class for specified scope.
  • getCurrentScopeToContextMap
  • getRegistrationCode
  • transformGet1
    Transform 1 argument get method :public T get(Contextual contextual);
  • transformGet2
    Transform 2 arguments get method :public T get(Contextual contextual, CreationalContext creationalCo

Popular in Java

  • Parsing JSON documents to java classes using gson
  • findViewById (Activity)
  • getContentResolver (Context)
  • getSupportFragmentManager (FragmentActivity)
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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