public ResourceElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); Resource resource = ae.getAnnotation(Resource.class); String resourceName = resource.name(); Class<?> resourceType = resource.type(); 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)); } } else if (embeddedValueResolver != null) { resourceName = embeddedValueResolver.resolveStringValue(resourceName); } if (Object.class != resourceType) { checkResourceType(resourceType); } else { // No resource type specified... check field/method. resourceType = getResourceType(); } this.name = (resourceName != null ? resourceName : ""); this.lookupType = resourceType; String lookupValue = resource.lookup(); this.mappedName = (StringUtils.hasLength(lookupValue) ? lookupValue : resource.mappedName()); Lazy lazy = ae.getAnnotation(Lazy.class); this.lazyLookup = (lazy != null && lazy.value()); }
public ResourceElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); Resource resource = ae.getAnnotation(Resource.class); String resourceName = resource.name(); Class<?> resourceType = resource.type(); 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)); } } else if (embeddedValueResolver != null) { resourceName = embeddedValueResolver.resolveStringValue(resourceName); } if (Object.class != resourceType) { checkResourceType(resourceType); } else { // No resource type specified... check field/method. resourceType = getResourceType(); } this.name = (resourceName != null ? resourceName : ""); this.lookupType = resourceType; String lookupValue = resource.lookup(); this.mappedName = (StringUtils.hasLength(lookupValue) ? lookupValue : resource.mappedName()); Lazy lazy = ae.getAnnotation(Lazy.class); this.lazyLookup = (lazy != null && lazy.value()); }
protected String getResourceName(InjectionPoint injectionPoint) { Resource resource = getResourceAnnotated(injectionPoint).getAnnotation(Resource.class); String mappedName = resource.mappedName(); String lookup = resource.lookup(); if (!lookup.isEmpty()) { return lookup; } if (!mappedName.isEmpty()) { return mappedName; } String proposedName = ResourceInjectionUtilities.getResourceName(injectionPoint); return getEJBResourceName(injectionPoint, proposedName); }
public static String getResourceName(InjectionPoint injectionPoint) { Resource resource = getResourceAnnotated(injectionPoint).getAnnotation(Resource.class); String mappedName = resource.mappedName(); if (!mappedName.equals("")) { return mappedName;
@Override public String mappedName() { return resource.mappedName(); }
private boolean hasMappedName(Resource resource) { return !"".equals(resource.mappedName()); }
@Override public Object getKey(final InjectionTargetInformation injectionTargetInformation) { final Resource annotation = injectionTargetInformation.getAnnotation(Resource.class); if (annotation != null && !annotation.mappedName().equals("")) { return annotation.mappedName(); } return super.getKey(injectionTargetInformation); } }
protected void initResouceAnnotatedDependency(Field field) throws NamingException { Resource annotation = field.getAnnotation(Resource.class); if (annotation == null) { return; } String name = annotation.mappedName(); if (name == null || name.equals("")) { name = field.getName(); } inject(field, name); }
private String getDescriptiveMappedName(Field field, Resource resource) { return hasMappedName(resource) ? "field:'" + field.getName() + "' mapped-name:'" + resource.mappedName() + "'" : "no name?"; }
protected String getResourceName(Resource resource) { String mappedName = resource.mappedName(); if (!mappedName.equals("")) { return mappedName; } String name = resource.name(); if (!name.equals("")) { return RESOURCE_LOOKUP_PREFIX + "/" + name; } return null; } }
protected String getResourceName(Resource resource) { String lookup = tryResourceLookup(resource); if (!lookup.equals("")) { return lookup; } String mappedName = resource.mappedName(); if (!mappedName.equals("")) { return mappedName; } String name = resource.name(); if (!name.equals("")) { return RESOURCE_LOOKUP_PREFIX + "/" + name; } return null; }
private String getResourceName(InjectionPoint ip) { Resource resourceAnnotation = ip.getAnnotated().getAnnotation(Resource.class); String name = resourceAnnotation.mappedName(); if (name.trim().isEmpty()) { name = resourceAnnotation.lookup(); if (name.trim().isEmpty()) { name = "dummyName"; } } return name; }
public void handleClass (Class<?> clazz) { Resource resource = (Resource)clazz.getAnnotation(Resource.class); if (resource != null) { String name = resource.name(); String mappedName = resource.mappedName(); if (name==null || name.trim().equals("")) throw new IllegalStateException ("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)"); try { if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context, name,mappedName)) if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context.getServer(), name,mappedName)) throw new IllegalStateException("No resource at "+(mappedName==null?name:mappedName)); } catch (NamingException e) { LOG.warn(e); } } }
private boolean injectNamedResource(Map<ResourceKey, Object> namedResources, Object serviceInstance, Field field, Resource resource) { if (namedResources == null) { return false; } ResourceKey key = ResourceKey.of(resource.name(), field.getType()); Object value = namedResources.get(key); if (value == null) { ResourceKey mappedKey = ResourceKey.of(resource.mappedName(), field.getType()); value = namedResources.get(mappedKey); } else if (hasMappedName(resource)) { LOG.debug("using name to inject, mapped name exists though"); } if (value != null) { injectResourceValue(serviceInstance, field, value); return true; } return false; }
public void handleClass (Class<?> clazz) { Resource resource = (Resource)clazz.getAnnotation(Resource.class); if (resource != null) { String name = resource.name(); String mappedName = resource.mappedName(); if (name==null || name.trim().equals("")) throw new IllegalStateException ("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)"); try { if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context, name,mappedName)) if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context.getServer(), name,mappedName)) throw new IllegalStateException("No resource at "+(mappedName==null?name:mappedName)); } catch (NamingException e) { LOG.warn(e); } } }
public void handleClass (Class<?> clazz) { Resource resource = (Resource)clazz.getAnnotation(Resource.class); if (resource != null) { String name = resource.name(); String mappedName = resource.mappedName(); if (name==null || name.trim().equals("")) throw new IllegalStateException ("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)"); try { if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context, name,mappedName)) if (!org.eclipse.jetty.plus.jndi.NamingEntryUtil.bindToENC(_context.getServer(), name,mappedName)) throw new IllegalStateException("No resource at "+(mappedName==null?name:mappedName)); } catch (NamingException e) { LOG.warn(e); } } }
@Override protected String getResourceName(InjectionPoint injectionPoint) { Resource resource = injectionPoint.getAnnotated().getAnnotation(Resource.class); String mappedName = resource.mappedName(); String lookup = resource.lookup(); if (!lookup.isEmpty()) { return lookup; } if (!mappedName.isEmpty()) { return mappedName; } String proposedName = super.getResourceName(injectionPoint); return getEJBResourceName(injectionPoint, proposedName); }
protected EnvironmentEntryMetaData createEntry(Resource annotation, E element) { EnvironmentEntryMetaData entry = new EnvironmentEntryMetaData(); String name = annotation.name(); if(name.length() == 0) name = getName(element); entry.setEnvEntryName(name); Descriptions descriptions = ProcessorUtils.getDescription(annotation.description()); if(descriptions != null) entry.setDescriptions(descriptions); if(annotation.type() != Object.class) entry.setType(annotation.type().getName()); else entry.setType(getType(element)); if(annotation.mappedName().length() > 0) entry.setValue(annotation.mappedName()); String injectionName = getInjectionName(element); Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(injectionName, element); if(injectionTargets != null) entry.setInjectionTargets(injectionTargets); return entry; }
protected MessageDestinationReferenceMetaData createMessageRef(Resource annotation, E element) { MessageDestinationReferenceMetaData ref = new MessageDestinationReferenceMetaData(); String name = annotation.name(); if(name.length() == 0) name = getName(element); ref.setMessageDestinationRefName(name); if(annotation.mappedName().length() > 0) ref.setMappedName(annotation.mappedName()); if(annotation.type() != Object.class) ref.setType(annotation.type().getName()); else ref.setType(getType(element)); Descriptions descriptions = ProcessorUtils.getDescription(annotation.description()); if(descriptions != null) ref.setDescriptions(descriptions); String injectionName = getInjectionName(element); Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(injectionName, element); if(injectionTargets != null) ref.setInjectionTargets(injectionTargets); return ref; }
protected ResourceEnvironmentReferenceMetaData createResourceEnvRef(Resource annotation, E element) { ResourceEnvironmentReferenceMetaData ref = new ResourceEnvironmentReferenceMetaData(); String name = annotation.name(); if(name.length() == 0) name = getName(element); ref.setResourceEnvRefName(name); if(annotation.mappedName().length() > 0) ref.setMappedName(annotation.mappedName()); if(annotation.type() != Object.class) ref.setType(annotation.type().getName()); else ref.setType(getType(element)); Descriptions descriptions = ProcessorUtils.getDescription(annotation.description()); if(descriptions != null) ref.setDescriptions(descriptions); String injectionName = getInjectionName(element); Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(injectionName, element); if(injectionTargets != null) ref.setInjectionTargets(injectionTargets); return ref; }