modules/enterprise/gui/coregui/pom.xml | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/listener/CoreGuiServletContextListener.java | 67 +++++++ modules/enterprise/server/ear/pom.xml | 14 - modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 21 ++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/ShutdownListener.java | 7 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java | 10 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBeanPreparation.java | 68 ------- modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java | 29 --- modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqDeploymentMarker.java | 49 ----- modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqInitializationProcessor.java | 53 ----- modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqShutdownBeanDependenciesProcessor.java | 94 ---------- pom.xml | 7 12 files changed, 114 insertions(+), 311 deletions(-)
New commits: commit 0bddf58297213e94fe7d8ab426c07c1ad10dfe70 Author: Thomas Segismont tsegismo@redhat.com Date: Fri Jun 28 12:45:50 2013 +0200
Bug 957689 - Unable to complete tasks when server is shutdown
Removed DUPs Made Core GUI last component to get deployed and first to get undeployed Added CoreGuiServletContextListener to initialize or shutdown RHQ server
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml index 7375ec2..969ab8e 100644 --- a/modules/enterprise/gui/coregui/pom.xml +++ b/modules/enterprise/gui/coregui/pom.xml @@ -191,6 +191,12 @@ </dependency>
<dependency> + <groupId>org.jboss.spec.javax.servlet</groupId> + <artifactId>jboss-servlet-api_3.0_spec</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>${resteasy.version}</version> diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/listener/CoreGuiServletContextListener.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/listener/CoreGuiServletContextListener.java new file mode 100644 index 0000000..8260327 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/listener/CoreGuiServletContextListener.java @@ -0,0 +1,67 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2013 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +package org.rhq.enterprise.gui.coregui.server.listener; + +import static java.util.concurrent.TimeUnit.SECONDS; + +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; + +import javax.ejb.EJB; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; + +import org.rhq.enterprise.server.core.ShutdownListener; +import org.rhq.enterprise.server.core.StartupLocal; + +/** + * Listens to {@link ServletContextEvent}s to initialize or shutdown RHQ server. + * + * @author Thomas Segismont + */ +@WebListener +public class CoreGuiServletContextListener implements ServletContextListener { + + private ScheduledExecutorService scheduledExecutorService; + + @EJB + StartupLocal startupBean; + + @EJB + ShutdownListener shutdownListener; + + @Override + public void contextInitialized(ServletContextEvent sce) { + scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); + scheduledExecutorService.schedule(new Runnable() { + @Override + public void run() { + startupBean.init(); + } + }, 10, SECONDS); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + shutdownListener.handleNotification(); + scheduledExecutorService.shutdownNow(); + } +} diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml index a0e00f6..9a82877 100644 --- a/modules/enterprise/server/ear/pom.xml +++ b/modules/enterprise/server/ear/pom.xml @@ -298,13 +298,6 @@ <!-- ** WARs --> <webModule> <groupId>${project.groupId}</groupId> - <artifactId>rhq-coregui</artifactId> - <bundleFileName>coregui.war</bundleFileName> - <contextRoot>/coregui</contextRoot> - </webModule> - - <webModule> - <groupId>${project.groupId}</groupId> <artifactId>rhq-portal</artifactId> <bundleFileName>rhq-portal.war</bundleFileName> <contextRoot>/</contextRoot> @@ -340,6 +333,13 @@ <contextRoot>/jboss-remoting-servlet-invoker</contextRoot> </webModule>
+ <webModule> + <groupId>${project.groupId}</groupId> + <artifactId>rhq-coregui</artifactId> + <bundleFileName>coregui.war</bundleFileName> + <contextRoot>/coregui</contextRoot> + </webModule> + </modules> </configuration> </plugin> diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java index c0b8449..ea7ac6b 100644 --- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java +++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java @@ -1,3 +1,22 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2013 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + package org.rhq.enterprise.server.test;
import java.io.File; @@ -325,8 +344,6 @@ public abstract class AbstractEJB3Test extends Arquillian { testEar.delete(ArchivePaths .create("/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/core/StartupBean$1.class")); testEar.delete(ArchivePaths - .create("/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/core/StartupBeanPreparation.class")); - testEar.delete(ArchivePaths .create("/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/core/ShutdownListener.class"));
//replace the above startup beans with stripped down versions diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/ShutdownListener.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/ShutdownListener.java index 585dbaf..b07a420 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/ShutdownListener.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/ShutdownListener.java @@ -24,11 +24,9 @@ import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement;
-import javax.annotation.PreDestroy; import javax.annotation.Resource; import javax.ejb.EJB; import javax.ejb.Singleton; -import javax.ejb.Startup; import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; import javax.sql.DataSource; @@ -62,7 +60,6 @@ import org.rhq.enterprise.server.util.LookupUtil; * @author Joseph Marques */ @Singleton -@Startup @TransactionAttribute(TransactionAttributeType.SUPPORTS) public class ShutdownListener { private final Log log = LogFactory.getLog(ShutdownListener.class); @@ -94,10 +91,7 @@ public class ShutdownListener { * This is called when the shutdown notification is received from the JBoss server. This gives a chance for us to * cleanly shutdown our application in an orderly fashion. */ - @PreDestroy public void handleNotification() { - // JBossAS 4.2.3 used to send us this JMX notification on shutdown - AS7 does not have shutdown notifications. - // So we are using the @PreDestroy mechanism on a singleton EJB to attempt to clean up the application before it is shutdown log.info("Shutdown listener has been told we are shutting down - starting to clean up now..."); logShutdownTime(); stopScheduler(); @@ -157,6 +151,7 @@ public class ShutdownListener { } } } + /** * This will shutdown the scheduler. */ diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java index f8185e0..9d37b75 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright (C) 2005-2011 Red Hat, Inc. + * Copyright (C) 2005-2013 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -13,8 +13,8 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ package org.rhq.enterprise.server.core;
@@ -65,7 +65,6 @@ import org.rhq.enterprise.server.RHQConstants; import org.rhq.enterprise.server.alert.engine.internal.AlertConditionCacheCoordinator; import org.rhq.enterprise.server.auth.SessionManager; import org.rhq.enterprise.server.auth.SubjectManagerLocal; -import org.rhq.enterprise.server.storage.StorageClientManagerBean; import org.rhq.enterprise.server.cloud.TopologyManagerLocal; import org.rhq.enterprise.server.cloud.instance.CacheConsistencyManagerLocal; import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal; @@ -90,6 +89,7 @@ import org.rhq.enterprise.server.scheduler.jobs.PurgePluginsJob; import org.rhq.enterprise.server.scheduler.jobs.PurgeResourceTypesJob; import org.rhq.enterprise.server.scheduler.jobs.SavedSearchResultCountRecalculationJob; import org.rhq.enterprise.server.scheduler.jobs.StorageNodeMaintenanceJob; +import org.rhq.enterprise.server.storage.StorageClientManagerBean; import org.rhq.enterprise.server.storage.StorageClusterHeartBeatJob; import org.rhq.enterprise.server.system.SystemManagerLocal; import org.rhq.enterprise.server.util.LookupUtil; @@ -106,7 +106,6 @@ import org.rhq.enterprise.server.util.concurrent.AvailabilityReportSerializer; * BEAN ConcurrencyManagement is enough: the {@link #initialized} property is only modified on startup. */ @Singleton -//@Startup // when AS7-5530 is fixed, uncomment this and remove class StartupBeanToWorkaroundAS7_5530 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @ConcurrencyManagement(ConcurrencyManagementType.BEAN) public class StartupBean implements StartupLocal { @@ -170,7 +169,6 @@ public class StartupBean implements StartupLocal { * * @throws RuntimeException */ - //@PostConstruct // when AS7-5530 is fixed, uncomment this and remove class StartupBeanToWorkaroundAS7_5530 @Override public void init() throws RuntimeException { secureNaming(); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBeanPreparation.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBeanPreparation.java deleted file mode 100644 index c66d328..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBeanPreparation.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2011 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.core; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import javax.ejb.EJB; -import javax.ejb.Singleton; -import javax.ejb.Startup; -import javax.ejb.Timeout; -import javax.ejb.TimerConfig; -import javax.ejb.TimerService; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * This startup singleton EJB is here to work around bug AS7-5530 and to - * schedule the real StartupBean's work in a delayed fashion (this is to allow - * AS7 to complete its deployment work before we do our work). - * - * See https://issues.jboss.org/browse/AS7-5530 - */ -@Singleton -@Startup -public class StartupBeanPreparation { - private Log log = LogFactory.getLog(this.getClass()); - - @EJB - private StartupLocal startupBean; - - @Resource - private TimerService timerService; // needed to schedule our startup bean init call - - @PostConstruct - public void initWithTransactionBecauseAS75530() throws RuntimeException { - timerService.createSingleActionTimer(10000, new TimerConfig(null, false)); // call StartupBean in 10s - } - - @Timeout - public void initializeServer() throws RuntimeException { - try { - this.startupBean.init(); - } catch (Throwable t) { - // do NOT allow exceptions to bubble out of our method because then - // the EJB container would simply re-trigger the timer and call us again - // and we don't want to keep failing over and over filling the logs - // in an infinite loop. - log.fatal("The server failed to start up properly", t); - } - } -} diff --git a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java index 80515ed..4b1b46a 100644 --- a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java +++ b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java @@ -16,6 +16,7 @@ * along with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + package org.rhq.enterprise.startup;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; @@ -30,35 +31,26 @@ import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.URL import java.io.File; import java.io.FileNotFoundException; import java.net.URL; -import java.util.List;
-import org.jboss.as.controller.AbstractBoottimeAddStepHandler; +import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; -import org.jboss.as.controller.ServiceVerificationHandler; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration; import org.jboss.as.controller.registry.Resource; -import org.jboss.as.server.AbstractDeploymentChainStep; -import org.jboss.as.server.DeploymentProcessorTarget; -import org.jboss.as.server.deployment.Phase; import org.jboss.dmr.ModelNode; import org.jboss.logging.Logger; import org.jboss.modules.Module; -import org.jboss.msc.service.ServiceController; - -import org.rhq.enterprise.startup.deployment.RhqInitializationProcessor; -import org.rhq.enterprise.startup.deployment.RhqShutdownBeanDependenciesProcessor;
/** * Handler responsible for adding the subsystem resource to the model * * @author John Mazzitelli */ -class StartupSubsystemAdd extends AbstractBoottimeAddStepHandler { +class StartupSubsystemAdd extends AbstractAddStepHandler {
private static final Logger LOG = Logger.getLogger(StartupSubsystemAdd.class);
@@ -122,19 +114,4 @@ class StartupSubsystemAdd extends AbstractBoottimeAddStepHandler { return false; }
- @Override - protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model, - ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) - throws OperationFailedException { - LOG.info("Adding RHQ deploymentUnit processors"); - context.addStep(new AbstractDeploymentChainStep() { - public void execute(DeploymentProcessorTarget processorTarget) { - processorTarget.addDeploymentProcessor(StartupExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, - Phase.STRUCTURE_EAR + 10, new RhqInitializationProcessor()); - processorTarget.addDeploymentProcessor(StartupExtension.SUBSYSTEM_NAME, Phase.INSTALL, - Phase.INSTALL_DEPENDS_ON_ANNOTATION + 10, new RhqShutdownBeanDependenciesProcessor()); - } - }, OperationContext.Stage.RUNTIME); - } - } diff --git a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqDeploymentMarker.java b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqDeploymentMarker.java deleted file mode 100644 index ff98956..0000000 --- a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqDeploymentMarker.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2013 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package org.rhq.enterprise.startup.deployment; - -import org.jboss.as.server.deployment.AttachmentKey; -import org.jboss.as.server.deployment.DeploymentUnit; - -/** - * Marker for RHQ EAR. Deployment Unit Processors will only process RHQ EAR sub deployments. - * - * @author Thomas Segismont - */ -class RhqDeploymentMarker { - private static final AttachmentKey<RhqDeploymentMarker> MARKER = AttachmentKey.create(RhqDeploymentMarker.class); - - private RhqDeploymentMarker() { - // Defensive - } - - static void mark(DeploymentUnit unit) { - unit.putAttachment(MARKER, new RhqDeploymentMarker()); - } - - static boolean isRhqDeployment(DeploymentUnit unit) { - DeploymentUnit deploymentUnit = unit; - if (deploymentUnit.getParent() != null) { - do { - deploymentUnit = deploymentUnit.getParent(); - } while (deploymentUnit.getParent() != null); - } - return deploymentUnit.hasAttachment(MARKER); - } -} diff --git a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqInitializationProcessor.java b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqInitializationProcessor.java deleted file mode 100644 index 4e694ae..0000000 --- a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqInitializationProcessor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2013 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package org.rhq.enterprise.startup.deployment; - -import static org.rhq.enterprise.startup.StartupExtension.DEPLOYMENT_APP_EAR; - -import org.jboss.as.ee.structure.DeploymentType; -import org.jboss.as.ee.structure.DeploymentTypeMarker; -import org.jboss.as.server.deployment.DeploymentPhaseContext; -import org.jboss.as.server.deployment.DeploymentUnit; -import org.jboss.as.server.deployment.DeploymentUnitProcessingException; -import org.jboss.as.server.deployment.DeploymentUnitProcessor; -import org.jboss.logging.Logger; - -/** - * A DUP which detects RHQ EAR deployment. - * - * @author Thomas Segismont - */ -public class RhqInitializationProcessor implements DeploymentUnitProcessor { - - private static final Logger LOG = Logger.getLogger(RhqInitializationProcessor.class); - - @Override - public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { - DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); - if (deploymentUnit.getParent() == null && DEPLOYMENT_APP_EAR.equals(deploymentUnit.getName()) - && DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) { - LOG.info("Found " + DEPLOYMENT_APP_EAR + " deployment"); - RhqDeploymentMarker.mark(deploymentUnit); - } - } - - @Override - public void undeploy(DeploymentUnit context) { - } -} diff --git a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqShutdownBeanDependenciesProcessor.java b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqShutdownBeanDependenciesProcessor.java deleted file mode 100644 index 2b88268..0000000 --- a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqShutdownBeanDependenciesProcessor.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2013 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -package org.rhq.enterprise.startup.deployment; - -import static org.jboss.msc.service.ServiceBuilder.DependencyType.REQUIRED; - -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; - -import org.jboss.as.ee.component.Attachments; -import org.jboss.as.ee.component.ComponentDescription; -import org.jboss.as.ee.component.EEModuleDescription; -import org.jboss.as.ejb3.component.session.SessionBeanComponentDescription; -import org.jboss.as.server.deployment.DeploymentPhaseContext; -import org.jboss.as.server.deployment.DeploymentUnit; -import org.jboss.as.server.deployment.DeploymentUnitProcessingException; -import org.jboss.as.server.deployment.DeploymentUnitProcessor; - -/** - * A DUP which makes the ShutdownListener session bean automatically depend on all other sessions beans. - * - * @author Thomas Segismont - */ -public class RhqShutdownBeanDependenciesProcessor implements DeploymentUnitProcessor { - - public static final String SHUTDOWN_LISTENER_CLASS_NAME = "org.rhq.enterprise.server.core.ShutdownListener"; - - @Override - public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException { - DeploymentUnit unit = context.getDeploymentUnit(); - EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); - Collection<ComponentDescription> componentDescriptions = moduleDescription.getComponentDescriptions(); - - if (componentDescriptions == null || componentDescriptions.isEmpty() - || !RhqDeploymentMarker.isRhqDeployment(unit)) { - // Only process sub deployments of the RHQ EAR - return; - } - - Collection<SessionBeanComponentDescription> sessionBeanComponentDescriptions = getSessionBeanComponentDescriptions(componentDescriptions); - - SessionBeanComponentDescription shutdownBeanComponentDescription = extractShutdownBeanDescription(sessionBeanComponentDescriptions); - - for (SessionBeanComponentDescription sessionBeanComponentDescription : sessionBeanComponentDescriptions) { - shutdownBeanComponentDescription.addDependency(sessionBeanComponentDescription.getStartServiceName(), - REQUIRED); - } - } - - private Collection<SessionBeanComponentDescription> getSessionBeanComponentDescriptions( - Collection<ComponentDescription> componentDescriptions) { - Collection<SessionBeanComponentDescription> sessionBeanComponentDescriptions = new LinkedList<SessionBeanComponentDescription>(); - for (ComponentDescription componentDescription : componentDescriptions) { - if (componentDescription instanceof SessionBeanComponentDescription) { - sessionBeanComponentDescriptions.add((SessionBeanComponentDescription) componentDescription); - } - } - return sessionBeanComponentDescriptions; - } - - private SessionBeanComponentDescription extractShutdownBeanDescription( - Collection<SessionBeanComponentDescription> sessionBeanComponentDescriptions) { - for (Iterator<SessionBeanComponentDescription> iterator = sessionBeanComponentDescriptions.iterator(); iterator - .hasNext();) { - SessionBeanComponentDescription sessionBeanComponentDescription = iterator.next(); - if (sessionBeanComponentDescription.getComponentClassName().equals(SHUTDOWN_LISTENER_CLASS_NAME)) { - iterator.remove(); - return sessionBeanComponentDescription; - } - } - return null; - } - - @Override - public void undeploy(DeploymentUnit context) { - } -} diff --git a/pom.xml b/pom.xml index 220eb30..99c1bdc 100644 --- a/pom.xml +++ b/pom.xml @@ -90,6 +90,7 @@ <javax.annotation.api.version>1.0.1.Final</javax.annotation.api.version> <javax.ejb.api.version>1.0.2.Final</javax.ejb.api.version> <javax.jms.api.version>1.0.0.Final</javax.jms.api.version> + <javax.servlet.api.version>1.0.2.Final</javax.servlet.api.version> <javax.mail.api.version>1.4.4</javax.mail.api.version> <javassist.version>3.15.0-GA</javassist.version> <jaxb-api.version>1.0.4.Final</jaxb-api.version> @@ -318,6 +319,12 @@ </dependency>
<dependency> + <groupId>org.jboss.spec.javax.servlet</groupId> + <artifactId>jboss-servlet-api_3.0_spec</artifactId> + <version>${javax.servlet.api.version}</version> + </dependency> + + <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>${javassist.version}</version>
rhq-commits@lists.fedorahosted.org