javax.ejb.EJB.beanName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(14.3k)|赞(0)|评价(0)|浏览(282)

本文整理了Java中javax.ejb.EJB.beanName()方法的一些代码示例,展示了EJB.beanName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EJB.beanName()方法的具体详情如下:
包路径:javax.ejb.EJB
类名称:EJB
方法名:beanName

EJB.beanName介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

public EjbRefElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) {
  super(member, pd);
  EJB resource = ae.getAnnotation(EJB.class);
  String resourceBeanName = resource.beanName();
  String resourceName = resource.name();
  this.isDefaultName = !StringUtils.hasLength(resourceName);
  if (this.isDefaultName) {
    resourceName = this.member.getName();
    if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) {
      resourceName = Introspector.decapitalize(resourceName.substring(3));
    }
  }
  Class<?> resourceType = resource.beanInterface();
  if (Object.class != resourceType) {
    checkResourceType(resourceType);
  }
  else {
    // No resource type specified... check field/method.
    resourceType = getResourceType();
  }
  this.beanName = resourceBeanName;
  this.name = resourceName;
  this.lookupType = resourceType;
  this.mappedName = resource.mappedName();
}

代码示例来源:origin: org.springframework/spring-context

public EjbRefElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) {
  super(member, pd);
  EJB resource = ae.getAnnotation(EJB.class);
  String resourceBeanName = resource.beanName();
  String resourceName = resource.name();
  this.isDefaultName = !StringUtils.hasLength(resourceName);
  if (this.isDefaultName) {
    resourceName = this.member.getName();
    if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) {
      resourceName = Introspector.decapitalize(resourceName.substring(3));
    }
  }
  Class<?> resourceType = resource.beanInterface();
  if (Object.class != resourceType) {
    checkResourceType(resourceType);
  }
  else {
    // No resource type specified... check field/method.
    resourceType = getResourceType();
  }
  this.beanName = resourceBeanName;
  this.name = resourceName;
  this.lookupType = resourceType;
  this.mappedName = resource.mappedName();
}

代码示例来源:origin: org.fornax.cartridges/fornax-cartridges-sculptor-framework-test

protected void initEjbAnnotatedDependency(Field field) throws NamingException {
  EJB annotation = field.getAnnotation(EJB.class);
  if (annotation == null) {
    return;
  }
  String name = annotation.beanName();
  if (name == null || name.equals("")) {
    name = field.getName();
  }
  inject(field, name);
}

代码示例来源:origin: net.oneandone/ejb-cdi-unit

String beanNameOrName(EJB ejb) {
  if (!ejb.name().isEmpty()) {
    return ejb.name();
  } else {
    return ejb.beanName();
  }
}

代码示例来源:origin: org.jboss.ws/jbossws-jboss501

/**
* Constructs EjbReference.
*
* @param ejbAnnotation ejb annotation
* @param type fall back type
* @return ejb reference instance
*/
private EjbReference getEjbReference(final EJB ejbAnnotation, final Class<?> type)
{
 String beanInterface = ejbAnnotation.beanInterface().getName();
 if (java.lang.Object.class.getName().equals(beanInterface))
 {
   beanInterface = type.getName();
 }
 return new EjbReference(ejbAnnotation.beanName(), beanInterface, ejbAnnotation.mappedName());
}

代码示例来源:origin: org.seasar.container/s2-tiger

/**
   * {@link EJB}アノテーションで指定されたセッションビーンを取得するOGNL式を返します。
   * 
   * @param ejb
   *            {@link EJB}アノテーション
   * @return {@link EJB}アノテーションで指定されたセッションビーンを取得するOGNL式
   */
  protected String getExpression(final EJB ejb) {
    String name = ejb.beanName();
    if (StringUtil.isEmpty(name)) {
      name = ejb.name();
    }
    return name.replace('/', '.');
  }
}

代码示例来源:origin: org.jboss.ws/jbossws-jboss510

/**
* Constructs EjbReference.
*
* @param ejbAnnotation ejb annotation
* @param type fall back type
* @return ejb reference instance
*/
private EjbReference getEjbReference(final EJB ejbAnnotation, final Class<?> type)
{
 String beanInterface = ejbAnnotation.beanInterface().getName();
 if (java.lang.Object.class.getName().equals(beanInterface))
 {
   beanInterface = type.getName();
 }
 return new EjbReference(ejbAnnotation.beanName(), beanInterface, ejbAnnotation.mappedName());
}

代码示例来源:origin: org.jboss.ws/jbossws-jboss600M2

/**
* Constructs EjbReference.
*
* @param ejbAnnotation ejb annotation
* @param type fall back type
* @return ejb reference instance
*/
private EjbReference getEjbReference(final EJB ejbAnnotation, final Class<?> type)
{
 String beanInterface = ejbAnnotation.beanInterface().getName();
 if (java.lang.Object.class.getName().equals(beanInterface))
 {
   beanInterface = type.getName();
 }
 return new EjbReference(ejbAnnotation.beanName(), beanInterface, ejbAnnotation.mappedName());
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-tomcat

public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
{
 EJB ref = container.getAnnotation(EJB.class, method);
 if (ref != null)
 {
   if (!method.getName().startsWith("set"))
    throw new RuntimeException("@EJB can only be used with a set method: " + method);
   String encName = getEncName(ref, method);
   if (!container.getEncInjectors().containsKey(encName))
   {
    ejbRefEncInjector(ref.mappedName(), encName, method.getName().substring(0), method.getParameterTypes()[0], ref.beanName(), "@EJB", container);
    
    if (isIgnoreDependency(container, ref))
      log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
    else
      ejbRefDependency(ref.mappedName(), ref.beanName(), container, method.getParameterTypes()[0], "@EJB", encName);
   }
   super.handleMethodAnnotations(method, container, injectors);
 }
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-tomcat

if (ref.beanName().equals("") && memberType == null)
  throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB.  Please fill out the beanName and/or businessInterface attributes");
if (ref.beanName().equals(""))
  rtn = (EJBContainer) container.resolveEjbContainer(ref.beanName(), businessInterface);

代码示例来源:origin: apache/servicemix-bundles

public EjbRefElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) {
  super(member, pd);
  EJB resource = ae.getAnnotation(EJB.class);
  String resourceBeanName = resource.beanName();
  String resourceName = resource.name();
  this.isDefaultName = !StringUtils.hasLength(resourceName);
  if (this.isDefaultName) {
    resourceName = this.member.getName();
    if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) {
      resourceName = Introspector.decapitalize(resourceName.substring(3));
    }
  }
  Class<?> resourceType = resource.beanInterface();
  if (Object.class != resourceType) {
    checkResourceType(resourceType);
  }
  else {
    // No resource type specified... check field/method.
    resourceType = getResourceType();
  }
  this.beanName = resourceBeanName;
  this.name = resourceName;
  this.lookupType = resourceType;
  this.mappedName = resource.mappedName();
}

代码示例来源:origin: org.seasar.container/s2-tiger

/**
 * フィールドからコンポーネントの名前を解決します。
 * 
 * @param filed
 *            フィールド
 * @return コンポーネント名
 */
protected String resolveComponentName(final Field filed) {
  if (testContext.isEjb3Enabled()) {
    final EJB ejb = filed.getAnnotation(EJB.class);
    if (ejb != null) {
      if (!StringUtil.isEmpty(ejb.beanName())) {
        return ejb.beanName();
      } else if (!StringUtil.isEmpty(ejb.name())) {
        return ejb.name();
      }
    }
  }
  return normalizeName(filed.getName());
}

代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core

protected void handleClassAnnotation(EJB ejb, Class<?> clazz, InjectionContainer container)
{
 String encName = ejb.name();
 if (encName == null || encName.equals(""))
 {
   throw new RuntimeException("JBoss requires the name of the @EJB in the @EJBs: " + clazz);
 }
 encName = "env/" + encName;
 if (container.getEncInjectors().containsKey(encName)) return;
 ejbRefEncInjector(ejb.mappedName(), encName, null, ejb.beanInterface(), ejb.beanName(), "@EJB", container);
 // handle dependencies
 if (isIgnoreDependency(container, ejb))
   log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
 else
   ejbRefDependency(ejb.mappedName(), ejb.beanName(), container, ejb.beanInterface(), "@EJB", encName);
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-tomcat

protected void handleClassAnnotation(EJB ejb, Class<?> clazz, InjectionContainer container)
{
 String encName = ejb.name();
 if (encName == null || encName.equals(""))
 {
   throw new RuntimeException("JBoss requires the name of the @EJB in the @EJBs: " + clazz);
 }
 encName = "env/" + encName;
 if (container.getEncInjectors().containsKey(encName)) return;
 ejbRefEncInjector(ejb.mappedName(), encName, null, ejb.beanInterface(), ejb.beanName(), "@EJB", container);
 // handle dependencies
 if (isIgnoreDependency(container, ejb))
   log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
 else
   ejbRefDependency(ejb.mappedName(), ejb.beanName(), container, ejb.beanInterface(), "@EJB", encName);
}

代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core

public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
{
 EJB ref = container.getAnnotation(EJB.class, method);
 if (ref != null)
 {
   if (!method.getName().startsWith("set"))
    throw new RuntimeException("@EJB can only be used with a set method: " + method);
   String encName = getEncName(ref, method);
   if (!container.getEncInjectors().containsKey(encName))
   {
    Class<?> businessInterface = method.getParameterTypes()[0];
    if (ref.beanInterface() != null && ref.beanInterface() != Object.class)
    {
      businessInterface = ref.beanInterface();
    }
    ejbRefEncInjector(ref.mappedName(), encName, method.getName().substring(0), businessInterface, ref.beanName(), "@EJB", container);
    
    if (container.getAnnotation(IgnoreDependency.class, method) == null)
    {
      if (isIgnoreDependency(container, ref))
       log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
      else
       ejbRefDependency(ref.mappedName(), ref.beanName(), container, businessInterface, "@EJB", encName);
    }
   }
   super.handleMethodAnnotations(method, container, injectors);
 }
}

代码示例来源:origin: org.jboss.eap/wildfly-weld-ejb

private ViewDescription getViewDescription(EJB ejb, InjectionPoint injectionPoint) {
  final Set<ViewDescription> viewService;
  if (ejb.beanName().isEmpty()) {
    if (ejb.beanInterface() != Object.class) {
      viewService = applicationDescription.getComponentsForViewName(ejb.beanInterface().getName(), deploymentRoot);
    } else {
      viewService = applicationDescription.getComponentsForViewName(getType(injectionPoint.getType()).getName(), deploymentRoot);
    }
  } else {
    if (ejb.beanInterface() != Object.class) {
      viewService = applicationDescription.getComponents(ejb.beanName(), ejb.beanInterface().getName(), deploymentRoot);
    } else {
      viewService = applicationDescription.getComponents(ejb.beanName(), getType(injectionPoint.getType()).getName(), deploymentRoot);
    }
  }
  if (injectionPoint.getAnnotated().isAnnotationPresent(Produces.class)) {
    if (viewService.isEmpty()) {
      throw WeldLogger.ROOT_LOGGER.ejbNotResolved(ejb, injectionPoint.getMember());
    } else if (viewService.size() > 1) {
      throw WeldLogger.ROOT_LOGGER.moreThanOneEjbResolved(ejb, injectionPoint.getMember(), viewService);
    }
  } else {
    if (viewService.isEmpty()) {
      return null;
    } else if (viewService.size() > 1) {
      return null;
    }
  }
  return viewService.iterator().next();
}

代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-mc-int

/**
* Create @EJB value meta data.
*
* @param annotation 
* @return @EJB metadata
*/
@Override
protected ValueMetaData createValueMetaData(FieldInfo propInfo, EJB annotation)
{
 // Get properties from the annotation
 String beanName = annotation.beanName();
 String beanInterface = annotation.beanInterface().getName();
 String mappedName = annotation.mappedName();
 // Supply beanInterface from reflection if not explicitly-defined
 if (beanInterface == null || beanInterface.equals(Object.class.getName()))
 {
   String reflectType = propInfo.getType().getName();
   beanInterface = reflectType;
 }
 // Create a reference
 EjbReference reference = new EjbReference(beanName, beanInterface, mappedName);
 log.debug("Found @EJB reference " + reference);
 // Return a new ValueMetaData w/ the reference
 return new AbstractEjbReferenceValueMetadata(this.getResolver(), reference, this.getNamingContext());
}

代码示例来源:origin: org.jboss.ejb3/jboss-ejb3-core

public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
{
 EJB ref = container.getAnnotation(EJB.class, field);
 if (ref != null)
 {
   String encName = getEncName(ref, field);
   if (!container.getEncInjectors().containsKey(encName))
   {
    Class<?> businessInterface = field.getType();
    if (ref.beanInterface() != null && ref.beanInterface() != Object.class)
    {
      businessInterface = ref.beanInterface();
    }
    if (container.getAnnotation(IgnoreDependency.class, field) == null)
    {
      if (isIgnoreDependency(container, ref))
       log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
      else
       ejbRefDependency(ref.mappedName(), ref.beanName(), container, businessInterface, "@EJB", encName);
    }
    ejbRefEncInjector(ref.mappedName(), encName, field.getName(), businessInterface, ref.beanName(), "@EJB", container);
   }
   super.handleFieldAnnotations(field, container, injectors);
 }
}

代码示例来源:origin: org.jboss/jboss-metadata

protected AnnotatedEJBReferenceMetaData createEJB(EJB annotation, E element)
  {
   AnnotatedEJBReferenceMetaData ref = new AnnotatedEJBReferenceMetaData();
   if(annotation.name().length() > 0)
     ref.setEjbRefName(annotation.name());
   else
     ref.setEjbRefName(getName(element));
   if(annotation.beanInterface() != Object.class)
     ref.setBeanInterface(annotation.beanInterface());
   else
     ref.setBeanInterface(getType(element));
   if(annotation.description().length() > 0)
   {
     DescriptionImpl description = new DescriptionImpl();
     description.setDescription(annotation.description());
     DescriptionsImpl descriptions = new DescriptionsImpl();
     descriptions.add(description);
     ref.setDescriptions(descriptions);
   }
   if(annotation.beanName().length() > 0)
     ref.setLink(annotation.beanName());
   if(annotation.mappedName().length() > 0)
     ref.setMappedName(annotation.mappedName());

   return ref;
  }
}

代码示例来源:origin: org.jboss.ws/jbossws-jboss510-metadata

protected AnnotatedEJBReferenceMetaData createEJB(EJB annotation, E element)
{
 AnnotatedEJBReferenceMetaData ref = new AnnotatedEJBReferenceMetaData();
 if(annotation.name().length() > 0)
   ref.setEjbRefName(annotation.name());
 else
   ref.setEjbRefName(getName(element));
 if(annotation.beanInterface() != Object.class)
   ref.setBeanInterface(annotation.beanInterface());
 else
   ref.setBeanInterface(getType(element));
 if(annotation.description().length() > 0)
 {
   DescriptionImpl description = new DescriptionImpl();
   description.setDescription(annotation.description());
   DescriptionsImpl descriptions = new DescriptionsImpl();
   descriptions.add(description);
   ref.setDescriptions(descriptions);
 }
 if(annotation.beanName().length() > 0)
   ref.setLink(annotation.beanName());
 if(annotation.mappedName().length() > 0)
   ref.setMappedName(annotation.mappedName());
 String name = ProcessorUtils.getName(element);
 Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(name, element);
 if(injectionTargets != null)
   ref.setInjectionTargets(injectionTargets);
 return ref;
}

相关文章