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: ruch...@wso2.com Blog: ruchirawagee...@blogspot.com Mobile: +94775493444 Lean . Enterprise . Middleware
_______________________________________________ Carbon-dev mailing list Carbon-dev@wso2.org http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev