Package agentj.thread

Examples of agentj.thread.Controller


        task.period = period;
        task.state = TimerTask.SCHEDULED;

        queue.add(task);

        Controller controller = AgentJVirtualMachine.getCurrentNS2NodeController();
        double delayMillis = (double) (time - javm.lang.System.currentTimeMillis()) / 1000.0;

        ProtolibTimer protoTimer = new ProtolibTimer(controller, delayMillis, 0);
        protoTimer.startTimerAndNotifyOnTimeout(task);
  logger.trace("javm/util/Timer: sched leaving");
View Full Code Here


        Class c = null;
        String javaClass = args[0];
        String nsAgentPtrString = args[1];
        String hostName = args[2];

        Controller controller = new Controller();
        Ns2Node nsnode = new Ns2MobileNode(hostName, controller);
        controller.setNodePropperties(nsnode);
        setCurrentNode(nsnode); // sets current AgentJ node running

        AgentJObjectItem item;

        logger.trace("NS-2 Object with ID " + nsAgentPtrString + " Being Registered");

        try {
            // Here instantiate a ClassLoader - segements each agent into a different namespace
            // Classload loader = ClassLoader.getSystemClassLoader() or instantiate our own
            // loader.loadClass(javaClass);
            c = TransformClassLoader.getClass(javaClass);
        } catch (ClassNotFoundException cnf) {
            logger.error("AgentJVirtualMachine.java:  Class " + javaClass + " NOT FOUND\n" +
                    "TIP: Check the your classpath and name of class\n" +
                    "TIP: Check you have inclued the correct Java package");
            throw cnf;
        }

        logger.trace("Class = " + c.getName());

        Object tobj = null;

        try {
            tobj = c.newInstance();
        } catch (InstantiationException ie) {
            logger.error("AgentJVirtualMachine.java:  Class " + javaClass + " could not be instantiated"
                    + "\nTIP: Does it extend the AgentJNode ?");
            throw ie;
        } catch (IllegalAccessException iae) {
            logger.error("AgentJVirtualMachine.java:  Class " + javaClass + " threw an illegal Access Exception"
                    + "\nTIP: is the class public ?");
            throw iae;
        } catch (Exception ie) {
            ie.printStackTrace();
        }

        AgentJAgent agentJObject = null;

        try {
            logger.trace("Object is " + tobj.getClass().getName());
            agentJObject = (AgentJAgent) tobj;
        } catch (ClassCastException e) {
            logger.fatal("Class " + tobj.getClass().getName() + " does not implement necessary interface, agentj.AgentJNode");
            e.printStackTrace();
            System.exit(1);
        }

        logger.trace("Registered classname: " + javaClass);

        long nsAgentPtr = Long.parseLong(nsAgentPtrString.substring(2), 16);

        // set local variables

        nsnode.setAgent(agentJObject);
        agentJObject.ns2Node = nsnode;

        controller.setAgentProperties(nsAgentPtr, agentJObject);
        agentJObject.controller = controller; // set the controller for the node.
        agentJObject.id = idCount;
        ++idCount;
        agentJObject._nsAgentPtr = nsAgentPtr; // sets the agentJ pointer for this node
View Full Code Here

TOP

Related Classes of agentj.thread.Controller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.