Search in sources :

Example 76 with Named

use of javax.inject.Named in project ListenerMusicPlayer by hefuyicoder.

the class NetworkModule method provideKuGouRetrofit.

@Provides
@Named("kugou")
@PerApplication
Retrofit provideKuGouRetrofit() {
    String endpointUrl = Constants.BASE_API_URL_KUGOU;
    Gson gson = new GsonBuilder().create();
    GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(gson);
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient client = new OkHttpClient.Builder().cache(new Cache(FileUtil.getHttpCacheDir(ListenerApp.getContext()), Constants.HTTP_CACHE_SIZE)).connectTimeout(Constants.HTTP_CONNECT_TIMEOUT, TimeUnit.MILLISECONDS).readTimeout(Constants.HTTP_READ_TIMEOUT, TimeUnit.MILLISECONDS).build();
    //        OkHttpClient newClient = client.newBuilder().addInterceptor(loggingInterceptor).build();
    Retrofit retrofit = new Retrofit.Builder().baseUrl(endpointUrl).client(client).addConverterFactory(gsonConverterFactory).addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
    return retrofit;
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) GsonBuilder(com.google.gson.GsonBuilder) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) GsonConverterFactory(retrofit2.converter.gson.GsonConverterFactory) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Cache(okhttp3.Cache) Named(javax.inject.Named) PerApplication(io.hefuyi.listener.injector.scope.PerApplication) Provides(dagger.Provides)

Example 77 with Named

use of javax.inject.Named in project camel by apache.

the class PropertiesConfigurationTest method propertiesComponent.

@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent propertiesComponent() {
    Properties configuration = new Properties();
    configuration.put("property", "value");
    PropertiesComponent component = new PropertiesComponent();
    component.setInitialProperties(configuration);
    component.setLocation("classpath:camel1.properties,classpath:camel2.properties");
    return component;
}
Also used : Properties(java.util.Properties) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 78 with Named

use of javax.inject.Named in project camel by apache.

the class Jms method sjms.

@Produces
@Named("sjms")
@ApplicationScoped
SjmsComponent sjms() {
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useShutdownHook=false&broker.useJmx=false"));
    component.setConnectionCount(maxConnections);
    return component;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 79 with Named

use of javax.inject.Named in project camel by apache.

the class Application method properties.

@Produces
@ApplicationScoped
@Named("properties")
// "properties" component bean that Camel uses to lookup properties
PropertiesComponent properties(PropertiesParser parser) {
    PropertiesComponent component = new PropertiesComponent();
    // Use DeltaSpike as configuration source for Camel CDI
    component.setPropertiesParser(parser);
    return component;
}
Also used : PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 80 with Named

use of javax.inject.Named in project OpenAM by OpenRock.

the class CoreRestGuiceModule method getServerAttributeTitles.

@Provides
@Singleton
@Named("ServerAttributeTitles")
public Properties getServerAttributeTitles() throws IOException {
    Properties titleProperties = new Properties();
    titleProperties.load(getClass().getClassLoader().getResourceAsStream("amConsole.properties"));
    return titleProperties;
}
Also used : SystemProperties(com.iplanet.am.util.SystemProperties) Properties(java.util.Properties) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Named (javax.inject.Named)136 Produces (javax.enterprise.inject.Produces)40 ApplicationScoped (javax.enterprise.context.ApplicationScoped)31 Test (org.junit.Test)29 Provides (com.google.inject.Provides)23 Properties (java.util.Properties)18 Singleton (javax.inject.Singleton)18 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)15 Api (com.google.api.server.spi.config.Api)15 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)15 JsonNode (com.fasterxml.jackson.databind.JsonNode)14 PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)12 Annotation (java.lang.annotation.Annotation)11 Provides (dagger.Provides)9 ArrayList (java.util.ArrayList)8 Inject (javax.inject.Inject)8 List (java.util.List)7 HashMap (java.util.HashMap)6 Method (java.lang.reflect.Method)5 ApiConfigAnnotationReader (com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader)4