本文整理了Java中javax.inject.Singleton
类的一些代码示例,展示了Singleton
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Singleton
类的具体详情如下:
包路径:javax.inject.Singleton
类名称:Singleton
暂无
代码示例来源:origin: Netflix/eureka
@Singleton
public static class UpStatusProvider implements Provider<Supplier<Boolean>> {
@Inject
private Provider<EurekaUpStatusResolver> upStatus;
@Override
public Supplier<Boolean> get() {
final EurekaUpStatusResolver resolver = upStatus.get();
return new Supplier<Boolean>() {
@Override
public Boolean get() {
return resolver.getStatus().equals(InstanceInfo.InstanceStatus.UP);
}
};
}
}
代码示例来源:origin: square/dagger
@Singleton
public static class L {
@Inject @Named("one") F f;
@Inject Provider<L> lProvider;
}
代码示例来源:origin: jclouds/legacy-jclouds
@Provides
@Singleton
protected Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> provideOrgCatalogItemSupplierCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
OrgCatalogItemSupplier supplier) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds,
TimeUnit.SECONDS);
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-skin-skinx
/**
* Skin extension that provides the wrapper on the resource CSS extensions.
*
* @version $Id: 1a90752faf4ae27128a1e0889781c6ffc0634ee4 $
* @since 1.20
*/
@Component
@Named("ssrx")
@Singleton
public class CssResourceSkinExtension extends AbstractWrapperSkinExtension
{
}
代码示例来源:origin: azkaban/azkaban
@Inject
@Provides
@Singleton
public Configuration createHadoopConfiguration() {
final String hadoopConfDirPath = requireNonNull(this.props.get(HADOOP_CONF_DIR_PATH));
final File hadoopConfDir = new File(requireNonNull(hadoopConfDirPath));
checkArgument(hadoopConfDir.exists() && hadoopConfDir.isDirectory());
final Configuration hadoopConf = new Configuration(false);
hadoopConf.addResource(new org.apache.hadoop.fs.Path(hadoopConfDirPath, "core-site.xml"));
hadoopConf.addResource(new org.apache.hadoop.fs.Path(hadoopConfDirPath, "hdfs-site.xml"));
hadoopConf.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
return hadoopConf;
}
代码示例来源:origin: bumptech/glide
@Singleton
@Named("hotViralImages")
@Provides
Observable<List<Image>> provideHotViralImages(ImgurObservables imgurObservables) {
return imgurObservables.getHotViralImages(5 /*maxPages*/);
}
代码示例来源:origin: prestodb/presto
@Provides
@Singleton
public static ResourceGroupManager<?> getResourceGroupManager(@SuppressWarnings("rawtypes") ResourceGroupManager manager)
{
return manager;
}
代码示例来源:origin: kairosdb/kairosdb
@Provides @Named(QUEUE_PROCESSOR) @Singleton
public ExecutorService getQueueExecutor()
{
return Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("QueueProcessor-%s").build());
}
代码示例来源:origin: com.amysta.jclouds/jclouds-core
@Singleton
public class ReleasePayloadAndReturn implements Function<HttpResponse, Void> {
@Resource
protected Logger logger = Logger.NULL;
public Void apply(HttpResponse from) {
releasePayload(from);
return null;
}
}
代码示例来源:origin: org.xwiki.rendering/xwiki-rendering-syntax-event
@Component
@Named("event/1.0")
@Singleton
public class EventBlockRenderer extends AbstractBlockRenderer
{
@Inject
@Named("event/1.0")
private PrintRendererFactory eventRendererFactory;
@Override
protected PrintRendererFactory getPrintRendererFactory()
{
return this.eventRendererFactory;
}
}
代码示例来源:origin: jclouds/legacy-jclouds
@Provides
@Singleton
public Supplier<Access> provide() {
return Suppliers.ofInstance(new ParseRackspaceAccessTest().expected());
}
}).getInstance(RegionIdToURISupplier.Factory.class);
代码示例来源:origin: jclouds/legacy-jclouds
@Provides
@org.jclouds.trmk.vcloud_0_8.endpoints.Catalog
@Singleton
protected Supplier<ReferenceType> provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultOrg) {
return Suppliers.compose(defaultCatalogURIForOrg, defaultOrg);
}
代码示例来源:origin: jclouds/legacy-jclouds
@Provides
@Singleton
public LoadingCache<String, Set<? extends Extension>> provideExtensionsByZone(final javax.inject.Provider<KeystoneApi> keystoneApi) {
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
.build(CacheLoader.from(Suppliers.memoize(new Supplier<Set<? extends Extension>>() {
@Override
public Set<? extends Extension> get() {
return keystoneApi.get().getExtensionApi().list();
}
})));
}
代码示例来源:origin: bumptech/glide
/** Specifies Dagger modules for {@link ImgurApplication}. */
@Singleton
@Component(
modules = {
AndroidSupportInjectionModule.class,
MainActivityModule.class,
ApplicationModule.class,
ApiModule.class
})
public interface ImgurApplicationComponent extends AndroidInjector<ImgurApplication> {
// Empty.
}
代码示例来源:origin: apache/maven
@Named
@Singleton
public class DefaultToolchainsBuilder
implements ToolchainsBuilder
@Inject
private ToolchainsReader toolchainsReader;
代码示例来源:origin: jclouds/legacy-jclouds
@Provides
@Singleton
protected Supplier<Map<URI, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> provideURIToVDC(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException,
URItoVDC supplier) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds,
TimeUnit.SECONDS);
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-skin-skinx
/**
* Skin extension that provides the wrapper on the file JavaScript extensions.
*
* @version $Id: 5be9a81d51e1feaf3764a90c510c612d4ab3ff69 $
* @since 1.20
*/
@Component
@Named("jsfx")
@Singleton
public class JsFileSkinExtension extends AbstractWrapperSkinExtension
{
}
代码示例来源:origin: azkaban/azkaban
@Inject
@Provides
@Singleton
public FileSystem createHadoopFileSystem(final Configuration hadoopConf, final HdfsAuth auth) {
try {
auth.authorize();
return FileSystem.get(hadoopConf);
} catch (final IOException e) {
log.error("Unable to initialize HDFS", e);
throw new AzkabanException(e);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Named("singleton")
@Singleton
public static class SingletonScopedTestBean extends ScopedTestBean {
}
代码示例来源:origin: prestodb/presto
@Provides
@Singleton
public static QueryPerformanceFetcher createQueryPerformanceFetcher(QueryManager queryManager)
{
return queryManager::getFullQueryInfo;
}
内容来源于网络,如有侵权,请联系作者删除!