1/*2 * Copyright 2000-2001,2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.om.registry.base;
1819import org.apache.jetspeed.om.registry.RegistryEntry;
20import org.apache.jetspeed.om.registry.InvalidEntryException;
21import org.apache.jetspeed.om.registry.RegistryException;
22import org.apache.jetspeed.services.Registry;
23import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
24import org.apache.jetspeed.services.logging.JetspeedLogger;
252627/***28 * Extends BaseRegistry implementation to override object creation29 * method and ensure Registry object is synchronized with its30 * persistence backend by delegating actual addition/deletion of objects31 * to the registry service.32 * <p>To avoid loops, a RegistryService implementation using this class33 * nees to call the addLocalEntry/removeLocalEntry methods to modify34 * the in memory state of this Registry</p>35 *36 * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>37 * @version $Id: BasePortletControlRegistry.java,v 1.4 2004/02/23 03:08:26 jford Exp $38 */39publicclassBasePortletControlRegistryextendsBaseRegistry40 {
4142/***43 * Static initialization of the logger for this class44 */45privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(BasePortletControlRegistry.class.getName());
4647/***48 @see Registry#setEntry49 */50publicvoid setEntry( RegistryEntry entry ) throws InvalidEntryException
51 {
52// Delegate to the RegistryService to ensure correct handling of53// persistence if using file fragments5455try56 {
57 Registry.addEntry(Registry.PORTLET_CONTROL, entry);
58 }
59catch (RegistryException e)
60 {
61 logger.error("Exception", e);
62 }
63 }
6465/***66 @see Registry#addEntry67 */68publicvoid addEntry( RegistryEntry entry ) throws InvalidEntryException
69 {
70// Delegate to the RegistryService to ensure correct handling of71// persistence if using file fragments7273try74 {
75 Registry.addEntry(Registry.PORTLET_CONTROL, entry);
76 }
77catch (RegistryException e)
78 {
79 logger.error("Exception", e);
80 }
81 }
8283/***84 @see Registry#removeEntry85 */86publicvoid removeEntry( String name )
87 {
88// Delegate to the RegistryService to ensure correct handling of89// persistence if using file fragments9091 Registry.removeEntry(Registry.PORTLET_CONTROL, name);
92 }
9394/***95 @see Registry#removeEntry96 */97publicvoid removeEntry( RegistryEntry entry )
98 {
99// Delegate to the RegistryService to ensure correct handling of100// persistence if using file fragments101102if (entry != null)
103 {
104 Registry.removeEntry(Registry.PORTLET_CONTROL, entry.getName());
105 }
106 }
107108/***109 * Creates a new RegistryEntry instance compatible with the current110 * Registry instance implementation111 *112 * @return the newly created RegistryEntry113 */114publicRegistryEntry createEntry()
115 {
116returnnewBasePortletControlEntry();
117 }
118 }