@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); } }; } }
@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()); } }
/** * 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; } }
@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; }
/** * 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)); } }
/** * 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"); } }
@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); } }; } }
@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()); } }
/** * 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(); } }