KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > refactoring > safedelete > SunJaxWsXmlSafeDeleteRefactoring


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.j2ee.refactoring.safedelete;
21
22 import org.netbeans.jmi.javamodel.JavaClass;
23 import org.netbeans.modules.j2ee.refactoring.J2EERefactoring;
24 import org.netbeans.modules.j2ee.refactoring.jaxwssupport.JaxWsXmlRefactoringSupport;
25 import org.netbeans.modules.refactoring.api.Problem;
26 import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
27 import org.netbeans.modules.websvc.api.jaxws.project.config.Endpoint;
28 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel;
29 import org.openide.filesystems.FileObject;
30 import org.openide.util.NbBundle;
31
32 /**
33  * This class handles safe delete refactoring of a web service endpoint implementation class
34  * that is listed in sun-jaxws.xml. To be specific, this class does not delete reference to the
35  * removed class but collects its usages from sun-jaxws.xml for displaying these
36  * as problems to the user.
37  *
38  * @author Erno Mononen
39  */

40 public class SunJaxWsXmlSafeDeleteRefactoring extends JaxWsXmlRefactoringSupport implements J2EERefactoring {
41     
42     /**
43      * The java class that's being removed.
44      */

45     private JavaClass javaClass;
46     
47     /**
48      * Creates a new instance of SunJaxWsXmlSafeDeleteRefactoring
49      */

50     public SunJaxWsXmlSafeDeleteRefactoring(JavaClass javaClass) {
51         this.javaClass = javaClass;
52     }
53     
54     /**
55      * Checks whether the java class to be removed is listed as an endpoint implementation
56      * class in sun-jaxws.xml and returns appropriate problem (warning) if it is.
57      */

58     public Problem preCheck() {
59         
60         if (!isWebSvcFromWsdl(javaClass)){
61             return null;
62         }
63
64         FileObject sunjaxwsfile = getSunJaxWsXmlFile(javaClass);
65         Problem result = null;
66         
67         for (Endpoint each : getEndpoints(javaClass)) {
68             Problem problem = new Problem(false, NbBundle.getMessage(SunJaxWsXmlSafeDeleteRefactoring.class,
69                    "TXT_SunJaxWsXmlSafeDeleteWarning", javaClass.getName(), sunjaxwsfile.getNameExt())); //NOI18N
70
if (result != null){
71                 result.setNext(problem);
72             } else {
73                 result = problem;
74             }
75         }
76         return result;
77     }
78     
79     public Problem checkParameters() {
80         return null;
81     }
82     
83     public Problem fastCheckParameters() {
84         return null;
85     }
86     
87     public Problem prepare(RefactoringElementsBag refactoringElementsBag) {
88         return null;
89     }
90 }
91
Popular Tags