/** * Add all default handlers to the chain and the given {@link Hook}'s. After that {@link #wireExtensibleHandlers()} is called * * @param hooks * @throws WiringException */ public SMTPProtocolHandlerChain(MetricFactory metricFactory, Hook... hooks) throws WiringException { this(metricFactory, true); for (Hook hook : hooks) { add(hook); } wireExtensibleHandlers(); }
public SMTPProtocolHandlerChain(MetricFactory metricFactory, boolean addDefault) { this.metricFactory = metricFactory; if (addDefault) { addAll(initDefaultHandlers()); } }
@Override public void add(int index, ProtocolHandler element) { checkForAuth(element); super.add(index, element); }
private synchronized boolean checkForAuth(ProtocolHandler handler) { if (isReadyOnly()) { throw new UnsupportedOperationException("Read-Only"); } if (handler instanceof AuthHook) { // check if we need to add the AuthCmdHandler List<ExtensibleHandler> handlers = getHandlers(ExtensibleHandler.class); for (ExtensibleHandler h: handlers) { if (h.getMarkerInterfaces().contains(AuthHook.class)) { return true; } } if (!add(new AuthCmdHandler())) { return false; } } return true; }
private Protocol createProtocol(Optional<ProtocolHandler> handler) throws WiringException { SMTPProtocolHandlerChain chain = new SMTPProtocolHandlerChain(new NoopMetricFactory()); if (handler.isPresent()) { chain.add(handler.get()); } chain.wireExtensibleHandlers(); return new SMTPProtocol(chain, new SMTPConfigurationImpl()); }
protected Protocol createProtocol(ProtocolHandler... handlers) throws WiringException { SMTPProtocolHandlerChain chain = new SMTPProtocolHandlerChain(new NoopMetricFactory()); chain.addAll(0, Arrays.asList(handlers)); chain.wireExtensibleHandlers(); return new SMTPProtocol(chain, new SMTPConfigurationImpl()); }
private Protocol createProtocol(Optional<ProtocolHandler> handler) throws WiringException { SMTPProtocolHandlerChain chain = new SMTPProtocolHandlerChain(new NoopMetricFactory()); if (handler.isPresent()) { chain.add(handler.get()); } chain.wireExtensibleHandlers(); return new SMTPProtocol(chain, new SMTPConfigurationImpl()); }
protected Protocol createProtocol(ProtocolHandler... handlers) throws WiringException { SMTPProtocolHandlerChain chain = new SMTPProtocolHandlerChain(new NoopMetricFactory()); chain.addAll(0, Arrays.asList(handlers)); chain.wireExtensibleHandlers(); return new SMTPProtocol(chain, new SMTPConfigurationImpl()); }
@Override public boolean add(ProtocolHandler handler) { checkForAuth(handler); return super.add(handler); }