javax.inject.Named Java Examples

The following examples show how to use javax.inject.Named. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JwtProxyProvisioner.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@Inject
public JwtProxyProvisioner(
    SignatureKeyManager signatureKeyManager,
    JwtProxyConfigBuilderFactory jwtProxyConfigBuilderFactory,
    ExternalServiceExposureStrategy externalServiceExposureStrategy,
    CookiePathStrategy cookiePathStrategy,
    @Named("che.server.secure_exposer.jwtproxy.image") String jwtProxyImage,
    @Named("che.server.secure_exposer.jwtproxy.memory_limit") String memoryLimitBytes,
    @Named("che.server.secure_exposer.jwtproxy.cpu_limit") String cpuLimitCores,
    @Named("che.workspace.sidecar.image_pull_policy") String imagePullPolicy,
    @Assisted RuntimeIdentity identity)
    throws InternalInfrastructureException {
  super(
      constructKeyPair(signatureKeyManager, identity),
      jwtProxyConfigBuilderFactory,
      externalServiceExposureStrategy,
      cookiePathStrategy,
      jwtProxyImage,
      memoryLimitBytes,
      cpuLimitCores,
      imagePullPolicy,
      identity.getWorkspaceId(),
      true);
}
 
Example #2
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Singleton @Provides AnalyticsManager providesAnalyticsManager(
    @Named("aptoideLogger") EventLogger aptoideBiEventLogger,
    @Named("facebook") EventLogger facebookEventLogger,
    @Named("flurryLogger") EventLogger flurryEventLogger, HttpKnockEventLogger knockEventLogger,
    @Named("aptoideEvents") Collection<String> aptoideEvents,
    @Named("facebookEvents") Collection<String> facebookEvents,
    @Named("flurryEvents") Collection<String> flurryEvents,
    @Named("flurrySession") SessionLogger flurrySessionLogger,
    @Named("aptoideSession") SessionLogger aptoideSessionLogger,
    @Named("normalizer") AnalyticsEventParametersNormalizer analyticsNormalizer,
    @Named("rakamEventLogger") EventLogger rakamEventLogger,
    @Named("rakamEvents") Collection<String> rakamEvents, AnalyticsLogger logger) {

  return new AnalyticsManager.Builder().addLogger(aptoideBiEventLogger, aptoideEvents)
      .addLogger(facebookEventLogger, facebookEvents)
      .addLogger(flurryEventLogger, flurryEvents)
      .addLogger(rakamEventLogger, rakamEvents)
      .addSessionLogger(flurrySessionLogger)
      .addSessionLogger(aptoideSessionLogger)
      .setKnockLogger(knockEventLogger)
      .setAnalyticsNormalizer(analyticsNormalizer)
      .setDebugLogger(logger)
      .build();
}
 
Example #3
Source File: BlockchainModule.java    From besu with Apache License 2.0 6 votes vote down vote up
@Provides
MutableWorldView getMutableWorldView(
    @Named("StateRoot") final Bytes32 stateRoot,
    final WorldStateStorage worldStateStorage,
    final WorldStatePreimageStorage worldStatePreimageStorage,
    final GenesisState genesisState,
    @Named("KeyValueStorageName") final String keyValueStorageName) {
  if ("memory".equals(keyValueStorageName)) {
    final DefaultMutableWorldState mutableWorldState =
        new DefaultMutableWorldState(worldStateStorage, worldStatePreimageStorage);
    genesisState.writeStateTo(mutableWorldState);
    return mutableWorldState;
  } else {
    return new DefaultMutableWorldState(stateRoot, worldStateStorage, worldStatePreimageStorage);
  }
}
 
Example #4
Source File: KafkaRuntimeConfigProducer.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Produces
@DefaultBean
@ApplicationScoped
@Named("default-kafka-broker")
public Map<String, Object> createKafkaRuntimeConfig() {
    Map<String, Object> properties = new HashMap<>();
    final Config config = ConfigProvider.getConfig();

    StreamSupport
            .stream(config.getPropertyNames().spliterator(), false)
            .map(String::toLowerCase)
            .filter(name -> name.startsWith(configPrefix))
            .distinct()
            .sorted()
            .forEach(name -> {
                final String key = name.substring(configPrefix.length() + 1).toLowerCase().replaceAll("[^a-z0-9.]", ".");
                final String value = config.getOptionalValue(name, String.class).orElse("");
                properties.put(key, value);
            });

    return properties;
}
 
Example #5
Source File: ProbeScheduler.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@Inject
public ProbeScheduler(
    @Named("che.workspace.probe_pool_size") int probeSchedulerPoolSize,
    ExecutorServiceWrapper executorServiceWrapper) {
  probesExecutor =
      executorServiceWrapper.wrap(
          new ScheduledThreadPoolExecutor(
              probeSchedulerPoolSize,
              new ThreadFactoryBuilder()
                  .setDaemon(true)
                  .setNameFormat("ServerProbes-%s")
                  .build()),
          ProbeScheduler.class.getName());
  timeouts = new Timer("ServerProbesTimeouts", true);
  probesFutures = new ConcurrentHashMap<>();
}
 
Example #6
Source File: MessagingEndpoint.java    From watchpresenter with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param versionNumber Version number for which message should be retrieved
 */
@ApiMethod(name = "getMessageForVersion")
public VersionMessage getMessageForVersion(@Named("versionNumber")int versionNumber, User user)
        throws IOException, OAuthRequestException {
    if(user == null){
        throw new OAuthRequestException("Not authorized");
    }
    final String userId = PresenterRecord.getUserId(user.getEmail());
    if(log.isLoggable(Level.FINE)) {
        log.fine("Get message version for userId " +
                userId + ". Version number: " + versionNumber);
    }
    VersionMessage message = new VersionMessage(
            VersionMessage.ACTION_NOTHING, "", "");
    return message;
}
 
Example #7
Source File: WordCountStream.java    From micronaut-kafka with Apache License 2.0 6 votes vote down vote up
@Singleton
@Named(MY_STREAM)
KStream<String, String> myStream(
        @Named(MY_STREAM) ConfiguredStreamBuilder builder) {

    // end::namedStream[]
    // set default serdes
    Properties props = builder.getConfiguration();
    props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName());
    props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName());
    props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");

    KStream<String, String> source = builder.stream(NAMED_WORD_COUNT_INPUT);
    KTable<String, Long> counts = source
            .flatMapValues(value -> Arrays.asList(value.toLowerCase(Locale.getDefault()).split(" ")))
            .groupBy((key, value) -> value)
            .count();

    // need to override value serde to Long type
    counts.toStream().to(NAMED_WORD_COUNT_OUTPUT, Produced.with(Serdes.String(), Serdes.Long()));
    return source;
}
 
Example #8
Source File: BindingToClassTest.java    From toothpick with Apache License 2.0 6 votes vote down vote up
@Test
public void testBindingToClassAPI_withNameAsAnnotation_asSingleton() {
  // GIVEN
  Module module = new Module();

  // WHEN
  module.bind(String.class).withName(Named.class).to(String.class).singleton();

  // THEN
  Binding<String> binding = getBinding(module);
  assertBinding(
      binding,
      CLASS,
      String.class,
      Named.class.getCanonicalName(),
      String.class,
      null,
      null,
      null,
      true,
      false,
      false,
      false);
}
 
Example #9
Source File: CmdDeleteConfValue.java    From linstor-server with GNU General Public License v3.0 6 votes vote down vote up
@Inject
public CmdDeleteConfValue(
    DbConnectionPool dbConnectionPoolRef,
    @Named(CoreModule.CTRL_CONF_LOCK) ReadWriteLock confLockRef,
    SystemConfRepository systemConfRepositoryRef,
    Provider<TransactionMgr> trnActProviderRef
)
{
    super(
        new String[]
        {
            "DelCfgVal"
        },
        "Deletes a configuration value",
        "Deletes an entry from the configuration.",
        PARAMETER_DESCRIPTIONS,
        null
    );

    dbConnectionPool = dbConnectionPoolRef;
    confWrLock = confLockRef.writeLock();
    systemConfRepository = systemConfRepositoryRef;
    trnActProvider = trnActProviderRef;
}
 
Example #10
Source File: ApplicationDirectoriesImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Inject
public ApplicationDirectoriesImpl(@Named("${karaf.base}") final File installDir,
                                  @Named("${karaf.data}") final File workDir)
{
  this.installDir = resolve(installDir, false);
  log.debug("Install dir: {}", this.installDir);

  this.configDir = resolve(new File(installDir, "etc"), false);
  log.debug("Config dir: {}", this.configDir);

  this.workDir = resolve(workDir, true);
  log.debug("Work dir: {}", this.workDir);

  // Resolve the tmp dir from system properties.
  String tmplocation = System.getProperty("java.io.tmpdir", "tmp");
  this.tempDir = resolve(new File(tmplocation), true);
  log.debug("Temp dir: {}", this.tempDir);
}
 
Example #11
Source File: CmdRunDeviceManager.java    From linstor-server with GNU General Public License v3.0 5 votes vote down vote up
@Inject
public CmdRunDeviceManager(
    DeviceManager deviceManagerRef,
    @Named(CoreModule.RSC_DFN_MAP_LOCK) ReadWriteLock rscDfnMapLockRef,
    CoreModule.ResourceDefinitionMap rscDfnMapRef,
    ControllerPeerConnector ctrlPeerConnRef
)
{
    super(
        new String[]
        {
            "RunDevMgr"
        },
        "Run device manager operations on selected resources",
        "The device manager is notified to run operations on selected resources, thereby attempting" +
        "to adjust the state of those resources to their respective target states.\n\n" +
        "If the device manager service is stopped, operations will commonly run when the\n" +
        "device manager service is restarted.",
        PARAMETER_DESCRIPTIONS,
        null
    );

    deviceManager = deviceManagerRef;
    rscDfnMapLock = rscDfnMapLockRef;
    rscDfnMap = rscDfnMapRef;
    ctrlPeerConn = ctrlPeerConnRef;
}
 
Example #12
Source File: WaxEndpoint.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
/**
 * Remove an existing session.
 * <p>
 * Clients that create sessions without a duration (will last forever) will need to call this
 * method on their own to clean up the session.
 *
 * @return {@link WaxRemoveSessionResponse} with the deleted session id
 * @throws InternalServerErrorException if the session deletion failed
 */
@ApiMethod(
    name = "sessions.remove",
    path = "removesession",
    httpMethod = HttpMethod.POST)
public WaxRemoveSessionResponse removeSession(@Named("sessionId") String sessionId)
    throws InternalServerErrorException {
  try {
    store.deleteSession(sessionId);
    return new WaxRemoveSessionResponse(sessionId);
  } catch (InvalidSessionException e) {
    throw new InternalServerErrorException(e.getMessage());
  }
}
 
Example #13
Source File: InsightsApi.java    From bitbucket-rest with Apache License 2.0 5 votes vote down vote up
@Named("insights:delete-report")
@Documentation( {"https://docs.atlassian.com/bitbucket-server/rest/6.4.0/bitbucket-code-insights-rest.html#idp8"})
@Consumes(MediaType.APPLICATION_JSON)
@Path("/projects/{project}/repos/{repo}/commits/{commitId}/reports/{key}")
@Fallback(BitbucketFallbacks.RequestStatusOnError.class)
@ResponseParser(RequestStatusParser.class)
@DELETE
RequestStatus deleteReport(@PathParam("project") String project,
                           @PathParam("repo") String repo,
                           @PathParam("commitId") String commitId,
                           @PathParam("key") String key);
 
Example #14
Source File: CurrentProcessInstance.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the id of the currently associated process instance or 'null'
 */
/* Makes the processId available for injection */
@Produces
@Named
@ProcessInstanceId
public String getProcessInstanceId() {
    return businessProcess.getProcessInstanceId();
}
 
Example #15
Source File: ReqVlmAllocated.java    From linstor-server with GNU General Public License v3.0 5 votes vote down vote up
@Inject
public ReqVlmAllocated(
    ScopeRunner scopeRunnerRef,
    StltApiCallHandlerUtils apiCallHandlerUtilsRef,
    CommonSerializer commonSerializerRef,
    @Named(ApiModule.API_CALL_ID) Provider<Long> apiCallIdProviderRef
)
{
    scopeRunner = scopeRunnerRef;
    apiCallHandlerUtils = apiCallHandlerUtilsRef;
    commonSerializer = commonSerializerRef;
    apiCallIdProvider = apiCallIdProviderRef;
}
 
Example #16
Source File: ApplicationModule.java    From exchange-rates-mvvm with Apache License 2.0 5 votes vote down vote up
@Override
@Provides
@Singleton
@Named("remote")
public CurrencyDataSource provideRemoteCurrencyDataSource(ApplicationProperties properties, final CurrencyDataApi currencyDataApi){
    return new RetrofitCurrencyDataSource(currencyDataApi, properties.getOerAppId());
}
 
Example #17
Source File: DynamicFilterChainManager.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public DynamicFilterChainManager(@Named("SHIRO") final ServletContext servletContext,
    final List<FilterChain> filterChains, final BeanLocator locator)
{
  super(new DelegatingFilterConfig("SHIRO", checkNotNull(servletContext)));
  this.filterChains = checkNotNull(filterChains);

  // install the watchers for dynamic components contributed by other bundles
  locator.watch(Key.get(Filter.class, Named.class), new FilterInstaller(), this);
  locator.watch(Key.get(FilterChain.class), new FilterChainRefresher(), this);
}
 
Example #18
Source File: CreateOfferDataModel.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Inject
public CreateOfferDataModel(CreateOfferService createOfferService,
                            OpenOfferManager openOfferManager,
                            BtcWalletService btcWalletService,
                            BsqWalletService bsqWalletService,
                            Preferences preferences,
                            User user,
                            P2PService p2PService,
                            PriceFeedService priceFeedService,
                            AccountAgeWitnessService accountAgeWitnessService,
                            FeeService feeService,
                            @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
                            MakerFeeProvider makerFeeProvider,
                            Navigation navigation) {
    super(createOfferService,
            openOfferManager,
            btcWalletService,
            bsqWalletService,
            preferences,
            user,
            p2PService,
            priceFeedService,
            accountAgeWitnessService,
            feeService,
            btcFormatter,
            makerFeeProvider,
            navigation);
}
 
Example #19
Source File: ClientModule.java    From fyber_mobile_offers with MIT License 5 votes vote down vote up
@Provides
@Singleton
public Cache provideCache(@Named("cacheDir") File cacheDir, @Named("cacheSize") long cacheSize) {
    Cache cache = null;

    try {
        cache = new Cache(new File(cacheDir.getPath(), "http-cache"), cacheSize);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return cache;
}
 
Example #20
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Singleton @Provides @Named("retrofit-auto-update") Retrofit providesAutoUpdateRetrofit(
    @Named("default") OkHttpClient httpClient, @Named("auto-update-base-host") String baseHost,
    Converter.Factory converterFactory, @Named("rx") CallAdapter.Factory rxCallAdapterFactory) {
  return new Retrofit.Builder().baseUrl(baseHost)
      .client(httpClient)
      .addCallAdapterFactory(rxCallAdapterFactory)
      .addConverterFactory(converterFactory)
      .build();
}
 
Example #21
Source File: ParseQuery.java    From heroic with Apache License 2.0 5 votes vote down vote up
@Inject
public ParseQuery(
    Clock clock, QueryParser parser, AsyncFramework async,
    @Named("application/json") ObjectMapper mapper
) {
    this.clock = clock;
    this.parser = parser;
    this.async = async;
    this.mapper = mapper;
}
 
Example #22
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Singleton @Provides @Named("user-agent-v8") Interceptor provideUserAgentInterceptorV8(
    IdsRepository idsRepository, @Named("aptoidePackage") String aptoidePackage,
    AuthenticationPersistence authenticationPersistence, AptoideMd5Manager aptoideMd5Manager) {
  return new UserAgentInterceptorV8(idsRepository, AptoideUtils.SystemU.getRelease(),
      Build.VERSION.SDK_INT, AptoideUtils.SystemU.getModel(), AptoideUtils.SystemU.getProduct(),
      System.getProperty("os.arch"), new DisplayMetrics(),
      AptoideUtils.Core.getDefaultVername(application)
          .replace("aptoide-", ""), aptoidePackage, aptoideMd5Manager, BuildConfig.VERSION_CODE,
      authenticationPersistence);
}
 
Example #23
Source File: NexusLifecycleManagerTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  phases = newArrayList(
      offPhase,
      kernelPhase,
      storagePhase,
      restorePhase,
      upgradePhase,
      schemasPhase,
      eventsPhase,
      securityPhase,
      servicesPhase,
      capabilitiesPhase,
      tasksPhase
  );

  assertThat("One or more phases is not mocked", phases.size(), is(Phase.values().length));

  // OFF phase should never get called
  doThrow(new Exception("testing")).when(offPhase).start();
  doThrow(new Exception("testing")).when(offPhase).stop();

  // randomize location results
  randomPhases = new ArrayList<>(phases);
  Collections.shuffle(randomPhases);
  Iterable<BeanEntry<Named, Lifecycle>> entries = randomPhases.stream().map(phase -> {
    BeanEntry<Named, Lifecycle> entry = mock(BeanEntry.class);
    doReturn(phase.getClass().getSuperclass()).when(entry).getImplementationClass();
    when(entry.getValue()).thenReturn(phase);
    return entry;
  }).collect(toList());

  when(locator.<Named, Lifecycle> locate(Key.get(Lifecycle.class, Named.class))).thenReturn(entries);

  underTest = new NexusLifecycleManager(locator, systemBundle);
}
 
Example #24
Source File: RPackagesBuilderFacetImpl.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param eventManager The event manager to use when posting new events.
 * @param interval     The interval in milliseconds to wait between rebuilds.
 */
@Inject
public RPackagesBuilderFacetImpl(
    final EventManager eventManager,
    @Named("${nexus.r.packagesBuilder.interval:-1000}") final long interval)
{
  this.eventManager = checkNotNull(eventManager);
  this.interval = interval;
}
 
Example #25
Source File: RestartContainerResolver.java    From incubator-heron with Apache License 2.0 5 votes vote down vote up
@Inject
public RestartContainerResolver(@Named(CONF_TOPOLOGY_NAME) String topologyName,
                                EventManager eventManager,
                                ISchedulerClient schedulerClient,
                                HealthManagerMetrics publishingMetrics) {
  this.topologyName = topologyName;
  this.eventManager = eventManager;
  this.schedulerClient = schedulerClient;
  this.publishingMetrics = publishingMetrics;
}
 
Example #26
Source File: LegacyKeyStoreUpgradeService.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public LegacyKeyStoreUpgradeService(@Named(DatabaseInstanceNames.CONFIG) final Provider<DatabaseInstance> databaseInstance,
                                    final ApplicationDirectories appDirectories)
{
  this.databaseInstance = checkNotNull(databaseInstance);
  keyStoreBasedir = new File(appDirectories.getWorkDirectory("keystores", false), KeyStoreManagerImpl.NAME).toPath();
}
 
Example #27
Source File: StaticListDiscovery.java    From heroic with Apache License 2.0 5 votes vote down vote up
@Inject
public StaticListDiscovery(
    AsyncFramework async,
    @Named("nodes") List<URI> nodes
) {
    this.async = async;
    this.nodes = nodes;
}
 
Example #28
Source File: CheckInEndpoint.java    From solutions-mobile-shopping-assistant-backend-java with Apache License 2.0 5 votes vote down vote up
/**
 * This method gets the entity having primary key id. It uses HTTP GET method.
 *
 * @param id the primary key of the java bean.
 * @return The entity with primary key id.
 */
@ApiMethod(name = "getCheckIn")
public CheckIn getCheckIn(@Named("id") Long id) {
  EntityManager mgr = getEntityManager();
  CheckIn checkin = null;
  try {
    checkin = mgr.find(CheckIn.class, id);
  } finally {
    mgr.close();
  }
  return checkin;
}
 
Example #29
Source File: SubmitCommand.java    From startup-os with Apache License 2.0 5 votes vote down vote up
@Inject
public SubmitCommand(
    FileUtils utils,
    GitRepoFactory repoFactory,
    @Named("Workspace path") String workspacePath,
    @Named("Diff number") Integer diffNumber) {
  this.fileUtils = utils;
  this.gitRepoFactory = repoFactory;
  this.workspacePath = workspacePath;
  this.diffNumber = diffNumber;

  ManagedChannel channel =
      ManagedChannelBuilder.forAddress("localhost", GRPC_PORT).usePlaintext().build();
  codeReviewBlockingStub = CodeReviewServiceGrpc.newBlockingStub(channel);
}
 
Example #30
Source File: AppModule.java    From hacker-news-android with Apache License 2.0 5 votes vote down vote up
@Provides
@Named("retrofit-loglevel")
RestAdapter.LogLevel providesLogLevel(){
    if(BuildConfig.DEBUG) {
        return RestAdapter.LogLevel.FULL;
    }
    else {
        return RestAdapter.LogLevel.NONE;
    }
}