Java Restful Web Service - Static Member Variables

user2906488

I'm creating a web service and I need to map a bunch of String names to set of database names. That is, a request will arrive with a data item, and I need to figure out which database it maps to.

To create this mapping, I need to query the database also, preferably only once. I want to be able to access this mapping whenever requests come in and not have to construct my map on each request. What I don't want, is to have to query the database 10 times every 10 seconds, which is potentially what could happen, in this case.

I considered storing the map as a static member variable upon the first request. So my question is - are there any known issues with having this map as static and sharing across requests?

Elemental

As long as you only fill this static structure at startup (and don't expect it to change during the lifetime of the service) there are no issues with this. Specifically the only situations where this might be a problem are:

  • If the map is very big and it doesn't make sense to include hold all of it in memory
  • If the map is changing often

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Use threads on a RESTful Web Service in Java

From Dev

How to expose a cxf restful web service in java?

From Dev

Deploy Java restful web service to live server

From Dev

How to expose a cxf restful web service in java?

From Dev

How to test a restful web service in java

From Dev

how to consume a Restful Web Service (Restful API) in Java

From Dev

Static member variables

From Dev

Hosting restful web service in java on a real web server?

From Dev

Restful Web Service Error

From Dev

RESTful web service - HATEOAS

From Dev

State in Restful web service

From Dev

SQLite for a RESTful web service

From Dev

Client in REstful web service

From Dev

About RESTful web service

From Dev

State in Restful web service

From Dev

RESTFUL Web Service - List

From Dev

ColdFusion RESTful web service

From Dev

RESTful Web service json responses return null in java

From Dev

java Restful web service get the data from textbox in POST action

From Dev

restful web-service - I get java.lang.IncompatibleClassChangeError

From Dev

How to enable CORS with a java restful web service on JBoss AS

From Dev

Java Restful Web Service running only Android 4.4 Mobile not other

From Dev

Java Restful Web Service running only Android 4.4 Mobile not other

From Dev

restful web-service - I get java.lang.IncompatibleClassChangeError

From Dev

What's the equivalent of Jersey Restful web service(Java) in C#?

From Dev

How to enable CORS with a java restful web service on JBoss AS

From Dev

Java , how can i get JSON from restful(?) web service

From Dev

create new record into DB using java RESTful web service

From Dev

java - how to send images from a RESTful web service?

Related Related

HotTag

Archive