001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.annotation.ejb.cache.tree;
023:
024: import java.lang.annotation.Annotation;
025:
026: /**
027: * @version <tt>$Revision: 62097 $</tt>
028: * @author <a href="mailto:bdecoste@jboss.com">William DeCoste</a>
029: */
030: public class CacheConfigImpl implements CacheConfig {
031: private String name = "jboss.cache:service=EJB3SFSBClusteredCache";
032: private int maxSize = 100000;
033: private long idleTimeoutSeconds = 300;
034: private long removalTimeoutSeconds = 0;
035: private boolean replicationIsPassivation = true;
036:
037: public CacheConfigImpl() {
038: }
039:
040: public String name() {
041: return name;
042: }
043:
044: public void setName(String name) {
045: this .name = name;
046: }
047:
048: public int maxSize() {
049: return maxSize;
050: }
051:
052: public void setMaxSize(int maxSize) {
053: this .maxSize = maxSize;
054: }
055:
056: public long idleTimeoutSeconds() {
057: return idleTimeoutSeconds;
058: }
059:
060: public void setIdleTimeoutSeconds(long idleTimeoutSeconds) {
061: this .idleTimeoutSeconds = idleTimeoutSeconds;
062: }
063:
064: public long removalTimeoutSeconds() {
065: return removalTimeoutSeconds;
066: }
067:
068: public void setRemovalTimeoutSeconds(long removalTimeoutSeconds) {
069: this .removalTimeoutSeconds = removalTimeoutSeconds;
070: }
071:
072: public boolean replicationIsPassivation() {
073: return replicationIsPassivation;
074: }
075:
076: public void setReplicationIsPassivation(
077: boolean replicationIsPassivation) {
078: this .replicationIsPassivation = replicationIsPassivation;
079: }
080:
081: public void merge(CacheConfig annotation) {
082: if (maxSize == 100000)
083: maxSize = annotation.maxSize();
084:
085: if (idleTimeoutSeconds == 300)
086: idleTimeoutSeconds = annotation.idleTimeoutSeconds();
087:
088: if (removalTimeoutSeconds == 0)
089: removalTimeoutSeconds = annotation.removalTimeoutSeconds();
090:
091: if (replicationIsPassivation == true)
092: replicationIsPassivation = annotation
093: .replicationIsPassivation();
094:
095: }
096:
097: public Class<? extends Annotation> annotationType() {
098: return CacheConfig.class;
099: }
100: }
|