ObjectWeb Consortium
Search ObjectWeb Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | proactive List | September 2003 Index

    Date Index  -->     Thread Index  -->

Re: I have a cuestion?


This section is about the activity of  active objects.
you can define the activity inside the Active Object by implementing interfaces InitActive, RunActive, EndActive.
public class A implements InitActive, RunActive {
    private String myName;

    public String getName() {
      return myName;
    }

    // -- implements InitActive
    public void initActivity(Body body) {
      myName = body.getName();
    }

    // -- implements RunActive for serving request in a LIFO fashion
    public void runActivity(Body body) {
      Service service = new Service(Body);
      while (body.isActive()) {             //----------------------------------- in this method you have access to the internal state of the AO
        service.blockingServeYoungest();
      }
    }

    public static void main(String[] args) throws Exception {
      A a = (A) ProActive.newActive("A",null);
      System.out.println("Name = "+a.getName());
    }
  }
But if you want to create a generic activity for several Active Objects, you can create a class that implements RunActive and pass this class as parameter when calling newActive. But since RunActive is defined outside the reified object, you cannot get access to the internal state of the AO
 
public class LIFOActivity implements RunActive {
    // -- implements RunActive for serving request in a LIFO fashion
    public void runActivity(Body body) {
      Service service = new Service(Body);
      while (body.isActive()) {
        service.blockingServeYoungest();
      }
    }
  }
-----------------------------------------------------------------------------------------------------------------------------
  import org.objectweb.proactive.*;
  public class A implements InitActive {
    private String myName;

    public String getName() {
      return myName;
    }

    // -- implements InitActive
    public void initActivity(Body body) {
      myName = body.getName();
    }

    public static void main(String[] args) throws Exception {
      // newActive(classname, constructor parameter (null = none),
      //           node (null = local), active, MetaObjectFactory (null = default)
      A a = (A) ProActive.newActive("A", null, null, new LIFOActivity(), null); --> class LIFO is passed as parameter of newActive
      System.out.println("Name = "+a.getName());
    }
  }
 
Let me know if it is clear enough

----- Original Message -----
Sent: Thursday, September 04, 2003 2:30 AM
Subject: I have a cuestion?

Hi.
I have a cuestion?
in the tutorial , in Active OBjects: creation and advanced concepts in the part :"Passing an object implementing the interfaces when creating the active object".
 

in this part --> Comparing to the solution above where interfaces are directly implemented in the reified class, there is one

restriction here : you cannot access the internal state of the reified object. Using an external object should

therefore be used when the implementation of the activity is generic enough not to have to access the member

variables of the reified object.

 

that it means, that in this new solution if it is possible to obtain the internal state of the abstraido
object?.

bocause this solution it shows the name of the class

 



Charla con tus amigos en línea mediante MSN Messenger: Haz clic aquí with MSN 8.


    Date Index  -->     Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 1999-2005, ObjectWeb Consortium | contact | webmaster.