001/* 002 * (C) Copyright 2006-2011 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 * Florent Guillaume 018 * Benoit Delbosc 019 */ 020package org.nuxeo.ecm.core.storage.sql; 021 022import java.io.Serializable; 023import java.util.Calendar; 024import java.util.Collection; 025import java.util.Map; 026import java.util.Set; 027 028import javax.transaction.xa.XAException; 029import javax.transaction.xa.XAResource; 030import javax.transaction.xa.Xid; 031 032import org.nuxeo.ecm.core.api.IterableQueryResult; 033import org.nuxeo.ecm.core.api.Lock; 034import org.nuxeo.ecm.core.api.PartialList; 035import org.nuxeo.ecm.core.query.QueryFilter; 036 037/** 038 * A {@link Mapper} that uses a {@link UnifiedCachingRowMapper} for row-related operation, and delegates to the 039 * {@link Mapper} for others. 040 */ 041public class UnifiedCachingMapper extends UnifiedCachingRowMapper implements CachingMapper { 042 043 /** 044 * The {@link Mapper} to which operations are delegated. 045 */ 046 public Mapper mapper; 047 048 @Override 049 public void initialize(String repositoryName, Model model, Mapper mapper, 050 InvalidationsPropagator invalidationsPropagator, Map<String, String> properties) { 051 super.initialize(repositoryName, model, mapper, invalidationsPropagator, properties); 052 this.mapper = mapper; 053 } 054 055 @Override 056 public Identification getIdentification() { 057 return mapper.getIdentification(); 058 } 059 060 @Override 061 public void close() { 062 super.close(); 063 mapper.close(); 064 } 065 066 @Override 067 public int getTableSize(String tableName) { 068 return mapper.getTableSize(tableName); 069 } 070 071 @Override 072 public void createDatabase(String ddlMode) { 073 mapper.createDatabase(ddlMode); 074 } 075 076 @Override 077 public Serializable getRootId(String repositoryId) { 078 return mapper.getRootId(repositoryId); 079 } 080 081 @Override 082 public void setRootId(Serializable repositoryId, Serializable id) { 083 mapper.setRootId(repositoryId, id); 084 } 085 086 @Override 087 public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, 088 boolean countTotal) { 089 return mapper.query(query, queryType, queryFilter, countTotal); 090 } 091 092 @Override 093 public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, long countUpTo) { 094 return mapper.query(query, queryType, queryFilter, countUpTo); 095 } 096 097 @Override 098 public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, 099 Object... params) { 100 return mapper.queryAndFetch(query, queryType, queryFilter, params); 101 } 102 103 @Override 104 public Set<Serializable> getAncestorsIds(Collection<Serializable> ids) { 105 return mapper.getAncestorsIds(ids); 106 } 107 108 @Override 109 public void updateReadAcls() { 110 mapper.updateReadAcls(); 111 } 112 113 @Override 114 public void rebuildReadAcls() { 115 mapper.rebuildReadAcls(); 116 } 117 118 @Override 119 public int getClusterNodeIdType() { 120 return mapper.getClusterNodeIdType(); 121 } 122 123 @Override 124 public void createClusterNode(Serializable nodeId) { 125 mapper.createClusterNode(nodeId); 126 } 127 128 @Override 129 public void removeClusterNode(Serializable nodeId) { 130 mapper.removeClusterNode(nodeId); 131 } 132 133 @Override 134 public void insertClusterInvalidations(Serializable nodeId, Invalidations invalidations) { 135 mapper.insertClusterInvalidations(nodeId, invalidations); 136 } 137 138 @Override 139 public Invalidations getClusterInvalidations(Serializable nodeId) { 140 return mapper.getClusterInvalidations(nodeId); 141 } 142 143 @Override 144 public Lock getLock(Serializable id) { 145 return mapper.getLock(id); 146 } 147 148 @Override 149 public Lock setLock(Serializable id, Lock lock) { 150 return mapper.setLock(id, lock); 151 } 152 153 @Override 154 public Lock removeLock(Serializable id, String owner, boolean force) { 155 return mapper.removeLock(id, owner, force); 156 } 157 158 @Override 159 public void markReferencedBinaries() { 160 mapper.markReferencedBinaries(); 161 } 162 163 @Override 164 public int cleanupDeletedRows(int max, Calendar beforeTime) { 165 return mapper.cleanupDeletedRows(max, beforeTime); 166 } 167 168 @Override 169 public void start(Xid xid, int flags) throws XAException { 170 mapper.start(xid, flags); 171 } 172 173 @Override 174 public void end(Xid xid, int flags) throws XAException { 175 mapper.end(xid, flags); 176 177 } 178 179 @Override 180 public int prepare(Xid xid) throws XAException { 181 return mapper.prepare(xid); 182 } 183 184 @Override 185 public void commit(Xid xid, boolean onePhase) throws XAException { 186 mapper.commit(xid, onePhase); 187 } 188 189 // rollback interacts with caches so is in RowMapper 190 191 @Override 192 public void forget(Xid xid) throws XAException { 193 mapper.forget(xid); 194 } 195 196 @Override 197 public Xid[] recover(int flag) throws XAException { 198 return mapper.recover(flag); 199 } 200 201 @Override 202 public boolean setTransactionTimeout(int seconds) throws XAException { 203 return mapper.setTransactionTimeout(seconds); 204 } 205 206 @Override 207 public int getTransactionTimeout() throws XAException { 208 return mapper.getTransactionTimeout(); 209 } 210 211 @Override 212 public boolean isSameRM(XAResource xares) throws XAException { 213 return mapper.isSameRM(xares); 214 } 215 216 @Override 217 public boolean isConnected() { 218 return mapper.isConnected(); 219 } 220 221 @Override 222 public void connect() { 223 mapper.connect(); 224 } 225 226 @Override 227 public void disconnect() { 228 mapper.disconnect(); 229 } 230}