KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > om > registry > base > BasePortletControllerRegistry


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 at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * 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 and
14  * limitations under the License.
15  */

16
17 package org.apache.jetspeed.om.registry.base;
18
19 import org.apache.jetspeed.om.registry.RegistryEntry;
20 import org.apache.jetspeed.om.registry.InvalidEntryException;
21 import org.apache.jetspeed.om.registry.RegistryException;
22 import org.apache.jetspeed.services.Registry;
23 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
24 import org.apache.jetspeed.services.logging.JetspeedLogger;
25
26 /**
27  * Extends BaseRegistry implementation to override object creation
28  * method and ensure Registry object is synchronized with its
29  * persistence backend by delegating actual addition/deletion of objects
30  * to the registry service.
31  * <p>To avoid loops, a RegistryService implementation using this class
32  * nees to call the addLocalEntry/removeLocalEntry methods to modify
33  * 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  */

38 public class BasePortletControllerRegistry extends BaseRegistry
39 {
40     
41     /**
42      * Static initialization of the logger for this class
43      */

44     private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(BasePortletControllerRegistry.class.getName());
45     
46     /**
47     @see Registry#setEntry
48     */

49     public void setEntry( RegistryEntry entry ) throws InvalidEntryException
50     {
51         // Delegate to the RegistryService to ensure correct handling of
52
// persistence if using file fragments
53

54         try
55         {
56             Registry.addEntry(Registry.PORTLET_CONTROLLER, entry);
57         }
58         catch (RegistryException e)
59         {
60             logger.error("Exception", e);
61         }
62     }
63
64     /**
65     @see Registry#addEntry
66     */

67     public void addEntry( RegistryEntry entry ) throws InvalidEntryException
68     {
69         // Delegate to the RegistryService to ensure correct handling of
70
// persistence if using file fragments
71

72         try
73         {
74             Registry.addEntry(Registry.PORTLET_CONTROLLER, entry);
75         }
76         catch (RegistryException e)
77         {
78             logger.error("Exception", e);
79         }
80     }
81
82     /**
83     @see Registry#removeEntry
84     */

85     public void removeEntry( String JavaDoc name )
86     {
87         // Delegate to the RegistryService to ensure correct handling of
88
// persistence if using file fragments
89

90         Registry.removeEntry(Registry.PORTLET_CONTROLLER, name);
91     }
92
93     /**
94     @see Registry#removeEntry
95     */

96     public void removeEntry( RegistryEntry entry )
97     {
98         // Delegate to the RegistryService to ensure correct handling of
99
// persistence if using file fragments
100

101         if (entry != null)
102         {
103             Registry.removeEntry(Registry.PORTLET_CONTROLLER, entry.getName());
104         }
105     }
106
107     /**
108      * Creates a new RegistryEntry instance compatible with the current
109      * Registry instance implementation
110      *
111      * @return the newly created RegistryEntry
112      */

113     public RegistryEntry createEntry()
114     {
115         return new BasePortletControllerEntry();
116     }
117 }
118
Popular Tags