Eric V
Eric V

Reputation: 1170

Instantiate Bean/Service with Spring IoC

With Java-APNS, they create a service like this:

 ApnsService service = APNS.newService()
     .withCert("C:/temp/myCertificate.p12", "p@ssw0rd")
     .withSandboxDestination()
     .build();

ApnsService is a Java Interface.

I'd like to instantiate this service with Spring and inject it in another service, any idea?

Best thanks to you!

Upvotes: 0

Views: 569

Answers (1)

duffymo
duffymo

Reputation: 308928

You may be able to do it in Spring by designating a factory method in the application context for that bean, but it could be tricky. The Bloch builder idiom is not what Spring had in mind.

Upvotes: 1

Related Questions