Excellent progress Ruchira.

We need to have a discussion on tooling .. can you please grab me for 5-10
mins today? Lets come up with a plan to build a plan :).

On the JSS model below, what happens to any code that's in the file outside
of any function definitions?

Also, should we consider placing JS files that execute on the server like
this in a separate location rather than use a different extension? That's
the model with servlets - and its useful and necessary when the server side
code starts importing other stuff to use. We could simply use "WEB-INF" too
as that special directory ..

Sanjiva.

On Thu, Nov 3, 2011 at 2:29 PM, Ruchira Wageesha <[email protected]> wrote:

> Hi,
>
> I have added all existing hostobjects(except global System HO) of WSO2
> Mashup Server to the Appdev environment. Several hostobjects such as
> WSRequest, was modified to act independently of carbon environment. XHR
> hostobject was also added which allows you to call sync/async HTTP calls
> using httpcore-nio.
>
> For the *.jss stuff, JSON support was also implemented. In a *.jss, we can
> implement doGet, doPost etc. methods which corresponds to relevant HTTP
> methods. So, when an HTTP request comes to a *.jss file, then request will
> be dispatched to the relavant JavaScript method in the *.jss file. There,
> you have access to the *request*, *response* and *session* objects.
>
> If the request content type is json, then we can get content as a JSON by
> accessing "*request.content*" property. Further, you can get any
> parameters posted with the request by calling *request.getParameter()*method.
>
> When we returning from a *.jss, you can either return directly a JSON
> object which will be serialized and send to the client as a JSON content.
> If you want, you can set custom headers to the response object and put
> content using *response.write()* method. A sample *.jss content can be
> found at the bottom.
>
> Further, a new Rhino engine was created which allows to keep different top
> level scopes for different envirenments. i.e. now we can allow to plug, any
> product specific, tenant specific Hostobjects without affecting others.
> Later this will be integrated into javax.script API.
>
> In order to allow database calls, php-mysql api was proposed. But, it
> doesn't seem like it utilizes Object Orientation which can be effectively
> used in JavaScript in order to make it easier for the developer. php-mysql
> api has a functional programming model. Also, we need to allow users to do
> async database calls. i.e. register a function which will get executed once
> the database return the result set. So, it would be better to have an API
> as in XHR.
>
> I will send a separate mail with a proposed mysql api covering above
> requirements.
>
> Following is the current request, response, session object APIs which
> corresponds to relavant Java methods.
>
> *session object API*
>
> readonly property number created
> readonly property number lastAccessed
> readonly property isNew
> property maxInactive
>
>
> void put(string key, object value)
> object get(string key)
> void invalidate()
>
> *request object API*
>
> readonly property object content //this will return string content or json
> content depending on the content type
> readonly property string method
> readonly property string protocol
> readonly property string queryString
> readonly property string contentType
> readonly property number contentLength
>
> string getHeader(string name)
> string getParameter(string name)
>
> *response object API*
>
> property string content
> property string contentType
> property number status
>
> void addHeader(string name, string value)
> void getHeader(string name)
> void write(object content) // JSON objects will be serialized to strings
> void sendError(number code, string message)
> void sendRedirect(string url)
>
>
> *A Sample *.jss content*
>
> function *doGet*(request, response, session) {
>     response.write("<html>");
>     response.write("<h2>" + request.getHeader("User-Agent") + "</h2>");
>     response.write("<h2>" + request.getParameter("lang") + "</h2>");
>     response.write("</html>");
> }
>
> function *doPost*(request, response, session) {
>     var obj = {
>         name : "ruchira",
>         age : 27,
>         address : {
>             number : "16",
>             city : "ahangama"
>         }
>     };
>     //if the request was JSON, then content property will return that JSON
> object
>     //obj = request.content;
>     session.put("myObj", obj);
>     var o = session.get("myObj");
>     return o;
> }
>
>
> regards,
> Ruchira
> --
> Ruchira Wageesha
> Software Engineer - WSO2 Inc. www.wso2.com
>
> Email: [email protected] Blog: [email protected]
> Mobile: +94775493444
>
> Lean . Enterprise . Middleware
>
> _______________________________________________
> Architecture mailing list
> [email protected]
> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>
>


-- 
Sanjiva Weerawarana, Ph.D.
Founder, Chairman & CEO; WSO2, Inc.;  http://wso2.com/
email: [email protected]; phone: +94 11 763 9614; cell: +94 77 787 6880 | +1
650 265 8311
blog: http://sanjiva.weerawarana.org/

Lean . Enterprise . Middleware
_______________________________________________
Carbon-dev mailing list
[email protected]
http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev

Reply via email to