You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Salvatore Lionetti <sa...@gmail.com> on 2012/09/19 21:18:10 UTC

@SMD annotation

Hi,

i'm using a beautiful Struts2 2.3.1.2 environment.
I'm having trouble with annotation @SMD, basically ignored, at least
in the initial message:

methods: [...], "objectName": null, ... "version": .1 (the default)

This is the commands:

Java
@SMD(objectName = "TEST", serviceType = "JSON-RPC", version = "10.0")
public class SimpleJAction {
    public String smd()
    {
        return Action.SUCCESS;
    }
    @SMDMethod
    ... a lot of methods.
}

Struts.xml
    <package name="example" extends="json-default">
        <action name="simpleJAction" class="x.y.SimpleJsonAction"
method="smd">
            <interceptor-ref name="json">
                <param name="enableSMD">true</param>
                <param name="ignoreSMDMethodInterfaces">false</param>
            </interceptor-ref>
            <result type="json">
                <param name="enableSMD">true</param>
                <param name="contentType">text/html</param>
                <param name="ignoreInterfaces">false</param>
            </result>
        </action>
      ...
     </package>

Basically all works great, except @SMD annotation is totally ignored
(compile support seem works great!)

In the first method called in class SimpleJsonAction, the second
message exchanged after the 'methods' one, i dump:

log.error(this.getClass().getAnnotation(SMD.class).toString());

And obtain an almost  correct (serviceType is no more 'JSON-RPC', anyway)

@org.apache.struts2.json.annotations.SMD(serviceType=service, version=10.0,...)

Could you please help me in finding the mistake?

Thanks for your attention

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: @SMD annotation

Posted by Frans Thamura <fr...@meruvian.org>.
we have working more than 2 years to map the REST standard GET PUT
DELETE POST to S2 Plugins.

we have a showcase also there.

but if you wanna to try our yama, (struts2-spring-hibernate),
showcase, that will help you a lot, and the license also same Apache .
http://yama.java.net,

all our work in maven central also.

we have our real life system like www.mervpolis.com,
http://sums.mervpolis.com , all using this plugins.

we use jackson as json parser.

visit our knowledgespace, in http://space.meruvian.org/meruvian/yama,
so you can quick looking our quickstart documentation for using yama.

we have yama with jaxrs, and we in plan to make rest plugin little bit
adopt several JAXRS model, rather using current @Action @Result model


On 9/20/12, Salvatore Lionetti <sa...@youco.eu> wrote:
> Hi Frans,
>
> Thanks for your suggestion, really interesting
> "Built-in resource transformer for JSON and XML."
>
> But struts-json plugin seems to provide all the "tools" in my case.
> I see the code changed a lot, expecially now the annotation on SMD
> object is now done in SMDGenerator::generate() instead of
> JSONResult::writeSMD, Perhaps i've a problem with the root object. But
> in my case there are many SMD methods, each resembling to a particular
> bean automagically serialized/deserialized by the plugin. Moreover the
> strange thing is that method are correctly collected from my custom
> object. Does the initial message (method: [] , ..., objectName, ... )
> is generated in SMDGenerator::generate()?
>
> Thanks for your attention
>
>
>
> 2012/9/20, Frans Thamura <fr...@meruvian.org>:
>> hi there,,
>>
>> we modify the REST, i believe you interest with @SMD because want to
>> process the response
>>
>> try this
>>
>> s2restplugins.java.net
>>
>> F
>>
>> On Thu, Sep 20, 2012 at 2:18 AM, Salvatore Lionetti
>> <sa...@gmail.com> wrote:
>>> Hi,
>>>
>>> i'm using a beautiful Struts2 2.3.1.2 environment.
>>> I'm having trouble with annotation @SMD, basically ignored, at least
>>> in the initial message:
>>>
>>> methods: [...], "objectName": null, ... "version": .1 (the default)
>>>
>>> This is the commands:
>>>
>>> Java
>>> @SMD(objectName = "TEST", serviceType = "JSON-RPC", version = "10.0")
>>> public class SimpleJAction {
>>>     public String smd()
>>>     {
>>>         return Action.SUCCESS;
>>>     }
>>>     @SMDMethod
>>>     ... a lot of methods.
>>> }
>>>
>>> Struts.xml
>>>     <package name="example" extends="json-default">
>>>         <action name="simpleJAction" class="x.y.SimpleJsonAction"
>>> method="smd">
>>>             <interceptor-ref name="json">
>>>                 <param name="enableSMD">true</param>
>>>                 <param name="ignoreSMDMethodInterfaces">false</param>
>>>             </interceptor-ref>
>>>             <result type="json">
>>>                 <param name="enableSMD">true</param>
>>>                 <param name="contentType">text/html</param>
>>>                 <param name="ignoreInterfaces">false</param>
>>>             </result>
>>>         </action>
>>>       ...
>>>      </package>
>>>
>>> Basically all works great, except @SMD annotation is totally ignored
>>> (compile support seem works great!)
>>>
>>> In the first method called in class SimpleJsonAction, the second
>>> message exchanged after the 'methods' one, i dump:
>>>
>>> log.error(this.getClass().getAnnotation(SMD.class).toString());
>>>
>>> And obtain an almost  correct (serviceType is no more 'JSON-RPC',
>>> anyway)
>>>
>>> @org.apache.struts2.json.annotations.SMD(serviceType=service,
>>> version=10.0,...)
>>>
>>> Could you please help me in finding the mistake?
>>>
>>> Thanks for your attention
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
--
Frans Thamura (曽志胜)
Shadow Master and Lead Investor
Meruvian.
Integrated Hypermedia Java Solution Provider.

Mobile: +628557888699
Blog: http://blogs.mervpolis.com/roller/flatburger (id)

FB: http://www.facebook.com/meruvian
TW: http://www.twitter.com/meruvian / @meruvian
Website: http://www.meruvian.org

"We grow because we share the same belief."

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: @SMD annotation

Posted by Salvatore Lionetti <sa...@youco.eu>.
Hi Frans,

Thanks for your suggestion, really interesting
"Built-in resource transformer for JSON and XML."

But struts-json plugin seems to provide all the "tools" in my case.
I see the code changed a lot, expecially now the annotation on SMD
object is now done in SMDGenerator::generate() instead of
JSONResult::writeSMD, Perhaps i've a problem with the root object. But
in my case there are many SMD methods, each resembling to a particular
bean automagically serialized/deserialized by the plugin. Moreover the
strange thing is that method are correctly collected from my custom
object. Does the initial message (method: [] , ..., objectName, ... )
is generated in SMDGenerator::generate()?

Thanks for your attention



2012/9/20, Frans Thamura <fr...@meruvian.org>:
> hi there,,
>
> we modify the REST, i believe you interest with @SMD because want to
> process the response
>
> try this
>
> s2restplugins.java.net
>
> F
>
> On Thu, Sep 20, 2012 at 2:18 AM, Salvatore Lionetti
> <sa...@gmail.com> wrote:
>> Hi,
>>
>> i'm using a beautiful Struts2 2.3.1.2 environment.
>> I'm having trouble with annotation @SMD, basically ignored, at least
>> in the initial message:
>>
>> methods: [...], "objectName": null, ... "version": .1 (the default)
>>
>> This is the commands:
>>
>> Java
>> @SMD(objectName = "TEST", serviceType = "JSON-RPC", version = "10.0")
>> public class SimpleJAction {
>>     public String smd()
>>     {
>>         return Action.SUCCESS;
>>     }
>>     @SMDMethod
>>     ... a lot of methods.
>> }
>>
>> Struts.xml
>>     <package name="example" extends="json-default">
>>         <action name="simpleJAction" class="x.y.SimpleJsonAction"
>> method="smd">
>>             <interceptor-ref name="json">
>>                 <param name="enableSMD">true</param>
>>                 <param name="ignoreSMDMethodInterfaces">false</param>
>>             </interceptor-ref>
>>             <result type="json">
>>                 <param name="enableSMD">true</param>
>>                 <param name="contentType">text/html</param>
>>                 <param name="ignoreInterfaces">false</param>
>>             </result>
>>         </action>
>>       ...
>>      </package>
>>
>> Basically all works great, except @SMD annotation is totally ignored
>> (compile support seem works great!)
>>
>> In the first method called in class SimpleJsonAction, the second
>> message exchanged after the 'methods' one, i dump:
>>
>> log.error(this.getClass().getAnnotation(SMD.class).toString());
>>
>> And obtain an almost  correct (serviceType is no more 'JSON-RPC', anyway)
>>
>> @org.apache.struts2.json.annotations.SMD(serviceType=service,
>> version=10.0,...)
>>
>> Could you please help me in finding the mistake?
>>
>> Thanks for your attention
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: @SMD annotation

Posted by Frans Thamura <fr...@meruvian.org>.
hi there,,

we modify the REST, i believe you interest with @SMD because want to
process the response

try this

s2restplugins.java.net

F

On Thu, Sep 20, 2012 at 2:18 AM, Salvatore Lionetti
<sa...@gmail.com> wrote:
> Hi,
>
> i'm using a beautiful Struts2 2.3.1.2 environment.
> I'm having trouble with annotation @SMD, basically ignored, at least
> in the initial message:
>
> methods: [...], "objectName": null, ... "version": .1 (the default)
>
> This is the commands:
>
> Java
> @SMD(objectName = "TEST", serviceType = "JSON-RPC", version = "10.0")
> public class SimpleJAction {
>     public String smd()
>     {
>         return Action.SUCCESS;
>     }
>     @SMDMethod
>     ... a lot of methods.
> }
>
> Struts.xml
>     <package name="example" extends="json-default">
>         <action name="simpleJAction" class="x.y.SimpleJsonAction"
> method="smd">
>             <interceptor-ref name="json">
>                 <param name="enableSMD">true</param>
>                 <param name="ignoreSMDMethodInterfaces">false</param>
>             </interceptor-ref>
>             <result type="json">
>                 <param name="enableSMD">true</param>
>                 <param name="contentType">text/html</param>
>                 <param name="ignoreInterfaces">false</param>
>             </result>
>         </action>
>       ...
>      </package>
>
> Basically all works great, except @SMD annotation is totally ignored
> (compile support seem works great!)
>
> In the first method called in class SimpleJsonAction, the second
> message exchanged after the 'methods' one, i dump:
>
> log.error(this.getClass().getAnnotation(SMD.class).toString());
>
> And obtain an almost  correct (serviceType is no more 'JSON-RPC', anyway)
>
> @org.apache.struts2.json.annotations.SMD(serviceType=service, version=10.0,...)
>
> Could you please help me in finding the mistake?
>
> Thanks for your attention
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: @SMD annotation

Posted by Salvatore Lionetti <sa...@youco.eu>.
Here the code:

http://pastebin.com/K28NsN0F


2012/9/20, Salvatore Lionetti <sa...@youco.eu>:
> Hi Maurizio,
>
> === The situation ===
> <<Environment>>
> Apache 7.0.14
>
> <<Plugins>>
> struts2-{core,json-plugin}-2.3.1.2.jar, aspectjrt-1.6.11.jar, ...
>
> <<Application>>
> Similar to that explained@
> http://struts.apache.org/2.1.8/docs/json-plugin.html
> section "JSON RPC" but decorated with the following annotation:
>
> @SMD(objectName = "testaction", serviceType = "JSON-RPC", version = "10.0")
> public class SMDAction {
> ...
> }
> just the row before the class definition (with implicit declaration)
> beginning.
>
> === Black Box Test: given input, expected output ===
> At client request "GET /context/SMDAction HTTP/1.1"
> I read the following response
> HTTP/1.1 200 OK
> {
> "methods":[{"name":"method1",...}],
> "objectName":"testaction",
> "serviceType":"JSON-RPC",
> "serviceUrl":"/context/SMDAction",
> "version":"10.0"
> }
>
> === The output in the crude and hard reality ===
> This is the response i got:
> {
> "methods":[{"name":"method1",...}],
> "objectName":null,
> "serviceType":"JSON-RPC",
> "serviceUrl":"/context/SMDAction",
> "version":".1"
> }
> Note that all methods and relative parameters are corrects respect to
> @SMDMethod annotations. The only pb in on "version", "objectName"
> field, hence @SMD annotation.
>
> For a running example i need more time.
>
> Have a good day
>
> 2012/9/20, Maurizio Cucchiara <mc...@apache.org>:
>> Hi Salvatore,
>> I would like to help you, but unfortunately I didn't get you.
>> Could you provide a deeper explanation of your issues, please?
>> What is the expected output?
>> Could you also provide a runnable example (maybe through a pastebin)?
>>
>> Twitter     :http://www.twitter.com/m_cucchiara
>> G+          :https://plus.google.com/107903711540963855921
>> Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
>>
>> Maurizio Cucchiara
>>
>>
>> On 19 September 2012 21:18, Salvatore Lionetti
>> <sa...@gmail.com>wrote:
>>
>>> Hi,
>>>
>>> i'm using a beautiful Struts2 2.3.1.2 environment.
>>> I'm having trouble with annotation @SMD, basically ignored, at least
>>> in the initial message:
>>>
>>> methods: [...], "objectName": null, ... "version": .1 (the default)
>>>
>>> This is the commands:
>>>
>>> Java
>>> @SMD(objectName = "TEST", serviceType = "JSON-RPC", version = "10.0")
>>> public class SimpleJAction {
>>>     public String smd()
>>>     {
>>>         return Action.SUCCESS;
>>>     }
>>>     @SMDMethod
>>>     ... a lot of methods.
>>> }
>>>
>>> Struts.xml
>>>     <package name="example" extends="json-default">
>>>         <action name="simpleJAction" class="x.y.SimpleJsonAction"
>>> method="smd">
>>>             <interceptor-ref name="json">
>>>                 <param name="enableSMD">true</param>
>>>                 <param name="ignoreSMDMethodInterfaces">false</param>
>>>             </interceptor-ref>
>>>             <result type="json">
>>>                 <param name="enableSMD">true</param>
>>>                 <param name="contentType">text/html</param>
>>>                 <param name="ignoreInterfaces">false</param>
>>>             </result>
>>>         </action>
>>>       ...
>>>      </package>
>>>
>>> Basically all works great, except @SMD annotation is totally ignored
>>> (compile support seem works great!)
>>>
>>> In the first method called in class SimpleJsonAction, the second
>>> message exchanged after the 'methods' one, i dump:
>>>
>>> log.error(this.getClass().getAnnotation(SMD.class).toString());
>>>
>>> And obtain an almost  correct (serviceType is no more 'JSON-RPC',
>>> anyway)
>>>
>>> @org.apache.struts2.json.annotations.SMD(serviceType=service,
>>> version=10.0,...)
>>>
>>> Could you please help me in finding the mistake?
>>>
>>> Thanks for your attention
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: @SMD annotation

Posted by Maurizio Cucchiara <mc...@apache.org>.
Hi Salvatore,
firstly I'm sorry for the late answer. Unfortunately (or fortunately
depending on the point of view) I was not able to reproduce the
behavior you described.
I've been using the Struts Blank Web App [1] for my test (you can also
download the Blank Web App from the download page [2])
I changed 2 files (pom.xml and example.xml) and I added the class you
sent before (SMDAction.java) (see [3] for further details).
The output is consistent with the expected one, as you will see from
the gist [3].

Obviously I didn't know how your custom interceptors work.
Also, I haven't used Spring (which IMO is the culprit)

Can you try if is the issue have to do w/ Spring use?

Ciao

[1] http://struts.apache.org/2.x/docs/struts-2-blank-archetype.html
[2] http://apache.fis.uniroma2.it//struts/examples/struts-2.3.4.1-apps.zip
[3] https://gist.github.com/3774981


Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: @SMD annotation

Posted by Salvatore Lionetti <sa...@youco.eu>.
Hi Maurizio,

=== The situation ===
<<Environment>>
Apache 7.0.14

<<Plugins>>
struts2-{core,json-plugin}-2.3.1.2.jar, aspectjrt-1.6.11.jar, ...

<<Application>>
Similar to that explained@
http://struts.apache.org/2.1.8/docs/json-plugin.html
section "JSON RPC" but decorated with the following annotation:

@SMD(objectName = "testaction", serviceType = "JSON-RPC", version = "10.0")
public class SMDAction {
...
}
just the row before the class definition (with implicit declaration) beginning.

=== Black Box Test: given input, expected output ===
At client request "GET /context/SMDAction HTTP/1.1"
I read the following response
HTTP/1.1 200 OK
{
"methods":[{"name":"method1",...}],
"objectName":"testaction",
"serviceType":"JSON-RPC",
"serviceUrl":"/context/SMDAction",
"version":"10.0"
}

=== The output in the crude and hard reality ===
This is the response i got:
{
"methods":[{"name":"method1",...}],
"objectName":null,
"serviceType":"JSON-RPC",
"serviceUrl":"/context/SMDAction",
"version":".1"
}
Note that all methods and relative parameters are corrects respect to
@SMDMethod annotations. The only pb in on "version", "objectName"
field, hence @SMD annotation.

For a running example i need more time.

Have a good day

2012/9/20, Maurizio Cucchiara <mc...@apache.org>:
> Hi Salvatore,
> I would like to help you, but unfortunately I didn't get you.
> Could you provide a deeper explanation of your issues, please?
> What is the expected output?
> Could you also provide a runnable example (maybe through a pastebin)?
>
> Twitter     :http://www.twitter.com/m_cucchiara
> G+          :https://plus.google.com/107903711540963855921
> Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
>
> Maurizio Cucchiara
>
>
> On 19 September 2012 21:18, Salvatore Lionetti
> <sa...@gmail.com>wrote:
>
>> Hi,
>>
>> i'm using a beautiful Struts2 2.3.1.2 environment.
>> I'm having trouble with annotation @SMD, basically ignored, at least
>> in the initial message:
>>
>> methods: [...], "objectName": null, ... "version": .1 (the default)
>>
>> This is the commands:
>>
>> Java
>> @SMD(objectName = "TEST", serviceType = "JSON-RPC", version = "10.0")
>> public class SimpleJAction {
>>     public String smd()
>>     {
>>         return Action.SUCCESS;
>>     }
>>     @SMDMethod
>>     ... a lot of methods.
>> }
>>
>> Struts.xml
>>     <package name="example" extends="json-default">
>>         <action name="simpleJAction" class="x.y.SimpleJsonAction"
>> method="smd">
>>             <interceptor-ref name="json">
>>                 <param name="enableSMD">true</param>
>>                 <param name="ignoreSMDMethodInterfaces">false</param>
>>             </interceptor-ref>
>>             <result type="json">
>>                 <param name="enableSMD">true</param>
>>                 <param name="contentType">text/html</param>
>>                 <param name="ignoreInterfaces">false</param>
>>             </result>
>>         </action>
>>       ...
>>      </package>
>>
>> Basically all works great, except @SMD annotation is totally ignored
>> (compile support seem works great!)
>>
>> In the first method called in class SimpleJsonAction, the second
>> message exchanged after the 'methods' one, i dump:
>>
>> log.error(this.getClass().getAnnotation(SMD.class).toString());
>>
>> And obtain an almost  correct (serviceType is no more 'JSON-RPC', anyway)
>>
>> @org.apache.struts2.json.annotations.SMD(serviceType=service,
>> version=10.0,...)
>>
>> Could you please help me in finding the mistake?
>>
>> Thanks for your attention
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: @SMD annotation

Posted by Maurizio Cucchiara <mc...@apache.org>.
Hi Salvatore,
I would like to help you, but unfortunately I didn't get you.
Could you provide a deeper explanation of your issues, please?
What is the expected output?
Could you also provide a runnable example (maybe through a pastebin)?

Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 19 September 2012 21:18, Salvatore Lionetti
<sa...@gmail.com>wrote:

> Hi,
>
> i'm using a beautiful Struts2 2.3.1.2 environment.
> I'm having trouble with annotation @SMD, basically ignored, at least
> in the initial message:
>
> methods: [...], "objectName": null, ... "version": .1 (the default)
>
> This is the commands:
>
> Java
> @SMD(objectName = "TEST", serviceType = "JSON-RPC", version = "10.0")
> public class SimpleJAction {
>     public String smd()
>     {
>         return Action.SUCCESS;
>     }
>     @SMDMethod
>     ... a lot of methods.
> }
>
> Struts.xml
>     <package name="example" extends="json-default">
>         <action name="simpleJAction" class="x.y.SimpleJsonAction"
> method="smd">
>             <interceptor-ref name="json">
>                 <param name="enableSMD">true</param>
>                 <param name="ignoreSMDMethodInterfaces">false</param>
>             </interceptor-ref>
>             <result type="json">
>                 <param name="enableSMD">true</param>
>                 <param name="contentType">text/html</param>
>                 <param name="ignoreInterfaces">false</param>
>             </result>
>         </action>
>       ...
>      </package>
>
> Basically all works great, except @SMD annotation is totally ignored
> (compile support seem works great!)
>
> In the first method called in class SimpleJsonAction, the second
> message exchanged after the 'methods' one, i dump:
>
> log.error(this.getClass().getAnnotation(SMD.class).toString());
>
> And obtain an almost  correct (serviceType is no more 'JSON-RPC', anyway)
>
> @org.apache.struts2.json.annotations.SMD(serviceType=service,
> version=10.0,...)
>
> Could you please help me in finding the mistake?
>
> Thanks for your attention
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>