@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition beanDefinition) { ScopeMetadata metadata = new ScopeMetadata(); metadata.setScopeName("myCustomScope"); return metadata; }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; Set<String> annTypes = annDef.getMetadata().getAnnotationTypes(); String found = null; for (String annType : annTypes) { Set<String> metaAnns = annDef.getMetadata().getMetaAnnotationTypes(annType); if (metaAnns.contains("javax.inject.Scope")) { if (found != null) { throw new IllegalStateException("Found ambiguous scope annotations on bean class [" + definition.getBeanClassName() + "]: " + found + ", " + annType); } found = annType; String scopeName = resolveScopeName(annType); if (scopeName == null) { throw new IllegalStateException( "Unsupported scope annotation - not mapped onto Spring scope name: " + annType); } metadata.setScopeName(scopeName); } } } return metadata; }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; Set<String> annTypes = annDef.getMetadata().getAnnotationTypes(); String found = null; for (String annType : annTypes) { Set<String> metaAnns = annDef.getMetadata().getMetaAnnotationTypes(annType); if (metaAnns.contains("javax.inject.Scope")) { if (found != null) { throw new IllegalStateException("Found ambiguous scope annotations on bean class [" + definition.getBeanClassName() + "]: " + found + ", " + annType); } found = annType; String scopeName = resolveScopeName(annType); if (scopeName == null) { throw new IllegalStateException( "Unsupported scope annotation - not mapped onto Spring scope name: " + annType); } metadata.setScopeName(scopeName); } } } return metadata; }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; for (String type : annDef.getMetadata().getAnnotationTypes()) { if (type.equals(javax.inject.Singleton.class.getName())) { metadata.setScopeName(BeanDefinition.SCOPE_SINGLETON); break; } else if (annDef.getMetadata().getMetaAnnotationTypes(type).contains(javax.inject.Scope.class.getName())) { metadata.setScopeName(type.substring(type.length() - 13, type.length() - 6).toLowerCase()); metadata.setScopedProxyMode(scopedProxyMode); break; } else if (type.startsWith("javax.inject")) { metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE); } } } return metadata; } });
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor( annDef.getMetadata(), this.scopeAnnotationType); if (attributes != null) { metadata.setScopeName(attributes.getString("value")); ScopedProxyMode proxyMode = attributes.getEnum("proxyMode"); if (proxyMode == ScopedProxyMode.DEFAULT) { proxyMode = this.defaultProxyMode; } metadata.setScopedProxyMode(proxyMode); } } return metadata; }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor( annDef.getMetadata(), this.scopeAnnotationType); if (attributes != null) { metadata.setScopeName(attributes.getString("value")); ScopedProxyMode proxyMode = attributes.getEnum("proxyMode"); if (proxyMode == ScopedProxyMode.DEFAULT) { proxyMode = this.defaultProxyMode; } metadata.setScopedProxyMode(proxyMode); } } return metadata; }
private ScopeMetadata requestScopeAsDefault() { ScopeMetadata singleton = new ScopeMetadata(); singleton.setScopeName(WebApplicationContext.SCOPE_REQUEST); return singleton; } }
/** * {@inheritDoc} * * @see org.springframework.context.annotation.ScopeMetadataResolver#resolveScopeMetadata(org.springframework.beans.factory.config.BeanDefinition) */ public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata scopeMetadata = new ScopeMetadata(); scopeMetadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE); return scopeMetadata; } }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; if (annDef.getMetadata().hasAnnotation(StickyDomain.class.getName())) { metadata.setScopeName("prototype"); } else if (annDef.getMetadata().hasMetaAnnotation(StickyDomain.class.getName())) { metadata.setScopeName("prototype"); } else { metadata.setScopeName("singleton"); } } return metadata; }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; if (annDef.getMetadata().hasAnnotation(StickyDomain.class.getName())) { metadata.setScopeName("prototype"); } else if (annDef.getMetadata().hasMetaAnnotation(StickyDomain.class.getName())) { metadata.setScopeName("prototype"); } else { metadata.setScopeName("singleton"); } } return metadata; }
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { AnnotationMetadata metadata = ((AnnotatedBeanDefinition) definition).getMetadata(); for (Map.Entry<String, String> scope : scopes.entrySet()) { if (metadata.hasAnnotation(scope.getKey())) { ScopeMetadata scopeMetadata = new ScopeMetadata(); scopeMetadata.setScopeName(scope.getValue()); return scopeMetadata; } } return requestScopeAsDefault(); }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; Set<String> annTypes = annDef.getMetadata().getAnnotationTypes(); String found = null; for (String annType : annTypes) { Set<String> metaAnns = annDef.getMetadata().getMetaAnnotationTypes(annType); if (metaAnns.contains("javax.inject.Scope")) { if (found != null) { throw new IllegalStateException("Found ambiguous scope annotations on bean class [" + definition.getBeanClassName() + "]: " + found + ", " + annType); } found = annType; String scopeName = resolveScopeName(annType); if (scopeName == null) { throw new IllegalStateException( "Unsupported scope annotation - not mapped onto Spring scope name: " + annType); } metadata.setScopeName(scopeName); } } } return metadata; }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; Set<String> annTypes = annDef.getMetadata().getAnnotationTypes(); String found = null; for (String annType : annTypes) { Set<String> metaAnns = annDef.getMetadata().getMetaAnnotationTypes(annType); if (metaAnns.contains("javax.inject.Scope")) { if (found != null) { throw new IllegalStateException("Found ambiguous scope annotations on bean class [" + definition.getBeanClassName() + "]: " + found + ", " + annType); } found = annType; String scopeName = resolveScopeName(annType); if (scopeName == null) { throw new IllegalStateException( "Unsupported scope annotation - not mapped onto Spring scope name: " + annType); } metadata.setScopeName(scopeName); } } } return metadata; }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition)definition; Set<String> annotationTypes = annDef.getMetadata().getAnnotationTypes(); // String scopeName; if (annotationTypes.contains(Singleton.class.getName())) { scopeName = "singleton"; } else { scopeName = "prototype"; for (Scope scope : scopes) { if (annotationTypes.contains(scope.getAnnotationType().getName())) { scopeName = scope.name().toLowerCase(); break; } } } metadata.setScopeName(scopeName); return metadata; } else { return super.resolveScopeMetadata(definition); } } }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition)definition; Set<String> annotationTypes = annDef.getMetadata().getAnnotationTypes(); // String scopeName; if (annotationTypes.contains(Singleton.class.getName())) { scopeName = "singleton"; } else { scopeName = "prototype"; for (Scope scope : scopes) { if (annotationTypes.contains(scope.getAnnotationType().getName())) { scopeName = scope.name().toLowerCase(); break; } } } metadata.setScopeName(scopeName); return metadata; } else { return super.resolveScopeMetadata(definition); } } }
/** * Discover spring scope using bean definition. * * @param definition bean definition * @return scope metadata */ @Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; String scopeName = JsfCdiToSpring.scopeName(annDef.getMetadata().getAnnotationTypes()); if (scopeName != null) { metadata.setScopeName(scopeName); logger.debug(definition.getBeanClassName() + " - Scope(" + metadata.getScopeName().toUpperCase() + ") - " + metadata.getScopedProxyMode().toString().toUpperCase()); } else { // do the regular Spring stuff.. metadata = super.resolveScopeMetadata(definition); } } return metadata; } }
@Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor( annDef.getMetadata(), this.scopeAnnotationType); if (attributes != null) { metadata.setScopeName(attributes.getString("value")); ScopedProxyMode proxyMode = attributes.getEnum("proxyMode"); if (proxyMode == ScopedProxyMode.DEFAULT) { proxyMode = this.defaultProxyMode; } metadata.setScopedProxyMode(proxyMode); } } return metadata; }