private static Spec spec(BeanSpec beanSpec) { if (null != beanSpec.getAnnotation(Enable.class)) { return new Spec(true); } else if (null != beanSpec.getAnnotation(Disable.class)) { return new Spec(false); } return Spec.DEFAULT; }
private static Spec spec(BeanSpec beanSpec) { if (null != beanSpec.getAnnotation(Enable.class)) { return new Spec(true); } else if (null != beanSpec.getAnnotation(Disable.class)) { return new Spec(false); } return Spec.DEFAULT; }
private static Spec spec(BeanSpec beanSpec) { return new Spec() .with(beanSpec.getAnnotation(Disable.class)) .with(beanSpec.getAnnotation(AllowOrigin.class)) .with(beanSpec.getAnnotation(ExposeHeaders.class)) .with(beanSpec.getAnnotation(AllowCredentials.class)) .with(beanSpec.getAnnotation(DisallowCredentials.class)) .with(beanSpec.getAnnotation(AllowHeaders.class)) .with(beanSpec.getAnnotation(MaxAge.class)); }
private static Spec spec(BeanSpec beanSpec) { return new Spec() .with(beanSpec.getAnnotation(Disable.class)) .with(beanSpec.getAnnotation(AllowOrigin.class)) .with(beanSpec.getAnnotation(ExposeHeaders.class)) .with(beanSpec.getAnnotation(AllowCredentials.class)) .with(beanSpec.getAnnotation(DisallowCredentials.class)) .with(beanSpec.getAnnotation(AllowHeaders.class)) .with(beanSpec.getAnnotation(MaxAge.class)); }
public boolean isProvided(BeanSpec beanSpec) { Class rawType = beanSpec.rawType(); boolean provided = (ActProviders.isProvided(rawType) || null != beanSpec.getAnnotation(Inject.class) || null != beanSpec.getAnnotation(Provided.class) || null != beanSpec.getAnnotation(Context.class) || null != beanSpec.getAnnotation(Singleton.class) || beanSpec.isInstanceOf(SingletonBase.class) || subjectToInject(beanSpec) ); return provided && (!($.isSimpleType(rawType) && !beanSpec.hasAnnotation())); }
public boolean isProvided(BeanSpec beanSpec) { Class rawType = beanSpec.rawType(); boolean provided = (ActProviders.isProvided(rawType) || null != beanSpec.getAnnotation(Inject.class) || null != beanSpec.getAnnotation(Provided.class) || null != beanSpec.getAnnotation(Context.class) || null != beanSpec.getAnnotation(Singleton.class) || beanSpec.isInstanceOf(SingletonBase.class) || subjectToInject(beanSpec) ); return provided && (!($.isSimpleType(rawType) && !beanSpec.hasAnnotation())); }
private ValueLoader valueLoaderOf(BeanSpec spec) { LoadValue loadValue = spec.getAnnotation(LoadValue.class); if (null == loadValue) { Annotation[] aa = spec.taggedAnnotations(LoadValue.class); if (aa.length > 0) { Annotation a = aa[0]; loadValue = a.annotationType().getAnnotation(LoadValue.class); } } return null == loadValue ? null : Act.getInstance(loadValue.value()); }
private ValueLoader valueLoaderOf(BeanSpec spec) { LoadValue loadValue = spec.getAnnotation(LoadValue.class); if (null == loadValue) { Annotation[] aa = spec.taggedAnnotations(LoadValue.class); if (aa.length > 0) { Annotation a = aa[0]; loadValue = a.annotationType().getAnnotation(LoadValue.class); } } return null == loadValue ? null : Act.getInstance(loadValue.value()); }
private static boolean isEmail(BeanSpec spec) { SampleData.Category anno = spec.getAnnotation(SampleData.Category.class); SampleDataCategory category = null != anno ? anno.value() : null; if (null != category && category != EMAIL) { return false; } category = SampleDataCategory.of(spec.name()); return category == EMAIL; }
private String checkDefaultValue(BeanSpec spec) { DefaultValue def = spec.getAnnotation(DefaultValue.class); if (null != def) { return def.value(); } Class<?> type = spec.rawType(); if (type.isPrimitive()) { Object o = Act.app().resolverManager().resolve("", type); return null != o ? o.toString() : null; } return null; }
private static boolean isEmail(BeanSpec spec) { SampleData.Category anno = spec.getAnnotation(SampleData.Category.class); SampleDataCategory category = null != anno ? anno.value() : null; if (null != category && category != EMAIL) { return false; } category = SampleDataCategory.of(spec.name()); return category == EMAIL; }
private String checkDefaultValue(BeanSpec spec) { DefaultValue def = spec.getAnnotation(DefaultValue.class); if (null != def) { return def.value(); } Class<?> type = spec.rawType(); if (type.isPrimitive()) { Object o = Act.app().resolverManager().resolve("", type); return null != o ? o.toString() : null; } return null; }
protected StringValueResolver lookupResolver(BeanSpec spec, Class runtimeType) { StringValueResolver resolver = null; Param param = spec.getAnnotation(Param.class); if (null != param) { Class<? extends StringValueResolver> resolverClass = param.resolverClass(); if (Param.DEFAULT_RESOLVER.class != resolverClass) { resolver = injector.get(resolverClass); } } if (null == resolver) { resolver = resolverManager.resolver(runtimeType, spec); } return resolver; }
@Override protected void initialized() { String path = (String) options.get("value"); E.unexpectedIf(S.blank(path), "resource path not specified"); boolean trimLeadingSlash = !$.bool(options.get("skipTrimLeadingSlash")); while (trimLeadingSlash && path.startsWith("/")) { path = path.substring(1); } E.unexpectedIf(S.blank(path), "resource path not specified"); HeaderMapping anno = spec.getAnnotation(HeaderMapping.class); if (null != anno) { this.hint = HeaderMapping.Parser.parse(anno.value()); } resource = load(path, spec, hint); }
public SessionValueLoader(String name, BeanSpec beanSpec) { this.key = key(name, beanSpec); this.targetType = beanSpec.rawType(); this.stringValueResolver = App.instance().resolverManager().resolver(targetType, beanSpec); E.illegalArgumentIf(null == this.stringValueResolver, "Cannot find out StringValueResolver for %s", beanSpec); DefaultValue defValAnno = beanSpec.getAnnotation(DefaultValue.class); if (null != defValAnno) { this.defVal = stringValueResolver.resolve(defValAnno.value()); } else { this.defVal = StringValueResolverValueLoaderBase.defVal(null, targetType); } }
public SessionValueLoader(String name, BeanSpec beanSpec) { this.key = key(name, beanSpec); this.targetType = beanSpec.rawType(); this.stringValueResolver = App.instance().resolverManager().resolver(targetType, beanSpec); E.illegalArgumentIf(null == this.stringValueResolver, "Cannot find out StringValueResolver for %s", beanSpec); DefaultValue defValAnno = beanSpec.getAnnotation(DefaultValue.class); if (null != defValAnno) { this.defVal = stringValueResolver.resolve(defValAnno.value()); } else { this.defVal = StringValueResolverValueLoaderBase.defVal(null, targetType); } }
protected StringValueResolverValueLoaderBase(ParamKey key, DefaultValue def, StringValueResolver resolver, BeanSpec paramSpec, boolean simpleKeyOnly) { E.illegalArgumentIf(simpleKeyOnly && !key.isSimple()); this.paramSpec = paramSpec; this.param = paramSpec.getAnnotation(Param.class); this.paramKey = key; this.defSpec = def; this.resolverManager = Act.app().resolverManager(); this.injector = Act.app().injector(); this.requireRuntimeType = false; this.stringValueResolver = resolver; this.defVal = null != def ? this.stringValueResolver.resolve(def.value()) : defVal(param, paramSpec.rawType()); }
protected StringValueResolverValueLoaderBase(ParamKey key, DefaultValue def, StringValueResolver resolver, BeanSpec paramSpec, boolean simpleKeyOnly) { E.illegalArgumentIf(simpleKeyOnly && !key.isSimple()); this.paramSpec = paramSpec; this.param = paramSpec.getAnnotation(Param.class); this.paramKey = key; this.defSpec = def; this.resolverManager = Act.app().resolverManager(); this.injector = Act.app().injector(); this.requireRuntimeType = false; this.stringValueResolver = resolver; this.defVal = null != def ? this.stringValueResolver.resolve(def.value()) : defVal(param, paramSpec.rawType()); }
public StringValueResolverValueLoaderBase(ParamKey key, DefaultValue def, BeanSpec spec, boolean simpleKeyOnly) { E.illegalArgumentIf(simpleKeyOnly && !key.isSimple()); this.paramSpec = spec; this.param = spec.getAnnotation(Param.class); this.paramKey = key; this.defSpec = def; this.resolverManager = Act.app().resolverManager(); this.injector = Act.app().injector(); this.requireRuntimeType = !(spec.type() instanceof Class); this.stringValueResolver = this.requireRuntimeType ? null : lookupResolver(spec, spec.rawType()); this.defVal = this.requireRuntimeType ? null : null != def ? this.stringValueResolver.resolve(def.value()) : defVal(param, spec.rawType()); }
public StringValueResolverValueLoaderBase(ParamKey key, DefaultValue def, BeanSpec spec, boolean simpleKeyOnly) { E.illegalArgumentIf(simpleKeyOnly && !key.isSimple()); this.paramSpec = spec; this.param = spec.getAnnotation(Param.class); this.paramKey = key; this.defSpec = def; this.resolverManager = Act.app().resolverManager(); this.injector = Act.app().injector(); this.requireRuntimeType = !(spec.type() instanceof Class); this.stringValueResolver = this.requireRuntimeType ? null : lookupResolver(spec, spec.rawType()); this.defVal = this.requireRuntimeType ? null : null != def ? this.stringValueResolver.resolve(def.value()) : defVal(param, spec.rawType()); }