Search in sources :

Example 1 with RMTxStore

use of org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore in project jbossws-cxf by jbossws.

the class RMStoreFeature method initializeProvider.

protected void initializeProvider(InterceptorProvider provider, Bus bus) {
    String dataSource = serverDataSource;
    RMTxStore rmStore = new RMDataSourceStore();
    if (provider instanceof Client) {
        try {
            Connection con = DriverManager.getConnection("jdbc:derby:./target/wsrmdb;create=true", rmStore.getUserName(), rmStore.getPassword());
            rmStore.setConnection(con);
        } catch (SQLException e) {
            Loggers.ROOT_LOGGER.log(Level.FATAL, "Can't create connection from " + rmStore.getUrl(), e);
            throw new WSFException(e);
        }
    } else {
        // server side
        if (ctx == null) {
            try {
                ctx = new InitialContext();
                DataSource rmDs = (DataSource) ctx.lookup(dataSource);
                rmStore.setDataSource(rmDs);
            } catch (NamingException e) {
                Loggers.DEPLOYMENT_LOGGER.log(Level.FATAL, "Can't create datasource with " + dataSource, e);
                throw new WSFException(e);
            }
        }
    }
    rmStore.init();
    this.setStore(rmStore);
    // force to use RM11 and it can only work with wsa200508 (http://www.w3.org/2005/08/addressing) which is enabled with @Addressing
    this.setRMNamespace(RM11Constants.NAMESPACE_URI);
    RMAssertion assertion = new RMAssertion();
    BaseRetransmissionInterval retransMissionInveral = new BaseRetransmissionInterval();
    retransMissionInveral.setMilliseconds(10000L);
    assertion.setBaseRetransmissionInterval(retransMissionInveral);
    this.setRMAssertion(assertion);
    super.initializeProvider(provider, bus);
}
Also used : SQLException(java.sql.SQLException) RMAssertion(org.apache.cxf.ws.rmp.v200502.RMAssertion) BaseRetransmissionInterval(org.apache.cxf.ws.rmp.v200502.RMAssertion.BaseRetransmissionInterval) Connection(java.sql.Connection) WSFException(org.jboss.wsf.spi.WSFException) NamingException(javax.naming.NamingException) Client(org.apache.cxf.endpoint.Client) RMTxStore(org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore) InitialContext(javax.naming.InitialContext) DataSource(javax.sql.DataSource)

Aggregations

Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 InitialContext (javax.naming.InitialContext)1 NamingException (javax.naming.NamingException)1 DataSource (javax.sql.DataSource)1 Client (org.apache.cxf.endpoint.Client)1 RMTxStore (org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore)1 RMAssertion (org.apache.cxf.ws.rmp.v200502.RMAssertion)1 BaseRetransmissionInterval (org.apache.cxf.ws.rmp.v200502.RMAssertion.BaseRetransmissionInterval)1 WSFException (org.jboss.wsf.spi.WSFException)1