Hi all,
-- I've written a custom webapp that looks like so: package my.package.webapp;
import my.package.io.MyUploader;
public class Notifier extends MultiThreadedApplicationAdapter { private final Logger log = Red5LoggerFactory.getLogger(getClass()); private MyUploader uploader; @Override log.info("uploader = {}", uploader); } ... } I've got a JAR file, MyJar.jar, created as part of a separate project, that includes the class my.package.io.MyUploader. The JAR contains a Spring app, and MyUploader is a singleton, annotated as a @Service. I've added MyJar.jar to the webapp's pom.xml as a provided dependency, and the webapp compiles as I'd expect. I copied MyJar.jar to my Red5Pro server's lib directory. => I want Notifier to have its uploader field set to an instance of my.package.io.MyUploader at startup using Spring dependency injection I edited the webapp's red5-web.xml file and added various <bean .../> declarations like so: <bean id="uploader" class="my.package.io.Uploader" autowire="byType"/> I also tried omitting the autowire declaration, tried using byName, and more. What I expect: The appStart method runs. The log shows uploader = my.package.io.MyUploader@xxxxxx What actually happens: The appStart method runs. The log shows uploader = null My Question: How do I arrange it so my Notifier class gets a MyUploader instance injected into its uploader field? I normally use Spring with annotation-based dependency management, so I may have overlooked something obvious in my XML. Thanks, Herb --- You received this message because you are subscribed to the Google Groups "red5" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Don't use autowire. Create a property in your Notifier class of type Uploader. Create getter setter for it . In red5-web.xml instantiate your component as you have shown. Then pass the reference to your Notifier (web.handler) like so: <property name="uploader" ref="uploader" /> On Fri, 26 Oct, 2018, 2:07 AM Herb Jellinek, <[hidden email]> wrote:
--- You received this message because you are subscribed to the Google Groups "red5" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Excellent - thanks for the quick reply. For the benefit of others coming across this later, here's what I did:
-- - Added public getUploader and setUploader methods to my.package.Notifier. - Modified red5-web.xml like so: <bean id="uploader" class="my.package.io.MyUploader"/> And now the uploader field contains a MyUploader instance by the time appStart runs. Herb On Thursday, October 25, 2018 at 1:48:27 PM UTC-7, Rajdeep Rath wrote:
--- You received this message because you are subscribed to the Google Groups "red5" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |