You are viewing a plain text version of this content. The canonical link for it is here.
Posted to photark-dev@incubator.apache.org by Subash Chaturanga <su...@gmail.com> on 2011/07/31 21:12:34 UTC

How to Implement a custom Java Class which is capable of moving through Tuscany services.

How to implement a custom Class which is capable of moving through Tuscany
services ? What are the  mandatory attributes it should have ? Does it need
to implement java Serializable interface explicitly? Does this class must
have only Java natives as its state such as (String, int, ..) ?

Thanks
-- 
Subash Chaturanga
Department of Computer Science & Engineering
University of Moratuwa
Sri Lanka

Blog -  http://subashsdm.blogspot.com/
Twitter - http://twitter.com/subash89

Re: How to Implement a custom Java Class which is capable of moving through Tuscany services.

Posted by Avdhesh Yadav <av...@avdheshyadav.com>.
On Tue, Aug 2, 2011 at 11:48 AM, Subash Chaturanga <su...@gmail.com>wrote:

> When  implement Java Serializable interface on the PhotoP it worked. So
> shall I go ahead with it. I didn't explicitly did that before as photark
> Album impl class also not doing that.
>


 +1

>
> --
> Subash Chaturanga
> Department of Computer Science & Engineering
> University of Moratuwa
> Sri Lanka
>
> Blog -  http://subashsdm.blogspot.com/
> Twitter - http://twitter.com/subash89
>



-- 
Avdhesh Yadav
http://www.avdheshyadav.com
http://twitter.com/yadavavdhesh

Re: How to Implement a custom Java Class which is capable of moving through Tuscany services.

Posted by Subash Chaturanga <su...@gmail.com>.
When  implement Java Serializable interface on the PhotoP it worked. So
shall I go ahead with it. I didn't explicitly did that before as photark
Album impl class also not doing that.

On Tue, Aug 2, 2011 at 11:15 AM, Subash Chaturanga <su...@gmail.com>wrote:

> Regarding my initial problem(discussion is under the subject "Problem with
> interacting among two SCA services.") of having issues when using one
> service by another, as a solution w.r.t this thread,
>
> So I implemented a dummy Java bean class (with the intention, if  this
> works I can refactor the service interface accordingly ) as you suggested,
> which has two variables as information and no functioning methods . And
> replace this with the org.face4j.Photo for testing purpose whether this
> PhotoP object returns successfully from FaceRecognitionService to
> FacebookFriendFinder service. But I got the same result where it terminates
> at the same return point. Any idea ?
>
> public class PhotoP {
>     private String name;
>     private String names;
>
>     public PhotoP(String name){
>      this.name=name;
>     }
>
>     public String getName(){
>     return name;
>     }
>
>     @Property
>     public void setName(String name){
>       this.name = name;
>     }
>
>     public String getNames(){
>     return names;
>     }
>
>     @Property
>     public void setNames(String names){
>       this.names = names;
>     }
>
> }
>
>
> On Mon, Aug 1, 2011 at 7:47 AM, Luciano Resende <lu...@gmail.com>wrote:
>
>> On Sun, Jul 31, 2011 at 2:12 PM, Subash Chaturanga <su...@gmail.com>
>> wrote:
>> > How to implement a custom Class which is capable of moving through
>> Tuscany
>> > services ? What are the  mandatory attributes it should have ? Does it
>> need
>> > to implement java Serializable interface explicitly? Does this class
>> must
>> > have only Java natives as its state such as (String, int, ..) ?
>> >
>>
>> In general, you want to have Java beans [1] that represent pure data
>> and have no behavior.  Having said that, this is really not a Tuscany
>> question, but a general question depending on how you are going to
>> serialize your class. Consider when you expose your service using a
>> Tuscany JSON-RPC binding, which under the cover is going to use
>> Jackson framework to serialize the object to json; in this case a Java
>> bean would do it, but you could even take advantage of some JAXB
>> annotations that are supported by Jackson. Now, if we consider
>> exposing a service with Tuscany REST binding using XML wireformat, we
>> need to understand some of the limitations we have when serializing
>> XML, particularly where arrays need to be wrapped, etc.
>>
>> Well, hopefully this allows you to get going... if you want to discuss
>> some proposals, I'm happy to review and provide any feedback.
>>
>>
>>
>> [1] http://en.wikipedia.org/wiki/JavaBean
>>
>>
>>
>> --
>> Luciano Resende
>> http://people.apache.org/~lresende
>> http://twitter.com/lresende1975
>> http://lresende.blogspot.com/
>>
>
>
>
> --
> Subash Chaturanga
> Department of Computer Science & Engineering
> University of Moratuwa
> Sri Lanka
>
> Blog -  http://subashsdm.blogspot.com/
> Twitter - http://twitter.com/subash89
>
>
>


-- 
Subash Chaturanga
Department of Computer Science & Engineering
University of Moratuwa
Sri Lanka

Blog -  http://subashsdm.blogspot.com/
Twitter - http://twitter.com/subash89

Re: How to Implement a custom Java Class which is capable of moving through Tuscany services.

Posted by Subash Chaturanga <su...@gmail.com>.
Regarding my initial problem(discussion is under the subject "Problem with
interacting among two SCA services.") of having issues when using one
service by another, as a solution w.r.t this thread,

So I implemented a dummy Java bean class (with the intention, if  this works
I can refactor the service interface accordingly ) as you suggested, which
has two variables as information and no functioning methods . And replace
this with the org.face4j.Photo for testing purpose whether this PhotoP
object returns successfully from FaceRecognitionService to
FacebookFriendFinder service. But I got the same result where it terminates
at the same return point. Any idea ?

public class PhotoP {
    private String name;
    private String names;

    public PhotoP(String name){
     this.name=name;
    }

    public String getName(){
    return name;
    }

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

    public String getNames(){
    return names;
    }

    @Property
    public void setNames(String names){
      this.names = names;
    }

}


On Mon, Aug 1, 2011 at 7:47 AM, Luciano Resende <lu...@gmail.com>wrote:

> On Sun, Jul 31, 2011 at 2:12 PM, Subash Chaturanga <su...@gmail.com>
> wrote:
> > How to implement a custom Class which is capable of moving through
> Tuscany
> > services ? What are the  mandatory attributes it should have ? Does it
> need
> > to implement java Serializable interface explicitly? Does this class must
> > have only Java natives as its state such as (String, int, ..) ?
> >
>
> In general, you want to have Java beans [1] that represent pure data
> and have no behavior.  Having said that, this is really not a Tuscany
> question, but a general question depending on how you are going to
> serialize your class. Consider when you expose your service using a
> Tuscany JSON-RPC binding, which under the cover is going to use
> Jackson framework to serialize the object to json; in this case a Java
> bean would do it, but you could even take advantage of some JAXB
> annotations that are supported by Jackson. Now, if we consider
> exposing a service with Tuscany REST binding using XML wireformat, we
> need to understand some of the limitations we have when serializing
> XML, particularly where arrays need to be wrapped, etc.
>
> Well, hopefully this allows you to get going... if you want to discuss
> some proposals, I'm happy to review and provide any feedback.
>
>
>
> [1] http://en.wikipedia.org/wiki/JavaBean
>
>
>
> --
> Luciano Resende
> http://people.apache.org/~lresende
> http://twitter.com/lresende1975
> http://lresende.blogspot.com/
>



-- 
Subash Chaturanga
Department of Computer Science & Engineering
University of Moratuwa
Sri Lanka

Blog -  http://subashsdm.blogspot.com/
Twitter - http://twitter.com/subash89

Re: How to Implement a custom Java Class which is capable of moving through Tuscany services.

Posted by Luciano Resende <lu...@gmail.com>.
On Sun, Jul 31, 2011 at 2:12 PM, Subash Chaturanga <su...@gmail.com> wrote:
> How to implement a custom Class which is capable of moving through Tuscany
> services ? What are the  mandatory attributes it should have ? Does it need
> to implement java Serializable interface explicitly? Does this class must
> have only Java natives as its state such as (String, int, ..) ?
>

In general, you want to have Java beans [1] that represent pure data
and have no behavior.  Having said that, this is really not a Tuscany
question, but a general question depending on how you are going to
serialize your class. Consider when you expose your service using a
Tuscany JSON-RPC binding, which under the cover is going to use
Jackson framework to serialize the object to json; in this case a Java
bean would do it, but you could even take advantage of some JAXB
annotations that are supported by Jackson. Now, if we consider
exposing a service with Tuscany REST binding using XML wireformat, we
need to understand some of the limitations we have when serializing
XML, particularly where arrays need to be wrapped, etc.

Well, hopefully this allows you to get going... if you want to discuss
some proposals, I'm happy to review and provide any feedback.



[1] http://en.wikipedia.org/wiki/JavaBean



-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/