Does Spring contain something similar to BeanUtils populate method? - spring

I'm trying to populate a pojo with data from a map. I can use Apache Commons but I'm curious if Spring also has an implementation built in.
I know Spring must contain a method that does this mapping; spring integration inbound http gateways will map HTTP payloads to a POJO (request-payload-type).
Is BeanUtils the de facto standard for doing exactly what I want?

Spring Integration has this one MapToObjectTransformer and it's logic is the same as it is in the case of Spring MVC - DataBinder.
So, I suppose it would be enough just read source code of MapToObjectTransformer.

Spring also contains the BeanUtils.
Refer the following link:
org.springframework.beans.BeanUtils

Related

Spring : Auto Generate CRUD Rest Controller

Is there a way to generate spring rest crontroller for a business flow.
I want to generate CRUD services for given database object.For example, "employee_mst" , generate CRUD services code automatically.This is similar to what we used to have in hibernate or what we have in loopback.io for node. Appreciate any help around it.
I found a link that may answer your question: https://docs.spring.io/spring-data/rest/docs/current/reference/html/.
This text explains that Spring Data REST generates REST interfaces from Spring Data repositories.
I intend to try this but did not do so yet.
EDIT: I saw in my example application that Spring Data REST did what I expected. I could request all entities in my Spring Data repository using a HTTP request. The returned JSON contained also discovery information. You may prefer writing your own controller to have more control on what information is returned.

Using Spring Integration as a glue between spring beans

I have a web application with controllers, services and simple beans.
I want to use Spring Integration as a glue to link the beans. So instead of using a reference to the next bean to be called in a bean I just want to send (return) a message (e.g. a domain object) which would be the incoming parameter in the method signature of the next bean.
Is it a good idea to use Spring Integration for this? Would SI degrade the performance?
Thanks,
V.
Please, read the Reference Manual (http://projects.spring.io/spring-integration/) and other resources before asking similar questions. Spring Integration isn't a glue.
It's an Enterprise Integration Patterns implementation Framework. Even if it can do what you are asking, its purpose is much farther.
I'd say such a requirements may be addressed just with the raw ApplicationEvent model.

Register Jackson with wink using spring integration

I have developed a small RESTful web service using apache wink. I am using the spring integration module and define my rest services there. I am trying to add JSON support and have run into a small bug. When I try to return a java list with only 1 element in it, wink returns just the object instead of an array with 1 object in it. It seems this is a bug with the default JSON providers that come with wink.
So I have attempted to use Jackson as the wink JSON provider. I have found documentation of how to define a WinkApplication and set Jackson as the provider. This never gets used in my app and I believe it's because the winkCoreContext-server.xml file defines a Registrar instead of using the Application I defined.
Can anyone point me to some documentation or an example of how to use Jackson together with the spring integration module of Apache Wink?
I finally found a post that answered my question:
http://agoodexample.tumblr.com/
I needed to extend the wink-spring-integration Registrar class and add a setter for singletons then load my jackson provider through a reference.

Spring mvc - get data from other server, what object to use and how to reuse it?

I have some url that I need to read data from there and use it in my controller.
Usually in java application I use http client, to get data from some url.
My questions are:
What object to use in spring mvc to get data from some url (like http client) ?
How to reuse this objects, so every time not to create it ?
Thank you!
In agreement with the comment by #Evgeny and #Beau above, you can use any client library you like. HttpClient is VERY bean friendly and, for cases where it might be difficult to construct the configuration, you can always provide a Spring factory bean to construct the object.
If you are looking to abstract away the plumbing of the HttpClient API usage, utilize the RestTemplate suggested by #Evgeny (I believe that it is also his brainchild) It is a VERY rich and simple API to leverage.

A heavily customized Spring Web application and the dispatcher servlet

We have a web application that uses spring, struts and camel right now and there is a lot of customization we have done to allow us to know when beans are added to the context.
So, we have gotten to a point where we would like to remove struts from the application, because we are only using it to handle actions and we figure we could either use spring or camel to do the same thing. So I was able to get it to work with camel/velocity, but we didn't like how we really couldn't use the request object directly in the jsp (afaik, you have to put everything in the header of the Exchange and in the jsp you would do ${header.someReqVariableName}).
So we wanted to go the spring route, but since we load the context.xml directly, we have a provider that extends ContextSingletonBeanFactoryLocator and we pass the xml file name as a param, we haven't been able to figure out how to get the DispatcherServlet to work without giving it another configuration xml.
Is there a way to either:
Have camel use jsp for processing a jsp (and have all the usage of jsp tags)?
or
Have spring to see that a context has already been loaded and use that instead of having another new one?
or
Something better I have thought up?
You can use camel-jetty to expose HTTP endpoints, but I wouldn't use it for any complex web app development (JPS, etc). I'd use use Spring MVC (or similar) and use Camel for any complex routing/messaging requirements...
Here is another way, you can use the producer template to send the request to the camel context if you can get the reference of the camel context from the spring.

Resources