001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.ksb.messaging.web;
017
018 import org.apache.commons.lang.StringUtils;
019 import org.apache.struts.action.ActionForm;
020 import org.apache.struts.action.ActionForward;
021 import org.apache.struts.action.ActionMapping;
022 import org.apache.struts.action.ActionMessages;
023 import org.kuali.rice.core.api.config.property.ConfigContext;
024 import org.kuali.rice.ksb.service.KSBServiceLocator;
025 import org.kuali.rice.ksb.util.KSBConstants;
026
027 import javax.servlet.ServletException;
028 import javax.servlet.http.HttpServletRequest;
029 import javax.servlet.http.HttpServletResponse;
030 import java.io.IOException;
031
032
033 /**
034 * Struts action for interacting with the queue of messages.
035 *
036 * @author Kuali Rice Team (rice.collab@kuali.org)
037 */
038 public class ThreadPoolAction extends KSBAction {
039
040 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ThreadPoolAction.class);
041
042 public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request,
043 HttpServletResponse response) throws IOException, ServletException {
044 return mapping.findForward("basic");
045 }
046
047 public ActionMessages establishRequiredState(HttpServletRequest request, ActionForm actionForm) throws Exception {
048 ThreadPoolForm form = (ThreadPoolForm)actionForm;
049 form.setThreadPool(KSBServiceLocator.getThreadPool());
050 if (form.getCorePoolSize() == null) {
051 form.setCorePoolSize(form.getThreadPool().getCorePoolSize());
052 }
053 if (form.getMaximumPoolSize() == null) {
054 form.setMaximumPoolSize(form.getThreadPool().getMaximumPoolSize());
055 }
056 if (form.getTimeIncrement() == null) {
057 String timeIncrementValue = ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.ROUTE_QUEUE_TIME_INCREMENT_KEY);
058 if (!StringUtils.isEmpty(timeIncrementValue)) {
059 form.setTimeIncrement(Long.parseLong(timeIncrementValue));
060 }
061 }
062 if (form.getMaxRetryAttempts() == null) {
063 String maxRetryAttemptsValue = ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.ROUTE_QUEUE_MAX_RETRY_ATTEMPTS_KEY);
064 if (!StringUtils.isEmpty(maxRetryAttemptsValue)) {
065 form.setMaxRetryAttempts(Long.parseLong(maxRetryAttemptsValue));
066 }
067 }
068 return null;
069 }
070
071 }