View Javadoc
1   package org.apache.commons.jcs3.auxiliary;
2   
3   import org.apache.commons.jcs3.engine.behavior.ICacheEventQueue;
4   
5   /*
6    * Licensed to the Apache Software Foundation (ASF) under one
7    * or more contributor license agreements.  See the NOTICE file
8    * distributed with this work for additional information
9    * regarding copyright ownership.  The ASF licenses this file
10   * to you under the Apache License, Version 2.0 (the
11   * "License"); you may not use this file except in compliance
12   * with the License.  You may obtain a copy of the License at
13   *
14   *   http://www.apache.org/licenses/LICENSE-2.0
15   *
16   * Unless required by applicable law or agreed to in writing,
17   * software distributed under the License is distributed on an
18   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19   * KIND, either express or implied.  See the License for the
20   * specific language governing permissions and limitations
21   * under the License.
22   */
23  
24  /**
25   * This has common attributes used by all auxiliaries.
26   */
27  public abstract class AbstractAuxiliaryCacheAttributes
28      implements AuxiliaryCacheAttributes
29  {
30      /** Don't change */
31      private static final long serialVersionUID = -6594609334959187673L;
32  
33      /** cacheName */
34      private String cacheName;
35  
36      /** name */
37      private String name;
38  
39      /** eventQueueType -- pooled, or single threaded */
40      private ICacheEventQueue.QueueType eventQueueType;
41  
42      /** Named when pooled */
43      private String eventQueuePoolName;
44  
45      /**
46       * @param name
47       */
48      @Override
49      public void setCacheName( final String name )
50      {
51          this.cacheName = name;
52      }
53  
54      /**
55       * Gets the cacheName attribute of the AuxiliaryCacheAttributes object
56       * <p>
57       * @return The cacheName value
58       */
59      @Override
60      public String getCacheName()
61      {
62          return this.cacheName;
63      }
64  
65      /**
66       * This is the name of the auxiliary in configuration file.
67       * <p>
68       * @see org.apache.commons.jcs3.auxiliary.AuxiliaryCacheAttributes#setName(String)
69       */
70      @Override
71      public void setName( final String s )
72      {
73          this.name = s;
74      }
75  
76      /**
77       * Gets the name attribute of the AuxiliaryCacheAttributes object
78       * <p>
79       * @return The name value
80       */
81      @Override
82      public String getName()
83      {
84          return this.name;
85      }
86  
87      /**
88       * SINGLE is the default. If you choose POOLED, the value of EventQueuePoolName will be used
89       * <p>
90       * @param queueType SINGLE or POOLED
91       */
92      @Override
93      public void setEventQueueType( final ICacheEventQueue.QueueType queueType )
94      {
95          this.eventQueueType = queueType;
96      }
97  
98      /**
99       * @return SINGLE or POOLED
100      */
101     @Override
102     public ICacheEventQueue.QueueType getEventQueueType()
103     {
104         return eventQueueType;
105     }
106 
107     /**
108      * If you choose a POOLED event queue type, the value of EventQueuePoolName will be used. This
109      * is ignored if the pool type is SINGLE
110      * <p>
111      * @param s SINGLE or POOLED
112      */
113     @Override
114     public void setEventQueuePoolName( final String s )
115     {
116         eventQueuePoolName = s;
117     }
118 
119     /**
120      * Sets the pool name to use. If a pool is not found by this name, the thread pool manager will
121      * return a default configuration.
122      * <p>
123      * @return name of thread pool to use for this auxiliary
124      */
125     @Override
126     public String getEventQueuePoolName()
127     {
128         return eventQueuePoolName;
129     }
130 
131     /**
132      * @see Object#clone()
133      */
134     @Override
135     public AbstractAuxiliaryCacheAttributes clone()
136     {
137         try
138         {
139             return (AbstractAuxiliaryCacheAttributes)super.clone();
140         }
141         catch (final CloneNotSupportedException e)
142         {
143             throw new RuntimeException("Clone not supported. This should never happen.", e);
144         }
145     }
146 }