Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-02-08 Thread Sajith Ariyarathna
Hi Manu,

Logging full object might break existing code that has logs of Java object
> in other products. If a developer accidentally logs a circular references
> it might even crash the server.
>
 Point taken, logging circular objects is a problem. My concern is that,
logging Java objects details in "JSON string format" is not a good way to
do it. May be we can log details of the Java object without following the
JSON format. Like this,

(class: org.wso2.models.Student, toString: "name: Kamal, age: 25, city:
Colombo")


Thanks.

On Tue, Feb 9, 2016 at 12:29 PM, Manuranga Perera  wrote:

> Hi Sajith,
> +1 not longing full object. Logging full object might break existing code
> that has logs of Java object in other products. If a developer accidentally
> logs a circular references it might even crash the server. Logs are for
> getting a bit of information for debug or operational purposes, it
> shouldn't be heavy or have any side effects.
>
> A log should be something you should be able to put without worrying too
> much.
>
> On Thu, Feb 4, 2016 at 6:41 PM, Sajith Ariyarathna 
> wrote:
>
>> So I am planning to log in-case of Java object as below without logging
>>> whole object.
>>> { "javaObject" : true, "hashCode" : "39d92a", "class" :
>>> "org.wso2.apim.StoreHostObject"}
>>>
>> -1
>>
>>- Think from the JavaScript perspective. When you log an object in
>>Jaggery/JavaScript it gives you the JSON representation of that object.
>>That is the expected behavior. So if you outputs a JSON string as the 
>> above
>>suggestion, it gives a wrong impression that there are 3 properties
>>"javaObject", "hasCode" & "class".
>>- Most of the time we log an object to see what is inside that
>>object. Above suggestion does not help in that situation. See the 
>> beginning
>>of this mail thread. The original problem you had was 'Jaggery gives "{}"
>>when logging a POJO instead of the JSON representation of that POJO'.
>>
>> My suggestion is to just output the JSON string of the POJO, If you
>> really want to add the Java class name then you can try something like this.
>>  (org.wso2.models.Student){"name": "Kamal", "age": "26", "city":
>> "Colombo"}
>>
>> Thanks.
>>
>> On Wed, Feb 3, 2016 at 1:00 PM, Rajeenthini Satkunam <
>> rajeenth...@wso2.com> wrote:
>>
>>> HI all,
>>>
>>> The issue was solved by adding  for
>>> jackson-databind,jackson-annotations,jackson-core for POM[1] .
>>>
>>> By the Way I would like to discuss more regarding this mail.
>>>
>>> *Issue I am trying to solve*
>>>
>>>  - I am getting empty JSON string ("{}") when logging Java object.
>>>  - Empty JSON string("{}") will give wrong information to user.
>>>
>>> *Proposed solution*
>>>
>>>   - give the user proper understandable log message.
>>>   - the logging need to be fast and summarized.
>>>
>>> So I am planning to log in-case of Java object as below without logging
>>> whole object.
>>> { "javaObject" : true, "hashCode" : "39d92a", "class" :
>>> "org.wso2.apim.StoreHostObject"}
>>>
>>> You can find these links[2][3] as resources to get an idea.
>>>
>>> [1] -
>>> https://github.com/wso2/jaggery/blob/master/features/org.jaggeryjs.server.feature/pom.xml
>>> [2] -
>>> https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.log/src/main/java/org/jaggeryjs/hostobjects/log/LogHostObject.java
>>> [3] -
>>> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java
>>>
>>>
>>> On Wed, Feb 3, 2016 at 10:27 AM, Rajeenthini Satkunam <
>>> rajeenth...@wso2.com> wrote:
>>>
 HI Niranjan,

 Ya sure.I will meet you today.

 On Wed, Feb 3, 2016 at 9:25 AM, Niranjan Karunanandham <
 niran...@wso2.com> wrote:

> Hi Rajeenthini,
>
>
> On Wed, Feb 3, 2016 at 9:19 AM, Rajeenthini Satkunam <
> rajeenth...@wso2.com> wrote:
>
>> HI All,
>>
>> Thank you chamara and sajith for your valuable suggestions.I have
>> done the improvement in Jaggery to log the java Object.
>>
>> improvement
>> -
>> 1)
>> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L78
>>
>> Added new code segment as per sajith's suggestion
>>
>> try{
>> return (new ObjectMapper().writeValueAsString(obj));
>> }catch (Exception e){
>> log.debug("Object " + obj.toString() + " of class " + obj.getClass() 
>> + " cannot be converted to JSON");
>> }
>>
>> return "{}";
>>
>>
>> 2) https://github.com/wso2/jaggery/blob/master/pom.xml
>>
>> Added maven dependencies for Jackson data-bind and annotations
>>
>> 
>> com.fasterxml.jackson.core
>> jackson-annotations
>> ${jackson.version}
>> 
>> 

Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-02-08 Thread Manuranga Perera
Hi Sajith,
+1 not longing full object. Logging full object might break existing code
that has logs of Java object in other products. If a developer accidentally
logs a circular references it might even crash the server. Logs are for
getting a bit of information for debug or operational purposes, it
shouldn't be heavy or have any side effects.

A log should be something you should be able to put without worrying too
much.

On Thu, Feb 4, 2016 at 6:41 PM, Sajith Ariyarathna 
wrote:

> So I am planning to log in-case of Java object as below without logging
>> whole object.
>> { "javaObject" : true, "hashCode" : "39d92a", "class" :
>> "org.wso2.apim.StoreHostObject"}
>>
> -1
>
>- Think from the JavaScript perspective. When you log an object in
>Jaggery/JavaScript it gives you the JSON representation of that object.
>That is the expected behavior. So if you outputs a JSON string as the above
>suggestion, it gives a wrong impression that there are 3 properties
>"javaObject", "hasCode" & "class".
>- Most of the time we log an object to see what is inside that object.
>Above suggestion does not help in that situation. See the beginning of this
>mail thread. The original problem you had was 'Jaggery gives "{}" when
>logging a POJO instead of the JSON representation of that POJO'.
>
> My suggestion is to just output the JSON string of the POJO, If you really
> want to add the Java class name then you can try something like this.
>  (org.wso2.models.Student){"name": "Kamal", "age": "26", "city": "Colombo"}
>
> Thanks.
>
> On Wed, Feb 3, 2016 at 1:00 PM, Rajeenthini Satkunam  > wrote:
>
>> HI all,
>>
>> The issue was solved by adding  for
>> jackson-databind,jackson-annotations,jackson-core for POM[1] .
>>
>> By the Way I would like to discuss more regarding this mail.
>>
>> *Issue I am trying to solve*
>>
>>  - I am getting empty JSON string ("{}") when logging Java object.
>>  - Empty JSON string("{}") will give wrong information to user.
>>
>> *Proposed solution*
>>
>>   - give the user proper understandable log message.
>>   - the logging need to be fast and summarized.
>>
>> So I am planning to log in-case of Java object as below without logging
>> whole object.
>> { "javaObject" : true, "hashCode" : "39d92a", "class" :
>> "org.wso2.apim.StoreHostObject"}
>>
>> You can find these links[2][3] as resources to get an idea.
>>
>> [1] -
>> https://github.com/wso2/jaggery/blob/master/features/org.jaggeryjs.server.feature/pom.xml
>> [2] -
>> https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.log/src/main/java/org/jaggeryjs/hostobjects/log/LogHostObject.java
>> [3] -
>> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java
>>
>>
>> On Wed, Feb 3, 2016 at 10:27 AM, Rajeenthini Satkunam <
>> rajeenth...@wso2.com> wrote:
>>
>>> HI Niranjan,
>>>
>>> Ya sure.I will meet you today.
>>>
>>> On Wed, Feb 3, 2016 at 9:25 AM, Niranjan Karunanandham <
>>> niran...@wso2.com> wrote:
>>>
 Hi Rajeenthini,


 On Wed, Feb 3, 2016 at 9:19 AM, Rajeenthini Satkunam <
 rajeenth...@wso2.com> wrote:

> HI All,
>
> Thank you chamara and sajith for your valuable suggestions.I have done
> the improvement in Jaggery to log the java Object.
>
> improvement
> -
> 1)
> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L78
>
> Added new code segment as per sajith's suggestion
>
> try{
> return (new ObjectMapper().writeValueAsString(obj));
> }catch (Exception e){
> log.debug("Object " + obj.toString() + " of class " + obj.getClass() 
> + " cannot be converted to JSON");
> }
>
> return "{}";
>
>
> 2) https://github.com/wso2/jaggery/blob/master/pom.xml
>
> Added maven dependencies for Jackson data-bind and annotations
>
> 
> com.fasterxml.jackson.core
> jackson-annotations
> ${jackson.version}
> 
> 
> com.fasterxml.jackson.core
> jackson-databind
> ${jackson.version}
> 
>
> 3) 
> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/pom.xml
>
> Added maven dependencies for Jackson data-bind and annotations
>
>
> I have tried to build(mvn clean install) Jaggery and product-Jaggery
> respectively.I can build Jaggery successfully But It has failed when
> building product Jaggery at Jaggery - Profile Generation.
>
> As per offline discussion with Niranjan I have added 
> and <*dependency*> for Jackson data-bind and annotation in POM.xml[
> 

Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-02-04 Thread Sajith Ariyarathna
>
> So I am planning to log in-case of Java object as below without logging
> whole object.
> { "javaObject" : true, "hashCode" : "39d92a", "class" :
> "org.wso2.apim.StoreHostObject"}
>
-1

   - Think from the JavaScript perspective. When you log an object in
   Jaggery/JavaScript it gives you the JSON representation of that object.
   That is the expected behavior. So if you outputs a JSON string as the above
   suggestion, it gives a wrong impression that there are 3 properties
   "javaObject", "hasCode" & "class".
   - Most of the time we log an object to see what is inside that object.
   Above suggestion does not help in that situation. See the beginning of this
   mail thread. The original problem you had was 'Jaggery gives "{}" when
   logging a POJO instead of the JSON representation of that POJO'.

My suggestion is to just output the JSON string of the POJO, If you really
want to add the Java class name then you can try something like this.
 (org.wso2.models.Student){"name": "Kamal", "age": "26", "city": "Colombo"}

Thanks.

On Wed, Feb 3, 2016 at 1:00 PM, Rajeenthini Satkunam 
wrote:

> HI all,
>
> The issue was solved by adding  for
> jackson-databind,jackson-annotations,jackson-core for POM[1] .
>
> By the Way I would like to discuss more regarding this mail.
>
> *Issue I am trying to solve*
>
>  - I am getting empty JSON string ("{}") when logging Java object.
>  - Empty JSON string("{}") will give wrong information to user.
>
> *Proposed solution*
>
>   - give the user proper understandable log message.
>   - the logging need to be fast and summarized.
>
> So I am planning to log in-case of Java object as below without logging
> whole object.
> { "javaObject" : true, "hashCode" : "39d92a", "class" :
> "org.wso2.apim.StoreHostObject"}
>
> You can find these links[2][3] as resources to get an idea.
>
> [1] -
> https://github.com/wso2/jaggery/blob/master/features/org.jaggeryjs.server.feature/pom.xml
> [2] -
> https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.log/src/main/java/org/jaggeryjs/hostobjects/log/LogHostObject.java
> [3] -
> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java
>
>
> On Wed, Feb 3, 2016 at 10:27 AM, Rajeenthini Satkunam <
> rajeenth...@wso2.com> wrote:
>
>> HI Niranjan,
>>
>> Ya sure.I will meet you today.
>>
>> On Wed, Feb 3, 2016 at 9:25 AM, Niranjan Karunanandham > > wrote:
>>
>>> Hi Rajeenthini,
>>>
>>>
>>> On Wed, Feb 3, 2016 at 9:19 AM, Rajeenthini Satkunam <
>>> rajeenth...@wso2.com> wrote:
>>>
 HI All,

 Thank you chamara and sajith for your valuable suggestions.I have done
 the improvement in Jaggery to log the java Object.

 improvement
 -
 1)
 https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L78

 Added new code segment as per sajith's suggestion

 try{
 return (new ObjectMapper().writeValueAsString(obj));
 }catch (Exception e){
 log.debug("Object " + obj.toString() + " of class " + obj.getClass() + 
 " cannot be converted to JSON");
 }

 return "{}";


 2) https://github.com/wso2/jaggery/blob/master/pom.xml

 Added maven dependencies for Jackson data-bind and annotations

 
 com.fasterxml.jackson.core
 jackson-annotations
 ${jackson.version}
 
 
 com.fasterxml.jackson.core
 jackson-databind
 ${jackson.version}
 

 3) 
 https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/pom.xml

 Added maven dependencies for Jackson data-bind and annotations


 I have tried to build(mvn clean install) Jaggery and product-Jaggery
 respectively.I can build Jaggery successfully But It has failed when
 building product Jaggery at Jaggery - Profile Generation.

 As per offline discussion with Niranjan I have added 
 and <*dependency*> for Jackson data-bind and annotation in POM.xml[
 https://github.com/wso2/jaggery/blob/master/features/org.jaggeryjs.server.feature/pom.xml]
 file as below.

 com.fasterxml.jackson.core:jackson-databind
 com.fasterxml.jackson.core:jackson-annotations


 
 com.fasterxml.jackson.core
 jackson-databind
 
 
 com.fasterxml.jackson.core
 jackson-annotations
 


 But Still I am getting product Jaggery build fail at the point Jaggery - 
 Profile Generation,following error can be observe in the command line.


 Installation failed.Cannot complete the install because one or more 
 required items could not be found.

  Software being installed: uuid Module - 

Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-02-02 Thread Rajeenthini Satkunam
HI Niranjan,

Ya sure.I will meet you today.

On Wed, Feb 3, 2016 at 9:25 AM, Niranjan Karunanandham 
wrote:

> Hi Rajeenthini,
>
>
> On Wed, Feb 3, 2016 at 9:19 AM, Rajeenthini Satkunam  > wrote:
>
>> HI All,
>>
>> Thank you chamara and sajith for your valuable suggestions.I have done
>> the improvement in Jaggery to log the java Object.
>>
>> improvement
>> -
>> 1)
>> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L78
>>
>> Added new code segment as per sajith's suggestion
>>
>> try{
>> return (new ObjectMapper().writeValueAsString(obj));
>> }catch (Exception e){
>> log.debug("Object " + obj.toString() + " of class " + obj.getClass() + " 
>> cannot be converted to JSON");
>> }
>>
>> return "{}";
>>
>>
>> 2) https://github.com/wso2/jaggery/blob/master/pom.xml
>>
>> Added maven dependencies for Jackson data-bind and annotations
>>
>> 
>> com.fasterxml.jackson.core
>> jackson-annotations
>> ${jackson.version}
>> 
>> 
>> com.fasterxml.jackson.core
>> jackson-databind
>> ${jackson.version}
>> 
>>
>> 3) 
>> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/pom.xml
>>
>> Added maven dependencies for Jackson data-bind and annotations
>>
>>
>> I have tried to build(mvn clean install) Jaggery and product-Jaggery
>> respectively.I can build Jaggery successfully But It has failed when
>> building product Jaggery at Jaggery - Profile Generation.
>>
>> As per offline discussion with Niranjan I have added 
>> and <*dependency*> for Jackson data-bind and annotation in POM.xml[
>> https://github.com/wso2/jaggery/blob/master/features/org.jaggeryjs.server.feature/pom.xml]
>> file as below.
>>
>> com.fasterxml.jackson.core:jackson-databind
>> com.fasterxml.jackson.core:jackson-annotations
>>
>>
>> 
>> com.fasterxml.jackson.core
>> jackson-databind
>> 
>> 
>> com.fasterxml.jackson.core
>> jackson-annotations
>> 
>>
>>
>> But Still I am getting product Jaggery build fail at the point Jaggery - 
>> Profile Generation,following error can be observe in the command line.
>>
>>
>> Installation failed.Cannot complete the install because one or more required 
>> items could not be found.
>>
>>  Software being installed: uuid Module - Feature 1.4.3 
>> (org.jaggeryjs.modules.uuid.feature.group 1.4.3)
>>  Missing requirement: jackson-databind 2.0.0 (jackson-databind 2.0.0) 
>> requires 'package com.fasterxml.jackson.core [2.0.0,3.0.0)' but it could not 
>> be found
>>  Cannot satisfy dependency:
>>   From: org.jaggeryjs.modules.uuid 1.4.3 (org.jaggeryjs.modules.uuid 1.4.3)
>>   To: package org.jaggeryjs.scriptengine.exceptions [0.11.0,1.0.0)
>>  Cannot satisfy dependency:
>>
>>   From: uuid Module - Feature 1.4.3 
>> (org.jaggeryjs.modules.uuid.feature.group 1.4.3)
>>   To: org.jaggeryjs.modules.uuid [1.4.3]
>>  Cannot satisfy dependency:
>>   From: org.jaggeryjs.scriptengine 0.12.1.SNAPSHOT 
>> (org.jaggeryjs.scriptengine 0.12.1.SNAPSHOT)
>>   To: package com.fasterxml.jackson.databind [2.0.0,3.0.0)
>> Application failed, log file location: 
>> /home/rajee/.m2/repository/org/eclipse/tycho/tycho-p2-runtime/0.13.0/eclipse/configuration/1454469448601.log
>>
>>
>> Can anyone help me to figure out the cause of build fail.Hope I have 
>> included all the steps I have followed.Your help would be appreciated.
>>
>> As per the error, the build is failing because jackson-databind requires
> com.fasterxml.jackson.core within the range 2.0.0 and 3.0.0. If this is
> required by the feature then you need to bundle it in the feature. Shall we
> have a look at this today?
>
>>
>>
>>
>> On Tue, Feb 2, 2016 at 10:23 AM, Rajeenthini Satkunam <
>> rajeenth...@wso2.com> wrote:
>>
>>> Hi sajith,
>>>
>>> Noted and thank you for the suggestions.
>>>
>>> On Mon, Feb 1, 2016 at 11:53 PM, Sajith Ariyarathna 
>>> wrote:
>>>
 Hi Rajeenthini,

 You are hoping to add the following code snippet to the serializeJSON
 method [1] of the org.jaggeryjs.scriptengine.util.HostObjectUtil class.

> String JsonString = null;
> try{
> ObjectMapper mapper = new ObjectMapper();
> JsonString = mapper.writeValueAsString(obj);
> }catch (Exception e){
> System.out.println(e.getMessage());
> }
>
> return "{\"javaObject\":\"true\",\"object\":\"" + JsonString + "\"}";
>
> There are few issue in this code snippet.

- Don't catch generic Exception, always catch a specific exception.
In here you should catch JsonProcessingException [2].
- Don't use System.out.println to log exceptions. Instead use a
proper logger. HostObjectUtil class has a log object defined in
line 30 [3], you can use that.
- Returning '{"javaObject": "true", "object": "{ ... }"}' 

Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-02-02 Thread Rajeenthini Satkunam
HI all,

The issue was solved by adding  for
jackson-databind,jackson-annotations,jackson-core for POM[1] .

By the Way I would like to discuss more regarding this mail.

*Issue I am trying to solve*

 - I am getting empty JSON string ("{}") when logging Java object.
 - Empty JSON string("{}") will give wrong information to user.

*Proposed solution*

  - give the user proper understandable log message.
  - the logging need to be fast and summarized.

So I am planning to log in-case of Java object as below without logging
whole object.
{ "javaObject" : true, "hashCode" : "39d92a", "class" :
"org.wso2.apim.StoreHostObject"}

You can find these links[2][3] as resources to get an idea.

[1] -
https://github.com/wso2/jaggery/blob/master/features/org.jaggeryjs.server.feature/pom.xml
[2] -
https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.log/src/main/java/org/jaggeryjs/hostobjects/log/LogHostObject.java
[3] -
https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java


On Wed, Feb 3, 2016 at 10:27 AM, Rajeenthini Satkunam 
wrote:

> HI Niranjan,
>
> Ya sure.I will meet you today.
>
> On Wed, Feb 3, 2016 at 9:25 AM, Niranjan Karunanandham 
> wrote:
>
>> Hi Rajeenthini,
>>
>>
>> On Wed, Feb 3, 2016 at 9:19 AM, Rajeenthini Satkunam <
>> rajeenth...@wso2.com> wrote:
>>
>>> HI All,
>>>
>>> Thank you chamara and sajith for your valuable suggestions.I have done
>>> the improvement in Jaggery to log the java Object.
>>>
>>> improvement
>>> -
>>> 1)
>>> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L78
>>>
>>> Added new code segment as per sajith's suggestion
>>>
>>> try{
>>> return (new ObjectMapper().writeValueAsString(obj));
>>> }catch (Exception e){
>>> log.debug("Object " + obj.toString() + " of class " + obj.getClass() + 
>>> " cannot be converted to JSON");
>>> }
>>>
>>> return "{}";
>>>
>>>
>>> 2) https://github.com/wso2/jaggery/blob/master/pom.xml
>>>
>>> Added maven dependencies for Jackson data-bind and annotations
>>>
>>> 
>>> com.fasterxml.jackson.core
>>> jackson-annotations
>>> ${jackson.version}
>>> 
>>> 
>>> com.fasterxml.jackson.core
>>> jackson-databind
>>> ${jackson.version}
>>> 
>>>
>>> 3) 
>>> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/pom.xml
>>>
>>> Added maven dependencies for Jackson data-bind and annotations
>>>
>>>
>>> I have tried to build(mvn clean install) Jaggery and product-Jaggery
>>> respectively.I can build Jaggery successfully But It has failed when
>>> building product Jaggery at Jaggery - Profile Generation.
>>>
>>> As per offline discussion with Niranjan I have added 
>>> and <*dependency*> for Jackson data-bind and annotation in POM.xml[
>>> https://github.com/wso2/jaggery/blob/master/features/org.jaggeryjs.server.feature/pom.xml]
>>> file as below.
>>>
>>> com.fasterxml.jackson.core:jackson-databind
>>> com.fasterxml.jackson.core:jackson-annotations
>>>
>>>
>>> 
>>> com.fasterxml.jackson.core
>>> jackson-databind
>>> 
>>> 
>>> com.fasterxml.jackson.core
>>> jackson-annotations
>>> 
>>>
>>>
>>> But Still I am getting product Jaggery build fail at the point Jaggery - 
>>> Profile Generation,following error can be observe in the command line.
>>>
>>>
>>> Installation failed.Cannot complete the install because one or more 
>>> required items could not be found.
>>>
>>>  Software being installed: uuid Module - Feature 1.4.3 
>>> (org.jaggeryjs.modules.uuid.feature.group 1.4.3)
>>>  Missing requirement: jackson-databind 2.0.0 (jackson-databind 2.0.0) 
>>> requires 'package com.fasterxml.jackson.core [2.0.0,3.0.0)' but it could 
>>> not be found
>>>  Cannot satisfy dependency:
>>>   From: org.jaggeryjs.modules.uuid 1.4.3 (org.jaggeryjs.modules.uuid 1.4.3)
>>>   To: package org.jaggeryjs.scriptengine.exceptions [0.11.0,1.0.0)
>>>  Cannot satisfy dependency:
>>>
>>>   From: uuid Module - Feature 1.4.3 
>>> (org.jaggeryjs.modules.uuid.feature.group 1.4.3)
>>>   To: org.jaggeryjs.modules.uuid [1.4.3]
>>>  Cannot satisfy dependency:
>>>   From: org.jaggeryjs.scriptengine 0.12.1.SNAPSHOT 
>>> (org.jaggeryjs.scriptengine 0.12.1.SNAPSHOT)
>>>   To: package com.fasterxml.jackson.databind [2.0.0,3.0.0)
>>> Application failed, log file location: 
>>> /home/rajee/.m2/repository/org/eclipse/tycho/tycho-p2-runtime/0.13.0/eclipse/configuration/1454469448601.log
>>>
>>>
>>> Can anyone help me to figure out the cause of build fail.Hope I have 
>>> included all the steps I have followed.Your help would be appreciated.
>>>
>>> As per the error, the build is failing because jackson-databind requires
>> com.fasterxml.jackson.core within the range 2.0.0 and 3.0.0. If this is
>> required by the 

Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-02-02 Thread Rajeenthini Satkunam
HI All,

Thank you chamara and sajith for your valuable suggestions.I have done the
improvement in Jaggery to log the java Object.

improvement
-
1)
https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L78

Added new code segment as per sajith's suggestion

try{
return (new ObjectMapper().writeValueAsString(obj));
}catch (Exception e){
log.debug("Object " + obj.toString() + " of class " +
obj.getClass() + " cannot be converted to JSON");
}

return "{}";


2) https://github.com/wso2/jaggery/blob/master/pom.xml

Added maven dependencies for Jackson data-bind and annotations


com.fasterxml.jackson.core
jackson-annotations
${jackson.version}


com.fasterxml.jackson.core
jackson-databind
${jackson.version}


3) 
https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/pom.xml

Added maven dependencies for Jackson data-bind and annotations


I have tried to build(mvn clean install) Jaggery and product-Jaggery
respectively.I can build Jaggery successfully But It has failed when
building product Jaggery at Jaggery - Profile Generation.

As per offline discussion with Niranjan I have added  and <
*dependency*> for Jackson data-bind and annotation in POM.xml[
https://github.com/wso2/jaggery/blob/master/features/org.jaggeryjs.server.feature/pom.xml]
file as below.

com.fasterxml.jackson.core:jackson-databind
com.fasterxml.jackson.core:jackson-annotations



com.fasterxml.jackson.core
jackson-databind


com.fasterxml.jackson.core
jackson-annotations



But Still I am getting product Jaggery build fail at the point Jaggery
- Profile Generation,following error can be observe in the command
line.


Installation failed.Cannot complete the install because one or more
required items could not be found.

 Software being installed: uuid Module - Feature 1.4.3
(org.jaggeryjs.modules.uuid.feature.group 1.4.3)
 Missing requirement: jackson-databind 2.0.0 (jackson-databind 2.0.0)
requires 'package com.fasterxml.jackson.core [2.0.0,3.0.0)' but it
could not be found
 Cannot satisfy dependency:
  From: org.jaggeryjs.modules.uuid 1.4.3 (org.jaggeryjs.modules.uuid 1.4.3)
  To: package org.jaggeryjs.scriptengine.exceptions [0.11.0,1.0.0)
 Cannot satisfy dependency:

  From: uuid Module - Feature 1.4.3
(org.jaggeryjs.modules.uuid.feature.group 1.4.3)
  To: org.jaggeryjs.modules.uuid [1.4.3]
 Cannot satisfy dependency:
  From: org.jaggeryjs.scriptengine 0.12.1.SNAPSHOT
(org.jaggeryjs.scriptengine 0.12.1.SNAPSHOT)
  To: package com.fasterxml.jackson.databind [2.0.0,3.0.0)
Application failed, log file location:
/home/rajee/.m2/repository/org/eclipse/tycho/tycho-p2-runtime/0.13.0/eclipse/configuration/1454469448601.log


Can anyone help me to figure out the cause of build fail.Hope I have
included all the steps I have followed.Your help would be appreciated.




On Tue, Feb 2, 2016 at 10:23 AM, Rajeenthini Satkunam 
wrote:

> Hi sajith,
>
> Noted and thank you for the suggestions.
>
> On Mon, Feb 1, 2016 at 11:53 PM, Sajith Ariyarathna 
> wrote:
>
>> Hi Rajeenthini,
>>
>> You are hoping to add the following code snippet to the serializeJSON
>> method [1] of the org.jaggeryjs.scriptengine.util.HostObjectUtil class.
>>
>>> String JsonString = null;
>>> try{
>>> ObjectMapper mapper = new ObjectMapper();
>>> JsonString = mapper.writeValueAsString(obj);
>>> }catch (Exception e){
>>> System.out.println(e.getMessage());
>>> }
>>>
>>> return "{\"javaObject\":\"true\",\"object\":\"" + JsonString + "\"}";
>>>
>>> There are few issue in this code snippet.
>>
>>- Don't catch generic Exception, always catch a specific exception.
>>In here you should catch JsonProcessingException [2].
>>- Don't use System.out.println to log exceptions. Instead use a
>>proper logger. HostObjectUtil class has a log object defined in line
>>30 [3], you can use that.
>>- Returning '{"javaObject": "true", "object": "{ ... }"}' string
>>gives a wrong impression that there are two attributes called 'javaObject'
>>& 'object' in the logged object. I think just returning the JSON string
>>will be enough.
>>
>> After corrections (I also took the liberty to reduce no of lines):
>>
>> try {
>>
>> return (new ObjectMapper()).writeValueAsString(obj);
>>
>> } catch (JsonProcessingException e) {
>>
>> log.debug("Object " + obj.toString() + " of class " + obj.getClassName()
>> + " cannot be converted to JSON");
>>
>> }
>>
>> return "{}";
>>
>>
>> [1]
>> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L78
>> [2]
>> 

Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-02-02 Thread Niranjan Karunanandham
Hi Rajeenthini,


On Wed, Feb 3, 2016 at 9:19 AM, Rajeenthini Satkunam 
wrote:

> HI All,
>
> Thank you chamara and sajith for your valuable suggestions.I have done the
> improvement in Jaggery to log the java Object.
>
> improvement
> -
> 1)
> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L78
>
> Added new code segment as per sajith's suggestion
>
> try{
> return (new ObjectMapper().writeValueAsString(obj));
> }catch (Exception e){
> log.debug("Object " + obj.toString() + " of class " + obj.getClass() + " 
> cannot be converted to JSON");
> }
>
> return "{}";
>
>
> 2) https://github.com/wso2/jaggery/blob/master/pom.xml
>
> Added maven dependencies for Jackson data-bind and annotations
>
> 
> com.fasterxml.jackson.core
> jackson-annotations
> ${jackson.version}
> 
> 
> com.fasterxml.jackson.core
> jackson-databind
> ${jackson.version}
> 
>
> 3) 
> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/pom.xml
>
> Added maven dependencies for Jackson data-bind and annotations
>
>
> I have tried to build(mvn clean install) Jaggery and product-Jaggery
> respectively.I can build Jaggery successfully But It has failed when
> building product Jaggery at Jaggery - Profile Generation.
>
> As per offline discussion with Niranjan I have added 
> and <*dependency*> for Jackson data-bind and annotation in POM.xml[
> https://github.com/wso2/jaggery/blob/master/features/org.jaggeryjs.server.feature/pom.xml]
> file as below.
>
> com.fasterxml.jackson.core:jackson-databind
> com.fasterxml.jackson.core:jackson-annotations
>
>
> 
> com.fasterxml.jackson.core
> jackson-databind
> 
> 
> com.fasterxml.jackson.core
> jackson-annotations
> 
>
>
> But Still I am getting product Jaggery build fail at the point Jaggery - 
> Profile Generation,following error can be observe in the command line.
>
>
> Installation failed.Cannot complete the install because one or more required 
> items could not be found.
>
>  Software being installed: uuid Module - Feature 1.4.3 
> (org.jaggeryjs.modules.uuid.feature.group 1.4.3)
>  Missing requirement: jackson-databind 2.0.0 (jackson-databind 2.0.0) 
> requires 'package com.fasterxml.jackson.core [2.0.0,3.0.0)' but it could not 
> be found
>  Cannot satisfy dependency:
>   From: org.jaggeryjs.modules.uuid 1.4.3 (org.jaggeryjs.modules.uuid 1.4.3)
>   To: package org.jaggeryjs.scriptengine.exceptions [0.11.0,1.0.0)
>  Cannot satisfy dependency:
>
>   From: uuid Module - Feature 1.4.3 (org.jaggeryjs.modules.uuid.feature.group 
> 1.4.3)
>   To: org.jaggeryjs.modules.uuid [1.4.3]
>  Cannot satisfy dependency:
>   From: org.jaggeryjs.scriptengine 0.12.1.SNAPSHOT 
> (org.jaggeryjs.scriptengine 0.12.1.SNAPSHOT)
>   To: package com.fasterxml.jackson.databind [2.0.0,3.0.0)
> Application failed, log file location: 
> /home/rajee/.m2/repository/org/eclipse/tycho/tycho-p2-runtime/0.13.0/eclipse/configuration/1454469448601.log
>
>
> Can anyone help me to figure out the cause of build fail.Hope I have included 
> all the steps I have followed.Your help would be appreciated.
>
> As per the error, the build is failing because jackson-databind requires
com.fasterxml.jackson.core within the range 2.0.0 and 3.0.0. If this is
required by the feature then you need to bundle it in the feature. Shall we
have a look at this today?

>
>
>
> On Tue, Feb 2, 2016 at 10:23 AM, Rajeenthini Satkunam <
> rajeenth...@wso2.com> wrote:
>
>> Hi sajith,
>>
>> Noted and thank you for the suggestions.
>>
>> On Mon, Feb 1, 2016 at 11:53 PM, Sajith Ariyarathna 
>> wrote:
>>
>>> Hi Rajeenthini,
>>>
>>> You are hoping to add the following code snippet to the serializeJSON
>>> method [1] of the org.jaggeryjs.scriptengine.util.HostObjectUtil class.
>>>
 String JsonString = null;
 try{
 ObjectMapper mapper = new ObjectMapper();
 JsonString = mapper.writeValueAsString(obj);
 }catch (Exception e){
 System.out.println(e.getMessage());
 }

 return "{\"javaObject\":\"true\",\"object\":\"" + JsonString + "\"}";

 There are few issue in this code snippet.
>>>
>>>- Don't catch generic Exception, always catch a specific exception.
>>>In here you should catch JsonProcessingException [2].
>>>- Don't use System.out.println to log exceptions. Instead use a
>>>proper logger. HostObjectUtil class has a log object defined in line
>>>30 [3], you can use that.
>>>- Returning '{"javaObject": "true", "object": "{ ... }"}' string
>>>gives a wrong impression that there are two attributes called 
>>> 'javaObject'
>>>& 'object' in the logged object. I think just returning the JSON string
>>>will be enough.
>>>
>>> After corrections (I also took the liberty to reduce no of lines):
>>>
>>> 

Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-02-01 Thread Rajeenthini Satkunam
Hi sajith,

Noted and thank you for the suggestions.

On Mon, Feb 1, 2016 at 11:53 PM, Sajith Ariyarathna 
wrote:

> Hi Rajeenthini,
>
> You are hoping to add the following code snippet to the serializeJSON
> method [1] of the org.jaggeryjs.scriptengine.util.HostObjectUtil class.
>
>> String JsonString = null;
>> try{
>> ObjectMapper mapper = new ObjectMapper();
>> JsonString = mapper.writeValueAsString(obj);
>> }catch (Exception e){
>> System.out.println(e.getMessage());
>> }
>>
>> return "{\"javaObject\":\"true\",\"object\":\"" + JsonString + "\"}";
>>
>> There are few issue in this code snippet.
>
>- Don't catch generic Exception, always catch a specific exception. In
>here you should catch JsonProcessingException [2].
>- Don't use System.out.println to log exceptions. Instead use a proper
>logger. HostObjectUtil class has a log object defined in line 30 [3],
>you can use that.
>- Returning '{"javaObject": "true", "object": "{ ... }"}' string gives
>a wrong impression that there are two attributes called 'javaObject' &
>'object' in the logged object. I think just returning the JSON string will
>be enough.
>
> After corrections (I also took the liberty to reduce no of lines):
>
> try {
>
> return (new ObjectMapper()).writeValueAsString(obj);
>
> } catch (JsonProcessingException e) {
>
> log.debug("Object " + obj.toString() + " of class " + obj.getClassName() +
> " cannot be converted to JSON");
>
> }
>
> return "{}";
>
>
> [1]
> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L78
> [2]
> https://static.javadoc.io/com.fasterxml.jackson.core/jackson-databind/2.6.3/com/fasterxml/jackson/databind/ObjectMapper.html#writeValueAsString(java.lang.Object)
> [3]
> https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L30
>
> Thanks.
>
>
> On Mon, Feb 1, 2016 at 8:13 PM, Rajeenthini Satkunam  > wrote:
>
>> Hi sajith,
>>
>> i have added this Student class for example.As for current implementation
>> goes like this way in Jaggery below.
>>
>> public static String serializeJSON(Object obj) {
>> if (obj instanceof Wrapper) {
>> obj = ((Wrapper) obj).unwrap();
>> }
>> if (obj == null) {
>> return "null";
>> }
>> if (obj instanceof Undefined) {
>> return "null";
>> }
>> if (obj instanceof Boolean) {
>> return Boolean.toString((Boolean) obj);
>> }
>> if (obj instanceof String) {
>> return serializeString((String) obj);
>> }
>> if (obj instanceof ConsString) {
>> return serializeString(obj.toString());
>> }
>> if (obj instanceof Number) {
>> return obj.toString();
>> }
>> if (obj instanceof XMLObject) {
>> return serializeString(serializeXML((ScriptableObject) obj));
>> }
>> if (obj instanceof NativeObject) {
>> return serializeNativeObject((NativeObject) obj);
>> }
>> if (obj instanceof NativeArray) {
>> return serializeNativeArray((NativeArray) obj);
>> }
>> if (obj instanceof Object[]) {
>> return serializeObjectArray((Object[]) obj);
>> }
>> if (obj instanceof Scriptable) {
>> Scriptable object = (Scriptable) obj;
>> String jsClass = object.getClassName();
>> if ("Date".equals(jsClass)) {
>> return serializeString(serializeNativeDate(object));
>> } else if ("Error".equals(jsClass)) {
>> return serializeString(serializeNativeError(object));
>> }
>> }
>> String JsonString = null;
>> try{
>> ObjectMapper mapper = new ObjectMapper();
>> JsonString = mapper.writeValueAsString(obj);
>> }catch (Exception e){
>> System.out.println(e.getMessage());
>> }
>>
>> return "{\"javaObject\":\"true\",\"object\":\"" + JsonString + "\"}";
>> }
>>
>> AFAIU since we are parsing Object type of argument It is better we can
>> use ObjectMapper.Correct me If I am wrong.Your suggestion would be more
>> appreciated.
>>
>> On Sun, Jan 31, 2016 at 10:23 AM, Sajith Ariyarathna 
>> wrote:
>>
>>> Hi Rajeenthini,
>>>
>>> AFAIK ability to convert a POJO into JSON object does nor affect the
>>> output of a Jaggery Log of that POJO.
>>> To get a proper log output for a Java object, you need to implement the
>>> "toString" method in that Java class. For example in your case,
>>>
>>> public class Student {
>>>
>>> ...
>>>
>>> public String toString() {
>>>
>>> return "{name: " + this.name + ", age: " + this.age + ", indexNo: " +
>>> this.indexNo + "}";
>>>
>>> }
>>>
>>> }
>>>
>>> Now you can log a Student object in your Jaggery code as following.
>>>
>>> log.info(studentObj.toString());
>>>
>>>
>>> Thanks.
>>>
>>>

Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-02-01 Thread Rajeenthini Satkunam
Hi sajith,

i have added this Student class for example.As for current implementation
goes like this way in Jaggery below.

public static String serializeJSON(Object obj) {
if (obj instanceof Wrapper) {
obj = ((Wrapper) obj).unwrap();
}
if (obj == null) {
return "null";
}
if (obj instanceof Undefined) {
return "null";
}
if (obj instanceof Boolean) {
return Boolean.toString((Boolean) obj);
}
if (obj instanceof String) {
return serializeString((String) obj);
}
if (obj instanceof ConsString) {
return serializeString(obj.toString());
}
if (obj instanceof Number) {
return obj.toString();
}
if (obj instanceof XMLObject) {
return serializeString(serializeXML((ScriptableObject) obj));
}
if (obj instanceof NativeObject) {
return serializeNativeObject((NativeObject) obj);
}
if (obj instanceof NativeArray) {
return serializeNativeArray((NativeArray) obj);
}
if (obj instanceof Object[]) {
return serializeObjectArray((Object[]) obj);
}
if (obj instanceof Scriptable) {
Scriptable object = (Scriptable) obj;
String jsClass = object.getClassName();
if ("Date".equals(jsClass)) {
return serializeString(serializeNativeDate(object));
} else if ("Error".equals(jsClass)) {
return serializeString(serializeNativeError(object));
}
}
String JsonString = null;
try{
ObjectMapper mapper = new ObjectMapper();
JsonString = mapper.writeValueAsString(obj);
}catch (Exception e){
System.out.println(e.getMessage());
}

return "{\"javaObject\":\"true\",\"object\":\"" + JsonString + "\"}";
}

AFAIU since we are parsing Object type of argument It is better we can use
ObjectMapper.Correct me If I am wrong.Your suggestion would be more
appreciated.

On Sun, Jan 31, 2016 at 10:23 AM, Sajith Ariyarathna 
wrote:

> Hi Rajeenthini,
>
> AFAIK ability to convert a POJO into JSON object does nor affect the
> output of a Jaggery Log of that POJO.
> To get a proper log output for a Java object, you need to implement the
> "toString" method in that Java class. For example in your case,
>
> public class Student {
>
> ...
>
> public String toString() {
>
> return "{name: " + this.name + ", age: " + this.age + ", indexNo: " +
> this.indexNo + "}";
>
> }
>
> }
>
> Now you can log a Student object in your Jaggery code as following.
>
> log.info(studentObj.toString());
>
>
> Thanks.
>
>
>
> On Sat, Jan 30, 2016 at 9:28 PM, Rajeenthini Satkunam <
> rajeenth...@wso2.com> wrote:
>
>> Hi,
>>
>> I have worked on writing Jaggery test for Jaggery-Product.I can observe
>> when we tried to log the object it always gives us empty JSON
>> ({}).Currently the implementation goes this way when we try to log java
>> object.
>>
>> So I was trying to get rid of this observed behavior of Jaggery.I have
>> gone through a solution.
>>
>> *using Jackson[1] *
>>
>> We can convert java object to JSON[2] and can log it.
>>
>> I have shared the piece of code I have tried out with Jackson below.
>>
>> *Simple POJO Student class*
>>
>> public class Student {
>> private int age;
>> private String name;
>> private String indexNo;
>>
>> public int getAge() {
>> return age;
>> }
>>
>> public void setAge(int age) {
>> this.age = age;
>> }
>>
>> public String getName() {
>> return name;
>> }
>>
>> public void setName(String name) {
>> this.name = name;
>> }
>>
>> public String getIndexNo() {
>> return indexNo;
>> }
>>
>> public void setIndexNo(String indexNo) {
>> this.indexNo = indexNo;
>> }
>> }
>>
>> *Simple class to test Jackson*
>>
>> import com.fasterxml.jackson.databind.ObjectMapper;
>> import util.Student;
>> public class MyTest {
>> public static void main(String args[]){
>> Student st = new Student();
>> st.setIndexNo("DS001");
>> st.setAge(12);
>> st.setName("kareena");
>> try{
>> ObjectMapper mapper = new ObjectMapper();
>> String jsonInString = mapper.writeValueAsString(st);
>> 
>> System.out.println("");
>> System.out.println(jsonInString);
>> 
>> System.out.println("");
>>
>> }catch(Exception e){
>> System.out.print("Exception caught  "+ e);
>> }
>>
>> }
>> }
>>
>> Actual output by above code.
>> 
>> {"age":12,"name":"kareena","indexNo":"DS001"}
>> 
>>
>> I have added a dependency in the POM.xml
>>
>> 
>> com.fasterxml.jackson.core
>> jackson-databind
>> 2.6.3
>> 
>>
>>
>> IMHO we can use the same scenario in case of log JAVA 

Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-02-01 Thread Sajith Ariyarathna
Hi Rajeenthini,

You are hoping to add the following code snippet to the serializeJSON
method [1] of the org.jaggeryjs.scriptengine.util.HostObjectUtil class.

> String JsonString = null;
> try{
> ObjectMapper mapper = new ObjectMapper();
> JsonString = mapper.writeValueAsString(obj);
> }catch (Exception e){
> System.out.println(e.getMessage());
> }
>
> return "{\"javaObject\":\"true\",\"object\":\"" + JsonString + "\"}";
>
> There are few issue in this code snippet.

   - Don't catch generic Exception, always catch a specific exception. In
   here you should catch JsonProcessingException [2].
   - Don't use System.out.println to log exceptions. Instead use a proper
   logger. HostObjectUtil class has a log object defined in line 30 [3],
   you can use that.
   - Returning '{"javaObject": "true", "object": "{ ... }"}' string gives a
   wrong impression that there are two attributes called 'javaObject' &
   'object' in the logged object. I think just returning the JSON string will
   be enough.

After corrections (I also took the liberty to reduce no of lines):

try {

return (new ObjectMapper()).writeValueAsString(obj);

} catch (JsonProcessingException e) {

log.debug("Object " + obj.toString() + " of class " + obj.getClassName() +
" cannot be converted to JSON");

}

return "{}";


[1]
https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L78
[2]
https://static.javadoc.io/com.fasterxml.jackson.core/jackson-databind/2.6.3/com/fasterxml/jackson/databind/ObjectMapper.html#writeValueAsString(java.lang.Object)
[3]
https://github.com/wso2/jaggery/blob/master/components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/util/HostObjectUtil.java#L30

Thanks.


On Mon, Feb 1, 2016 at 8:13 PM, Rajeenthini Satkunam 
wrote:

> Hi sajith,
>
> i have added this Student class for example.As for current implementation
> goes like this way in Jaggery below.
>
> public static String serializeJSON(Object obj) {
> if (obj instanceof Wrapper) {
> obj = ((Wrapper) obj).unwrap();
> }
> if (obj == null) {
> return "null";
> }
> if (obj instanceof Undefined) {
> return "null";
> }
> if (obj instanceof Boolean) {
> return Boolean.toString((Boolean) obj);
> }
> if (obj instanceof String) {
> return serializeString((String) obj);
> }
> if (obj instanceof ConsString) {
> return serializeString(obj.toString());
> }
> if (obj instanceof Number) {
> return obj.toString();
> }
> if (obj instanceof XMLObject) {
> return serializeString(serializeXML((ScriptableObject) obj));
> }
> if (obj instanceof NativeObject) {
> return serializeNativeObject((NativeObject) obj);
> }
> if (obj instanceof NativeArray) {
> return serializeNativeArray((NativeArray) obj);
> }
> if (obj instanceof Object[]) {
> return serializeObjectArray((Object[]) obj);
> }
> if (obj instanceof Scriptable) {
> Scriptable object = (Scriptable) obj;
> String jsClass = object.getClassName();
> if ("Date".equals(jsClass)) {
> return serializeString(serializeNativeDate(object));
> } else if ("Error".equals(jsClass)) {
> return serializeString(serializeNativeError(object));
> }
> }
> String JsonString = null;
> try{
> ObjectMapper mapper = new ObjectMapper();
> JsonString = mapper.writeValueAsString(obj);
> }catch (Exception e){
> System.out.println(e.getMessage());
> }
>
> return "{\"javaObject\":\"true\",\"object\":\"" + JsonString + "\"}";
> }
>
> AFAIU since we are parsing Object type of argument It is better we can use
> ObjectMapper.Correct me If I am wrong.Your suggestion would be more
> appreciated.
>
> On Sun, Jan 31, 2016 at 10:23 AM, Sajith Ariyarathna 
> wrote:
>
>> Hi Rajeenthini,
>>
>> AFAIK ability to convert a POJO into JSON object does nor affect the
>> output of a Jaggery Log of that POJO.
>> To get a proper log output for a Java object, you need to implement the
>> "toString" method in that Java class. For example in your case,
>>
>> public class Student {
>>
>> ...
>>
>> public String toString() {
>>
>> return "{name: " + this.name + ", age: " + this.age + ", indexNo: " +
>> this.indexNo + "}";
>>
>> }
>>
>> }
>>
>> Now you can log a Student object in your Jaggery code as following.
>>
>> log.info(studentObj.toString());
>>
>>
>> Thanks.
>>
>>
>>
>> On Sat, Jan 30, 2016 at 9:28 PM, Rajeenthini Satkunam <
>> rajeenth...@wso2.com> wrote:
>>
>>> Hi,
>>>
>>> I have worked on writing Jaggery test for Jaggery-Product.I can observe
>>> when we tried to log the object it always gives us empty JSON
>>> ({}).Currently the implementation goes this way when we 

Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-01-31 Thread Chamara Philips
There is com.google.gson.Gson as well, which I have used in OIDCDiscovery
project [1], (which is not yet merged) to convert a Java object to JSON.
But jackson seems more suitable, as it supports data-binding functionality.

[1] https://github.com/wso2/carbon-identity/pull/1694/



On Sat, Jan 30, 2016 at 9:28 PM, Rajeenthini Satkunam 
wrote:

> Hi,
>
> I have worked on writing Jaggery test for Jaggery-Product.I can observe
> when we tried to log the object it always gives us empty JSON
> ({}).Currently the implementation goes this way when we try to log java
> object.
>
> So I was trying to get rid of this observed behavior of Jaggery.I have
> gone through a solution.
>
> *using Jackson[1] *
>
> We can convert java object to JSON[2] and can log it.
>
> I have shared the piece of code I have tried out with Jackson below.
>
> *Simple POJO Student class*
>
> public class Student {
> private int age;
> private String name;
> private String indexNo;
>
> public int getAge() {
> return age;
> }
>
> public void setAge(int age) {
> this.age = age;
> }
>
> public String getName() {
> return name;
> }
>
> public void setName(String name) {
> this.name = name;
> }
>
> public String getIndexNo() {
> return indexNo;
> }
>
> public void setIndexNo(String indexNo) {
> this.indexNo = indexNo;
> }
> }
>
> *Simple class to test Jackson*
>
> import com.fasterxml.jackson.databind.ObjectMapper;
> import util.Student;
> public class MyTest {
> public static void main(String args[]){
> Student st = new Student();
> st.setIndexNo("DS001");
> st.setAge(12);
> st.setName("kareena");
> try{
> ObjectMapper mapper = new ObjectMapper();
> String jsonInString = mapper.writeValueAsString(st);
> 
> System.out.println("");
> System.out.println(jsonInString);
> 
> System.out.println("");
>
> }catch(Exception e){
> System.out.print("Exception caught  "+ e);
> }
>
> }
> }
>
> Actual output by above code.
> 
> {"age":12,"name":"kareena","indexNo":"DS001"}
> 
>
> I have added a dependency in the POM.xml
>
> 
> com.fasterxml.jackson.core
> jackson-databind
> 2.6.3
> 
>
>
> IMHO we can use the same scenario in case of log JAVA object.Your help and
> suggestions are more appreciated and guide me if I am wrong or I can have
> better solution than this.
>
> [1] - https://github.com/FasterXML/jackson-databind
> [2] -
> http://www.mkyong.com/java/how-to-convert-java-object-to-from-json-jackson/
> --
>
> *Thank You.*
>
> *Rajeenthini Satkunam*
>
> *Associate Software Engineer | WSO2*
>
>
> *E:rajeenth...@wso2.com *
>
> *M :+94770832823 <%2B94770832823>   *
>
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Hareendra Chamara Philips
*Software  Engineer*
Mobile : +94 (0) 767 184161 <%2B94%20%280%29%20773%20451194>
chama...@wso2.com 
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-01-30 Thread Rajeenthini Satkunam
Hi,

I have worked on writing Jaggery test for Jaggery-Product.I can observe
when we tried to log the object it always gives us empty JSON
({}).Currently the implementation goes this way when we try to log java
object.

So I was trying to get rid of this observed behavior of Jaggery.I have gone
through a solution.

*using Jackson[1] *

We can convert java object to JSON[2] and can log it.

I have shared the piece of code I have tried out with Jackson below.

*Simple POJO Student class*

public class Student {
private int age;
private String name;
private String indexNo;

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getIndexNo() {
return indexNo;
}

public void setIndexNo(String indexNo) {
this.indexNo = indexNo;
}
}

*Simple class to test Jackson*

import com.fasterxml.jackson.databind.ObjectMapper;
import util.Student;
public class MyTest {
public static void main(String args[]){
Student st = new Student();
st.setIndexNo("DS001");
st.setAge(12);
st.setName("kareena");
try{
ObjectMapper mapper = new ObjectMapper();
String jsonInString = mapper.writeValueAsString(st);

System.out.println("");
System.out.println(jsonInString);

System.out.println("");

}catch(Exception e){
System.out.print("Exception caught  "+ e);
}

}
}

Actual output by above code.

{"age":12,"name":"kareena","indexNo":"DS001"}


I have added a dependency in the POM.xml


com.fasterxml.jackson.core
jackson-databind
2.6.3



IMHO we can use the same scenario in case of log JAVA object.Your help and
suggestions are more appreciated and guide me if I am wrong or I can have
better solution than this.

[1] - https://github.com/FasterXML/jackson-databind
[2] -
http://www.mkyong.com/java/how-to-convert-java-object-to-from-json-jackson/
-- 

*Thank You.*

*Rajeenthini Satkunam*

*Associate Software Engineer | WSO2*


*E:rajeenth...@wso2.com *

*M :+94770832823   *
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV][JAGGERY] Getting Empty JSON when logging(log.info)

2016-01-30 Thread Sajith Ariyarathna
Hi Rajeenthini,

AFAIK ability to convert a POJO into JSON object does nor affect the output
of a Jaggery Log of that POJO.
To get a proper log output for a Java object, you need to implement the
"toString" method in that Java class. For example in your case,

public class Student {

...

public String toString() {

return "{name: " + this.name + ", age: " + this.age + ", indexNo: " +
this.indexNo + "}";

}

}

Now you can log a Student object in your Jaggery code as following.

log.info(studentObj.toString());


Thanks.



On Sat, Jan 30, 2016 at 9:28 PM, Rajeenthini Satkunam 
wrote:

> Hi,
>
> I have worked on writing Jaggery test for Jaggery-Product.I can observe
> when we tried to log the object it always gives us empty JSON
> ({}).Currently the implementation goes this way when we try to log java
> object.
>
> So I was trying to get rid of this observed behavior of Jaggery.I have
> gone through a solution.
>
> *using Jackson[1] *
>
> We can convert java object to JSON[2] and can log it.
>
> I have shared the piece of code I have tried out with Jackson below.
>
> *Simple POJO Student class*
>
> public class Student {
> private int age;
> private String name;
> private String indexNo;
>
> public int getAge() {
> return age;
> }
>
> public void setAge(int age) {
> this.age = age;
> }
>
> public String getName() {
> return name;
> }
>
> public void setName(String name) {
> this.name = name;
> }
>
> public String getIndexNo() {
> return indexNo;
> }
>
> public void setIndexNo(String indexNo) {
> this.indexNo = indexNo;
> }
> }
>
> *Simple class to test Jackson*
>
> import com.fasterxml.jackson.databind.ObjectMapper;
> import util.Student;
> public class MyTest {
> public static void main(String args[]){
> Student st = new Student();
> st.setIndexNo("DS001");
> st.setAge(12);
> st.setName("kareena");
> try{
> ObjectMapper mapper = new ObjectMapper();
> String jsonInString = mapper.writeValueAsString(st);
> 
> System.out.println("");
> System.out.println(jsonInString);
> 
> System.out.println("");
>
> }catch(Exception e){
> System.out.print("Exception caught  "+ e);
> }
>
> }
> }
>
> Actual output by above code.
> 
> {"age":12,"name":"kareena","indexNo":"DS001"}
> 
>
> I have added a dependency in the POM.xml
>
> 
> com.fasterxml.jackson.core
> jackson-databind
> 2.6.3
> 
>
>
> IMHO we can use the same scenario in case of log JAVA object.Your help and
> suggestions are more appreciated and guide me if I am wrong or I can have
> better solution than this.
>
> [1] - https://github.com/FasterXML/jackson-databind
> [2] -
> http://www.mkyong.com/java/how-to-convert-java-object-to-from-json-jackson/
> --
>
> *Thank You.*
>
> *Rajeenthini Satkunam*
>
> *Associate Software Engineer | WSO2*
>
>
> *E:rajeenth...@wso2.com *
>
> *M :+94770832823 <%2B94770832823>   *
>
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Sajith Ariyarathna
Software Engineer; WSO2, Inc.;  http://wso2.com/
mobile: +94 77 6602284, +94 71 3951048
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV][Jaggery][javascript] jagg.post() returns to the error function while post fuction implements properly.

2015-11-20 Thread Sajith Ariyarathna
Hi Ishara,

Can you share the exception log here? So we can look into it and figure out
whats happening.

Thanks.

On Fri, Nov 20, 2015 at 12:23 PM, Ishara Cooray  wrote:

> I have the following code implemented in a jaggery app. In the reInvite
> function sends an email and returns email. The issue is though the email is
> sent successfully it throws an error.
>
>
> jagg.post("../blocks/tenant/register/invite/ajax/invite.jag", {
> action:"reInvite",
> email:email
> },
> function (result) {
>   //do something
> },
> function (jqXHR, textStatus, errorThrown) {
> //handle error
> });
>
> What could be the possible reason for this error?
> Appreciate your inputs.
>
> Thanks.
> Ishara Cooray
> Senior Software Engineer
> Mobile : +9477 262 9512
> WSO2, Inc. | http://wso2.com/
> Lean . Enterprise . Middleware
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Sajith Ariyarathna
Software Engineer; WSO2, Inc.;  http://wso2.com/
mobile: +94 77 6602284, +94 71 3951048
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] [Jaggery]How to convert/cast an exception stachtrace to a string

2015-11-20 Thread Lalanke Athauda
Hi Ishara,
Are you sure? It works perfect for me. I tested both with and without
stringify method.
Could you show your code? Maybe I might have misunderstood your problem.

On Fri, Nov 20, 2015 at 1:21 PM, Ishara Cooray  wrote:

> Thanks for the reply Lalanke. But *stringify() * results the same.
>
> Ishara Cooray
> Senior Software Engineer
> Mobile : +9477 262 9512
> WSO2, Inc. | http://wso2.com/
> Lean . Enterprise . Middleware
>
> On Fri, Nov 20, 2015 at 12:22 PM, Lalanke Athauda 
> wrote:
>
>> Hi Ishara,
>> Try this one.
>>
>> var exceptionString = "Custom Message" + *stringify*(e);
>>
>> Hope this solve your problem.
>>
>> On Fri, Nov 20, 2015 at 11:57 AM, Ishara Cooray  wrote:
>>
>>> Hi,
>>>
>>> In Jaggerry If an exception is concatenated to a string it will
>>> concatenate only the message part but the stacktrace is omited.
>>>
>>> ex: var exceptionString = "Custom Message" + e;
>>> This exceptionString does not have the stacktrace.
>>>
>>> How can i get the exception with the stacktrace as a string in Jaggery?
>>>
>>>
>>> Thanks & Regards,
>>> Ishara Cooray
>>> Senior Software Engineer
>>> Mobile : +9477 262 9512
>>> WSO2, Inc. | http://wso2.com/
>>> Lean . Enterprise . Middleware
>>>
>>> ___
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> Lalanke Athauda
>> Software Engineer
>> WSO2 Inc.
>> Mobile: 0772264301
>>
>
>


-- 
Lalanke Athauda
Software Engineer
WSO2 Inc.
Mobile: 0772264301
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] [Jaggery]How to convert/cast an exception stachtrace to a string

2015-11-20 Thread Chamara Philips
Hi Ishara,

In Jaggery you can use try, catch with Log to log errors properly.
Following is an example.

var log = new Log();
try{
//do work
} catch (e) {
log.error(e) ; //logs the stack trace
print(e); // prints the stack trace
} finally{
//do final
}

Also you can use the properties of exception to get specific information.

Ex :

e.lineNumber => Line number where the error occured
e.message => Javascript error message
e.javaException => Java exception object.

Hope it helps.

Thanks.


On Fri, Nov 20, 2015 at 1:21 PM, Ishara Cooray  wrote:

> Thanks for the reply Lalanke. But *stringify() * results the same.
>
> Ishara Cooray
> Senior Software Engineer
> Mobile : +9477 262 9512
> WSO2, Inc. | http://wso2.com/
> Lean . Enterprise . Middleware
>
> On Fri, Nov 20, 2015 at 12:22 PM, Lalanke Athauda 
> wrote:
>
>> Hi Ishara,
>> Try this one.
>>
>> var exceptionString = "Custom Message" + *stringify*(e);
>>
>> Hope this solve your problem.
>>
>> On Fri, Nov 20, 2015 at 11:57 AM, Ishara Cooray  wrote:
>>
>>> Hi,
>>>
>>> In Jaggerry If an exception is concatenated to a string it will
>>> concatenate only the message part but the stacktrace is omited.
>>>
>>> ex: var exceptionString = "Custom Message" + e;
>>> This exceptionString does not have the stacktrace.
>>>
>>> How can i get the exception with the stacktrace as a string in Jaggery?
>>>
>>>
>>> Thanks & Regards,
>>> Ishara Cooray
>>> Senior Software Engineer
>>> Mobile : +9477 262 9512
>>> WSO2, Inc. | http://wso2.com/
>>> Lean . Enterprise . Middleware
>>>
>>> ___
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> Lalanke Athauda
>> Software Engineer
>> WSO2 Inc.
>> Mobile: 0772264301
>>
>
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Hareendra Chamara P h i l i p s
*Software  Engineer*
Mobile : +94 (0) 767 184161 <%2B94%20%280%29%20773%20451194>
chama...@wso2.com 
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] [DEV] [Jaggery]How to convert/cast an exception stachtrace to a string

2015-11-19 Thread Ishara Cooray
Hi,

In Jaggerry If an exception is concatenated to a string it will concatenate
only the message part but the stacktrace is omited.

ex: var exceptionString = "Custom Message" + e;
This exceptionString does not have the stacktrace.

How can i get the exception with the stacktrace as a string in Jaggery?


Thanks & Regards,
Ishara Cooray
Senior Software Engineer
Mobile : +9477 262 9512
WSO2, Inc. | http://wso2.com/
Lean . Enterprise . Middleware
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] [Jaggery]How to convert/cast an exception stachtrace to a string

2015-11-19 Thread Lalanke Athauda
Hi Ishara,
Try this one.

var exceptionString = "Custom Message" + *stringify*(e);

Hope this solve your problem.

On Fri, Nov 20, 2015 at 11:57 AM, Ishara Cooray  wrote:

> Hi,
>
> In Jaggerry If an exception is concatenated to a string it will
> concatenate only the message part but the stacktrace is omited.
>
> ex: var exceptionString = "Custom Message" + e;
> This exceptionString does not have the stacktrace.
>
> How can i get the exception with the stacktrace as a string in Jaggery?
>
>
> Thanks & Regards,
> Ishara Cooray
> Senior Software Engineer
> Mobile : +9477 262 9512
> WSO2, Inc. | http://wso2.com/
> Lean . Enterprise . Middleware
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Lalanke Athauda
Software Engineer
WSO2 Inc.
Mobile: 0772264301
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] [DEV][Jaggery][javascript] jagg.post() returns to the error function while post fuction implements properly.

2015-11-19 Thread Ishara Cooray
I have the following code implemented in a jaggery app. In the reInvite
function sends an email and returns email. The issue is though the email is
sent successfully it throws an error.


jagg.post("../blocks/tenant/register/invite/ajax/invite.jag", {
action:"reInvite",
email:email
},
function (result) {
  //do something
},
function (jqXHR, textStatus, errorThrown) {
//handle error
});

What could be the possible reason for this error?
Appreciate your inputs.

Thanks.
Ishara Cooray
Senior Software Engineer
Mobile : +9477 262 9512
WSO2, Inc. | http://wso2.com/
Lean . Enterprise . Middleware
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] [Jaggery]How to convert/cast an exception stachtrace to a string

2015-11-19 Thread Ishara Cooray
Thanks for the reply Lalanke. But *stringify() * results the same.

Ishara Cooray
Senior Software Engineer
Mobile : +9477 262 9512
WSO2, Inc. | http://wso2.com/
Lean . Enterprise . Middleware

On Fri, Nov 20, 2015 at 12:22 PM, Lalanke Athauda  wrote:

> Hi Ishara,
> Try this one.
>
> var exceptionString = "Custom Message" + *stringify*(e);
>
> Hope this solve your problem.
>
> On Fri, Nov 20, 2015 at 11:57 AM, Ishara Cooray  wrote:
>
>> Hi,
>>
>> In Jaggerry If an exception is concatenated to a string it will
>> concatenate only the message part but the stacktrace is omited.
>>
>> ex: var exceptionString = "Custom Message" + e;
>> This exceptionString does not have the stacktrace.
>>
>> How can i get the exception with the stacktrace as a string in Jaggery?
>>
>>
>> Thanks & Regards,
>> Ishara Cooray
>> Senior Software Engineer
>> Mobile : +9477 262 9512
>> WSO2, Inc. | http://wso2.com/
>> Lean . Enterprise . Middleware
>>
>> ___
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Lalanke Athauda
> Software Engineer
> WSO2 Inc.
> Mobile: 0772264301
>
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-08-12 Thread Ajith Vitharana
Hi All

Seems the issue [1] is due to the same reason (please correct if i'm wrong)
So can we apply same kind of fix to resolve [1] ?

[1] https://wso2.org/jira/browse/BAM-1383

-Ajith

On Fri, Mar 20, 2015 at 2:33 PM, Rasika Perera rasi...@wso2.com wrote:

 Hi Tharindu,

 Correct. As we discussed, we are making two network calls for the same
 functionality. Assuming that the network call is costly, when number of
 log-in users increasing and fetching Human Tasks available on BPS server,
 network traffic is increased.

 However, It might not affect very badly when there are less number of
 concurrent log-ins. On the other-hand, it might be the case for highly
 occupied production environment.

 Thank you

 On Fri, Mar 20, 2015 at 11:48 PM, Tharindu Dharmarathna 
 tharin...@wso2.com wrote:

 Hi Rasika,

 Thank you for the clarification , and as our offline chat we are sending
 multiple network calls to the BPS is that not become issue come into the
 production ? .

 Thanks and Regards
 Tharindu.

 On Fri, Mar 20, 2015 at 11:37 PM, Rasika Perera rasi...@wso2.com wrote:

 Hi Lakmali,

 +1 for the explanation. In your solution, I think HTTP HEAD[1] is better
 to testing accessibility of the server endpoint.

 var httpClient = new
 Packages.org.apache.http.impl.client.DefaultHttpClient();
 var *httpHead* = new Packages.org.apache.http.client.methods.*HttpHead*
 (endpoint);
 var response = httpClient.execute(*httpHead*);
 BPSRunning = true;

 [1]
 http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpHead.html

 Thank you

 On Fri, Mar 20, 2015 at 11:53 AM, Lakmali Baminiwatta lakm...@wso2.com
 wrote:

 Thanks Ruchira for the information.

 On 19 March 2015 at 18:00, Ruchira Wageesha ruch...@wso2.com wrote:

 Following are the possible options that I can think.

 1. Patching XHR to get rid of the log message
 2. Hiding the error from log4j, but AFAIK, then it will not log any
 error from XHR
 3. Using any Java's http-client directly from Jaggery[a] to do the
 HTTP calls instead of XHR
 4. Using any Java's http-client to check the endpoint status, and
 continue original HTTP call with XHR

 [a]
 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java

 /Ruchira

 On Thu, Mar 19, 2015 at 5:18 PM, Lakmali Baminiwatta lakm...@wso2.com
  wrote:

 Hi Ruchira,

 In APIM and APPM we talk to the BPS server and fetch Human Tasks
 available. For that when the user is login to the admin-dashboard jaggery
 app, we do a login call to BPS server using XMLHttpRequest. At this 
 point,
 if the BPS is not running we are getting this connection refused error in
 the logs. We need to handle this.

 As Tharindu mentioned, XMLHttpRequestHostObject.java uses log.error(e
 .getMessage(), e); [1]. Therefore we can't get rid of this stack
 trace in the log by just catching the exception.

 Is there any method in jaggery that we can use to check whether
 server is up and running before doing the send call and handle this?
 Appreciate any help on this.

 [1]
 https://github.com/wso2/jaggery/blob/0.9.0.ALPHA4.wso2v4/components/hostobjects/org.jaggeryjs.hostobjects.xhr/src/main/java/org/jaggeryjs/hostobjects/xhr/XMLHttpRequestHostObject.java
 [2]https://wso2.org/jira/browse/APPM-587
 [3]https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks,
 Lakmali

 On 18 March 2015 at 08:57, Tharindu Dharmarathna tharin...@wso2.com
 wrote:

 Hi Ruchira,

 We want to carch the exception according to connection refused
 exception from the jaggery side . Due to logging of this  exception from
 Hostobject We couldn't remove this exception come from the console.

 Is there any way of check a server is up and running from jaggery
 side . If there's a way we can avoid exception come from the console.

 Thanks
 Tharindu

 On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 What is the issue with going try/catch blocks?

 /Ruchira

 On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna 
 tharin...@wso2.com wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);

 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch 

Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-20 Thread Lakmali Baminiwatta
Hi all,

Isn't it better to handle this error rather than hiding the logs through
log4j.properties? I think option 4 is better and has minimal changes to
existing logic.

ex: We can put a try/catch block and handle below before the XHR request.

var httpClient = new
Packages.org.apache.http.impl.client.DefaultHttpClient();
var httpPost = new
Packages.org.apache.http.client.methods.HttpPost(endpoint);
var response = httpClient.execute(httpPost);
BPSRunning = true;

Thanks,
Lakmali

On 20 March 2015 at 10:33, Rasika Perera rasi...@wso2.com wrote:

 [Please ignore my previous reply, it was incomplete]

 Hi Tharindu,

 According to chat we had, IMO if your intention is to avoid error messages
 from XMLHttpRequestHostObject.java rather than patching XHR, you can
 add following to your log4j property file.

 log4j.logger.your package = DEBUG|INFO|OFF|WARN...

 log4j.logger.org.jaggeryjs.hostobjects.xhr.XMLHttpRequestHostObject = FATAL

 Or...

 log4j.logger.org.jaggeryjs.hostobjects.xhr= FATAL

 Note that i used log level FATAL over completely turn off logging using
 OFF.

 Thank you

 On Fri, Mar 20, 2015 at 10:27 AM, Rasika Perera rasi...@wso2.com wrote:

 Hi Tharindu,

 According to chat we had, IMO if your intention is to avoid error
 messages from XMLHttpRequestHostObject.java rather than patching XHR, you
 can add following to your log4j property file.

 log4j.logger.your package = DEBUG|INFO|OFF|WARN...

 log4j.logger.org.jaggeryjs.hostobjects.xhr.XMLHttpRequestHostObject =
 FATAL

 or


 Note that i used log level FATAL over completely turn off logging using
 OFF.

 Thank you


 On Thu, Mar 19, 2015 at 6:00 PM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 Following are the possible options that I can think.

 1. Patching XHR to get rid of the log message
 2. Hiding the error from log4j, but AFAIK, then it will not log any
 error from XHR
 3. Using any Java's http-client directly from Jaggery[a] to do the HTTP
 calls instead of XHR
 4. Using any Java's http-client to check the endpoint status, and
 continue original HTTP call with XHR

 [a]
 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java

 /Ruchira

 On Thu, Mar 19, 2015 at 5:18 PM, Lakmali Baminiwatta lakm...@wso2.com
 wrote:

 Hi Ruchira,

 In APIM and APPM we talk to the BPS server and fetch Human Tasks
 available. For that when the user is login to the admin-dashboard jaggery
 app, we do a login call to BPS server using XMLHttpRequest. At this point,
 if the BPS is not running we are getting this connection refused error in
 the logs. We need to handle this.

 As Tharindu mentioned, XMLHttpRequestHostObject.java uses 
 log.error(e.getMessage(),
 e); [1]. Therefore we can't get rid of this stack trace in the log by
 just catching the exception.

 Is there any method in jaggery that we can use to check whether server
 is up and running before doing the send call and handle this? Appreciate
 any help on this.

 [1]
 https://github.com/wso2/jaggery/blob/0.9.0.ALPHA4.wso2v4/components/hostobjects/org.jaggeryjs.hostobjects.xhr/src/main/java/org/jaggeryjs/hostobjects/xhr/XMLHttpRequestHostObject.java
 [2]https://wso2.org/jira/browse/APPM-587
 [3]https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks,
 Lakmali

 On 18 March 2015 at 08:57, Tharindu Dharmarathna tharin...@wso2.com
 wrote:

 Hi Ruchira,

 We want to carch the exception according to connection refused
 exception from the jaggery side . Due to logging of this  exception from
 Hostobject We couldn't remove this exception come from the console.

 Is there any way of check a server is up and running from jaggery side
 . If there's a way we can avoid exception come from the console.

 Thanks
 Tharindu

 On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 What is the issue with going try/catch blocks?

 /Ruchira

 On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna 
 tharin...@wso2.com wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


 Exception come from the following jaggery hostobject code

 

Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-20 Thread Rasika Perera
Hi Tharindu,

Correct. As we discussed, we are making two network calls for the same
functionality. Assuming that the network call is costly, when number of
log-in users increasing and fetching Human Tasks available on BPS server,
network traffic is increased.

However, It might not affect very badly when there are less number of
concurrent log-ins. On the other-hand, it might be the case for highly
occupied production environment.

Thank you

On Fri, Mar 20, 2015 at 11:48 PM, Tharindu Dharmarathna tharin...@wso2.com
wrote:

 Hi Rasika,

 Thank you for the clarification , and as our offline chat we are sending
 multiple network calls to the BPS is that not become issue come into the
 production ? .

 Thanks and Regards
 Tharindu.

 On Fri, Mar 20, 2015 at 11:37 PM, Rasika Perera rasi...@wso2.com wrote:

 Hi Lakmali,

 +1 for the explanation. In your solution, I think HTTP HEAD[1] is better
 to testing accessibility of the server endpoint.

 var httpClient = new
 Packages.org.apache.http.impl.client.DefaultHttpClient();
 var *httpHead* = new Packages.org.apache.http.client.methods.*HttpHead*
 (endpoint);
 var response = httpClient.execute(*httpHead*);
 BPSRunning = true;

 [1]
 http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpHead.html

 Thank you

 On Fri, Mar 20, 2015 at 11:53 AM, Lakmali Baminiwatta lakm...@wso2.com
 wrote:

 Thanks Ruchira for the information.

 On 19 March 2015 at 18:00, Ruchira Wageesha ruch...@wso2.com wrote:

 Following are the possible options that I can think.

 1. Patching XHR to get rid of the log message
 2. Hiding the error from log4j, but AFAIK, then it will not log any
 error from XHR
 3. Using any Java's http-client directly from Jaggery[a] to do the HTTP
 calls instead of XHR
 4. Using any Java's http-client to check the endpoint status, and
 continue original HTTP call with XHR

 [a]
 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java

 /Ruchira

 On Thu, Mar 19, 2015 at 5:18 PM, Lakmali Baminiwatta lakm...@wso2.com
 wrote:

 Hi Ruchira,

 In APIM and APPM we talk to the BPS server and fetch Human Tasks
 available. For that when the user is login to the admin-dashboard jaggery
 app, we do a login call to BPS server using XMLHttpRequest. At this point,
 if the BPS is not running we are getting this connection refused error in
 the logs. We need to handle this.

 As Tharindu mentioned, XMLHttpRequestHostObject.java uses 
 log.error(e.getMessage(),
 e); [1]. Therefore we can't get rid of this stack trace in the log by
 just catching the exception.

 Is there any method in jaggery that we can use to check whether server
 is up and running before doing the send call and handle this? Appreciate
 any help on this.

 [1]
 https://github.com/wso2/jaggery/blob/0.9.0.ALPHA4.wso2v4/components/hostobjects/org.jaggeryjs.hostobjects.xhr/src/main/java/org/jaggeryjs/hostobjects/xhr/XMLHttpRequestHostObject.java
 [2]https://wso2.org/jira/browse/APPM-587
 [3]https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks,
 Lakmali

 On 18 March 2015 at 08:57, Tharindu Dharmarathna tharin...@wso2.com
 wrote:

 Hi Ruchira,

 We want to carch the exception according to connection refused
 exception from the jaggery side . Due to logging of this  exception from
 Hostobject We couldn't remove this exception come from the console.

 Is there any way of check a server is up and running from jaggery
 side . If there's a way we can avoid exception come from the console.

 Thanks
 Tharindu

 On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 What is the issue with going try/catch blocks?

 /Ruchira

 On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna 
 tharin...@wso2.com wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


 Exception come from the following jaggery hostobject code

 private static void executeRequest(Context cx,
 XMLHttpRequestHostObject xhr) throws ScriptException {
 try {
 xhr.httpClient.executeMethod(xhr.method);
 xhr.statusLine = 

Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-20 Thread Tharindu Dharmarathna
Hi Rasika,

Thank you for the clarification , and as our offline chat we are sending
multiple network calls to the BPS is that not become issue come into the
production ? .

Thanks and Regards
Tharindu.

On Fri, Mar 20, 2015 at 11:37 PM, Rasika Perera rasi...@wso2.com wrote:

 Hi Lakmali,

 +1 for the explanation. In your solution, I think HTTP HEAD[1] is better
 to testing accessibility of the server endpoint.

 var httpClient = new
 Packages.org.apache.http.impl.client.DefaultHttpClient();
 var *httpHead* = new Packages.org.apache.http.client.methods.*HttpHead*
 (endpoint);
 var response = httpClient.execute(*httpHead*);
 BPSRunning = true;

 [1]
 http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpHead.html

 Thank you

 On Fri, Mar 20, 2015 at 11:53 AM, Lakmali Baminiwatta lakm...@wso2.com
 wrote:

 Thanks Ruchira for the information.

 On 19 March 2015 at 18:00, Ruchira Wageesha ruch...@wso2.com wrote:

 Following are the possible options that I can think.

 1. Patching XHR to get rid of the log message
 2. Hiding the error from log4j, but AFAIK, then it will not log any
 error from XHR
 3. Using any Java's http-client directly from Jaggery[a] to do the HTTP
 calls instead of XHR
 4. Using any Java's http-client to check the endpoint status, and
 continue original HTTP call with XHR

 [a]
 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java

 /Ruchira

 On Thu, Mar 19, 2015 at 5:18 PM, Lakmali Baminiwatta lakm...@wso2.com
 wrote:

 Hi Ruchira,

 In APIM and APPM we talk to the BPS server and fetch Human Tasks
 available. For that when the user is login to the admin-dashboard jaggery
 app, we do a login call to BPS server using XMLHttpRequest. At this point,
 if the BPS is not running we are getting this connection refused error in
 the logs. We need to handle this.

 As Tharindu mentioned, XMLHttpRequestHostObject.java uses 
 log.error(e.getMessage(),
 e); [1]. Therefore we can't get rid of this stack trace in the log by
 just catching the exception.

 Is there any method in jaggery that we can use to check whether server
 is up and running before doing the send call and handle this? Appreciate
 any help on this.

 [1]
 https://github.com/wso2/jaggery/blob/0.9.0.ALPHA4.wso2v4/components/hostobjects/org.jaggeryjs.hostobjects.xhr/src/main/java/org/jaggeryjs/hostobjects/xhr/XMLHttpRequestHostObject.java
 [2]https://wso2.org/jira/browse/APPM-587
 [3]https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks,
 Lakmali

 On 18 March 2015 at 08:57, Tharindu Dharmarathna tharin...@wso2.com
 wrote:

 Hi Ruchira,

 We want to carch the exception according to connection refused
 exception from the jaggery side . Due to logging of this  exception from
 Hostobject We couldn't remove this exception come from the console.

 Is there any way of check a server is up and running from jaggery side
 . If there's a way we can avoid exception come from the console.

 Thanks
 Tharindu

 On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 What is the issue with going try/catch blocks?

 /Ruchira

 On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna 
 tharin...@wso2.com wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


 Exception come from the following jaggery hostobject code

 private static void executeRequest(Context cx,
 XMLHttpRequestHostObject xhr) throws ScriptException {
 try {
 xhr.httpClient.executeMethod(xhr.method);
 xhr.statusLine = xhr.method.getStatusLine();
 xhr.responseHeaders = xhr.method.getResponseHeaders();
 updateReadyState(cx, xhr, HEADERS_RECEIVED);
 byte[] response = xhr.method.getResponseBody();
 if (response.length  0) {
 xhr.responseText = new String(response);
 }
 Header contentType = xhr.method.getResponseHeader(Content-Type);
 if (contentType != null) {
 xhr.responseType = contentType.getValue();
 }
 updateReadyState(cx, xhr, DONE);
 } catch (IOException e) {
 log.error(e.getMessage(), e);
 throw new ScriptException(e);
 } finally {
 

Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-20 Thread Rasika Perera
Hi Lakmali,

+1 for the explanation. In your solution, I think HTTP HEAD[1] is better to
testing accessibility of the server endpoint.

var httpClient = new
Packages.org.apache.http.impl.client.DefaultHttpClient();
var *httpHead* = new Packages.org.apache.http.client.methods.*HttpHead*
(endpoint);
var response = httpClient.execute(*httpHead*);
BPSRunning = true;

[1]
http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpHead.html

Thank you

On Fri, Mar 20, 2015 at 11:53 AM, Lakmali Baminiwatta lakm...@wso2.com
wrote:

 Thanks Ruchira for the information.

 On 19 March 2015 at 18:00, Ruchira Wageesha ruch...@wso2.com wrote:

 Following are the possible options that I can think.

 1. Patching XHR to get rid of the log message
 2. Hiding the error from log4j, but AFAIK, then it will not log any error
 from XHR
 3. Using any Java's http-client directly from Jaggery[a] to do the HTTP
 calls instead of XHR
 4. Using any Java's http-client to check the endpoint status, and
 continue original HTTP call with XHR

 [a]
 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java

 /Ruchira

 On Thu, Mar 19, 2015 at 5:18 PM, Lakmali Baminiwatta lakm...@wso2.com
 wrote:

 Hi Ruchira,

 In APIM and APPM we talk to the BPS server and fetch Human Tasks
 available. For that when the user is login to the admin-dashboard jaggery
 app, we do a login call to BPS server using XMLHttpRequest. At this point,
 if the BPS is not running we are getting this connection refused error in
 the logs. We need to handle this.

 As Tharindu mentioned, XMLHttpRequestHostObject.java uses 
 log.error(e.getMessage(),
 e); [1]. Therefore we can't get rid of this stack trace in the log by
 just catching the exception.

 Is there any method in jaggery that we can use to check whether server
 is up and running before doing the send call and handle this? Appreciate
 any help on this.

 [1]
 https://github.com/wso2/jaggery/blob/0.9.0.ALPHA4.wso2v4/components/hostobjects/org.jaggeryjs.hostobjects.xhr/src/main/java/org/jaggeryjs/hostobjects/xhr/XMLHttpRequestHostObject.java
 [2]https://wso2.org/jira/browse/APPM-587
 [3]https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks,
 Lakmali

 On 18 March 2015 at 08:57, Tharindu Dharmarathna tharin...@wso2.com
 wrote:

 Hi Ruchira,

 We want to carch the exception according to connection refused
 exception from the jaggery side . Due to logging of this  exception from
 Hostobject We couldn't remove this exception come from the console.

 Is there any way of check a server is up and running from jaggery side
 . If there's a way we can avoid exception come from the console.

 Thanks
 Tharindu

 On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 What is the issue with going try/catch blocks?

 /Ruchira

 On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna 
 tharin...@wso2.com wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


 Exception come from the following jaggery hostobject code

 private static void executeRequest(Context cx,
 XMLHttpRequestHostObject xhr) throws ScriptException {
 try {
 xhr.httpClient.executeMethod(xhr.method);
 xhr.statusLine = xhr.method.getStatusLine();
 xhr.responseHeaders = xhr.method.getResponseHeaders();
 updateReadyState(cx, xhr, HEADERS_RECEIVED);
 byte[] response = xhr.method.getResponseBody();
 if (response.length  0) {
 xhr.responseText = new String(response);
 }
 Header contentType = xhr.method.getResponseHeader(Content-Type);
 if (contentType != null) {
 xhr.responseType = contentType.getValue();
 }
 updateReadyState(cx, xhr, DONE);
 } catch (IOException e) {
 log.error(e.getMessage(), e);
 throw new ScriptException(e);
 } finally {
 xhr.method.releaseConnection();
 }
 }

 XMLHttpRequestHostObject.java

 [1] - https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks and regards


 *Tharindu Dharmarathna*Associate Software Engineer
 WSO2 Inc.; http://wso2.com
 lean.enterprise.middleware

 mobile: *+94779109091 %2B94779109091*




 --

 

Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-19 Thread Ruchira Wageesha
Following are the possible options that I can think.

1. Patching XHR to get rid of the log message
2. Hiding the error from log4j, but AFAIK, then it will not log any error
from XHR
3. Using any Java's http-client directly from Jaggery[a] to do the HTTP
calls instead of XHR
4. Using any Java's http-client to check the endpoint status, and continue
original HTTP call with XHR

[a]
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java

/Ruchira

On Thu, Mar 19, 2015 at 5:18 PM, Lakmali Baminiwatta lakm...@wso2.com
wrote:

 Hi Ruchira,

 In APIM and APPM we talk to the BPS server and fetch Human Tasks
 available. For that when the user is login to the admin-dashboard jaggery
 app, we do a login call to BPS server using XMLHttpRequest. At this point,
 if the BPS is not running we are getting this connection refused error in
 the logs. We need to handle this.

 As Tharindu mentioned, XMLHttpRequestHostObject.java uses 
 log.error(e.getMessage(),
 e); [1]. Therefore we can't get rid of this stack trace in the log by
 just catching the exception.

 Is there any method in jaggery that we can use to check whether server is
 up and running before doing the send call and handle this? Appreciate any
 help on this.

 [1]
 https://github.com/wso2/jaggery/blob/0.9.0.ALPHA4.wso2v4/components/hostobjects/org.jaggeryjs.hostobjects.xhr/src/main/java/org/jaggeryjs/hostobjects/xhr/XMLHttpRequestHostObject.java
 [2]https://wso2.org/jira/browse/APPM-587
 [3]https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks,
 Lakmali

 On 18 March 2015 at 08:57, Tharindu Dharmarathna tharin...@wso2.com
 wrote:

 Hi Ruchira,

 We want to carch the exception according to connection refused exception
 from the jaggery side . Due to logging of this  exception from Hostobject
 We couldn't remove this exception come from the console.

 Is there any way of check a server is up and running from jaggery side .
 If there's a way we can avoid exception come from the console.

 Thanks
 Tharindu

 On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 What is the issue with going try/catch blocks?

 /Ruchira

 On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna 
 tharin...@wso2.com wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


 Exception come from the following jaggery hostobject code

 private static void executeRequest(Context cx, XMLHttpRequestHostObject
 xhr) throws ScriptException {
 try {
 xhr.httpClient.executeMethod(xhr.method);
 xhr.statusLine = xhr.method.getStatusLine();
 xhr.responseHeaders = xhr.method.getResponseHeaders();
 updateReadyState(cx, xhr, HEADERS_RECEIVED);
 byte[] response = xhr.method.getResponseBody();
 if (response.length  0) {
 xhr.responseText = new String(response);
 }
 Header contentType = xhr.method.getResponseHeader(Content-Type);
 if (contentType != null) {
 xhr.responseType = contentType.getValue();
 }
 updateReadyState(cx, xhr, DONE);
 } catch (IOException e) {
 log.error(e.getMessage(), e);
 throw new ScriptException(e);
 } finally {
 xhr.method.releaseConnection();
 }
 }

 XMLHttpRequestHostObject.java

 [1] - https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks and regards


 *Tharindu Dharmarathna*Associate Software Engineer
 WSO2 Inc.; http://wso2.com
 lean.enterprise.middleware

 mobile: *+94779109091 %2B94779109091*




 --

 *Ruchira Wageesha**Associate Technical Lead*
 *WSO2 Inc. - lean . enterprise . middleware |  wso2.com
 http://wso2.com*

 *email: ruch...@wso2.com ruch...@wso2.com,   blog:
 ruchirawageesha.blogspot.com http://ruchirawageesha.blogspot.com,
 mobile: +94 77 5493444 %2B94%2077%205493444*




 --

 *Tharindu Dharmarathna*Associate Software Engineer
 WSO2 Inc.; http://wso2.com
 lean.enterprise.middleware

 mobile: *+94779109091 %2B94779109091*

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Lakmali Baminiwatta
  Senior Software Engineer
 WSO2, Inc.: http://wso2.com
 lean.enterprise.middleware
 mobile: 

Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-19 Thread Lakmali Baminiwatta
Hi Ruchira,

In APIM and APPM we talk to the BPS server and fetch Human Tasks available.
For that when the user is login to the admin-dashboard jaggery app, we do a
login call to BPS server using XMLHttpRequest. At this point, if the BPS is
not running we are getting this connection refused error in the logs. We
need to handle this.

As Tharindu mentioned, XMLHttpRequestHostObject.java uses
log.error(e.getMessage(),
e); [1]. Therefore we can't get rid of this stack trace in the log by just
catching the exception.

Is there any method in jaggery that we can use to check whether server is
up and running before doing the send call and handle this? Appreciate any
help on this.

[1]
https://github.com/wso2/jaggery/blob/0.9.0.ALPHA4.wso2v4/components/hostobjects/org.jaggeryjs.hostobjects.xhr/src/main/java/org/jaggeryjs/hostobjects/xhr/XMLHttpRequestHostObject.java
[2]https://wso2.org/jira/browse/APPM-587
[3]https://wso2.org/jira/browse/APIMANAGER-3139

Thanks,
Lakmali

On 18 March 2015 at 08:57, Tharindu Dharmarathna tharin...@wso2.com wrote:

 Hi Ruchira,

 We want to carch the exception according to connection refused exception
 from the jaggery side . Due to logging of this  exception from Hostobject
 We couldn't remove this exception come from the console.

 Is there any way of check a server is up and running from jaggery side .
 If there's a way we can avoid exception come from the console.

 Thanks
 Tharindu

 On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 What is the issue with going try/catch blocks?

 /Ruchira

 On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna 
 tharin...@wso2.com wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


 Exception come from the following jaggery hostobject code

 private static void executeRequest(Context cx, XMLHttpRequestHostObject
 xhr) throws ScriptException {
 try {
 xhr.httpClient.executeMethod(xhr.method);
 xhr.statusLine = xhr.method.getStatusLine();
 xhr.responseHeaders = xhr.method.getResponseHeaders();
 updateReadyState(cx, xhr, HEADERS_RECEIVED);
 byte[] response = xhr.method.getResponseBody();
 if (response.length  0) {
 xhr.responseText = new String(response);
 }
 Header contentType = xhr.method.getResponseHeader(Content-Type);
 if (contentType != null) {
 xhr.responseType = contentType.getValue();
 }
 updateReadyState(cx, xhr, DONE);
 } catch (IOException e) {
 log.error(e.getMessage(), e);
 throw new ScriptException(e);
 } finally {
 xhr.method.releaseConnection();
 }
 }

 XMLHttpRequestHostObject.java

 [1] - https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks and regards


 *Tharindu Dharmarathna*Associate Software Engineer
 WSO2 Inc.; http://wso2.com
 lean.enterprise.middleware

 mobile: *+94779109091 %2B94779109091*




 --

 *Ruchira Wageesha**Associate Technical Lead*
 *WSO2 Inc. - lean . enterprise . middleware |  wso2.com http://wso2.com*

 *email: ruch...@wso2.com ruch...@wso2.com,   blog:
 ruchirawageesha.blogspot.com http://ruchirawageesha.blogspot.com,
 mobile: +94 77 5493444 %2B94%2077%205493444*




 --

 *Tharindu Dharmarathna*Associate Software Engineer
 WSO2 Inc.; http://wso2.com
 lean.enterprise.middleware

 mobile: *+94779109091 %2B94779109091*

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
Lakmali Baminiwatta
 Senior Software Engineer
WSO2, Inc.: http://wso2.com
lean.enterprise.middleware
mobile:  +94 71 2335936
blog : lakmali.com
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-19 Thread Rasika Perera
Hi Tharindu,

According to chat we had, IMO if your intention is to avoid error messages
from XMLHttpRequestHostObject.java rather than patching XHR, you can
add following to your log4j property file.

log4j.logger.your package = DEBUG|INFO|OFF|WARN...

log4j.logger.org.jaggeryjs.hostobjects.xhr.XMLHttpRequestHostObject = FATAL

or


Note that i used log level FATAL over completely turn off logging using
OFF.

Thank you


On Thu, Mar 19, 2015 at 6:00 PM, Ruchira Wageesha ruch...@wso2.com wrote:

 Following are the possible options that I can think.

 1. Patching XHR to get rid of the log message
 2. Hiding the error from log4j, but AFAIK, then it will not log any error
 from XHR
 3. Using any Java's http-client directly from Jaggery[a] to do the HTTP
 calls instead of XHR
 4. Using any Java's http-client to check the endpoint status, and continue
 original HTTP call with XHR

 [a]
 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java

 /Ruchira

 On Thu, Mar 19, 2015 at 5:18 PM, Lakmali Baminiwatta lakm...@wso2.com
 wrote:

 Hi Ruchira,

 In APIM and APPM we talk to the BPS server and fetch Human Tasks
 available. For that when the user is login to the admin-dashboard jaggery
 app, we do a login call to BPS server using XMLHttpRequest. At this point,
 if the BPS is not running we are getting this connection refused error in
 the logs. We need to handle this.

 As Tharindu mentioned, XMLHttpRequestHostObject.java uses 
 log.error(e.getMessage(),
 e); [1]. Therefore we can't get rid of this stack trace in the log by
 just catching the exception.

 Is there any method in jaggery that we can use to check whether server is
 up and running before doing the send call and handle this? Appreciate any
 help on this.

 [1]
 https://github.com/wso2/jaggery/blob/0.9.0.ALPHA4.wso2v4/components/hostobjects/org.jaggeryjs.hostobjects.xhr/src/main/java/org/jaggeryjs/hostobjects/xhr/XMLHttpRequestHostObject.java
 [2]https://wso2.org/jira/browse/APPM-587
 [3]https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks,
 Lakmali

 On 18 March 2015 at 08:57, Tharindu Dharmarathna tharin...@wso2.com
 wrote:

 Hi Ruchira,

 We want to carch the exception according to connection refused exception
 from the jaggery side . Due to logging of this  exception from Hostobject
 We couldn't remove this exception come from the console.

 Is there any way of check a server is up and running from jaggery side .
 If there's a way we can avoid exception come from the console.

 Thanks
 Tharindu

 On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 What is the issue with going try/catch blocks?

 /Ruchira

 On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna 
 tharin...@wso2.com wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


 Exception come from the following jaggery hostobject code

 private static void executeRequest(Context cx,
 XMLHttpRequestHostObject xhr) throws ScriptException {
 try {
 xhr.httpClient.executeMethod(xhr.method);
 xhr.statusLine = xhr.method.getStatusLine();
 xhr.responseHeaders = xhr.method.getResponseHeaders();
 updateReadyState(cx, xhr, HEADERS_RECEIVED);
 byte[] response = xhr.method.getResponseBody();
 if (response.length  0) {
 xhr.responseText = new String(response);
 }
 Header contentType = xhr.method.getResponseHeader(Content-Type);
 if (contentType != null) {
 xhr.responseType = contentType.getValue();
 }
 updateReadyState(cx, xhr, DONE);
 } catch (IOException e) {
 log.error(e.getMessage(), e);
 throw new ScriptException(e);
 } finally {
 xhr.method.releaseConnection();
 }
 }

 XMLHttpRequestHostObject.java

 [1] - https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks and regards


 *Tharindu Dharmarathna*Associate Software Engineer
 WSO2 Inc.; http://wso2.com
 lean.enterprise.middleware

 mobile: *+94779109091 %2B94779109091*




 --

 *Ruchira Wageesha**Associate Technical Lead*
 *WSO2 Inc. - lean . enterprise . middleware |  wso2.com
 http://wso2.com*

 *email: ruch...@wso2.com ruch...@wso2.com,   blog:
 

Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-19 Thread Rasika Perera
[Please ignore my previous reply, it was incomplete]

Hi Tharindu,

According to chat we had, IMO if your intention is to avoid error messages
from XMLHttpRequestHostObject.java rather than patching XHR, you can
add following to your log4j property file.

log4j.logger.your package = DEBUG|INFO|OFF|WARN...

log4j.logger.org.jaggeryjs.hostobjects.xhr.XMLHttpRequestHostObject = FATAL

Or...

log4j.logger.org.jaggeryjs.hostobjects.xhr= FATAL

Note that i used log level FATAL over completely turn off logging using
OFF.

Thank you

On Fri, Mar 20, 2015 at 10:27 AM, Rasika Perera rasi...@wso2.com wrote:

 Hi Tharindu,

 According to chat we had, IMO if your intention is to avoid error messages
 from XMLHttpRequestHostObject.java rather than patching XHR, you can
 add following to your log4j property file.

 log4j.logger.your package = DEBUG|INFO|OFF|WARN...

 log4j.logger.org.jaggeryjs.hostobjects.xhr.XMLHttpRequestHostObject = FATAL

 or


 Note that i used log level FATAL over completely turn off logging using
 OFF.

 Thank you


 On Thu, Mar 19, 2015 at 6:00 PM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 Following are the possible options that I can think.

 1. Patching XHR to get rid of the log message
 2. Hiding the error from log4j, but AFAIK, then it will not log any error
 from XHR
 3. Using any Java's http-client directly from Jaggery[a] to do the HTTP
 calls instead of XHR
 4. Using any Java's http-client to check the endpoint status, and
 continue original HTTP call with XHR

 [a]
 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Scripting_Java

 /Ruchira

 On Thu, Mar 19, 2015 at 5:18 PM, Lakmali Baminiwatta lakm...@wso2.com
 wrote:

 Hi Ruchira,

 In APIM and APPM we talk to the BPS server and fetch Human Tasks
 available. For that when the user is login to the admin-dashboard jaggery
 app, we do a login call to BPS server using XMLHttpRequest. At this point,
 if the BPS is not running we are getting this connection refused error in
 the logs. We need to handle this.

 As Tharindu mentioned, XMLHttpRequestHostObject.java uses 
 log.error(e.getMessage(),
 e); [1]. Therefore we can't get rid of this stack trace in the log by
 just catching the exception.

 Is there any method in jaggery that we can use to check whether server
 is up and running before doing the send call and handle this? Appreciate
 any help on this.

 [1]
 https://github.com/wso2/jaggery/blob/0.9.0.ALPHA4.wso2v4/components/hostobjects/org.jaggeryjs.hostobjects.xhr/src/main/java/org/jaggeryjs/hostobjects/xhr/XMLHttpRequestHostObject.java
 [2]https://wso2.org/jira/browse/APPM-587
 [3]https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks,
 Lakmali

 On 18 March 2015 at 08:57, Tharindu Dharmarathna tharin...@wso2.com
 wrote:

 Hi Ruchira,

 We want to carch the exception according to connection refused
 exception from the jaggery side . Due to logging of this  exception from
 Hostobject We couldn't remove this exception come from the console.

 Is there any way of check a server is up and running from jaggery side
 . If there's a way we can avoid exception come from the console.

 Thanks
 Tharindu

 On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha ruch...@wso2.com
 wrote:

 What is the issue with going try/catch blocks?

 /Ruchira

 On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna 
 tharin...@wso2.com wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


 Exception come from the following jaggery hostobject code

 private static void executeRequest(Context cx,
 XMLHttpRequestHostObject xhr) throws ScriptException {
 try {
 xhr.httpClient.executeMethod(xhr.method);
 xhr.statusLine = xhr.method.getStatusLine();
 xhr.responseHeaders = xhr.method.getResponseHeaders();
 updateReadyState(cx, xhr, HEADERS_RECEIVED);
 byte[] response = xhr.method.getResponseBody();
 if (response.length  0) {
 xhr.responseText = new String(response);
 }
 Header contentType = xhr.method.getResponseHeader(Content-Type);
 if (contentType != null) {
 xhr.responseType = contentType.getValue();
 }
 

Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-17 Thread Tharindu Dharmarathna
Hi Ruchira,

We want to carch the exception according to connection refused exception
from the jaggery side . Due to logging of this  exception from Hostobject
We couldn't remove this exception come from the console.

Is there any way of check a server is up and running from jaggery side . If
there's a way we can avoid exception come from the console.

Thanks
Tharindu

On Wed, Mar 18, 2015 at 2:06 AM, Ruchira Wageesha ruch...@wso2.com wrote:

 What is the issue with going try/catch blocks?

 /Ruchira

 On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna tharin...@wso2.com
  wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


 Exception come from the following jaggery hostobject code

 private static void executeRequest(Context cx, XMLHttpRequestHostObject
 xhr) throws ScriptException {
 try {
 xhr.httpClient.executeMethod(xhr.method);
 xhr.statusLine = xhr.method.getStatusLine();
 xhr.responseHeaders = xhr.method.getResponseHeaders();
 updateReadyState(cx, xhr, HEADERS_RECEIVED);
 byte[] response = xhr.method.getResponseBody();
 if (response.length  0) {
 xhr.responseText = new String(response);
 }
 Header contentType = xhr.method.getResponseHeader(Content-Type);
 if (contentType != null) {
 xhr.responseType = contentType.getValue();
 }
 updateReadyState(cx, xhr, DONE);
 } catch (IOException e) {
 log.error(e.getMessage(), e);
 throw new ScriptException(e);
 } finally {
 xhr.method.releaseConnection();
 }
 }

 XMLHttpRequestHostObject.java

 [1] - https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks and regards


 *Tharindu Dharmarathna*Associate Software Engineer
 WSO2 Inc.; http://wso2.com
 lean.enterprise.middleware

 mobile: *+94779109091 %2B94779109091*




 --

 *Ruchira Wageesha**Associate Technical Lead*
 *WSO2 Inc. - lean . enterprise . middleware |  wso2.com http://wso2.com*

 *email: ruch...@wso2.com ruch...@wso2.com,   blog:
 ruchirawageesha.blogspot.com http://ruchirawageesha.blogspot.com,
 mobile: +94 77 5493444 %2B94%2077%205493444*




-- 

*Tharindu Dharmarathna*Associate Software Engineer
WSO2 Inc.; http://wso2.com
lean.enterprise.middleware

mobile: *+94779109091*
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-17 Thread Ruchira Wageesha
What is the issue with going try/catch blocks?

/Ruchira

On Tue, Mar 17, 2015 at 5:56 PM, Tharindu Dharmarathna tharin...@wso2.com
wrote:

 Hi all,

 According to public jira [1]  how can we handle connection refused
 exception come from this issue . This come from the send method.

 code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


 Exception come from the following jaggery hostobject code

 private static void executeRequest(Context cx, XMLHttpRequestHostObject
 xhr) throws ScriptException {
 try {
 xhr.httpClient.executeMethod(xhr.method);
 xhr.statusLine = xhr.method.getStatusLine();
 xhr.responseHeaders = xhr.method.getResponseHeaders();
 updateReadyState(cx, xhr, HEADERS_RECEIVED);
 byte[] response = xhr.method.getResponseBody();
 if (response.length  0) {
 xhr.responseText = new String(response);
 }
 Header contentType = xhr.method.getResponseHeader(Content-Type);
 if (contentType != null) {
 xhr.responseType = contentType.getValue();
 }
 updateReadyState(cx, xhr, DONE);
 } catch (IOException e) {
 log.error(e.getMessage(), e);
 throw new ScriptException(e);
 } finally {
 xhr.method.releaseConnection();
 }
 }

 XMLHttpRequestHostObject.java

 [1] - https://wso2.org/jira/browse/APIMANAGER-3139

 Thanks and regards


 *Tharindu Dharmarathna*Associate Software Engineer
 WSO2 Inc.; http://wso2.com
 lean.enterprise.middleware

 mobile: *+94779109091 %2B94779109091*




-- 

*Ruchira Wageesha**Associate Technical Lead*
*WSO2 Inc. - lean . enterprise . middleware |  wso2.com http://wso2.com*

*email: ruch...@wso2.com ruch...@wso2.com,   blog:
ruchirawageesha.blogspot.com http://ruchirawageesha.blogspot.com,
mobile: +94 77 5493444*
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] [DEV][Jaggery] how to handle exception come from XMLHttpRequestHostObject

2015-03-17 Thread Tharindu Dharmarathna
Hi all,

According to public jira [1]  how can we handle connection refused
exception come from this issue . This come from the send method.

code snippest for this issue


 try{
 var xhr = new XMLHttpRequest();
 var site = require(/site/conf/site.json);
 var endpoint =
 site.workflows.applicationWorkFlowServerURL+AuthenticationAdmin;
 xhr.open(POST, endpoint);
 var payload = 'soap:Envelope xmlns:soap=
 http://www.w3.org/2003/05/soap-envelope; xmlns:aut=
 http://authentication.services.core.carbon.wso2.org;soap:Header/soap:Bodyaut:loginaut:username'
 + username + '/aut:usernameaut:password' + password +
 '/aut:passwordaut:remoteAddresslocalhost/aut:remoteAddress/aut:login/soap:Body/soap:Envelope';
 xhr.send(payload);
 var cookie = (xhr.getAllResponseHeaders());
 log.info(xhr.readyState);
 //session.put(workflowCookie,cookie.split(;)[0].split(:)[1]);
 var sessionCookie = xhr.getResponseHeader(Set-Cookie);
 session.put(workflowCookie,sessionCookie);
 }catch (e) {
 // log.error(e.message);
 }


Exception come from the following jaggery hostobject code

private static void executeRequest(Context cx, XMLHttpRequestHostObject
 xhr) throws ScriptException {
 try {
 xhr.httpClient.executeMethod(xhr.method);
 xhr.statusLine = xhr.method.getStatusLine();
 xhr.responseHeaders = xhr.method.getResponseHeaders();
 updateReadyState(cx, xhr, HEADERS_RECEIVED);
 byte[] response = xhr.method.getResponseBody();
 if (response.length  0) {
 xhr.responseText = new String(response);
 }
 Header contentType = xhr.method.getResponseHeader(Content-Type);
 if (contentType != null) {
 xhr.responseType = contentType.getValue();
 }
 updateReadyState(cx, xhr, DONE);
 } catch (IOException e) {
 log.error(e.getMessage(), e);
 throw new ScriptException(e);
 } finally {
 xhr.method.releaseConnection();
 }
 }

XMLHttpRequestHostObject.java

[1] - https://wso2.org/jira/browse/APIMANAGER-3139

Thanks and regards


*Tharindu Dharmarathna*Associate Software Engineer
WSO2 Inc.; http://wso2.com
lean.enterprise.middleware

mobile: *+94779109091*
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV][Jaggery] Calling a Java method asynchronously from Jaggery

2014-09-17 Thread Inosh Perera
Thank you, I will look into these.

regards,
Inosh

On Wed, Sep 17, 2014 at 10:23 AM, Manuranga Perera m...@wso2.com wrote:

 setTimeout(function(){
 Packages.org.my.ClassName.method();
 },1);

 this will call it in a new thread.

 On Wed, Sep 17, 2014 at 9:57 AM, Kasun Dissanayake kas...@wso2.com
 wrote:

 Hi Inosh,

 AFAIY there is no way to do that. But you can easily use AJAX methods.
 Just follow these demos [1].

 [1] http://jaggeryjs.org/samples.jag

 Cheers

 On Wed, Sep 17, 2014 at 9:43 AM, Inosh Perera ino...@wso2.com wrote:

 Hi all,
 I need to call java method inside Jaggery. But this has to be done in an
 asynchronous way. Is there a way to do this in Jaggery? Is there a way to
 deal with threads in Jaggery?

 Regards,
 Inosh

 --
 Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Kasun Dissanayake
 Software Engineer
 WSO2 Inc.
 Lean | Enterprise | Middleware
 Tel - +94 77 086 2860
 Skype - kasun.dissanayake4
 LinkedIn - lk.linkedin.com/in/kasundis/




 --
 With regards,
 *Manu*ranga Perera.

 phone : 071 7 70 20 50
 mail : m...@wso2.com




-- 
Inosh Perera
Software Engineer, WSO2 Inc.
Tel: 0785293686
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] [DEV][Jaggery] Calling a Java method asynchronously from Jaggery

2014-09-16 Thread Inosh Perera
Hi all,
I need to call java method inside Jaggery. But this has to be done in an
asynchronous way. Is there a way to do this in Jaggery? Is there a way to
deal with threads in Jaggery?

Regards,
Inosh

-- 
Inosh Perera
Software Engineer, WSO2 Inc.
Tel: 0785293686
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV][Jaggery] Calling a Java method asynchronously from Jaggery

2014-09-16 Thread Kasun Dissanayake
Hi Inosh,

AFAIY there is no way to do that. But you can easily use AJAX methods. Just
follow these demos [1].

[1] http://jaggeryjs.org/samples.jag

Cheers

On Wed, Sep 17, 2014 at 9:43 AM, Inosh Perera ino...@wso2.com wrote:

 Hi all,
 I need to call java method inside Jaggery. But this has to be done in an
 asynchronous way. Is there a way to do this in Jaggery? Is there a way to
 deal with threads in Jaggery?

 Regards,
 Inosh

 --
 Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
Kasun Dissanayake
Software Engineer
WSO2 Inc.
Lean | Enterprise | Middleware
Tel - +94 77 086 2860
Skype - kasun.dissanayake4
LinkedIn - lk.linkedin.com/in/kasundis/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV][Jaggery] Calling a Java method asynchronously from Jaggery

2014-09-16 Thread Manuranga Perera
setTimeout(function(){
Packages.org.my.ClassName.method();
},1);

this will call it in a new thread.

On Wed, Sep 17, 2014 at 9:57 AM, Kasun Dissanayake kas...@wso2.com wrote:

 Hi Inosh,

 AFAIY there is no way to do that. But you can easily use AJAX methods.
 Just follow these demos [1].

 [1] http://jaggeryjs.org/samples.jag

 Cheers

 On Wed, Sep 17, 2014 at 9:43 AM, Inosh Perera ino...@wso2.com wrote:

 Hi all,
 I need to call java method inside Jaggery. But this has to be done in an
 asynchronous way. Is there a way to do this in Jaggery? Is there a way to
 deal with threads in Jaggery?

 Regards,
 Inosh

 --
 Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Kasun Dissanayake
 Software Engineer
 WSO2 Inc.
 Lean | Enterprise | Middleware
 Tel - +94 77 086 2860
 Skype - kasun.dissanayake4
 LinkedIn - lk.linkedin.com/in/kasundis/




-- 
With regards,
*Manu*ranga Perera.

phone : 071 7 70 20 50
mail : m...@wso2.com
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [dev][jaggery]

2014-01-17 Thread Madhuka Udantha
Hi

Issue was fixed, jaggery app code was updated after investigating BE ws.
JAggery code app code fixing was referring  WSRequest[1],
open ( object options | String httpMethod, String url [, Boolean async [,
String username [, String password]]])


[1] http://jaggeryjs.org/apidocs/ws.jag


On Mon, Jan 13, 2014 at 5:06 PM, Iroshan Wickramarathna iros...@wso2.comwrote:

 Hi Madhuka,

 Here is the full error trace,

 [2014-01-13 16:58:14,769] ERROR
 {org.jaggeryjs.hostobjects.ws.WSRequestHostObject} -  Error occured while
 invoking the service
 org.apache.axis2.AxisFault: The input stream for an incoming message is
 null.
 at
 org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:93)
  at
 org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:68)
 at
 org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:348)
  at
 org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:445)
 at
 org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
  at
 org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
 at
 org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:554)
  at
 org.jaggeryjs.hostobjects.ws.WSRequestHostObject.jsFunction_send(WSRequestHostObject.java:362)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
 at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
  at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386)
 at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
  at
 org.jaggeryjs.rhino.WSjaggeryTest.c1._c_invokeinsertDrink_1(/WSjaggeryTest//WSjaggeryTest.jag:21)
 at
 org.jaggeryjs.rhino.WSjaggeryTest.c1.call(/WSjaggeryTest//WSjaggeryTest.jag)
  at
 org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:74)
 at
 org.jaggeryjs.rhino.WSjaggeryTest.c1._c_script_0(/WSjaggeryTest//WSjaggeryTest.jag:30)
  at
 org.jaggeryjs.rhino.WSjaggeryTest.c1.call(/WSjaggeryTest//WSjaggeryTest.jag)
 at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
  at
 org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
 at
 org.jaggeryjs.rhino.WSjaggeryTest.c1.call(/WSjaggeryTest//WSjaggeryTest.jag)
  at
 org.jaggeryjs.rhino.WSjaggeryTest.c1.exec(/WSjaggeryTest//WSjaggeryTest.jag)
 at
 org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:570)
  at
 org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)
 at
 org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:432)
  at
 org.jaggeryjs.jaggery.core.JaggeryServlet.doGet(JaggeryServlet.java:24)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
  at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at
 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
  at
 org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
 at
 org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
  at
 org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
 at org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21)
  at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at
 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
 at
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
  at
 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
 at
 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
  at
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
 at
 org.wso2.carbon.statistics.webapp.RequestIntercepterValve.invoke(RequestIntercepterValve.java:43)
  at
 org.wso2.carbon.bam.webapp.stat.publisher.WebAppStatisticPublisherValve.invoke(WebAppStatisticPublisherValve.java:104)
 at
 org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:178)
  at
 org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
 at
 org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:56)
  at
 org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
 at
 

Re: [Dev] [dev][jaggery]

2014-01-13 Thread Madhuka Udantha
Hi Iroshan,

Can you give full error trace (/log)?
Here[1,2] are references for WSRequest

[1]
http://madhukaudantha.blogspot.com/2013/02/invoke-web-service-with-jaggery-with.html
[2] http://jaggeryjs.org/apidocs/ws.jag


On Thu, Jan 9, 2014 at 11:15 AM, Iroshan Wickramarathna iros...@wso2.comwrote:

 Hi all,

 I'm trying to invoke a data service using a simple jaggery app. When I
 invoke a operation which doesn't give any result. it gives an error.

 Ex. trying to invoke a insert drink operation

   function invokeinsertDrink() {
 var log = new Log();
 var ws = require(ws);

  var CSDS = new ws.WSRequest();
  var options = new Array();
  options.useSOAP = 1.2;
  options.action = urn:insert_drink_operation;
  var payload =' p:insert_drink_operation xmlns:p=
 http://ws.wso2.org/dataservice;xs:id xmlns:xs=
 http://ws.wso2.org/dataservice;3/xs:idxs:name xmlns:xs=
 http://ws.wso2.org/dataservice;cococola/xs:name xs:cost xmlns:xs=
 http://ws.wso2.org/dataservice;50/xs:cost/p:insert_drink_operation';

 var result;

  try {
  CSDS.open(options,
 https://10.100.4.53:9443/services/CofeeShopService/;, false);
  CSDS.send(payload);
  result = CSDS;
  } catch (e) {
  log.error(e.toString());
  return e.toString();
 }
  return result.responseText;

 }
 print(invokeinsertDrink());


 }



 Even though data has been added to the data base properly it gives
 following error.

  JavaException: org.jaggeryjs.scriptengine.exceptions.ScriptException:
 Error occured while invoking the service

 how can I handle this error?

 --
 Thanx.
 Ujitha Iroshan



 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
*Madhuka* Udantha
Senior Software Engineer
Development Technologies
WSO2 Inc. : http://wso2.com

*Mobile*: +94774066336
*Blog*: http://madhukaudantha.blogspot.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [dev][jaggery]

2014-01-13 Thread Iroshan Wickramarathna
Hi Madhuka,

Here is the full error trace,

[2014-01-13 16:58:14,769] ERROR
{org.jaggeryjs.hostobjects.ws.WSRequestHostObject} -  Error occured while
invoking the service
org.apache.axis2.AxisFault: The input stream for an incoming message is
null.
at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:93)
at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:68)
at
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:348)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:445)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:554)
at
org.jaggeryjs.hostobjects.ws.WSRequestHostObject.jsFunction_send(WSRequestHostObject.java:362)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
at
org.jaggeryjs.rhino.WSjaggeryTest.c1._c_invokeinsertDrink_1(/WSjaggeryTest//WSjaggeryTest.jag:21)
at
org.jaggeryjs.rhino.WSjaggeryTest.c1.call(/WSjaggeryTest//WSjaggeryTest.jag)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:74)
at
org.jaggeryjs.rhino.WSjaggeryTest.c1._c_script_0(/WSjaggeryTest//WSjaggeryTest.jag:30)
at
org.jaggeryjs.rhino.WSjaggeryTest.c1.call(/WSjaggeryTest//WSjaggeryTest.jag)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
at
org.jaggeryjs.rhino.WSjaggeryTest.c1.call(/WSjaggeryTest//WSjaggeryTest.jag)
at
org.jaggeryjs.rhino.WSjaggeryTest.c1.exec(/WSjaggeryTest//WSjaggeryTest.jag)
at
org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:570)
at org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)
at
org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:432)
at org.jaggeryjs.jaggery.core.JaggeryServlet.doGet(JaggeryServlet.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at
org.wso2.carbon.statistics.webapp.RequestIntercepterValve.invoke(RequestIntercepterValve.java:43)
at
org.wso2.carbon.bam.webapp.stat.publisher.WebAppStatisticPublisherValve.invoke(WebAppStatisticPublisherValve.java:104)
at
org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:178)
at
org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
at
org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:56)
at
org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
at
org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:141)
at
org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at
org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at

[Dev] [dev][jaggery]

2014-01-08 Thread Iroshan Wickramarathna
Hi all,

I'm trying to invoke a data service using a simple jaggery app. When I
invoke a operation which doesn't give any result. it gives an error.

Ex. trying to invoke a insert drink operation

  function invokeinsertDrink() {
var log = new Log();
var ws = require(ws);

 var CSDS = new ws.WSRequest();
 var options = new Array();
 options.useSOAP = 1.2;
 options.action = urn:insert_drink_operation;
 var payload =' p:insert_drink_operation xmlns:p=
http://ws.wso2.org/dataservice;xs:id xmlns:xs=
http://ws.wso2.org/dataservice;3/xs:idxs:name xmlns:xs=
http://ws.wso2.org/dataservice;cococola/xs:name xs:cost xmlns:xs=
http://ws.wso2.org/dataservice;50/xs:cost/p:insert_drink_operation';

var result;

 try {
 CSDS.open(options,
https://10.100.4.53:9443/services/CofeeShopService/;, false);
 CSDS.send(payload);
 result = CSDS;
 } catch (e) {
 log.error(e.toString());
 return e.toString();
}
 return result.responseText;

}
print(invokeinsertDrink());


}



Even though data has been added to the data base properly it gives
following error.

 JavaException: org.jaggeryjs.scriptengine.exceptions.ScriptException:
Error occured while invoking the service

how can I handle this error?

-- 
Thanx.
Ujitha Iroshan
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] [XACML with jaggery]

2013-07-10 Thread Nuwan Bandara
Hi Gayan,

XACML engine is a policy evaluation module. You dont need a special type of
binding for that. What you can do is, forward the attributes you want to
evaluate against a XACML policy to the XACML engine via a REST call or a WS
call.

for instance, WSO2 IS can be the XACML PDP, where your jaggery application
will be the PEP. so you can call IS via WS/REST with the attributes and get
the result which is given by the IS as the response.

Regards,
/Nuwan


On Wed, Jul 10, 2013 at 12:07 PM, Gayan Gunawardana ga...@wso2.com wrote:

 Hi,

 For MDM we have a requirement to bind with XACML engine inside a jaggery
 application.

 org.wso2_.carbon.identity.entitlement.filter_0.zip available in
 application server but jaggery does not support custom filters.

 Is it allow to add custom filters to jaggery-core or is there any other
 option.


 --
 Gayan Gunawardana
 Software Engineer; WSO2mobile Inc.; http://wso2mobile.com/
 Email: ga...@wso2.com
 Mobile: +94 (71) 8020933
 Blog: http://gayanj2ee.blogspot.com/

 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




-- 
*Thanks  Regards,

Nuwan Bandara
Technical Lead; **WSO2 Inc. *
*lean . enterprise . middleware |  http://wso2.com *
*blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763 9629
*
http://www.nuwanbando.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] [XACML with jaggery]

2013-07-10 Thread Gayan Gunawardana
Hi Nuwan,

Yes, WSO2 IS is the PDP but it's more easy to invoke Entitlement Service
through EntitlementFilter than direct WS/REST calls.


On Wed, Jul 10, 2013 at 12:14 PM, Nuwan Bandara nu...@wso2.com wrote:

 Hi Gayan,

 XACML engine is a policy evaluation module. You dont need a special type
 of binding for that. What you can do is, forward the attributes you want to
 evaluate against a XACML policy to the XACML engine via a REST call or a WS
 call.

 for instance, WSO2 IS can be the XACML PDP, where your jaggery application
 will be the PEP. so you can call IS via WS/REST with the attributes and get
 the result which is given by the IS as the response.

 Regards,
 /Nuwan


 On Wed, Jul 10, 2013 at 12:07 PM, Gayan Gunawardana ga...@wso2.comwrote:

 Hi,

 For MDM we have a requirement to bind with XACML engine inside a jaggery
 application.

 org.wso2_.carbon.identity.entitlement.filter_0.zip available in
 application server but jaggery does not support custom filters.

 Is it allow to add custom filters to jaggery-core or is there any other
 option.


 --
 Gayan Gunawardana
 Software Engineer; WSO2mobile Inc.; http://wso2mobile.com/
 Email: ga...@wso2.com
 Mobile: +94 (71) 8020933
 Blog: http://gayanj2ee.blogspot.com/

 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




 --
 *Thanks  Regards,

 Nuwan Bandara
 Technical Lead; **WSO2 Inc. *
 *lean . enterprise . middleware |  http://wso2.com *
 *blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763
 9629
 *
 http://www.nuwanbando.com/




-- 
Gayan Gunawardana
Software Engineer; WSO2mobile Inc.; http://wso2mobile.com/
Email: ga...@wso2.com
Mobile: +94 (71) 8020933
Blog: http://gayanj2ee.blogspot.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] [XACML with jaggery]

2013-07-10 Thread Nuwan Bandara
On Wed, Jul 10, 2013 at 12:33 PM, Gayan Gunawardana ga...@wso2.com wrote:

 Hi Nuwan,

 Yes, WSO2 IS is the PDP but it's more easy to invoke Entitlement Service
 through EntitlementFilter than direct WS/REST calls.


There are no filters in jaggery world, what you can do is, route all
requests through one controller which will act as your filter

Regards,
/Nuwan




 On Wed, Jul 10, 2013 at 12:14 PM, Nuwan Bandara nu...@wso2.com wrote:

 Hi Gayan,

 XACML engine is a policy evaluation module. You dont need a special type
 of binding for that. What you can do is, forward the attributes you want to
 evaluate against a XACML policy to the XACML engine via a REST call or a WS
 call.

 for instance, WSO2 IS can be the XACML PDP, where your jaggery
 application will be the PEP. so you can call IS via WS/REST with the
 attributes and get the result which is given by the IS as the response.

 Regards,
 /Nuwan


 On Wed, Jul 10, 2013 at 12:07 PM, Gayan Gunawardana ga...@wso2.comwrote:

 Hi,

 For MDM we have a requirement to bind with XACML engine inside a jaggery
 application.

 org.wso2_.carbon.identity.entitlement.filter_0.zip available in
 application server but jaggery does not support custom filters.

 Is it allow to add custom filters to jaggery-core or is there any other
 option.


 --
 Gayan Gunawardana
 Software Engineer; WSO2mobile Inc.; http://wso2mobile.com/
 Email: ga...@wso2.com
 Mobile: +94 (71) 8020933
 Blog: http://gayanj2ee.blogspot.com/

 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




 --
 *Thanks  Regards,

 Nuwan Bandara
 Technical Lead; **WSO2 Inc. *
 *lean . enterprise . middleware |  http://wso2.com *
 *blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763
 9629
 *
 http://www.nuwanbando.com/




 --
 Gayan Gunawardana
 Software Engineer; WSO2mobile Inc.; http://wso2mobile.com/
 Email: ga...@wso2.com
 Mobile: +94 (71) 8020933
 Blog: http://gayanj2ee.blogspot.com/




-- 
*Thanks  Regards,

Nuwan Bandara
Technical Lead; **WSO2 Inc. *
*lean . enterprise . middleware |  http://wso2.com *
*blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763 9629
*
http://www.nuwanbando.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] How to insert data to db without sql injection from Jaggery?

2013-06-04 Thread Nuwan Bandara
We do prepareStatement() inside the DB module [1]

[1]
https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.db/src/main/java/org/jaggeryjs/hostobjects/db/DatabaseHostObject.java


On Tue, Jun 4, 2013 at 2:25 PM, Dilshan Edirisuriya dils...@wso2.comwrote:

 Hi,

 How do we do subject? Could not find that in the Jaggery documentation at
 [1]. FYI I need a similar implementation as prepared statement.

 [1] - http://jaggeryjs.org/apidocs/rdb.jag

 Regards,

 Dilshan


 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




-- 
*Thanks  Regards,

Nuwan Bandara
Technical Lead  Member, MC, Development Technologies
WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763 9629
*
http://www.nuwanbando.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] How to insert data to db without sql injection from Jaggery?

2013-06-04 Thread Dilshan Edirisuriya
Thanks Nuwan. Based on the code it seems we have to pass them as arguments
to query. How to do the mapping? Can we use a place holder like ?


On Tue, Jun 4, 2013 at 7:34 PM, Nuwan Bandara nu...@wso2.com wrote:

 We do prepareStatement() inside the DB module [1]

 [1]
 https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.db/src/main/java/org/jaggeryjs/hostobjects/db/DatabaseHostObject.java


 On Tue, Jun 4, 2013 at 2:25 PM, Dilshan Edirisuriya dils...@wso2.comwrote:

 Hi,

 How do we do subject? Could not find that in the Jaggery documentation at
 [1]. FYI I need a similar implementation as prepared statement.

 [1] - http://jaggeryjs.org/apidocs/rdb.jag

 Regards,

 Dilshan


 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




 --
 *Thanks  Regards,

 Nuwan Bandara
 Technical Lead  Member, MC, Development Technologies
 WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
 blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763
 9629
 *
 http://www.nuwanbando.com/

___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] How to insert data to db without sql injection from Jaggery?

2013-06-04 Thread Nuwan Bandara
Yes, haven't you tried that already ?

 var result = db.query(SELECT * FROM demo where name=?, 'WSO2');


On Tue, Jun 4, 2013 at 4:10 PM, Dilshan Edirisuriya dils...@wso2.comwrote:

 Thanks Nuwan. Based on the code it seems we have to pass them as arguments
 to query. How to do the mapping? Can we use a place holder like ?


 On Tue, Jun 4, 2013 at 7:34 PM, Nuwan Bandara nu...@wso2.com wrote:

 We do prepareStatement() inside the DB module [1]

 [1]
 https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.db/src/main/java/org/jaggeryjs/hostobjects/db/DatabaseHostObject.java


 On Tue, Jun 4, 2013 at 2:25 PM, Dilshan Edirisuriya dils...@wso2.comwrote:

 Hi,

 How do we do subject? Could not find that in the Jaggery documentation
 at [1]. FYI I need a similar implementation as prepared statement.

 [1] - http://jaggeryjs.org/apidocs/rdb.jag

 Regards,

 Dilshan


 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




 --
 *Thanks  Regards,

 Nuwan Bandara
 Technical Lead  Member, MC, Development Technologies
 WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
 blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763
 9629
 *
 http://www.nuwanbando.com/





-- 
*Thanks  Regards,

Nuwan Bandara
Technical Lead  Member, MC, Development Technologies
WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763 9629
*
http://www.nuwanbando.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] How to insert data to db without sql injection from Jaggery?

2013-06-04 Thread Dilshan Edirisuriya
Thanks Nuwan.


On Tue, Jun 4, 2013 at 7:45 PM, Nuwan Bandara nu...@wso2.com wrote:

 Yes, haven't you tried that already ?

  var result = db.query(SELECT * FROM demo where name=?, 'WSO2');


 On Tue, Jun 4, 2013 at 4:10 PM, Dilshan Edirisuriya dils...@wso2.comwrote:

 Thanks Nuwan. Based on the code it seems we have to pass them as
 arguments to query. How to do the mapping? Can we use a place holder like
 ?


 On Tue, Jun 4, 2013 at 7:34 PM, Nuwan Bandara nu...@wso2.com wrote:

 We do prepareStatement() inside the DB module [1]

 [1]
 https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.db/src/main/java/org/jaggeryjs/hostobjects/db/DatabaseHostObject.java


 On Tue, Jun 4, 2013 at 2:25 PM, Dilshan Edirisuriya dils...@wso2.comwrote:

 Hi,

 How do we do subject? Could not find that in the Jaggery documentation
 at [1]. FYI I need a similar implementation as prepared statement.

 [1] - http://jaggeryjs.org/apidocs/rdb.jag

 Regards,

 Dilshan


 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




 --
 *Thanks  Regards,

 Nuwan Bandara
 Technical Lead  Member, MC, Development Technologies
 WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
 blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763
 9629
 *
 http://www.nuwanbando.com/





 --
 *Thanks  Regards,

 Nuwan Bandara
 Technical Lead  Member, MC, Development Technologies
 WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
 blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763
 9629
 *
 http://www.nuwanbando.com/

___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] MongoDB support for Jaggery?

2013-03-21 Thread Ruchira Wageesha
Yes, MongoDB and CouchDB are the natural choices for Jaggery. At the
moment, we don't have any direct support for them, but we can easily wrap
their native Java/JavaScript drivers and provide a nice and simple Jaggery
module.

BTW, if you wish to contribute to Jaggery, then this would be a cool module
as a start up. :)


On Thu, Mar 21, 2013 at 4:38 PM, Afkham Azeez az...@wso2.com wrote:

 Folks,
 What are the plan for supporting NoSQL data stores in Jaggery? Have you
 considered supporting MongoDB? Its native JSON based interaction APIs
 should be a natural fir for Jaggery.

 --
 *Afkham Azeez*
 Director of Architecture; WSO2, Inc.; http://wso2.com
 Member; Apache Software Foundation; http://www.apache.org/
 * http://www.apache.org/**
 email: **az...@wso2.com* az...@wso2.com* cell: +94 77 3320919
 blog: **http://blog.afkham.org* http://blog.afkham.org*
 twitter: **http://twitter.com/afkham_azeez*http://twitter.com/afkham_azeez
 *
 linked-in: **http://lk.linkedin.com/in/afkhamazeez*
 *
 *
 *Lean . Enterprise . Middleware*

 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




-- 
*Ruchira Wageesha
Senior Software Engineer  Member, Management Committee, Development
Technologies*
*WSO2 Inc. - lean . enterprise . middleware |  wso2.com*
*
email: ruch...@wso2.com,   blog: ruchirawageesha.blogspot.com,   mobile:
+94 77 5493444*
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] IntelliJ Idea plugin for Jaggery

2012-11-13 Thread Janaka Ranabahu
Hi Ishara,

Nice work.

I have a little concern. I installed the plugin from idea repository and
noticed that there were some logs printed on the console. It seems like the
whole jaggery file has been printed in the console. Please note that there
were several logs such as the following.

JAGGERY_TAG_STARTED-OUTERBRACKETS%=
JAGGERY_TAG_CLOSSING-JAVASCRIPT_TEXTapiData.name
YYINITIAL-OUTERBRACKETS%
Content length :4
Last character :
BRACE_STARTED-HTML_TEXT','
JAGGERY_TAG_STARTED-OUTERBRACKETS%=
JAGGERY_TAG_CLOSSING-JAVASCRIPT_TEXTapiData.version
YYINITIAL-OUTERBRACKETS%
Content length :4
Last character :
BRACE_STARTED-HTML_TEXT','
JAGGERY_TAG_STARTED-OUTERBRACKETS%=
JAGGERY_TAG_CLOSSING-JAVASCRIPT_TEXTapiData.provider
YYINITIAL-OUTERBRACKETS%
Content length :696
Last character :
BRACE_STARTED-HTML_TEXT')


Thanks,
Janaka




On Sun, Nov 11, 2012 at 7:57 PM, Pradeep Fernando prad...@wso2.com wrote:

 nice work!
 just for my info : why cant we use it with community edition of Jidea. ?


 --Pradeep

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
Janaka Ranabahu
Senior Software Engineer
WSO2 Inc.

Mobile +94 718370861
Email : jan...@wso2.com
Blog : janakaranabahu.blogspot.com
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] Push notification to the client browser

2012-07-23 Thread Nuwan Bandara
+1, Dilshan, if time permits can you digg into this. We added tomcat .27
also because of WS support, if we can figure out away to get this to
jaggery that would be great.

Regards,
/Nuwan

On Mon, Jul 23, 2012 at 3:42 PM, Dilshan Edirisuriya dils...@wso2.comwrote:

 Hi,

 Is there any chance that we can get the above feature integrated to the
 Jaggery? This will be essential when displaying real time event happening
 in the backend components (like a build etc). I believe this should be
 accomplished by using web sockets. But with the lack of support to some of
 the browser versions we may have to implement comet or long polling as well
 in the server additional to this behavior.

 For the moment we will deal with the pulling mechanism every X time
 interval but would like to have the above feature in place for Jaggery.


 Regards,

 Dilshan

 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




-- 
*Thanks  Regards,

Nuwan Bandara
Associate Technical Lead  Member, MC, Development Technologies
WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763 9629
*
http://www.nuwanbando.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] Push notification to the client browser

2012-07-23 Thread Dilshan Edirisuriya
Sure will do.

On Mon, Jul 23, 2012 at 3:53 PM, Nuwan Bandara nu...@wso2.com wrote:

 +1, Dilshan, if time permits can you digg into this. We added tomcat .27
 also because of WS support, if we can figure out away to get this to
 jaggery that would be great.

 Regards,
 /Nuwan

 On Mon, Jul 23, 2012 at 3:42 PM, Dilshan Edirisuriya dils...@wso2.comwrote:

 Hi,

 Is there any chance that we can get the above feature integrated to the
 Jaggery? This will be essential when displaying real time event happening
 in the backend components (like a build etc). I believe this should be
 accomplished by using web sockets. But with the lack of support to some of
 the browser versions we may have to implement comet or long polling as well
 in the server additional to this behavior.

 For the moment we will deal with the pulling mechanism every X time
 interval but would like to have the above feature in place for Jaggery.


 Regards,

 Dilshan

 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




 --
 *Thanks  Regards,

 Nuwan Bandara
 Associate Technical Lead  Member, MC, Development Technologies
 WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
 blog : http://nuwanbando.com; email: nu...@wso2.com; phone: +94 11 763
 9629
 *
 http://www.nuwanbando.com/

___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Dev-Jaggery] JavaScript Caching in Jaggery

2012-06-22 Thread Sanjiva Weerawarana
I can't see the advantages of option 2 ... we have to assume every bit of
JS is different so its not about sharing a .class. If we can have a lazy
loading + unloading scheme in place then option 1 is fine IMO.

We should be able to piggyback off the webapp lazyloading stuff?

Sanjiva.

On Thu, Jun 21, 2012 at 6:28 PM, Ruchira Wageesha ruch...@wso2.com wrote:

 Hi all,

 We are using Rhino's script compilation support in Jaggery product to
 improve the performance of JS execution.

 When we compiled a JS file using Rhino, we can get either

1. An object(Script) of the *.class file
   - This will be kept in memory and executed when ever needed
   - When n webapps of m size in a jaggery server are equally
   accessed, n x m memory will be needed in order keep all webapp objects 
 in
   memory
   - If the server doesn't have enough memory, then we will have to
   recompile the same webapp time to time
2. A *.class file for that script
   - In this way, we can save the *.class file to the disk and load it
   using a custom classloader.
   - In a muti-tenant environment, we can release the memory of unused
   classloaders and load the classes on demand using saved *.class files
   - As per my understanding, it would be able to server n webapps of
   m size using less amount of memory than above 1 by unloading unused
   classloaders and loading *.class on demand

 Currently it has been implemented to work in both modes, but I am not sure
 which one would be ideal for the case.

 Welcome your thoughts 

 regards,
 Ruchira

 --
 *Ruchira Wageesha
 Senior Software Engineer  Member, Management Committee, Development
 Technologies*
 *WSO2 Inc. - lean . enterprise . middleware |  wso2.com*
 *
 email: ruch...@wso2.com,   blog: ruchirawageesha.blogspot.com,   mobile: +94
 77 5493444*


 ___
 Dev mailing list
 d...@jaggeryjs.org
 http://mail.jaggeryjs.org/cgi-bin/mailman/listinfo/dev




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

Lean . Enterprise . Middleware
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev