KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > bus > ws > rm > RMEndpoint


1 package org.objectweb.celtix.bus.ws.rm;
2
3 import java.math.BigInteger JavaDoc;
4 import java.util.Map JavaDoc;
5
6 import javax.xml.namespace.QName JavaDoc;
7
8 import org.objectweb.celtix.bus.configuration.wsrm.EndpointPolicyType;
9 import org.objectweb.celtix.bus.ws.addressing.ContextUtils;
10 import org.objectweb.celtix.ws.rm.Identifier;
11 import org.objectweb.celtix.ws.rm.policy.RMAssertionType;
12 import org.objectweb.celtix.ws.rm.policy.RMAssertionType.BaseRetransmissionInterval;
13 import org.objectweb.celtix.ws.rm.policy.RMAssertionType.ExponentialBackoff;
14
15 public class RMEndpoint {
16
17     private static final String JavaDoc POLICIES_PROPERTY_NAME = "policies";
18     private static final String JavaDoc RMASSERTION_PROPERTY_NAME = "rmAssertion";
19     
20     private RMHandler handler;
21     
22
23     protected RMEndpoint(RMHandler h) {
24         handler = h;
25     }
26     
27     
28     public RMHandler getHandler() {
29         return handler;
30     }
31     
32     public RMAssertionType getRMAssertion() {
33         RMAssertionType a = getHandler().getConfiguration()
34             .getObject(RMAssertionType.class, RMASSERTION_PROPERTY_NAME);
35
36         // the following should not be necessary as the rm handler configuration metadata
37
// supplies a default value for the RMAssertion
38

39         if (null == a) {
40             a = RMUtils.getWSRMPolicyFactory().createRMAssertionType();
41             RMUtils.getWSRMPolicyFactory().createRMAssertionType();
42         }
43         
44         if (null == a.getBaseRetransmissionInterval()) {
45             BaseRetransmissionInterval bri =
46                 RMUtils.getWSRMPolicyFactory().createRMAssertionTypeBaseRetransmissionInterval();
47             bri.setMilliseconds(new BigInteger JavaDoc(RetransmissionQueue.DEFAULT_BASE_RETRANSMISSION_INTERVAL));
48             a.setBaseRetransmissionInterval(bri);
49         }
50         
51         if (null == a.getExponentialBackoff()) {
52             ExponentialBackoff eb =
53                 RMUtils.getWSRMPolicyFactory().createRMAssertionTypeExponentialBackoff();
54             a.setExponentialBackoff(eb);
55         }
56         Map JavaDoc<QName JavaDoc, String JavaDoc> otherAttributes = a.getExponentialBackoff().getOtherAttributes();
57         String JavaDoc val = otherAttributes.get(RetransmissionQueue.EXPONENTIAL_BACKOFF_BASE_ATTR);
58         if (null == val) {
59             otherAttributes.put(RetransmissionQueue.EXPONENTIAL_BACKOFF_BASE_ATTR,
60                                 RetransmissionQueue.DEFAULT_EXPONENTIAL_BACKOFF);
61         }
62
63         return a;
64     }
65     
66
67     /**
68      * Generates and returns a sequence identifier.
69      *
70      * @return the sequence identifier.
71      */

72     public Identifier generateSequenceIdentifier() {
73         String JavaDoc sequenceID = ContextUtils.generateUUID();
74         Identifier sid = RMUtils.getWSRMFactory().createIdentifier();
75         sid.setValue(sequenceID);
76         return sid;
77     }
78
79     public EndpointPolicyType getPolicies() {
80         return (EndpointPolicyType)handler.getConfiguration().getObject(POLICIES_PROPERTY_NAME);
81     }
82     
83     public String JavaDoc getEndpointId() {
84         return handler.getConfiguration().getParent().getId().toString();
85     }
86     
87 }
88
Popular Tags