当前位置: 首页>>代码示例>>Java>>正文


Java Err类代码示例

本文整理汇总了Java中de.invesdwin.context.log.error.Err的典型用法代码示例。如果您正苦于以下问题:Java Err类的具体用法?Java Err怎么用?Java Err使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Err类属于de.invesdwin.context.log.error包,在下文中一共展示了Err类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readNext

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
@SuppressWarnings({ "null" })
private E readNext() {
    try {
        if (innerClosed) {
            return (E) null;
        }
        final String line = lineReader.readLine();
        if (line == null) {
            innerClose();
            return (E) null;
        }
        final byte[] bytes = line.getBytes();
        if (bytes.length == 0) {
            throw new IllegalStateException("empty encoded entries should have been filtered by add()");
        }
        final byte[] decoded = Base64.decodeBase64(bytes);
        if (decoded.length == 0) {
            throw new IllegalStateException("empty entries should have been filtered by add()");
        }
        return serde.fromBytes(decoded);
    } catch (final IOException e) {
        throw Err.process(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:25,代码来源:SerializingCollection.java

示例2: toJSON

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
@Override
public String toJSON() {

    final ObjectMapper mapper = new ObjectMapper();
    mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
    String json = null;
    try {
        mapper.writeValue(stream, this);
        json = new String(stream.toByteArray(), "UTF-8");
    } catch (final IOException e) {
        Err.process(e);
    }

    //TODO serialize Object as JSON
    return json;
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:18,代码来源:RdpConfig.java

示例3: testDeleteNonExisting

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
public void testDeleteNonExisting() {
    final SimpleTestEntity ent = new SimpleTestEntity();
    ent.setId(Long.MAX_VALUE);
    try {
        dao.delete(ent);
        Fail.fail("Exception should have been thrown!");
    } catch (final Throwable t) {
        final boolean causedBy = Throwables.isCausedByType(t, EmptyResultDataAccessException.class);
        if (!causedBy) {
            throw Err.process(t);
        }
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:14,代码来源:SimpleTestDaoTest.java

示例4: testBeanValidation

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
public void testBeanValidation() {
    try {
        final SimpleTestEntity entWithoutName = new SimpleTestEntity();
        dao.save(entWithoutName);
        Fail.fail("Exception expected");
    } catch (final Throwable t) {
        final ConstraintViolationException e = Throwables.getCauseByType(t, ConstraintViolationException.class);
        Assertions.assertThat(e).isNotNull();
        Err.process(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:12,代码来源:SimpleTestDaoTest.java

示例5: testRollback

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
public void testRollback() {
    final String name = "thisCausesARollBack";

    final SimpleTestEntity ent = new SimpleTestEntity();
    ent.setName(name);
    try {
        service.saveEntityAndRollback(ent);
    } catch (final IllegalStateException e) {
        Err.process(e);
    }
    final SimpleTestEntity gelesen = service.getByName(name);
    Assertions.assertThat(gelesen).isNull();
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:14,代码来源:SimpleTestDaoTest.java

示例6: testRequiresNewTransaction

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
public void testRequiresNewTransaction() {
    final String name = "thisWillBeKept";

    final SimpleTestEntity ent = new SimpleTestEntity();
    ent.setName(name);
    try {
        service.saveEntityAndRollbackAfterRequiresNewMethodCall(ent);
    } catch (final IllegalStateException e) {
        Err.process(e);
    }

    final SimpleTestEntity findOne = service.getByName(name);
    Assertions.assertThat(findOne).isNotNull();
    Assertions.assertThat(ent.getId()).isEqualTo(findOne.getId());
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:16,代码来源:SimpleTestDaoTest.java

示例7: corruptionHandlingNewStorage

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
private TimeSeriesStorage corruptionHandlingNewStorage() {
    try {
        return newStorage(directory);
    } catch (final Throwable t) {
        if (Throwables.isCausedByType(t, CorruptedTimeSeriesStorageException.class)) {
            Err.process(new RuntimeException("Resetting " + ATimeSeriesDB.class.getSimpleName() + " ["
                    + getDirectory() + "] because the storage has been corrupted"));
            FileUtils.deleteQuietly(directory);
            return new TimeSeriesStorage(directory);
        } else {
            throw Throwables.propagate(t);
        }
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:15,代码来源:ATimeSeriesDB.java

示例8: getTempFolder

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
private File getTempFolder() {
    final File tempFolder = new File(ContextProperties.TEMP_DIRECTORY, SerializingCollection.class.getSimpleName());
    try {
        FileUtils.forceMkdir(tempFolder);
    } catch (final IOException e) {
        throw Err.process(e);
    }
    return tempFolder;
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:10,代码来源:SerializingCollection.java

示例9: getFos

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
private OutputStream getFos() {
    if (fos == null) {
        //Lazy init to prevent too many open files Exceptions
        if (closed) {
            throw new IllegalStateException("false expected");
        }
        try {
            fos = newCompressor(newFileOutputStream(file));
        } catch (final IOException e) {
            throw Err.process(e);
        }
    }
    return fos;
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:15,代码来源:SerializingCollection.java

示例10: add

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
@Override
public boolean add(final E element) {
    if (this.size == READ_ONLY_FILE_SIZE) {
        throw new IllegalStateException(
                "File [" + file + "] is in read only mode since it contained data when it was opened!");
    }
    try {
        final byte[] bytes = serde.toBytes(element);
        if (bytes == null || bytes.length == 0) {
            throw new IllegalStateException("bytes should contain actual data: " + element);
        }
        if (fixedLength == null) {
            final byte[] encoded = Base64.encodeBase64(bytes);
            if (encoded.length == 0) {
                throw new IllegalStateException(
                        "empty encoded bytes should not occur since empty bytes should aready be filtered");
            }
            if (firstElement) {
                firstElement = false;
            } else {
                getFos().write(ELEMENT_DELIMITER);
            }
            getFos().write(encoded);
        } else {
            if (bytes.length != fixedLength) {
                throw new IllegalArgumentException(
                        "Serialized object [" + element + "] has unexpected byte length of [" + bytes.length
                                + "] while fixed length [" + fixedLength + "] was expected!");
            }
            getFos().write(bytes);
        }

    } catch (final IOException e) {
        throw Err.process(e);
    }
    size++;
    return true;
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:39,代码来源:SerializingCollection.java

示例11: initDirectory

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
private void initDirectory() {
    try {
        FileUtils.forceMkdir(directory);
    } catch (final IOException e) {
        throw Err.process(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:8,代码来源:ADelegateRangeTable.java

示例12: writePersistenceXml

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
private void writePersistenceXml() {
    try {
        final File metaInfDir = new File(ContextProperties.TEMP_CLASSPATH_DIRECTORY, "META-INF");
        FileUtils.forceMkdir(metaInfDir);
        final File file = new File(metaInfDir, "persistence.xml");
        FileUtils.deleteQuietly(file);
        final String content = generatePersistenceXml();
        FileUtils.write(file, content);
    } catch (final IOException e) {
        throw Err.process(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:13,代码来源:ClasspathScanningPersistenceUnitManager.java

示例13: getContextResources

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
@Override
public List<PositionedResource> getContextResources() {
    try {
        final String content = generateContextXml();
        final File xmlFile = new File(ContextProperties.TEMP_DIRECTORY, "ctx.jpa.repository.scan.xml");
        FileUtils.writeStringToFile(xmlFile, content);
        final FileSystemResource fsResource = new FileSystemResource(xmlFile);
        xmlFile.deleteOnExit();
        return Arrays.asList(PositionedResource.of(fsResource, ResourcePosition.END));
    } catch (final IOException e) {
        throw Err.process(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:14,代码来源:JpaRepositoryScanContextLocation.java

示例14: createDelegate

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
@Override
protected DataSource createDelegate() {
    final ComboPooledDataSource ds = new ComboPooledDataSource();
    try {
        ds.setDriverClass(context.getConnectionDriver());
    } catch (final PropertyVetoException e1) {
        throw Err.process(e1);
    }
    ds.setJdbcUrl(context.getConnectionUrl());
    ds.setUser(context.getConnectionUser());
    ds.setPassword(context.getConnectionPassword());

    ds.setMaxStatements(5000);
    ds.setMaxStatementsPerConnection(50);
    ds.setStatementCacheNumDeferredCloseThreads(1); //fix apparent deadlocks

    ds.setMaxPoolSize(100);
    ds.setMinPoolSize(1);
    ds.setMaxIdleTime(new Duration(1, FTimeUnit.MINUTES).intValue(FTimeUnit.SECONDS));
    ds.setTestConnectionOnCheckout(true);

    ds.setAutoCommitOnClose(true);

    Assertions.assertThat(this.closeableDs).isNull();
    this.closeableDs = ds;

    if (logging) {
        try {
            final ConnectionPoolDataSourceProxy proxy = new ConnectionPoolDataSourceProxy();
            proxy.setTargetDSDirect(ds);
            return proxy;
        } catch (final JdbcDsLogRuntimeException e) {
            throw new RuntimeException(e);
        }
    } else {
        return ds;
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:39,代码来源:ConfiguredCPDataSource.java

示例15: testDeleteNonExisting

import de.invesdwin.context.log.error.Err; //导入依赖的package包/类
public void testDeleteNonExisting() {
    final TestEntity ent = new TestEntity();
    ent.setId(Long.MAX_VALUE);
    try {
        dao.delete(ent);
        Fail.fail("Exception should have been thrown!");
    } catch (final Throwable t) {
        final boolean causedBy = Throwables.isCausedByType(t, EmptyResultDataAccessException.class);
        if (!causedBy) {
            throw Err.process(t);
        }
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:14,代码来源:TestDaoTest.java


注:本文中的de.invesdwin.context.log.error.Err类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。