use of org.jboss.msc.service.StartException in project wildfly by wildfly.
the class SecurityDomainService method start.
/** {@inheritDoc} */
@Override
public void start(StartContext context) throws StartException {
SecurityLogger.ROOT_LOGGER.debugf("Starting SecurityDomainService(%s)", name);
if (applicationPolicy != null) {
final ApplicationPolicyRegistration applicationPolicyRegistration = (ApplicationPolicyRegistration) configurationValue.getValue();
applicationPolicyRegistration.addApplicationPolicy(applicationPolicy.getName(), applicationPolicy);
}
final JNDIBasedSecurityManagement securityManagement = (JNDIBasedSecurityManagement) securityManagementValue.getValue();
AuthenticationCacheFactory cacheFactory = null;
if ("infinispan".equals(cacheType)) {
cacheFactory = new InfinispanAuthenticationCacheFactory(cacheManagerValue.getValue(), name);
} else if ("default".equals(cacheType)) {
cacheFactory = new DefaultAuthenticationCacheFactory();
}
try {
securityDomainContext = securityManagement.createSecurityDomainContext(name, cacheFactory);
} catch (Exception e) {
throw SecurityLogger.ROOT_LOGGER.unableToStartException("SecurityDomainService", e);
}
if (jsseSecurityDomain != null) {
try {
jsseSecurityDomain.reloadKeyAndTrustStore();
securityDomainContext.setJSSE(jsseSecurityDomain);
} catch (Exception e) {
throw SecurityLogger.ROOT_LOGGER.unableToStartException("SecurityDomainService", e);
}
}
securityManagement.getSecurityManagerMap().put(name, securityDomainContext);
}
use of org.jboss.msc.service.StartException in project wildfly by wildfly.
the class JPAIdentityStoreService method start.
@Override
public void start(StartContext startContext) throws StartException {
this.storeConfig = this.configurationBuilder.create();
this.transactionalEntityManagerHelper = new TransactionalEntityManagerHelper(this.transactionSynchronizationRegistry.getValue(), this.transactionManager.getValue());
try {
configureEntityManagerFactory();
configureEntities();
} catch (Exception e) {
throw ROOT_LOGGER.idmJpaStartFailed(e);
}
this.configurationBuilder.addContextInitializer(new ContextInitializer() {
@Override
public void initContextForStore(IdentityContext context, IdentityStore<?> store) {
if (store instanceof JPAIdentityStore) {
EntityManager entityManager = context.getParameter(JPAIdentityStore.INVOCATION_CTX_ENTITY_MANAGER);
if (entityManager == null || !entityManager.isOpen()) {
context.setParameter(JPAIdentityStore.INVOCATION_CTX_ENTITY_MANAGER, getEntityManager(getTransactionManager().getValue()));
}
}
}
});
}
use of org.jboss.msc.service.StartException in project wildfly by wildfly.
the class AbstractPojoPhase method executeInstalls.
protected void executeInstalls() throws StartException {
List<Joinpoint> installs = getInstalls();
if (installs.isEmpty())
return;
int i = 0;
try {
for (i = 0; i < installs.size(); i++) installs.get(i).dispatch();
} catch (Throwable t) {
considerUninstalls(getUninstalls(), i);
throw new StartException(t);
}
}
use of org.jboss.msc.service.StartException in project wildfly by wildfly.
the class BeanUtils method configure.
/**
* Configure bean.
*
* @param beanConfig the bean metadata config, must not be null
* @param beanInfo the bean info, can be null if enough info
* @param module the current CL module, must not be null
* @param bean the bean instance
* @param nullify do we nullify property
* @throws Throwable for any error
*/
public static void configure(BeanMetaDataConfig beanConfig, BeanInfo beanInfo, Module module, Object bean, boolean nullify) throws Throwable {
Set<PropertyConfig> properties = beanConfig.getProperties();
if (properties != null) {
List<PropertyConfig> used = new ArrayList<PropertyConfig>();
for (PropertyConfig pc : properties) {
try {
configure(beanInfo, module, bean, pc, nullify);
used.add(pc);
} catch (Throwable t) {
if (nullify == false) {
for (PropertyConfig upc : used) {
try {
configure(beanInfo, module, bean, upc, true);
} catch (Throwable ignored) {
}
}
throw new StartException(t);
}
}
}
}
}
use of org.jboss.msc.service.StartException in project wildfly by wildfly.
the class BeanUtils method instantiateBean.
/**
* Instantiate bean.
*
* @param beanConfig the bean metadata config, must not be null
* @param beanInfo the bean info, can be null if enough info
* @param index the reflection index, must not be null
* @param module the current CL module, must not be null
* @return new bean instance
* @throws Throwable for any error
*/
public static Object instantiateBean(BeanMetaDataConfig beanConfig, BeanInfo beanInfo, DeploymentReflectionIndex index, Module module) throws Throwable {
Joinpoint instantiateJoinpoint = null;
ValueConfig[] parameters = new ValueConfig[0];
String[] types = Configurator.NO_PARAMS_TYPES;
ConstructorConfig ctorConfig = beanConfig.getConstructor();
if (ctorConfig != null) {
parameters = ctorConfig.getParameters();
types = Configurator.getTypes(parameters);
String factoryClass = ctorConfig.getFactoryClass();
FactoryConfig factory = ctorConfig.getFactory();
if (factoryClass != null || factory != null) {
String factoryMethod = ctorConfig.getFactoryMethod();
if (factoryMethod == null)
throw PojoLogger.ROOT_LOGGER.missingFactoryMethod(beanConfig);
if (factoryClass != null) {
// static factory
Class<?> factoryClazz = Class.forName(factoryClass, false, module.getClassLoader());
Method method = Configurator.findMethod(index, factoryClazz, factoryMethod, types, true, true, true);
MethodJoinpoint mj = new MethodJoinpoint(method);
// null, since this is static call
mj.setTarget(new ImmediateValue<Object>(null));
mj.setParameters(parameters);
instantiateJoinpoint = mj;
} else if (factory != null) {
ReflectionJoinpoint rj = new ReflectionJoinpoint(factory.getBeanInfo(), factoryMethod, types);
// null type is ok, as this should be plain injection
rj.setTarget(new ImmediateValue<Object>(factory.getValue(null)));
rj.setParameters(parameters);
instantiateJoinpoint = rj;
}
}
}
// plain bean's ctor
if (instantiateJoinpoint == null) {
if (beanInfo == null)
throw new StartException(PojoLogger.ROOT_LOGGER.missingBeanInfo(beanConfig));
Constructor ctor = (types.length == 0) ? beanInfo.getConstructor() : beanInfo.findConstructor(types);
ConstructorJoinpoint constructorJoinpoint = new ConstructorJoinpoint(ctor);
constructorJoinpoint.setParameters(parameters);
instantiateJoinpoint = constructorJoinpoint;
}
return instantiateJoinpoint.dispatch();
}
Aggregations