Cisco Unified Application Environment Developer Forums

« Back to Etch

[Etch] Etch extern date

Combination View Flat View Tree View
Threads [ Previous | Next ]
Hello,

I have finished a RPC system for my java application using Etch.
I think Etch is a powerful RPC system because I have only needed two weeks for make this work (I'm using exceptions, structs, client calls, timeouts, null values, etc.)

At this moment all java.util.Date parameters of my service are passed as long types and now I want change it to 'extern date' but I'm having problems.

I'm using a simple service to do this tests.
This is service definition:

----------------------------------
module com.speedycontrol.testdate.common

@Authorize( true ) @Timeout( 4000 )
service DateTimeService {

    //@Extern( java, "java.util.Date", "", "com.speedycontrol.etch.MyDateSerializer", "" )
    @Extern( java, "java.util.Date", "", "etch.bindings.java.util.DateSerializer", "" )
    extern date

    date getDateTime()
   
}
----------------------------------

When I run the client I have this exception:

----------------------------------
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.speedycontrol.testdate.common.DateTimeServiceHelper.newServer(DateTimeServiceHelper.java:113)
    at com.speedycontrol.testdate.client.Main.main(Main.java:21)
Caused by: java.lang.IllegalArgumentException: type com.speedycontrol.testdate.common.DateTimeService.date(-255586452): class class java.util.Date is already mapped to type _Etch_Datetime(725183436)
    at etch.bindings.java.support.Class2TypeMap.put(Class2TypeMap.java:55)
    at etch.bindings.java.util.DateSerializer.init(DateSerializer.java:46)
&nbsp;&nbsp;&nbsp; at com.speedycontrol.testdate.common.ValueFactoryDateTimeService.<clinit>(ValueFactoryDateTimeService.java:82)
&nbsp;&nbsp;&nbsp; ... 2 more
----------------------------------

I have tried using 'etch.binding.java.util.DateSerializer' and with my own serializer (clone of previous).

I see that method etc.binding.java.util.DateSerializer.init() is called two times.
&nbsp;* First time is called from etch.bindings.java.support.DefaultValueFactory.init(..)
&nbsp;* Second time from my extern definition (then throws exception).

Only when I remove first call, the client work properly

What must I do ?


I send this message to mailing list because I can&#39;t send a new topic in Etch forum. I tried with IE, Firefox and Chrome last two weeks and I can&#39;t send (I think this page has some problem).


_______________________________________________
Etch mailing list
Etch@developer.cisco.com

<style type="text/css">

<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
coloremoticon1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->

</style>



Hi Juan,


&nbsp;


Which version of Etch are you using?&nbsp; For some time now, Etch
supports the type &#8216;Datetime&#8217; natively (case sensitive).


&nbsp;


You might want to try that instead.&nbsp; Not to say you don&#8217;t have a
problem with Extern&#8212;but I&#8217;m just pointing you in this other direction because
1) it probably makes more sense to just use the Etch native type, and 2) I
haven&#8217;t use extern myself and don&#8217;t know much about debugging.


&nbsp;


Thanks for letting us know about the Etch forum; we&#8217;ll check it
out.


&nbsp;


Seth


&nbsp;



From:
etch-bounces@developer.cisco.com mailto:etch-bounces@developer.cisco.com On
Behalf Of
Juan Padilla Julian
Sent: Wednesday, October 08, 2008 6:56 AM
To: etch@developer.cisco.com
Subject: Etch extern date



&nbsp;



Hello,

I have finished a RPC system for my java application using Etch.
I think Etch is a powerful RPC system because I have only needed two weeks for
make this work (I'm using exceptions, structs, client calls, timeouts, null
values, etc.)

At this moment all java.util.Date parameters of my service are passed as long
types and now I want change it to 'extern date' but I'm having problems.

I'm using a simple service to do this tests.
This is service definition:

----------------------------------
module com.speedycontrol.testdate.common

@Authorize( true ) @Timeout( 4000 )
service DateTimeService {

&nbsp;&nbsp;&nbsp; //@Extern( java, &quot;java.util.Date&quot;, &quot;&quot;,
&quot;com.speedycontrol.etch.MyDateSerializer&quot;, &quot;&quot; )
&nbsp;&nbsp;&nbsp; @Extern( java, &quot;java.util.Date&quot;, &quot;&quot;,
&quot;etch.bindings.java.util.DateSerializer&quot;, &quot;&quot; )
&nbsp;&nbsp;&nbsp; extern date

&nbsp;&nbsp;&nbsp; date getDateTime()
&nbsp;&nbsp;&nbsp;
}
----------------------------------

When I run the client I have this exception:

----------------------------------
Exception in thread &quot;main&quot; java.lang.ExceptionInInitializerError
&nbsp;&nbsp;&nbsp; at
com.speedycontrol.testdate.common.DateTimeServiceHelper.newServer(DateTimeServiceHelper.java:113)
&nbsp;&nbsp;&nbsp; at com.speedycontrol.testdate.client.Main.main(Main.java:21)
Caused by: java.lang.IllegalArgumentException: type
com.speedycontrol.testdate.common.DateTimeService.date(-255586452): class class
java.util.Date is already mapped to type _Etch_Datetime(725183436)
&nbsp;&nbsp;&nbsp; at
etch.bindings.java.support.Class2TypeMap.put(Class2TypeMap.java:55)
&nbsp;&nbsp;&nbsp; at
etch.bindings.java.util.DateSerializer.init(DateSerializer.java:46)
&nbsp;&nbsp;&nbsp; at
com.speedycontrol.testdate.common.ValueFactoryDateTimeService.<clinit>(ValueFactoryDateTimeService.java:82)
&nbsp;&nbsp;&nbsp; ... 2 more
----------------------------------

I have tried using 'etch.binding.java.util.DateSerializer' and with my own
serializer (clone of previous).

I see that method etc.binding.java.util.DateSerializer.init() is called two
times.
&nbsp;* First time is called from
etch.bindings.java.support.DefaultValueFactory.init(..)
&nbsp;* Second time from my extern definition (then throws exception).

Only when I remove first call, the client work properly

What must I do ?


I send this message to mailing list because I can't send a new topic in Etch
forum. I tried with IE, Firefox and Chrome last two weeks and I can't send (I
think this page has some problem).



_______________________________________________
Etch mailing list
Etch@developer.cisco.com

Re: [Etch] Etch extern date
Answer
10/10/08 8:10 PM as a reply to Juan Padilla Julian.
Juan,

I'm wondering if you finally got this straightened out?

The way etch works is there is a tight binding between supported types and their serializers. So you cannot have two serializers for java.util.Date, and a given serializer can only be initialized once per service (because that creates definitions in the service's ValueFactory).

Also, as seth call said you ought to use the standard Datetime type that etch supports, which is compiled into java.util.Date for java and the appropriate other types for csharp, ruby, python, etc.