I am creating a web application with a Java back end. I intend to house this on Amazon Web Services.
Ideally, in the future, I would like to create a Native Android application that carries the same functionality as the web app.
How can I implement my current application so that the Native App and Web App can both use the same back end database and services?
I have been reading about Service Orientated Architecture, is this the correct approach?
Service Orientated Architecture (SOA) is an approach that has been around for a while and could certainly meet your requirements. However I would caution you that you are going to run into lots of "Enterprise" designs as you search for information about SOA that will really be overkill for the type of development you are doing.
In general I would simply recommend that you focus on the following:
Keep your UI (HTML/JS/CSS) in a separate project from the Java back end. This practice will force you to keep the UI and back end concerns separate.
Have your back end expose an API that sends and receives JSON via HTTP/HTTPS.
Make your back end services stateless. Using JSON web tokens for authentication is a good way to accomplish this (I like using Auth0 for this). In other words don't rely on an HTTP session to track your users from within your Java code. This has the added benefit of making your application really easy to scale.
If you do these things then when it comes time to build the Android app you wont have to touch the back end at all. You will just have to implement the UI again in native Android.
Since you tagged this question with AWS I assume you plan to implement your back end on AWS. If so, I would highly recommend you look into using Amazon's API Gateway service. This service would sit between your UI layer and your back end. This provides several advantages such as rate limiting and caching to secure your API from DDOS attacks, an optional API key for added security, and API versioning to help you deploy new versions of your API without breaking existing clients. Also, by defining your API using the API Gateway service you can then generate an SDK for your API for use in JavaScript, Android and iOS.
Another big advantage of using API Gateway is that it allows you to break up your back end into separate servers, Lambda functions, etc. This allows for great flexibility, and I can't stress enough how the ability to use AWS Lambda in your back end will reduce administrative work as well as hosting costs. This enables you to start thinking about your back end in terms of Microservices.
Related
Application insights can used to monitor custom application events (such as calls, exceptions, durations etc).
The documentation gives SDKs for .net, and an agent for java. https://learn.microsoft.com/en-us/azure/azure-monitor/app/platforms
We are using java, but its hosting by Adobe (its their cloud CMS called AEM), so we cant run or install any agent. We can include java libraries, and cam make rest calls going out.
The question is, does AI have any sort of rest API to get application monitoring data into AI? Azure as a whole has one (e.g. for querying resource groups) https://learn.microsoft.com/en-us/rest/api/azure/
NOTE: this is not to query AI data, there is a specific API for that, we need an API to write the event and telemetry data into it.
I don't think it is officially published (REST API for ingestion).
At the same time the wire protocol is used by both all SDKs and by many customers who decided to use REST API directly. So, essentially REST API will not change.
One way is to build an app using agent, sniff wire protocol using Fiddler (or similar tool) and then use it as REST API.
Beware that Application Insights SDKs (and agents) take care of many things - starting from auto collection, calculating standard metrics and finishing with proper backoff logic/retries/etc.
On top of it Application Insights SDKs support two channels - Standard and Real-time (Live Metrics/Diagnostics). Implementing the second channel might be quite tricky.
Can I use Java backend for a browser game with Javascript frontend?
Since I already have knowledge in Java aswell as Javascript I was confused if I should forget Java for this purpose and skip to NodeJS for the backend, although I want to focus on Java in my future.
Would I need to learn Java Servlets and JSP or would a book aboout Java Networking be enough to deal with communication, or are both required since Servlet are part of a webapplication running on a web container, and Java Networking is not standalone.
You can! The choice of your technology stack for the frontend does not necessarily need to influence the choice of your backend technology (and vice versa).
Architecture
You can serve your game view directly from your java application. You could use JSP (or other templating solutions) for visual representation and/or include more logic via javascript.
You could also go for a more distributed approach, where your frontend would only be responsible for fetching and displaying the game state, while your backend would be responsible for serving and maintaining the game state. Your frontend could then inquire about and ask to modify the game state via http, and the backend might answer with the current game state represented as, for example, JSON.
Technologies
While reading about Servlets and JSP or basic networking can be of some value in itself; For this specific purpose, I'd rather look into some options to get you started more quickly. You might find using an established, modern framework easier - Since you're familiar with Java and want to focus that, I'd point you towards Spring Boot 2. Getting a web application running that accepts and serves JSON via an http endpoint can be done quite quickly. In my experience, it's well adopted in the industry as well, so you might benefit from that, too.
You are, however, free to chose in what language or framework to implement your backend: A server written in NodeJS any other language can be used for the same purpose, as long as you know how frontend and backend are going to communicate.
Is it correct that Android application which communicates with external database (somewhere on the server), requires web service (e.g. java web service)?
Is that web service an actual back end application which directly communicate with the DB?
Is this service, I am talking about, the same thing what AWS or google cloud offers, or am I messing it up?
Cloud providers can provide you computers and other hardware to run your back end server on and in some cases can provide you some or all of the services you need in your back end, obviously depending on what your app actually needs to do.
For example, AWS provides identify verification services, streaming recording backend services, notifications etc. You still need to do work to integrate your app with them but they do a lot of the heavy lifting for you.
Deciding whether to use the services or just the HW with your own services built on top is an architectural and business decision really.
You may want to balance ease of integration against vendor lock in (i.e. being tied to a single cloud provider to run your back end).
Personally, I like architectures that can be ported between cloud providers - you can still build on non cloud provider 3rd party service building block software if you want.
Having said that, AWS and Google have almost certainly put a lot of effort and thought into making their service building blocks easy to integrate and scalable so you may find their ecosystems work for you.
This is a very beginner question. I have tried to search for advice but am overwhelmed by the amount of information and would like some help with ideas on approaches to server design or what to search for!
What I would like to set up is a backend server that provides search capabilities and business logic and validation across some fairly basic data. It wont get too large.
I would then like to be able to plug in a website as a front end or a mobile app or a facebook app or even a desktop app..
My question is what is the best way for front ends to hook into the backend? I would like to have various user accounts with permission levels so authorisation would be important.
I generally only code as a hobby so whilst technically I have built a spring based website before the exact semantics of the client server relationship weren't clear to me. Now I want to separate the backend so that is is agnostic of how the data is displayed or entered completely and can run on a separate machine.
Thanks,
Rob
There is a ton on options. I had good expirience with apache CXF rest services (logic encapsulated in java beans, spring configuration) and pico web remoting ( more exotic,
but also rest service and plain java objects providing business logic)
if you ar already using spring, I would recommend to stick with CXF - it integtrates seamlesly ( and is spring configured itself )
I'm creating an android application. Most of the functionality will be done offline, however I need to build some dependency between users of the application, such as being able to see peoples "high scores" and to communicate between users, and sending each other in-app messages.
Therefore, I'll need a webserver which the app can connect to in order to store such information. I imagine the app will make REST calls to get high scores.
I'm trying to avoid the overhead of having to create a fully functional web application (SpringMVC for example). Is there any application that makes this simpler?
What is a good, simple web stack I could use for this?
We use the Java RESTlet framework for creating RESTful interfaces for our mobile apps, and deploy via Google AppEngine. I shared a series of screencasts on YouTube demonstrating this approach that you might find useful. The RESTlet framework used in the screencasts is a few versions old, but this should help you get up to speed fairly quickly. We like this particular approach because it's straightforward for Android developers (who are already proficient in Java), scales well, and its free until you hit Google's quotas.