Trace: Object Injection


Object Injection

Occasionally, it's important to add external objects in your running application without additional coding. We have an injection mechanism which is pretty simple. It's possible to inject custom Java objects or objects which implements the interface IInjectObject. The difference is that simple objects don't use an init method:

public interface IInjectObject
    public String getDefaultName();	
    public void init(ISession pSession);

To inject the object, simply put the configuration in config.xml:

The injection is

<?xml version="1.0" encoding="UTF-8"?>
    <!-- inject in every LCO -->
    <inject class="" name="myClass"/>
    <!-- inject in specific LCO -->
    <inject ...>
      <allow instanceof="com.sibvisions.rad.server.MasterSession"/>
      <allow lifecyclename=""/>

It's also possible to inject by ServiceLoader. Simply create a file with the name com.sibvisions.rad.server.IInjectObject in META-INF/services, in your classpath. The file should contain one line per object:

Be sure that MyInjectObject implements IInjectObject.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information