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

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

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

EJB.mappedName介绍

暂无

代码示例

代码示例来源: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.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.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: 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.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.jbossas/jboss-as-tomcat

if (ref.mappedName() != null && !"".equals(ref.mappedName()))

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

if (ref.mappedName() != null && !"".equals(ref.mappedName()))

代码示例来源: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.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: arquillian/arquillian-core

@Test
public void testResolveJNDINameMappedNameSpecified() {
  cut.enrich(new EJBEnrichedMappedNameClass());
  String expected = EJBEnrichedMappedNameClass.class.getDeclaredFields()[0].getAnnotation(EJB.class).mappedName();
 /*
  * When 'mappedName' is set, the only JNDI name to check is the exact value specified in the annotation.
  */
  assertThat(resolvedJndiName, is(notNullValue()));
  assertThat(resolvedJndiName.length, is(1));
  assertThat(resolvedJndiName[0], is(expected));
}

代码示例来源:origin: org.jboss.arquillian.testenricher/arquillian-testenricher-ejb

@Test
public void testResolveJNDINameMappedNameSpecified() {
  cut.enrich(new EJBEnrichedMappedNameClass());
  String expected = EJBEnrichedMappedNameClass.class.getDeclaredFields()[0].getAnnotation(EJB.class).mappedName();
 /*
  * When 'mappedName' is set, the only JNDI name to check is the exact value specified in the annotation.
  */
  assertThat(resolvedJndiName, is(notNullValue()));
  assertThat(resolvedJndiName.length, is(1));
  assertThat(resolvedJndiName[0], is(expected));
}

代码示例来源: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.eap/wildfly-weld-ejb

private String getEjbBindLocation(InjectionPoint injectionPoint) {
  EJB ejb = ResourceInjectionUtilities.getResourceAnnotated(injectionPoint).getAnnotation(EJB.class);
  String mappedName = ejb.mappedName();
  if (!mappedName.equals("")) {
    return mappedName;
  }
  String name = ejb.name();
  if (!name.equals("")) {
    return ResourceInjectionUtilities.RESOURCE_LOOKUP_PREFIX + "/" + name;
  }
  String propertyName;
  if (injectionPoint.getMember() instanceof Field) {
    propertyName = injectionPoint.getMember().getName();
  } else if (injectionPoint.getMember() instanceof Method) {
    propertyName = ResourceInjectionUtilities.getPropertyName((Method) injectionPoint.getMember());
    if (propertyName == null) {
      throw WeldLogger.ROOT_LOGGER.injectionPointNotAJavabean((Method) injectionPoint.getMember());
    }
  } else {
    throw WeldLogger.ROOT_LOGGER.cannotInject(injectionPoint);
  }
  String className = injectionPoint.getMember().getDeclaringClass().getName();
  return ResourceInjectionUtilities.RESOURCE_LOOKUP_PREFIX + "/" + className + "/" + propertyName;
}

代码示例来源: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;
}

代码示例来源:origin: org.glassfish.main.web/weld-integration

private String getLookupName( Class annotatedClass, AnnotatedField annotatedField, List<InjectionCapable> injectionResources ) {
  String lookupName = null;
  if ( annotatedField.isAnnotationPresent( Resource.class ) ) {
    Resource resource = annotatedField.getAnnotation( Resource.class );
    lookupName = getJndiName( resource.lookup(), resource.mappedName(), resource.name() );
  } else if ( annotatedField.isAnnotationPresent( EJB.class ) ) {
    EJB ejb = annotatedField.getAnnotation( EJB.class );
    lookupName = getJndiName(ejb.lookup(), ejb.mappedName(), ejb.name());
  } else if ( annotatedField.isAnnotationPresent( WebServiceRef.class ) ) {
    WebServiceRef webServiceRef = annotatedField.getAnnotation( WebServiceRef.class );
    lookupName = getJndiName(webServiceRef.lookup(), webServiceRef.mappedName(), webServiceRef.name());
  } else if ( annotatedField.isAnnotationPresent( PersistenceUnit.class ) ) {
    PersistenceUnit persistenceUnit = annotatedField.getAnnotation( PersistenceUnit.class );
    lookupName = getJndiName( persistenceUnit.unitName(), null, persistenceUnit.name() );
  } else if ( annotatedField.isAnnotationPresent( PersistenceContext.class ) ) {
    PersistenceContext persistenceContext = annotatedField.getAnnotation( PersistenceContext.class );
    lookupName = getJndiName( persistenceContext.unitName(), null, persistenceContext.name() );
  }
  if ( lookupName == null || lookupName.trim().length() == 0 ) {
    lookupName = getComponentEnvName( annotatedClass,
                     annotatedField.getJavaMember().getName(),
                     injectionResources );
  }
  return lookupName;
}

相关文章