KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > core > jaxws > nodes > JaxWsChildren


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 package org.netbeans.modules.websvc.core.jaxws.nodes;
20
21 import java.io.File JavaDoc;
22 import java.net.URI JavaDoc;
23 import java.net.URISyntaxException JavaDoc;
24 import java.net.URL JavaDoc;
25 import java.net.UnknownHostException JavaDoc;
26 import java.util.*;
27 import java.util.Set JavaDoc;
28 import javax.lang.model.element.AnnotationMirror;
29 import javax.lang.model.element.Element;
30 import javax.lang.model.element.ExecutableElement;
31 import javax.lang.model.element.Modifier;
32 import javax.lang.model.element.TypeElement;
33 import javax.lang.model.util.ElementFilter;
34 import javax.swing.SwingUtilities JavaDoc;
35 import javax.xml.parsers.ParserConfigurationException JavaDoc;
36 import javax.xml.transform.stream.StreamSource JavaDoc;
37 import org.apache.tools.ant.module.api.support.ActionUtils;
38 import org.netbeans.api.java.source.CancellableTask;
39 import org.netbeans.api.java.source.CompilationController;
40 import org.netbeans.api.java.source.JavaSource;
41 import org.openide.nodes.AbstractNode;
42 import static org.netbeans.api.java.source.JavaSource.Phase;
43 import org.netbeans.api.project.FileOwnerQuery;
44 import org.netbeans.api.project.Project;
45 import org.netbeans.modules.j2ee.common.source.SourceUtils;
46 import org.netbeans.modules.websvc.api.jaxws.project.GeneratedFilesHelper;
47 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel;
48 import org.netbeans.modules.websvc.core.JaxWsUtils;
49 import org.netbeans.modules.websvc.jaxws.api.JAXWSSupport;
50 import org.netbeans.modules.websvc.api.jaxws.project.config.Service;
51 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModel;
52 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModelListener;
53 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModeler;
54 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModelerFactory;
55 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlOperation;
56 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlPort;
57 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlService;
58 import org.netbeans.modules.websvc.api.jaxws.project.WSUtils;
59 import org.netbeans.modules.websvc.jaxws.api.WsdlWrapperGenerator;
60 import org.netbeans.modules.websvc.jaxws.api.WsdlWrapperHandler;
61 import org.openide.DialogDisplayer;
62 import org.openide.ErrorManager;
63 import org.openide.execution.ExecutorTask;
64 import org.openide.filesystems.FileLock;
65 import org.openide.filesystems.FileObject;
66 import org.openide.filesystems.FileStateInvalidException;
67 import org.openide.filesystems.FileUtil;
68 import org.openide.nodes.Children;
69 import org.openide.nodes.Node;
70 import org.openide.util.NbBundle;
71 import java.io.IOException JavaDoc;
72 import org.netbeans.modules.websvc.api.jaxws.project.config.Binding;
73 import org.xml.sax.SAXException JavaDoc;
74
75 /*
76  * Children of the web service node, namely,
77  * the operations of the webservice
78  */

79
80 public class JaxWsChildren extends Children.Keys/* implements MDRChangeListener */{
81     private static final java.awt.Image JavaDoc OPERATION_BADGE =
82         org.openide.util.Utilities.loadImage( "org/netbeans/modules/websvc/core/webservices/ui/resources/wsoperation.png" ); //NOI18N
83

84     private FileObject implClass;
85     private Service service;
86     private FileObject srcRoot;
87     
88     private WsdlModel wsdlModel;
89     private WsdlModeler wsdlModeler;
90     private boolean modelGenerationFinished;
91
92     
93     public JaxWsChildren(Service service, FileObject srcRoot, FileObject implClass) {
94         super();
95         this.service = service;
96         this.srcRoot=srcRoot;
97         this.implClass = implClass;
98     }
99
100 // Retouche
101
// public ComponentMethodViewStrategy createViewStrategy() {
102
// WSComponentMethodViewStrategy strategy = WSComponentMethodViewStrategy.instance();
103
// return strategy;
104
// }
105
//
106

107     private List<ExecutableElement> getPublicMethods(CompilationController controller, TypeElement classElement) throws IOException JavaDoc {
108         List<? extends Element> members = classElement.getEnclosedElements();
109         List<ExecutableElement> methods = ElementFilter.methodsIn(members);
110         List<ExecutableElement> publicMethods = new ArrayList<ExecutableElement>();
111         for (ExecutableElement method:methods) {
112             Set JavaDoc<Modifier> modifiers = method.getModifiers();
113             if (modifiers.contains(Modifier.PUBLIC)) {
114                 publicMethods.add(method);
115             }
116         }
117         return publicMethods;
118     }
119
120     protected void addNotify() {
121         super.addNotify();
122         if (isFromWsdl()) {
123             try {
124                 FileObject localWsdlFolder = getJAXWSSupport().getLocalWsdlFolderForService(service.getName(),false);
125                 assert localWsdlFolder!=null:"Cannot find folder for local wsdl file"; //NOI18N
126
FileObject wsdlFo =
127                     localWsdlFolder.getFileObject(service.getLocalWsdlFile());
128                 if (wsdlFo==null) return;
129                 wsdlModeler = WsdlModelerFactory.getDefault().getWsdlModeler(wsdlFo.getURL());
130                 String JavaDoc packageName = service.getPackageName();
131                 if (packageName!=null && service.isPackageNameForceReplace()) {
132                     // set the package name for the modeler
133
wsdlModeler.setPackageName(packageName);
134                 } else {
135                     wsdlModeler.setPackageName(null);
136                 }
137                 JAXWSSupport support = getJAXWSSupport();
138                 wsdlModeler.setCatalog(support.getCatalog());
139                 setBindings(support,wsdlModeler,service);
140                 modelGenerationFinished=false;
141                 ((JaxWsNode)getNode()).changeIcon();
142                 wsdlModeler.generateWsdlModel(new WsdlModelListener() {
143                     public void modelCreated(WsdlModel model) {
144                         wsdlModel=model;
145                         modelGenerationFinished=true;
146                         ((JaxWsNode)getNode()).changeIcon();
147                         if (model==null) {
148                             DialogDisplayer.getDefault().notify(
149                                     new JaxWsUtils.WsImportServiceFailedMessage(wsdlModeler.getCreationException()));
150                         }
151                         updateKeys();
152                     }
153                 });
154             } catch (FileStateInvalidException ex) {
155                 ErrorManager.getDefault().log(ex.getLocalizedMessage());
156                 updateKeys();
157             }
158         } else {
159             assert(implClass != null);
160             //registerListener();
161
//methods = getMethods();
162
//registerMethodListeners();
163
updateKeys();
164         }
165     }
166
167 // Retouche
168
// private void registerListener() {
169
// if (implClass!=null) ((MDRChangeSource)implClass).addListener(this);
170
// }
171
//
172
// private void registerMethodListeners() {
173
// if (methods!=null) {
174
// for (int i=0;i<methods.length;i++) {
175
// ((MDRChangeSource)methods[i]).addListener(this);
176
// }
177
// }
178
// }
179
//
180
// private void removeListener() {
181
// if (implClass!=null) ((MDRChangeSource)implClass).removeListener(this);
182
// }
183
//
184
//
185
// private void removeMethodListeners() {
186
// if (methods!=null) {
187
// for (int i=0;i<methods.length;i++) {
188
// ((MDRChangeSource)methods[i]).removeListener(this);
189
// }
190
// }
191
// }
192

193 // protected void removeNotify() {
194
// setKeys(Collections.EMPTY_SET);
195
// if (!isFromWsdl()) {
196
// removeListener();
197
// removeMethodListeners();
198
// methods=null;
199
// }
200
// super.removeNotify();
201
// }
202

203     private void updateKeys() {
204         if (isFromWsdl()) {
205             List keys = new ArrayList();
206             if (wsdlModel!=null) {
207                 WsdlService wsdlService = wsdlModel.getServiceByName(service.getServiceName());
208                 if (wsdlService!=null) {
209                     WsdlPort wsdlPort = wsdlService.getPortByName(service.getPortName());
210                     if (wsdlPort!=null)
211                         keys = wsdlPort.getOperations();
212                 }
213             }
214             setKeys(keys);
215         } else {
216             SwingUtilities.invokeLater(new Runnable JavaDoc() {
217                 public void run() {
218                     final List[] keys = new List[]{new ArrayList()};
219                     if (implClass != null) {
220                         JavaSource javaSource = JavaSource.forFileObject(implClass);
221                         if (javaSource!=null) {
222                             CancellableTask<CompilationController> task = new CancellableTask<CompilationController>() {
223                                 public void run(CompilationController controller) throws IOException JavaDoc {
224                                     controller.toPhase(Phase.ELEMENTS_RESOLVED);
225                                     SourceUtils srcUtils = SourceUtils.newInstance(controller);
226                                     if (srcUtils!=null) {
227                                         // find WS operations
228
// either annotated (@WebMethod) public mathods
229
// or all public methods
230
List<ExecutableElement> publicMethods = getPublicMethods(controller, srcUtils.getTypeElement());
231                                         List<ExecutableElement> wsOperations = new ArrayList<ExecutableElement>();
232                                         boolean foundWebMethodAnnotation=false;
233                                         for(ExecutableElement method:publicMethods) {
234                                             List<? extends AnnotationMirror> annotations = method.getAnnotationMirrors();
235                                             boolean hasWebMethodAnnotation=false;
236                                             for (AnnotationMirror an:annotations) {
237                                                 TypeElement webMethodEl = controller.getElements().getTypeElement("javax.jws.WebMethod"); //NOI18N
238
if (webMethodEl!=null && controller.getTypes().isSameType(webMethodEl.asType(), an.getAnnotationType())) {
239                                                     hasWebMethodAnnotation=true;
240                                                     break;
241                                                 }
242                                             }
243                                             if (hasWebMethodAnnotation) {
244                                                 if (!foundWebMethodAnnotation) {
245                                                     foundWebMethodAnnotation=true;
246                                                     // remove all methods added before
247
// because only annotated methods should be added
248
if (wsOperations.size()>0) wsOperations.clear();
249                                                 }
250                                                 wsOperations.add(method);
251                                             } else if (!foundWebMethodAnnotation) {
252                                                 // there are only non-annotated methods present until now
253
wsOperations.add(method);
254                                             }
255                                         } // for
256
keys[0] = wsOperations;
257                                     }
258                                 }
259                                 
260                                 public void cancel() {}
261                             };
262                             try {
263                                 javaSource.runUserActionTask(task, true);
264                             } catch (IOException JavaDoc ex) {
265                                 ErrorManager.getDefault().notify(ex);
266                             }
267                         }
268                         
269 // Retouche
270
// if (methods==null)
271
// registerMethodListeners();
272
// methods = keys[0];
273
}
274                     setKeys(keys[0]);
275                 }
276             });
277         }
278     }
279     
280     protected Node[] createNodes(Object JavaDoc key) {
281         if(key instanceof WsdlOperation) {
282             return new Node[] {new OperationNode((WsdlOperation)key)};
283         } else if(key instanceof ExecutableElement) {
284 // Method method = (Method)key;
285
// ComponentMethodViewStrategy cmvs = createViewStrategy();
286
// return new Node[] {new MethodNode(method, implClass, new ArrayList(), cmvs)};
287
// }
288
final ExecutableElement method = (ExecutableElement)key;
289             Node n = new AbstractNode(Children.LEAF) {
290
291                 @java.lang.Override JavaDoc
292                 public java.awt.Image JavaDoc getIcon(int type) {
293                     return OPERATION_BADGE;
294                 }
295
296                 @Override JavaDoc
297                 public String JavaDoc getDisplayName() {
298                     return method.getSimpleName().toString();
299                 }
300             };
301             
302             return new Node[]{n};
303         }
304         return new Node[0];
305     }
306     
307     private boolean isFromWsdl() {
308         return service.getWsdlUrl()!=null;
309     }
310     
311     private JAXWSSupport getJAXWSSupport() {
312         return JAXWSSupport.getJAXWSSupport(srcRoot);
313     }
314     
315     private void setBindings(JAXWSSupport support, WsdlModeler wsdlModeler, Service service) {
316         Binding[] extbindings = service.getBindings();
317         if (extbindings==null || extbindings.length==0) {
318             wsdlModeler.setJAXBBindings(null);
319             return;
320         }
321         String JavaDoc[] bindingFiles = new String JavaDoc[extbindings.length];
322         for(int i = 0; i < extbindings.length; i++){
323             bindingFiles[i] = extbindings[i].getFileName();
324         }
325         /*
326         String[] bindingFiles = service.getBindings();
327         if (bindingFiles==null || bindingFiles.length==0) {
328             wsdlModeler.setJAXBBindings(null);
329             return;
330         }
331          */

332         FileObject bindingsFolder = support.getBindingsFolderForService(getNode().getName(),true);
333         List<URL JavaDoc> list = new ArrayList<URL JavaDoc>();
334         for (int i=0;i<bindingFiles.length;i++) {
335             FileObject fo = bindingsFolder.getFileObject(bindingFiles[i]);
336             try {
337                 list.add(fo.getURL());
338             } catch (FileStateInvalidException ex) {
339                 // if there is problem no bindings will be added
340
}
341         }
342         URL JavaDoc[] bindings = new URL JavaDoc[list.size()];
343         list.<URL JavaDoc>toArray(bindings);
344         wsdlModeler.setJAXBBindings(bindings);
345     }
346     
347     void refreshKeys(boolean downloadWsdl, final boolean refreshImplClass) {
348         if (!isFromWsdl()) return;
349         super.addNotify();
350         List keys=null;
351         try {
352             // copy to local wsdl first
353
JAXWSSupport support = getJAXWSSupport();
354             
355             if (downloadWsdl) {
356                 String JavaDoc serviceName = getNode().getName();
357                 FileObject xmlResorcesFo = support.getLocalWsdlFolderForService(serviceName,true);
358                 FileObject localWsdl = null;
359                 try {
360                     localWsdl = WSUtils.retrieveResource(
361                             xmlResorcesFo,
362                             new URI JavaDoc(service.getWsdlUrl()));
363                     // copy resources to WEB-INF/wsdl/${serviceName}
364
FileObject wsdlFolder = getWsdlFolderForService(support, serviceName);
365                     WSUtils.copyFiles(xmlResorcesFo, wsdlFolder);
366                 } catch (URISyntaxException JavaDoc ex) {
367                     ErrorManager.getDefault().notify(ex);
368                 } catch (UnknownHostException JavaDoc ex) {
369                     ErrorManager.getDefault().annotate(ex,
370                             NbBundle.getMessage(JaxWsClientChildren.class,"MSG_ConnectionProblem"));
371                     return;
372                 } catch (IOException JavaDoc ex) {
373                     ErrorManager.getDefault().annotate(ex,
374                             NbBundle.getMessage(JaxWsClientChildren.class,"MSG_ConnectionProblem"));
375                     return;
376                 }
377                 
378                 // re-generate also wrapper wsdl file if necessary
379
if (localWsdl!=null) {
380                     WsdlWrapperHandler handler = null;
381                     try {
382                         handler = WsdlWrapperGenerator.parse(localWsdl.getURL().toExternalForm());
383                     } catch (ParserConfigurationException JavaDoc ex) {
384                         ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,ex);
385                     } catch (SAXException JavaDoc ex) {
386                         ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,ex);
387                     } catch (IOException JavaDoc ex) {
388                         ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,ex);
389                     }
390                     if (!handler.isServiceElement()) {
391                         StreamSource JavaDoc source = new StreamSource JavaDoc(localWsdl.getURL().toExternalForm());
392                         try {
393                             File JavaDoc wrapperWsdlFile = new File JavaDoc(FileUtil.toFile(localWsdl.getParent()), WsdlWrapperGenerator.getWrapperName(localWsdl.getURL())); //NOI18N
394

395                             if(!wrapperWsdlFile.exists()) {
396                                 try {
397                                     wrapperWsdlFile.createNewFile();
398                                 } catch(IOException JavaDoc ex) {
399                                     ErrorManager.getDefault().notify(ErrorManager.EXCEPTION,ex);
400                                 }
401                             }
402                             if (wrapperWsdlFile.exists()) {
403                                 WsdlWrapperGenerator.generateWrapperWSDLContent(wrapperWsdlFile, source, handler.getTargetNsPrefix(),localWsdl.getNameExt());
404                             }
405                         } catch (IOException JavaDoc ex) {
406                             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,ex);
407                         }
408                     }
409                 }
410             }
411             FileObject wsdlFo =
412                 getJAXWSSupport().getLocalWsdlFolderForService(service.getName(),false).getFileObject(service.getLocalWsdlFile());
413             wsdlModeler = WsdlModelerFactory.getDefault().getWsdlModeler(wsdlFo.getURL());
414             String JavaDoc packageName = service.getPackageName();
415             if (packageName!=null && service.isPackageNameForceReplace()) {
416                 // set the package name for the modeler
417
wsdlModeler.setPackageName(packageName);
418             } else {
419                 wsdlModeler.setPackageName(null);
420             }
421             wsdlModeler.setCatalog(support.getCatalog());
422             setBindings(support, wsdlModeler, service);
423             
424             // re-generate java artifacts
425
regenerateJavaArtifacts();
426             // update nodes and implementation class
427

428             modelGenerationFinished=false;
429             ((JaxWsNode)getNode()).changeIcon();
430             wsdlModeler.generateWsdlModel(new WsdlModelListener() {
431                 public void modelCreated(WsdlModel model) {
432                     wsdlModel=model;
433                     modelGenerationFinished=true;
434                     ((JaxWsNode)getNode()).changeIcon();
435                     if (model==null) {
436                         DialogDisplayer.getDefault().notify(
437                                 new JaxWsUtils.WsImportServiceFailedMessage(wsdlModeler.getCreationException()));
438                     }
439                     updateKeys();
440                     if (model!=null) {
441                         try {
442                             // test if serviceName, portName are the same, change if necessary
443
String JavaDoc serviceName = service.getServiceName();
444                             String JavaDoc portName = service.getPortName();
445                             WsdlService wsdlService = model.getServiceByName(serviceName);
446                             boolean jaxWsModelChanged=false;
447                             if (wsdlService==null) {
448                                 wsdlService = (WsdlService)model.getServices().get(0);
449                                 service.setServiceName(wsdlService.getName());
450                                 jaxWsModelChanged=true;
451                             }
452                             WsdlPort wsdlPort = wsdlService.getPortByName(portName);
453                             if (wsdlPort==null) {
454                                 wsdlPort = (WsdlPort)wsdlService.getPorts().get(0);
455                                 service.setPortName(wsdlPort.getName());
456                                 jaxWsModelChanged=true;
457                             }
458                             
459                             // test if package name for java artifacts hasn't changed
460
String JavaDoc oldPkgName = service.getPackageName();
461                             if (wsdlService!=null && oldPkgName!=null && !service.isPackageNameForceReplace()) {
462                                 String JavaDoc javaName = wsdlService.getJavaName();
463                                 int dotPosition = javaName.lastIndexOf(".");
464                                 if (dotPosition>=0) {
465                                     String JavaDoc newPkgName = javaName.substring(0,dotPosition);
466                                     if (!oldPkgName.equals(newPkgName)) {
467                                         service.setPackageName(newPkgName);
468                                         jaxWsModelChanged=true;
469                                     }
470                                 }
471                             }
472
473                             // save jax-ws model
474
if (jaxWsModelChanged) {
475                                 Project project = FileOwnerQuery.getOwner(srcRoot);
476                                 if (project!=null) {
477                                     JaxWsModel jaxWsModel = (JaxWsModel)project.getLookup().lookup(JaxWsModel.class);
478                                     if (jaxWsModel!=null) jaxWsModel.write();
479                                 }
480
481                             }
482                             if (refreshImplClass) {
483                                 // re-generate implementation class
484
String JavaDoc implClass = service.getImplementationClass();
485                                 FileObject oldImplClass = srcRoot.getFileObject(implClass.replace('.','/')+".java"); //NOI18N
486
FileObject oldCopy = srcRoot.getFileObject(implClass.replace('.','/')+".java.old"); //NOI18N
487
int index = implClass.lastIndexOf(".");
488                                 FileObject folder = index>0?srcRoot.getFileObject(implClass.substring(0,index).replace('.','/')):srcRoot;
489                                 if (folder!=null) {
490                                     String JavaDoc name = (index>=0?implClass.substring(index+1):implClass);
491                                     if (oldImplClass!=null) {
492                                         if (oldCopy!=null) oldCopy.delete();
493                                         FileUtil.copyFile(oldImplClass, folder, name+".java", "old"); //NOI18N
494
oldImplClass.delete();
495                                     }
496                                     JaxWsUtils.generateJaxWsImplementationClass(FileOwnerQuery.getOwner(srcRoot),
497                                         folder, name, model, service);
498                                     JaxWsNode parent = (JaxWsNode)getNode();
499                                     FileObject newImplClass = srcRoot.getFileObject(implClass.replace('.','/')+".java"); //NOI18N
500
if (newImplClass!=null) {
501                                         JaxWsChildren.this.implClass=newImplClass;
502                                     }
503                                     parent.refreshImplClass();
504                                     
505                                 }
506                             }
507                         } catch (Exception JavaDoc ex) {
508                             ErrorManager.getDefault().notify(ErrorManager.ERROR,ex);
509                         }
510                     }
511                 }
512             });
513         } catch (FileStateInvalidException ex) {
514             ErrorManager.getDefault().log(ex.getLocalizedMessage());
515         }
516     }
517     
518     private void regenerateJavaArtifacts() {
519         Project project = FileOwnerQuery.getOwner(srcRoot);
520         if (project!=null) {
521             FileObject buildImplFo = project.getProjectDirectory().getFileObject(GeneratedFilesHelper.BUILD_IMPL_XML_PATH);
522             try {
523                 String JavaDoc name = service.getName();
524                 ExecutorTask wsimportTask =
525                     ActionUtils.runTarget(buildImplFo,
526                         new String JavaDoc[]{"wsimport-service-clean-"+name,"wsimport-service-"+name},null); //NOI18N
527
wsimportTask.waitFinished();
528             } catch (IOException JavaDoc ex) {
529                 ErrorManager.getDefault().log(ex.getLocalizedMessage());
530             } catch (IllegalArgumentException JavaDoc ex) {
531                 ErrorManager.getDefault().log(ex.getLocalizedMessage());
532             }
533         }
534     }
535
536 // Retouche
537
// public static class WSComponentMethodViewStrategy implements ComponentMethodViewStrategy {
538
// // private Image NOT_OPERATION_BADGE = Utilities.loadImage("org/openide/src/resources/error.gif");
539
// private static WSComponentMethodViewStrategy wsmvStrategy;
540
// private WSComponentMethodViewStrategy(){
541
// }
542
//
543
// public static WSComponentMethodViewStrategy instance(){
544
// if(wsmvStrategy == null){
545
// wsmvStrategy = new WSComponentMethodViewStrategy();
546
// }
547
// return wsmvStrategy;
548
// }
549
// public Image getBadge(Method method, Collection interfaces){
550
//
551
// /* no need to badge this, it sometimes not a sign for bad operation see 55679 Set paramTypes = new HashSet();
552
// //FIX-ME:Need a better way to find out if method is in SEI
553
// MethodParameter[] parameters = method.getParameters();
554
// for(int i = 0; i < parameters.length; i++){
555
// paramTypes.add(parameters[i].getType());
556
// }
557
// Iterator iter = interfaces.iterator();
558
// while(iter.hasNext()){
559
// ClassElement intf = (ClassElement)iter.next();
560
// if(intf.getMethod(method.getName(), (Type[])paramTypes.toArray(new Type[paramTypes.size()])) == null){
561
// return NOT_OPERATION_BADGE;
562
// }
563
//
564
// }*/
565
//
566
// return null;
567
// }
568
//
569
// public void deleteImplMethod(Method m, JavaClass implClass, Collection interfaces) throws IOException{
570
// //delete method in the SEI
571
// Iterator iter = interfaces.iterator();
572
// while (iter.hasNext()){
573
// JavaClass intf = (JavaClass)iter.next();
574
// try {
575
// intf.getContents().remove(m);
576
// } catch (JmiException e) {
577
// throw new IOException(e.getMessage());
578
// }
579
// }
580
// //delete method from Impl class
581
// Method[] methods = JMIUtils.getMethods(implClass);
582
// for(int i = 0; i < methods.length; i++){
583
// Method method = methods[i];
584
// if (JMIUtils.equalMethods(m, method)) {
585
// try {
586
// implClass.getContents().remove(method);
587
// break;
588
// } catch (JmiException e) {
589
// throw new IOException(e.getMessage());
590
// }
591
// }
592
// }
593
// }
594
//
595
// public OpenCookie getOpenCookie(Method m, JavaClass implClass, Collection interfaces) {
596
// Method[] methods = JMIUtils.getMethods(implClass);
597
// for(int i = 0; i < methods.length; i++) {
598
// Method method = methods[i];
599
// if (JMIUtils.equalMethods(m, method)) {
600
// return (OpenCookie)JMIUtils.getCookie(method, OpenCookie.class);
601
// }
602
// }
603
// return null;
604
// }
605
//
606
// public Image getIcon(Method me, Collection interfaces) {
607
// return Utilities.loadImage("org/openide/src/resources/methodPublic.gif");
608
// }
609
//
610
// }
611

612 // public void change(MDRChangeEvent evt) {
613
// if (evt.getSource() instanceof JavaClass) {
614
// removeMethodListeners();
615
// methods=null;
616
// updateKeys();
617
// } else if (evt.getSource() instanceof Method && evt instanceof AttributeEvent) {
618
// AttributeEvent attrEvt = ((AttributeEvent) evt);
619
// int type = attrEvt.getType();
620
// if (type==AttributeEvent.EVENT_ATTRIBUTE_ADD) {
621
// // annotation has been added
622
// Object newElement = attrEvt.getNewElement();
623
// if (newElement instanceof Annotation) {
624
// if ("javax.jws.WebMethod".equals(((Annotation)newElement).getType().getName())) //NOI18N
625
// updateKeys();
626
// }
627
// } else if (type == AttributeEvent.EVENT_ATTRIBUTE_REMOVE && "annotations".equals(attrEvt.getAttributeName())) { //NOI18N
628
// // annotation has been removed
629
// // NOTE: this may require more proper evaluation of deleted Attribute
630
// updateKeys();
631
// } else if (type == AttributeEvent.EVENT_ATTRIBUTE_SET && "modifiers".equals(attrEvt.getAttributeName())) { //NOI18N
632
// // modifier has been changed
633
// updateKeys();
634
// }
635
// }
636
// }
637

638     private FileObject getWsdlFolderForService(JAXWSSupport support, String JavaDoc name) throws IOException JavaDoc {
639         FileObject globalWsdlFolder = support.getWsdlFolder(true);
640         FileObject oldWsdlFolder = globalWsdlFolder.getFileObject(name);
641         if (oldWsdlFolder!=null) {
642             FileLock lock = oldWsdlFolder.lock();
643             try {
644                 oldWsdlFolder.delete(lock);
645             } finally {
646                 lock.releaseLock();
647             }
648         }
649         return globalWsdlFolder.createFolder(name);
650     }
651     
652     WsdlModeler getWsdlModeler() {
653         return wsdlModeler;
654     }
655     
656     boolean isModelGenerationFinished() {
657         return modelGenerationFinished;
658     }
659     
660 }
661
Popular Tags