Search in sources :

Example 61 with Identifier

use of org.apache.cxf.ws.rm.v200502.Identifier in project cxf by apache.

the class RMTxStore method createSourceSequence.

public void createSourceSequence(SourceSequence seq) {
    String sequenceIdentifier = seq.getIdentifier().getValue();
    String endpointIdentifier = seq.getEndpointIdentifier();
    String protocolVersion = encodeProtocolVersion(seq.getProtocol());
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Creating source sequence: " + sequenceIdentifier + ", (endpoint: " + endpointIdentifier + ")");
    }
    Connection con = verifyConnection();
    PreparedStatement stmt = null;
    SQLException conex = null;
    try {
        beginTransaction();
        stmt = getStatement(con, CREATE_SRC_SEQUENCE_STMT_STR);
        stmt.setString(1, sequenceIdentifier);
        Date expiry = seq.getExpires();
        stmt.setLong(2, expiry == null ? 0 : expiry.getTime());
        Identifier osid = seq.getOfferingSequenceIdentifier();
        stmt.setString(3, osid == null ? null : osid.getValue());
        stmt.setString(4, endpointIdentifier);
        stmt.setString(5, protocolVersion);
        stmt.execute();
        commit(con);
    } catch (SQLException ex) {
        conex = ex;
        abort(con);
        throw new RMStoreException(ex);
    } finally {
        releaseResources(stmt, null);
        updateConnectionState(con, conex);
    }
}
Also used : RMStoreException(org.apache.cxf.ws.rm.persistence.RMStoreException) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) Date(java.util.Date)

Example 62 with Identifier

use of org.apache.cxf.ws.rm.v200502.Identifier in project cxf by apache.

the class RMTxStore method getDestinationSequences.

public Collection<DestinationSequence> getDestinationSequences(String endpointIdentifier) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.info("Getting destination sequences for endpoint: " + endpointIdentifier);
    }
    Connection con = verifyConnection();
    PreparedStatement stmt = null;
    SQLException conex = null;
    Collection<DestinationSequence> seqs = new ArrayList<>();
    ResultSet res = null;
    try {
        stmt = getStatement(con, SELECT_DEST_SEQUENCES_STMT_STR);
        stmt.setString(1, endpointIdentifier);
        res = stmt.executeQuery();
        while (res.next()) {
            Identifier sid = new Identifier();
            sid.setValue(res.getString(1));
            EndpointReferenceType acksTo = RMUtils.createReference(res.getString(2));
            long lm = res.getLong(3);
            ProtocolVariation pv = decodeProtocolVersion(res.getString(4));
            boolean t = res.getBoolean(5);
            InputStream is = res.getBinaryStream(6);
            SequenceAcknowledgement ack = null;
            if (null != is) {
                ack = PersistenceUtils.getInstance().deserialiseAcknowledgment(is);
            }
            DestinationSequence seq = new DestinationSequence(sid, acksTo, lm, t, ack, pv);
            seqs.add(seq);
        }
    } catch (SQLException ex) {
        conex = ex;
        LOG.log(Level.WARNING, new Message("SELECT_DEST_SEQ_FAILED_MSG", LOG).toString(), ex);
    } finally {
        releaseResources(stmt, res);
        updateConnectionState(con, conex);
    }
    return seqs;
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Message(org.apache.cxf.common.i18n.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) SQLException(java.sql.SQLException) InputStream(java.io.InputStream) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ResultSet(java.sql.ResultSet) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Example 63 with Identifier

use of org.apache.cxf.ws.rm.v200502.Identifier in project cxf by apache.

the class RMTxStore method getSourceSequences.

public Collection<SourceSequence> getSourceSequences(String endpointIdentifier) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.info("Getting source sequences for endpoint: " + endpointIdentifier);
    }
    Connection con = verifyConnection();
    PreparedStatement stmt = null;
    SQLException conex = null;
    Collection<SourceSequence> seqs = new ArrayList<>();
    ResultSet res = null;
    try {
        stmt = getStatement(con, SELECT_SRC_SEQUENCES_STMT_STR);
        stmt.setString(1, endpointIdentifier);
        res = stmt.executeQuery();
        while (res.next()) {
            Identifier sid = new Identifier();
            sid.setValue(res.getString(1));
            long cmn = res.getLong(2);
            boolean lm = res.getBoolean(3);
            long lval = res.getLong(4);
            Date expiry = 0 == lval ? null : new Date(lval);
            String oidValue = res.getString(5);
            Identifier oi = null;
            if (null != oidValue) {
                oi = new Identifier();
                oi.setValue(oidValue);
            }
            ProtocolVariation pv = decodeProtocolVersion(res.getString(6));
            SourceSequence seq = new SourceSequence(sid, expiry, oi, cmn, lm, pv);
            seqs.add(seq);
        }
    } catch (SQLException ex) {
        conex = ex;
        // ignore
        LOG.log(Level.WARNING, new Message("SELECT_SRC_SEQ_FAILED_MSG", LOG).toString(), ex);
    } finally {
        releaseResources(stmt, res);
        updateConnectionState(con, conex);
    }
    return seqs;
}
Also used : Message(org.apache.cxf.common.i18n.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Date(java.util.Date) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ResultSet(java.sql.ResultSet) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Example 64 with Identifier

use of org.apache.cxf.ws.rm.v200502.Identifier in project cxf by apache.

the class RetransmissionQueueImpl method purgeCandidates.

private void purgeCandidates(SourceSequence seq, boolean any) {
    Collection<Long> purged = new ArrayList<>();
    Collection<ResendCandidate> resends = new ArrayList<>();
    Identifier sid = seq.getIdentifier();
    synchronized (this) {
        LOG.fine("Start purging resend candidates.");
        List<ResendCandidate> sequenceCandidates = getSequenceCandidates(seq);
        if (null != sequenceCandidates) {
            for (int i = sequenceCandidates.size() - 1; i >= 0; i--) {
                ResendCandidate candidate = sequenceCandidates.get(i);
                long m = candidate.getNumber();
                if (any || seq.isAcknowledged(m)) {
                    sequenceCandidates.remove(i);
                    candidate.resolved();
                    unacknowledgedCount--;
                    purged.add(m);
                    resends.add(candidate);
                }
            }
            if (sequenceCandidates.isEmpty()) {
                candidates.remove(sid.getValue());
            }
        }
        LOG.fine("Completed purging resend candidates.");
    }
    if (!purged.isEmpty()) {
        RMStore store = manager.getStore();
        if (null != store) {
            store.removeMessages(sid, purged, true);
        }
        RMEndpoint rmEndpoint = seq.getSource().getReliableEndpoint();
        for (ResendCandidate resend : resends) {
            rmEndpoint.handleAcknowledgment(sid.getValue(), resend.getNumber(), resend.getMessage());
        }
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ArrayList(java.util.ArrayList) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint) Endpoint(org.apache.cxf.endpoint.Endpoint)

Example 65 with Identifier

use of org.apache.cxf.ws.rm.v200502.Identifier in project cxf by apache.

the class AbstractEndpointTest method testGenerateSequenceIdentifier.

@Test
public void testGenerateSequenceIdentifier() {
    RMManager mgr = control.createMock(RMManager.class);
    EasyMock.expect(rme.getManager()).andReturn(mgr);
    SequenceIdentifierGenerator generator = control.createMock(SequenceIdentifierGenerator.class);
    EasyMock.expect(mgr.getIdGenerator()).andReturn(generator);
    Identifier id = control.createMock(Identifier.class);
    EasyMock.expect(generator.generateSequenceIdentifier()).andReturn(id);
    control.replay();
    AbstractEndpoint tested = new AbstractEndpoint(rme);
    assertSame(id, tested.generateSequenceIdentifier());
    control.verify();
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Test(org.junit.Test)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 Test (org.junit.Test)40 ArrayList (java.util.ArrayList)11 Message (org.apache.cxf.message.Message)11 SourceSequence (org.apache.cxf.ws.rm.SourceSequence)11 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)11 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)11 Connection (java.sql.Connection)9 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)8 SQLException (java.sql.SQLException)7 Date (java.util.Date)7 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)7 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)7 Method (java.lang.reflect.Method)6 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)6 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)6 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)6 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)5 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)5 PreparedStatement (java.sql.PreparedStatement)4