Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2011, 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.ejb3.subsystem;
 
 
 import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.CORE_THREADS;
 import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.MAX_THREADS;
 import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.PATH;
 import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.RELATIVE_TO;
 
 import java.util.List;
Adds the timer service

Author(s):
Stuart Douglas
 
 public class TimerServiceAdd extends AbstractBoottimeAddStepHandler implements DescriptionProvider {
 
     private static final Logger logger = Logger.getLogger(TimerServiceAdd.class);
 
     public static final TimerServiceAdd INSTANCE = new TimerServiceAdd();


    
Populate the timerService from the operation

Parameters:
operation the operation
timerServiceModel strict-max-pool ModelNode
Throws:
org.jboss.as.controller.OperationFailedException
 
 
     protected void populateModel(ModelNode operationModelNode timerServiceModelthrows OperationFailedException {
 
         // max-pool-size
         if (operation.hasDefined(.)) {
             int maxThreads = operation.get(.).asInt();
             if (maxThreads <= 0) {
                 throw new IllegalArgumentException("Invalid value: " + maxThreads + " for " + .);
             }
             timerServiceModel.get().set(maxThreads);
         }
         if (operation.hasDefined(.)) {
             int coreThreads = operation.get(.).asInt();
             if (coreThreads <= 0) {
                 throw new IllegalArgumentException("Invalid value: " + coreThreads + " for " + .);
             }
             timerServiceModel.get().set(coreThreads);
         }
 
         if (operation.hasDefined(.)) {
             String relativeTo = operation.get(.).asString();
             timerServiceModel.get().set(relativeTo);
         }
 
         if (operation.hasDefined(.)) {
             String dataDir = operation.get(.).asString();
            timerServiceModel.get().set(dataDir);
        }
    }
    protected void performBoottime(final OperationContext contextModelNode operationfinal ModelNode modelServiceVerificationHandler verificationHandlerList<ServiceController<?>> newControllers) {
        // Only take runtime action if EJB3 Lite isn't configured
        final ModelNode rootResource = context.getRootResource().getChild(PathElement.pathElement(..)).getModel();
        final boolean lite = rootResource.hasDefined(.) && rootResource.get(.).asBoolean();
        if (!lite) {
            context.addStep(new AbstractDeploymentChainStep() {
                protected void execute(DeploymentProcessorTarget processorTarget) {
                    .debug("Configuring timers");
                    ModelNode timerServiceModel = model;
                    final ModelNode pathNode = timerServiceModel.get();
                    final String path = pathNode.isDefined() ? pathNode.asString() : null;
                    final ModelNode relativeToNode = timerServiceModel.get();
                    final String relativeTo = relativeToNode.isDefined() ? relativeToNode.asString() : null;
                    //install the ejb timer service data store path service
                    if (path != null) {
                        if (relativeTo != null) {
                            RelativePathService.addService(.pathrelativeTocontext.getServiceTarget());
                        } else {
                            AbsolutePathService.addService(.pathcontext.getServiceTarget());
                        }
                    }
                    int coreThreadCount = timerServiceModel.get().asInt(0);
                    int maxThreadCount = timerServiceModel.get().asInt(Runtime.getRuntime().availableProcessors());
                    //we only add the timer service DUP's when the timer service in enabled in XML
                    processorTarget.addDeploymentProcessor(..new AroundTimeoutAnnotationParsingProcessor());
                    processorTarget.addDeploymentProcessor(..new TimerServiceDeploymentProcessor(coreThreadCountmaxThreadCounttrue));
                }
            }, ..);
        }
    }
            @Override
    public ModelNode getModelDescription(Locale locale) {
        return EJB3SubsystemDescriptions.getTimerServiceAddDescription(locale);
    }
New to GrepCode? Check out our FAQ X