KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitconf > wsdlmodelext > AddressingModelHelper


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 2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.wsitconf.wsdlmodelext;
21
22 import org.netbeans.modules.websvc.wsitmodelext.addressing.Addressing10WsdlQName;
23 import org.netbeans.modules.websvc.wsitmodelext.addressing.Addressing10WsdlUsingAddressing;
24 import org.netbeans.modules.websvc.wsitmodelext.policy.All;
25 import org.netbeans.modules.websvc.wsitmodelext.policy.Policy;
26 import org.netbeans.modules.xml.wsdl.model.Binding;
27
28 /**
29  *
30  * @author Martin Grebac
31  */

32 public class AddressingModelHelper {
33     
34     /**
35      * Creates a new instance of AddressingModelHelper
36      */

37     public AddressingModelHelper() {
38     }
39     
40     public static Addressing10WsdlUsingAddressing getUsingAddressing(Policy p) {
41         return (Addressing10WsdlUsingAddressing) PolicyModelHelper.getTopLevelElement(p, Addressing10WsdlUsingAddressing.class);
42     }
43     
44     // checks if Addressing is enabled in the config wsdl on specified binding
45
public static boolean isAddressingEnabled(Binding b) {
46         Policy p = PolicyModelHelper.getPolicyForElement(b);
47         if (p != null) {
48             Addressing10WsdlUsingAddressing addrAssertion = getUsingAddressing(p);
49             return (addrAssertion != null);
50         }
51         return false;
52     }
53     
54     // enables Addressing in the config wsdl on specified binding
55
public static void enableAddressing(Binding b) {
56         All a = PolicyModelHelper.createPolicy(b);
57         PolicyModelHelper.createElement(a, Addressing10WsdlQName.USINGADDRESSING.getQName(), Addressing10WsdlUsingAddressing.class, false);
58     }
59
60     // disables Addressing in the config wsdl on specified binding
61
public static void disableAddressing(Binding b) {
62         Policy p = PolicyModelHelper.getPolicyForElement(b);
63         Addressing10WsdlUsingAddressing a = getUsingAddressing(p);
64         if (a != null) {
65             PolicyModelHelper.removeElement(a.getParent(), Addressing10WsdlUsingAddressing.class, false);
66         }
67         PolicyModelHelper.cleanPolicies(b);
68     }
69 }
70
Popular Tags