/** * @see org.apache.mailet.MailetContext#getPostmaster() */ public MailAddress getPostmaster() { return mailServer.getPostmaster(); }
@Override protected boolean useVirtualHosting() { return mailServer.supportVirtualHosting(); } }
/** * (non-Javadoc) * @see org.apache.james.protocols.smtp.core.RcptCmdHandler#getDefaultDomain() */ protected String getDefaultDomain() { return mailServer.getDefaultDomain(); } }
@PostConstruct public void init() throws Exception { HierarchicalConfiguration conf = config.configurationAt("table"); ClassLoader loader = Thread.currentThread().getContextClassLoader(); String repName = conf.getString("[@name]", null); String repClass = conf.getString("[@class]"); if (repName == null) { repName = repClass; } if (log.isDebugEnabled()) { log.debug("Starting " + repClass); } vut = (VirtualUserTable) instanceFactory.newInstance(loader .loadClass(repClass), log, conf); if (log.isInfoEnabled()) { StringBuffer logBuffer = new StringBuffer(64).append("Bean ") .append(repName).append(" started."); log.info(logBuffer.toString()); } }
/** * @see org.apache.james.pop3server.POP3HandlerConfigurationData#getHelloName() */ public String getHelloName() { if (POP3Server.this.getHelloName() == null) { return POP3Server.this.mailServer.getHelloName(); } else { return POP3Server.this.getHelloName(); } }
@SuppressWarnings("unchecked") public void sendMail(MailAddress sender, Collection recipients, MimeMessage message, String state) throws MessagingException { MailImpl mail = new MailImpl(mailServer.getId(), sender, recipients, message); try { mail.setState(state); sendMail(mail); } finally { LifecycleUtil.dispose(mail); } }
public final <T> T newInstance(Class<T> clazz, Log log, HierarchicalConfiguration config) throws InstanceException { try { T obj = clazz.newInstance(); injectResources(obj); postConstruct(obj); synchronized (this) { loaderRegistry.add(obj); } return obj; } catch (Exception e) { throw new InstanceException("Unable to load instance of class " + clazz, e); } }
/** * Set the destination for the repository * * @param destination the destination under which the repository get stored * @throws ConfigurationException * @throws ConfigurationException get thrown on invalid destintion syntax */ protected void setDestination( final String destination ) throws ConfigurationException { if( !destination.startsWith( FileSystem.FILE_PROTOCOL ) ){ throw new ConfigurationException( "cannot handle destination " + destination); } try { m_baseDirectory = fileSystem.getFile(destination); } catch (FileNotFoundException e) { throw new ConfigurationException("Unable to acces destination " + destination, e); } }
public final <T> T newInstance(Class<T> clazz) throws InstanceException { return newInstance(clazz, null, null); }
/** * Dispose all loaded instances by calling the method of the instances which * is annotated with @PreDestroy */ public synchronized void dispose() { for (int i = 0; i < loaderRegistry.size(); i++) { try { preDestroy(loaderRegistry.get(i)); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } loaderRegistry.clear(); }
private void injectResources(Object resource) { final Method[] methods = resource.getClass().getMethods(); for (Method method : methods) { final Resource resourceAnnotation = method.getAnnotation(Resource.class); if (resourceAnnotation != null) { final String name = resourceAnnotation.name(); if (name == null) { throw new UnsupportedOperationException("Resource annotation without name specified is not supported by this implementation"); } else { // Name indicates a service final Object service = getObjectForName(name); if (service == null) { throw new RuntimeException("Injection failed for object " + resource + " on method " + method + " with resource name " + name + ", because no mapping was found"); } else { try { Object[] args = { service }; method.invoke(resource, args); } catch (IllegalAccessException e) { throw new RuntimeException("Injection failed for object " + resource + " on method " + method + " with resource " + service, e); } catch (IllegalArgumentException e) { throw new RuntimeException("Injection failed for object " + resource + " on method " + method + " with resource " + service, e); } catch (InvocationTargetException e) { throw new RuntimeException("Injection failed for object " + resource + " on method " + method + " with resource " + service, e); } } } } } }
@PostConstruct public void init() throws Exception { HierarchicalConfiguration conf = config.configurationAt("domainlist"); ClassLoader loader = Thread.currentThread().getContextClassLoader(); String repName = conf.getString("[@name]", null); String repClass = conf.getString("[@class]"); if (repName == null) { repName = repClass; } if (log.isDebugEnabled()) { log.debug("Starting " + repClass); } domainList = (DomainList) instanceFactory.newInstance(loader .loadClass(repClass), log, conf); if (log.isInfoEnabled()) { StringBuffer logBuffer = new StringBuffer(64).append("Bean ") .append(repName).append(" started."); log.info(logBuffer.toString()); } }
/** * @see org.apache.james.protocols.smtp.SMTPConfiguration#getHelloName() */ public String getHelloName() { if (SMTPServer.this.getHelloName() == null) { return SMTPServer.this.mailServer.getHelloName(); } else { return SMTPServer.this.getHelloName(); } }
/** * @see org.apache.mailet.MailetContext#isLocalEmail(org.apache.mailet.MailAddress) */ public boolean isLocalEmail(MailAddress mailAddress) { String userName = mailAddress.toString(); if (!isLocalServer(mailAddress.getDomain())) { return false; } if (mailServer.supportVirtualHosting() == false) { userName = mailAddress.getLocalPart(); } return localusers.contains(userName); }
/** * Handler method called upon receipt of a DATA command. * Reads in message data, creates header, and delivers to * mail server service for delivery. * * @param session SMTP session object * @param argument the argument passed in with the command by the SMTP client */ protected SMTPResponse doDATA(SMTPSession session, String argument) { try { MimeMessageInputStreamSource mmiss = new MimeMessageInputStreamSource(mailServer.getId()); session.getState().put(SMTPConstants.DATA_MIMEMESSAGE_STREAMSOURCE, mmiss); } catch (MessagingException e) { session.getLogger().warn("Error creating mimemessagesource for incoming data",e); return new SMTPResponse(SMTPRetCode.LOCAL_ERROR, "Unexpected error preparing to receive DATA."); } // out = new PipedOutputStream(messageIn); session.pushLineHandler(getLineHandler()); return new SMTPResponse(SMTPRetCode.DATA_READY, "Ok Send data ending with <CRLF>.<CRLF>"); }
/** * @see org.apache.james.protocols.smtp.core.MailCmdHandler#getDefaultDomain() */ public String getDefaultDomain() { return mailServer.getDefaultDomain(); }
sqlFile = fileSystem.getFile(sqlFileUrl); sqlFileUrl = null; } catch (Exception e) {
/** * (non-Javadoc) * @see org.apache.james.mailetcontainer.api.MailetLoader#getMailet(java.lang.String, org.apache.commons.configuration.Configuration) */ public Mailet getMailet(final String mailetName, final Configuration configuration) throws MessagingException { try { for (final String packageName:packages) { final String className = packageName + mailetName; try { final Mailet mailet = (Mailet)factory.newInstance(Thread.currentThread().getContextClassLoader().loadClass(className)); final MailetConfigImpl configImpl = new MailetConfigImpl(); configImpl.setMailetName(mailetName); configImpl.setConfiguration(configuration); configImpl.setMailetContext(mailetContext); mailet.init(configImpl); return mailet; } catch (ClassNotFoundException cnfe) { //do this so we loop through all the packages } } throw classNotFound(mailetName); } catch (MessagingException me) { throw me; } catch (Exception e) { e.printStackTrace(); throw loadFailed(mailetName, e); } }
/** * @see org.apache.james.protocols.smtp.SMTPConfiguration#getHelloName() */ public String getHelloName() { if (LMTPServer.this.getHelloName() == null) { return LMTPServer.this.mailServer.getHelloName(); } else { return LMTPServer.this.getHelloName(); } }
/** * @see org.apache.mailet.MailetContext#isLocalUser(String) */ public boolean isLocalUser(String name) { if (name == null) { return false; } try { if (name.indexOf("@") == -1) { return isLocalEmail(new MailAddress(name, mailServer.getDefaultDomain())); } else { return isLocalEmail(new MailAddress(name)); } } catch (ParseException e) { log("Error checking isLocalUser for user " + name); return false; } }