本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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();
}
示例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());
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
}