1 package org.objectweb.celtix.bus.ws.rm; 2 3 import java.lang.reflect.Method ; 4 5 import javax.xml.datatype.Duration ; 6 7 import org.objectweb.celtix.bindings.AbstractBindingBase; 8 import org.objectweb.celtix.bindings.DataBindingCallback; 9 import org.objectweb.celtix.bindings.Request; 10 import org.objectweb.celtix.bus.configuration.wsrm.SourcePolicyType; 11 import org.objectweb.celtix.bus.jaxws.JAXBDataBindingCallback; 12 import org.objectweb.celtix.bus.ws.addressing.AddressingPropertiesImpl; 13 import org.objectweb.celtix.bus.ws.addressing.ContextUtils; 14 import org.objectweb.celtix.bus.ws.addressing.VersionTransformer; 15 import org.objectweb.celtix.transports.Transport; 16 import org.objectweb.celtix.ws.addressing.AddressingProperties; 17 import org.objectweb.celtix.ws.addressing.AttributedURIType; 18 import org.objectweb.celtix.ws.addressing.RelatesToType; 19 import org.objectweb.celtix.ws.addressing.v200408.EndpointReferenceType; 20 import org.objectweb.celtix.ws.rm.CreateSequenceType; 21 import org.objectweb.celtix.ws.rm.Expires; 22 import org.objectweb.celtix.ws.rm.OfferType; 23 24 public class CreateSequenceRequest extends Request { 25 26 private static final String METHOD_NAME = "createSequence"; 27 private static final String OPERATION_NAME = "CreateSequence"; 28 29 public CreateSequenceRequest(AbstractBindingBase b, 30 Transport t, 31 RMSource source, 32 org.objectweb.celtix.ws.addressing.EndpointReferenceType to, 33 EndpointReferenceType acksTo, 34 RelatesToType relatesTo) { 35 36 super(b, t, b.createObjectContext()); 37 38 if (to != null) { 39 ContextUtils.storeTo(to, getObjectMessageContext()); 40 ContextUtils.storeReplyTo(VersionTransformer.convert(acksTo), 41 getObjectMessageContext()); 42 } 43 44 ContextUtils.storeUsingAddressing(true, getObjectMessageContext()); 45 46 getObjectMessageContext().setRequestorRole(true); 47 48 AddressingProperties maps = new AddressingPropertiesImpl(); 49 AttributedURIType actionURI = ContextUtils.WSA_OBJECT_FACTORY.createAttributedURIType(); 50 actionURI.setValue(RMUtils.getRMConstants().getCreateSequenceAction()); 51 maps.setAction(actionURI); 52 maps.setRelatesTo(relatesTo); 53 ContextUtils.storeMAPs(maps, getObjectMessageContext(), true, true, true, true); 54 55 setMessageParameters(source, acksTo); 56 57 setOneway(false); 62 expectRelatedRequest(); 63 } 64 65 public static Method getMethod() { 66 Method method = null; 67 try { 68 method = OutOfBandProtocolMessages.class.getMethod( 69 METHOD_NAME, 70 new Class [] {CreateSequenceType.class}); 71 } catch (NoSuchMethodException ex) { 72 ex.printStackTrace(); 73 } 74 return method; 75 } 76 77 public static String getOperationName() { 78 return OPERATION_NAME; 79 } 80 81 public static DataBindingCallback createDataBindingCallback() { 82 return new JAXBDataBindingCallback(getMethod(), DataBindingCallback.Mode.PARTS, null); 83 } 84 85 protected OfferType getIncludedOffer() { 86 Object [] params = getObjectMessageContext().getMessageObjects(); 87 if (null == params || params.length < 1) { 88 return null; 89 } 90 return ((CreateSequenceType)params[0]).getOffer(); 91 } 92 93 private void setMessageParameters(RMSource source, EndpointReferenceType defaultAcksTo) { 94 SourcePolicyType sourcePolicies = source.getSourcePolicies(); 95 assert null != sourcePolicies; 96 97 CreateSequenceType cs = RMUtils.getWSRMFactory().createCreateSequenceType(); 98 99 String address = sourcePolicies.getAcksTo(); 100 EndpointReferenceType acksTo = null; 101 if (null != address) { 102 acksTo = RMUtils.createReference(address); 103 } else { 104 acksTo = defaultAcksTo; 105 } 106 cs.setAcksTo(acksTo); 107 108 Duration d = sourcePolicies.getSequenceExpiration(); 109 if (null != d) { 110 Expires expires = RMUtils.getWSRMFactory().createExpires(); 111 expires.setValue(d); 112 cs.setExpires(expires); 113 } 114 115 if (sourcePolicies.isIncludeOffer()) { 116 OfferType offer = RMUtils.getWSRMFactory().createOfferType(); 117 d = sourcePolicies.getOfferedSequenceExpiration(); 118 if (null != d) { 119 Expires expires = RMUtils.getWSRMFactory().createExpires(); 120 expires.setValue(d); 121 offer.setExpires(expires); 122 } 123 offer.setIdentifier(source.generateSequenceIdentifier()); 124 cs.setOffer(offer); 125 } 126 127 getObjectMessageContext().setMessageObjects(new Object [] {cs}); 128 } 129 } 130 | Popular Tags |