Search in sources :

Example 1 with MdsEntityWireException

use of org.motechproject.mds.exception.init.MdsEntityWireException in project motech by motech.

the class EntitiesBundleMonitor method start.

/**
 * Starts the entities bundle and waits until it will be started and its context will be
 * initialized.
 */
public void start() {
    LOGGER.info("Starting the entities bundle");
    try {
        Bundle entitiesBundle = getEntitiesBundle();
        if (entitiesBundle != null && entitiesBundle.getState() != Bundle.STARTING && entitiesBundle.getState() != Bundle.ACTIVE) {
            entitiesBundle.start();
        } else {
            LOGGER.warn("No entities bundle to start");
            return;
        }
    } catch (BundleException e) {
        if (e.getType() == BundleException.RESOLVE_ERROR) {
            throw new MdsEntityWireException(e);
        } else {
            throw new MdsException("Unable to start the entities bundle", e);
        }
    }
    waitUntil(new Condition() {

        @Override
        public boolean await() {
            return !bundleStarted;
        }
    }, "started");
    LOGGER.info("Started the entities bundle");
    waitForEntitiesContext();
}
Also used : Bundle(org.osgi.framework.Bundle) MdsEntityWireException(org.motechproject.mds.exception.init.MdsEntityWireException) MdsException(org.motechproject.mds.exception.MdsException) BundleException(org.osgi.framework.BundleException)

Aggregations

MdsException (org.motechproject.mds.exception.MdsException)1 MdsEntityWireException (org.motechproject.mds.exception.init.MdsEntityWireException)1 Bundle (org.osgi.framework.Bundle)1 BundleException (org.osgi.framework.BundleException)1