Source Code Cross Referenced for EsbPathHelper.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » common » util » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.common.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id$
023:         */
024:        package com.bostechcorp.cbesb.common.util;
025:
026:        import java.io.File;
027:        import java.io.IOException;
028:
029:        import org.apache.commons.lang.StringUtils;
030:        import org.apache.commons.logging.Log;
031:        import org.apache.commons.logging.LogFactory;
032:
033:        public class EsbPathHelper {
034:            private static final Log log = LogFactory
035:                    .getLog(EsbPathHelper.class);
036:
037:            protected static final String CBESB_HOME = "CBESB_HOME";
038:
039:            protected static final String CBESB_HOME_SYSPROP = "cbesb.home";
040:
041:            protected static String CBESB_UI_WS = "CBESB_UI_WS";
042:
043:            protected static String CBESB_UI_WS_SYSPROP = "cbesb.ui.ws";
044:
045:            protected static String CBESB_SERVER_MODE = "CBESB_SERVER_MODE";
046:
047:            protected static final String CBESB_SERVER_MODE_SYSPROP = "cbesb.server.mode";
048:
049:            protected static String basePackageName = "com.bostechcorp.cbesb.fsmparser";
050:
051:            protected static String mdlFolder = "src/formats/";
052:
053:            //alert monitor values
054:            protected static String ALERT_HOME = "ALERT_HOME";
055:            protected static String activatedAlertFolder = "activated";
056:
057:            public static String getCbesbUiWorkSpace() {
058:                String esbHome = getCbesbHomeDir();
059:
060:                String uiWorkspace = System.getenv(CBESB_UI_WS);
061:                String uiWorkspaceProp = System
062:                        .getProperty(CBESB_UI_WS_SYSPROP);
063:                if (uiWorkspaceProp != null)
064:                    uiWorkspace = uiWorkspaceProp;
065:
066:                if (uiWorkspace == null && esbHome != null) {
067:                    uiWorkspace = esbHome + File.separator + "ideworkspace";
068:                }
069:                File file = new File(uiWorkspace);
070:                try {
071:                    return file.getCanonicalPath();
072:                } catch (IOException e) {
073:                    log.error("get cbesb workspace dir error:", e);
074:                }
075:
076:                return uiWorkspace;
077:
078:            }
079:
080:            public static String getCbesbHomeDir() {
081:                String esbHome = System.getenv(CBESB_HOME);
082:                String esbHomeProp = System.getProperty(CBESB_HOME_SYSPROP);
083:
084:                // Always to use the -D option to overwrite the system enviroment
085:                if (esbHomeProp != null)
086:                    esbHome = esbHomeProp;
087:                File file = new File(esbHome);
088:                try {
089:                    return file.getCanonicalPath();
090:                } catch (IOException e) {
091:                    log.error("get cbesb home dir error:", e);
092:                }
093:
094:                return esbHome;
095:            }
096:
097:            public static String getFullPathForDef(String defStr) {
098:
099:                if (defStr.indexOf("::") == -1) {
100:                    // this is for Junit test case, read directly from local file system
101:                    return defStr;
102:                } else {
103:
104:                    //	defStr=MacroUtil.replaceBuiltinMacro(defStr);
105:
106:                    int index = defStr.lastIndexOf("::");
107:                    String substringAfter = defStr.substring(index + 2, defStr
108:                            .length());
109:                    // the MsgDef is in the format of "projName::src/formats/file.mdl"
110:
111:                    if (substringAfter.indexOf(":") > -1) {
112:                        substringAfter = StringUtils.substringBefore(
113:                                substringAfter, ":");
114:                    }
115:                    String projName = defStr.substring(0, index);
116:                    projName = handelProjectName(projName, "/");
117:
118:                    String uiWorkspace = getCbesbUiWorkSpace();
119:
120:                    return uiWorkspace + File.separator + projName
121:                            + File.separator + substringAfter;
122:
123:                }
124:
125:            }
126:
127:            /**
128:             * 
129:             * @param msgDefStr
130:             * @return   Array 0--fsmClassName, 1--messageName, 2--SA name
131:             * @throws Exception
132:             */
133:            public static String[] getFsmClassName(String msgDefStr)
134:                    throws Exception {
135:                String fsmClass = null;
136:                String messageName = null;
137:                String saName = null;
138:                int index = msgDefStr.lastIndexOf("::");
139:                if (index > -1) {
140:                    String substringAfter = msgDefStr.substring(index + 2,
141:                            msgDefStr.length());
142:                    // the MsgDef is in the format of "projName::src/formats/file.mdl"
143:
144:                    String projName = msgDefStr.substring(0, index);
145:                    int firstSep = projName.indexOf("::");
146:                    if (firstSep >= 0)
147:                        saName = projName.substring(0, firstSep);
148:                    else
149:                        saName = projName;
150:                    projName = handelProjectName(projName, ".");
151:
152:                    fsmClass = basePackageName + "." + projName;
153:
154:                    if (substringAfter.indexOf(":") > -1) {
155:                        String remainStr = StringUtils.substringBefore(
156:                                substringAfter, ":");
157:                        messageName = StringUtils.substringAfter(
158:                                substringAfter, ":");
159:
160:                        String packageName = StringUtils.substringBetween(
161:                                substringAfter, mdlFolder, ":");
162:                        String[] packages = StringUtils.split(packageName, "/");
163:                        for (int i = 0; i < packages.length - 1; i++) {
164:                            fsmClass = fsmClass + "." + packages[i];
165:                        }
166:                        String mdlFileName = StringUtils.substringBefore(
167:                                packages[packages.length - 1], ".");
168:
169:                        fsmClass = fsmClass + "." + mdlFileName + "."
170:                                + messageName + "." + messageName;
171:                    }
172:                }
173:
174:                String[] result = new String[] { fsmClass, messageName, saName };
175:                return result;
176:            }
177:
178:            public static String handelProjectName(String projName,
179:                    String delimiter) {
180:                if (projName.contains("::")) {
181:                    if (isServerMode())
182:                        projName = projName.replace("::", delimiter);
183:                    else
184:                        projName = StringUtils.substringAfter(projName, "::");
185:
186:                }
187:                return projName;
188:            }
189:
190:            public static String getTrnClassName(String trnName) {
191:                String fullName = trnName
192:                        .substring(0, trnName.lastIndexOf('.'));
193:                int lastColon = fullName.lastIndexOf("::");
194:                String projectSpecifier = fullName.substring(0, lastColon);
195:                if (projectSpecifier.indexOf("::") >= 0)
196:                    projectSpecifier = projectSpecifier
197:                            .substring(projectSpecifier.indexOf("::") + 2);
198:                String pathPart = fullName.substring(lastColon + 2);
199:                pathPart = pathPart.replace("src/xlate/", "");
200:                pathPart = pathPart.replace("/", ".");
201:                String className = "com.bostechcorp.cbesb.generated.map."
202:                        + projectSpecifier + "." + pathPart;
203:                return className;
204:            }
205:
206:            public static String getProjectName(String defName) {
207:                String projectName = defName
208:                        .substring(0, defName.indexOf("::"));
209:                return projectName;
210:            }
211:
212:            /**
213:             * 
214:             * @param msgDefStr  the MsgDef is in the format of "projName::v004010/variant/m270"
215:             * @return Array 0--projectName
216:             * 				1--	x12 xersion
217:             *              2--variant
218:             *              3--message
219:             *              4--service assembly name
220:             *        ProjectName: if the msgDefStr contains ESB project Name, 
221:             *        	the return projectName like JSAProjName/ESBProjName
222:             */
223:            public static String[] getVariantMessage(String msgDefStr) {
224:                String remainStr = msgDefStr;
225:                String projName = "";
226:                String saName = "";
227:                int firstColons = msgDefStr.indexOf("::");
228:                if (firstColons > -1) {
229:                    saName = msgDefStr.substring(0, firstColons);
230:                    int index = msgDefStr.lastIndexOf("::");
231:                    remainStr = msgDefStr.substring(index + 2, msgDefStr
232:                            .length());
233:                    if (remainStr.indexOf(":") > -1) {
234:                        remainStr = StringUtils.substringBefore(remainStr, ":");
235:                    }
236:                    projName = msgDefStr.substring(0, index);
237:                    projName = handelProjectName(projName, "/");
238:
239:                }
240:
241:                String[] msgDefs = remainStr.split("/");
242:                if (msgDefs[2].endsWith(".mdl")) {
243:                    msgDefs[2] = msgDefs[2].substring(0, msgDefs[2]
244:                            .lastIndexOf(".mdl"));
245:                }
246:                String[] result = new String[] { projName, msgDefs[0],
247:                        msgDefs[1], msgDefs[2], saName };
248:                return result;
249:
250:            }
251:
252:            public static boolean isServerMode() {
253:                String serverMode = System.getenv(CBESB_SERVER_MODE);
254:                String sysServerMode = System
255:                        .getProperty(CBESB_SERVER_MODE_SYSPROP);
256:                if (sysServerMode != null)
257:                    serverMode = sysServerMode;
258:                log.debug("ESB server mode:" + serverMode);
259:
260:                if (serverMode != null && serverMode.equalsIgnoreCase("true")) {
261:                    return true;
262:                } else
263:                    return false;
264:            }
265:
266:            //	public static String getAertHome()
267:            //	{
268:            //		return System.getenv(ALERT_HOME);
269:            //	}
270:            //	
271:            //	public static String getActivatedAlertFolder()
272:            //	{
273:            //		return getAertHome()+"/"+activatedAlertFolder;
274:            //	}
275:
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.