001/*
002 * (C) Copyright 2006-2019 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 *
016 * Contributors:
017 *     Bogdan Stefanescu
018 *     Florent Guillaume
019 */
020package org.nuxeo.ecm.core.api.repository;
021
022import java.util.concurrent.Callable;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XObject;
026import org.nuxeo.ecm.core.api.CoreSession;
027
028/**
029 * A high-level repository descriptor, from which you get a {@link CoreSession} when calling {@code open}.
030 * <p>
031 * This is obsolete as an extension point, use org.nuxeo.ecm.core.storage.sql.RepositoryService instead. Descriptor kept
032 * for backward-compatibility.
033 * <p>
034 * Note that this is still use as an object returned by the core api RepositoryManager.
035 */
036@XObject("repository")
037public class Repository {
038
039    @XNode("@name")
040    private String name;
041
042    @XNode("@label")
043    private String label;
044
045    @XNode("@isDefault")
046    private Boolean isDefault;
047
048    private Boolean headless;
049
050    /**
051     * Factory to used to create the low-level repository.
052     */
053    private Callable<Object> repositoryFactory;
054
055    private PoolConfiguration poolConfig;
056
057    public Repository() {
058    }
059
060    public Repository(String name, String label, Boolean isDefault, Boolean headless,
061            Callable<Object> repositoryFactory, PoolConfiguration poolConfig) {
062        this.name = name;
063        this.label = label;
064        this.isDefault = isDefault;
065        this.headless = headless;
066        this.repositoryFactory = repositoryFactory;
067        this.poolConfig = poolConfig;
068    }
069
070    public void setLabel(String label) {
071        this.label = label;
072    }
073
074    public void setDefault(Boolean isDefault) {
075        this.isDefault = isDefault;
076    }
077
078    public String getName() {
079        return name;
080    }
081
082    public String getLabel() {
083        return label;
084    }
085
086    public Boolean getDefault() {
087        return isDefault;
088    }
089
090    public boolean isDefault() {
091        return Boolean.TRUE.equals(isDefault);
092    }
093
094    /** @since 11.2 */
095    public boolean isHeadless() {
096        return Boolean.TRUE.equals(headless);
097    }
098
099    public Callable<Object> getRepositoryFactory() {
100        return repositoryFactory;
101    }
102
103    public PoolConfiguration getPoolConfig() {
104        return poolConfig;
105    }
106
107    @Override
108    public String toString() {
109        return getClass().getSimpleName() + " {name=" + name + ", label=" + label + '}';
110    }
111
112}