1 package org.objectweb.celtix.bus.ws.rm; 2 3 import java.math.BigInteger ; 4 import java.util.Map ; 5 6 import javax.xml.namespace.QName ; 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 POLICIES_PROPERTY_NAME = "policies"; 18 private static final String 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 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 (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 <QName , String > otherAttributes = a.getExponentialBackoff().getOtherAttributes(); 57 String 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 72 public Identifier generateSequenceIdentifier() { 73 String 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 getEndpointId() { 84 return handler.getConfiguration().getParent().getId().toString(); 85 } 86 87 } 88 | Popular Tags |