public class GuardedObject extends Object implements Serializable
GuardedObject封装了一个目标对象和一个Guard对象,使得只有在Guard对象允许的情况下才能访问目标对象。 一个对象被GuardedObject封装后,对该对象的访问由getObject
方法控制,该方法调用Guard对象上的守卫访问的checkGuard
方法。 如果不允许访问,则抛出异常。
Guard
, Permission
, Serialized Form
Constructor and Description |
---|
GuardedObject(Object object, Guard guard)
使用指定的对象和守卫构造一个GuardedObject。
|
public Object getObject() throws SecurityException
SecurityException
- 如果对被保护对象的访问被拒绝。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.