@Override public final <V> V perform(final Callable<V> method) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Handling @Atomic call from " + Thread.currentThread().getStackTrace()[2]); } TransactionManager tm = FenixFramework.getTransactionManager(); return tm.withTransaction(method, this.atomic); } }
public static void atomic(final Runnable runnable) { getTransactionManager().withTransaction(new CallableWithoutException<Void>() { @Override public Void call() { runnable.run(); return null; } }); }
public static <T> T atomic(Callable<T> callable) throws Exception { return getTransactionManager().withTransaction(callable); }
public static Transaction getTransaction() { return getTransactionManager().getTransaction(); }
private static void initializeInstallationData() { getTransactionManager().withTransaction(new CallableWithoutException<Void>() { @Override public Void call() { InstallationData data = getDomainRoot().getInstallationData(); if (data == null) { data = new InstallationData(getDomainRoot()); } // In the future, automatic upgrade hooks may be invoked here data.updateModuleData(getProject()); return null; } }); }
@Override protected void init() { super.init(); URL hibernateSearchConfigURL = Thread.currentThread().getContextClassLoader().getResource(CONFIG_FILE); if (hibernateSearchConfigURL == null) { logger.info("Resource '" + CONFIG_FILE + "' not found. Hibernate Search disabled"); return; } logger.info("Using config resource: " + hibernateSearchConfigURL); Properties properties = new Properties(); try { properties.load(hibernateSearchConfigURL.openStream()); } catch (IOException e) { logger.error("Hibernate Search unable to create properties. Hibernate Search disabled", e); } // Ensure TxIntrospector is available if (!TxStats.ENABLED) { logger.error("TxIntrospector is disabled!" + " -> Module Hibernate-search will not be available." + " Please enable TxIntrospector and rebuild your application"); return; } HibernateSearchSupport.initializeSearchFactory(properties); // Register our listener FenixFramework.getTransactionManager().addCommitListener(new CommitIndexer()); }
/** * Commits the current, and starts a new write transaction. */ public static void checkpointTransaction() { if (FenixFramework.isInitialized()) { throw new Error("Cannot checkpoint transactions after the framework is initialized."); } try { TransactionManager txManager = FenixFramework.getTransactionManager(); if (txManager.getTransaction() != null) { txManager.commit(); } txManager.begin(false); } catch (Exception e) { logger.error("An error has ocurred while checkpointing the transaction", e); throw new Error(e); } } }