Source Code Cross Referenced for ApplicationUtils.java in  » UML » MetaBoss » com » metaboss » sdlctools » applications » cmdlinetools » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » MetaBoss » com.metaboss.sdlctools.applications.cmdlinetools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.sdlctools.applications.cmdlinetools;
016:
017:        import java.io.File;
018:        import java.util.ArrayList;
019:        import java.util.Iterator;
020:
021:        import javax.naming.Context;
022:        import javax.naming.InitialContext;
023:        import javax.naming.NamingException;
024:
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:        import org.apache.log4j.PropertyConfigurator;
028:
029:        import com.metaboss.enterprise.BaseException;
030:        import com.metaboss.enterprise.bs.BSDomainObjectInvocationException;
031:        import com.metaboss.enterprise.bs.BSException;
032:        import com.metaboss.enterprise.bs.BSIllegalArgumentException;
033:        import com.metaboss.enterprise.bs.BSNamingAndDirectoryServiceInvocationException;
034:        import com.metaboss.sdlctools.models.ModelRepository;
035:        import com.metaboss.sdlctools.models.ModelRepositoryException;
036:        import com.metaboss.sdlctools.models.ModelValidationException;
037:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
038:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
039:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
040:        import com.metaboss.util.MetaBossSpecificUtils;
041:
042:        class ApplicationUtils {
043:            // Commons Logging instance.
044:            private static Log sLogger = null;
045:
046:            static void initialiseApplication() throws BSException {
047:                try {
048:                    // Read metaboss installation specific properties
049:                    MetaBossSpecificUtils.setupSystemProperties();
050:                    // Configure logger as early as possible, but after we have read property files
051:                    PropertyConfigurator.configure(System.getProperties());
052:                    // Now we can initialise logger
053:                    sLogger = LogFactory.getLog(ApplicationUtils.class);
054:                    // Load the model from "MetaBoss.ModelDir"
055:                    String lEnterpriseModelDir = System
056:                            .getProperty("MetaBoss.ModelDir");
057:                    if (lEnterpriseModelDir == null
058:                            || lEnterpriseModelDir.length() == 0)
059:                        throw new BSIllegalArgumentException(
060:                                "MetaBoss.ModelDir java system property must be defined. It must point to the top level directory of the enterprise model.");
061:                    File lModelDir = new File(lEnterpriseModelDir)
062:                            .getAbsoluteFile();
063:                    File lModelFile = new File(lEnterpriseModelDir
064:                            + File.separator + "Model.xml").getAbsoluteFile();
065:                    String lModelName = lModelFile.getAbsolutePath();
066:                    sLogger.info("Loading MetaBossEnterpriseModel from "
067:                            + lModelDir.getAbsolutePath() + " file.");
068:                    Context lContext = new InitialContext();
069:                    ModelRepository lModelRepository = (ModelRepository) lContext
070:                            .lookup(ModelRepository.COMPONENT_URL);
071:                    lModelRepository.openModel(lModelName, lModelFile,
072:                            "MetaBossMetaModel");
073:                    lModelRepository.setDefaultModel(lModelName);
074:                    sLogger
075:                            .info("Successfully loaded MetaBossEnterpriseModel from "
076:                                    + lModelDir.getAbsolutePath() + " file.");
077:                } catch (NamingException e) {
078:                    throw new BSNamingAndDirectoryServiceInvocationException(
079:                            "Unable to locate model repository implementation",
080:                            e);
081:                } catch (ModelRepositoryException e) {
082:                    throw new BSDomainObjectInvocationException(
083:                            "Unable to open enterprise model", e);
084:                }
085:            }
086:
087:            // Helper. Gets array of all refs of all services for the enterprise    
088:            static String[] getAllServiceRefs(Enterprise pEnterprise)
089:                    throws Exception {
090:                ArrayList lServiceRefs = new ArrayList();
091:                Iterator lSystemsIter = pEnterprise.getSystems().iterator();
092:                while (lSystemsIter.hasNext()) {
093:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) lSystemsIter
094:                            .next();
095:                    Iterator lServicemodulesIter = lSystem.getServicemodules()
096:                            .iterator();
097:                    while (lServicemodulesIter.hasNext()) {
098:                        Servicemodule lServicemodule = (Servicemodule) lServicemodulesIter
099:                                .next();
100:                        Iterator lServicesIter = lServicemodule.getServices()
101:                                .iterator();
102:                        while (lServicesIter.hasNext()) {
103:                            Service lService = (Service) lServicesIter.next();
104:                            lServiceRefs.add(lService.getRef());
105:                        }
106:                    }
107:                }
108:                return (String[]) lServiceRefs.toArray(new String[lServiceRefs
109:                        .size()]);
110:            }
111:
112:            // Helper. Gets array of all refs of all services for the system    
113:            static String[] getAllServiceRefs(
114:                    com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System pSystem)
115:                    throws Exception {
116:                ArrayList lServiceRefs = new ArrayList();
117:                Iterator lServicemodulesIter = pSystem.getServicemodules()
118:                        .iterator();
119:                while (lServicemodulesIter.hasNext()) {
120:                    Servicemodule lServicemodule = (Servicemodule) lServicemodulesIter
121:                            .next();
122:                    Iterator lServicesIter = lServicemodule.getServices()
123:                            .iterator();
124:                    while (lServicesIter.hasNext()) {
125:                        Service lService = (Service) lServicesIter.next();
126:                        lServiceRefs.add(lService.getRef());
127:                    }
128:                }
129:                return (String[]) lServiceRefs.toArray(new String[lServiceRefs
130:                        .size()]);
131:            }
132:
133:            // Helper. Gets array of all refs of all services for the servicemodule    
134:            static String[] getAllServiceRefs(Servicemodule pServicemodule)
135:                    throws Exception {
136:                ArrayList lServiceRefs = new ArrayList();
137:                Iterator lServicesIter = pServicemodule.getServices()
138:                        .iterator();
139:                while (lServicesIter.hasNext()) {
140:                    Service lService = (Service) lServicesIter.next();
141:                    lServiceRefs.add(lService.getRef());
142:                }
143:                return (String[]) lServiceRefs.toArray(new String[lServiceRefs
144:                        .size()]);
145:            }
146:
147:            // This helper must be called from all tools when exception has been caught
148:            // it will print the exception in the best possible manner
149:            static void handleException(Throwable pThrowable) {
150:                System.out.println("Caught exception "
151:                        + pThrowable.getClass().getName());
152:                if (pThrowable instanceof  BaseException) {
153:                    pThrowable.printStackTrace(System.out);
154:                    Throwable t = pThrowable.getCause();
155:                    while (t != null) {
156:                        System.out.println();
157:                        System.out.println();
158:                        System.out.println("Cause : " + t.getClass().getName());
159:                        t.printStackTrace(System.out);
160:                        // Special case for model validation exception - it has explanation
161:                        if (t instanceof  ModelValidationException) {
162:                            System.out.println(((ModelValidationException) t)
163:                                    .getFullExplanation());
164:                            break;
165:                        } else if (t instanceof  BaseException) {
166:                            t = ((BaseException) t).getCause();
167:                        } else
168:                            break;
169:                    }
170:                } else {
171:                    System.out.println(pThrowable.getMessage());
172:                    pThrowable.printStackTrace(System.out);
173:                }
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.