[Javalist] REST és adattípusok

Böszörményi Péter zmblevlist at gmail.com
2012. Jan. 16., H, 19:56:02 CET


Az implementaciobol refactoraltam ki az interfacet, lusta voltam torolni  
az annotaciokat. :)

On Mon, 16 Jan 2012 19:19:10 +0100, Zsombor <gzsombor at gmail.com> wrote:

> S ez még túlzó is, hiszen az implementáción nem kell megismételni az
> interfacen levő annotációkat.
>
> Zs
>
>
> On Mon, Jan 16, 2012 at 19:15, Böszörményi Péter  
> <zmblevlist at gmail.com>wrote:
>
>> Nos.
>>
>> Van egy roppant bonyoult interfaceunk:
>>
>> @Path("/test")
>> public interface ITestRest {
>>
>>        @GET
>>        @Produces("application/json")
>>        public abstract Map<Integer, TestDTO> alma() throws Exception;
>>
>> }
>>
>> Ennek van egy meg bonyolultabb megvalositasa:
>>
>> @Path("/test")
>> public class TestRest implements ITestRest {
>>
>>        @Override
>>        @GET
>>        @Produces("application/json")
>>        public Map<Integer, TestDTO> alma() throws Exception {
>>
>>                Map<Integer, TestDTO> map = new HashMap<Integer,  
>> TestDTO>();
>>                map.put(1, new TestDTO("almavalue"));
>>                map.put(2, new TestDTO("kortevalue"));
>>                return map;
>>        }
>>
>> }
>>
>> A DTO kicsit ki lett csinositva:
>>
>> @XmlRootElement
>> public class TestDTO {
>>        private String almaProperty;
>>
>>        public TestDTO() {
>>                this(null);
>>
>>        }
>>
>>        public TestDTO(String x) {
>>                this.almaProperty = x;
>>        }
>>
>>        public void setAlmaProperty(String s) {
>>
>>                this.almaProperty = s;
>>        }
>>
>>        public String getAlmaProperty() {
>>                return this.almaProperty;
>>        }
>>
>>        @Override
>>        public String toString() {
>>                return "TestDTO [almaProperty=" + this.almaProperty +  
>> "]";
>>        }
>>
>> }
>>
>> Es a kliens roppant bonyolult kodja:
>> public class Main {
>>
>>        public static void main(String[] args) throws Exception {
>>                ITestRest test = ProxyFactory.create(ITestRest.**class, "
>> http://localhost:8080/**resttest <http://localhost:8080/resttest>");
>>                System.out.println(test.alma()**);
>>
>>        }
>> }
>>
>> On Mon, 16 Jan 2012 16:50:43 +0100, András Csányi  
>> <sayusi.ando at gmail.com>
>> wrote:
>>
>>  2012/1/16 Böszörményi Péter <zmblevlist at gmail.com>:
>>>
>>>> Nincs itt semmilyen interface. Van egy szerver oldalo cucc, ami  
>>>> jsonban
>>>> tolja ki az adatot. Kellene neked egy kliens oldali tipusos interface  
>>>> is?
>>>>
>>>
>>> Bezony. Az rinyál itt nekem, hogy nem tud mit kezdeni azzal, amit a
>>> szerver oldal kitol magából. Pontosabban lehet, hogy tud csak én nem
>>> tudom neki megmondani, hogy hogy és mit.
>>>
>>> Itt sírtam el panaszomat a stackoverflow -n.
>>> http://stackoverflow.com/**questions/8781769/resteasy-**
>>> messagebodyreader-error-**message<http://stackoverflow.com/questions/8781769/resteasy-messagebodyreader-error-message>
>>>
>>>
>>
>> --
>> Üdvözlettel,
>> Böszörményi Péter
>>
>> ______________________________**_________________
>> Javalist mailing list
>> Javalist at lists.javaforum.hu
>> http://lists.javaforum.hu/**mailman/listinfo/javalist<http://lists.javaforum.hu/mailman/listinfo/javalist>
>>


-- 
Üdvözlettel,
Böszörményi Péter


További információk a(z) Javalist levelezőlistáról