/** * {@link com.fasterxml.jackson.databind.ObjectMapper} provider that supplies context information to resource * classes and other providers. */ @Service @Provider public class ObjectMapperProvider implements ContextResolver<ObjectMapper> { /** * {@link com.fasterxml.jackson.databind.ObjectMapper}. If the object isn't set up, it is created. */ @Inject @Optional protected ObjectMapper objectMapper; @Override public synchronized ObjectMapper getContext(Class<?> type) { if(objectMapper == null) { objectMapper = JacksonUtils.createObjectMapper(); } return objectMapper; } }
/** * 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(); } }
@Service public static final class DefaultResolver implements CrudResolver { @Inject @Named("type") @Optional CrudResolver defaultResolver=null; @Override public <T extends ConfigBeanProxy> T resolve(AdminCommandContext context, Class<T> type) { if (defaultResolver!=null) { return defaultResolver.resolve(context, type); } return null; } } }
/** * Created by IntelliJ IDEA. * User: naman * Date: 13 Jan, 2011 * Time: 11:46:39 AM * To change this template use File | Settings | File Templates. */ @Service(name="JMX SSL Password Provider Service") @Singleton public class JMXMasterPasswordImpl 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(); } }
@Service public class ESResolver implements CrudResolver { @Inject Domain domain; @Inject @Optional ElasticServices elasticServices = null; @Override public <T extends ConfigBeanProxy> T resolve(AdminCommandContext context, Class<T> type) { if (elasticServices!=null) return (T) elasticServices; try { elasticServices = (ElasticServices) ConfigSupport.apply(new SingleConfigCode<Domain>() { @Override public Object run(Domain wDomain) throws PropertyVetoException, TransactionFailure { ElasticServices es = wDomain.createChild(ElasticServices.class); wDomain.getExtensions().add(es); return es; } }, domain); } catch (TransactionFailure t) { throw new RuntimeException(t); } return (T) elasticServices; } }
@Service @Provider public class ValidationConfigProvider implements ContextResolver<ValidationConfig> { @Inject @Optional protected javax.inject.Provider<Locale> localeProvider; @Inject @Optional protected ValidationConfig validationConfig; @Inject @Optional protected ResourceBundleProvider resourceBundleProvider;
@Service @NamespacePrefixes({BeanValidatorNamingProxy.nameForValidator, BeanValidatorNamingProxy.nameForValidatorFactory}) public class BeanValidatorNamingProxy implements NamedNamingObjectProxy { private Validator validator; @Inject @Named("ValidationNamingProxy") @Optional private NamedNamingObjectProxy cdiNamingProxy;