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

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

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

EJB.beanInterface介绍

暂无

代码示例

代码示例来源: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.apache.geronimo.ext.openejb/openejb-itests-client

protected final void processSetterInjections() {
  Object home = null;
  ClassFinder finder = null;
  List<Method> methodList = null;
  
  finder = new ClassFinder(getClassPath());
  methodList = finder.findAnnotatedMethods(EJB.class);
  for(Iterator methods = methodList.iterator(); methods.hasNext();) {
    Method method = (Method) methods.next();
    EJB ejbAnnotation = method.getAnnotation(EJB.class);
    if( (ejbAnnotation.name() != null) && (ejbAnnotation.name() != "") && (ejbAnnotation.beanInterface() != null)) {
      try {
        home = initialContext.lookup(ejbAnnotation.name());
        // home = ejbAnnotation.beanInterface().cast(PortableRemoteObject.narrow(home, ejbAnnotation.beanInterface()));
        home = cast(home, ejbAnnotation.beanInterface());
        method.setAccessible(true);
        method.invoke(this, new Object[] {home});
      } catch(Exception ex) {
        // TODO - MNour : Needs better exception handling
        ex.printStackTrace();
      }
    }
  }
}

代码示例来源:origin: org.apache.geronimo.ext.openejb/openejb-itests-client

protected final void processFieldInjections() {
  Object home = null;
  ClassFinder finder = null;
  List<Field> fieldList = null;
  
  finder = new ClassFinder(getClassPath());
  fieldList = finder.findAnnotatedFields(EJB.class);
  for(Iterator fields = fieldList.iterator(); fields.hasNext();) {
    Field field = (Field) fields.next();
    EJB ejbAnnotation = field.getAnnotation(EJB.class);
    if( (ejbAnnotation.name() != null) && (ejbAnnotation.name() != "") && (ejbAnnotation.beanInterface() != null)) {
      try {
        home = initialContext.lookup(ejbAnnotation.name());
        // home = ejbAnnotation.beanInterface().cast(PortableRemoteObject.narrow(home, ejbAnnotation.beanInterface()));
        home = cast(home, ejbAnnotation.beanInterface());
        field.setAccessible(true);
        field.set(this, home);
      } catch(Exception ex) {
        // TODO - MNour : Needs better exception handling
        ex.printStackTrace();
      }
    }
  }
}

代码示例来源:origin: org.apache.openejb/openejb-itests-client

protected final void processSetterInjections() {
  Object home = null;
  ClassFinder finder = null;
  List<Method> methodList = null;
  
  finder = new ClassFinder(getClassPath());
  methodList = finder.findAnnotatedMethods(EJB.class);
  for(final Iterator methods = methodList.iterator(); methods.hasNext();) {
    final Method method = (Method) methods.next();
    final EJB ejbAnnotation = method.getAnnotation(EJB.class);
    if( (ejbAnnotation.name() != null) && (ejbAnnotation.name() != "") && (ejbAnnotation.beanInterface() != null)) {
      try {
        home = initialContext.lookup(ejbAnnotation.name());
        // home = ejbAnnotation.beanInterface().cast(PortableRemoteObject.narrow(home, ejbAnnotation.beanInterface()));
        home = cast(home, ejbAnnotation.beanInterface());
        method.setAccessible(true);
        method.invoke(this, new Object[] {home});
      } catch(final Exception ex) {
        // TODO - MNour : Needs better exception handling
        ex.printStackTrace();
      }
    }
  }
}

代码示例来源:origin: org.apache.openejb/openejb-itests-client

protected final void processFieldInjections() {
  Object home = null;
  ClassFinder finder = null;
  List<Field> fieldList = null;
  
  finder = new ClassFinder(getClassPath());
  fieldList = finder.findAnnotatedFields(EJB.class);
  for(final Iterator fields = fieldList.iterator(); fields.hasNext();) {
    final Field field = (Field) fields.next();
    final EJB ejbAnnotation = field.getAnnotation(EJB.class);
    if( (ejbAnnotation.name() != null) && (ejbAnnotation.name() != "") && (ejbAnnotation.beanInterface() != null)) {
      try {
        home = initialContext.lookup(ejbAnnotation.name());
        // home = ejbAnnotation.beanInterface().cast(PortableRemoteObject.narrow(home, ejbAnnotation.beanInterface()));
        home = cast(home, ejbAnnotation.beanInterface());
        field.setAccessible(true);
        field.set(this, home);
      } catch(final Exception ex) {
        // TODO - MNour : Needs better exception handling
        ex.printStackTrace();
      }
    }
  }
}

代码示例来源: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: com.caucho/resin

private ConfigProgram generateContext(AnnotatedMethod<?> method,
                   EJB ejb)
 throws ConfigException
{
 String name = ejb.name();
 Method javaMethod = method.getJavaMember();
 
 String location = getLocation(javaMethod);
 Class<?> bindType = javaMethod.getParameterTypes()[0];
 
 // ejb/2005
 if (! Object.class.equals(ejb.beanInterface())) {
  bindType = ejb.beanInterface();
 }
 
 ValueGenerator gen = bindGenerator(location, ejb, bindType);
 if (name != null && ! "".equals(name)) {
  bindJndi(name, gen, name);
 }
 
 bindJndi(javaMethod, gen);
 
 return new MethodGeneratorProgram(javaMethod, gen);
}

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

if (!ref.beanInterface().getName().equals(Object.class.getName()))
  businessInterface = ref.beanInterface();

代码示例来源:origin: com.caucho/resin

private void introspectClass(String location, EJB ejb)
{
 String name = ejb.name();
 Class<?> bindType = ejb.beanInterface();
 
 if ("".equals(name))
  throw new ConfigException(L.l("{0}: @EJB name() attribute is required for @EJB on a class.",
                 location));
 
 if (Object.class.equals(bindType))
  throw new ConfigException(L.l("{0}: @EJB beanInterface() attribute is required for @EJB on a class.",
                 location));
 
 ValueGenerator gen = bindGenerator(location, ejb, bindType);
 if (name != null && ! "".equals(name)) {
  bindJndi(name, gen, name);
 }
 
}

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

相关文章