简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM