How to expose services in Rest? [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Please help me to understand how to expose service in REST.
Is it depends on RESOURCE or depends on the size of data ?
Example:
Let we take 2 resources (STUDENT & DEPARTMENT). Now I have an requirement of exposing "Total number of Students" and "Total number of Departments".
How should I expose a service now ?
Is it like exposing 2 different resource(api/student/total & api/department/total) ?
Or can it be do like this(api/total/student,department) since the response data will be very minimal ?
Should we consider the response size when deciding about Resources ?

It depends.
If you want a very clean interface, that sticks as strict as possible to the REST-rules, than use solution 1. I would recommend this if you expose your API to the internet for a broad audience.
If you want to optimize performance use solution 2. This would especially make sense if you know all the appications that use your API and sticking to official rules is less important.

Related

Rest API Reponse : Uppercase to camelcase [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed last year.
Improve this question
What is the Best way to convert Uppercase values to camel case.
Lets say I have API with response {"name":"VIRAT KOHLI","teams":"RCB INDIA DELHI"}
Should it be handle at DB query level or Java level (Business logic) or at Client-side like using Angular pipes. What is the best practices and what is best in terms of performance ?
At database I am using simple JDBC query.
So I don't think there's a huge difference in performance or speed.
However, if you are working with a very large amount of data, doing the conversion at the database level could add a little bit more time.
It all depends on your context but you can :
Do it by Angular using the "TitleCasePipe"(https://angular.io/api/common/TitleCasePipe#titlecasepipe)
or
avoid repetition by doing a ".map()" on the received data by putting in camelCase the concerned fields (there are a lot of examples out there).
Do it on the Business layer of your Backend just making sure to do the transformation before sending the response.
Finally do it from the database (not recommended) but you have to take into account that the code is always faster than a database query.

Rest Api design: resource archetypes, store and controller [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
i am currently in the process of looking more closely at the design of truly restful services.During my research I read something about resource archetypes at rest, four different types of archetypes come up frequently in discussion: document, collection, memory and controller. The first two I understand without any problems, but the last two I don't really understand. Can someone please give a clear explanation and example for both? Thank you.
Sure, there are four main archetypes at rest, the two that you're asking are:
Store: It'll never generate a new URI, we'll use the next URI http://api.example.com/song-management/users/{id}/playlists a user can PUT, GET and DELETE any playlist from its account but this store, the store is always managed by the client.
Controller: Are like functions, when HTTP verbs can't say the action which a resource will do, you should use this archetype. Eg. http://api.example.com/song-management/users/{id}/playlist/play will starts a playlist.
resource: https://restfulapi.net/resource-naming/

Java: small key/value persister [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I need a very lightweight and persistent key/value-store in Java.
The amount of data is very very low and it should be very simple (getter and setter and all can operate on strings).
So I think of using some small NoSQL-DB or even giving some integrated collection a serializer/deserializer to the filesystem.
But I think NoSQL is a overkill and I hope a persister also exists for such a simple requirement.
Whats the best approach here? Any ideas?
You can either implement your own thing if it is a simple key-value string. (Have a look at Java's Properties class too in case it suits your requirements).
If your requirements are slightly more complex have a look at the embedded lightweight databases you can use. Maybe BerkleyDB might work for you. There are quite a number of others if you do a bit of search.
Also think about what you actually need to do with the data. Do you need to query it (so it needs to be indexed?) or do you just want to load it back all into memory? (in which case using a simple JSON or YAML text format would also suffice.)
Most Map<String,String> can be serialized. So for example look into https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html
there you find Serializable. Under that point information to help yourself solve the Problem.

should I use distributed executors or mapreduce in hazelcast [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I need to run some calculations on a distributed map. But I cannot decide which approach to take.
My calculations will result in a map data structure. where the results will be mapped to their keys. think of it as a word count example. where word is the key and occurrence count is the value.
I have looked into both solutions and as I understand, map reduce fits best in this scenario but i want to keep things simple. and i also cannot see why this is not possible with distributed executor.
Both options are possible. Before we had the generic mapreduce framework people build solutions like this using the ExecutorService implementation.
At the moment, it'll change in the near future, the mr solution doesn't offer a way to write to an IMap directly, so all results are send to the caller first and he would have to store it then.

user defined functions vs built in function in java five relevant differences over time and space complexities [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Please explain me the differences over time and space complexities in java for user defined and predefined functions in java. examples like, linked list, list, stack class. please explain this with valid example.
thank you.
There is nothing special in predefined function over user defined. The only thing is predefined has been written by somebody else for you. It depends on algorithm.
Crap code/implementation runs in a crap way. Doesn't matter if its user created or system/API provided. example at a high level is EJBs vs Spring.
Good written code runs pretty and sleek. Again doesn't matter who the hell wrote it.

Categories