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 com.metaboss.sdlctools.applications.anttasks.builder.tools;
16:
17: import javax.naming.Context;
18: import javax.naming.InitialContext;
19: import javax.naming.NamingException;
20:
21: import org.apache.tools.ant.BuildException;
22:
23: import com.metaboss.enterprise.bs.BSException;
24: import com.metaboss.sdlctools.applications.anttasks.builder.MetaBossBuilderTask;
25: import com.metaboss.sdlctools.applications.anttasks.builder.ToolInvocationDefinition;
26: import com.metaboss.sdlctools.services.codegeneration.BSDomainSupportServicesImplementationGenerator;
27:
28: /** This definition is responsible for invocation of the DomainSupport generator */
29: public class DomainSupportGeneratorInvocationDefinition extends
30: ToolInvocationDefinition {
31: private String mRef = null;
32:
33: /** Public constructor for the invocation */
34: public DomainSupportGeneratorInvocationDefinition(
35: MetaBossBuilderTask pOwnerTask) {
36: super (pOwnerTask,
37: "Generate support service implementation for domain");
38: }
39:
40: // Override to return better description if possible
41: public String getToolInvocationName() {
42: if (mRef == null)
43: return super .getToolInvocationName();
44: return "Generate support service implementation for "
45: + getRef() + " domain";
46: }
47:
48: /** Setter for the ref attribute */
49: public void setRef(String pRef) {
50: mRef = pRef;
51: }
52:
53: /** Getter for the ref attribute */
54: public String getRef() {
55: if (mRef == null)
56: throw new BuildException(
57: "Missing 'ref' attribute, which is mandatory for generator invocation.");
58: return mRef;
59: }
60:
61: /** Overridden to compare details of the invocation */
62: public boolean equals(Object pOther) {
63: if (this == pOther)
64: return true;
65: if (pOther instanceof DomainSupportGeneratorInvocationDefinition) {
66: DomainSupportGeneratorInvocationDefinition lOther = (DomainSupportGeneratorInvocationDefinition) pOther;
67: if (getRef().equals(lOther.getRef()))
68: return true;
69: }
70: return false;
71: }
72:
73: /** This method will have to invoke the generator */
74: public void invoke() throws BuildException {
75: // Run inprocess
76: try {
77: Context lContext = new InitialContext();
78: BSDomainSupportServicesImplementationGenerator lGenerator = (BSDomainSupportServicesImplementationGenerator) lContext
79: .lookup(BSDomainSupportServicesImplementationGenerator.COMPONENT_URL);
80: lGenerator.generateSourceCodeForDomain(getOwnerTask()
81: .getGenDir().getAbsolutePath(), getRef());
82: } catch (NamingException e) {
83: throw new BuildException(
84: "Unable to locate generator for the Domain Support Implementation. Caught NamingException: "
85: + e.getMessage());
86: } catch (BSException e) {
87: throw new BuildException(
88: "Unable to run generator for the Domain Support Implementation. Caught BSException: "
89: + e.getMessage());
90: }
91: }
92: }
|