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;
2526/***27 * Extends BaseRegistry implementation to override object creation28 * method and ensure Registry object is synchronized with its29 * persistence backend by delegating actual addition/deletion of objects30 * to the registry service.31 * <p>To avoid loops, a RegistryService implementation using this class32 * nees to call the addLocalEntry/removeLocalEntry methods to modify33 * the in memory state of this Registry</p>34 *35 * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>36 * @version $Id: BasePortletControllerRegistry.java,v 1.4 2004/02/23 03:08:26 jford Exp $37 */38publicclassBasePortletControllerRegistryextendsBaseRegistry39 {
4041/***42 * Static initialization of the logger for this class43 */44privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(BasePortletControllerRegistry.class.getName());
4546/***47 @see Registry#setEntry48 */49publicvoid setEntry( RegistryEntry entry ) throws InvalidEntryException
50 {
51// Delegate to the RegistryService to ensure correct handling of52// persistence if using file fragments5354try55 {
56 Registry.addEntry(Registry.PORTLET_CONTROLLER, entry);
57 }
58catch (RegistryException e)
59 {
60 logger.error("Exception", e);
61 }
62 }
6364/***65 @see Registry#addEntry66 */67publicvoid addEntry( RegistryEntry entry ) throws InvalidEntryException
68 {
69// Delegate to the RegistryService to ensure correct handling of70// persistence if using file fragments7172try73 {
74 Registry.addEntry(Registry.PORTLET_CONTROLLER, entry);
75 }
76catch (RegistryException e)
77 {
78 logger.error("Exception", e);
79 }
80 }
8182/***83 @see Registry#removeEntry84 */85publicvoid removeEntry( String name )
86 {
87// Delegate to the RegistryService to ensure correct handling of88// persistence if using file fragments8990 Registry.removeEntry(Registry.PORTLET_CONTROLLER, name);
91 }
9293/***94 @see Registry#removeEntry95 */96publicvoid removeEntry( RegistryEntry entry )
97 {
98// Delegate to the RegistryService to ensure correct handling of99// persistence if using file fragments100101if (entry != null)
102 {
103 Registry.removeEntry(Registry.PORTLET_CONTROLLER, entry.getName());
104 }
105 }
106107/***108 * Creates a new RegistryEntry instance compatible with the current109 * Registry instance implementation110 *111 * @return the newly created RegistryEntry112 */113publicRegistryEntry createEntry()
114 {
115returnnewBasePortletControllerEntry();
116 }
117 }