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

How to use
getIfExists
method
in
org.jboss.weld.bean.ContextualInstance

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

origin: org.jboss.weld.se/weld-se

protected Object getReceiver(CreationalContext<X> creationalContext) {
  if (creationalContext != null) {
    if (creationalContext instanceof CreationalContextImpl<?>) {
      // Create child creational context so that a dependent observer may be destroyed after the observer method completes
      creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(declaringBean);
    }
    return ContextualInstance.get(declaringBean, beanManager, creationalContext);
  }
  // Conditional observer - no creational context is required
  return ContextualInstance.getIfExists(declaringBean, beanManager);
}
origin: weld/core

protected Object getReceiver(CreationalContext<X> creationalContext) {
  if (creationalContext != null) {
    if (creationalContext instanceof CreationalContextImpl<?>) {
      // Create child creational context so that a dependent observer may be destroyed after the observer method completes
      creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(declaringBean);
    }
    return ContextualInstance.get(declaringBean, beanManager, creationalContext);
  }
  // Conditional observer - no creational context is required
  return ContextualInstance.getIfExists(declaringBean, beanManager);
}
origin: weld/core

protected Object getReceiver(CreationalContext<X> creationalContext) {
  if (creationalContext != null) {
    if (creationalContext instanceof CreationalContextImpl<?>) {
      // Create child creational context so that a dependent observer may be destroyed after the observer method completes
      creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(declaringBean);
    }
    return ContextualInstance.get(declaringBean, beanManager, creationalContext);
  }
  // Conditional observer - no creational context is required
  return ContextualInstance.getIfExists(declaringBean, beanManager);
}
origin: org.jboss.weld.se/weld-se-shaded

protected Object getReceiver(CreationalContext<X> creationalContext) {
  if (creationalContext != null) {
    if (creationalContext instanceof CreationalContextImpl<?>) {
      // Create child creational context so that a dependent observer may be destroyed after the observer method completes
      creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(declaringBean);
    }
    return ContextualInstance.get(declaringBean, beanManager, creationalContext);
  }
  // Conditional observer - no creational context is required
  return ContextualInstance.getIfExists(declaringBean, beanManager);
}
origin: weld/core

protected Object getReceiver(CreationalContext<X> creationalContext) {
  if (creationalContext != null) {
    if (creationalContext instanceof CreationalContextImpl<?>) {
      // Create child creational context so that a dependent observer may be destroyed after the observer method completes
      creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(declaringBean);
    }
    return ContextualInstance.get(declaringBean, beanManager, creationalContext);
  }
  // Conditional observer - no creational context is required
  return ContextualInstance.getIfExists(declaringBean, beanManager);
}
origin: org.jboss.weld.servlet/weld-servlet-shaded

protected Object getReceiver(CreationalContext<X> creationalContext) {
  if (creationalContext != null) {
    if (creationalContext instanceof CreationalContextImpl<?>) {
      // Create child creational context so that a dependent observer may be destroyed after the observer method completes
      creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(declaringBean);
    }
    return ContextualInstance.get(declaringBean, beanManager, creationalContext);
  }
  // Conditional observer - no creational context is required
  return ContextualInstance.getIfExists(declaringBean, beanManager);
}
origin: org.jboss.weld.se/weld-se

public T getInstance() {
  T existingInstance = ContextualInstance.getIfExists(bean, manager);
  if (existingInstance != null) {
    return existingInstance;
  }
  WeldCreationalContext<T> creationalContext;
  WeldCreationalContext<?> previousCreationalContext = currentCreationalContext.get();
  if (previousCreationalContext == null) {
    creationalContext = new CreationalContextImpl<T>(bean);
  } else {
    creationalContext = previousCreationalContext.getCreationalContext(bean);
  }
  currentCreationalContext.set(creationalContext);
  // Ensure that there is no injection point associated
  final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.push(EmptyInjectionPoint.INSTANCE);
  try {
    return ContextualInstance.get(bean, manager, creationalContext);
  } finally {
    stack.pop();
    if (previousCreationalContext == null) {
      currentCreationalContext.remove();
    } else {
      currentCreationalContext.set(previousCreationalContext);
    }
  }
}
origin: weld/core

public T getInstance() {
  if (!Container.isSet(contextId)) {
    throw ContextLogger.LOG.contextualReferenceNotValidAfterShutdown(bean, contextId);
  }
  T existingInstance = ContextualInstance.getIfExists(bean, manager);
  if (existingInstance != null) {
    return existingInstance;
  }
  WeldCreationalContext<T> creationalContext;
  WeldCreationalContext<?> previousCreationalContext = currentCreationalContext.get();
  if (previousCreationalContext == null) {
    creationalContext = new CreationalContextImpl<T>(bean);
  } else {
    creationalContext = previousCreationalContext.getCreationalContext(bean);
  }
  currentCreationalContext.set(creationalContext);
  // Ensure that there is no injection point associated
  final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.push(EmptyInjectionPoint.INSTANCE);
  try {
    return ContextualInstance.get(bean, manager, creationalContext);
  } finally {
    stack.pop();
    if (previousCreationalContext == null) {
      currentCreationalContext.remove();
    } else {
      currentCreationalContext.set(previousCreationalContext);
    }
  }
}
origin: weld/core

public T getInstance() {
  if (!Container.isSet(contextId)) {
    throw ContextLogger.LOG.contextualReferenceNotValidAfterShutdown(bean, contextId);
  }
  T existingInstance = ContextualInstance.getIfExists(bean, manager);
  if (existingInstance != null) {
    return existingInstance;
  }
  WeldCreationalContext<T> creationalContext;
  WeldCreationalContext<?> previousCreationalContext = currentCreationalContext.get();
  if (previousCreationalContext == null) {
    creationalContext = new CreationalContextImpl<T>(bean);
  } else {
    creationalContext = previousCreationalContext.getCreationalContext(bean);
  }
  currentCreationalContext.set(creationalContext);
  // Ensure that there is no injection point associated
  final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.push(EmptyInjectionPoint.INSTANCE);
  try {
    return ContextualInstance.get(bean, manager, creationalContext);
  } finally {
    stack.pop();
    if (previousCreationalContext == null) {
      currentCreationalContext.remove();
    } else {
      currentCreationalContext.set(previousCreationalContext);
    }
  }
}
origin: weld/core

public Object getReference(Bean<?> bean, Type requestedType, CreationalContext<?> creationalContext, boolean noProxy) {
  if (creationalContext instanceof CreationalContextImpl<?>) {
    creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(bean);
  }
  if (!noProxy && isProxyRequired(bean)) {
    if (creationalContext != null || ContextualInstance.getIfExists(bean, this) != null) {
      if (requestedType == null) {
        return clientProxyProvider.getClientProxy(bean);
      } else {
        return clientProxyProvider.getClientProxy(bean, requestedType);
      }
    } else {
      return null;
    }
  } else {
    return ContextualInstance.get(bean, this, creationalContext);
  }
}
origin: org.jboss.weld.se/weld-se-shaded

public Object getReference(Bean<?> bean, Type requestedType, CreationalContext<?> creationalContext, boolean noProxy) {
  if (creationalContext instanceof CreationalContextImpl<?>) {
    creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(bean);
  }
  if (!noProxy && isProxyRequired(bean)) {
    if (creationalContext != null || ContextualInstance.getIfExists(bean, this) != null) {
      if (requestedType == null) {
        return clientProxyProvider.getClientProxy(bean);
      } else {
        return clientProxyProvider.getClientProxy(bean, requestedType);
      }
    } else {
      return null;
    }
  } else {
    return ContextualInstance.get(bean, this, creationalContext);
  }
}
origin: weld/core

public Object getReference(Bean<?> bean, Type requestedType, CreationalContext<?> creationalContext, boolean noProxy) {
  if (creationalContext instanceof CreationalContextImpl<?>) {
    creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(bean);
  }
  if (!noProxy && isProxyRequired(bean)) {
    if (creationalContext != null || ContextualInstance.getIfExists(bean, this) != null) {
      if (requestedType == null) {
        return clientProxyProvider.getClientProxy(bean);
      } else {
        return clientProxyProvider.getClientProxy(bean, requestedType);
      }
    } else {
      return null;
    }
  } else {
    return ContextualInstance.get(bean, this, creationalContext);
  }
}
origin: org.jboss.weld.se/weld-se

public Object getReference(Bean<?> bean, Type requestedType, CreationalContext<?> creationalContext, boolean noProxy) {
  if (creationalContext instanceof CreationalContextImpl<?>) {
    creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(bean);
  }
  if (!noProxy && isProxyRequired(bean)) {
    if (creationalContext != null || ContextualInstance.getIfExists(bean, this) != null) {
      if (requestedType == null) {
        return clientProxyProvider.getClientProxy(bean);
      } else {
        return clientProxyProvider.getClientProxy(bean, requestedType);
      }
    } else {
      return null;
    }
  } else {
    return ContextualInstance.get(bean, this, creationalContext);
  }
}
origin: weld/core

public Object getReference(Bean<?> bean, Type requestedType, CreationalContext<?> creationalContext, boolean noProxy) {
  if (creationalContext instanceof CreationalContextImpl<?>) {
    creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(bean);
  }
  if (!noProxy && isProxyRequired(bean)) {
    if (creationalContext != null || ContextualInstance.getIfExists(bean, this) != null) {
      if (requestedType == null) {
        return clientProxyProvider.getClientProxy(bean);
      } else {
        return clientProxyProvider.getClientProxy(bean, requestedType);
      }
    } else {
      return null;
    }
  } else {
    return ContextualInstance.get(bean, this, creationalContext);
  }
}
origin: org.jboss.weld.servlet/weld-servlet-shaded

public Object getReference(Bean<?> bean, Type requestedType, CreationalContext<?> creationalContext, boolean noProxy) {
  if (creationalContext instanceof CreationalContextImpl<?>) {
    creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(bean);
  }
  if (!noProxy && isProxyRequired(bean)) {
    if (creationalContext != null || ContextualInstance.getIfExists(bean, this) != null) {
      if (requestedType == null) {
        return clientProxyProvider.getClientProxy(bean);
      } else {
        return clientProxyProvider.getClientProxy(bean, requestedType);
      }
    } else {
      return null;
    }
  } else {
    return ContextualInstance.get(bean, this, creationalContext);
  }
}
origin: weld/core

public void dispose(T instance) {
  if (disposalMethod != null) {
    // CreationalContext is only created if we need it to obtain the receiver
    // MethodInvocationStrategy takes care of creating CC for parameters, if needed
    if (disposalMethod.getAnnotated().isStatic()) {
      disposalMethod.invokeDisposeMethod(null, instance, null);
    } else {
      WeldCreationalContext<X> ctx = null;
      try {
        Object receiver = ContextualInstance.getIfExists(getDeclaringBean(), getBeanManager());
        if (receiver == null) {
          ctx = getBeanManager().createCreationalContext(null);
          // Create child CC so that a dependent reciever may be destroyed after the disposer method completes
          receiver = ContextualInstance.get(getDeclaringBean(), getBeanManager(), ctx.getCreationalContext(getDeclaringBean()));
        }
        if (receiver != null) {
          disposalMethod.invokeDisposeMethod(receiver, instance, ctx);
        }
      } finally {
        if (ctx != null) {
          ctx.release();
        }
      }
    }
  }
}
origin: org.jboss.weld.servlet/weld-servlet-shaded

public void dispose(T instance) {
  if (disposalMethod != null) {
    // CreationalContext is only created if we need it to obtain the receiver
    // MethodInvocationStrategy takes care of creating CC for parameters, if needed
    if (disposalMethod.getAnnotated().isStatic()) {
      disposalMethod.invokeDisposeMethod(null, instance, null);
    } else {
      WeldCreationalContext<X> ctx = null;
      try {
        Object receiver = ContextualInstance.getIfExists(getDeclaringBean(), getBeanManager());
        if (receiver == null) {
          ctx = getBeanManager().createCreationalContext(null);
          // Create child CC so that a dependent reciever may be destroyed after the disposer method completes
          receiver = ContextualInstance.get(getDeclaringBean(), getBeanManager(), ctx.getCreationalContext(getDeclaringBean()));
        }
        if (receiver != null) {
          disposalMethod.invokeDisposeMethod(receiver, instance, ctx);
        }
      } finally {
        if (ctx != null) {
          ctx.release();
        }
      }
    }
  }
}
origin: org.jboss.weld.se/weld-se-shaded

public void dispose(T instance) {
  if (disposalMethod != null) {
    // CreationalContext is only created if we need it to obtain the receiver
    // MethodInvocationStrategy takes care of creating CC for parameters, if needed
    if (disposalMethod.getAnnotated().isStatic()) {
      disposalMethod.invokeDisposeMethod(null, instance, null);
    } else {
      WeldCreationalContext<X> ctx = null;
      try {
        Object receiver = ContextualInstance.getIfExists(getDeclaringBean(), getBeanManager());
        if (receiver == null) {
          ctx = getBeanManager().createCreationalContext(null);
          // Create child CC so that a dependent reciever may be destroyed after the disposer method completes
          receiver = ContextualInstance.get(getDeclaringBean(), getBeanManager(), ctx.getCreationalContext(getDeclaringBean()));
        }
        if (receiver != null) {
          disposalMethod.invokeDisposeMethod(receiver, instance, ctx);
        }
      } finally {
        if (ctx != null) {
          ctx.release();
        }
      }
    }
  }
}
origin: org.jboss.weld.se/weld-se

public void dispose(T instance) {
  if (disposalMethod != null) {
    // CreationalContext is only created if we need it to obtain the receiver
    // MethodInvocationStrategy takes care of creating CC for parameters, if needed
    if (disposalMethod.getAnnotated().isStatic()) {
      disposalMethod.invokeDisposeMethod(null, instance, null);
    } else {
      WeldCreationalContext<X> ctx = null;
      try {
        Object receiver = ContextualInstance.getIfExists(getDeclaringBean(), getBeanManager());
        if (receiver == null) {
          ctx = getBeanManager().createCreationalContext(null);
          // Create child CC so that a dependent reciever may be destroyed after the disposer method completes
          receiver = ContextualInstance.get(getDeclaringBean(), getBeanManager(), ctx.getCreationalContext(getDeclaringBean()));
        }
        if (receiver != null) {
          disposalMethod.invokeDisposeMethod(receiver, instance, ctx);
        }
      } finally {
        if (ctx != null) {
          ctx.release();
        }
      }
    }
  }
}
origin: weld/core

public void dispose(T instance) {
  if (disposalMethod != null) {
    // CreationalContext is only created if we need it to obtain the receiver
    // MethodInvocationStrategy takes care of creating CC for parameters, if needed
    if (disposalMethod.getAnnotated().isStatic()) {
      disposalMethod.invokeDisposeMethod(null, instance, null);
    } else {
      WeldCreationalContext<X> ctx = null;
      try {
        Object receiver = ContextualInstance.getIfExists(getDeclaringBean(), getBeanManager());
        if (receiver == null) {
          ctx = getBeanManager().createCreationalContext(null);
          // Create child CC so that a dependent reciever may be destroyed after the disposer method completes
          receiver = ContextualInstance.get(getDeclaringBean(), getBeanManager(), ctx.getCreationalContext(getDeclaringBean()));
        }
        if (receiver != null) {
          disposalMethod.invokeDisposeMethod(receiver, instance, ctx);
        }
      } finally {
        if (ctx != null) {
          ctx.release();
        }
      }
    }
  }
}
org.jboss.weld.beanContextualInstancegetIfExists

Javadoc

Shortcut for obtaining contextual instances with semantics equivalent to: manager.getContext(bean.getScope()).get(bean);

Popular methods of ContextualInstance

  • get
  • getStrategy

Popular in Java

  • Reactive rest calls using spring rest template
  • getResourceAsStream (ClassLoader)
  • onRequestPermissionsResult (Fragment)
  • getSystemService (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Runner (org.openjdk.jmh.runner)
  • Option (scala)
  • Best plugins for Eclipse
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