2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org
.argeo
.slc
.core
.execution
.tasks
;
19 import java
.lang
.reflect
.Method
;
20 import java
.util
.UUID
;
22 import org
.argeo
.slc
.SlcException
;
23 import org
.argeo
.slc
.deploy
.DeployedSystem
;
24 import org
.argeo
.slc
.deploy
.DeployedSystemManager
;
25 import org
.argeo
.slc
.process
.SlcExecution
;
26 import org
.argeo
.slc
.process
.SlcExecutionRelated
;
27 import org
.argeo
.slc
.process
.SlcExecutionStep
;
28 import org
.argeo
.slc
.structure
.StructureRegistry
;
30 /** Use {@link MethodCall} instead. */
32 public class SlcManager
implements Runnable
, SlcExecutionRelated
{
34 private String slcExecutionUuid
;
35 private String slcExecutionStepUuid
;
37 private String action
;
38 private DeployedSystemManager
<DeployedSystem
> manager
;
40 public final void run() {
41 uuid
= UUID
.randomUUID().toString();
42 executeActions(StructureRegistry
.ALL
);
45 protected void executeActions(String mode
) {
47 Class
<?
>[] argClasses
= null;
48 Method method
= manager
.getClass().getMethod(action
, argClasses
);
49 Object
[] argObjects
= null;
50 method
.invoke(manager
, argObjects
);
51 } catch (Exception e
) {
52 throw new SlcException("Cannot execute action " + action
53 + " for manager " + manager
, e
);
57 public void setAction(String action
) {
61 public void setManager(DeployedSystemManager
<DeployedSystem
> manager
) {
62 this.manager
= manager
;
65 public String
getUuid() {
69 public void setUuid(String uuid
) {
73 public String
getSlcExecutionUuid() {
74 return slcExecutionUuid
;
77 public void setSlcExecutionUuid(String slcExecutionUuid
) {
78 this.slcExecutionUuid
= slcExecutionUuid
;
81 public String
getSlcExecutionStepUuid() {
82 return slcExecutionStepUuid
;
85 public void setSlcExecutionStepUuid(String slcExecutionStepUuid
) {
86 this.slcExecutionStepUuid
= slcExecutionStepUuid
;
89 public void notifySlcExecution(SlcExecution slcExecution
) {
90 if (slcExecution
!= null) {
91 slcExecutionUuid
= slcExecution
.getUuid();
92 SlcExecutionStep step
= slcExecution
.currentStep();
94 slcExecutionStepUuid
= step
.getUuid();