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