01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity.acl.basic.cache;
17:
18: import org.acegisecurity.acl.basic.BasicAclEntry;
19:
20: import org.springframework.util.Assert;
21:
22: import java.io.Serializable;
23:
24: /**
25: * Used by {@link EhCacheBasedAclEntryCache} to store the array of <code>BasicAclEntry</code>s in the cache.<P>This
26: * is necessary because caches store a single object per key, not an array.</p>
27: * <P>This class uses value object semantics. ie: construction-based initialisation without any setters for the
28: * properties.</p>
29: *
30: * @author Ben Alex
31: * @version $Id: BasicAclEntryHolder.java 1496 2006-05-23 13:38:33Z benalex $
32: */
33: public class BasicAclEntryHolder implements Serializable {
34: //~ Instance fields ================================================================================================
35:
36: private BasicAclEntry[] basicAclEntries;
37:
38: //~ Constructors ===================================================================================================
39:
40: /**
41: * Constructs the <code>BasicAclEntryHolder</code>.
42: *
43: * @param aclEntries to cache (any <code>null</code>s will cause an
44: * exception, which should not be a problem as the contract for
45: * <code>BasicAclEntryCache</code> allows exceptions if
46: * <code>null</code>s are presented)
47: *
48: * @throws IllegalArgumentException if a <code>null</code> exists anywhere
49: * in the <code>aclEntries</code> or if a <code>null</code> is
50: * passed to the constructor
51: */
52: public BasicAclEntryHolder(BasicAclEntry[] aclEntries) {
53: Assert.notNull(aclEntries, "aclEntries cannot be null");
54:
55: for (int i = 0; i < aclEntries.length; i++) {
56: Assert.notNull(aclEntries[i], "aclEntries cannot be null");
57: }
58:
59: this .basicAclEntries = aclEntries;
60: }
61:
62: //~ Methods ========================================================================================================
63:
64: public BasicAclEntry[] getBasicAclEntries() {
65: return basicAclEntries;
66: }
67: }
|