本文整理汇总了Java中org.activiti.engine.impl.util.IoUtil.closeSilently方法的典型用法代码示例。如果您正苦于以下问题:Java IoUtil.closeSilently方法的具体用法?Java IoUtil.closeSilently怎么用?Java IoUtil.closeSilently使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.impl.util.IoUtil
的用法示例。
在下文中一共展示了IoUtil.closeSilently方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public byte[] serialize(Object value, ValueFields valueFields) {
if (value == null) {
return null;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = null;
try {
oos = createObjectOutputStream(baos);
oos.writeObject(value);
} catch (Exception e) {
throw new ActivitiException("Couldn't serialize value '" + value + "' in variable '" + valueFields.getName() + "'", e);
} finally {
IoUtil.closeSilently(oos);
}
return baos.toByteArray();
}
示例2: generateImage
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
/**
* Generates an image of what currently is drawn on the canvas.
* <p/>
* Throws an {@link ActivitiException} when {@link #close()} is already
* called.
*/
public InputStream generateImage(String imageType) {
if (closed) {
throw new ActivitiException("ProcessDiagramGenerator already closed");
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
// Try to remove white space
minX = (minX <= 5) ? 5 : minX;
minY = (minY <= 5) ? 5 : minY;
BufferedImage imageToSerialize = processDiagram;
if (minX >= 0 && minY >= 0) {
imageToSerialize = processDiagram.getSubimage(minX - 5, minY - 5, canvasWidth - minX + 5, canvasHeight - minY + 5);
}
ImageIO.write(imageToSerialize, imageType, out);
} catch (IOException e) {
throw new ActivitiException("Error while generating process image", e);
} finally {
IoUtil.closeSilently(out);
}
return new ByteArrayInputStream(out.toByteArray());
}
示例3: generateImage
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
/**
* Generates an image of what currently is drawn on the canvas.
*
* Throws an {@link ActivitiException} when {@link #close()} is already
* called.
*/
public InputStream generateImage(String imageType) {
if (closed) {
throw new ActivitiException("ProcessDiagramGenerator already closed");
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
// Try to remove white space
minX = (minX <= 5) ? 5 : minX;
minY = (minY <= 5) ? 5 : minY;
BufferedImage imageToSerialize = processDiagram;
if (minX >= 0 && minY >= 0) {
imageToSerialize = processDiagram.getSubimage(minX - 5, minY - 5, canvasWidth - minX + 5, canvasHeight - minY + 5);
}
ImageIO.write(imageToSerialize, imageType, out);
} catch (IOException e) {
throw new ActivitiException("Error while generating process image", e);
} finally {
IoUtil.closeSilently(out);
}
return new ByteArrayInputStream(out.toByteArray());
}
示例4: serialize
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public static byte[] serialize(Object value, ValueFields valueFields) {
if(value == null) {
return null;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream ois = null;
try {
ois = new ObjectOutputStream(baos);
ois.writeObject(value);
} catch (Exception e) {
throw new ActivitiException("coudn't deserialize value '"+value+"' in variable '"+valueFields.getName()+"'", e);
} finally {
IoUtil.closeSilently(ois);
}
return baos.toByteArray();
}
示例5: executeSchemaResource
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public void executeSchemaResource(String operation, String component, String resourceName, boolean isOptional) {
InputStream inputStream = null;
try {
inputStream = ReflectUtil.getResourceAsStream(resourceName);
if (inputStream == null) {
if (isOptional) {
log.fine("no schema resource "+resourceName+" for "+operation);
} else {
throw new ActivitiException("resource '" + resourceName + "' is not available");
}
} else {
executeSchemaResource(operation, component, resourceName, inputStream);
}
} finally {
IoUtil.closeSilently(inputStream);
}
}
示例6: serialize
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public static byte[] serialize(Object value, ValueFields valueFields) {
if (value == null) {
return null;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = null;
try {
oos = createObjectOutputStream(baos);
oos.writeObject(value);
} catch (Exception e) {
throw new ActivitiException("Couldn't serialize value '"+value+"' in variable '"+valueFields.getName()+"'", e);
} finally {
IoUtil.closeSilently(oos);
}
return baos.toByteArray();
}
示例7: executeSchemaResource
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public void executeSchemaResource(String operation, String component, String resourceName, boolean isOptional) {
InputStream inputStream = null;
try {
inputStream = ReflectUtil.getResourceAsStream(resourceName);
if (inputStream == null) {
if (isOptional) {
log.debug("no schema resource {} for {}", resourceName, operation);
} else {
throw new ActivitiException("resource '" + resourceName + "' is not available");
}
} else {
executeSchemaResource(operation, component, resourceName, inputStream);
}
} finally {
IoUtil.closeSilently(inputStream);
}
}
示例8: deserialize
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public Object deserialize(byte[] bytes, ValueFields valueFields) {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
try {
ObjectInputStream ois = createObjectInputStream(bais);
Object deserializedObject = ois.readObject();
return deserializedObject;
} catch (Exception e) {
throw new ActivitiException("Couldn't deserialize object in variable '" + valueFields.getName() + "'", e);
} finally {
IoUtil.closeSilently(bais);
}
}
示例9: buildProcessEngine
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
private static ProcessEngine buildProcessEngine(URL resource) {
InputStream inputStream = null;
try {
inputStream = resource.openStream();
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(inputStream);
return processEngineConfiguration.buildProcessEngine();
} catch (IOException e) {
throw new ActivitiIllegalArgumentException("couldn't open resource stream: " + e.getMessage(), e);
} finally {
IoUtil.closeSilently(inputStream);
}
}
示例10: buildProcessEngine
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
private static ProcessEngine buildProcessEngine(URL resource) {
InputStream inputStream = null;
try {
inputStream = resource.openStream();
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(inputStream);
return processEngineConfiguration.buildProcessEngine();
} catch (IOException e) {
throw new ActivitiException("couldn't open resource stream: "+e.getMessage(), e);
} finally {
IoUtil.closeSilently(inputStream);
}
}
示例11: run
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public void run() {
task.log("launching cmd '"+cmdString(cmd)+"' in dir '"+dir+"'");
if (msg!=null) {
task.log("waiting for launch completion msg '"+msg+"'...");
} else {
task.log("not waiting for a launch completion msg.");
}
ProcessBuilder processBuilder = new ProcessBuilder(cmd)
.redirectErrorStream(true)
.directory(dir);
InputStream consoleStream = null;
try {
Process process = processBuilder.start();
consoleStream = process.getInputStream();
BufferedReader consoleReader = new BufferedReader(new InputStreamReader(consoleStream));
String consoleLine = "";
while ( (consoleLine!=null)
&& (msg==null || consoleLine.indexOf(msg)==-1)
) {
consoleLine = consoleReader.readLine();
if (consoleLine!=null) {
task.log(" " + consoleLine);
} else {
task.log("launched process completed");
}
}
} catch (Exception e) {
throw new BuildException("couldn't launch "+cmdString(cmd), e);
} finally {
IoUtil.closeSilently(consoleStream);
}
}
示例12: getValue
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public Object getValue(ValueFields valueFields) {
Object cachedObject = valueFields.getCachedValue();
if (cachedObject!=null) {
return cachedObject;
}
byte[] bytes = (byte[]) super.getValue(valueFields);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
Object deserializedObject;
try {
ObjectInputStream ois = new ObjectInputStream(bais);
deserializedObject = ois.readObject();
valueFields.setCachedValue(deserializedObject);
if (valueFields instanceof VariableInstanceEntity) {
Context
.getCommandContext()
.getDbSqlSession()
.addDeserializedObject(deserializedObject, bytes, (VariableInstanceEntity) valueFields);
}
} catch (Exception e) {
throw new ActivitiException("coudn't deserialize object in variable '"+valueFields.getName()+"'", e);
} finally {
IoUtil.closeSilently(bais);
}
return deserializedObject;
}
示例13: getValue
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
public Object getValue(ValueFields valueFields) {
Object cachedObject = valueFields.getCachedValue();
if (cachedObject != null) {
return cachedObject;
}
byte[] bytes = (byte[]) super.getValue(valueFields);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
try {
ObjectInputStream ois = createObjectInputStream(bais);
Object deserializedObject = ois.readObject();
valueFields.setCachedValue(deserializedObject);
if (valueFields instanceof VariableInstanceEntity) {
// we need to register the deserialized object for dirty checking,
// so that it can be serialized again if it was changed.
Context.getCommandContext()
.getDbSqlSession()
.addDeserializedObject(deserializedObject, bytes, (VariableInstanceEntity) valueFields);
}
return deserializedObject;
} catch (Exception e) {
throw new ActivitiException("Couldn't deserialize object in variable '"+valueFields.getName()+"'", e);
} finally {
IoUtil.closeSilently(bais);
}
}
示例14: buildProcessEngine
import org.activiti.engine.impl.util.IoUtil; //导入方法依赖的package包/类
private static ProcessEngine buildProcessEngine(URL resource) {
InputStream inputStream = null;
try {
inputStream = resource.openStream();
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(inputStream);
return processEngineConfiguration.buildProcessEngine();
} catch (IOException e) {
throw new ActivitiIllegalArgumentException("couldn't open resource stream: "+e.getMessage(), e);
} finally {
IoUtil.closeSilently(inputStream);
}
}