]> git.argeo.org Git - gpl/argeo-slc.git/blob - ServiceMsgHandler.java
405741e4ff94ed23328302617070695ffdb40053
[gpl/argeo-slc.git] / ServiceMsgHandler.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.argeo.slc.services;
17
18 import org.argeo.slc.SlcException;
19 import org.argeo.slc.msg.MsgHandler;
20 import org.argeo.slc.msg.process.SlcExecutionStatusRequest;
21 import org.argeo.slc.msg.process.SlcExecutionStepsRequest;
22 import org.argeo.slc.msg.test.tree.AddTreeTestResultAttachmentRequest;
23 import org.argeo.slc.msg.test.tree.CloseTreeTestResultRequest;
24 import org.argeo.slc.msg.test.tree.CreateTreeTestResultRequest;
25 import org.argeo.slc.msg.test.tree.ResultPartRequest;
26 import org.argeo.slc.process.SlcExecution;
27
28 public class ServiceMsgHandler implements MsgHandler {
29 private TestManagerService testManagerService;
30 private SlcExecutionService slcExecutionService;
31
32 public Object handleMsg(Object msg) {
33 if (msg instanceof SlcExecution)
34 slcExecutionService.newExecution((SlcExecution) msg);
35 else if (msg instanceof SlcExecutionStepsRequest)
36 slcExecutionService.addSteps((SlcExecutionStepsRequest) msg);
37 else if (msg instanceof SlcExecutionStatusRequest)
38 slcExecutionService.updateStatus((SlcExecutionStatusRequest) msg);
39 else if (msg instanceof CreateTreeTestResultRequest)
40 testManagerService
41 .createTreeTestResult((CreateTreeTestResultRequest) msg);
42 else if (msg instanceof ResultPartRequest)
43 testManagerService.addResultPart((ResultPartRequest) msg);
44 else if (msg instanceof CloseTreeTestResultRequest)
45 testManagerService
46 .closeTreeTestResult((CloseTreeTestResultRequest) msg);
47 else if (msg instanceof AddTreeTestResultAttachmentRequest)
48 testManagerService
49 .addAttachment((AddTreeTestResultAttachmentRequest) msg);
50 else
51 throw new SlcException("Unrecognized message type " + msg);
52 return null;
53 }
54
55 public void setTestManagerService(TestManagerService testManagerService) {
56 this.testManagerService = testManagerService;
57 }
58
59 public void setSlcExecutionService(SlcExecutionService slcExecutionService) {
60 this.slcExecutionService = slcExecutionService;
61 }
62
63 }