01: /*
02: * ========================================================================
03: *
04: * Copyright 2004 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: * ========================================================================
19: */
20: package org.apache.cactus.integration.ant.util;
21:
22: import org.apache.tools.ant.Location;
23: import org.apache.tools.ant.Project;
24: import org.apache.tools.ant.Target;
25: import org.apache.tools.ant.Task;
26:
27: /**
28: * Default {@link AntTaskFactory} for creating Ant tasks.
29: *
30: * @version $Id: DefaultAntTaskFactory.java 239003 2004-05-31 20:05:27Z vmassol $
31: */
32: public class DefaultAntTaskFactory implements AntTaskFactory {
33: /**
34: * The current {@link Project} being executed.
35: */
36: private Project currentProject;
37:
38: /**
39: * The current Ant task being executed.
40: */
41: private String currentTaskName;
42:
43: /**
44: * The current {@link Location} of the Task being executed.
45: */
46: private Location currentLocation;
47:
48: /**
49: * The current {@link Target} being executed.
50: */
51: private Target currentOwningTarget;
52:
53: /**
54: * @param theProject the current project
55: * @param theCurrentTaskName the current Ant task name
56: * @param theCurrentLocation the current task location
57: * @param theCurrentTarget the current target being executed
58: */
59: public DefaultAntTaskFactory(Project theProject,
60: String theCurrentTaskName, Location theCurrentLocation,
61: Target theCurrentTarget) {
62: this .currentProject = theProject;
63: this .currentTaskName = theCurrentTaskName;
64: this .currentLocation = theCurrentLocation;
65: this .currentOwningTarget = theCurrentTarget;
66: }
67:
68: /**
69: * @see AntTaskFactory#createTask(String)
70: */
71: public Task createTask(String theName) {
72: Task retVal = this.currentProject.createTask(theName);
73: if (retVal != null) {
74: retVal.setTaskName(this.currentTaskName);
75: retVal.setLocation(this.currentLocation);
76: retVal.setOwningTarget(this.currentOwningTarget);
77: }
78: return retVal;
79: }
80: }
|