/** * Add MAPs which are specific to the requestor or responder role. * * @param maps the MAPs being assembled * @param message the current message * @param isRequestor true iff the current messaging role is that of requestor * @param isFault true if a fault is being mediated */ private void addRoleSpecific( AddressingProperties maps, Message message, boolean isRequestor, boolean isFault) { if (isRequestor) { Exchange exchange = message.getExchange(); // add request-specific MAPs boolean isOneway = exchange.isOneWay(); boolean isOutbound = ContextUtils.isOutbound(message); // To if (maps.getTo() == null) { Conduit conduit = null; if (isOutbound) { conduit = ContextUtils.getConduit(null, message); } String s = (String) message.get(Message.ENDPOINT_ADDRESS); EndpointReferenceType reference = conduit != null ? conduit.getTarget() : ContextUtils.getNoneEndpointReference(); if (conduit != null && !StringUtils.isEmpty(s) && !reference.getAddress().getValue().equals(s)) { EndpointReferenceType ref = new EndpointReferenceType(); AttributedURIType tp = new AttributedURIType(); tp.setValue(s); ref.setAddress(tp); ref.setMetadata(reference.getMetadata()); ref.setReferenceParameters(reference.getReferenceParameters()); ref.getOtherAttributes().putAll(reference.getOtherAttributes()); reference = ref; } maps.setTo(reference); } // ReplyTo, set if null in MAPs or if set to a generic address // (anonymous or none) that may not be appropriate for the // current invocation EndpointReferenceType replyTo = maps.getReplyTo(); if (ContextUtils.isGenericAddress(replyTo)) { replyTo = getReplyTo(message, replyTo); if (replyTo == null || (isOneway && (replyTo == null || replyTo.getAddress() == null || !Names.WSA_NONE_ADDRESS.equals(replyTo.getAddress().getValue())))) { AttributedURIType address = ContextUtils.getAttributedURI( isOneway ? Names.WSA_NONE_ADDRESS : Names.WSA_ANONYMOUS_ADDRESS); replyTo = ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType(); replyTo.setAddress(address); } maps.setReplyTo(replyTo); } // FaultTo if (maps.getFaultTo() == null) { maps.setFaultTo(maps.getReplyTo()); } else if (maps.getFaultTo().getAddress() == null) { maps.setFaultTo(null); } } else { // add response-specific MAPs AddressingProperties inMAPs = getMAPs(message, false, false); maps.exposeAs(inMAPs.getNamespaceURI()); // To taken from ReplyTo or FaultTo in incoming MAPs (depending // on the fault status of the response) if (isFault && inMAPs.getFaultTo() != null) { maps.setTo(inMAPs.getFaultTo()); } else if (maps.getTo() == null && inMAPs.getReplyTo() != null) { maps.setTo(inMAPs.getReplyTo()); } // RelatesTo taken from MessageID in incoming MAPs if (inMAPs.getMessageID() != null && !Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE))) { String inMessageID = inMAPs.getMessageID().getValue(); maps.setRelatesTo(ContextUtils.getRelatesTo(inMessageID)); } else { maps.setRelatesTo(ContextUtils.getRelatesTo(Names.WSA_UNSPECIFIED_RELATIONSHIP)); } // fallback fault action if (isFault && maps.getAction() == null) { maps.setAction(ContextUtils.getAttributedURI(Names.WSA_DEFAULT_FAULT_ACTION)); } if (isFault && !ContextUtils.isGenericAddress(inMAPs.getFaultTo())) { Message m = message.getExchange().getInFaultMessage(); if (m == null) { m = message; } InternalContextUtils.rebaseResponse(inMAPs.getFaultTo(), inMAPs, m); Destination destination = InternalContextUtils.createDecoupledDestination(m.getExchange(), inMAPs.getFaultTo()); m.getExchange().setDestination(destination); } } }
public RMEndpoint getReliableEndpoint(Message message) throws RMException { Endpoint endpoint = message.getExchange().getEndpoint(); QName name = endpoint.getEndpointInfo().getName(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Getting RMEndpoint for endpoint with info: " + name); } if (name.equals(RM10Constants.PORT_NAME) || name.equals(RM11Constants.PORT_NAME)) { WrappedEndpoint wrappedEndpoint = (WrappedEndpoint) endpoint; endpoint = wrappedEndpoint.getWrappedEndpoint(); } String rmUri = (String) message.getContextualProperty(WSRM_VERSION_PROPERTY); if (rmUri == null) { RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false); if (rmps != null) { rmUri = rmps.getNamespaceURI(); } } String addrUri = (String) message.getContextualProperty(WSRM_WSA_VERSION_PROPERTY); if (addrUri == null) { AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, false, false); if (maps != null) { addrUri = maps.getNamespaceURI(); } } RMConfiguration config = getConfiguration(); if (rmUri != null) { config.setRMNamespace(rmUri); ProtocolVariation protocol = ProtocolVariation.findVariant(rmUri, addrUri); if (protocol == null) { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("UNSUPPORTED_NAMESPACE", LOG, addrUri, rmUri); LOG.log(Level.INFO, msg.toString()); throw new RMException(msg); } } if (addrUri != null) { config.setRM10AddressingNamespace(addrUri); } Long timeout = (Long) message.getContextualProperty(WSRM_INACTIVITY_TIMEOUT_PROPERTY); if (timeout != null) { config.setInactivityTimeout(timeout); } Long interval = (Long) message.getContextualProperty(WSRM_RETRANSMISSION_INTERVAL_PROPERTY); if (interval != null) { config.setBaseRetransmissionInterval(interval); } Boolean exponential = (Boolean) message.getContextualProperty(WSRM_EXPONENTIAL_BACKOFF_PROPERTY); if (exponential != null) { config.setExponentialBackoff(exponential); } interval = (Long) message.getContextualProperty(WSRM_ACKNOWLEDGEMENT_INTERVAL_PROPERTY); if (interval != null) { config.setAcknowledgementInterval(interval); } RMEndpoint rme = reliableEndpoints.get(endpoint); if (null == rme) { synchronized (endpoint) { rme = reliableEndpoints.get(endpoint); if (rme != null) { return rme; } rme = createReliableEndpoint(endpoint); org.apache.cxf.transport.Destination destination = message.getExchange().getDestination(); EndpointReferenceType replyTo = null; if (null != destination) { AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, false); replyTo = maps.getReplyTo(); } Endpoint ei = message.getExchange().getEndpoint(); org.apache.cxf.transport.Destination dest = ei == null ? null : ei.getEndpointInfo() .getProperty( MAPAggregator.DECOUPLED_DESTINATION, org.apache.cxf.transport.Destination.class); config = RMPolicyUtilities.getRMConfiguration(config, message); rme.initialise(config, message.getExchange().getConduit(message), replyTo, dest, message); reliableEndpoints.put(endpoint, rme); LOG.fine("Created new RMEndpoint."); } } return rme; }