Search in sources :

Example 16 with SourceSequence

use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.

the class RMTxStore method getSourceSequence.

public SourceSequence getSourceSequence(Identifier sid) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.info("Getting source sequences for id: " + sid);
    }
    Connection con = verifyConnection();
    PreparedStatement stmt = null;
    SQLException conex = null;
    ResultSet res = null;
    try {
        stmt = getStatement(con, SELECT_SRC_SEQUENCE_STMT_STR);
        stmt.setString(1, sid.getValue());
        res = stmt.executeQuery();
        if (res.next()) {
            long cmn = res.getLong(1);
            boolean lm = res.getBoolean(2);
            long lval = res.getLong(3);
            Date expiry = 0 == lval ? null : new Date(lval);
            String oidValue = res.getString(4);
            Identifier oi = null;
            if (null != oidValue) {
                oi = RMUtils.getWSRMFactory().createIdentifier();
                oi.setValue(oidValue);
            }
            ProtocolVariation pv = decodeProtocolVersion(res.getString(5));
            return new SourceSequence(sid, expiry, oi, cmn, lm, pv);
        }
    } 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 null;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Message(org.apache.cxf.common.i18n.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Date(java.util.Date) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Example 17 with SourceSequence

use of org.apache.cxf.ws.rm.SourceSequence 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 18 with SourceSequence

use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.

the class AbstractClientPersistenceTest method verifyRecovery.

void verifyRecovery() throws Exception {
    RMManager manager = bus.getExtension(RMManager.class);
    assertNotNull(manager);
    RMStore store = manager.getStore();
    assertNotNull(store);
    Client client = ClientProxy.getClient(greeter);
    String id = RMUtils.getEndpointIdentifier(client.getEndpoint());
    Collection<DestinationSequence> dss = store.getDestinationSequences(id);
    assertEquals(1, dss.size());
    Collection<SourceSequence> sss = store.getSourceSequences(id);
    assertEquals(1, sss.size());
    int i = 0;
    while (store.getMessages(sss.iterator().next().getIdentifier(), true).size() > 0 && i < 10) {
        Thread.sleep(200);
        i++;
    }
    assertEquals(0, store.getMessages(sss.iterator().next().getIdentifier(), true).size());
    assertEquals(0, store.getMessages(sss.iterator().next().getIdentifier(), false).size());
}
Also used : DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) RMManager(org.apache.cxf.ws.rm.RMManager) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) Client(org.apache.cxf.endpoint.Client) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Endpoint(javax.xml.ws.Endpoint)

Example 19 with SourceSequence

use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.

the class AbstractClientPersistenceTest method verifyStorePopulation.

void verifyStorePopulation() {
    RMManager manager = bus.getExtension(RMManager.class);
    assertNotNull(manager);
    RMStore store = manager.getStore();
    assertNotNull(store);
    Client client = ClientProxy.getClient(greeter);
    String id = RMUtils.getEndpointIdentifier(client.getEndpoint());
    Collection<DestinationSequence> dss = store.getDestinationSequences(id);
    assertEquals(1, dss.size());
    Collection<SourceSequence> sss = store.getSourceSequences(id);
    assertEquals(1, sss.size());
    Collection<RMMessage> msgs = store.getMessages(sss.iterator().next().getIdentifier(), true);
    assertEquals(2, msgs.size());
    msgs = store.getMessages(sss.iterator().next().getIdentifier(), false);
    assertEquals(0, msgs.size());
}
Also used : DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) RMManager(org.apache.cxf.ws.rm.RMManager) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) Client(org.apache.cxf.endpoint.Client) SourceSequence(org.apache.cxf.ws.rm.SourceSequence)

Aggregations

SourceSequence (org.apache.cxf.ws.rm.SourceSequence)19 Test (org.junit.Test)12 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)11 ArrayList (java.util.ArrayList)6 Connection (java.sql.Connection)4 SQLException (java.sql.SQLException)4 Date (java.util.Date)4 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)4 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)4 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)3 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 Message (org.apache.cxf.common.i18n.Message)2 Client (org.apache.cxf.endpoint.Client)2 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)2 RMManager (org.apache.cxf.ws.rm.RMManager)2 RMStoreException (org.apache.cxf.ws.rm.persistence.RMStoreException)2 Endpoint (javax.xml.ws.Endpoint)1 RMEndpoint (org.apache.cxf.ws.rm.RMEndpoint)1