View Javadoc

1   /* Copyright 2004 Acegi Technology Pty Limited
2    *
3    * Licensed under the Apache License, Version 2.0 (the "License");
4    * you may not use this file except in compliance with the License.
5    * You may obtain a copy of the License at
6    *
7    *     http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * 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 java.io.Serializable;
21  
22  import org.springframework.util.Assert;
23  
24  
25  /***
26   * Used by {@link EhCacheBasedAclEntryCache} to store the array of
27   * <code>BasicAclEntry</code>s in the cache.
28   * 
29   * <P>
30   * This is necessary because caches store a single object per key, not an
31   * array.
32   * </p>
33   * 
34   * <P>
35   * This class uses value object semantics. ie: construction-based
36   * initialisation without any setters for the properties.
37   * </p>
38   *
39   * @author Ben Alex
40   * @version $Id: BasicAclEntryHolder.java,v 1.3 2005/11/17 00:56:47 benalex Exp $
41   */
42  public class BasicAclEntryHolder implements Serializable {
43      //~ Instance fields ========================================================
44  
45      private BasicAclEntry[] basicAclEntries;
46  
47      //~ Constructors ===========================================================
48  
49      /***
50       * Constructs the <code>BasicAclEntryHolder</code>.
51       *
52       * @param aclEntries to cache (any <code>null</code>s will cause an
53       *        exception, which should not be a problem as the contract for
54       *        <code>BasicAclEntryCache</code> allows exceptions if
55       *        <code>null</code>s are presented)
56       *
57       * @throws IllegalArgumentException if a <code>null</code> exists anywhere
58       *         in the <code>aclEntries</code> or if a <code>null</code> is
59       *         passed to the constructor
60       */
61      public BasicAclEntryHolder(BasicAclEntry[] aclEntries) {
62          Assert.notNull(aclEntries, "aclEntries cannot be null");
63  
64          for (int i = 0; i < aclEntries.length; i++) {
65              Assert.notNull(aclEntries[i], "aclEntries cannot be null");
66          }
67  
68          this.basicAclEntries = aclEntries;
69      }
70  
71      //~ Methods ================================================================
72  
73      public BasicAclEntry[] getBasicAclEntries() {
74          return basicAclEntries;
75      }
76  }