01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in
06: * compliance with the License. You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
11: * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
12: * language governing permissions and limitations under the License.
13: */
14: package edu.iu.uis.eden.messaging.web;
15:
16: import java.io.IOException;
17:
18: import javax.servlet.ServletException;
19: import javax.servlet.http.HttpServletRequest;
20: import javax.servlet.http.HttpServletResponse;
21:
22: import org.apache.struts.action.ActionForm;
23: import org.apache.struts.action.ActionForward;
24: import org.apache.struts.action.ActionMapping;
25: import org.apache.struts.action.ActionMessages;
26: import org.kuali.bus.services.KSBServiceLocator;
27:
28: import edu.iu.uis.eden.web.WorkflowAction;
29:
30: /**
31: * Struts action for interacting with the queue of messages.
32: *
33: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
34: */
35: public class ThreadPoolAction extends WorkflowAction {
36:
37: public ActionForward start(ActionMapping mapping, ActionForm form,
38: HttpServletRequest request, HttpServletResponse response)
39: throws IOException, ServletException {
40: return mapping.findForward("basic");
41: }
42:
43: public ActionForward update(ActionMapping mapping,
44: ActionForm actionForm, HttpServletRequest request,
45: HttpServletResponse response) throws IOException,
46: ServletException {
47: ThreadPoolForm form = (ThreadPoolForm) actionForm;
48: form.getThreadPool().setCorePoolSize(form.getCorePoolSize());
49: if (form.getMaximumPoolSize() < form.getCorePoolSize()) {
50: form.setMaximumPoolSize(form.getCorePoolSize());
51: }
52: form.getThreadPool().setMaximumPoolSize(
53: form.getMaximumPoolSize());
54: return mapping.findForward("basic");
55: }
56:
57: public ActionMessages establishRequiredState(
58: HttpServletRequest request, ActionForm actionForm)
59: throws Exception {
60: ThreadPoolForm form = (ThreadPoolForm) actionForm;
61: form.setThreadPool(KSBServiceLocator.getThreadPool());
62: if (form.getCorePoolSize() == null) {
63: form
64: .setCorePoolSize(form.getThreadPool()
65: .getCorePoolSize());
66: }
67: if (form.getMaximumPoolSize() == null) {
68: form.setMaximumPoolSize(form.getThreadPool()
69: .getMaximumPoolSize());
70: }
71: return null;
72: }
73:
74: }
|