Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Support for Compile Time DI with Play 2.4 #69

Closed
loicdescotte opened this issue Aug 27, 2015 · 3 comments
Closed

No Support for Compile Time DI with Play 2.4 #69

loicdescotte opened this issue Aug 27, 2015 · 3 comments

Comments

@loicdescotte
Copy link
Contributor

Hi,
Play 2.4 supports both runtime and compile time dependency injection.
As CommonsMailer uses @Inject it seems impossible to use it without the Guice container.
It would be nice to provide a trait that provide a "raw" mailer client and that could be mixed in Play's BuiltInComponentsFromContext to support compile time DI, like this WS Component for example.

Thanks

Loïc

@ggrossetie
Copy link
Member

Hi @loicdescotte,

With this pull request, you will be able to manually create a mailer client:

val email = Email("Simple email", "Mister FROM <[email protected]>")
new SMTPMailer(SMTPConfiguration("typesafe.org", 1234)).send(email)

AFAIK NingWS also use @Inject, for example in the NingWSAPI constructor (i.e. the dependency on Guice is provided by Play!). So basically we just need to create a trait ?

trait MailerComponents {

  def configuration: Configuration

  lazy val mailerClient = new SMTPMailer(new SMTPConfigurationProvider(configuration).get())
}

Having said that, we still need to sort out how to let user provide their own SMTPConfiguration and how to provide multiple mailer clients (for other email service providers as requested in #10)

@loicdescotte
Copy link
Contributor Author

@Mogztter great, I hope it will be merged :)
Indeed I guess we just need to create a trait like this one.

@ggrossetie
Copy link
Member

Resolved by #70

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants