Carsten Ziegeler | 7853b9a | 2008-01-11 16:30:24 +0000 | [diff] [blame^] | 1 | /* |
Felix Meschberger | add2b4a | 2007-04-11 18:12:33 +0000 | [diff] [blame] | 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.apache.felix.cm.impl; |
| 20 | |
| 21 | |
| 22 | import java.io.IOException; |
| 23 | import java.util.Dictionary; |
| 24 | import java.util.Enumeration; |
| 25 | |
| 26 | import org.apache.felix.cm.PersistenceManager; |
| 27 | |
| 28 | |
| 29 | /** |
| 30 | * The <code>PersistenceManagerProxy</code> TODO |
| 31 | * |
| 32 | * @author fmeschbe |
| 33 | */ |
| 34 | class PersistenceManagerProxy implements PersistenceManager |
| 35 | { |
| 36 | |
| 37 | private PersistenceManager delegatee; |
| 38 | |
| 39 | |
| 40 | PersistenceManagerProxy( PersistenceManager delegatee ) |
| 41 | { |
| 42 | setPersistenceManager( delegatee ); |
| 43 | } |
| 44 | |
| 45 | |
| 46 | /** |
| 47 | * @param pid |
| 48 | * @throws IOException |
| 49 | * @see org.apache.felix.cm.PersistenceManager#delete(java.lang.String) |
| 50 | */ |
| 51 | public void delete( String pid ) throws IOException |
| 52 | { |
| 53 | checkDelegatee(); |
| 54 | delegatee.delete( pid ); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | /** |
| 59 | * @param pid |
Felix Meschberger | add2b4a | 2007-04-11 18:12:33 +0000 | [diff] [blame] | 60 | * @see org.apache.felix.cm.PersistenceManager#exists(java.lang.String) |
| 61 | */ |
| 62 | public boolean exists( String pid ) |
| 63 | { |
| 64 | return delegatee != null && delegatee.exists( pid ); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | /** |
Felix Meschberger | add2b4a | 2007-04-11 18:12:33 +0000 | [diff] [blame] | 69 | * @throws IOException |
| 70 | * @see org.apache.felix.cm.PersistenceManager#getDictionaries() |
| 71 | */ |
| 72 | public Enumeration getDictionaries() throws IOException |
| 73 | { |
| 74 | checkDelegatee(); |
| 75 | return delegatee.getDictionaries(); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | /** |
| 80 | * @param pid |
Felix Meschberger | add2b4a | 2007-04-11 18:12:33 +0000 | [diff] [blame] | 81 | * @throws IOException |
| 82 | * @see org.apache.felix.cm.PersistenceManager#load(java.lang.String) |
| 83 | */ |
| 84 | public Dictionary load( String pid ) throws IOException |
| 85 | { |
| 86 | checkDelegatee(); |
| 87 | return delegatee.load( pid ); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | /** |
| 92 | * @param pid |
| 93 | * @param properties |
| 94 | * @throws IOException |
| 95 | * @see org.apache.felix.cm.PersistenceManager#store(java.lang.String, java.util.Dictionary) |
| 96 | */ |
| 97 | public void store( String pid, Dictionary properties ) throws IOException |
| 98 | { |
| 99 | checkDelegatee(); |
| 100 | delegatee.store( pid, properties ); |
| 101 | } |
| 102 | |
| 103 | |
| 104 | void setPersistenceManager( PersistenceManager delegatee ) |
| 105 | { |
| 106 | this.delegatee = delegatee; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | void checkDelegatee() throws IOException |
| 111 | { |
| 112 | if ( delegatee == null ) |
| 113 | { |
| 114 | throw new IOException( "PersistenceManager not valid" ); |
| 115 | } |
| 116 | } |
| 117 | } |