I am shifting my applications to cloud foundry. I have pushed my front end as an html app and my backend REST services provider as a Java app. Now, I want to make HTTP calls to my backend java app from my html app. I know I can hardcode java app's url, but what is the best practice here? I can't seem to find anything after considerable world wide web search.
Best practice is to use a dedicated directory service like Eureka to discover your backend Java app. Chris Richardson provides a good overview here:
http://microservices.io/patterns/client-side-discovery.html
Spring Boot/Spring Cloud make it extremely easy to a Eureka server up and running, and for your Java app to register with the server:
http://cloud.spring.io/spring-cloud-netflix/
For your HTML app, you will want to use a Javascript client library to access your directory service, like this one:
https://www.npmjs.com/package/eureka-js-client
Related
I am working on a mobile application and require following feature-
When Admin App user changes status on the admin app, the user on the client app must get it updated in real-time (as we generally see in real-time delivery apps which show status of delivery). The backend is handled using Spring-boot application.
I am familiar with the concept of Web Sockets and how to use them on mobile applications. But I am not familiar with the Web Socket configuration on the backend (Spring Boot Application).
I saw several articles related to simple chatting web applications but couldn't find much about such a scenario. Can anybody suggest how can I implement this on the backend, how exactly Web Socket APIs can be developed using Spring Boot and how the complete flow of data from one mobile to another mobile can be achieved?
A full description of how to do this is, in my opinion, beyond the scope of a SO answer, so I'll provide some links to resources you can use to build the knowledge instead:
Spring WebSockets reference docs
Example of a WebSockets app
Baeldung tutorial
I'm going to start developing a new simple "X management" kind app, like contact management or events management. What I want to know is which tools would be the best to achieve it in the way I want.
My app needs to be a web app running on a server that has a mysql database to save and retrieve some simple information. This app must have a web client but I want it to be able to be extended to work with an Android app client.
Things I've thought:
I've worked on Java with facelets and JPA travels management app running on a GlassFish server on localhost with a JSF web view, so maybe my web client and the full app could be done with this.
I've worked with web services such as SOAP and REST with Jaxb and xml schemes to retrieve information parsing some webs into xml or json to show on a client .net app. So I've thought I can add to my app, like last topic we talked about, a REST web service layer to easily work as I want, or at least I think it would be easy. If I do this the Android app could share the same app core code but using the REST service.
My question is what could be the best way to do an app with 2 client side in different platforms that could share some code to be easy to extend it moreover to a desktop app. I've talked about these 2 options because I'm a students of computers at university and those are the tools I know, but I can easy learn more. I've also think about just a REST service and create a web and an Android client to work on same service or something like that.
This post is getting long, so here is the summary: What technologies and tools do you think are the best choice to create an java web app that needs to have web and Android client? Also what server, like tomcat, GlassFish or another, should I use? And what about persistence layer? JPA with mysql is the best I know to work with.
Thanks a lot.
P.D: I work with eclipse
From my point of view:
You can use java jersey and java spring both ( java spring as Dependency injection) for creating RESTful Web service. So, In server side you will create endpoint and you can access data from any platform through those endpoint.
Server can be anyone. It's up to you. I always try to use tomcat but tomcat is not a full JavaEE container it's only a servlet container. So if you want to use full JavaEE version then you should use Glassfish.
And yes JPA .It can be easily used in any environment supporting JPA including Java SE applications, Java EE application servers, Enterprise OSGi containers etc.
On the other hand, still choice is yours.
I'm planning to build a two-tier application, with a back-end (java, possibly spring MVC) which delivers JSON up to a front-end (PHP, Drupal7). I only want the front-end application exposed to the outside world and in a traditional environment I would probably stick the back-end on some ports inside the firewall (assuming both parts run within the FW).
Is this possible to do in the Google App Engine environment?
It's not possible to run GAE inside your firewall. It runs on Google's servers.
You can do basic things like blocking IPs but its not really necessary. Since your 'front end' has the php backend you can call from there your appengine with a secret parameter (as in "myapp.appspot.com?key=sE34sdJSjUy" ) Its very simple security and since no one can see that url (in your php backend), its as good as any other authentication method.
Here is the background of my situation:
I want to create an iPad application that interacts with a oracle SQL database. I have existing Java code from my Flex application that handles all the database requests, and modifications using the Spring Framework. The Flex Application ran as a web service through TomCat. Now I want to make that flex application into a mobile iPad version. I am having trouble figuring out what is the easiest way to use existing Java code and use it for the iPad because the iPad interacts using URL requests instead of direct with the Java.
My question is, can I use the existing Java code with the Spring framework to save time from coding all the back-end handling? Basically I want to access all the classes from my Java code by doing Requests from the iPad. Is this possible and will I need JSON or XML to interact between the iPad and the Java code?
Summary:
Can I use
iPad Objective-C <-----> Java (with spring framework) on TomCat Web Service to handle oracle SQL data handeling? If so, how and what technologies do I need? Will I need JSON or XML and how does that factor between the iPad and Java?
Thanks!
A good approach would be to design your app to communicate with RESTful services that return JSON. Once this is done your iPad app doesn't have to even know that the server code is written in Java.. it's just interacting over HTTP.
Here's a good tutorial on setting up your tomcat to host your RESTful services: http://www.vogella.com/articles/REST/article.html - I've used this for an app I'm developing. Spring isn't even necessary.
You could go XML, but JSON is just easier in my opinion. Here's a good blog outlining the good and bad of both sides. http://digitalbazaar.com/2010/11/22/json-vs-xml/
OK, I'm making the following presumptions.
Your flex application runs on a different machine from the Tomcat
server
Your flex application makes web service calls to the Tomcat server
So, the flex application doesn't know the underlying technology that provides the web services. It's just seeing/consuming the output
There's no reason why the iPad app can't do the same thing. There's no reason why it can't use the same web services that the Flex application uses. It could consume the same messages (Assuming it can handle the request/response format currently employed by the Flex application).
You can make changes if you like if you want to change the structure of the requests/responses between the clients. But the clients don't know (nor care) how the web services are implemented. They are just requesting and consuming info.
I currently have a full java web application stack (J2EE web app using Spring and Hibernate with a RIA client using dojo).
I have to move technology stacks for the UI to be asp.net but am allowed to keep the server components in java.
Any ideas on best practice here - and yes, I have to adopt this hybrid tech stack.
Initial thoughts are:
asp.net ajax (possibly using asp.net MVC) to provide the UI and a thin control layer in IIS.
expose current java web app (residing on a remote machine) as RESTful web services (the web app would remain in a J2EE serlet container such as Tomcat or Jetty). The new control layer would provide security (authentication and authorisation), comet server push abilities and then basic request passthrough to the web app.
Basically, I am unsure 'how much' C# I should write in the control layer and how best to expose and communicate with the existing java web app. Also, currently, I use JSON as the data interchange format.
I would suggest you start moving to asp.net feature by feature, don't try to implement everything at once.