On Mon, Jun 16, 2008 at 11:47 AM, Ramkumar R <[EMAIL PROTECTED]> wrote:

> Here is the brief summary on the monitor extensions, please review the same
> and post your comments and suggestions on the same. This would help us for
> the documentation.
> **
> *Need for Monitor Extension:*
> **The need for monitor extension came as a requirement, to have a
> customized
> exception handling on Tuscany runtime especially when the user input errors
> are determined while reading, resolving and building phase of the
> contribution within the Tuscany runtime. Here different users/vendors using
> Tuscany with their products wanted to ignore some of the user input errors
> and allow the runtime to proceed further, while the others wanted to stop
> processing when a error is determined at the end of each phase.
>
>
>
> Another important need for a monitor extension is to validate the user
> inputs (via contributions) and report all the issues identified in one go
> (Example: As how the java compiler does for java code).
>
> * *
> *How monitor extension is applied to the current code:*
> Currently monitors are introduced into various part of the code, where we
> do
> a validation for user input at different phases while reading, resolving
> and
> building the contribution.
> **
>
> **
>
> 1. Errors and warnings are logged with the monitor as problems and the
> processing
> continues. Exceptions won't be thrown, where ever possible. Processing here
> covers any processing of user input, i.e. contributions and the artifacts
> they contain.
>
>
>
> 2. After each phase namely read, resolve and build contribution, the
> problems
> are read from the monitor for display to the user (currently this will have
> already happened as our current monitor will just log errors and warnings
> as
> it receives them but you can imagine more capable monitors).
>
>
>
> 3. The controlling logic may look at the errors and warnings it is
> reporting
> to the user and prevent further processing occurring. Or it may allow
> processing
> to continue. This  depends on which bit of processing we are talking about
> and what errors have been reported.
>
> * *
>
> *How to initialize the monitor from the core runtime:*
>
> Monitors are initialized in the core runtime using the utility extensions
> as
> shown below.
>
>
>
> UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(
> UtilityExtensionPoint.*class*);
>
> MonitorFactory monitorFactory =
> utilities.*getUtility*(MonitorFactory.*class
> *);
>
> monitor = monitorFactory.createMonitor();
>
>
>
> * *
>
> *Creating a Monitor Extension:*
>
> * *
>
> *NOTE: *Please have a look at the interface design of Monitor, Problem and
> MonitorFactory from monitor module in the Tuscany source code.**
>
> * *
>
> *Step 1:  *Create a class MyMonitorImpl.java which implements the Monitor
> interface.
>
>
>
> *public* *class* MyMonitorImpl* implements* Monitor {
>
>    *private* *static* *final* Logger *logger* = Logger.*getLogger*(
> MyMonitorImpl.*class*.getName());
>
>
>
>    // Cache all the problem reported to monitor for further analysis
>
>    *private* List<Problem> problemCache = *new* ArrayList<Problem>();
>
>
>
>    *public* *void* problem(Problem problem) {
>
>        // Your custom code to handle the problem
>
>    }
>
> }**
>
> **
> **
> In this code, we keep a cache of all the problems reported via the monitor
> to allow the controlling logic to decide if the processing should continue
> or not.
> * *
>
> *Step 2: *Create a class MyMonitorFactoryImpl.java which implements
> the MonitorFactory
> interface.
>
>
>
> *public* *class* MyMonitorFactoryImpl* implements* MonitorFactory {
>
>
>
>    *private* Monitor monitor = *null*;
>
>
>
>    *public* Monitor createMonitor() {
>
>        *if* (monitor == *null*){
>
>            monitor = *new* MyMonitorImpl();
>
>        }
>
>        *return* monitor ;
>
>    }
>
> }
>
>
>
>
>
> *Step 3: *Create a plain text file named as "META-
> INF/services/org.apache.tuscany.sca.monitor.MonitorFactory"
>
>
> Register the extension by adding a line in this file as shown below….
> org.apache.tuscany.sca.monitor.impl.MyMonitorFactoryImpl
>
> --
> Thanks & Regards,
> Ramkumar Ramalingam
>

Hi Ram

Thanks for putting this together. A couple of comments..

- Something has gone wrong with the formatting that makes it a little
difficult to read. I see a lot of * characters in my mail reader.
- I've added another method to the Monitor interface to allow a list of
reported problems to be retrieved.
- For point 3 I did put some monitor analysis in the runtimes (SCADomain &
Node2) so you could reference that
- I was a little confused by the titles 1, 2, 3 and step1, step2, step3.
- Would be worth saying something about how to treat exceptions. This is the
area that I think is trickiest but we did have a disucssion on this and I
believe reached some conclusions, - If it's easier you could put these words
up in the wiki and then we can edit there and look to including in the
extension developers guide which feels like the natural home for this.

Regards

Simon

Reply via email to