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: */
018: package org.apache.lenya.cms.repository;
019:
020: import org.apache.avalon.framework.logger.AbstractLogEnabled;
021: import org.apache.avalon.framework.thread.ThreadSafe;
022: import org.apache.lenya.ac.Identity;
023: import org.apache.lenya.cms.observation.RepositoryEvent;
024: import org.apache.lenya.cms.observation.RepositoryListener;
025: import org.apache.lenya.transaction.IdentityMap;
026: import org.apache.lenya.transaction.IdentityMapImpl;
027: import org.apache.lenya.transaction.Lock;
028: import org.apache.lenya.transaction.Lockable;
029: import org.apache.lenya.transaction.TransactionException;
030: import org.apache.lenya.transaction.Transactionable;
031:
032: /**
033: * Shared item store implementation.
034: */
035: public class SharedItemStoreImpl extends AbstractLogEnabled implements
036: SharedItemStore, ThreadSafe {
037:
038: private IdentityMap map;
039:
040: protected synchronized IdentityMap getIdentityMap() {
041: if (this .map == null) {
042: this .map = new IdentityMapImpl(getLogger());
043: }
044: return this .map;
045: }
046:
047: public void addListener(RepositoryListener listener)
048: throws RepositoryException {
049: throw new IllegalStateException("Operation not permitted.");
050: }
051:
052: public void commit() throws RepositoryException {
053: throw new IllegalStateException("Operation not permitted.");
054: }
055:
056: public void enqueueEvent(RepositoryEvent event) {
057: throw new IllegalStateException("Operation not permitted.");
058: }
059:
060: public Identity getIdentity() {
061: throw new IllegalStateException("Operation not permitted.");
062: }
063:
064: public RepositoryItem getRepositoryItem(
065: RepositoryItemFactory factory, String key)
066: throws RepositoryException {
067: RepositoryItemFactoryWrapper wrapper = new RepositoryItemFactoryWrapper(
068: factory, this );
069: return (RepositoryItem) getIdentityMap().get(wrapper, key);
070: }
071:
072: public boolean isListenerRegistered(RepositoryListener listener) {
073: return false;
074: }
075:
076: public boolean isModifiable() {
077: return false;
078: }
079:
080: public void rollback() throws RepositoryException {
081: throw new IllegalStateException("Operation not permitted.");
082: }
083:
084: public void setIdentity(Identity identity) {
085: throw new IllegalStateException("Operation not permitted.");
086: }
087:
088: public Lock createLock(Lockable lockable, int version)
089: throws TransactionException {
090: throw new IllegalStateException("Operation not permitted.");
091: }
092:
093: public boolean isDirty(Transactionable transactionable) {
094: return false;
095: }
096:
097: public void registerDirty(Transactionable object)
098: throws TransactionException {
099: throw new IllegalStateException("Operation not permitted.");
100: }
101:
102: public void registerNew(Transactionable object)
103: throws TransactionException {
104: throw new IllegalStateException("Operation not permitted.");
105: }
106:
107: public void registerRemoved(Transactionable object)
108: throws TransactionException {
109: throw new IllegalStateException("Operation not permitted.");
110: }
111:
112: public void removeLock(Lockable lockable)
113: throws TransactionException {
114: throw new IllegalStateException("Operation not permitted.");
115: }
116:
117: public synchronized void clear() {
118: this .map = null;
119: }
120:
121: public String getId() {
122: return getClass().getName();
123: }
124:
125: }
|