Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.server.deployment;
import static org.jboss.as.server.ServerLogger.DEPLOYMENT_LOGGER;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import org.jboss.as.server.ServerLogger;
import org.jboss.as.server.ServerMessages;
import org.jboss.msc.service.AbstractServiceListener;
import org.jboss.msc.service.DelegatingServiceRegistry;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceController.Mode;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
/**
* A service which executes a particular phase of deployment.
*
* @param the public type of this deployment unit phase
*
* @author David M. Lloyd
*/
final class DeploymentUnitPhaseService implements Service {
private static final AttachmentKey> UNVISITED_DEFERRED_MODULES = AttachmentKey.createList(DeploymentUnit.class);
private final InjectedValue deployerChainsInjector = new InjectedValue();
private final DeploymentUnit deploymentUnit;
private final Phase phase;
private final AttachmentKey valueKey;
private final List injectedAttachedDependencies = new ArrayList();
/**
* boolean value that tracks if this phase has already been run.
*
* If anything attempts to restart the phase a complete deployment restart is performed instead.
*/
private final AtomicBoolean runOnce = new AtomicBoolean();
private DeploymentUnitPhaseService(final DeploymentUnit deploymentUnit, final Phase phase, final AttachmentKey valueKey) {
this.deploymentUnit = deploymentUnit;
this.phase = phase;
this.valueKey = valueKey;
}
private static DeploymentUnitPhaseService create(final DeploymentUnit deploymentUnit, final Phase phase, AttachmentKey valueKey) {
return new DeploymentUnitPhaseService(deploymentUnit, phase, valueKey);
}
static DeploymentUnitPhaseService> create(final DeploymentUnit deploymentUnit, final Phase phase) {
return create(deploymentUnit, phase, phase.getPhaseKey());
}
@SuppressWarnings("unchecked")
public synchronized void start(final StartContext context) throws StartException {
boolean allowRestart = restartAllowed();
if(runOnce.get() && !allowRestart) {
ServerLogger.DEPLOYMENT_LOGGER.deploymentRestartDetected(deploymentUnit.getName());
//this only happens on deployment restart, which we don't support at the moment.
//instead we are going to restart the complete deployment.
//we get the deployment unit service name
//add a listener to perform a restart when the service goes down
//then stop the deployment unit service
final ServiceName serviceName;
if(deploymentUnit.getParent() == null) {
serviceName = deploymentUnit.getServiceName();
} else {
serviceName = deploymentUnit.getParent().getServiceName();
}
ServiceController> controller = context.getController().getServiceContainer().getRequiredService(serviceName);
controller.addListener(new AbstractServiceListener