Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8147665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:25:30+00:00 2026-06-06T14:25:30+00:00

I have a restfull webservice that requires loading trained model files and to create

  • 0

I have a restfull webservice that requires loading trained model files and to create some other objects and it takes lots of time. Therefore I need to do this only once (when starting the webservice). Currently the system loads trained files and some other objects at each webservice call and it is costly. Can you please tell me how to handle this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:25:31+00:00Added an answer on June 6, 2026 at 2:25 pm

    You could use the Singleton pattern. It is used to make sure that certain resources are created only once. So basically, you could have one class whose purpose is to instantiate these files and have the webservices call this class, something like so (taken from Wikipedia):

    public class Singleton {
        private static volatile Singleton instance = null;
        private static File file1;
        ... 
    
    
        private Singleton() 
        {  
            //Load whatever you need here.
        }
    
        public static Singleton getInstance() {
                if (instance == null) {
                        synchronized (Singleton.class)
                                if (instance == null) {
                                        instance = new Singleton();
                                }
                }
                return instance;
        }
    
       ...
       //Other getter and setters for your files and other objects
    

    }

    Then, in your webservice you could do something like so:

    ...
    Singleton.getInstance().getSomeFile();
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Scala application that relies on an external RESTful webservice for some
I have a web service site that is restful enabled, so other websites/ajax script
I have a restful webservice which receives some structured data which is put straight
I have a RestFull grails api that i expose through grails Controller. I need
With a PHP MVC project, I have a few model classes that load data
I am using a RESTfull webservice with this methode: @POST @Consumes({application/json}) @Path(create/) public void
I have a Java RESTful webservice that will be called about every 10 seconds
I want to create a webservice that allows users to enter the longitude and
I am writing a webservice that allows users to post files and then retrieve
We have a RESTFul webservice that returns a list of persons. /person/list However, the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.