Re: [Resteasy-users] Scan vs Spring

2014-02-11 Thread Jean-François HEROUARD
Mixing auto-scan may lead to misunderstanding for maintenance of code. I
agree scan should be possible, as long as you do not mix Spring features
with Resteasy, especially bean lifecycle. Usually I inject business beans
in resteasy WS using Spring IoC, @Autowired or @Inject annotations are
ignored if REST URL handlers are not seen by Spring listener. Using more
features of Spring will have some strange side effects if remote calls are
not in a Spring context. After some tests and long time of debugging trying
to understand why Spring is not fully usable (I remember a case where
@Autowired was working but not some EL in @Value), I only configure
Resteasy "Spring MVC integration" in the main app, and "Spring Integration"
in Resteasy for test. For simple REST WS, I have another war, without any
Spring dependency.


2014-02-06 20:41 GMT+01:00 Anthony Whitford :

> I have a project that is using RestEasy -- there were 23 resources.
> The project was using "resteasy.scan.resources=true" in the web.xml.
>
> Now, I added another resource.  This time, we need Spring.
> So, I add the resteasy-spring dependency and update the web.xml,
> according to the docs:
>
>
> http://docs.jboss.org/resteasy/docs/3.0.6.Final/userguide/html/RESTEasy_Spring_Integration.html
>
> Now, the boot fails because the "scan" can't coexist with Spring.  No
> problem, I can remove the scan  But then my original 23 resources are
> not available.
>
> According to the documentation...
>
> "RESTEasy will automatically scan for @Provider and JAX-RS resource
> annotations on your bean class and register them as JAS-RS resources."
>
>
> It would seem that I need to make the 23 resources Spring beans (Add a
> @Named annotation, for example), or else manually list them in my web.xml
> ("resteasy.resources"), or create an Application instance to register
> them...
>
> Ugh...  Why can't the RestEasy-Spring bootstrap automatically register the
> resources annotated with @Path?
>
> Or...  Why can't the SCAN coexist with Spring again?
>
>
>
>
> --
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
>
--
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] [External] Re: Error marshaling w/ XmlAnyElement + Element Adapter - simple JBoss 7 + RESTEasy project

2014-02-04 Thread Jean-François HEROUARD
With a small change I got your sample :
public class LabelValueAdapter extends XmlAdapter {

@Override
public Element marshal(LabelValue labelValueModel) throws Exception {
Element e =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().createElement(getCleanLabel(labelValueModel.getLabel()));
e.setAttribute("label", labelValueModel.getLabel());
e.setTextContent(labelValueModel.getValue());
return e;
}
@Override
public LabelValue unmarshal(Element element) throws Exception {
throw new UnsupportedOperationException();
}

private String getCleanLabel(String attributeLabel) {
attributeLabel = attributeLabel.replaceAll("dk_",
"").replaceAll("[()]", "")
.replaceAll("[^\\w\\s]", "_").replaceAll(" ", "_")
.toUpperCase();
return attributeLabel;
}
}


2014-02-04 Johnson, Shawn [USA] :

> Thanks so much Jean-François.  I had taken that example from another site
> - where they used the both JAXBElement as well as dom.Element - to add the
> attribute to the label.  Is there another way to accomplish something like
> this?  Since this is only marshaling my Java objects, I have a lot of
> flexibility on how I structure my class.
>
> Deer Park
> Mountain Stream
> Mr. Water
>
>
> From:  Jean-François HEROUARD 
> Date:  Tuesday, February 4, 2014 4:25 AM
> To:  Shawn Johnson 
> Cc:  "resteasy-users@lists.sourceforge.net"
> 
> Subject:  [External]  Re: [Resteasy-users] Error marshaling w/
> XmlAnyElement + Element Adapter - simple JBoss 7 + RESTEasy project
>
>
> I've tested with JAXB 2.2.5, it's the same problem, so forget my previous
> mail.
>
> With the following method in LabelValueAdapter, there's no more NPE :
> @Override
> public Element marshal(LabelValue labelValueModel) throws Exception {
> Element e =
> DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().cre
> ateElement(getCleanLabel(labelValueModel.getLabel()));
> e.setTextContent(labelValueModel.getValue());
> return e;
> }
>
>
> With this result :
> 
> 
> Deer Park
> Mountain Stream
> Mr. Water
> 
> I have removed all adapter class private attributes and usage JAXBElement,
> it seems there is a problem calling a JAXB marshaller inside an adapter.
> JAXB marshalling is not "reentrant" ?
>
>
>
>
> 2014-02-04 Jean-François HEROUARD :
>
> I had a similar problem, but the stacktrace was not exactly the same. This
> NPE sounds like a jaxb-impl bug of 2.2.4 version, see
> https://jaxb.java.net/2.2.6/docs/ch02.html. Version 2.2.4 is embedded by
> JBoss7.1.x, you should replace jaxb-impl with 2.2.5. Can you also check in
> your "crazy class path" project what
>  is your version af jaxb-impl ?
>
> I'll try to find time to check out and run your project.
>
>
>
> 2014-02-03 Johnson, Shawn [USA] :
>
>
> Bill, thanks for the reply. Sorry for leaving out the version info -
> partially because I've tried 3 different configs.  Below is the stack
> trace from JBoss AS 7.2 - which I left with it's included version of
> RESTEasy 2.3.5.  I can also repeat this with
>  3.0.6 if that's more helpful?
>
>
> [Previous message was too long for the mailing list]
>
>
> Here is a link to the full stack trace using RESTEasy 2.3.5.
> http://pastebin.com/eFiBgfYQ
>
>
> Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter -
> simple JBoss 7 + RESTEasy project
> From: Bill Burke  - 2014-02-03 15:19
> You'll have to point out what resteasy version you are using so I can
> match the line numbers in you stack trace up.
>
>
>
> ---
> ---
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktr
> k
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
>
> http://pubads.g.doubleclick

Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter - simple JBoss 7 + RESTEasy project

2014-02-04 Thread Jean-François HEROUARD
I've tested with JAXB 2.2.5, it's the same problem, so forget my previous
mail.
With the following method in LabelValueAdapter, there's no more NPE :
@Override
public Element marshal(LabelValue labelValueModel) throws Exception {
Element e =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().createElement(getCleanLabel(labelValueModel.getLabel()));
e.setTextContent(labelValueModel.getValue());
return e;
}

With this result :



Deer Park
Mountain Stream
Mr. Water


I have removed all adapter class private attributes and usage JAXBElement,
it seems there is a problem calling a JAXB marshaller inside an adapter.
JAXB marshalling is not "reentrant" ?



2014-02-04 Jean-François HEROUARD :

> I had a similar problem, but the stacktrace was not exactly the same. This
> NPE sounds like a jaxb-impl bug of 2.2.4 version, see
> https://jaxb.java.net/2.2.6/docs/ch02.html. Version 2.2.4 is embedded by
> JBoss7.1.x, you should replace jaxb-impl with 2.2.5. Can you also check in
> your "crazy class path" project what is your version af jaxb-impl ?
> I'll try to find time to check out and run your project.
>
>
> 2014-02-03 Johnson, Shawn [USA] :
>
> Bill, thanks for the reply. Sorry for leaving out the version info ­
>> partially because I've tried 3 different configs.  Below is the stack
>> trace from JBoss AS 7.2 ­ which I left with it's included version of
>> RESTEasy 2.3.5.  I can also repeat this with
>>  3.0.6 if that's more helpful?
>>
>> [Previous message was too long for the mailing list]
>>
>>
>> Here is a link to the full stack trace using RESTEasy 2.3.5.
>> http://pastebin.com/eFiBgfYQ
>>
>>
>> Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter -
>> simple JBoss 7 + RESTEasy project
>> From: Bill Burke  - 2014-02-03 15:19
>> You'll have to point out what resteasy version you are using so I can
>> match the line numbers in you stack trace up.
>>
>>
>>
>> --
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> ___
>> Resteasy-users mailing list
>> Resteasy-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>>
>
>
--
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter - simple JBoss 7 + RESTEasy project

2014-02-04 Thread Jean-François HEROUARD
I had a similar problem, but the stacktrace was not exactly the same. This
NPE sounds like a jaxb-impl bug of 2.2.4 version, see
https://jaxb.java.net/2.2.6/docs/ch02.html. Version 2.2.4 is embedded by
JBoss7.1.x, you should replace jaxb-impl with 2.2.5. Can you also check in
your "crazy class path" project what is your version af jaxb-impl ?
I'll try to find time to check out and run your project.


2014-02-03 Johnson, Shawn [USA] :

> Bill, thanks for the reply. Sorry for leaving out the version info ­
> partially because I've tried 3 different configs.  Below is the stack
> trace from JBoss AS 7.2 ­ which I left with it's included version of
> RESTEasy 2.3.5.  I can also repeat this with
>  3.0.6 if that's more helpful?
>
> [Previous message was too long for the mailing list]
>
>
> Here is a link to the full stack trace using RESTEasy 2.3.5.
> http://pastebin.com/eFiBgfYQ
>
>
> Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter -
> simple JBoss 7 + RESTEasy project
> From: Bill Burke  - 2014-02-03 15:19
> You'll have to point out what resteasy version you are using so I can
> match the line numbers in you stack trace up.
>
>
>
> --
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
--
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] return an appropriate object based on http status code

2013-09-24 Thread Jean-François HEROUARD
Using Resteasy 3.0.4 Final, I can not get the Entity on "void" methods.

I have a @DELETE method returning "void" normally (status 200) but an
serialized Error on status 400.
Using the following catch is working if method is normally returning an
Entity :
} catch (BadRequestException e) {
Response resp = e.getResponse();
err = resp.readEntity(Error.class);
}

On delete I have a "Response is closed" error.
Debugging a little, I found that the DefaultEntityExtractorFactory reads
the Entity :
if (status >= 400)
{
   response.bufferEntity();
   response.close();
   ClientInvocation.handleErrorStatus(response);
}

So the response is closed but available in the bufferedEntity field.
But the ClientResponse.readEntity is checking :
   public  T readEntity(Class type, Type genericType, Annotation[]
anns)
   {
  abortIfClosed();
  ...

The response is closed but the entity has been buffered, so error entity
can not be got.

Is it the expected behavior ? Is there a way to get the buffered entity ?
By extending the DefaultEntityExtractorFactory ?

Thanks.




2013/8/20 Bill Burke 

> Use REsteasy 3 and the new JAX-RS 2.0 client api.  Then you just return
> a Response, check the status, and extract whatever you want.
>
> On 8/20/2013 11:42 AM, Jason Novotny wrote:
> > Hi,
> >
> > Typically I have resteasy calls like:
> >
> >   @POST
> >   @Path("/blah/restcall")
> >   ClientResponse restCall();
> >
> > Where I expect to get MyObject back-- however, the third-party API I'm
> > using will flag the response code as 500 if it turns out to be an error,
> > in which case MyObject should really be ErrorObject. Is there a way to
> > handle this case easily?
> >
> > Thanks, Jason
> >
> >
> --
> > Introducing Performance Central, a new site from SourceForge and
> > AppDynamics. Performance Central is your source for news, insights,
> > analysis and resources for efficient Application Performance Management.
> > Visit us today!
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> > ___
> > Resteasy-users mailing list
> > Resteasy-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/resteasy-users
> >
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
>
> --
> Introducing Performance Central, a new site from SourceForge and
> AppDynamics. Performance Central is your source for news, insights,
> analysis and resources for efficient Application Performance Management.
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] return an appropriate object based on http status code

2013-08-27 Thread Jean-François HEROUARD
In this case with RestEASY 2 you may also use :

try {
  proxyClient.somethingThatReturnsError500();
} catch (ClientResponseFailure ex) {
LOGGER.info(
"Got a ClientResponse exception with status [{}]",

Integer.toString(ex.getResponse().getResponseStatus().getStatusCode()));
ErrorObject err = (ErrorObject)
ex.getResponse().getEntity(ErrorObject.class);
}




2013/8/20 Bill Burke 

> Use REsteasy 3 and the new JAX-RS 2.0 client api.  Then you just return
> a Response, check the status, and extract whatever you want.
>
> On 8/20/2013 11:42 AM, Jason Novotny wrote:
> > Hi,
> >
> > Typically I have resteasy calls like:
> >
> >   @POST
> >   @Path("/blah/restcall")
> >   ClientResponse restCall();
> >
> > Where I expect to get MyObject back-- however, the third-party API I'm
> > using will flag the response code as 500 if it turns out to be an error,
> > in which case MyObject should really be ErrorObject. Is there a way to
> > handle this case easily?
> >
> > Thanks, Jason
> >
> >
> --
> > Introducing Performance Central, a new site from SourceForge and
> > AppDynamics. Performance Central is your source for news, insights,
> > analysis and resources for efficient Application Performance Management.
> > Visit us today!
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> > ___
> > Resteasy-users mailing list
> > Resteasy-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/resteasy-users
> >
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
>
> --
> Introducing Performance Central, a new site from SourceForge and
> AppDynamics. Performance Central is your source for news, insights,
> analysis and resources for efficient Application Performance Management.
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Transfer security context to EJB layer

2013-08-27 Thread Jean-François HEROUARD
I confirm it does, JAAS context is transfered during an EJB remote call.


2013/8/12 Bill Burke 

> It should transfer.
>
> On 8/12/2013 9:01 AM, Jose Miguel Barone Mattos wrote:
> > Hi!
> > I want to know if it's possible to call an ejb service that inherits the
> > security information from the web layer, when the rest service resides.
> >
> > thanks.
> >
> >
> >
> >
> >
> --
> > Get 100% visibility into Java/.NET code with AppDynamics Lite!
> > It's a free troubleshooting tool designed for production.
> > Get down to code-level detail for bottlenecks, with <2% overhead.
> > Download for free and get started troubleshooting in minutes.
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> >
> >
> >
> > ___
> > Resteasy-users mailing list
> > Resteasy-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/resteasy-users
> >
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
>
> --
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] SerializableProvider in 3.0 beta : should use MediaType.isCompatible ?

2013-03-06 Thread Jean-François HEROUARD
While playing with SerializableProvider in RestEASY beta 3 I got errors due
to a MediaType being changed to
"application/x-java-serialized-object;charset=UTF-8" by a global servlet
Spring filter. Charset is useless but I think the @Provider should use
MediaType.isCompatible instead of String equels.

Here is the modification I made :

@Provider
@Produces(SerializableProvider.MIMETYPE)
@Consumes(SerializableProvider.MIMETYPE)
public class SerializableProvider implements
MessageBodyReader, MessageBodyWriter {
/** Marshaller for Java serialized objects */
public final static String MIMETYPE =
"application/x-java-serialized-object";
/** Corresponding MediaType */
public final static MediaType MEDIATYPE = new MediaType("application",
"x-java-serialized-object");

@Override
public boolean isWriteable(Class type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
return Serializable.class.isAssignableFrom(type) &&
MEDIATYPE.isCompatible(mediaType);
}

@Override
public long getSize(Serializable t, Class type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
return -1;
}

@Override
public void writeTo(Serializable t, Class type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap httpHeaders, OutputStream
entityStream) throws IOException,
WebApplicationException {
BufferedOutputStream bos = new BufferedOutputStream(entityStream);
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(t);
oos.close();
}

@Override
public boolean isReadable(Class type, Type genericType, Annotation[]
annotations, MediaType mediaType) {
return Serializable.class.isAssignableFrom(type)
&& MEDIATYPE.isCompatible(mediaType);
}

@Override
public Serializable readFrom(Class type, Type
genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap
httpHeaders, InputStream entityStream)
throws IOException, WebApplicationException {
BufferedInputStream bis = new BufferedInputStream(entityStream);
ObjectInputStream ois = new ObjectInputStream(bis);
try {
return Serializable.class.cast(ois.readObject());
} catch (ClassNotFoundException e) {
throw new WebApplicationException(e);
}
}
}
--
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Any way to access JettisonMappedContext constructed by RESTEasy ?

2012-09-28 Thread Jean-François HEROUARD
I would do the other way : put your Jettison configuration in a JAXB
decorator (see the @Pretty in user guide). The marshaller in the decorator
processor is Jettison.

Maybe another way : do you really need the Json in the response template ?
Using the rest-js "Ajax client" you can really simply get your JSON by
javascript. And if you need it in DOM jQuery can inject it :
MainMapPageModel.JSON  could be serialized as  and
a $('#jsonify').html(jsonResponse) would do the job.

2012/9/27 Adam Walczak 

> Hi,
>
> I'm developing a website using RESTEasy and Seam REST module for
> templating support.
> (great libraries BTW)
>
> I have a method that generates an HTML page like:
>
> @GET
> @Produces({MediaType.TEXT_HTML})
> @ResponseTemplate(value=MainLayoutModel.TEMP_PATH,
> responseName="model")
> public MainMapPageModel mainMapPage() throws JAXBException {
> MainMapPageModel model = new MainMapPageModel();
> model.addLocacScript("main-map.js");
> Marshaller m = createMarshaller() // need to implement this so I
> can later to getJSON() in the template
> StringWriter sw = new StringWriter();
> m.marshal(model, sw);
> model.setJSON(sw.toString());
> return model;
> }
>
> As you see I would like to have the MainMapPageModel also available in my
> HTML as JSON so that it would be accessible to my JavaScript code.
>
> The most suitable marshaller for me would be the same one RESTEasy is
> using.
> This way the JSON in HTML would be consistent with my JSON from the REST
> API.
>
> This is why I'm searching for a way to access
> RESTEasy's JettisonMappedContext to create a marshaller.
> Does any one know any way to get it ?
> What class in RESTEasy instances it internally ?
> Maybe I could hack it.
>
> Big thanks for any help.
>
> --
> Adam Walczak
> www.adamwalczak.info
> +48 604 188 992
>
>
>
> --
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://ad.doubleclick.net/clk;258768047;13503038;j?
> http://info.appdynamics.com/FreeJavaPerformanceDownload.html
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
>
--
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


Re: [Resteasy-users] Get the produced JSON on the server side

2012-07-25 Thread Jean-François HEROUARD
Maybe look at org.jboss.resteasy.plugins.cache.server.ServerCacheInterceptor
?

"  implement a simple caching " : using already provided Resteasy JBoss
Cache, or your own based on ehcache with disk overflow is not so hard and
has great performance

2012/7/24 mickael.p...@gmail.com 

> Hi everyone,
>
> I use RESTEasy 2.3.4 to produce a JSON content from my POJOs (correctly
> annotated with @XmlRootElement, etc.). The simple case where I use @GET and
> @Produces("application/json") to return a list of objects is working fine.
>
> Now, server-side, I need to implement a simple caching mechanism. Instead
> of querying all my POJOs I want to check if a file (containing the JSON
> response) exists on my file system. If not, I would like to put the JSON
> produced content in this file.
>
> My question: how do I, server-side, get the JSON produced by RESTEasy, so
> I can have a simple String that I could write on my file system?
>
> So far, I'm trying with the Client framework (
> http://docs.jboss.org/resteasy/docs/2.3.4.Final/userguide/html/RESTEasy_Client_Framework.html)
> but I think there is a better way to do so.
>
> Thanks,
> Mickael.
>
> --
> *Mickaël Pham* | Solutions Consultant Intern @ Zuora
> Mobile: +1 (408) 646-0219 | Website: www.mickael-pham.fr
> 
>
>
>
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
>
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] RESTEasy linking resource / extending UEL with Spring

2012-04-05 Thread Jean-François HEROUARD
Here is a simple way to get RESTEasy links to resolve UEL variable as
Spring beans (supposing there is only one Spring ApplicationContext) :

@Component
public class SpringELProvider implements ELProvider,
ApplicationContextAware {

private static ApplicationContext applicationContext;

@Override
public ELContext getContext(final ELContext ctx) {
final SimpleSpringBeanELResolver elr = new
SimpleSpringBeanELResolver(applicationContext);
return new ELContext() {

@Override
public VariableMapper getVariableMapper() {
return ctx.getVariableMapper();
}

@Override
public FunctionMapper getFunctionMapper() {
return ctx.getFunctionMapper();
}

@Override
public ELResolver getELResolver() {
CompositeELResolver cer = new CompositeELResolver();
cer.add(elr);
cer.add(ctx.getELResolver());
return cer;
}
};
}

@Override
public void setApplicationContext(ApplicationContext
applicationContext) throws BeansException {
SpringELProvider.applicationContext = applicationContext;
}

}

Also add a  in the
Spring application-context to initialize the ELProvider static variable.

Maybe it could be added to documentation (Extending the UEL context - as
the Seam sample) ?
--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users


[Resteasy-users] Spring DispatcherServlet: NullPointerException due to absence ResteasyProviderFactory.getContextData(Registry.class)

2012-03-20 Thread Jean-François HEROUARD
Hello,

I have the same issue than a mail of june 2011 when using LinkDecorator
with Spring MVC :

Caused by: java.lang.NullPointerException: null
at 
org.jboss.resteasy.links.impl.RESTUtils.getServiceMethods(RESTUtils.java:85)
~[resteasy-links-2.2.0.GA.jar:na]
at 
org.jboss.resteasy.links.impl.RESTUtils.addDiscovery(RESTUtils.java:52)


I modified LinkDecorator.java to :

ResourceMethodRegistry registry = (ResourceMethodRegistry)
//ResteasyProviderFactory.getContextData(Registry.class);
ResteasyProviderFactory.getContextData(HttpServletRequest.class).getSession().getServletContext().getAttribute(Registry.class.getName());

To get registry from Http servlet context (if I understood well, then
Boostrap put it there).

But why does Registry is not known by Resteasy Spring View ?

Is it a bug ?
--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users