本文整理了Java中io.baratine.inject.Key.of()
方法的一些代码示例,展示了Key.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Key.of()
方法的具体详情如下:
包路径:io.baratine.inject.Key
类名称:Key
方法名:of
[英]Builds key from a Class
[中]从类生成密钥
代码示例来源:origin: baratine/baratine
@Override
public BindingBuilder<T> to(Class<? super T> type)
{
Objects.requireNonNull(type);
_key = Key.of(type);
return this;
}
代码示例来源:origin: baratine/baratine
BindingBuilderImpl(InjectorBuilder builder,
Class<T> type)
{
Objects.requireNonNull(builder);
_builder = builder;
Objects.requireNonNull(type);
_key = Key.of(type);
_impl = type;
}
代码示例来源:origin: baratine/baratine
static <T> InjectionPoint<T> of(Field f)
{
return new InjectionPointImpl<>(Key.of(f),
f.getGenericType(),
f.getName(),
f.getAnnotations(),
f.getDeclaringClass());
}
代码示例来源:origin: baratine/baratine
/**
* Creates a new instance for a given type.
*/
@Override
public <T> T instance(Class<T> type)
{
Key<T> key = Key.of(type);
return instance(key);
}
代码示例来源:origin: baratine/baratine
static <T> InjectionPoint<T> of(Class<T> type)
{
return new InjectionPointImpl<>(Key.of(type),
type,
type.getSimpleName(),
type.getAnnotations(),
type);
}
代码示例来源:origin: baratine/baratine
static <T> InjectionPoint<T> of(Method m)
{
return new InjectionPointImpl<>(Key.of(m),
m.getGenericReturnType(),
m.getName(),
m.getAnnotations(),
m.getDeclaringClass());
}
代码示例来源:origin: baratine/baratine
InjectField(InjectorAmp inject,
Field field)
{
_inject = inject;
_field = field;
_field.setAccessible(true);
_isOptional = field.isAnnotationPresent(Opt.class);
_key = Key.of(field);
_program = _inject.provider(this);
}
代码示例来源:origin: baratine/baratine
static <T> InjectionPoint<T> of(Class<?> declaringClass,
Class<T> paramType,
Annotation []annotations)
{
return new InjectionPointImpl<>(Key.of(paramType),
paramType,
declaringClass.getName(),
annotations,
declaringClass);
}
代码示例来源:origin: baratine/baratine
@Override
public ConvertManager converter()
{
if (_convertManager == null) {
_convertManager = provider(Key.of(ConvertManager.class));
}
return _convertManager.get();
}
代码示例来源:origin: baratine/baratine
@Override
public <T> ServiceBuilder service(Class<T> type)
{
Key<?> key = Key.of(type, ServiceImpl.class);
return service(key, type);
}
代码示例来源:origin: baratine/baratine
static <T> InjectionPoint<T> of(Constructor<?> c)
{
return new InjectionPointImpl<>(Key.of(c),
c.getDeclaringClass(),
c.getDeclaringClass().getSimpleName(),
c.getAnnotations(),
c.getDeclaringClass());
}
代码示例来源:origin: baratine/baratine
/**
* Returns an object producer.
*/
private <T> BindingAmp<T> findObjectBinding(Key<T> key)
{
Objects.requireNonNull(key);
if (key.qualifiers().length != 1) {
throw new IllegalArgumentException();
}
return (BindingAmp) findBinding(Key.of(Object.class,
key.qualifiers()[0]));
}
代码示例来源:origin: baratine/baratine
@Override
public <T> ServiceRef.ServiceBuilder service(Class<T> serviceClass)
{
Objects.requireNonNull(serviceClass);
validator().serviceClass(serviceClass);
Key<?> key = Key.of(serviceClass, ServiceImpl.class);
ServiceBuilderWebImpl service
= new ServiceBuilderWebImpl(this, key, serviceClass);
_includes.add(service);
return service;
}
代码示例来源:origin: baratine/baratine
BindingBuilderImpl(InjectorBuilder builder,
Function<?,T> function)
{
Objects.requireNonNull(builder);
_builder = builder;
Objects.requireNonNull(function);
Class<T> keyType = (Class) TypeRef.of(function.getClass())
.to(Function.class)
.param(1)
.rawClass();
_key = (Key) Key.of(keyType);
_function = function;
}
代码示例来源:origin: baratine/baratine
static <T> InjectionPoint<T> of(Parameter p)
{
return new InjectionPointImpl<>((Key<T>) Key.of(p),
p.getParameterizedType(),
p.getName(),
p.getAnnotations(),
p.getDeclaringExecutable().getDeclaringClass());
}
代码示例来源:origin: baratine/baratine
public ServerAuthManager()
{
_security = SecuritySystem.getCurrent();
InjectorAmp injectManager = InjectorAmp.current();
_auth = injectManager.instance(io.baratine.inject.Key.of(AuthenticatorRole.class,
Admin.class));
if (_auth == null) {
_auth = injectManager.instance(AuthenticatorRole.class);
}
}
代码示例来源:origin: baratine/baratine
void bind(InjectorImpl injector)
{
addBean(injector, Key.of(Injector.class), ()->injector);
for (IncludeBuilder include : includes()) {
include.build(injector);
}
for (BindingBuilderImpl<?> binding : _bindings) {
binding.build(injector);
}
}
代码示例来源:origin: baratine/baratine
private void introspectOnLookup()
{
if (isImplemented(OnLookup.class)) {
return;
}
Key<T> key = Key.of(_type, ServiceImpl.class);
// XXX: provider should be passed in? Non-injector session provider?
Provider<T> provider = services().injector().provider(key);
FieldBean<T> setter = findIdSetter();
MethodAmp onLookup = new MethodOnLookup(_stubClassSession, provider, setter);
onLookup(onLookup);
}
代码示例来源:origin: baratine/baratine
@Override
public <T> WebBuilder view(Class<? extends ViewRender<T>> viewClass)
{
TypeRef viewType = TypeRef.of(viewClass).to(ViewRender.class);
TypeRef typeRef = viewType.param(0);
Class renderedType = Object.class;
if (typeRef != null)
renderedType = typeRef.rawClass();
ViewRender<?> view = injector().instance(viewClass);
return view(view, Key.of(renderedType));
}
代码示例来源:origin: baratine/baratine
private void introspectOnLookup()
{
if (isImplemented(OnLookup.class)) {
return;
}
Class<?> entityClass = _configResource.entityType();
Key<Object> key = (Key) Key.of(entityClass);
Provider<Object> provider = services().injector().provider(key);
MethodHandle setter = findIdSetter();
Convert<String,?> converter = findConverter();
MethodAmp onLookup = new MethodOnLookup(_stubAsset, provider, converter, setter);
onLookup(onLookup);
}
内容来源于网络,如有侵权,请联系作者删除!