1 package net.sourceforge.blogentis.plugins.impl;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import java.util.ArrayList;
26 import java.util.Iterator;
27 import java.util.List;
28
29 import net.sourceforge.blogentis.plugins.BlogPluginService;
30 import net.sourceforge.blogentis.plugins.IExtensionPoint;
31
32 import org.apache.commons.logging.Log;
33 import org.apache.commons.logging.LogFactory;
34
35 /***
36 * An ArrayList that handles extension point management.
37 *
38 * @author abas
39 */
40 class ExtensionPointList {
41 private static final Log log = LogFactory.getLog(BlogPluginService.class);
42
43 private List list = new ArrayList();
44
45 public synchronized void registerExtensionPoint(IExtensionPoint point) {
46 if (list.contains(point)) {
47 log.warn("Extension point '" + point.getName()
48 + "' already exists for addition");
49 return;
50 }
51 list.add(point);
52 }
53
54 public synchronized void deregisterExtensionPoint(IExtensionPoint point) {
55 if (list.contains(point)) {
56 log.warn("Extension point '" + point.getName()
57 + "' does not exits for removal");
58 return;
59 }
60 list.remove(point);
61 }
62
63 public synchronized IExtensionPoint locateExtensionPoint(Class name) {
64 for(Iterator i = list.iterator(); i.hasNext();) {
65 Object o = i.next();
66 if (name.isInstance(o))
67 return (IExtensionPoint)o;
68 }
69 return null;
70 }
71
72 public Iterator iterator(){
73 return list.iterator();
74 }
75 }