com.google.inject.name.Names#named ( )源码实例Demo

下面列出了com.google.inject.name.Names#named ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: proteus   文件: ConfigModule.java
@SuppressWarnings("unchecked")
private void bindConfig(final Config config)
{
    traverse(this.binder(), "", config.root());

    for (Entry<String, ConfigValue> entry : config.entrySet()) {
        String name = entry.getKey();
        Named named = Names.named(name);
        Object value = entry.getValue().unwrapped();

        if (value instanceof List) {
            List<Object> values = (List<Object>) value;
            Type listType = (values.size() == 0)
                    ? String.class
                    : Types.listOf(values.iterator().next().getClass());
            Key<Object> key = (Key<Object>) Key.get(listType, Names.named(name));

            this.binder().bind(key).toInstance(values);
        } else {
            this.binder().bindConstant().annotatedWith(named).to(value.toString());
        }
    }

    Config referenceConfig = ConfigFactory.load(ConfigFactory.defaultReference());

    this.config = ConfigFactory.load(config).withFallback(referenceConfig);

    log.debug(this.config.toString());

    this.binder().bind(Config.class).toInstance(config);
}
 
private TermFacetViewModelFactory findViewModelFactory(final TermFacetedSearchFormSettings<?> settings) {
    if (settings.getMapperSettings() != null) {
        try {
            final Named named = Names.named(settings.getMapperSettings().getName());
            return injector.getInstance(Key.get(TermFacetViewModelFactory.class, named));
        } catch (ConfigurationException e) {
            LOGGER.warn("Could not find term facet mapper with name \"{}\"", settings.getFieldName());
        }
    }
    return termFacetViewModelFactory;
}
 
源代码3 项目: Orienteer   文件: OUsersCommonUtils.java
public static List<IOAuth2Provider> getOAuth2Providers() {
    OrienteerWebApplication app = OrienteerWebApplication.lookupApplication();
    if (app == null) {
        return Collections.emptyList();
    }
    Named named = Names.named("orienteer.oauth2.providers");
    Key<List<IOAuth2Provider>> key = Key.get(new TypeLiteral<List<IOAuth2Provider>>() {}, named);
    return app.getInjector().getInstance(key);
}
 
源代码4 项目: karyon   文件: TcpRxServerProvider.java
public TcpRxServerProvider(String name, Class<I> iType, Class<O> oType) {
    nameAnnotation = Names.named(name);

    connectionHandlerKey = keyFor(ConnectionHandler.class, iType, oType, nameAnnotation);
    pipelineConfiguratorKey = Key.get(PipelineConfigurator.class, nameAnnotation);
    metricEventsListenerFactoryKey = Key.get(MetricEventsListenerFactory.class, nameAnnotation);
    serverConfigKey = Key.get(ServerConfig.class, nameAnnotation);
}
 
源代码5 项目: karyon   文件: HttpRxServerProvider.java
public HttpRxServerProvider(String name, Class<I> iType, Class<O> oType) {
    nameAnnotation = Names.named(name);

    routerKey = keyFor(RequestHandler.class, iType, oType, nameAnnotation);
    interceptorSupportKey = keyFor(GovernatorHttpInterceptorSupport.class, iType, oType, nameAnnotation);
    pipelineConfiguratorKey = Key.get(PipelineConfigurator.class, nameAnnotation);
    metricEventsListenerFactoryKey = Key.get(MetricEventsListenerFactory.class, nameAnnotation);
    serverConfigKey = Key.get(ServerConfig.class, nameAnnotation);
}
 
源代码6 项目: karyon   文件: WebSocketsRxServerProvider.java
public WebSocketsRxServerProvider(String name, Class<I> iType, Class<O> oType) {
    nameAnnotation = Names.named(name);

    connectionHandlerKey = keyFor(ConnectionHandler.class, iType, oType, nameAnnotation);
    pipelineConfiguratorKey = Key.get(PipelineConfigurator.class, nameAnnotation);
    metricEventsListenerFactoryKey = Key.get(MetricEventsListenerFactory.class, nameAnnotation);
    serverConfigKey = Key.get(AbstractServerModule.ServerConfig.class, nameAnnotation);
}
 
源代码7 项目: karyon   文件: AbstractServerModule.java
protected AbstractServerModule(String moduleName, Class<I> iType, Class<O> oType) {
    nameAnnotation = Names.named(moduleName);
    this.iType = iType;
    this.oType = oType;

    pipelineConfiguratorKey = Key.get(PipelineConfigurator.class, nameAnnotation);
    serverConfigKey = Key.get(ServerConfig.class, nameAnnotation);

    serverConfigBuilder = newServerConfigBuilder();
}
 
protected Named named() {
	return Names.named(name() + "." + type().name().toLowerCase());
}
 
源代码9 项目: json2java4idea   文件: ProjectModule.java
@Nonnull
Annotation annotation() {
    return Names.named(name);
}
 
源代码10 项目: pinpoint   文件: ConfigModule.java
private void bindConstants(ProfilerConfig profilerConfig) {

        bind(TraceDataFormatVersion.class).toProvider(TraceDataFormatVersionProvider.class).in(Scopes.SINGLETON);

        Named callstackMaxDepth = Names.named("profiler.callstack.max.depth");
        bindConstant().annotatedWith(callstackMaxDepth).to(profilerConfig.getCallStackMaxDepth());

        bindConstant().annotatedWith(TraceAgentActiveThread.class).to(profilerConfig.isTraceAgentActiveThread());

        bindConstant().annotatedWith(DeadlockMonitorEnable.class).to(profilerConfig.isDeadlockMonitorEnable());
        bindConstant().annotatedWith(DeadlockMonitorInterval.class).to(profilerConfig.getDeadlockMonitorInterval());
    }