KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > ant > Command


1 package org.apache.ojb.broker.ant;
2
3 /* Copyright 1999-2005 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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 import org.apache.ddlutils.Platform;
19 import org.apache.ddlutils.model.Database;
20 import org.apache.ojb.broker.metadata.DescriptorRepository;
21 import org.apache.tools.ant.BuildException;
22 import org.apache.tools.ant.Task;
23
24 /**
25  * Base class for commands that work with a database and repository model.
26  *
27  * @author Thomas Dudziak
28  * @version $Revision: 1.1.2.2 $
29  */

30 public abstract class Command
31 {
32     /** The platform. */
33     private Platform _platform;
34     /** Whether to stop execution upon an error. */
35     private boolean _failOnError = true;
36
37     /**
38      * Returns the database type.
39      *
40      * @return The database type
41      */

42     protected String JavaDoc getDatabaseType()
43     {
44         return _platform.getName();
45     }
46
47     /**
48      * Sets the platform.
49      *
50      * @param platform The platform
51      */

52     protected void setPlatform(Platform platform)
53     {
54         _platform = platform;
55     }
56
57     /**
58      * Determines whether the command execution will be stopped upon an error.
59      * Default value is <code>true</code>.
60      *
61      * @return <code>true</code> if the execution stops in case of an error
62      */

63     public boolean isFailOnError()
64     {
65         return _failOnError;
66     }
67
68     /**
69      * Specifies whether the command execution will be stopped upon an error.
70      *
71      * @param failOnError <code>true</code> if the execution stops in case of an error
72      */

73     public void setFailOnError(boolean failOnError)
74     {
75         _failOnError = failOnError;
76     }
77
78     /**
79      * Creates the platform for the configured database.
80      *
81      * @return The platform
82      */

83     protected Platform getPlatform() throws BuildException
84     {
85         return _platform;
86     }
87
88     /**
89      * Executes this command.
90      *
91      * @param task The executing task
92      * @param dbModel The database model
93      * @param objModel The object model
94      */

95     public abstract void execute(Task task, Database dbModel, DescriptorRepository objModel) throws BuildException;
96 }
97
Popular Tags