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;
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: import org.apache.tools.ant.types.Path;
23:
24: import com.metaboss.sdlctools.models.ModelRepository;
25:
26: /** Static toolbox with a number of Ant specific MetaBoss utilities. */
27: public class AntMetaBossUtils {
28: // The model repository
29: private static ModelRepository mModelRepository = null;
30:
31: /** The getter for the ModelRepository. */
32: public static ModelRepository getModelRepository()
33: throws BuildException {
34: if (mModelRepository == null) {
35: try {
36: Context lContext = new InitialContext();
37: mModelRepository = (ModelRepository) lContext
38: .lookup(ModelRepository.COMPONENT_URL);
39: } catch (NamingException e) {
40: throw new BuildException(
41: "Unable to connect to model repository. Caught javax.naming.NamingException :"
42: + e.getMessage());
43: }
44: }
45: return mModelRepository;
46: }
47:
48: /** This method fixes the fact that the ant's Path object does not overload equals operator */
49: public static boolean pathEquals(Path pFirstPath, Path pSecondPath) {
50: // Do it the easy way first
51: if (pFirstPath == null && pSecondPath == null)
52: return true;
53: if (pFirstPath == null || pSecondPath == null)
54: return false;
55: if (pFirstPath.equals(pSecondPath))
56: return true;
57: // Path object are not equal - we should try them one more chance
58: return pFirstPath.toString().equals(pSecondPath.toString());
59: }
60: }
|