Source Code Cross Referenced for Util.java in  » ESB » open-esb » com » sun » jbi » management » system » 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 » open esb » com.sun.jbi.management.system 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)Util.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        /**
030:         *  Util.java
031:         *
032:         *  SUN PROPRIETARY/CONFIDENTIAL.
033:         *  This software is the proprietary information of Sun Microsystems, Inc.
034:         *  Use is subject to license terms.
035:         *
036:         *  Created on December 17, 2004, 2:26 PM
037:         */package com.sun.jbi.management.system;
038:
039:        import java.io.File;
040:        import java.util.Properties;
041:        import java.util.HashMap;
042:
043:        import com.sun.jbi.management.registry.Registry;
044:        import com.sun.jbi.management.registry.RegistryBuilder;
045:        import com.sun.jbi.management.registry.RegistryType;
046:        import com.sun.jbi.management.registry.RegistrySpecImpl;
047:        import com.sun.jbi.management.registry.xml.RegistryImpl;
048:        import com.sun.jbi.management.repository.Repository;
049:
050:        /**
051:         *
052:         * @author Sun Microsystems, Inc.
053:         */
054:        public class Util {
055:
056:            /**
057:             * @param packageName is the pkgname.
058:             * @return  a String Translator. 
059:             */
060:            public static com.sun.jbi.StringTranslator getStringTranslator(
061:                    String packageName) {
062:                Class clazz;
063:                java.lang.reflect.Constructor ctor;
064:                try {
065:                    clazz = Class
066:                            .forName("com.sun.jbi.management.StringTranslator");
067:                    ctor = clazz.getDeclaredConstructors()[0];
068:                    ctor.setAccessible(true);
069:                    return (com.sun.jbi.StringTranslator) ctor
070:                            .newInstance(new Object[] { packageName, null });
071:                    //this.getClass().getClassLoader()});
072:                } catch (Exception ex) {
073:                    ex.printStackTrace();
074:                    return null;
075:                }
076:
077:            }
078:
079:            /**
080:             * Make a copy of the source file in the destination file.
081:             * @return true if the operation was a success, false otherwise
082:             */
083:            public static boolean fileCopy(String source, String destination)
084:                    throws java.io.IOException {
085:                File sourceFile = new File(source);
086:                File destFile = new File(destination);
087:
088:                if (!destFile.exists()) {
089:                    int len = (int) sourceFile.length();
090:                    byte[] buf = new byte[len];
091:                    java.io.FileInputStream fis = new java.io.FileInputStream(
092:                            sourceFile);
093:                    fis.read(buf, 0, len);
094:                    if (fis != null) {
095:                        fis.close();
096:                    }
097:
098:                    java.io.FileOutputStream fos = new java.io.FileOutputStream(
099:                            destFile);
100:                    fos.write(buf, 0, len);
101:                    if (fos != null) {
102:                        fos.flush();
103:                        fos.close();
104:                    }
105:                    return true;
106:                } else {
107:                    return false;
108:                }
109:            }
110:
111:            /**
112:             * Create a Registry Instance.
113:             *
114:             * @return a Registry Instance
115:             * @throws Exception if an unexpected error occurs
116:             */
117:            public static Registry createRegistry() throws Exception {
118:                return createRegistry(getRegistryDirPath(), false);
119:            }
120:
121:            /**
122:             * Create a Registry Instance.
123:             *
124:             * @return a Registry Instance
125:             * @throws Exception if an unexpected error occurs
126:             */
127:            public static Registry createRegistry(boolean readOnly)
128:                    throws Exception {
129:                return createRegistry(getRegistryDirPath(), readOnly);
130:            }
131:
132:            /**
133:             * Create a Registry Instance.
134:             *
135:             * @return a Registry Instance
136:             * @throws Exception if an unexpected error occurs
137:             */
138:            public static Registry createRegistry(String regFolder)
139:                    throws Exception {
140:                return createRegistry(regFolder, false);
141:            }
142:
143:            /**
144:             * Create a Registry Instance.
145:             *
146:             * @return a Registry Instance
147:             * @throws Exception if an unexpected error occurs
148:             */
149:            public static Registry createRegistry(String regFolder,
150:                    boolean readOnly) throws Exception {
151:                try {
152:
153:                    // -- Create a XML Registry Spec.
154:                    Properties props = new Properties();
155:                    props.setProperty(Registry.REGISTRY_FOLDER_PROPERTY,
156:                            regFolder);
157:                    if (readOnly) {
158:                        props.setProperty(Registry.REGISTRY_READONLY_PROPERTY,
159:                                Boolean.toString(readOnly));
160:                    }
161:                    props.setProperty(Registry.REGISTRY_LOCK_INTERVAL_PROPERTY,
162:                            "120");
163:                    return RegistryBuilder
164:                            .buildRegistry(new RegistrySpecImpl(
165:                                    RegistryType.XML, props,
166:                                    createManagementContext()));
167:                } catch (Exception aEx) {
168:                    aEx.printStackTrace();
169:                    throw aEx;
170:                }
171:            }
172:
173:            /**
174:             * @return the path to the Registry Folder
175:             */
176:            public static String getRegistryDirPath() {
177:                String srcroot = System.getProperty("junit.srcroot");
178:
179:                java.io.File f = new java.io.File(srcroot + "/runtime/manage");
180:                if (!f.exists()) {
181:                    // -- mainline/whitney build
182:                    return srcroot + "/shasta/manage/bld/regress/testdata";
183:                } else {
184:                    // -- open-esb build
185:                    return srcroot
186:                            + "/runtime/manage/bld/test-classes/testdata";
187:                }
188:            }
189:
190:            public static ManagementContext createManagementContext()
191:                    throws Exception {
192:                ScaffoldEnvironmentContext envCtx = new ScaffoldEnvironmentContext();
193:                com.sun.jbi.util.EnvironmentAccess.setContext(envCtx);
194:                String testPath = System.getProperty("junit.srcroot")
195:                        + "/runtime/manage/bld/";
196:                envCtx.setJbiInstanceRoot(testPath);
197:                envCtx.setAppServerInstanceRoot(testPath);
198:                envCtx.setJbiInstallRoot(System.getProperty("junit.as8base")
199:                        + "/jbi");
200:                ManagementContext ctx = new ManagementContext(envCtx);
201:                Repository repository = new Repository(ctx);
202:
203:                ctx.setRepository(repository);
204:
205:                return ctx;
206:
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.