Source Code Cross Referenced for WebModule.java in  » IDE-Netbeans » api » org » netbeans » modules » web » api » webmodule » 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 » IDE Netbeans » api » org.netbeans.modules.web.api.webmodule 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.web.api.webmodule;
043:
044:        import java.util.Iterator;
045:        import org.netbeans.modules.j2ee.dd.api.web.WebAppMetadata;
046:        import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel;
047:        import org.netbeans.modules.web.webmodule.WebModuleAccessor;
048:        import org.netbeans.modules.web.spi.webmodule.*;
049:        import org.openide.filesystems.FileObject;
050:        import org.openide.util.Lookup;
051:        import org.openide.util.Parameters;
052:
053:        /**
054:         * This class encapsulates a web module.
055:         * 
056:         * <p>A client may obtain a <code>WebModule</code> instance using
057:         * method {@link #getWebModule}, for any
058:         * {@link org.openide.filesystems.FileObject} in the web module directory structure.</p>
059:         * <div class="nonnormative">
060:         * <p>Use the classpath API to obtain the classpath for the document base (this classpath
061:         * is used for code completion of JSPs). An example:</p>
062:         * <pre>
063:         *     WebModule wm = ...;
064:         *     FileObject docRoot = wm.getDocumentBase ();
065:         *     ClassPath cp = ClassPath.getClassPath(docRoot, ClassPath.EXECUTE);
066:         * </pre>
067:         * <p>Note that no particular directory structure for web module is guaranteed 
068:         * by this API.</p>
069:         * </div>
070:         *
071:         * @author  Pavel Buzek
072:         */
073:        public final class WebModule {
074:
075:            public static final String J2EE_13_LEVEL = "1.3"; //NOI18N
076:            public static final String J2EE_14_LEVEL = "1.4"; //NOI18N
077:            public static final String JAVA_EE_5_LEVEL = "1.5"; //NOI18N
078:
079:            private final WebModuleImplementation impl;
080:            private static final Lookup.Result implementations = Lookup
081:                    .getDefault().lookupResult(WebModuleProvider.class);
082:
083:            static {
084:                WebModuleAccessor.DEFAULT = new WebModuleAccessor() {
085:                    public WebModule createWebModule(
086:                            WebModuleImplementation spiWebmodule) {
087:                        return new WebModule(spiWebmodule);
088:                    }
089:                };
090:            }
091:
092:            private WebModule(WebModuleImplementation impl) {
093:                Parameters.notNull("impl", impl); // NOI18N
094:                this .impl = impl;
095:            }
096:
097:            /**
098:             * Finds the web module that a given file belongs to. The given file should
099:             * be one known to be owned by a web module (e.g., it can be a file in a
100:             * Java source group, such as a servlet, or it can be a file in the document
101:             * base, such as a JSP page).
102:             *
103:             * @param  file the file to find the web module for; never null.
104:             * @return the web module this file belongs to or null if the file does not belong
105:             *         to any web module.
106:             * @throws NullPointerException if the <code>file</code> parameter is null.
107:             */
108:            public static WebModule getWebModule(FileObject file) {
109:                Parameters.notNull("file", file); // NOI18N
110:                Iterator it = implementations.allInstances().iterator();
111:                while (it.hasNext()) {
112:                    WebModuleProvider impl = (WebModuleProvider) it.next();
113:                    WebModule wm = impl.findWebModule(file);
114:                    if (wm != null) {
115:                        return wm;
116:                    }
117:                }
118:                return null;
119:            }
120:
121:            /**
122:             * Returns the folder that contains sources of the static documents for
123:             * the web module (html, JSPs, etc.).
124:             *
125:             * @return the static documents folder; can be null.
126:             */
127:            public FileObject getDocumentBase() {
128:                return impl.getDocumentBase();
129:            }
130:
131:            /**
132:             * Returns the WEB-INF folder for the web module.
133:             * It may return null for web module that does not have any WEB-INF folder.
134:             * <div class="nonnormative">
135:             * <p>The WEB-INF folder would typically be a child of the folder returned
136:             * by {@link #getDocumentBase} but does not need to be.</p>
137:             * </div>
138:             *
139:             * @return the WEB-INF folder; can be null.
140:             */
141:            public FileObject getWebInf() {
142:                return impl.getWebInf();
143:            }
144:
145:            /**
146:             * Returns the deployment descriptor (<code>web.xml</code> file) of the web module.
147:             * <div class="nonnormative">
148:             * The web.xml file would typically be a child of the folder returned
149:             * by {@link #getWebInf} but does not need to be.
150:             * </div>
151:             *
152:             * @return the <code>web.xml</code> file; can be null.
153:             */
154:            public FileObject getDeploymentDescriptor() {
155:                return impl.getDeploymentDescriptor();
156:            }
157:
158:            /**
159:             * Returns the context path of the web module.
160:             *
161:             * @return the context path; can be null.
162:             */
163:            public String getContextPath() {
164:                return impl.getContextPath();
165:            }
166:
167:            /**
168:             * Returns the J2EE platform version of this module. The returned value is
169:             * one of the constants {@link #J2EE_13_LEVEL}, {@link #J2EE_14_LEVEL} or 
170:             * {@link #JAVA_EE_5_LEVEL}.
171:             *
172:             * @return J2EE platform version; never null.
173:             */
174:            public String getJ2eePlatformVersion() {
175:                return impl.getJ2eePlatformVersion();
176:            }
177:
178:            /**
179:             * Returns the Java source roots associated with the web module.
180:             * <div class="nonnormative">
181:             * <p>Note that not all the java source roots in the project (e.g. in a freeform project)
182:             * belong to the web module.</p>
183:             * </div>
184:             *
185:             * @return this web module's Java source roots; never null.
186:             *
187:             * @deprecated This method is deprecated, because its return values does
188:             * not contain enough information about the source roots. Source roots
189:             * are usually implemented by a <code>org.netbeans.api.project.SourceGroup</code>,
190:             * which is more than just a container for a {@link org.openide.filesystems.FileObject}.
191:             */
192:            @Deprecated
193:            public FileObject[] getJavaSources() {
194:                return impl.getJavaSources();
195:            }
196:
197:            /**
198:             * Returns a model describing the metadata of this web module (servlets,
199:             * resources, etc.).
200:             *
201:             * @return this web module's metadata model; never null.
202:             */
203:            public MetadataModel<WebAppMetadata> getMetadataModel() {
204:                return impl.getMetadataModel();
205:            }
206:
207:            @Override
208:            public boolean equals(Object obj) {
209:                if (obj == null) {
210:                    return false;
211:                }
212:                if (!WebModule.class.isAssignableFrom(obj.getClass())) {
213:                    return false;
214:                }
215:                WebModule wm = (WebModule) obj;
216:                if (!getDocumentBase().equals(wm.getDocumentBase())) {
217:                    return false;
218:                }
219:                if (!getJ2eePlatformVersion().equals(
220:                        wm.getJ2eePlatformVersion())) {
221:                    return false;
222:                }
223:                String contextPath = getContextPath();
224:                String wmContextPath = wm.getContextPath();
225:                if (contextPath != null && wmContextPath != null) {
226:                    return contextPath.equals(wmContextPath);
227:                }
228:                return true;
229:            }
230:
231:            @Override
232:            public int hashCode() {
233:                int hashCode = getDocumentBase().getPath().hashCode();
234:                String contextPath = getContextPath();
235:                if (contextPath != null) {
236:                    hashCode += contextPath.hashCode();
237:                }
238:                return hashCode;
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.