Ejemplo n.º 1
0
  private void recoverSourceSequence(
      Endpoint endpoint, Conduit conduit, Source s, SourceSequence ss) {
    Collection<RMMessage> ms = store.getMessages(ss.getIdentifier(), true);
    if (null == ms || 0 == ms.size()) {
      store.removeSourceSequence(ss.getIdentifier());
      return;
    }
    LOG.log(Level.FINE, "Number of messages in sequence: {0}", ms.size());

    s.addSequence(ss, false);
    // choosing an arbitrary valid source sequence as the current source sequence
    if (s.getAssociatedSequence(null) == null && !ss.isExpired() && !ss.isLastMessage()) {
      s.setCurrent(ss);
    }
    for (RMMessage m : ms) {

      Message message = new MessageImpl();
      Exchange exchange = new ExchangeImpl();
      message.setExchange(exchange);
      exchange.setOutMessage(message);
      if (null != conduit) {
        exchange.setConduit(conduit);
        message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
      }
      exchange.put(Endpoint.class, endpoint);
      exchange.put(Service.class, endpoint.getService());
      exchange.put(Binding.class, endpoint.getBinding());
      exchange.put(Bus.class, bus);

      SequenceType st = new SequenceType();
      st.setIdentifier(ss.getIdentifier());
      st.setMessageNumber(m.getMessageNumber());
      RMProperties rmps = new RMProperties();
      rmps.setSequence(st);
      rmps.exposeAs(ss.getProtocol().getWSRMNamespace());
      if (ss.isLastMessage() && ss.getCurrentMessageNr() == m.getMessageNumber()) {
        CloseSequenceType close = new CloseSequenceType();
        close.setIdentifier(ss.getIdentifier());
        rmps.setCloseSequence(close);
      }
      RMContextUtils.storeRMProperties(message, rmps, true);
      if (null == conduit) {
        String to = m.getTo();
        AddressingProperties maps = new AddressingProperties();
        maps.setTo(RMUtils.createReference(to));
        RMContextUtils.storeMAPs(maps, message, true, false);
      }

      try {
        // RMMessage is stored in a serialized way, therefore
        // RMMessage content must be splitted into soap root message
        // and attachments
        PersistenceUtils.decodeRMContent(m, message);
        RMContextUtils.setProtocolVariation(message, ss.getProtocol());
        retransmissionQueue.addUnacknowledged(message);
      } catch (IOException e) {
        LOG.log(Level.SEVERE, "Error reading persisted message data", e);
      }
    }
  }
Ejemplo n.º 2
0
  void recoverReliableEndpoint(Endpoint endpoint, Conduit conduit) {
    if (null == store || null == retransmissionQueue) {
      return;
    }

    String id = RMUtils.getEndpointIdentifier(endpoint, getBus());

    Collection<SourceSequence> sss = store.getSourceSequences(id);
    Collection<DestinationSequence> dss = store.getDestinationSequences(id);
    if ((null == sss || 0 == sss.size()) && (null == dss || 0 == dss.size())) {
      return;
    }
    LOG.log(Level.FINE, "Number of source sequences: {0}", sss.size());
    LOG.log(Level.FINE, "Number of destination sequences: {0}", dss.size());

    LOG.log(
        Level.FINE,
        "Recovering {0} endpoint with id: {1}",
        new Object[] {null == conduit ? "client" : "server", id});
    RMEndpoint rme = createReliableEndpoint(endpoint);
    rme.initialise(getConfiguration(), conduit, null, null, null);
    synchronized (reliableEndpoints) {
      reliableEndpoints.put(endpoint, rme);
    }
    for (SourceSequence ss : sss) {
      recoverSourceSequence(endpoint, conduit, rme.getSource(), ss);
    }

    for (DestinationSequence ds : dss) {
      reconverDestinationSequence(endpoint, conduit, rme.getDestination(), ds);
    }
    retransmissionQueue.start();
  }
Ejemplo n.º 3
0
 /**
  * Convert wsrm:SequenceAcknowledgement to 200502 version with 200408 WS-Addressing namespace.
  *
  * @param internal (non-<code>null</code>)
  * @return converted
  */
 public static org.apache.cxf.ws.rm.v200502.AckRequestedType convert200502(
     AckRequestedType internal) {
   org.apache.cxf.ws.rm.v200502.AckRequestedType exposed =
       RMUtils.getWSRM200502Factory().createAckRequestedType();
   exposed.setIdentifier(convert200502(internal.getIdentifier()));
   addAll(internal.getAny(), exposed.getAny());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 4
0
 /**
  * Convert wsrm:Expires to 200502 version with 200408 WS-Addressing namespace.
  *
  * @param internal (may be <code>null</code>)
  * @return converted (<code>null</code> if internal is <code>null</code>)
  */
 private static org.apache.cxf.ws.rm.v200502.Expires convert200502(Expires internal) {
   if (internal == null) {
     return null;
   }
   org.apache.cxf.ws.rm.v200502.Expires exposed = RMUtils.getWSRM200502Factory().createExpires();
   exposed.setValue(internal.getValue());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 5
0
 /**
  * Convert wsrm:SequenceType to 200502 version with 200508 WS-Addressing namespace.
  *
  * @param internal (non-<code>null</code>)
  * @return converted
  */
 public static org.apache.cxf.ws.rm.v200502wsa15.SequenceType convert200502wsa15(
     SequenceType internal) {
   org.apache.cxf.ws.rm.v200502wsa15.SequenceType exposed =
       RMUtils.getWSRM200502WSA200508Factory().createSequenceType();
   exposed.setIdentifier(convert200502wsa15(internal.getIdentifier()));
   exposed.setMessageNumber(internal.getMessageNumber());
   addAll(internal.getAny(), exposed.getAny());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 6
0
 /**
  * Convert wsrm:Identifier to 200502 version with 200408 WS-Addressing namespace.
  *
  * @param internal (may be <code>null</code>)
  * @return converted (<code>null</code> if internal is <code>null</code>)
  */
 public static org.apache.cxf.ws.rm.v200502.Identifier convert200502(Identifier internal) {
   if (internal == null) {
     return null;
   }
   org.apache.cxf.ws.rm.v200502.Identifier exposed =
       RMUtils.getWSRM200502Factory().createIdentifier();
   exposed.setValue(internal.getValue());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 7
0
 /**
  * Convert CreateSequenceType to 200502 version with 200508 WS-Addressing namespace.
  *
  * @param internal (non-<code>null</code>)
  * @return converted
  */
 public static org.apache.cxf.ws.rm.v200502wsa15.CreateSequenceType convert200502wsa15(
     CreateSequenceType internal) {
   org.apache.cxf.ws.rm.v200502wsa15.CreateSequenceType exposed =
       RMUtils.getWSRM200502WSA200508Factory().createCreateSequenceType();
   exposed.setAcksTo(internal.getAcksTo());
   exposed.setExpires(convert200502wsa15(internal.getExpires()));
   exposed.setOffer(convert200502wsa15(internal.getOffer()));
   addAll(internal.getAny(), exposed.getAny());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 8
0
 /**
  * Convert wsrm:CreateSequenceResponseType to 200502 version with 200408 WS-Addressing namespace.
  *
  * @param internal (non-<code>null</code>)
  * @return converted
  */
 public static org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType convert200502(
     CreateSequenceResponseType internal) {
   org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType exposed =
       RMUtils.getWSRM200502Factory().createCreateSequenceResponseType();
   exposed.setIdentifier(convert200502(internal.getIdentifier()));
   exposed.setExpires(convert200502(internal.getExpires()));
   exposed.setAccept(convert200502(internal.getAccept()));
   addAll(internal.getAny(), exposed.getAny());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 9
0
 /**
  * Convert CreateSequenceType to 200502 version with 200408 WS-Addressing namespace.
  *
  * @param internal (non-<code>null</code>)
  * @return converted
  */
 public static org.apache.cxf.ws.rm.v200502.CreateSequenceType convert200502(
     CreateSequenceType internal) {
   org.apache.cxf.ws.rm.v200502.CreateSequenceType exposed =
       RMUtils.getWSRM200502Factory().createCreateSequenceType();
   exposed.setAcksTo(
       org.apache.cxf.ws.addressing.VersionTransformer.convert(internal.getAcksTo()));
   exposed.setExpires(convert200502(internal.getExpires()));
   exposed.setOffer(convert200502(internal.getOffer()));
   addAll(internal.getAny(), exposed.getAny());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 10
0
 /**
  * Convert wsrm:AcceptType to 200502 version with 200408 WS-Addressing namespace.
  *
  * @param internal (may be <code>null</code>)
  * @return converted (<code>null</code> if internal is <code>null</code>)
  */
 private static org.apache.cxf.ws.rm.v200502.AcceptType convert200502(AcceptType internal) {
   if (internal == null) {
     return null;
   }
   org.apache.cxf.ws.rm.v200502.AcceptType exposed =
       RMUtils.getWSRM200502Factory().createAcceptType();
   exposed.setAcksTo(
       org.apache.cxf.ws.addressing.VersionTransformer.convert(internal.getAcksTo()));
   addAll(internal.getAny(), exposed.getAny());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 11
0
 /**
  * Convert wsrm:AcceptType to 200502 version with 200508 WS-Addressing namespace.
  *
  * @param internal (may be <code>null</code>)
  * @return converted (<code>null</code> if internal is <code>null</code>)
  */
 private static org.apache.cxf.ws.rm.v200502wsa15.AcceptType convert200502wsa15(
     AcceptType internal) {
   if (internal == null) {
     return null;
   }
   org.apache.cxf.ws.rm.v200502wsa15.AcceptType exposed =
       RMUtils.getWSRM200502WSA200508Factory().createAcceptType();
   exposed.setAcksTo(internal.getAcksTo());
   addAll(internal.getAny(), exposed.getAny());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 12
0
 /**
  * Convert wsrm:Offer to 200502 version with 200408 WS-Addressing namespace.
  *
  * @param internal (may be <code>null</code>)
  * @return converted (<code>null</code> if internal is <code>null</code>)
  */
 private static org.apache.cxf.ws.rm.v200502.OfferType convert200502(OfferType internal) {
   if (internal == null) {
     return null;
   }
   org.apache.cxf.ws.rm.v200502.OfferType exposed =
       RMUtils.getWSRM200502Factory().createOfferType();
   exposed.setExpires(convert200502(internal.getExpires()));
   exposed.setIdentifier(convert200502(internal.getIdentifier()));
   addAll(internal.getAny(), exposed.getAny());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 13
0
 public void clientCreated(final Client client) {
   if (null == store || null == retransmissionQueue) {
     return;
   }
   String id = RMUtils.getEndpointIdentifier(client.getEndpoint(), getBus());
   Collection<SourceSequence> sss = store.getSourceSequences(id /*, protocol*/);
   if (null == sss || 0 == sss.size()) {
     return;
   }
   LOG.log(Level.FINE, "Number of source sequences: {0}", sss.size());
   recoverReliableEndpoint(client.getEndpoint(), client.getConduit() /*, protocol*/);
 }
Ejemplo n.º 14
0
 /**
  * Convert wsrm:SequenceAcknowledgement to 200502 version with 200408 WS-Addressing namespace.
  *
  * @param internal (non-<code>null</code>)
  * @return converted
  */
 public static org.apache.cxf.ws.rm.v200502.SequenceAcknowledgement convert200502(
     SequenceAcknowledgement internal) {
   org.apache.cxf.ws.rm.v200502.SequenceAcknowledgement exposed =
       RMUtils.getWSRM200502Factory().createSequenceAcknowledgement();
   exposed.setIdentifier(convert200502(internal.getIdentifier()));
   List<org.apache.cxf.ws.rm.v200502.SequenceAcknowledgement.AcknowledgementRange> exposedRanges =
       exposed.getAcknowledgementRange();
   for (SequenceAcknowledgement.AcknowledgementRange range : internal.getAcknowledgementRange()) {
     org.apache.cxf.ws.rm.v200502.SequenceAcknowledgement.AcknowledgementRange exposedRange =
         new org.apache.cxf.ws.rm.v200502.SequenceAcknowledgement.AcknowledgementRange();
     exposedRange.setLower(range.getLower());
     exposedRange.setUpper(range.getUpper());
     exposedRanges.add(exposedRange);
     putAll(range.getOtherAttributes(), exposedRange.getOtherAttributes());
   }
   addAll(internal.getAny(), exposed.getAny());
   putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
   return exposed;
 }
Ejemplo n.º 15
0
  public SourceSequence getSequence(Identifier inSeqId, Message message, AddressingProperties maps)
      throws RMException {

    Source source = getSource(message);
    SourceSequence seq = source.getCurrent(inSeqId);
    RMConfiguration config = getEffectiveConfiguration(message);
    if (null == seq || seq.isExpired()) {
      // TODO: better error handling
      EndpointReferenceType to = null;
      boolean isServer = RMContextUtils.isServerSide(message);
      EndpointReferenceType acksTo = null;
      RelatesToType relatesTo = null;
      if (isServer) {
        AddressingProperties inMaps = RMContextUtils.retrieveMAPs(message, false, false);
        inMaps.exposeAs(config.getAddressingNamespace());
        acksTo = RMUtils.createReference(inMaps.getTo().getValue());
        to = inMaps.getReplyTo();
        source.getReliableEndpoint().getServant().setUnattachedIdentifier(inSeqId);
        relatesTo = (new org.apache.cxf.ws.addressing.ObjectFactory()).createRelatesToType();
        Destination destination = getDestination(message);
        DestinationSequence inSeq = inSeqId == null ? null : destination.getSequence(inSeqId);
        relatesTo.setValue(inSeq != null ? inSeq.getCorrelationID() : null);

      } else {
        to = RMUtils.createReference(maps.getTo().getValue());
        acksTo = maps.getReplyTo();
        if (RMUtils.getAddressingConstants().getNoneURI().equals(acksTo.getAddress().getValue())) {
          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);
          if (null == dest) {
            acksTo = RMUtils.createAnonymousReference();
          } else {
            acksTo = dest.getAddress();
          }
        }
      }

      if (ContextUtils.isGenericAddress(to)) {
        org.apache.cxf.common.i18n.Message msg =
            new org.apache.cxf.common.i18n.Message(
                "CREATE_SEQ_ANON_TARGET",
                LOG,
                to != null && to.getAddress() != null ? to.getAddress().getValue() : null);
        LOG.log(Level.INFO, msg.toString());
        throw new RMException(msg);
      }
      Proxy proxy = source.getReliableEndpoint().getProxy();
      ProtocolVariation protocol = config.getProtocolVariation();
      Exchange exchange = new ExchangeImpl();
      Map<String, Object> context = new HashMap<String, Object>(16);
      for (String key : message.getContextualPropertyKeys()) {
        // copy other properties?
        if (key.startsWith("ws-security")) {
          context.put(key, message.getContextualProperty(key));
        }
      }

      CreateSequenceResponseType createResponse =
          proxy.createSequence(acksTo, relatesTo, isServer, protocol, exchange, context);
      if (!isServer) {
        Servant servant = source.getReliableEndpoint().getServant();
        servant.createSequenceResponse(createResponse, protocol);

        // propagate security properties to application endpoint, in case we're using
        // WS-SecureConversation
        Exchange appex = message.getExchange();
        if (appex.get(SecurityConstants.TOKEN) == null) {
          appex.put(SecurityConstants.TOKEN, exchange.get(SecurityConstants.TOKEN));
          appex.put(SecurityConstants.TOKEN_ID, exchange.get(SecurityConstants.TOKEN_ID));
        }
      }

      seq = source.awaitCurrent(inSeqId);
      seq.setTarget(to);
    }

    return seq;
  }