@Test public void getMailetShouldLoadClassWhenInExtensionsJars() throws Exception { GuiceGenericLoader genericLoader = GuiceGenericLoader.forTesting(new ExtendedClassLoader(CLASSPATH_FILE_SYSTEM)); GuiceMailetLoader guiceMailetLoader = new GuiceMailetLoader(genericLoader, NO_MAILET_CONFIG_OVERRIDES); Mailet mailet = guiceMailetLoader.getMailet(FakeMailetConfig.builder() .mailetName("CustomMailet") .mailetContext(FakeMailContext.defaultContext()) .build()); assertThat(mailet.getClass().getCanonicalName()) .isEqualTo("org.apache.james.transport.mailets.CustomMailet"); }
@Override public Mailet getMailet(MailetConfig config) throws MessagingException { try { ClassName className = new ClassName(config.getMailetName()); Mailet result = genericLoader.<Mailet>withNamingSheme(MAILET_NAMING_SCHEME) .instantiate(className); result.init(resolveConfiguration(result, config)); return result; } catch (Exception e) { throw new MessagingException("Can not load mailet " + config.getMailetName(), e); } }
GuiceMailetLoader implements MailetLoader { @Override public Mailet getMailet(MailetConfig config) throws MessagingException { try { ClassName className = new ClassName(config.getMailetName()); Mailet result = genericLoader.<Mailet>withNamingSheme(MAILET_NAMING_SCHEME) .instantiate(className); result.init(resolveConfiguration(result, config)); return result; } catch (Exception e) { throw new MessagingException("Can not load mailet " + config.getMailetName(), e); } } }
GuiceMailetLoader implements MailetLoader { @Override public Mailet getMailet(MailetConfig config) throws MessagingException { try { ClassName className = new ClassName(config.getMailetName()); Mailet result = genericLoader.<Mailet>withNamingSheme(MAILET_NAMING_SCHEME) .instantiate(className); result.init(resolveConfiguration(result, config)); return result; } catch (Exception e) { throw new MessagingException("Can not load mailet " + config.getMailetName(), e); } } @Inject  GuiceMailetLoader(GuiceGenericLoader genericLoader, Set<MailetConfigurationOverride> mailetConfigurationOverrides); }
GuiceMailetLoader implements MailetLoader { @Override public Mailet getMailet(MailetConfig config) throws MessagingException { try { ClassName className = new ClassName(config.getMailetName()); Mailet result = genericLoader.<Mailet>withNamingSheme(MAILET_NAMING_SCHEME) .instantiate(className); result.init(resolveConfiguration(result, config)); return result; } catch (Exception e) { throw new MessagingException("Can not load mailet " + config.getMailetName(), e); } } @Inject  GuiceMailetLoader(GuiceGenericLoader genericLoader, Set<MailetConfigurationOverride> mailetConfigurationOverrides); @Override Mailet getMailet(MailetConfig config); }
GuiceMailetLoader implements MailetLoader { @Override public Mailet getMailet(MailetConfig config) throws MessagingException { try { ClassName className = new ClassName(config.getMailetName()); Mailet result = genericLoader.<Mailet>withNamingSheme(MAILET_NAMING_SCHEME) .instantiate(className); result.init(resolveConfiguration(result, config)); return result; } catch (Exception e) { throw new MessagingException("Can not load mailet " + config.getMailetName(), e); } } @Inject  GuiceMailetLoader(GuiceGenericLoader genericLoader, Set<MailetConfigurationOverride> mailetConfigurationOverrides); @Override Mailet getMailet(MailetConfig config);  }