Search in sources :

Example 1 with XAResourceRecoveryRegistry

use of org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry in project wildfly by wildfly.

the class AbstractResourceAdapterDeploymentService method unregisterAll.

public void unregisterAll(String deploymentName) {
    if (value != null) {
        DEPLOYMENT_CONNECTOR_LOGGER.debugf("Unregistering: %s", deploymentName);
        if (registry != null && registry.getValue() != null) {
            registry.getValue().unregisterResourceAdapterDeployment(value);
        }
        if (managementRepository != null && managementRepository.getValue() != null && value.getDeployment() != null && value.getDeployment().getConnector() != null) {
            managementRepository.getValue().getConnectors().remove(value.getDeployment().getConnector());
        }
        if (mdr != null && mdr.getValue() != null && value.getDeployment() != null && value.getDeployment().getCfs() != null && value.getDeployment().getCfJndiNames() != null) {
            for (int i = 0; i < value.getDeployment().getCfs().length; i++) {
                try {
                    String cf = value.getDeployment().getCfs()[i].getClass().getName();
                    String jndi = value.getDeployment().getCfJndiNames()[i];
                    mdr.getValue().unregisterJndiMapping(value.getDeployment().getURL().toExternalForm(), cf, jndi);
                } catch (Throwable nfe) {
                    DEPLOYMENT_CONNECTOR_LOGGER.debug("Exception during JNDI unbinding", nfe);
                }
            }
        }
        if (mdr != null && mdr.getValue() != null && value.getDeployment().getAos() != null && value.getDeployment().getAoJndiNames() != null) {
            for (int i = 0; i < value.getDeployment().getAos().length; i++) {
                try {
                    String ao = value.getDeployment().getAos()[i].getClass().getName();
                    String jndi = value.getDeployment().getAoJndiNames()[i];
                    mdr.getValue().unregisterJndiMapping(value.getDeployment().getURL().toExternalForm(), ao, jndi);
                } catch (Throwable nfe) {
                    DEPLOYMENT_CONNECTOR_LOGGER.debug("Exception during JNDI unbinding", nfe);
                }
            }
        }
        if (value != null && value.getDeployment() != null && value.getDeployment().getRecovery() != null && txInt != null && txInt.getValue() != null) {
            XAResourceRecoveryRegistry rr = txInt.getValue().getRecoveryRegistry();
            if (rr != null) {
                for (XAResourceRecovery recovery : value.getDeployment().getRecovery()) {
                    if (recovery != null) {
                        try {
                            recovery.shutdown();
                        } catch (Exception e) {
                            DEPLOYMENT_CONNECTOR_LOGGER.errorDuringRecoveryShutdown(e);
                        } finally {
                            rr.removeXAResourceRecovery(recovery);
                        }
                    }
                }
            }
        }
        if (value.getDeployment() != null && value.getDeployment().getConnectionManagers() != null) {
            for (ConnectionManager cm : value.getDeployment().getConnectionManagers()) {
                cm.shutdown();
            }
        }
        if (value.getDeployment() != null && value.getDeployment().getResourceAdapter() != null) {
            ClassLoader old = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
            try {
                WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(value.getDeployment().getResourceAdapter().getClass().getClassLoader());
                value.getDeployment().getResourceAdapter().stop();
            } catch (Throwable nfe) {
                DEPLOYMENT_CONNECTOR_LOGGER.errorStoppingRA(nfe);
            } finally {
                WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
            }
        }
        if (value.getDeployment() != null && value.getDeployment().getBootstrapContextIdentifier() != null) {
            BootstrapContextCoordinator.getInstance().removeBootstrapContext(value.getDeployment().getBootstrapContextIdentifier());
        }
    }
    if (raRepositoryRegistrationId != null && raRepository != null && raRepository.getValue() != null) {
        try {
            raRepository.getValue().unregisterResourceAdapter(raRepositoryRegistrationId);
        } catch (Throwable e) {
            DEPLOYMENT_CONNECTOR_LOGGER.debug("Failed to unregister RA from RA Repository", e);
        }
    }
    if (connectorServicesRegistrationName != null) {
        try {
            ConnectorServices.unregisterResourceAdapterIdentifier(connectorServicesRegistrationName);
        } catch (Throwable e) {
            DEPLOYMENT_CONNECTOR_LOGGER.debug("Failed to unregister RA from ConnectorServices", e);
        }
    }
    if (mdrRegistrationName != null && mdr != null && mdr.getValue() != null) {
        try {
            mdr.getValue().unregisterResourceAdapter(mdrRegistrationName);
        } catch (Throwable e) {
            DEPLOYMENT_CONNECTOR_LOGGER.debug("Failed to unregister RA from MDR", e);
        }
    }
}
Also used : CachedConnectionManager(org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager) ConnectionManager(org.jboss.jca.core.connectionmanager.ConnectionManager) XAResourceRecovery(org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery) XAResourceRecoveryRegistry(org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry) XsdString(org.jboss.jca.common.api.metadata.spec.XsdString) URISyntaxException(java.net.URISyntaxException) AlreadyExistsException(org.jboss.jca.core.spi.mdr.AlreadyExistsException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) DeployException(org.jboss.jca.deployers.common.DeployException)

Aggregations

URISyntaxException (java.net.URISyntaxException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 XsdString (org.jboss.jca.common.api.metadata.spec.XsdString)1 CachedConnectionManager (org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager)1 ConnectionManager (org.jboss.jca.core.connectionmanager.ConnectionManager)1 AlreadyExistsException (org.jboss.jca.core.spi.mdr.AlreadyExistsException)1 XAResourceRecovery (org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery)1 XAResourceRecoveryRegistry (org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry)1 DeployException (org.jboss.jca.deployers.common.DeployException)1