Re: req. Type support in SF

Steve Loughran <[email protected]> Thu, 01 Feb 2007 23:27:37 +0000
Newsgroups gmane.comp.java.smartfrog.user
Message-ID <[email protected]>
Kumaravel Ganesan wrote:
> 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.)

In the implementation class, *after all your children are deployed* (but 
not necessarily started, just deployed is enough), you can run through 
the list of children and use instanceof to check their type. Like here, 
in the TestRunnerImpl class to run child test suites:

     private boolean executeBatchTests() throws RemoteException, 
SmartFrogException {
         boolean successful = true;
         Enumeration e = sfChildren();
         while (e.hasMoreElements()) {
             Object child = e.nextElement();
             if (child instanceof TestSuite) {
                 TestSuite suiteComponent = (TestSuite) child;
                 successful &= executeTestSuite(suiteComponent);
             }
             //break out if the thread is interrupted
             if (Thread.currentThread().isInterrupted()) {
                 log.info("Test was interrupted");
                 return false;
             }
             if(!successful && !configuration.getKeepGoing()) {
                 //we have failed and asked to stop in this situation
                 log.info("Stopping tests after a failure");
                 return false;
             }
         }
         return successful;
     }

You must check interface type and not implementation, because if the 
child is remote, the child is some RMI proxy that implements the remote 
interfaces, not the implementation class.

-Steve


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642