javax.inject.Inject Java Examples

The following examples show how to use javax.inject.Inject. 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: ReflectiveJustInTimeLookupFactory.java    From dagger-reflect with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: GlueHiveMetastore.java    From presto with 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 #3
Source File: ShardOrganizationManager.java    From presto with 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 #4
Source File: SvnClientJavaHl.java    From MergeProcessor with 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 #5
Source File: MultinodeTls.java    From presto with 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 #6
Source File: KuduConnector.java    From presto with 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 #7
Source File: IntegrationLevelChangeAction.java    From openAGV with 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 File: OpponentInfoOverlay.java    From plugins with 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 #9
Source File: ThriftConnector.java    From presto with 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 #10
Source File: KourendLibraryTutorialOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@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 #11
Source File: OrderSequencesContainerPanel.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param portalProvider Provides a access to a portal.
 * @param transportViewFactory A factory for order sequence views.
 * @param dialogParent The parent component for dialogs shown by this instance.
 */
@Inject
public OrderSequencesContainerPanel(SharedKernelServicePortalProvider portalProvider,
                                    TransportViewFactory transportViewFactory,
                                    @ApplicationFrame Component dialogParent) {
  this.portalProvider = requireNonNull(portalProvider, "portalProvider");
  this.transportViewFactory = requireNonNull(transportViewFactory, "transportViewFactory");
  this.dialogParent = requireNonNull(dialogParent, "dialogParent");

  initComponents();
}
 
Example #12
Source File: PrioritizedParkingPositionSupplier.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param plantModelService The plant model service.
 * @param router A router for computing travel costs to parking positions.
 * @param priorityFunction A function computing the priority of a parking position.
 */
@Inject
public PrioritizedParkingPositionSupplier(InternalPlantModelService plantModelService,
                                          Router router,
                                          ParkingPositionToPriorityFunction priorityFunction) {
  super(plantModelService, router);
  this.priorityFunction = requireNonNull(priorityFunction, "priorityFunction");
}
 
Example #13
Source File: ElasticsearchMetadata.java    From presto with Apache License 2.0 5 votes vote down vote up
@Inject
public ElasticsearchMetadata(TypeManager typeManager, ElasticsearchClient client, ElasticsearchConfig config)
{
    requireNonNull(typeManager, "typeManager is null");
    this.ipAddressType = typeManager.getType(new TypeSignature(StandardTypes.IPADDRESS));
    this.client = requireNonNull(client, "client is null");
    requireNonNull(config, "config is null");
    this.schemaName = config.getDefaultSchema();
}
 
Example #14
Source File: CombatIconsOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Inject
private CombatIconsOverlay(final Client client, final BoostsPlugin plugin, final BoostsConfig config, final SkillIconManager iconManager)
{
	super(plugin);
	this.plugin = plugin;
	this.config = config;
	this.client = client;
	this.iconManager = iconManager;
	setPosition(OverlayPosition.TOP_LEFT);
	setPriority(OverlayPriority.MED);
	getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Boosts overlay"));
}
 
Example #15
Source File: AppDataManager.java    From v9porn with MIT License 5 votes vote down vote up
@Inject
AppDataManager(DbHelper mDbHelper, PreferencesHelper mPreferencesHelper, ApiHelper mApiHelper, HttpProxyCacheServer httpProxyCacheServer, CookieManager cookieManager, User user) {
    this.mDbHelper = mDbHelper;
    this.mPreferencesHelper = mPreferencesHelper;
    this.mApiHelper = mApiHelper;
    this.httpProxyCacheServer = httpProxyCacheServer;
    this.cookieManager = cookieManager;
    this.user = user;
}
 
Example #16
Source File: CoordinateCellEditor.java    From openAGV with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param textField
 */
@Inject
public CoordinateCellEditor(@Assisted JTextField textField,
                            @Assisted UserMessageHelper umh,
                            PropertiesComponentsFactory componentsFactory) {
  super(textField, umh);
  this.componentsFactory = requireNonNull(componentsFactory, "componentsFactory");
}
 
Example #17
Source File: AsyncHttpExecutionMBean.java    From presto with Apache License 2.0 5 votes vote down vote up
@Inject
public AsyncHttpExecutionMBean(@ForAsyncHttp ExecutorService responseExecutor, @ForAsyncHttp ScheduledExecutorService timeoutExecutor)
{
    requireNonNull(responseExecutor, "responseExecutor is null");
    requireNonNull(timeoutExecutor, "timeoutExecutor is null");
    this.responseExecutor = new ThreadPoolExecutorMBean((ThreadPoolExecutor) responseExecutor);
    this.timeoutExecutor = new ThreadPoolExecutorMBean((ThreadPoolExecutor) timeoutExecutor);
}
 
Example #18
Source File: WintertodtOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Inject
private WintertodtOverlay(final WintertodtPlugin plugin, WintertodtConfig wintertodtConfig)
{
	super(plugin);
	this.plugin = plugin;
	this.wintertodtConfig = wintertodtConfig;
	setPosition(OverlayPosition.BOTTOM_LEFT);
	getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Wintertodt overlay"));
}
 
Example #19
Source File: ParquetFileWriterFactory.java    From presto with Apache License 2.0 5 votes vote down vote up
@Inject
public ParquetFileWriterFactory(
        HdfsEnvironment hdfsEnvironment,
        TypeManager typeManager,
        NodeVersion nodeVersion,
        HiveConfig hiveConfig)
{
    this(
            hdfsEnvironment,
            typeManager,
            nodeVersion,
            requireNonNull(hiveConfig, "hiveConfig is null").getDateTimeZone());
}
 
Example #20
Source File: TaskResource.java    From presto with Apache License 2.0 5 votes vote down vote up
@Inject
public TaskResource(
        TaskManager taskManager,
        SessionPropertyManager sessionPropertyManager,
        @ForAsyncHttp BoundedExecutor responseExecutor,
        @ForAsyncHttp ScheduledExecutorService timeoutExecutor)
{
    this.taskManager = requireNonNull(taskManager, "taskManager is null");
    this.sessionPropertyManager = requireNonNull(sessionPropertyManager, "sessionPropertyManager is null");
    this.responseExecutor = requireNonNull(responseExecutor, "responseExecutor is null");
    this.timeoutExecutor = requireNonNull(timeoutExecutor, "timeoutExecutor is null");
}
 
Example #21
Source File: IndexLookup.java    From presto with 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());
}
 
Example #22
Source File: PathConnection.java    From openAGV with 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 #23
Source File: ThriftIndexProvider.java    From presto with 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 #24
Source File: ClientQueueMemoryLocalPersistence.java    From hivemq-community-edition with Apache License 2.0 5 votes vote down vote up
@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 #25
Source File: CookingOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Inject
private CookingOverlay(final Client client, final CookingPlugin plugin, final XpTrackerService xpTrackerService)
{
	super(plugin);
	setPosition(OverlayPosition.TOP_LEFT);
	this.client = client;
	this.plugin = plugin;
	this.xpTrackerService = xpTrackerService;
	getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Cooking overlay"));
	getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY, COOKING_RESET, "Cooking overlay"));
}
 
Example #26
Source File: DisconnectHandler.java    From hivemq-community-edition with Apache License 2.0 5 votes vote down vote up
@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
Source File: PendingWillMessages.java    From hivemq-community-edition with Apache License 2.0 5 votes vote down vote up
@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 #28
Source File: BlastMineRockOverlay.java    From plugins with 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 #29
Source File: IconFileResource.java    From hmdm-server with 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 #30
Source File: ResourceAccessType.java    From presto with 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();
}