001/*
002 * (C) Copyright 2006-2018 Nuxeo (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.nuxeo.ecm.core.redis;
017
018import org.apache.commons.lang3.StringUtils;
019import org.nuxeo.common.xmap.annotation.XNode;
020import org.nuxeo.common.xmap.annotation.XObject;
021import org.nuxeo.runtime.model.Descriptor;
022
023import redis.clients.jedis.Protocol;
024
025@XObject("pool")
026public abstract class RedisPoolDescriptor implements Descriptor {
027
028    @XNode("disabled")
029    protected boolean disabled;
030
031    public String password;
032
033    @XNode("database")
034    public int database = Protocol.DEFAULT_DATABASE;
035
036    @XNode("timeout")
037    public int timeout = Protocol.DEFAULT_TIMEOUT;
038
039    @XNode("maxTotal")
040    public int maxTotal = 16;
041
042    @XNode("maxIdle")
043    public int maxIdle = 8;
044
045    @XNode("prefix")
046    public String prefix;
047
048    @Override
049    public final String getId() {
050        return UNIQUE_DESCRIPTOR_ID;
051    }
052
053    @XNode("password")
054    public void setPassword(String value) {
055        password = StringUtils.defaultIfBlank(value, null);
056    }
057
058    protected abstract RedisExecutor newExecutor();
059}