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.jaxws.client; 21 22 import java.util.Iterator; 23 import org.netbeans.modules.websvc.jaxws.client.JAXWSClientViewAccessor; 24 import org.netbeans.modules.websvc.spi.jaxws.client.JAXWSClientViewImpl; 25 import org.netbeans.modules.websvc.spi.jaxws.client.JAXWSClientViewProvider; 26 import org.openide.util.Lookup; 27 import org.openide.nodes.Node; 28 import org.netbeans.api.project.Project; 29 30 /** JAXWSlientView should be used to display web service references in project. 31 * The wiew containes nodes representing web service references in project. 32 * <p> 33 * A client may obtain a JAXWClientView instance using 34 * <code>JAXWSClientView.getJAXWSClientView()</code> static 35 * method 36 * 37 * @author Peter Williams, Milan Kuchtiak 38 */ 39 public final class JAXWSClientView { 40 41 private JAXWSClientViewImpl impl; 42 private static final Lookup.Result implementations = 43 Lookup.getDefault().lookup(new Lookup.Template(JAXWSClientViewProvider.class)); 44 45 static { 46 JAXWSClientViewAccessor.DEFAULT = new JAXWSClientViewAccessor() { 47 public JAXWSClientView createJAXWSClientView(JAXWSClientViewImpl spiWebServicesClientView) { 48 return new JAXWSClientView(spiWebServicesClientView); 49 } 50 51 public JAXWSClientViewImpl getJAXWSClientViewImpl(JAXWSClientView wsv) { 52 return wsv == null ? null : wsv.impl; 53 } 54 }; 55 } 56 57 private JAXWSClientView(JAXWSClientViewImpl impl) { 58 if (impl == null) 59 throw new IllegalArgumentException (); 60 this.impl = impl; 61 } 62 63 /** Lookup the IDE and find JAXWSClientView instance 64 */ 65 public static JAXWSClientView getJAXWSClientView() { 66 Iterator it = implementations.allInstances().iterator(); 67 while (it.hasNext()) { 68 JAXWSClientViewProvider impl = (JAXWSClientViewProvider)it.next(); 69 JAXWSClientView wsv = impl.findJAXWSClientView (); 70 if (wsv != null) { 71 return wsv; 72 } 73 } 74 75 JAXWSClientViewProvider impl = (JAXWSClientViewProvider) Lookup.getDefault().lookup(JAXWSClientViewProvider.class); 76 if(impl != null) { 77 JAXWSClientView wsv = impl.findJAXWSClientView(); 78 return wsv; 79 } 80 return null; 81 } 82 83 // Delegated methods from WebServicesClientViewImpl 84 85 /** Create Node representing Web Service References for a given project 86 *@param project project containing web service references (WS Clients) 87 */ 88 public Node createJAXWSClientView(Project p) { 89 return impl.createJAXWSClientView(p); 90 } 91 92 }