001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.connector.deployment.jsr88;
018    
019    import org.apache.geronimo.deployment.plugin.XmlBeanSupport;
020    import org.apache.geronimo.xbeans.geronimo.GerSinglepoolType;
021    import org.apache.xmlbeans.SchemaTypeLoader;
022    
023    /**
024     * Settings for connectionmanager/single-pool
025     *
026     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
027     */
028    public class SinglePool extends XmlBeanSupport {
029        public SinglePool() {
030            super(null);
031        }
032        public SinglePool(GerSinglepoolType pool) {
033            super(null);
034            configure(pool);
035        }
036    
037        protected GerSinglepoolType getSinglePool() {
038            return (GerSinglepoolType) getXmlObject();
039        }
040    
041        protected void configure(GerSinglepoolType pool) {
042            setXmlObject(pool);
043            if(!isSelectOneAssumeMatch() && !isMatchOne() && !isMatchAll()) {
044                setMatchOne(true);
045            }
046        }
047    
048        // ----------------------- JavaBean Properties for single-pool ----------------------
049    
050        public Integer getMinSize() {
051            return getSinglePool().isSetMinSize() ? new Integer(getSinglePool().getMinSize()) : null;
052        }
053    
054        public void setMinSize(Integer value) {
055            Integer old = getMinSize();
056            if(value == null) {
057                if(getSinglePool().isSetMinSize()) {
058                    getSinglePool().unsetMinSize();
059                }
060            } else {
061                getSinglePool().setMinSize(value.intValue());
062            }
063            pcs.firePropertyChange("minSize", old, value);
064        }
065    
066        public Integer getMaxSize() {
067            return getSinglePool().isSetMaxSize() ? new Integer(getSinglePool().getMaxSize()) : null;
068        }
069    
070        public void setMaxSize(Integer value) {
071            Integer old = getMaxSize();
072            if(value == null) {
073                if(getSinglePool().isSetMaxSize()) {
074                    getSinglePool().unsetMaxSize();
075                }
076            } else {
077                getSinglePool().setMaxSize(value.intValue());
078            }
079            pcs.firePropertyChange("maxSize", old, value);
080        }
081    
082        public Integer getBlockingTimeoutMillis() {
083            return getSinglePool().isSetBlockingTimeoutMilliseconds() ? new Integer(getSinglePool().getBlockingTimeoutMilliseconds()) : null;
084        }
085    
086        public void setBlockingTimeoutMillis(Integer value) {
087            Integer old = getBlockingTimeoutMillis();
088            if(value == null) {
089                if(getSinglePool().isSetBlockingTimeoutMilliseconds()) {
090                    getSinglePool().unsetBlockingTimeoutMilliseconds();
091                }
092            } else {
093                getSinglePool().setBlockingTimeoutMilliseconds(value.intValue());
094            }
095            pcs.firePropertyChange("blockingTimeoutMillis", old, value);
096        }
097    
098        public Integer getIdleTimeoutMinutes() {
099            return getSinglePool().isSetIdleTimeoutMinutes() ? new Integer(getSinglePool().getIdleTimeoutMinutes()) : null;
100        }
101    
102        public void setIdleTimeoutMinutes(Integer value) {
103            Integer old = getIdleTimeoutMinutes();
104            if(value == null) {
105                if(getSinglePool().isSetIdleTimeoutMinutes()) {
106                    getSinglePool().unsetIdleTimeoutMinutes();
107                }
108            } else {
109                getSinglePool().setIdleTimeoutMinutes(value.intValue());
110            }
111            pcs.firePropertyChange("idleTimeoutMinutes", old, value);
112        }
113    
114        public boolean isMatchAll() {
115            return getSinglePool().isSetMatchAll();
116        }
117    
118        public void setMatchAll(boolean set) {
119            if(set) {
120                if(!isMatchAll()) {
121                    getSinglePool().addNewMatchAll();
122                    pcs.firePropertyChange("matchAll", !set, set);
123                }
124                if(isMatchOne()) setMatchOne(false);
125                if(isSelectOneAssumeMatch()) setSelectOneAssumeMatch(false);
126            } else {
127                if(isMatchAll()) {
128                    getSinglePool().unsetMatchAll();
129                    pcs.firePropertyChange("matchAll", !set, set);
130                }
131            }
132        }
133    
134        public boolean isMatchOne() {
135            return getSinglePool().isSetMatchOne();
136        }
137    
138        public void setMatchOne(boolean set) {
139            if(set) {
140                if(!isMatchOne()) {
141                    getSinglePool().addNewMatchOne();
142                    pcs.firePropertyChange("matchOne", !set, set);
143                }
144                if(isMatchAll()) setMatchAll(false);
145                if(isSelectOneAssumeMatch()) setSelectOneAssumeMatch(false);
146            } else {
147                if(isMatchOne()) {
148                    getSinglePool().unsetMatchOne();
149                    pcs.firePropertyChange("matchOne", !set, set);
150                }
151            }
152        }
153    
154        public boolean isSelectOneAssumeMatch() {
155            return getSinglePool().isSetSelectOneAssumeMatch();
156        }
157    
158        public void setSelectOneAssumeMatch(boolean set) {
159            if(set) {
160                if(!isSelectOneAssumeMatch()) {
161                    getSinglePool().addNewSelectOneAssumeMatch();
162                    pcs.firePropertyChange("selectOneAssumeMatch", !set, set);
163                }
164                if(isMatchAll()) setMatchAll(false);
165                if(isMatchOne()) setMatchOne(false);
166            } else {
167                if(isSelectOneAssumeMatch()) {
168                    getSinglePool().unsetSelectOneAssumeMatch();
169                    pcs.firePropertyChange("selectOneAssumeMatch", !set, set);
170                }
171            }
172        }
173    
174        // ----------------------- End of JavaBean Properties ----------------------
175    
176        protected SchemaTypeLoader getSchemaTypeLoader() {
177            return Connector15DCBRoot.SCHEMA_TYPE_LOADER;
178        }
179    }