View Javadoc

1   package net.sourceforge.blogentis.plugins;
2   
3   //-----------------------------------------------------------------------
4   //Blogentis - a blog publishing platform.
5   //Copyright (C) 2004 Tassos Bassoukos <abassouk@gmail.com>
6   //
7   //This library is free software; you can redistribute it and/or
8   //modify it under the terms of the GNU Lesser General Public
9   //License as published by the Free Software Foundation; either
10  //version 2.1 of the License, or (at your option) any later version.
11  //
12  //This library is distributed in the hope that it will be useful,
13  //but WITHOUT ANY WARRANTY; without even the implied warranty of
14  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  //Lesser General Public License for more details.
16  //
17  //You should have received a copy of the GNU Lesser General Public
18  //License along with this library; if not, write to the Free Software
19  //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  //-----------------------------------------------------------------------
21  //
22  //$Id: BlogPluginService.java,v 1.1 2004/10/22 17:34:14 tassos Exp $
23  //
24  
25  import java.util.Iterator;
26  
27  import net.sourceforge.blogentis.om.Blog;
28  
29  import org.apache.turbine.services.TurbineServices;
30  
31  /***
32   * @author abas
33   */
34  public class BlogPluginService {
35  
36      public static final String PLUGIN_LIST = "plugin.list";
37  
38      public static IPluginService getInstance() {
39          return (IPluginService)TurbineServices.getInstance()
40                  .getService(IPluginService.SERVICE_NAME);
41      }
42  
43      /***
44       * List the plugins in the order of their definition.
45       * 
46       * @return an iterator that returns IPlugin
47       */
48      public static Iterator getPlugins() {
49          return getInstance().getPlugins();
50      }
51  
52      /***
53       * Register a global extension point.
54       * 
55       * @param point
56       *            the global extension point to register.
57       */
58      public static void registerExtensionPoint(IExtensionPoint point) {
59          getInstance().registerExtensionPoint(point);
60      }
61  
62      /***
63       * Remove a global extension point.
64       * 
65       * @param point
66       *            the extension point to remove.
67       */
68      public static void deregisterExtensionPoint(IExtensionPoint point) {
69          getInstance().deregisterExtensionPoint(point);
70      }
71  
72      /***
73       * Register a blog-specific extension point.
74       * 
75       * @param blog
76       *            the blog that the extension point will apply.
77       * @param point
78       *            the extension point that will be registered.
79       */
80      public static void registerExtensionPoint(Blog blog,
81                                                IBlogExtensionPoint point) {
82          getInstance().registerExtensionPoint(blog, point);
83      }
84  
85      /***
86       * Remove a blog-specific extension point
87       * 
88       * @param blog
89       *            the blog that should contain the extension point.
90       * @param point
91       *            the extension point to remove.
92       */
93      public static void deregisterExtensionPoint(Blog blog,
94                                                  IBlogExtensionPoint point) {
95          getInstance().deregisterExtensionPoint(blog, point);
96      }
97  
98      /***
99       * Locate a global extension point that extends/implements the specified
100      * class.
101      * 
102      * @param name
103      * @return a global extension point instance that is castable to the
104      *         specified class.
105      */
106     public static IExtensionPoint locateExtensionPoint(Class name) {
107         return getInstance().locateExtensionPoint(name);
108     }
109 
110     /***
111      * Locate an extension point that extends/implements the specified class.
112      * 
113      * @param blog
114      *            the blog to which the extension point will belong.
115      * @param name
116      * @return the extension point instance that is castable to the specified
117      *         class.
118      */
119     public static IBlogExtensionPoint locateExtensionPoint(Blog blog, Class name) {
120         if (blog == null)
121             return null;
122         return getInstance().locateExtensionPoint(blog, name);
123     }
124 
125     /***
126      * Get the list of extension points supported by a blog.
127      * 
128      * @param blog
129      *            the blog whose extension points to list.
130      * @return an Iterator over the extension points.
131      */
132     public static Iterator getExtensionPoints(Blog blog) {
133         return getInstance().getExtensionPoints(blog);
134     }
135 }