01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: /* $Id: AbstractTask.java 473861 2006-11-12 03:51:14Z gregor $ */
20:
21: package org.apache.lenya.cms.task;
22:
23: import org.apache.avalon.framework.parameters.ParameterException;
24: import org.apache.avalon.framework.parameters.Parameters;
25: import org.apache.avalon.framework.service.ServiceManager;
26:
27: /**
28: * Abstract baseclass for Task
29: * @deprecated Use the usecase framework instead.
30: */
31: public abstract class AbstractTask implements Task {
32: private Parameters parameters = new Parameters();
33:
34: private ServiceManager manager;
35:
36: /**
37: * Ctor.
38: */
39: public AbstractTask() {
40: }
41:
42: /**
43: * @param manager The service manager to use.
44: */
45: public void service(ServiceManager manager) {
46: this .manager = manager;
47: }
48:
49: protected ServiceManager getServiceManager() {
50: return this .manager;
51: }
52:
53: /**
54: * Get parameters of the task
55: * @return The parameters
56: */
57: public Parameters getParameters() {
58: Parameters params = new Parameters();
59: params = params.merge(this .parameters);
60:
61: return params;
62: }
63:
64: /**
65: * Set the parameters
66: * @param _parameters The parameters
67: * @throws ParameterException if the parametrizing fails
68: */
69: public void parameterize(Parameters _parameters)
70: throws ParameterException {
71: this .parameters = this .parameters.merge(_parameters);
72: }
73:
74: /**
75: * Set the label of the task
76: * @param label The label
77: */
78: public void setLabel(String label) {
79: // do nothing
80: }
81:
82: private int result = SUCCESS;
83:
84: /**
85: * @see org.apache.lenya.cms.task.Task#getResult()
86: */
87: public int getResult() {
88: return this .result;
89: }
90:
91: /**
92: * Sets the result of this task.
93: * @param _result An integer ({@link Task#SUCCESS}, {@link Task#FAILURE}).
94: */
95: protected void setResult(int _result) {
96: this.result = _result;
97: }
98: }
|