1 21 package org.jsmtpd.core.common; 22 23 import java.util.Iterator ; 24 import java.util.LinkedList ; 25 import java.util.List ; 26 27 import org.jsmtpd.config.ModuleNotFoundException; 28 import org.jsmtpd.core.common.acl.IACL; 29 import org.jsmtpd.core.common.delivery.IDeliveryService; 30 import org.jsmtpd.core.common.dnsService.IDNSResolver; 31 import org.jsmtpd.core.common.filter.FilterTreeNode; 32 import org.jsmtpd.core.common.inputIPFilter.IFilterIP; 33 import org.jsmtpd.core.common.smtpExtension.ISmtpExtension; 34 35 40 public class PluginStore { 41 42 private static PluginStore instance = null; 43 private IACL acl = null; 44 private IDNSResolver resolver = null; 45 private IDeliveryService localDeliveryService = null; 46 private IDeliveryService remoteDeliveryService = null; 47 private LinkedList <LoadedPlugin> plugins = new LinkedList <LoadedPlugin>(); 48 private FilterTreeNode rootFilter = null; 49 private List <IFilterIP> inputIPFilterChain = new LinkedList <IFilterIP>(); 50 private List <ISmtpExtension> smtpExtensions = new LinkedList <ISmtpExtension>(); 51 52 private PluginStore() { 53 54 } 55 56 public void addPlugin(IGenericPlugin module, String logicalName) { 57 LoadedPlugin pl = new LoadedPlugin(module, logicalName); 58 plugins.add(pl); 59 } 60 61 public List <IGenericPlugin> getFilterList() { 62 LinkedList <IGenericPlugin> fl = new LinkedList <IGenericPlugin>(); 63 for (Iterator iter = plugins.iterator(); iter.hasNext();) { 64 LoadedPlugin element = (LoadedPlugin) iter.next(); 65 fl.add(element.getModule()); 66 } 67 return fl; 68 } 69 70 public IGenericPlugin getPluginByLogicalName(String logicalName) throws ModuleNotFoundException { 71 for (Iterator iter = plugins.iterator(); iter.hasNext();) { 72 LoadedPlugin element = (LoadedPlugin) iter.next(); 73 if (element.getLogicalName().equals(logicalName)) 74 return element.getModule(); 75 } 76 77 throw new ModuleNotFoundException(logicalName); 78 } 79 80 public static PluginStore getInstance() { 81 if (instance == null) 82 instance = new PluginStore(); 83 84 return instance; 85 } 86 87 public IACL getAcl() { 88 return acl; 89 } 90 91 public void setAcl(IACL acl) { 92 this.acl = acl; 93 } 94 95 public IDNSResolver getResolver() { 96 return resolver; 97 } 98 99 public void setResolver(IDNSResolver resolver) { 100 this.resolver = resolver; 101 } 102 103 public IDeliveryService getLocalDeliveryService() { 104 return localDeliveryService; 105 } 106 107 public void setLocalDeliveryService(IDeliveryService localDeliveryService) { 108 this.localDeliveryService = localDeliveryService; 109 } 110 111 public IDeliveryService getRemoteDeliveryService() { 112 return remoteDeliveryService; 113 } 114 115 public void setRemoteDeliveryService(IDeliveryService remoteDeliveryService) { 116 this.remoteDeliveryService = remoteDeliveryService; 117 } 118 119 public FilterTreeNode getRootFilter() { 120 return rootFilter; 121 } 122 123 public void setRootFilter(FilterTreeNode rootFilter) { 124 this.rootFilter = rootFilter; 125 } 126 127 public List <IFilterIP> getInputIPFilters() { 128 return inputIPFilterChain; 129 } 130 131 public void addInputIPFilters(IFilterIP in) { 132 inputIPFilterChain.add(in); 133 } 134 135 public void addSmtpExtensions(ISmtpExtension ext) { 136 smtpExtensions.add(ext); 137 return; 138 } 139 140 public List <ISmtpExtension> getSmtpExtensions() { 141 return smtpExtensions; 142 } 143 } | Popular Tags |