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

  • Home
  • SEARCH
  • 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 8333561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:04:39+00:00 2026-06-09T03:04:39+00:00

I have a library which returns a webservice client. Client c = Clientlib.getclient(); Now

  • 0

I have a library which returns a webservice client.

Client c = Clientlib.getclient();

Now what I did was I created a wrapper on top of it:

public class Myclient {

 private static Client c = ClientLib.getClient(); 
 private static instance = new MyClient();

 public static MyClient getInstance(){
  return instance;
 } 

 private Myclient(){
   //singleton
 }

 public Data getDate(Sting id){
  Data1 d1 = cleint.getData();
  convert d1 to Data and return data
 } 
}

Is this the correct way to do this? Should I create only once instance of Client?

Will I have some problem with this approach? What if two threads call the getData method
at the same time. This situation is likely as this is a web based app.

What if the connection to the server goes off and comes back? I dont think it should be a problem as http is stateless.

  • 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-09T03:04:40+00:00Added an answer on June 9, 2026 at 3:04 am

    Generally I think a wrapper is a good idea. You can rebuild the classes from the webservice without affecting the rest of you code. Also allows you to do other things like caching, security etc.

    If you intend on MyClient to be a singleton, then Client c doesn’t need to be static. Not a huge thing but worth noting.

    Whether there are threading issues depends on the implementation of ClientLib.getClient(). You might need to do some reading to find out if you are allowed to access it in a multithreaded way or whether you should be proving synchronization. By wrapping the client though, you can easily synchronize the access in one place. Generally a webservice should be accessible from multiple threads, it’s just a call over http.

    Only other thing I can suggest is the addition of an interface over MyClient just to decouple anything that uses this class. Makes it a little easier for testing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a library which has a basic class which is used extensively by
I have created a library which reads the app.config file and gets the type
I have a ASP.NET (C#) web page which utilizes a VB class library. The
Situation is following. I have shared library, which contains class definition - QueueClass :
I have a library which returns a hierarchical list composed of IDictionary, IList and
I have a C# library which has 2 methods. One returns an Integer and
I have a class, with a function which returns a count, like this: class
I have been looking underscore.js library functions and I noticed a function which returns
I have a GPS class which returns the current GPS coordinates to the calling
I have a javascript library which does returns a list of results to a

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.