Search in sources :

Example 36 with StartException

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);
}
Also used : InfinispanAuthenticationCacheFactory(org.jboss.as.security.plugins.InfinispanAuthenticationCacheFactory) DefaultAuthenticationCacheFactory(org.jboss.as.security.plugins.DefaultAuthenticationCacheFactory) InfinispanAuthenticationCacheFactory(org.jboss.as.security.plugins.InfinispanAuthenticationCacheFactory) AuthenticationCacheFactory(org.jboss.as.security.plugins.AuthenticationCacheFactory) DefaultAuthenticationCacheFactory(org.jboss.as.security.plugins.DefaultAuthenticationCacheFactory) ApplicationPolicyRegistration(org.jboss.security.config.ApplicationPolicyRegistration) StartException(org.jboss.msc.service.StartException) JNDIBasedSecurityManagement(org.jboss.as.security.plugins.JNDIBasedSecurityManagement)

Example 37 with StartException

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()));
                }
            }
        }
    });
}
Also used : JPAIdentityStore(org.picketlink.idm.jpa.internal.JPAIdentityStore) EntityManager(javax.persistence.EntityManager) ContextInitializer(org.picketlink.idm.spi.ContextInitializer) IdentityContext(org.picketlink.idm.spi.IdentityContext) NamingException(javax.naming.NamingException) StartException(org.jboss.msc.service.StartException) TransactionalEntityManagerHelper(org.wildfly.extension.picketlink.idm.jpa.transaction.TransactionalEntityManagerHelper)

Example 38 with StartException

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);
    }
}
Also used : StartException(org.jboss.msc.service.StartException)

Example 39 with StartException

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);
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) PropertyConfig(org.jboss.as.pojo.descriptor.PropertyConfig) StartException(org.jboss.msc.service.StartException)

Example 40 with StartException

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();
}
Also used : Constructor(java.lang.reflect.Constructor) ConstructorConfig(org.jboss.as.pojo.descriptor.ConstructorConfig) FactoryConfig(org.jboss.as.pojo.descriptor.FactoryConfig) Method(java.lang.reflect.Method) ImmediateValue(org.jboss.msc.value.ImmediateValue) ValueConfig(org.jboss.as.pojo.descriptor.ValueConfig) StartException(org.jboss.msc.service.StartException)

Aggregations

StartException (org.jboss.msc.service.StartException)43 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 ExecutorService (java.util.concurrent.ExecutorService)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)4 ORB (org.omg.CORBA.ORB)4 InetSocketAddress (java.net.InetSocketAddress)3 PrivilegedAction (java.security.PrivilegedAction)3 HashMap (java.util.HashMap)3 PostInitLoader (com.arjuna.orbportability.internal.utils.PostInitLoader)2 HandlerWrapper (io.undertow.server.HandlerWrapper)2 HttpHandler (io.undertow.server.HttpHandler)2 File (java.io.File)2 AccessControlContext (java.security.AccessControlContext)2 Map (java.util.Map)2 TempClassLoaderFactoryImpl (org.jboss.as.jpa.classloader.TempClassLoaderFactoryImpl)2 SocketBinding (org.jboss.as.network.SocketBinding)2 ModuleLoadException (org.jboss.modules.ModuleLoadException)2 Service (org.jboss.msc.service.Service)2 ServiceContainer (org.jboss.msc.service.ServiceContainer)2