01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package org.apache.tools.ant.taskdefs.optional.metaboss;
16:
17: import java.io.File;
18:
19: import javax.naming.Context;
20: import javax.naming.InitialContext;
21:
22: import org.apache.tools.ant.BuildException;
23:
24: import com.metaboss.sdlctools.applications.anttasks.MetaBossModelToolTask;
25: import com.metaboss.sdlctools.services.codegeneration.BSCoreCodeGenerator;
26:
27: /** Special Ant task used to invoke MetaBoss Enterprise Source Code Generator. */
28: public class SystemCoreGeneratorTask extends MetaBossModelToolTask {
29: private File mDestinationDir = null;
30: private String mRef = null;
31:
32: public SystemCoreGeneratorTask() {
33: // This task uses existing model
34: super (true);
35: }
36:
37: /** The setter for the "ref" attribute */
38: public void setRef(String pRef) {
39: mRef = pRef;
40: }
41:
42: // The getter for the "Ref" attribute. Passed to the destination application as an argument
43: protected String getRef() {
44: if (mRef == null)
45: throw new BuildException(
46: "Missing 'ref' attribute, which is mandatory for <"
47: + getTaskName() + "> task.");
48: return mRef;
49: }
50:
51: /** The setter for the "destinationdir" attribute */
52: public void setDestinationdir(File pDestinationDir) {
53: mDestinationDir = pDestinationDir;
54: }
55:
56: // The getter for the "destinationdir" attribute
57: protected File getDestinationdir() {
58: if (mDestinationDir == null)
59: throw new BuildException(
60: "Missing 'destinationdir' attribute, which is mandatory for <"
61: + getTaskName() + "> task.");
62: return mDestinationDir;
63: }
64:
65: // The method executing the tool
66: public void runTool() throws Exception {
67: // Get the domain and storage technology details
68: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) getModelElement(
69: getRef(),
70: new Class[] { com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System.class });
71: // Get the generator
72: Context ctx = new InitialContext();
73: BSCoreCodeGenerator lGenerator = (BSCoreCodeGenerator) ctx
74: .lookup(BSCoreCodeGenerator.COMPONENT_URL);
75: lGenerator.generateSourceCodeForSystem(getDestinationdir()
76: .getAbsolutePath(), getRef());
77: }
78: }
|