java 代码
- private PersonAggregateData copyAggregate(PersonAggregateData original) throws EventsPersonManagementException {
- ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- PersonAggregateData copy;
- try {
- out = new ObjectOutputStream(outputBytes);
- ByteArrayInputStream inputBytes;
- out.writeObject(original);
- inputBytes = new ByteArrayInputStream(outputBytes.toByteArray());
- in = new ObjectInputStream(inputBytes);
- copy = (PersonAggregateData) in.readObject();
- } catch (IOException e) {
- throw new EventsPersonManagementException("errors occur while copying the PersonAggregateData", e);
- } catch (ClassNotFoundException e) {
- throw new EventsPersonManagementException("errors occur while copying the PersonAggregateData", e);
- } finally {
- try {
- if (out != null) {
- out.close();
- }
- if (in != null) {
- in.close();
- }
- } catch (IOException e) {
- throw new EventsPersonManagementException("errors occur while copying the PersonAggregateData", e);
- }
- }
- return copy;
- }