Example usage for javax.ejb TransactionAttributeType NOT_SUPPORTED

List of usage examples for javax.ejb TransactionAttributeType NOT_SUPPORTED

Introduction

In this page you can find the example usage for javax.ejb TransactionAttributeType NOT_SUPPORTED.

Prototype

TransactionAttributeType NOT_SUPPORTED

To view the source code for javax.ejb TransactionAttributeType NOT_SUPPORTED.

Click Source Link

Document

The container invokes an enterprise bean method whose transaction attribute NOT_SUPPORTED with an unspecified transaction context.

Usage

From source file:org.rhq.enterprise.server.storage.StorageClientManager.java

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public long getRequestTimeouts() {
    return session.getTimeouts();
}

From source file:org.rhq.enterprise.server.storage.StorageClientManager.java

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public long getTotalRequests() {
    return session.getTimeouts();
}

From source file:org.rhq.enterprise.server.storage.StorageClientManager.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void persistStorageProperty(String key, String value) {
    if (Boolean.getBoolean("running.itests-2")) {
        // When running itests-2, there is no server props file, so avoid logging a confusing exception
        return;//  w  w  w . ja  va2 s . c  o m
    }
    PropertiesFileUpdate updater = new PropertiesFileUpdate(getServerPropsFile().getAbsolutePath());
    try {
        updater.update(key, value);
    } catch (IOException e) {
        // TODO should we propagate the exception?
        LOG.warn("Failed to persist property " + key + " due to unexpected I/O error",
                ThrowableUtil.getRootCause(e));
    }
}

From source file:org.rhq.enterprise.server.sync.SynchronizationManagerBean.java

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public ExportReport exportAllSubsystems(Subject subject) {
    ExportWrapper localExport = exportAllSubsystemsLocally(subject);

    byte[] buffer = new byte[65536];

    ByteArrayOutputStream out = new ByteArrayOutputStream(10240); //10KB is a reasonable minimum size of an export

    try {/*from www.  j  av a 2s . c om*/
        int cnt = 0;
        while ((cnt = localExport.getExportFile().read(buffer)) != -1) {
            out.write(buffer, 0, cnt);
        }

        return new ExportReport(localExport.getMessagesPerExporter(), out.toByteArray());
    } catch (Exception e) {
        return new ExportReport(e.getMessage());
    } finally {
        try {
            out.close();
        } catch (Exception e) {
            //this doesn't happen - out is backed by just an array
            LOG.error("Closing a byte array output stream failed. This should never happen.");
        }

        try {
            localExport.getExportFile().close();
        } catch (Exception e) {
            LOG.warn("Failed to close the export file stream.", e);
        }
    }
}

From source file:org.rhq.enterprise.server.sync.SynchronizationManagerBean.java

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public ExportWrapper exportAllSubsystemsLocally(Subject subject) {
    Set<Synchronizer<?, ?>> allSynchronizers = getInitializedSynchronizers(subject);
    Map<String, ExporterMessages> messages = new HashMap<String, ExporterMessages>();

    try {//w w  w  . j  a  v a 2 s . c om
        return new ExportWrapper(messages, new ExportingInputStream(allSynchronizers, messages));
    } catch (IOException e) {
        throw new IllegalStateException("Failed to initialize the export.", e);
    }
}

From source file:org.rhq.enterprise.server.system.SystemManagerBean.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public DatabaseType getDatabaseType() {
    Connection conn = null;//from   w  w w. java 2s  . co m
    DatabaseType dbtype = null;
    try {
        conn = dataSource.getConnection();
        dbtype = DatabaseTypeFactory.getDatabaseType(conn);
        return dbtype;
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                log.warn("Failed to close temporary connection", e);
            }
        }
    }
}

From source file:org.rhq.enterprise.server.system.SystemManagerBean.java

@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public long analyze(Subject whoami) {
    Connection conn = null;/*from  w ww .  j ava2s .  c o  m*/
    DatabaseType dbtype = null;
    try {
        conn = dataSource.getConnection();
        dbtype = DatabaseTypeFactory.getDatabaseType(conn);
        if (!DatabaseTypeFactory.isPostgres(dbtype)) {
            return -1;
        }

        long duration = doCommand(dbtype, conn, SQL_ANALYZE, null);
        return duration;
    } catch (Exception e) {
        log.error("Error analyzing database", e);
        throw new RuntimeException("Error analyzing database", e);
    } finally {
        if (dbtype != null) {
            dbtype.closeConnection(conn);
        }
    }
}

From source file:org.rhq.enterprise.server.system.SystemManagerBean.java

@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public long reindex(Subject whoami) {
    Connection conn = null;/*  w  w  w.j a  v a2  s.c  om*/
    DatabaseType dbtype = null;
    try {
        conn = dataSource.getConnection();
        dbtype = DatabaseTypeFactory.getDatabaseType(conn);
        long duration = 0;
        if (DatabaseTypeFactory.isPostgres(dbtype)) {
            for (String table : TABLES_TO_REINDEX) {
                duration += doCommand(dbtype, conn, SQL_REINDEX, table);
            }
        } else if (DatabaseTypeFactory.isOracle(dbtype)) {
            for (String index : ORA_INDEXES_TO_REBUILD) {
                duration += doCommand(dbtype, conn, SQL_REBUILD, index);
            }
        } else {
            return -1;
        }

        return duration;
    } catch (Exception e) {
        log.error("Error reindexing database", e);
        throw new RuntimeException("Error reindexing database", e);
    } finally {
        if (dbtype != null) {
            dbtype.closeConnection(conn);
        }
    }
}

From source file:org.rhq.enterprise.server.system.SystemManagerBean.java

@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public long vacuum(Subject whoami) {
    return vacuum(whoami, null);
}

From source file:org.rhq.enterprise.server.system.SystemManagerBean.java

@RequiredPermission(Permission.MANAGE_SETTINGS)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public long vacuum(Subject whoami, String[] tableNames) {
    long duration = 0;
    Connection conn = null;//from   w w w  .j av  a2s . c  o m
    DatabaseType dbtype = null;
    try {
        conn = dataSource.getConnection();
        dbtype = DatabaseTypeFactory.getDatabaseType(conn);
        if (!DatabaseTypeFactory.isPostgres(dbtype)) {
            return -1;
        }

        if (tableNames == null) // no names given -> operate on all tables.
        {
            tableNames = new String[1];
            tableNames[0] = null;
        }

        for (String tableName : tableNames) {
            duration += doCommand(dbtype, conn, SQL_VACUUM, tableName);
        }

        return duration;
    } catch (Exception e) {
        log.error("Error vacuuming database: " + e.getMessage(), e);
        return duration;
    } finally {
        if (dbtype != null) {
            dbtype.closeConnection(conn);
        }
    }
}