KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > api > webservices > WebServicesView


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.api.webservices;
21
22 import java.util.Iterator JavaDoc;
23 import org.netbeans.modules.websvc.webservices.WebServicesViewAccessor;
24 import org.netbeans.modules.websvc.spi.webservices.*;
25 import org.openide.filesystems.FileObject;
26 import org.openide.util.Lookup;
27 import org.openide.nodes.Node;
28 import org.netbeans.api.project.Project;
29
30 /** WebServicesView should be used to retrieve information and display objects
31  * for the webservices in a project.
32  * <p>
33  * A client may obtain a WebServicesView instance using
34  * <code>WebServicesView.getWebServicesView(fileObject)</code> static
35  * method, for any FileObject in the project directory structure.
36  *
37  * @author Peter Williams
38  */

39 public final class WebServicesView {
40     
41     private WebServicesViewImpl impl;
42     private static final Lookup.Result implementations =
43         Lookup.getDefault().lookup(new Lookup.Template(WebServicesViewProvider.class));
44     
45     static {
46         WebServicesViewAccessor.DEFAULT = new WebServicesViewAccessor() {
47             public WebServicesView createWebServicesView(WebServicesViewImpl spiWebServicesView) {
48                 return new WebServicesView(spiWebServicesView);
49             }
50
51             public WebServicesViewImpl getWebServicesViewImpl(WebServicesView wsv) {
52                 return wsv == null ? null : wsv.impl;
53             }
54         };
55     }
56     
57     private WebServicesView(WebServicesViewImpl impl) {
58         if (impl == null)
59             throw new IllegalArgumentException JavaDoc ();
60         this.impl = impl;
61     }
62     
63     /** Find the WebServicesView for given file or null if the file does not belong
64      * to any module support web services.
65      */

66     public static WebServicesView getWebServicesView(FileObject f) {
67         if (f != null) {
68            Iterator JavaDoc it = implementations.allInstances().iterator();
69            while (it.hasNext()) {
70               WebServicesViewProvider impl = (WebServicesViewProvider)it.next();
71               WebServicesView wsv = impl.findWebServicesView (f);
72               if (wsv != null) {
73                 return wsv;
74               }
75            }
76         }
77         return null;
78     }
79
80     // Delegated methods from WebServicesViewImpl
81

82     public Node createWebServicesView(FileObject srcRoot) {
83         return impl.createWebServicesView(srcRoot);
84     }
85     
86     
87     
88 /* !! What to put here?
89  *
90     public boolean equals (Object obj) {
91         if (!WebModule.class.isAssignableFrom(obj.getClass()))
92             return false;
93         WebModule wm = (WebModule) obj;
94         return getDocumentBase().equals(wm.getDocumentBase())
95             && getJ2eePlatformVersion().equals (wm.getJ2eePlatformVersion())
96             && getContextPath().equals(wm.getContextPath());
97     }
98     
99     public int hashCode () {
100         return getDocumentBase ().getPath ().length () + getContextPath ().length ();
101     }
102  */

103 }
104
Popular Tags