위임예언
2026년 6월 25일 09:30분
신명기 18장에서 하나님은 모세 같은 예언자를 세워 말씀을 대신 전달하게 합니다. 원본 메시지를 전달자를 통해 프록시합니다. 나는 원본 메시지를 대리자를 통해 전달하는 프록시 패턴을 구현했습니다.
package com.jesusbornd.deuteronomy;
public class Deuteronomy_18_Chapter_Lv2 {
interface MessageSource { String getMessage(); }
static class God implements MessageSource {
public String getMessage() { return "율법을 지키고 순종하라"; }
}
static class Prophet implements MessageSource {
private final MessageSource source;
private final String name;
Prophet(String name, MessageSource source) { this.name = name; this.source = source; }
public String getMessage() {
String msg = source.getMessage();
System.out.printf("[프록시: %s] 원본 수신 → 전달 중%n", name);
return msg;
}
}
public static void main(String[] args) {
MessageSource god = new God();
MessageSource prophet = new Prophet("모세", god);
System.out.println("전달 메시지: " + prophet.getMessage());
}
}
class God:
def get_message(self): return "율법을 지키고 순종하라"
class Prophet:
def __init__(self, name, source):
self.name = name
self._source = source
def get_message(self):
msg = self._source.get_message()
print(f"[프록시: {self.name}] 원본 수신 → 전달 중")
return msg
if __name__ == "__main__":
prophet = Prophet("모세", God())
print("전달 메시지:", prophet.get_message())
Search
Categories
← 목록으로
Comments
프록시는 원본을 보호하면서도 접근 가능하게 하는 중요한 패턴이네요.