View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.ksb.messaging.web;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.struts.action.ActionForm;
20  import org.apache.struts.action.ActionForward;
21  import org.apache.struts.action.ActionMapping;
22  import org.apache.struts.action.ActionMessages;
23  import org.kuali.rice.core.api.config.property.ConfigContext;
24  import org.kuali.rice.ksb.service.KSBServiceLocator;
25  import org.kuali.rice.ksb.util.KSBConstants;
26  
27  import javax.servlet.ServletException;
28  import javax.servlet.http.HttpServletRequest;
29  import javax.servlet.http.HttpServletResponse;
30  import java.io.IOException;
31  
32  
33  /**
34   * Struts action for interacting with the queue of messages.
35   *
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  public class ThreadPoolAction extends KSBAction {
39  
40      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ThreadPoolAction.class);
41  
42      public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request,
43  	    HttpServletResponse response) throws IOException, ServletException {
44  	return mapping.findForward("basic");
45      }
46  
47      public ActionMessages establishRequiredState(HttpServletRequest request, ActionForm actionForm) throws Exception {
48  	ThreadPoolForm form = (ThreadPoolForm)actionForm;
49  	form.setThreadPool(KSBServiceLocator.getThreadPool());
50  	if (form.getCorePoolSize() == null) {
51  	    form.setCorePoolSize(form.getThreadPool().getCorePoolSize());
52  	}
53  	if (form.getMaximumPoolSize() == null) {
54  	    form.setMaximumPoolSize(form.getThreadPool().getMaximumPoolSize());
55  	}
56  	if (form.getTimeIncrement() == null) {
57  	    String timeIncrementValue = ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.ROUTE_QUEUE_TIME_INCREMENT_KEY);
58  	    if (!StringUtils.isEmpty(timeIncrementValue)) {
59  		form.setTimeIncrement(Long.parseLong(timeIncrementValue));
60  	    }
61  	}
62  	if (form.getMaxRetryAttempts() == null) {
63  	    String maxRetryAttemptsValue = ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.ROUTE_QUEUE_MAX_RETRY_ATTEMPTS_KEY);
64  	    if (!StringUtils.isEmpty(maxRetryAttemptsValue)) {
65  		form.setMaxRetryAttempts(Long.parseLong(maxRetryAttemptsValue));
66  	    }
67  	}
68  	return null;
69      }
70  
71  }