item 90) 직렬화된 인스턴스 대신 직렬화 프록시 사용을 검토하라
직렬화 프록시 패턴
직렬화 프록시 구현 방법
class Period implements Serializable { private final Date start; private final Date end; public Period(Date start, Date end) { this.start = start; this.end = end; } // 직렬화 프록시 클래스 private static class SerializationProxy implements Serializable { private final Date start; private final Date end; public SerializationProxy(Period p) { this.start = p.start; this.end = p.end; } private static final long serialVersionUID = 234098243823485285L; } }
writeReplace
readObject
readResolve
장점
한계점
Last updated