Search in sources :

Example 21 with StartException

use of org.jboss.msc.service.StartException in project wildfly by wildfly.

the class EJBRemoteConnectorService method start.

@Override
public void start(StartContext context) throws StartException {
    final AssociationService associationService = associationServiceInjectedValue.getValue();
    final Endpoint endpoint = endpointValue.getValue();
    Executor executor = executorService.getOptionalValue();
    if (executor != null) {
        associationService.setExecutor(executor);
    }
    RemoteEJBService remoteEJBService = RemoteEJBService.create(associationService.getAssociation(), remotingTransactionServiceInjectedValue.getValue());
    final ControlledProcessStateService processStateService = controlledProcessStateServiceInjectedValue.getValue();
    if (processStateService.getCurrentState() == ControlledProcessState.State.STARTING) {
        final PropertyChangeListener listener = new PropertyChangeListener() {

            public void propertyChange(final PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("currentState") && evt.getOldValue() == ControlledProcessState.State.STARTING) {
                    remoteEJBService.serverUp();
                    // can't use a lambda because of this line...
                    processStateService.removePropertyChangeListener(this);
                }
            }
        };
        processStateService.addPropertyChangeListener(listener);
        // this is actually racy, so we have to double-check the state afterwards just to be sure it didn't transition before we got here.
        if (processStateService.getCurrentState() != ControlledProcessState.State.STARTING) {
            // this method is idempotent so it's OK if the listener got fired
            remoteEJBService.serverUp();
            // this one too
            processStateService.removePropertyChangeListener(listener);
        }
    } else {
        remoteEJBService.serverUp();
    }
    // Register an EJB channel open listener
    OpenListener channelOpenListener = remoteEJBService.getOpenListener();
    try {
        registration = endpoint.registerService(EJB_CHANNEL_NAME, channelOpenListener, this.channelCreationOptions);
    } catch (ServiceRegistrationException e) {
        throw new StartException(e);
    }
}
Also used : RemoteEJBService(org.jboss.ejb.protocol.remote.RemoteEJBService) ControlledProcessStateService(org.jboss.as.controller.ControlledProcessStateService) PropertyChangeEvent(java.beans.PropertyChangeEvent) Executor(java.util.concurrent.Executor) Endpoint(org.jboss.remoting3.Endpoint) PropertyChangeListener(java.beans.PropertyChangeListener) OpenListener(org.jboss.remoting3.OpenListener) ServiceRegistrationException(org.jboss.remoting3.ServiceRegistrationException) StartException(org.jboss.msc.service.StartException)

Example 22 with StartException

use of org.jboss.msc.service.StartException in project wildfly by wildfly.

the class CorbaORBService method start.

@Override
public void start(StartContext context) throws StartException {
    if (IIOPLogger.ROOT_LOGGER.isDebugEnabled()) {
        IIOPLogger.ROOT_LOGGER.debugf("Starting service %s", context.getController().getName().getCanonicalName());
    }
    try {
        // set the ORBClass and ORBSingleton class as system properties.
        properties.setProperty(Constants.ORB_CLASS, ORBImpl.class.getName());
        properties.setProperty(Constants.ORB_SINGLETON_CLASS, ORBSingleton.class.getName());
        WildFlySecurityManager.setPropertyPrivileged(Constants.ORB_CLASS, ORBImpl.class.getName());
        WildFlySecurityManager.setPropertyPrivileged(Constants.ORB_SINGLETON_CLASS, ORBSingleton.class.getName());
        properties.setProperty(ORBConstants.IOR_TO_SOCKET_INFO_CLASS_PROPERTY, CSIV2IORToSocketInfo.class.getName());
        // set the IIOP and IIOP/SSL ports from the respective socket bindings.
        if (this.iiopSocketBindingInjector.getValue() != null) {
            InetSocketAddress address = this.iiopSocketBindingInjector.getValue().getSocketAddress();
            properties.setProperty(ORBConstants.SERVER_HOST_PROPERTY, address.getAddress().getHostAddress());
            properties.setProperty(ORBConstants.SERVER_PORT_PROPERTY, String.valueOf(address.getPort()));
            properties.setProperty(ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY, String.valueOf(address.getPort()));
        }
        if (this.iiopSSLSocketBindingInjector.getOptionalValue() != null) {
            InetSocketAddress address = this.iiopSSLSocketBindingInjector.getValue().getSocketAddress();
            properties.setProperty(Constants.ORB_SSL_PORT, String.valueOf(address.getPort()));
            final String sslSocket = new StringBuilder().append(Constants.SSL_SOCKET_TYPE).append(':').append(String.valueOf(address.getPort())).toString();
            properties.setProperty(ORBConstants.LISTEN_SOCKET_PROPERTY, sslSocket);
            if (!properties.containsKey(Constants.ORB_ADDRESS)) {
                properties.setProperty(Constants.ORB_ADDRESS, address.getAddress().getHostAddress());
            }
        }
        // initialize the ORB - the thread context classloader needs to be adjusted as the ORB classes are loaded via reflection.
        ClassLoader loader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
        try {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(WildFlySecurityManager.getClassLoaderPrivileged(this.getClass()));
            this.orb = ORB.init(new String[0], properties);
            // initialize the ORBSingleton.
            ORB.init();
        } finally {
            // restore the thread context classloader.
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(loader);
        }
        // start the ORB in a separate thread.
        Thread orbThread = SecurityActions.createThread(new ORBRunner(this.orb), "ORB Run Thread");
        orbThread.start();
        // bind the ORB to JNDI under java:/jboss/ORB.
        ServiceTarget target = context.getChildTarget();
        CorbaServiceUtil.bindObject(target, "ORB", this.orb);
    } catch (Exception e) {
        throw new StartException(e);
    }
    CorbaUtils.setOrbProperties(properties);
    IIOPLogger.ROOT_LOGGER.corbaORBServiceStarted();
}
Also used : ORBImpl(com.sun.corba.se.impl.orb.ORBImpl) InetSocketAddress(java.net.InetSocketAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) StartException(org.jboss.msc.service.StartException) CSIV2IORToSocketInfo(org.wildfly.iiop.openjdk.csiv2.CSIV2IORToSocketInfo) ORBSingleton(com.sun.corba.se.impl.orb.ORBSingleton) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) StartException(org.jboss.msc.service.StartException)

Example 23 with StartException

use of org.jboss.msc.service.StartException in project wildfly by wildfly.

the class CorbaPOAService method start.

@Override
public void start(StartContext context) throws StartException {
    if (IIOPLogger.ROOT_LOGGER.isDebugEnabled()) {
        IIOPLogger.ROOT_LOGGER.debugf("Starting service %s", context.getController().getName().getCanonicalName());
    }
    ORB orb = this.orbInjector.getOptionalValue();
    POA parentPOA = this.parentPOAInjector.getOptionalValue();
    // if an ORB has been injected, we will use the ORB.resolve_initial_references method to instantiate the POA.
    if (orb != null) {
        try {
            this.poa = POAHelper.narrow(orb.resolve_initial_references(this.poaName));
        } catch (Exception e) {
            throw IIOPLogger.ROOT_LOGGER.errorResolvingInitRef(this.poaName, e);
        }
    } else // if a parent POA has been injected, we use it to create the policies and then the POA itself.
    if (parentPOA != null) {
        try {
            Policy[] poaPolicies = this.createPolicies(parentPOA);
            this.poa = parentPOA.create_POA(this.poaName, null, poaPolicies);
        } catch (Exception e) {
            throw IIOPLogger.ROOT_LOGGER.errorCreatingPOAFromParent(e);
        }
    } else {
        throw IIOPLogger.ROOT_LOGGER.invalidPOACreationArgs();
    }
    // check if the POA should be bound to JNDI under java:/jboss.
    if (this.bindingName != null) {
        CorbaServiceUtil.bindObject(context.getChildTarget(), this.bindingName, this.poa);
    }
    // activate the created POA.
    try {
        this.poa.the_POAManager().activate();
    } catch (Exception e) {
        throw IIOPLogger.ROOT_LOGGER.errorActivatingPOA(e);
    }
}
Also used : POA(org.omg.PortableServer.POA) ORB(org.omg.CORBA.ORB) StartException(org.jboss.msc.service.StartException)

Example 24 with StartException

use of org.jboss.msc.service.StartException in project wildfly by wildfly.

the class JaxrsSpringProcessor method getResteasySpringVirtualFile.

/**
     * Lookup Seam integration resource loader.
     *
     * @return the Seam integration resource loader
     * @throws DeploymentUnitProcessingException
     *          for any error
     */
protected synchronized VirtualFile getResteasySpringVirtualFile() throws DeploymentUnitProcessingException {
    if (resourceRoot != null) {
        return resourceRoot;
    }
    try {
        Module module = Module.getBootModuleLoader().loadModule(MODULE);
        URL fileUrl = module.getClassLoader().getResource(JAR_LOCATION);
        if (fileUrl == null) {
            throw JaxrsLogger.JAXRS_LOGGER.noSpringIntegrationJar();
        }
        File dir = new File(fileUrl.toURI());
        File file = null;
        for (String jar : dir.list()) {
            if (jar.endsWith(".jar")) {
                file = new File(dir, jar);
                break;
            }
        }
        if (file == null) {
            throw JaxrsLogger.JAXRS_LOGGER.noSpringIntegrationJar();
        }
        VirtualFile vf = VFS.getChild(file.toURI());
        final Closeable mountHandle = VFS.mountZip(file, vf, TempFileProviderService.provider());
        Service<Closeable> mountHandleService = new Service<Closeable>() {

            public void start(StartContext startContext) throws StartException {
            }

            public void stop(StopContext stopContext) {
                VFSUtils.safeClose(mountHandle);
            }

            public Closeable getValue() throws IllegalStateException, IllegalArgumentException {
                return mountHandle;
            }
        };
        ServiceBuilder<Closeable> builder = serviceTarget.addService(ServiceName.JBOSS.append(SERVICE_NAME), mountHandleService);
        builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
        resourceRoot = vf;
        return resourceRoot;
    } catch (Exception e) {
        throw new DeploymentUnitProcessingException(e);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) StopContext(org.jboss.msc.service.StopContext) Closeable(java.io.Closeable) Service(org.jboss.msc.service.Service) TempFileProviderService(org.jboss.as.server.deployment.module.TempFileProviderService) URL(java.net.URL) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) StartException(org.jboss.msc.service.StartException) StartContext(org.jboss.msc.service.StartContext) Module(org.jboss.modules.Module) VirtualFile(org.jboss.vfs.VirtualFile) File(java.io.File)

Example 25 with StartException

use of org.jboss.msc.service.StartException in project wildfly by wildfly.

the class CorbaNamingService method start.

@Override
public void start(StartContext context) throws StartException {
    IIOPLogger.ROOT_LOGGER.debugf("Starting service %s", context.getController().getName().getCanonicalName());
    ORB orb = orbInjector.getValue();
    POA rootPOA = rootPOAInjector.getValue();
    POA namingPOA = namingPOAInjector.getValue();
    try {
        // initialize the static naming service variables.
        CorbaNamingContext.init(orb, rootPOA);
        // create and initialize the root context instance according to the configuration.
        CorbaNamingContext ns = new CorbaNamingContext();
        ns.init(namingPOA, false, false);
        // create and activate the root context.
        byte[] rootContextId = "root".getBytes();
        namingPOA.activate_object_with_id(rootContextId, ns);
        namingService = NamingContextExtHelper.narrow(namingPOA.create_reference_with_id(rootContextId, "IDL:omg.org/CosNaming/NamingContextExt:1.0"));
        // exporting the NameService initial reference
        ((com.sun.corba.se.impl.orb.ORBImpl) orb).register_initial_reference(Constants.NAME_SERVICE_INIT_REF, namingPOA.servant_to_reference(ns));
        // exporting root-context initial reference
        final boolean exportCorbaloc = properties.getProperty(Constants.NAMING_EXPORT_CORBALOC).equals("true");
        if (exportCorbaloc) {
            final String rootContext = properties.getProperty(Constants.NAMING_ROOT_CONTEXT);
            ((com.sun.corba.se.impl.orb.ORBImpl) orb).register_initial_reference(rootContext, namingPOA.servant_to_reference(ns));
        }
    } catch (Exception e) {
        throw IIOPLogger.ROOT_LOGGER.failedToStartJBossCOSNaming(e);
    }
    // bind the corba naming service to JNDI.
    CorbaServiceUtil.bindObject(context.getChildTarget(), "corbanaming", namingService);
    if (IIOPLogger.ROOT_LOGGER.isDebugEnabled()) {
        IIOPLogger.ROOT_LOGGER.corbaNamingServiceStarted();
        IIOPLogger.ROOT_LOGGER.debugf("Naming: [%s]", orb.object_to_string(namingService));
    }
}
Also used : POA(org.omg.PortableServer.POA) CorbaNamingContext(org.wildfly.iiop.openjdk.naming.CorbaNamingContext) ORB(org.omg.CORBA.ORB) 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