Re: req. Type support in SF

"Guijarro, Julio" <[email protected]> Fri, 16 Feb 2007 13:47:28 -0000
Newsgroups gmane.comp.java.smartfrog.user
Message-ID <[email protected]>
Hi,

 

The SF language is not a programming language and we don't have that
kind of support built in, but the language

is extensible using functions.

 

For example, you can create a function that checks the object Types and
put them in a container but note that

in your example "pointcut" is not the object type, it is the name of the
object that it references

and this makes more difficult what you want to do. The alternative would
be to put a particular attribute inside

"pointcut" that declares the type for your "search".

 

Another alternative can be to use the BeanShell scripting component and
use its function extension to add new 

functionality directly in the description, check function_expression.sf
(attached) 

from org/smartfrog/services/scripting/examples/

 

I have attached an example that implement the first option, see attached
files (TypeSelect.java, function.sf, example.sf).

To try then you only need to create a new directory under
src/org/smartfrog/services called "typeselector",

compile and then deploy (using sfStart) or parse (using sfParse) the
description 

org/smartfrog/services/typeselector/example.sf

 

Some notes:

The function will try to find ComponentDescriptions tha contain an
attribute called "x" where x is defined in the function attribute

"selectionType". Another attribute checked by the function is
"selectionLazy" to determined if the result is LAZY or not.

 

sfFunctionLazy is an  "attribute" valid for any function. It tells the
parser no to resolve it during parsing time.

A LAZY function will be re-evealuated at runtime every time the function
attribute is resolved.

Also, a function becomes automatically LAZY if it contains a LAZY
attribute (we had this before),

even if the sfFunctionLazy attribute was not added.

 

Now, in the example function provided, I have added a special attribute
(selectionLazy) that controls if the 

result of parsing the function is LAZY or not.

This new attribute is only of use when the Funcion is not LAZY itself.

 

Summarizing:

sfFunctionLazy true; -> only runs the function code at runtime. Valid
for every function.

 

selectionLazy true> the result of the function will be LAZY (so for
example, the resulting ComponentDescription

                    in our example it does not get deployed).

                    This will only have some effect when the function is
run by the parser ( sfFunctionLazy false;)

 

You can play with both to understand the differences, especially using
SFParse.

 

The example used:

 

 

#include "org/smartfrog/components.sf"

#include "org/smartfrog/functions.sf"

 

#include "org/smartfrog/services/typeselector/function.sf"

 

pointcut extends {

  myType;

}

 

 

myPC0 extends pointcut {

     param  "(object key, object o)";

     call "(* Cashe.put(object key, object o))&&";

     noton  "(jphost)";

}

 

myPC1 extends pointcut {

     // sfProcessHost ATTRIB hostA;

     param  "method(..args)";

     execution "method";

}

 

 

 

easyHook extends typeSelect {

   //sfFunctionLazy true; //For runtime(true) or parse(false) time
evaluation

   selectionType "myType";

   selectionLazy false;

   pc0 extends myPC0;

   pc1 extends myPC1;

}

 

sfConfig extends Compound {

  test extends easyHook;

}

 

 

This does produce:

 

For Lazy function:

 

sfCodeBase "default";

sfClass "org.smartfrog.sfcore.compound.CompoundImpl";

//Unresolved function. Let alone until runtime

test LAZY APPLY {sfFunctionClass
"org.smartfrog.services.typeselector.TypeSelect";

    selectionLazy false;

    sfFunctionLazy true;

    selectionType "myType";

    pc0 extends  {

      myType "";

      param "(object key, object o)";

      call "(* Cashe.put(object key, object o))&&";

      noton "(jphost)";

    }

 

    pc1 extends  {

      myType "";

      param "method(..args)";

      execution "method";

    }

};

 

And at runtime you can see that the value contains the function
unresolved (check '*Value:' in screenshot) and what happens when it is
resolved (check '*Value resolved:' in screenshot). With the management
console it is also possible to play with the attributes and observe what
happens when the function is re-evaluated:

 

 

 

For not LAZY function:

 

sfCodeBase "default";

sfClass "org.smartfrog.sfcore.compound.CompoundImpl";

test extends  {

  selectionLazy false;

  selectionType "myType";

  pc0 extends  {

    myType "";

    param "(object key, object o)";

    call "(* Cashe.put(object key, object o))&&";

    noton "(jphost)";

  }

  pc1 extends  {

    myType "";

    param "method(..args)";

    execution "method";

  }

  //-> New CompDesc created by the function

  selectionResults extends  {

    pc0 extends  {

      myType "";

      param "(object key, object o)";

      call "(* Cashe.put(object key, object o))&&";

      noton "(jphost)";

    }

    pc1 extends  {

      myType "";

      param "method(..args)";

      execution "method";

    }

  }

}

 

Regards, 

 

Julio Guijarro

________________________________

From: smartfrog-support-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
[mailto:smartfrog-support-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of
Kumaravel Ganesan
Sent: 31 January 2007 10:22
To: smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [Smartfrog-support] req. Type support in SF

 

Hi , 

I knew that , SF language is untyped language. but still i am looking
for any work around.

Is there any way to get a "list of all atributes" which is a "TYPE of
Component" . 


For example, 
___________________________________dado_example.sf_______________
myPC0 extends pointcut
    {
    param  "(object key, object o)";
    call "(* Cashe.put(object key, object o))&&";
    not-on  "(jphost)";
    }

    myPC1 extends pointcut
    {
   // sfProcessHost ATTRIB hostA;
    param  "method(..args)";
    execution "method";
    }

    easy_Hook extends hook
    {
   
    pc ATTRIB myPC1;
   pc2 ATTRIB myPC2;
   ..
   ...

    advice ##
            after() {
            System.out.println("after");
            }
        #;
    }
------------------------------------------------------------------------
------

in hook.impl class, i would like to get the list of all attributes which
is type of pointcut (or which extends pointcut). 
(the number of  pc's may vary time to time.)


-- 
Thanks,
Kumaravel Ganesan
Research Student
Dr.MGR EDUCATIONAL AND RESEARCH INSTITUTE
Chennai , India
email : [email protected]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Smartfrog-support mailing list
Smartfrog-support-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/smartfrog-support
image002.jpg (image/jpeg, 96.9 KB) - not displayed
function_expression.sf (application/octet-stream, 2.8 KB) - not displayed
TypeSelect.java (application/octet-stream, 4.3 KB) - not displayed
function.sf (application/octet-stream, 1.2 KB) - not displayed
example.sf (application/octet-stream, 1.5 KB) - not displayed