下面列出了怎么用com.google.inject.Inject的API类实例代码及写法,或者点击链接到github查看源代码。
@Inject
public SessionHeartBeater(
Partitioner partitioner,
IntraServiceMessageBus intraServiceBus,
Supplier<Stream<PartitionedSession>> sessionSupplier
) {
this.sessionSupplier = sessionSupplier;
this.partitioner = partitioner;
this.intraServiceBus = intraServiceBus;
this.executor = Executors
.newSingleThreadScheduledExecutor(
ThreadPoolBuilder
.defaultFactoryBuilder()
.setNameFormat("ipcd-session-heartbeat")
.build()
);
this.heartbeatTimer = IrisMetrics.metrics("bridge.ipcd").timer("heartbeat");
}
@Inject
public AlexaPlatformService(AlexaPlatformServiceConfig config, PlatformMessageBus bus) {
this.bus = bus;
workerPool = new ThreadPoolBuilder()
.withMaxPoolSize(config.getMaxListenerThreads())
.withKeepAliveMs(config.getListenerThreadKeepAliveMs())
.withNameFormat(DISPATCHER_POOL_NAME + "-%d")
.withBlockingBacklog()
.withMetrics("alexa.bridge")
.build();
timeoutPool = new HashedWheelTimer(new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat(TIMEOUT_POOL_NAME + "-%d")
.setUncaughtExceptionHandler(new LoggingUncaughtExceptionHandler(logger))
.build());
defaultTimeoutSecs = config.getDefaultTimeoutSecs();
}
@Inject
public PlaceDeleter(
AccountDAO accountDao,
PlaceDAO placeDao,
PersonDAO personDao,
AuthorizationGrantDAO grantDao,
PreferencesDAO preferencesDao,
SubscriptionUpdater subscriptionUpdater,
PersonDeleter personDeleter,
PlatformMessageBus bus
) {
this.accountDao = accountDao;
this.placeDao = placeDao;
this.personDao = personDao;
this.grantDao = grantDao;
this.preferencesDao = preferencesDao;
this.subscriptionUpdater = subscriptionUpdater;
this.personDeleter = personDeleter;
this.bus = bus;
}
@Inject
public PlatformServiceDispatcher(
PlatformServiceConfig config,
PlatformMessageBus bus,
Set<PlatformService> services
) {
this.bus = bus;
this.services = IrisCollections.toUnmodifiableMap(services, (service) -> service.getAddress());
this.executor =
new ThreadPoolBuilder()
.withMaxPoolSize(config.getThreads())
.withKeepAliveMs(config.getKeepAliveMs())
.withBlockingBacklog()
.withNameFormat("platform-service-%d")
.withMetrics("platform.service")
.build();
}
@Inject
public CreateRequestHandler(
ContextLoader loader,
PlatformMessageBus platformBus,
PlaceExecutorRegistry registry,
PlaceDAO placeDao,
SceneDao sceneDao,
BeanAttributesTransformer<SceneDefinition> transformer
) {
this.loader = loader;
this.platformBus = platformBus;
this.registry = registry;
this.placeDao = placeDao;
this.sceneDao = sceneDao;
this.transformer = transformer;
}
@Inject
public CommandExecutor(
PlatformMessageBus bus,
@Named(VoiceConfig.NAME_EXECUTOR) ExecutorService executor,
VoiceConfig config,
@Named(VoiceConfig.NAME_TIMEOUT_TIMER) HashedWheelTimer timeoutTimer,
ResponseCompleter responseCompleter,
PlacePopulationCacheManager populationCacheMgr
) {
this.executor = executor;
this.config = config;
this.timeoutTimer = timeoutTimer;
this.responseCompleter = responseCompleter;
this.populationCacheMgr = populationCacheMgr;
this.busClient = new PlatformBusClient(bus, executor, ImmutableSet.of(AddressMatchers.equals(Address.platformService(VoiceService.NAMESPACE))));
}
@Inject
public VideoMetadataV2FavoriteTable(String ts, Session session) {
super(ts, session);
this.deleteField =
CassandraQueryBuilder
.delete(getTableName())
.addWhereColumnEquals(COL_RECORDINGID)
.addWhereColumnEquals(COL_FIELD)
.prepare(session);
this.insertField =
CassandraQueryBuilder
.insert(getTableName())
.addColumns(COLUMNS)
.withRetryPolicy(new LoggingRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE))
.prepare(session);
}
@Inject
public PersonSetAttributesHandler(
CapabilityRegistry capabilityRegistry,
BeanAttributesTransformer<Person> personTransformer,
AccountDAO accountDao,
PersonDAO personDao,
PersonPlaceAssocDAO personPlaceAssocDao,
BillingClient client,
PlatformMessageBus platformBus,
PlacePopulationCacheManager populationCacheMgr
) {
super(capabilityRegistry, personTransformer, platformBus, populationCacheMgr);
this.accountDao = accountDao;
this.personDao = personDao;
this.client = client;
this.personPlaceAssocDao = personPlaceAssocDao;
}
@Inject
public DetailedHubTable(@Named(CassandraHistory.NAME) Session session, HistoryAppenderConfig config) {
super(
CassandraQueryBuilder
.insert(TABLE_NAME)
.addColumns(Columns.HUB_ID, Columns.TIMESTAMP, Columns.MESSAGE_KEY, Columns.PARAMS, Columns.SUBJECT_ADDRESS)
.withTtlSec(TimeUnit.HOURS.toSeconds(config.getDetailedHubTtlHours()))
.prepare(session),
CassandraQueryBuilder
.select(TABLE_NAME)
.addColumns(Columns.HUB_ID, Columns.TIMESTAMP, Columns.MESSAGE_KEY, Columns.PARAMS, Columns.SUBJECT_ADDRESS)
.addWhereColumnEquals(Columns.HUB_ID)
.withConsistencyLevel(ConsistencyLevel.LOCAL_ONE)
.prepare(session),
CassandraQueryBuilder
.select(TABLE_NAME)
.addColumns(Columns.HUB_ID, Columns.TIMESTAMP, Columns.MESSAGE_KEY, Columns.PARAMS, Columns.SUBJECT_ADDRESS)
.where(Columns.HUB_ID + " = ? AND " + Columns.TIMESTAMP + " <= ?")
.withConsistencyLevel(ConsistencyLevel.LOCAL_ONE)
.prepare(session)
);
}
@Inject
public ProtocolBusServiceImpl(
ProtocolMessageBus protocolBus,
BridgeMetrics bridgeMetrics,
Set<ProtocolBusListener> listeners
) {
super(protocolBus, ADDRESSES, bridgeMetrics);
for(ProtocolBusListener listener: listeners) {
addProtocolListener(listener);
}
}
@Inject
public PersistenceShutdownHookInstaller(
final @NotNull ShutdownHooks shutdownHooks, final @NotNull PersistenceShutdownHook persistenceShutdownHook,
final @NotNull PersistenceStartup persistenceStartup) {
this.shutdownHooks = shutdownHooks;
this.persistenceShutdownHook = persistenceShutdownHook;
this.persistenceStartup = persistenceStartup;
}
@Inject
public AppFallbackHandler(
AlwaysAllow authorizer,
BridgeMetrics metrics,
BounceConfig config
) {
super(authorizer, new HttpSender(WebRunHandler.class, metrics));
this.androidStoreUrl = config.getAndroidStoreUrl();
this.appleStoreUrl = config.getAppleStoreUrl();
this.helpUrl = config.getHelpUrl();
}
@Inject
public VideoRecordingServer(
PlaceDAO placeDao,
VideoRecordingManager dao,
RecordingEventPublisher eventPublisher,
VideoStorage videoStorage,
VideoRecordingServerConfig videoConfig,
VideoSessionRegistry registry,
BridgeServerTlsContext serverTlsContext,
Provider<TrafficHandler> trafficHandlerProvider,
@Named("videoBossGroup") EventLoopGroup videoBossGroup,
@Named("videoWorkerGroup") EventLoopGroup videoWorkerGroup,
@Named("videoTcpChannelOptions") Map<ChannelOption<?>, Object> videoChildChannelOptions,
@Named("videoTcpParentChannelOptions") Map<ChannelOption<?>, Object> videoParentChannelOptions,
@Named("bridgeEventLoopProvider") BridgeServerEventLoopProvider eventLoopProvider,
VideoTtlResolver ttlResolver
) {
this.placeDao = placeDao;
this.dao = dao;
this.eventPublisher = eventPublisher;
this.videoStorage = videoStorage;
this.videoConfig = videoConfig;
this.registry = registry;
this.videoBossGroup = videoBossGroup;
this.videoWorkerGroup = videoWorkerGroup;
this.serverTlsContext = serverTlsContext;
this.videoChildChannelOptions = videoChildChannelOptions;
this.videoParentChannelOptions = videoParentChannelOptions;
this.trafficHandlerProvider = trafficHandlerProvider;
this.eventLoopProvider = eventLoopProvider;
this.ttlResolver = ttlResolver;
}
@Inject
public GetProductsByCategoryRESTHandler(AlwaysAllow alwaysAllow, BridgeMetrics metrics,
ProductCatalogManager manager, PopulationDAO populationDao, PlaceDAO placeDao, HubDAO hubDao,
BeanAttributesTransformer<ProductCatalogEntry> transformer, @Named("UseChunkedSender") RESTHandlerConfig restHandlerConfig) {
super(alwaysAllow, new HttpSender(GetProductsByCategoryRESTHandler.class, metrics), manager, populationDao, placeDao, hubDao, restHandlerConfig);
this.listTransformer = new BeanListTransformer<ProductCatalogEntry>(transformer);
}
@Inject
AbyssMinimapOverlay(Client client, RunecraftPlugin plugin, RunecraftConfig config, ItemManager itemManager)
{
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_WIDGETS);
this.client = client;
this.plugin = plugin;
this.config = config;
this.itemManager = itemManager;
}
@Inject
public UpdateBillingInfoCCHandler(
AccountDAO accountDao,
PersonDAO personDao,
BillingClient client,
PlatformMessageBus platformBus) {
this.accountDao = accountDao;
this.personDao = personDao;
this.client = client;
this.platformBus = platformBus;
}
@Inject
private BankGridOverlay(InventoryGridConfig config, Client client, ItemManager itemManager, InventoryGridPlugin plugin)
{
this.plugin = plugin;
this.itemManager = itemManager;
this.client = client;
this.config = config;
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_WIDGETS);
}
@Inject
private FarmingTracker(Client client, ItemManager itemManager, ConfigManager configManager, TimeTrackingConfig config, FarmingWorld farmingWorld)
{
this.client = client;
this.itemManager = itemManager;
this.configManager = configManager;
this.config = config;
this.farmingWorld = farmingWorld;
}
@Inject
public HttpHealthCheckServer(
HealthCheckServerConfig config,
BridgeMetrics metrics,
@Named(HealthCheckServerConfig.NAME_HEALTHCHECK_RESOURCES)
Set<HttpResource> resources
) {
this.initializer = new HttpServerChannelInitializer();
this.initializer.setMaxRequestSizeBytes(config.getMaxRequestSizeBytes());
this.initializer.setHandler(new HttpRequestHandler(resources, metrics));
this.initializer.setClientFactory(new NoAuthClientRegistry());
this.port = config.getPort();
}
@Inject
public DefinitionTransformCapabilityRegistry(DefinitionRegistry registry) {
capabilitiesByName = new HashMap<String, CapabilityDefinition>();
capabilitiesByNamespace = new HashMap<String, CapabilityDefinition>();
capabilities = new ArrayList<>();
ingest(registry.getCapabilities());
}
/**
*
*/
@Inject
public HubHeartbeatListener(
PlatformMessageBus platformBus,
HubRegistry hubs,
Partitioner partitioner
) {
super(platformBus);
this.hubs = hubs;
this.partitioner = partitioner;
}
@Inject
public SetSecurityAnswersHandler(
PersonDAO personDao,
@Named(NAME_RESOURCE_BUNDLE) ResourceBundle securityQuestionBundle,
PlatformMessageBus platformBus
) {
this.personDao = personDao;
this.securityQuestionBundle = securityQuestionBundle;
this.platformBus = platformBus;
}
@Inject
public AccountActivateHandler(AccountDAO accountDao,
PersonDAO personDao,
PlatformMessageBus platformBus,
PlacePopulationCacheManager populationCacheMgr) {
this.accountDao = accountDao;
this.personDao = personDao;
this.platformBus = platformBus;
this.populationCacheMgr = populationCacheMgr;
}
@Inject
public ForceRemoveRequestHandler(
DeviceDAO deviceDao,
PlatformMessageBus platformBus,
Set<GroovyDriverPlugin> plugins,
DeviceService service
) {
super(deviceDao, platformBus, plugins);
this.service = service;
}
@Inject
public DirectMessageExecutor(Set<DirectMessageHandler> handlers) {
if (handlers != null) {
handlers.forEach((h) -> this.handlers.put(h.supportsMessageType(), h));
}
this.refuseConnection = new RefuseConnectionException();
}
@Inject
public RemoveRequestHandler(
PlatformMessageBus bus,
ProductLoader loader
) {
this.bus = bus;
this.loader = loader;
}
@Inject
public KinesisMetadata(
KinesisConfig kinesisConfig,
Supplier<Map<SchemaTableName, KinesisStreamDescription>> tableDescriptionSupplier,
Set<KinesisInternalFieldDescription> internalFieldDescriptions)
{
requireNonNull(kinesisConfig, "kinesisConfig is null");
isHideInternalColumns = kinesisConfig.isHideInternalColumns();
this.tableDescriptionSupplier = requireNonNull(tableDescriptionSupplier);
this.internalFieldDescriptions = requireNonNull(internalFieldDescriptions, "internalFieldDescriptions is null");
}
@Inject
public KinesisTableDescriptionSupplier(
KinesisConfig kinesisConfig,
JsonCodec<KinesisStreamDescription> streamDescriptionCodec,
S3TableConfigClient s3TableConfigClient)
{
this.kinesisConfig = requireNonNull(kinesisConfig, "kinesisConfig is null");
this.streamDescriptionCodec = requireNonNull(streamDescriptionCodec, "streamDescriptionCodec is null");
this.s3TableConfigClient = requireNonNull(s3TableConfigClient, "S3 table config client is null");
}
@Inject
public HttpRequestInitializer(
Provider<ChannelInboundHandler> channelInboundProvider,
BridgeServerTlsContext tlsContext,
BridgeServerConfig serverConfig,
VideoConfig videoConfig,
IrisNettyCorsConfig corsConfig
) {
this.serverTlsContext = tlsContext;
this.serverConfig = serverConfig;
this.videoConfig = videoConfig;
this.channelInboundProvider = channelInboundProvider;
this.corsConfig = corsConfig;
}
@Inject
public GetProductsHandler(BeanAttributesTransformer<ProductCatalogEntry> transformer,
PopulationDAO populationDao,
ProductCatalogManager manager) {
super(populationDao, manager);
listTransformer = new BeanListTransformer<ProductCatalogEntry>(transformer);
}