Java源码示例:org.glassfish.jersey.internal.inject.InjectionResolver

示例1
@Override
protected void configure() {
    bind(profile).to(ProfileFactoryBuilder.class);
    bind(optProfile).to(OptionalProfileFactoryBuilder.class);

    if(manager == null){
        bind(DefaultProfileManagerFactoryBuilder.class)
            .to(ProfileManagerFactoryBuilder.class)
        ;
    } else {
        bind(manager).to(ProfileManagerFactoryBuilder.class);
    }

    bind(Pac4JProfileValueFactoryProvider.class).to(ValueParamProvider.class).in(Singleton.class);

    bind(ProfileInjectionResolver.class)
        .to(new GenericType<InjectionResolver<Pac4JProfile>>(){})
        .in(Singleton.class);

    bind(ProfileManagerInjectionResolver.class)
        .to(new GenericType<InjectionResolver<Pac4JProfileManager>>(){})
        .in(Singleton.class);
}
 
示例2
@Override
protected void configure() {
    bind(profile).to(ProfileFactoryBuilder.class);
    bind(optProfile).to(OptionalProfileFactoryBuilder.class);

    if(manager == null){
        bind(DefaultProfileManagerFactoryBuilder.class)
            .to(ProfileManagerFactoryBuilder.class).in(Singleton.class);
    } else {
        bind(manager).to(ProfileManagerFactoryBuilder.class);
    }

    bindAsContract(Pac4JProfileValueFactoryProvider.class).to(ValueParamProvider.class).in(Singleton.class);

    bindAsContract(ProfileInjectionResolver.class)
        .to(new GenericType<InjectionResolver<Pac4JProfile>>(){})
        .in(Singleton.class);

    bindAsContract(ProfileManagerInjectionResolver.class)
        .to(new GenericType<InjectionResolver<Pac4JProfileManager>>(){})
        .in(Singleton.class);
}
 
示例3
private static String renderParamInjectionResolver(final ParamInjectionResolver instance,
                                                   final boolean hkManaged,
                                                   final boolean lazy) {
    try {
        final Field field = ParamInjectionResolver.class.getDeclaredField("valueParamProvider");
        field.setAccessible(true);
        final ValueParamProvider param = (ValueParamProvider) field.get(instance);
        final Class<? extends ParamInjectionResolver> type = instance.getClass();
        return String.format("@%-30s %s using %s %s",
                instance.getAnnotation().getSimpleName(),
                RenderUtils.renderClassLine(type),
                param.getClass().getSimpleName(),
                RenderUtils.markers(collectMarkers(InjectionResolver.class, type, hkManaged, lazy)));
    } catch (Exception e) {
        throw new IllegalStateException("Failed to access provider field", e);
    }
}
 
示例4
/**
 * In fuw cases it is possible to get more information using provider instance. So this report
 * will be a bit more detailed comparing to {@link #render(Class, Class, boolean, boolean)}.
 *
 * @param ext         extension type (affects render format)
 * @param instance    provider instance
 * @param isHkManaged true if extension is managed with HK2
 * @param isLazy      true if extension is annotated with
 *                    {@link ru.vyarus.dropwizard.guice.module.installer.install.binding.LazyBinding}
 * @return rendered provider line
 */
public static String render(final Class<?> ext,
                            final Object instance,
                            final boolean isHkManaged,
                            final boolean isLazy) {
    final Class<?> type = instance.getClass();
    String res = null;
    if (ParamInjectionResolver.class.isAssignableFrom(type)) {
        res = renderParamInjectionResolver((ParamInjectionResolver) instance, isHkManaged, isLazy);
    } else if (ext.equals(InjectionResolver.class)) {
        res = renderInjectionResolver((InjectionResolver) instance, isHkManaged, isLazy);
    }
    return res == null ? render(ext, type, isHkManaged, isLazy) : res;
}
 
示例5
private static String renderInjectionResolver(final InjectionResolver instance,
                                              final boolean hkManaged,
                                              final boolean lazy) {
    final Class<? extends InjectionResolver> type = instance.getClass();
    return String.format(INJECTION_FORMAT, instance.getAnnotation().getSimpleName(),
            RenderUtils.renderClassLine(type,
                    collectMarkers(InjectionResolver.class, type, hkManaged, lazy)));
}
 
示例6
/**
 * Show injection resolvers {@link InjectionResolver}.
 *
 * @return config instance for chained calls
 */
public JerseyConfig showInjectionResolvers() {
    types.add(InjectionResolver.class);
    return this;
}