[Javalist] REST és adattípusok

Zsombor gzsombor at gmail.com
2012. Jan. 16., H, 19:19:10 CET


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>
>
--------- következő rész ---------
Egy csatolt HTML állomány át lett konvertálva...
URL: <http://lists.javaforum.hu/pipermail/javalist/attachments/20120116/4f21f79a/attachment.html>


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