Source Code Cross Referenced for MLetTag.java in  » JMX » mx4j » mx4j » loading » 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 » JMX » mx4j » mx4j.loading 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) The MX4J Contributors.
003:         * All rights reserved.
004:         *
005:         * This software is distributed under the terms of the MX4J License version 1.0.
006:         * See the terms of the MX4J License in the documentation provided with this software.
007:         */
008:
009:        package mx4j.loading;
010:
011:        import java.net.MalformedURLException;
012:        import java.net.URL;
013:        import java.util.ArrayList;
014:        import java.util.StringTokenizer;
015:        import javax.management.ObjectName;
016:
017:        /**
018:         * Represents an MLET tag, as documented in the JMX specification.
019:         *
020:         * @version $Revision: 1.6 $
021:         */
022:        public class MLetTag {
023:            private String code;
024:            private String object;
025:            private String archive;
026:            private String codebase;
027:            private ObjectName objectName;
028:            private String version;
029:            private ArrayList signature = new ArrayList();
030:            private ArrayList arguments = new ArrayList();
031:
032:            /**
033:             * Normalizes the codebase held by this MLetTag (specified in the MLet file) using the
034:             * URL of the MLet file as default.
035:             * This means that if the codebase in the MLet file is not provided or it is relative, then
036:             * the URL of the MLet file will be taken as base for computing the normalized codebase;
037:             * otherwise, if a full URL has been specified as codebase in the MLet file, that URL is taken
038:             * and the URL of the MLet file is discarded.
039:             *
040:             * @param mletFileURL The URL of the MLet file
041:             * @return The normalized codebase
042:             */
043:            public URL normalizeCodeBase(URL mletFileURL) {
044:                // If the codebase specified in the MLet file is relative, or null,
045:                // then the codebase is the one of the mletFileURL, otherwise
046:                // the given codebase must be used.
047:
048:                URL codebaseURL = null;
049:                String codebase = getCodeBase();
050:                if (codebase != null) {
051:                    // Try to see if it's a URL
052:                    try {
053:                        codebaseURL = new URL(codebase);
054:                    } catch (MalformedURLException ignored) {
055:                        // Not a complete URL, use the mletFileURL as a base
056:                        try {
057:                            codebaseURL = new URL(mletFileURL, codebase);
058:                        } catch (MalformedURLException alsoIgnored) {
059:                        }
060:                    }
061:                }
062:
063:                // Either codebase not provided or failed to be created, use the mletFileURL
064:                if (codebaseURL == null) {
065:                    String path = mletFileURL.getPath();
066:                    int index = path.lastIndexOf('/');
067:
068:                    try {
069:                        codebaseURL = new URL(mletFileURL, path.substring(0,
070:                                index + 1));
071:                    } catch (MalformedURLException ignored) {
072:                        // Cannot fail, we just remove the mlet file name from the path
073:                        // leaving the directory where it resides as a codebase
074:                    }
075:                }
076:                return codebaseURL;
077:            }
078:
079:            /**
080:             * Returns the jars file names specified in the ARCHIVE attribute of the MLet tag.
081:             */
082:            public String[] parseArchive() {
083:                String archive = getArchive();
084:                ArrayList archives = new ArrayList();
085:                StringTokenizer tokenizer = new StringTokenizer(archive, ",");
086:                while (tokenizer.hasMoreTokens()) {
087:                    String token = tokenizer.nextToken().trim();
088:                    if (token.length() > 0) {
089:                        token = token.replace('\\', '/');
090:                        archives.add(token);
091:                    }
092:                }
093:                return (String[]) archives.toArray(new String[0]);
094:            }
095:
096:            /**
097:             * Returns the URL for the given archive file name using the provided URL as a codebase,
098:             * or null if the URL cannot be created.
099:             */
100:            public URL createArchiveURL(URL codebase, String archive) {
101:                try {
102:                    return new URL(codebase, archive);
103:                } catch (MalformedURLException ignored) {
104:                }
105:                return null;
106:            }
107:
108:            public String getVersion() {
109:                return version;
110:            }
111:
112:            public String getCodeBase() {
113:                return codebase;
114:            }
115:
116:            public String getArchive() {
117:                return archive;
118:            }
119:
120:            public String getCode() {
121:                return code;
122:            }
123:
124:            public ObjectName getObjectName() {
125:                return objectName;
126:            }
127:
128:            public String getObject() {
129:                return object;
130:            }
131:
132:            public String[] getSignature() {
133:                return signature == null ? new String[0] : (String[]) signature
134:                        .toArray(new String[signature.size()]);
135:            }
136:
137:            public Object[] getArguments() {
138:                return arguments == null ? new Object[0] : (Object[]) arguments
139:                        .toArray(new Object[arguments.size()]);
140:            }
141:
142:            //
143:            // Setters, called by MLetParser
144:            //
145:
146:            void setArchive(String archive) {
147:                this .archive = archive;
148:            }
149:
150:            void setCode(String code) {
151:                this .code = code;
152:            }
153:
154:            void setCodeBase(String codebase) {
155:                // Important that the codebase ends with a slash, see usages of getCodeBase()
156:
157:                codebase = codebase.replace('\\', '/');
158:                if (!codebase.endsWith("/"))
159:                    codebase += "/";
160:                this .codebase = codebase;
161:            }
162:
163:            void setName(ObjectName name) {
164:                objectName = name;
165:            }
166:
167:            void setObject(String object) {
168:                this .object = object;
169:            }
170:
171:            void setVersion(String version) {
172:                this .version = version;
173:            }
174:
175:            void addArg(String type, Object value) {
176:                signature.add(type);
177:                arguments.add(value);
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.