2.6 Function Blocks Example

Example - Function Blocks Example

package com.mediationzone.java_agent;

import com.digitalroute.mz.java.agents.RealtimeAgent;
import com.digitalroute.mz.java.agents.api.AgentEnv;
import com.digitalroute.mz.java.agents.api.ConfigDefinition;
import com.digitalroute.mz.java.agents.UDRInterface;
import java.util.Map;

public class HelloworldAgent implements RealtimeAgent {

    @Override
    public void configure(ConfigDefinition cfg) {
        cfg.defineOutput(byte[].class, UDRInterface.class);
        //cfg.defineOutput(Your_UDR.class);
        //cfg.defineOutput("routename", Your_UDR.class);
    }

    @Override
    public void deinitialize(AgentEnv env) throws Exception {

    }

    @Override
    public void init(AgentEnv env, Map<String,String> userdata) throws Exception {

    }

    @Override
    public void consume(UDRInterface input, AgentEnv env) throws Exception {
        //  try {
        //    env.debug(input);
        //
        //    Your_UDR newUdr = env.createUDR(Your_UDR.class);
        //
        //    Your_UDR udr = (Your_UDR) input;
        //  } catch (Exception e) {
        //    throw new RuntimeException(e);
        //  }
        //
        env.debug("Hello World");
        env.route(input);
    }

    @Override
    public void consume(byte[] input, AgentEnv env) throws Exception {
        env.debug("Hello World");
        env.route(input);
    }

    @Override
    public Object getMIM(String mimName) {
        return null;
    }

}