Java Code Examples for javax.inject.Inject

The following examples show how to use javax.inject.Inject. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: presto   Source File: ShardOrganizationManager.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public ShardOrganizationManager(
        @ForMetadata IDBI dbi,
        NodeManager nodeManager,
        ShardManager shardManager,
        ShardOrganizer organizer,
        TemporalFunction temporalFunction,
        StorageManagerConfig config)
{
    this(dbi,
            nodeManager.getCurrentNode().getNodeIdentifier(),
            shardManager,
            organizer,
            temporalFunction,
            config.isOrganizationEnabled(),
            config.getOrganizationInterval(),
            config.getOrganizationDiscoveryInterval());
}
 
Example 2
Source Project: presto   Source File: KuduConnector.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public KuduConnector(
        LifeCycleManager lifeCycleManager,
        KuduMetadata metadata,
        ConnectorSplitManager splitManager,
        KuduTableProperties tableProperties,
        ConnectorPageSourceProvider pageSourceProvider,
        ConnectorPageSinkProvider pageSinkProvider,
        Set<Procedure> procedures)
{
    this.lifeCycleManager = requireNonNull(lifeCycleManager, "lifeCycleManager is null");
    this.metadata = requireNonNull(metadata, "metadata is null");
    this.splitManager = requireNonNull(splitManager, "splitManager is null");
    this.pageSourceProvider = requireNonNull(pageSourceProvider, "pageSourceProvider is null");
    this.tableProperties = requireNonNull(tableProperties, "tableProperties is null");
    this.pageSinkProvider = requireNonNull(pageSinkProvider, "pageSinkProvider is null");
    this.procedures = ImmutableSet.copyOf(requireNonNull(procedures, "procedures is null"));
}
 
Example 3
Source Project: plugins   Source File: OpponentInfoOverlay.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Inject
private OpponentInfoOverlay(
	final OpponentInfoPlugin opponentInfoPlugin,
	final OpponentInfoConfig opponentInfoConfig)
{
	super(opponentInfoPlugin);
	this.opponentInfoPlugin = opponentInfoPlugin;
	this.opponentInfoConfig = opponentInfoConfig;

	setPosition(OverlayPosition.TOP_LEFT);
	setPriority(OverlayPriority.HIGH);

	panelComponent.setBorder(new Rectangle(2, 2, 2, 2));
	panelComponent.setGap(new Point(0, 2));
	getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Opponent info overlay"));
}
 
Example 4
@Inject
private KourendLibraryTutorialOverlay(Client client, KourendLibraryConfig config, Library library)
{
	this.client = client;
	this.config = config;
	this.library = library;

	panelComponent.setPreferredSize(new Dimension(177, 0));

	noDataMessageComponent = LineComponent.builder().left("Click on the white squares to start finding books.").build();
	incompleteMessageComponent = LineComponent.builder().left("Some books have been found. Keep checking marked bookcases to find more.").build();
	completeMessageComponent = LineComponent.builder().left("All books found.").build();
	sidebarMessageComponent = LineComponent.builder().left("Locations are in the sidebar.").build();

	setPriority(OverlayPriority.LOW);
	setPosition(OverlayPosition.TOP_LEFT);
}
 
Example 5
private static <T> @Nullable Constructor<T> findSingleInjectConstructor(Class<T> cls) {
  // Not modifying it, safe to use generics; see Class#getConstructors() for more info.
  @SuppressWarnings("unchecked")
  Constructor<T>[] constructors = (Constructor<T>[]) cls.getDeclaredConstructors();
  Constructor<T> target = null;
  for (Constructor<T> constructor : constructors) {
    if (constructor.getAnnotation(Inject.class) != null) {
      if (target != null) {
        throw new IllegalStateException(
            cls.getCanonicalName() + " defines multiple @Inject-annotations constructors");
      }
      target = constructor;
    }
  }
  return target;
}
 
Example 6
Source Project: presto   Source File: ThriftConnector.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public ThriftConnector(
        LifeCycleManager lifeCycleManager,
        ThriftMetadata metadata,
        ThriftSplitManager splitManager,
        ThriftPageSourceProvider pageSourceProvider,
        ThriftSessionProperties sessionProperties,
        ThriftIndexProvider indexProvider)
{
    this.lifeCycleManager = requireNonNull(lifeCycleManager, "lifeCycleManager is null");
    this.metadata = requireNonNull(metadata, "metadata is null");
    this.splitManager = requireNonNull(splitManager, "splitManager is null");
    this.pageSourceProvider = requireNonNull(pageSourceProvider, "pageSourceProvider is null");
    this.sessionProperties = requireNonNull(sessionProperties, "sessionProperties is null");
    this.indexProvider = requireNonNull(indexProvider, "indexProvider is null");
}
 
Example 7
Source Project: openAGV   Source File: IntegrationLevelChangeAction.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param vehicles The selected vehicles.
 * @param level The level to to change the vehicles to.
 * @param portalProvider Provides access to a shared portal.
 */
@Inject
public IntegrationLevelChangeAction(@Assisted Collection<VehicleModel> vehicles,
                                    @Assisted Vehicle.IntegrationLevel level,
                                    SharedKernelServicePortalProvider portalProvider) {
  this.vehicles = requireNonNull(vehicles, "vehicles");
  this.level = requireNonNull(level, "level");
  this.portalProvider = requireNonNull(portalProvider, "portalProvider");

  String actionName;
  switch (level) {
    case TO_BE_NOTICED:
      actionName = bundle.getString("integrationLevelChangeAction.notice.name");
      break;
    case TO_BE_RESPECTED:
      actionName = bundle.getString("integrationLevelChangeAction.respect.name");
      break;
    case TO_BE_UTILIZED:
      actionName = bundle.getString("integrationLevelChangeAction.utilize.name");
      break;
    default:
      actionName = bundle.getString("integrationLevelChangeAction.ignore.name");
      break;
  }
  putValue(NAME, actionName);
}
 
Example 8
Source Project: MergeProcessor   Source File: SvnClientJavaHl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param provider      to authenticate when required
 * @param configuration the configuration to get and set the username and
 *                      password
 * @throws SvnClientException
 */
@Inject
public SvnClientJavaHl(ICredentialProvider provider, IConfiguration configuration) throws SvnClientException {
	try {
		if (!SVNClientAdapterFactory.isSVNClientAvailable(JhlClientAdapterFactory.JAVAHL_CLIENT)) {
			JhlClientAdapterFactory.setup();
		}
		client = SVNClientAdapterFactory.createSVNClient(JhlClientAdapterFactory.JAVAHL_CLIENT);
		final String username = configuration.getSvnUsername();
		if (username != null) {
			client.setUsername(username);
		}
		final String password = configuration.getSvnPassword();
		if (password != null) {
			client.setPassword(password);
		}
		client.addPasswordCallback(new SVNPromptUserPassword(provider, configuration, client));
	} catch (SVNClientException | ConfigurationException e) {
		throw new SvnClientException(e);
	}
}
 
Example 9
Source Project: presto   Source File: GlueHiveMetastore.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public GlueHiveMetastore(
        HdfsEnvironment hdfsEnvironment,
        GlueHiveMetastoreConfig glueConfig,
        GlueColumnStatisticsProvider columnStatisticsProvider,
        @ForGlueHiveMetastore Executor executor,
        @ForGlueHiveMetastore Optional<RequestHandler2> requestHandler)
{
    requireNonNull(glueConfig, "glueConfig is null");
    this.hdfsEnvironment = requireNonNull(hdfsEnvironment, "hdfsEnvironment is null");
    this.hdfsContext = new HdfsContext(ConnectorIdentity.ofUser(DEFAULT_METASTORE_USER));
    this.glueClient = createAsyncGlueClient(glueConfig, requestHandler);
    this.defaultDir = glueConfig.getDefaultWarehouseDir();
    this.catalogId = glueConfig.getCatalogId().orElse(null);
    this.partitionSegments = glueConfig.getPartitionSegments();
    this.executor = requireNonNull(executor, "executor is null");
    this.columnStatisticsProvider = requireNonNull(columnStatisticsProvider, "columnStatisticsProvider is null");
}
 
Example 10
Source Project: presto   Source File: MultinodeTls.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public MultinodeTls(
        PathResolver pathResolver,
        DockerFiles dockerFiles,
        PortBinder portBinder,
        Standard standard,
        Hadoop hadoop,
        EnvironmentOptions environmentOptions)
{
    super(ImmutableList.of(standard, hadoop));
    this.pathResolver = requireNonNull(pathResolver, "pathResolver is null");
    this.dockerFiles = requireNonNull(dockerFiles, "dockerFiles is null");
    this.portBinder = requireNonNull(portBinder, "portBinder is null");
    imagesVersion = requireNonNull(environmentOptions.imagesVersion, "environmentOptions.imagesVersion is null");
    serverPackage = requireNonNull(environmentOptions.serverPackage, "environmentOptions.serverPackage is null");
}
 
Example 11
@Inject
private ScreenMarkerWidgetHighlightOverlay(final ScreenMarkerPlugin plugin, final Client client)
{
	this.plugin = plugin;
	this.client = client;
	setPosition(OverlayPosition.DETACHED);
	setLayer(OverlayLayer.ABOVE_WIDGETS);
	setPriority(OverlayPriority.HIGH);
}
 
Example 12
Source Project: presto   Source File: ResourceAccessType.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public ResourceAccessType(StaticResourceAccessTypeLoader staticResourceAccessTypeLoader)
{
    this.resourceAccessTypeLoaders = ImmutableList.<ResourceAccessTypeLoader>builder()
            .add(staticResourceAccessTypeLoader)
            .add(new AnnotatedResourceAccessTypeLoader())
            .build();
}
 
Example 13
@Inject
private ScreenMarkerCreationOverlay(final ScreenMarkerPlugin plugin)
{
	this.plugin = plugin;
	setPosition(OverlayPosition.DETACHED);
	setLayer(OverlayLayer.ALWAYS_ON_TOP);
	setPriority(OverlayPriority.HIGH);
}
 
Example 14
Source Project: presto   Source File: TaskExecutor.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public TaskExecutor(TaskManagerConfig config, EmbedVersion embedVersion, MultilevelSplitQueue splitQueue)
{
    this(requireNonNull(config, "config is null").getMaxWorkerThreads(),
            config.getMinDrivers(),
            config.getMinDriversPerTask(),
            config.getMaxDriversPerTask(),
            embedVersion,
            splitQueue,
            Ticker.systemTicker());
}
 
Example 15
/**
 * Decorates the server span with custom data when the gRPC call is closed.
 *
 * @param serverCloseDecorator used to decorate the server span
 */
@Inject
public void setServerCloseDecorator(@Nullable ServerCloseDecorator serverCloseDecorator) {
    if (serverCloseDecorator != null) {
        builder.withServerCloseDecorator(serverCloseDecorator);
    }
}
 
Example 16
Source Project: openAGV   Source File: RobotCommAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public RobotCommAdapter(AdapterComponentsFactory componentsFactory,
                        RobotConfiguration configuration,
                        StandardVehicleService vehicleService,
                        StandardTransportOrderService transportOrderService,
                        StandardPlantModelService plantModelService,
                        StandardDispatcherService dispatcherService,
                        DefaultRouter router,
                        VehicleControllerPool vehicleControllerPool,
                        @Assisted Vehicle vehicle,
                        @KernelExecutor ExecutorService kernelExecutor) {

    super(new RobotProcessModel(vehicle),
            configuration.commandQueueCapacity(),
            configuration.sentQueueCapacity(),
            configuration.rechargeOperation());


    this.vehicle = requireNonNull(vehicle, "vehicle");
    this.configuration = requireNonNull(configuration, "configuration");
    this.componentsFactory = requireNonNull(componentsFactory, "componentsFactory");
    this.kernelExecutor = requireNonNull(kernelExecutor, "kernelExecutor");

    this.vehicleService = vehicleService;
    this.transportOrderService = transportOrderService;
    this.dispatcherService = dispatcherService;
    this.plantModelService = plantModelService;
    this.router = router;
    this.vehicleControllerPool = vehicleControllerPool;

    /**移动命令队列*/
    this.tempCommandQueue = new LinkedBlockingQueue<>();
    this.movementCommandQueue = new LinkedBlockingQueue<>();
}
 
Example 17
@Inject
IncomingPublishService(final @NotNull InternalPublishService publishService,
                       final @NotNull EventLog eventLog,
                       final @NotNull MqttConfigurationService mqttConfigurationService,
                       final @NotNull Mqtt5ServerDisconnector mqtt5ServerDisconnector) {

    this.publishService = publishService;
    this.eventLog = eventLog;
    this.mqttConfigurationService = mqttConfigurationService;
    this.mqtt5ServerDisconnector = mqtt5ServerDisconnector;
}
 
Example 18
Source Project: presto   Source File: ProxyResource.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public ProxyResource(@ForProxy HttpClient httpClient, JsonWebTokenHandler jwtHandler, ProxyConfig config)
{
    this.httpClient = requireNonNull(httpClient, "httpClient is null");
    this.jwtHandler = requireNonNull(jwtHandler, "jwtHandler is null");
    this.remoteUri = requireNonNull(config.getUri(), "uri is null");
    this.hmac = hmacSha256(loadSharedSecret(config.getSharedSecretFile()));
}
 
Example 19
Source Project: hadoop-ozone   Source File: ContainerEndpoint.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public ContainerEndpoint(OzoneStorageContainerManager reconSCM,
                         ContainerSchemaManager containerSchemaManager) {
  this.containerManager =
      (ReconContainerManager) reconSCM.getContainerManager();
  this.containerSchemaManager = containerSchemaManager;
}
 
Example 20
Source Project: openAGV   Source File: StandardTransportOrderService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param objectService The tcs obejct service.
 * @param globalSyncObject The kernel threads' global synchronization object.
 * @param globalObjectPool The object pool to be used.
 * @param orderPool The oder pool to be used.
 * @param model The model to be used.
 */
@Inject
public StandardTransportOrderService(TCSObjectService objectService,
                                     @GlobalSyncObject Object globalSyncObject,
                                     TCSObjectPool globalObjectPool,
                                     TransportOrderPool orderPool,
                                     Model model) {
  super(objectService);
  this.globalSyncObject = requireNonNull(globalSyncObject, "globalSyncObject");
  this.globalObjectPool = requireNonNull(globalObjectPool, "globalObjectPool");
  this.orderPool = requireNonNull(orderPool, "orderPool");
  this.model = requireNonNull(model, "model");
}
 
Example 21
Source Project: plugins   Source File: NpcSceneOverlay.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Inject
NpcSceneOverlay(final Client client, final NpcIndicatorsPlugin plugin, final NpcIndicatorsConfig config, final ModelOutlineRenderer modelOutliner)
{
	this.client = client;
	this.plugin = plugin;
	this.config = config;
	this.modelOutliner = modelOutliner;
	setPosition(OverlayPosition.DYNAMIC);
	setLayer(OverlayLayer.ABOVE_SCENE);
}
 
Example 22
Source Project: openAGV   Source File: PeriodicVehicleRedispatchingTask.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param dispatcherService The dispatcher service used to dispatch vehicles.
 * @param objectService The object service.
 */
@Inject
public PeriodicVehicleRedispatchingTask(DispatcherService dispatcherService,
                                        TCSObjectService objectService) {
  this.dispatcherService = requireNonNull(dispatcherService, "dispatcherService");
  this.objectService = requireNonNull(objectService, "objectService");
}
 
Example 23
Source Project: hmdm-server   Source File: IconFileResource.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <p>Constructs new <code>IconFileResource</code> instance. This implementation does nothing.</p>
 */
@Inject
public IconFileResource(UploadedFileDAO uploadedFileDAO,
                        CustomerDAO customerDAO,
                        @Named("files.directory") String filesDirectory) {
    this.uploadedFileDAO = uploadedFileDAO;
    this.customerDAO = customerDAO;
    this.filesDirectory = filesDirectory;
}
 
Example 24
Source Project: plugins   Source File: BlastMineRockOverlay.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Inject
private BlastMineRockOverlay(final Client client, final BlastMinePlugin plugin, final BlastMinePluginConfig config, final ItemManager itemManager)
{
	setPosition(OverlayPosition.DYNAMIC);
	setLayer(OverlayLayer.ABOVE_SCENE);
	this.client = client;
	this.plugin = plugin;
	this.config = config;
	chiselIcon = itemManager.getImage(ItemID.CHISEL);
	dynamiteIcon = itemManager.getImage(ItemID.DYNAMITE);
	tinderboxIcon = itemManager.getImage(ItemID.TINDERBOX);
}
 
Example 25
@Inject
public PendingWillMessages(@NotNull final InternalPublishService publishService,
                           @Persistence final ListeningScheduledExecutorService executorService,
                           @NotNull final ClientSessionPersistence clientSessionPersistence,
                           @NotNull final ClientSessionLocalPersistence clientSessionLocalPersistence) {
    this.publishService = publishService;
    this.executorService = executorService;
    this.clientSessionPersistence = clientSessionPersistence;
    this.clientSessionLocalPersistence = clientSessionLocalPersistence;
    executorService.scheduleAtFixedRate(new CheckWillsTask(), WILL_DELAY_CHECK_SCHEDULE, WILL_DELAY_CHECK_SCHEDULE, TimeUnit.SECONDS);

}
 
Example 26
@Inject
public DisconnectHandler(final EventLog eventLog, final MetricsHolder metricsHolder, final TopicAliasLimiter topicAliasLimiter) {
    this.eventLog = eventLog;
    this.metricsHolder = metricsHolder;
    this.topicAliasLimiter = topicAliasLimiter;
    this.logClientReasonString = InternalConfigurations.LOG_CLIENT_REASON_STRING_ON_DISCONNECT;
}
 
Example 27
@Inject
ClientQueueMemoryLocalPersistence(
        final @NotNull PublishPayloadPersistence payloadPersistence,
        final @NotNull MessageDroppedService messageDroppedService,
        final @NotNull MetricRegistry metricRegistry) {

    retainedMessageMax = InternalConfigurations.RETAINED_MESSAGE_QUEUE_SIZE.get();
    qos0ClientMemoryLimit = InternalConfigurations.QOS_0_MEMORY_LIMIT_PER_CLIENT.get();

    final int bucketCount = InternalConfigurations.PERSISTENCE_BUCKET_COUNT.get();
    this.messageDroppedService = messageDroppedService;
    this.payloadPersistence = payloadPersistence;
    this.qos0MemoryLimit = getQos0MemoryLimit();

    //must be concurrent as it is not protected by bucket access
    this.clientQos0MemoryMap = new ConcurrentHashMap<>();
    this.totalMemorySize = new AtomicLong();
    this.qos0MessagesMemory = new AtomicLong();

    //noinspection unchecked
    this.qos12MessageBuckets = new HashMap[bucketCount];
    //noinspection unchecked
    this.qos0MessageBuckets = new HashMap[bucketCount];
    //noinspection unchecked
    this.queueSizeBuckets = new HashMap[bucketCount];
    //noinspection unchecked
    this.retainedQueueSizeBuckets = new HashMap[bucketCount];

    for (int i = 0; i < bucketCount; i++) {
        qos12MessageBuckets[i] = new HashMap<>();
        qos0MessageBuckets[i] = new HashMap<>();
        queueSizeBuckets[i] = new HashMap<>();
        retainedQueueSizeBuckets[i] = new HashMap<>();
    }

    metricRegistry.register(
            HiveMQMetrics.QUEUED_MESSAGES_MEMORY_PERSISTENCE_TOTAL_SIZE.name(),
            (Gauge<Long>) totalMemorySize::get);

}
 
Example 28
Source Project: presto   Source File: ThriftIndexProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public ThriftIndexProvider(DriftClient<PrestoThriftService> client, ThriftHeaderProvider thriftHeaderProvider, ThriftConnectorStats stats, ThriftConnectorConfig config)
{
    this.client = requireNonNull(client, "client is null");
    this.thriftHeaderProvider = requireNonNull(thriftHeaderProvider, "thriftHeaderProvider is null");
    this.stats = requireNonNull(stats, "stats is null");
    requireNonNull(config, "config is null");
    this.maxBytesPerResponse = config.getMaxResponseSize().toBytes();
    this.lookupRequestsConcurrency = config.getLookupRequestsConcurrency();
}
 
Example 29
Source Project: openAGV   Source File: PathConnection.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param model The model corresponding to this graphical object.
 * @param textGenerator The tool tip text generator.
 */
@Inject
public PathConnection(@Assisted PathModel model,
                      ToolTipTextGenerator textGenerator) {
  super(model);
  this.textGenerator = requireNonNull(textGenerator, "textGenerator");
  resetPath();
}
 
Example 30
Source Project: presto   Source File: IndexLookup.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public IndexLookup(Connector connector, ColumnCardinalityCache cardinalityCache)
{
    this.connector = requireNonNull(connector, "connector is null");
    this.cardinalityCache = requireNonNull(cardinalityCache, "cardinalityCache is null");

    // Create a bounded executor with a pool size at 4x number of processors
    this.coreExecutor = newCachedThreadPool(daemonThreadsNamed("cardinality-lookup-%s"));
    this.executorService = new BoundedExecutor(coreExecutor, 4 * Runtime.getRuntime().availableProcessors());
}