Package org.wildfly.clustering.ee

Examples of org.wildfly.clustering.ee.Batch


    @Override
    public V create() {
        boolean newGroup = false;
        boolean success = false;
        UUID group = CURRENT_GROUP.get();
        Batch batch = this.manager.getBatcher().createBatch();
        try {
            if (group == null) {
                newGroup = true;
                group = this.manager.getGroupIdentifierFactory().createIdentifier();
                CURRENT_GROUP.set(group);
            }

            try {
                // This will invoke Cache.create() for nested beans
                // Nested beans will share the same group identifier
                V instance = this.factory.createInstance();
                K id = instance.getId();
                this.manager.createBean(id, group, instance).close();
                success = true;
                return instance;
            } finally {
                if (newGroup) {
                    CURRENT_GROUP.remove();
                }
            }
        } finally {
            if (success) {
                batch.close();
            } else {
                batch.discard();
            }
        }
    }
View Full Code Here


        }
    }

    @Override
    public V get(K id) {
        Batch batch = this.manager.getBatcher().createBatch();
        try {
            Bean<UUID, K, V> bean = this.manager.findBean(id);
            if (bean == null) {
                batch.close();
                return null;
            }
            V result = bean.acquire();
            result.setCacheContext(batch);
            return result;
        } catch (RuntimeException | Error e) {
            batch.discard();
            throw e;
        }
    }
View Full Code Here

        }

        @Override
        public boolean startBatch() {
            if (this.batcher == null) return false;
            Batch batch = CURRENT_BATCH.get();
            if (batch != null) return false;
            CURRENT_BATCH.set(this.batcher.createBatch());
            return true;
        }
View Full Code Here

            return true;
        }

        @Override
        public void endBatch(boolean successful) {
            Batch batch = CURRENT_BATCH.get();
            if (batch != null) {
                try {
                    if (successful) {
                        batch.close();
                    } else {
                        batch.discard();
                    }
                } finally {
                    CURRENT_BATCH.remove();
                }
            }
View Full Code Here

        this.id = id;
    }

    @Override
    public Void execute(BeanEvictionContext<I> context) throws Exception {
        Batch batch = context.getBatcher().createBatch();
        boolean success = false;
        try {
            InfinispanEjbLogger.ROOT_LOGGER.tracef("Evicting stateful session bean %s", this.id);
            context.getEvictor().evict(this.id);
            success = true;
        } finally {
            if (success) {
                batch.close();
            } else {
                batch.discard();
            }
        }
        return null;
    }
View Full Code Here

        @Override
        public void run() {
            InfinispanEjbLogger.ROOT_LOGGER.tracef("Expiring stateful session bean %s", this.id);
            try {
                Batch batch = BeanExpirationScheduler.this.batcher.createBatch();
                boolean success = false;
                try {
                    BeanExpirationScheduler.this.remover.remove(this.id, BeanExpirationScheduler.this.expiration.getRemoveListener());
                    success = true;
                } catch (Throwable e) {
                    InfinispanEjbLogger.ROOT_LOGGER.failedToExpireBean(e, this.id);
                } finally {
                    if (success) {
                        batch.close();
                    } else {
                        batch.discard();
                    }
                }
            } finally {
                synchronized (this) {
                    BeanExpirationScheduler.this.expirationFutures.remove(this.id);
View Full Code Here

                return new Handle() {
                    @Override
                    public void tearDown() {
                        // If the session was closed from an async context, the session batch may still be associated with the initial request thread
                        // We suspend the active batch, if present, otherwise the transaction associated with this thread may leak into a subsequent request.
                        Batch batch = manager.getBatcher().suspendBatch();
                        if (batch != null) {
                            UndertowLogger.REQUEST_LOGGER.tracef("Suspending residual active batch: %s", batch);
                        }
                    }
                };
View Full Code Here

    }

    @Override
    public SingleSignOn createSingleSignOn(Account account, String mechanism) {
        String id = this.manager.createIdentifier();
        Batch batch = this.manager.getBatcher().createBatch();
        AuthenticatedSession session = new AuthenticatedSession(account, mechanism);
        SSO<AuthenticatedSession, String, Void> sso = this.manager.createSSO(id, session);
        return new DistributableSingleSignOn(sso, this.registry, batch);
    }
View Full Code Here

        return new DistributableSingleSignOn(sso, this.registry, batch);
    }

    @Override
    public SingleSignOn findSingleSignOn(String id) {
        Batch batch = this.manager.getBatcher().createBatch();
        SSO<AuthenticatedSession, String, Void> sso = this.manager.findSSO(id);
        if (sso == null) {
            batch.discard();
            return null;
        }
        return new DistributableSingleSignOn(sso, this.registry, batch);
    }
View Full Code Here

        return new DistributableSingleSignOn(sso, this.registry, batch);
    }

    @Override
    public void removeSingleSignOn(String id) {
        Batch batch = this.manager.getBatcher().createBatch();
        SSO<AuthenticatedSession, String, Void> sso = this.manager.findSSO(id);
        if (sso != null) {
            sso.invalidate();
            batch.close();
        } else {
            batch.discard();
        }
    }
View Full Code Here

TOP

Related Classes of org.wildfly.clustering.ee.Batch

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.