本文整理了Java中javax.inject.Singleton.<init>()
方法的一些代码示例,展示了Singleton.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Singleton.<init>()
方法的具体详情如下:
包路径:javax.inject.Singleton
类名称:Singleton
方法名:<init>
暂无
代码示例来源:origin: prestodb/presto
@Provides
@Singleton
public static ResourceGroupManager<?> getResourceGroupManager(@SuppressWarnings("rawtypes") ResourceGroupManager manager)
{
return manager;
}
代码示例来源: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: bumptech/glide
@Singleton
@Named("hotViralImages")
@Provides
Observable<List<Image>> provideHotViralImages(ImgurObservables imgurObservables) {
return imgurObservables.getHotViralImages(5 /*maxPages*/);
}
代码示例来源:origin: square/dagger
@Singleton
public static class L {
@Inject @Named("one") F f;
@Inject Provider<L> lProvider;
}
代码示例来源: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: org.apache.jclouds.api/chef
@Singleton
public class ListCookbookVersionsImpl extends BaseListCookbookVersionsImpl implements ListCookbookVersions {
@Resource
@Named(ChefProperties.CHEF_LOGGER)
protected Logger logger = Logger.NULL;
@Inject
ListCookbookVersionsImpl(ChefApi api) {
super(api);
}
@Override
public Iterable<? extends CookbookVersion> execute() {
return super.execute(api.listCookbooks());
}
@Override
public Iterable<? extends CookbookVersion> execute(ExecutorService executor) {
return this.executeConcurrently(MoreExecutors.listeningDecorator(executor));
}
private Iterable<? extends CookbookVersion> executeConcurrently(ListeningExecutorService executor) {
return super.executeConcurrently(executor, api.listCookbooks());
}
}
代码示例来源:origin: kairosdb/kairosdb
@Provides @Named(QUEUE_PROCESSOR) @Singleton
public ExecutorService getQueueExecutor()
{
return Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("QueueProcessor-%s").build());
}
代码示例来源: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: org.glassfish.main.core/kernel
/**
* This service will scan for all jobs.xml
* @author Bhakti Mehta
*/
@Service (name="job-filescanner")
@Singleton
public class JobFileScanner implements PostConstruct {
@Inject
private ServiceLocator serviceLocator;
HashSet<File> persistedJobFiles ;
@Override
public void postConstruct() {
Collection<JobLocator> services = serviceLocator.getAllServices(JobLocator.class);
persistedJobFiles = new HashSet<File>() ;
for (JobLocator locator: services) {
persistedJobFiles.addAll(locator.locateJobXmlFiles());
}
}
public HashSet<File> getJobFiles() {
return persistedJobFiles;
}
}
代码示例来源: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: org.xwiki.platform/xwiki-platform-search-solr-api
/**
* Component used to extract a {@link DocumentReference} from a {@link SolrDocument}.
*
* @version $Id: b9acc4bf7fb4cacbc213962daa183f491ef9d856 $
* @since 7.2M2
*/
@Component
@Singleton
public class SolrDocumentReferenceResolver implements DocumentReferenceResolver<SolrDocument>
{
@Inject
private EntityReferenceResolver<SolrDocument> entityReferenceResolver;
@Override
public DocumentReference resolve(SolrDocument documentReferenceRepresentation, Object... parameters)
{
return new DocumentReference(this.entityReferenceResolver.resolve(documentReferenceRepresentation,
EntityType.DOCUMENT, parameters));
}
}
代码示例来源: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: apache/maven
@Named
@Singleton
public class DefaultToolchainsBuilder
implements ToolchainsBuilder
@Inject
private ToolchainsReader toolchainsReader;
代码示例来源:origin: org.xwiki.platform/xwiki-platform-captcha-default
/**
* Default implementation for {@link CaptchaConfiguration}.
*
* @version $Id: 1834827b33ae612bb4fe0369ad395505ca58d4e4 $
* @since 10.8RC1
*/
@Component
@Singleton
public class DefaultCaptchaConfiguration implements CaptchaConfiguration
{
@Inject
@Named("captcha")
private ConfigurationSource configuration;
@Override
public String getDefaultName()
{
return configuration.getProperty("captcha", "jcaptcha");
}
}
代码示例来源:origin: Netflix/eureka
@Singleton
public static class DownStatusProvider 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: org.apache.jclouds.api/chef
@Singleton
public class ListNodesImpl extends BaseListNodesImpl implements ListNodes {
@Resource
@Named(ChefProperties.CHEF_LOGGER)
protected Logger logger = Logger.NULL;
@Inject
ListNodesImpl(ChefApi api) {
super(api);
}
@Override
public Iterable<? extends Node> execute() {
return super.execute(api.listNodes());
}
@Override
public Iterable<? extends Node> execute(ExecutorService executor) {
return this.executeConcurrently(MoreExecutors.listeningDecorator(executor));
}
private Iterable<? extends Node> executeConcurrently(ListeningExecutorService executor) {
return super.executeConcurrently(executor, api.listNodes());
}
}
代码示例来源:origin: kairosdb/kairosdb
@Provides
@Singleton
@Named(HostManager.HOST_MANAGER_SERVICE_EXECUTOR)
public ScheduledExecutorService getExecutorService()
{
return Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder().setNameFormat("HostManagerService-%s").build());
}
}
代码示例来源: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: org.glassfish.main.security/ssl-impl
/**
* A contract to pass the Glassfish master password between the admin module and
* the security module.
*
* @author Sudarsan Sridhar
*/
@Service(name="Security SSL Password Provider Service")
@Singleton
public class MasterPasswordImpl implements MasterPassword {
@Inject @Optional IdentityManagement idm;
@Override
public PasswordAdapter getMasterPasswordAdapter() throws CertificateException, IOException, KeyStoreException, NoSuchAlgorithmException {
char pw[] = idm == null ? null : idm.getMasterPassword();
return new PasswordAdapter(pw);
}
public char[] getMasterPassword() {
return idm == null ? null : idm.getMasterPassword();
}
}
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!