KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > jbuilder > build > DeployBuilder


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  */

22 package org.enhydra.kelp.jbuilder.build;
23
24 // ToolBox imports
25
import org.enhydra.tool.common.ToolException;
26
27 // JBuilder imports
28
import com.borland.primetime.node.TextFileNode;
29 import com.borland.primetime.node.FileNode;
30 import com.borland.primetime.node.Node;
31 import com.borland.primetime.node.Project;
32 import com.borland.primetime.build.Builder;
33 import com.borland.primetime.build.BuildProcess;
34 import com.borland.primetime.build.BuilderManager;
35
36
37 // Kelp imports
38
import org.enhydra.kelp.KelpInfo;
39 import org.enhydra.kelp.common.PathUtil;
40 import org.enhydra.kelp.common.PropUtil;
41 import org.enhydra.kelp.common.node.OtterTextFileNode;
42 import org.enhydra.kelp.common.node.OtterTemplateNode;
43 import org.enhydra.kelp.jbuilder.node.PrimeTemplateNode;
44 import org.enhydra.kelp.jbuilder.node.PrimeTextFileNode;
45 import org.enhydra.kelp.jbuilder.properties.DeployProperties;
46
47
48 /**
49  * This class controls building and maintaining properties for HTML/XML files
50  * using the Enhydra XMLC Compiler.
51  *
52  */

53 public class DeployBuilder implements Builder {
54
55
56     public DeployBuilder() {}
57
58     /**
59      * Register open tool
60      *
61      */

62     public static void initOpenTool(byte majorVersion, byte minorVersion) {
63
64         if (KelpInfo.isClassPathComplete()) {
65             BuilderManager.registerBuilder(new DeployBuilder());
66         }
67     }
68
69     /**
70      * Called by the Build System when make or rebuild occurs
71      */

72     public void updateBuildProcess(BuildProcess buildProcess,
73                                    Node nativeNode) {
74
75         DeployBuildTask task = null;
76         TextFileNode nativeTextNode = null;
77         OtterTemplateNode otterTemplateNode = null;
78         OtterTextFileNode otterTextNode = null;
79         String JavaDoc stringIn = null;
80         boolean selected = false;
81         if (nativeNode instanceof Project) {
82             task = findTask(buildProcess);
83             task.setNodeOnly(false);
84
85         } else if (nativeNode instanceof TextFileNode) {
86             nativeTextNode = (TextFileNode) nativeNode;
87             otterTextNode = new PrimeTextFileNode(nativeTextNode);
88             if (PathUtil.isTemplate(otterTextNode)) {
89                try {
90                  otterTemplateNode = new PrimeTemplateNode(nativeTextNode);
91               } catch (ToolException e) {
92                 e.printStackTrace();
93               }
94             }
95         }
96         if (otterTemplateNode != null && otterTemplateNode.isSelected()) {
97             task = findTask(buildProcess);
98             task.addNode(otterTemplateNode);
99         }
100     }
101
102     private DeployBuildTask findTask(BuildProcess buildProcess) {
103       DeployBuildTask task = null;
104       task = (DeployBuildTask) buildProcess.getTask(DeployBuildTask.SHARED_KEY);
105       if (task == null) {
106          task = new DeployBuildTask();
107          // There is both a map and a list
108
buildProcess.putTask(DeployBuildTask.SHARED_KEY, task);
109           buildProcess.getBuildTaskList().add(task);
110       }
111       return task;
112     }
113 }
114
Popular Tags