Package net.jini.core.transaction

Examples of net.jini.core.transaction.Transaction


    public void run() throws Exception {
        SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 1);
        SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 2);
        SimpleEntry sampleEntry3 = new SimpleEntry("TestEntry #1", 2);
        SimpleEntry template;
        Transaction txn;
        String msg;

        // first check that space is empty
        if (!checkSpace(space)) {
            throw new TestException("Space is not empty in the beginning.");
View Full Code Here


     */
    public void run() throws Exception {
        SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 1);
        SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 2);
        SimpleEntry result;
        Transaction txn;
        long curTime1;
        long curTime2;
        long leaseTime;

        // first check that space is empty
View Full Code Here

     * section 3.1.</P>
     */
    public void run() throws Exception {
        SimpleEntry sampleEntry = new SimpleEntry("TestEntry #1", 1);
        SimpleEntry result;
        Transaction txn1;
        Transaction txn2;

        // first check that space is empty
        if (!checkSpace(space)) {
            throw new TestException(
                    "Space is not empty in the beginning.");
View Full Code Here

    public void run() throws Exception {
        SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 1);
        SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 2);
        SimpleEntry sampleEntry3 = new SimpleEntry("TestEntry #1", 2);
        SimpleEntry template;
        Transaction txn;
        String msg;

        // first check that space is empty
        if (!checkSpace(space)) {
            throw new TestException("Space is not empty in the beginning.");
View Full Code Here

            -8999, -15000, -16000000, Long.MIN_VALUE, -3 };
        SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 1);
        SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 2);
        SimpleEntry sampleEntry3 = new SimpleEntry("TestEntry #1", 2);
        SimpleEntry template;
        Transaction txn;

        // first check that space is empty
        if (!checkSpace(space)) {
            throw new TestException("Space is not empty in the beginning.");
        }
View Full Code Here

     */
    public void run() throws Exception {
        SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 1);
        SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 2);
        SimpleEntry result;
        Transaction txn;

        // first check that space is empty
        if (!checkSpace(space)) {
            throw new TestException(
                    "Space is not empty in the beginning.");
View Full Code Here

    public void run() throws Exception {
        SimpleEntry sampleEntry1 = new SimpleEntry("TestEntry #1", 1);
        SimpleEntry sampleEntry2 = new SimpleEntry("TestEntry #2", 2);
        SimpleEntry sampleEntry3 = new SimpleEntry("TestEntry #1", 2);
        SimpleEntry template;
        Transaction txn;
        String msg;

        // first check that space is empty
        if (!checkSpace(space)) {
            throw new TestException("Space is not empty in the beginning.");
View Full Code Here

        }

        if (entry == null) {
            LOG.warn("No payload for exchange: " + exchange);
        } else {
            Transaction tnx = null;
            if (transactionHelper != null) {
                tnx = transactionHelper.getJiniTransaction(transactionTimeout).transaction;
            }
            if (LOG.isDebugEnabled()) {
                LOG.debug("Writing body : " + entry);
            }
            javaSpace.write(entry, tnx, Lease.FOREVER);

            if (ExchangeHelper.isOutCapable(exchange)) {
                OutEntry tmpl = new OutEntry();
                tmpl.correlationId = ((InEntry) entry).correlationId;

                OutEntry replyCamelEntry = null;
                while (replyCamelEntry == null) {
                    replyCamelEntry = (OutEntry) javaSpace.take(tmpl, tnx, 100);
                }

                Object obj;
                if (replyCamelEntry.binary) {
                    obj = replyCamelEntry.buffer;
                } else {
                    ByteArrayInputStream bis = new ByteArrayInputStream(replyCamelEntry.buffer);
                    ObjectInputStream ois = new ObjectInputStream(bis);
                    obj = ois.readObject();
                }
                exchange.getOut().setBody(obj);
            }
            if (tnx != null) {
                tnx.commit();
            }
        }
    }
View Full Code Here

            this.template = javaSpace.snapshot(new InEntry());
        }
    }

    public void run() {
        Transaction tnx = null;
        try {
            DefaultExchange exchange = (DefaultExchange) endpoint.createExchange(ExchangePattern.InOut);
            Message message = exchange.getIn();
            if (transactionHelper != null) {
                tnx = transactionHelper.getJiniTransaction(transactionTimeout).transaction;
            }
            Entry entry = null;
            switch (verb) {
            case JavaSpaceConsumer.TAKE:
                entry = javaSpace.take(template, tnx, 100);
                break;
            case JavaSpaceConsumer.READ:
                entry = javaSpace.read(template, tnx, 100);
                break;
            default:
                throw new RuntimeCamelException("Wrong verb");
            }
            if (entry != null) {
                if (entry instanceof InEntry) {
                    if (((InEntry) entry).binary) {
                        message.setBody(((InEntry) entry).buffer);
                    } else {
                        ByteArrayInputStream bis = new ByteArrayInputStream(((InEntry) entry).buffer);
                        ObjectInputStream ois = new ObjectInputStream(bis);
                        Object obj = ois.readObject();
                        message.setBody(obj);
                    }
                    processor.process(exchange);
                    Message out = exchange.getOut();
                    if (out.getBody() != null && ExchangeHelper.isOutCapable(exchange)) {
                        OutEntry replyCamelEntry = new OutEntry();
                        replyCamelEntry.correlationId = ((InEntry) entry).correlationId;
                        if (out.getBody() instanceof byte[]) {
                            replyCamelEntry.binary = true;
                            replyCamelEntry.buffer = (byte[]) out.getBody();
                        } else {
                            ByteArrayOutputStream bos = new ByteArrayOutputStream();
                            ObjectOutputStream oos = new ObjectOutputStream(bos);
                            oos.writeObject(out.getBody());
                            replyCamelEntry.binary = false;
                            replyCamelEntry.buffer = bos.toByteArray();
                        }
                        javaSpace.write(replyCamelEntry, tnx, Lease.FOREVER);
                    }
                } else {
                    message.setBody(entry, Entry.class);
                    processor.process(exchange);
                }
            }

        } catch (Exception e) {
            if (tnx != null) {
                try {
                    tnx.abort();
                } catch (UnknownTransactionException e1) {
                    throw new RuntimeCamelException(e1);
                } catch (CannotAbortException e1) {
                    throw new RuntimeCamelException(e1);
                } catch (RemoteException e1) {
                    throw new RuntimeCamelException(e1);
                }
            }
            throw new RuntimeCamelException(e);
        } finally {
            if (tnx != null) {
                try {
                    tnx.commit();
                } catch (UnknownTransactionException e1) {
                    throw new RuntimeCamelException(e1);
                } catch (RemoteException e1) {
                    throw new RuntimeCamelException(e1);
                } catch (CannotCommitException e1) {
View Full Code Here

        }

        if (entry == null) {
            LOG.warn("No payload for exchange: " + exchange);
        } else {
            Transaction tnx = null;
            if (transactionHelper != null) {
                tnx = transactionHelper.getJiniTransaction(transactionTimeout).transaction;
            }
            if (LOG.isDebugEnabled()) {
                LOG.debug("Writing body : " + entry);
            }
            javaSpace.write(entry, tnx, Lease.FOREVER);

            if (ExchangeHelper.isOutCapable(exchange)) {
                OutEntry tmpl = new OutEntry();
                tmpl.correlationId = ((InEntry) entry).correlationId;

                OutEntry replyCamelEntry = null;
                while (replyCamelEntry == null) {
                    replyCamelEntry = (OutEntry) javaSpace.take(tmpl, tnx, 100);
                }

                Object obj;
                if (replyCamelEntry.binary) {
                    obj = replyCamelEntry.buffer;
                } else {
                    ByteArrayInputStream bis = new ByteArrayInputStream(replyCamelEntry.buffer);
                    ObjectInputStream ois = new ObjectInputStream(bis);
                    obj = ois.readObject();
                }
                exchange.getOut().setBody(obj);
            }
            if (tnx != null) {
                tnx.commit();
            }
        }
    }
View Full Code Here

TOP

Related Classes of net.jini.core.transaction.Transaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.