On Thu, Apr 18, 2013 at 5:45 PM, Nalin Chandraratne <[email protected]> wrote:

> Hi,
>
> Thanks guys. I could do it with
>
> MessageFormatter messageFormatter =
> axis2MessageContext.getConfigurationContext().getAxisConfiguration().getMessageFormatter(JSON_CONTENT);
>

This way of direct accessing MessageFormatters and Builders are
discouraged  in Axis2 instead you should use provided factory methods to
get an instance of MessageFormatter/Builder. Instead of above method please
use following code.

Builder messageBuilder =
MessageProcessorSelector.getMessageBuilder(JSON_CONTENT,
axis2MessageContext);

MessageFormatter messageFormatter =
MessageProcessorSelector.getMessageFormatter(axis2MessageContext);

Note : Before you call getMessageFormatter() method make sure to check
Constants.Configuration.MESSAGE_TYPE is set on the axis2MessageContext
object. If it not there you can add it like below deepening on your use
case.

axis2MessageContext.setProperty(Constants.Configuration.MESSAGE_TYPE,
JSON_CONTENT);

Thanks !


>
> (Earlier I was using getMessageContext instead of
> .getConfigurationContext, thats y i couldn't find the correct method. My
> bad  )
>
> Really appriciate your help.
>
> UseCase:
>
> Its for an enhancement of PayloadFactory mediator. Suppose we have an
> incoming xml message and we want to send a json output. Depending on the
> active json formatter, we either attach the transformed json message to the
> payload or to the message context as a property.
>
> Nalin.
>
>
> On Thu, Apr 18, 2013 at 5:33 PM, Sagara Gunathunga <[email protected]>wrote:
>
>>
>>
>>
>> On Thu, Apr 18, 2013 at 5:21 PM, Nalin Chandraratne <[email protected]>wrote:
>>
>>> Hi
>>>
>>> @sagara : active means the builders/formaters which are uncommented in
>>> the axis2.xml. (if the Content-Type is application/json either
>>> jsomOmBuilder or jsonStreamBuilder is uncommented. want to know which is
>>> uncommented in a given time)
>>>
>>
>> For this you can follow what Nirmal suggested. BTW can you please explain
>> your complete use case   ? I mean why you want to find what is the active
>> builder etc ?  And the place you want to have above check ?
>>
>> Thanks !
>>
>>
>>>
>>>
>>> On Thu, Apr 18, 2013 at 5:08 PM, Sagara Gunathunga <[email protected]>wrote:
>>>
>>>>
>>>>
>>>>
>>>> On Thu, Apr 18, 2013 at 5:01 PM, Nalin Chandraratne <[email protected]>wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> @Sagara : The flag strategy only works if the content actually comes
>>>>> through the specific builder. Suppose the content came through a xml
>>>>> builder and we want to find out if the jsonStreamBuilder is active.. Then
>>>>> this method wouldn't work.
>>>>>
>>>>
>>>> What does you mean as active here ?
>>>>
>>>> Thanks !
>>>>
>>>>
>>>>>
>>>>> @Nirmal : Couldn't find the builders from the axis2config. Appreciate
>>>>> if you could elaborate :)
>>>>>
>>>>>
>>>>> On Thu, Apr 18, 2013 at 4:09 PM, Sagara Gunathunga <[email protected]>wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, Apr 18, 2013 at 3:11 PM, Nalin Chandraratne 
>>>>>> <[email protected]>wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> How to identify all the *AVAILABLE* message builders and formatters
>>>>>>> in run time ?
>>>>>>> As an example, I want to know whether jsonOmBuilder or
>>>>>>> JsonStreamBuilder is active.
>>>>>>>
>>>>>>
>>>>>> AFAIK JsonStreamBuilder is a custom builder cerated for ESB usages.
>>>>>> Within the processDocument() method  of JsonStreamBuilder class set a 
>>>>>> flag
>>>>>> to MC. Now whenever required you can check above flag from MC and 
>>>>>> determine
>>>>>> whether message was build by JsonStreamBuilder or not, if the flag found 
>>>>>> on
>>>>>> MC means message came through JsonStreamBuilder if flag is not found
>>>>>> message didn't come through JsonStreamBuilder.
>>>>>>
>>>>>> Thanks !
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Nalin Chamara
>>>>>>> Software Engineer
>>>>>>> [email protected]
>>>>>>> +94715614756
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sagara Gunathunga
>>>>>>
>>>>>> Technical Lead; WSO2, Inc.;  http://wso2.com
>>>>>> V.P Apache Web Services;    http://ws.apache.org/
>>>>>> Linkedin; http://www.linkedin.com/in/ssagara
>>>>>> Blog ;  http://ssagara.blogspot.com
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Nalin Chamara
>>>>> Software Engineer
>>>>> [email protected]
>>>>> +94715614756
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Sagara Gunathunga
>>>>
>>>> Technical Lead; WSO2, Inc.;  http://wso2.com
>>>> V.P Apache Web Services;    http://ws.apache.org/
>>>> Linkedin; http://www.linkedin.com/in/ssagara
>>>> Blog ;  http://ssagara.blogspot.com
>>>>
>>>>
>>>
>>>
>>> --
>>> Nalin Chamara
>>> Software Engineer
>>> [email protected]
>>> +94715614756
>>>
>>
>>
>>
>> --
>> Sagara Gunathunga
>>
>> Technical Lead; WSO2, Inc.;  http://wso2.com
>> V.P Apache Web Services;    http://ws.apache.org/
>> Linkedin; http://www.linkedin.com/in/ssagara
>> Blog ;  http://ssagara.blogspot.com
>>
>>
>
>
> --
> Nalin Chamara
> Software Engineer
> [email protected]
> +94715614756
>



-- 
Sagara Gunathunga

Technical Lead; WSO2, Inc.;  http://wso2.com
V.P Apache Web Services;    http://ws.apache.org/
Linkedin; http://www.linkedin.com/in/ssagara
Blog ;  http://ssagara.blogspot.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to