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 378931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:50:33+00:00 2026-05-12T14:50:33+00:00

I am running a service A which has a class X . I am

  • 0

I am running a service A which has a class X. I am going to deploy another service B on same machine which is using this class X. How can I make sure that the same instance of service A is reused instead of another.

PS:Service written in JAVA.

Adding: Both these services are Axis2 services. Service B is hot-deployed. Service B used class Y which is extension of class X.

  • 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-05-12T14:50:34+00:00Added an answer on May 12, 2026 at 2:50 pm

    Could we try to distinguish classes, objects and services.

    You have something like this?

    @javax.jws.WebService
    public class ServiceAAA{
    
        public String echo(String arg) {
            // some really nice code here     
        }
    
    }
    

    and you want to add

    @javax.jws.WebService
    public class ServiceBBB{
        public String superEcho(String arg) {
            // even more code here
            // which needs to reuse the code from A's echo()     
        }   
    }
    

    So clearly we don’t want to cut and paste between the two implementations. How do we reuse?

    Alternative 1:

    Directly call A from B. You are asking how to do that. It could be done. You would just code a JAX-WS client call in your implmentation. However I stringly recommend against this. A service call is likely to be more expensive than a simple Java call.

    Only do this if y6ou don’t have the option of deploying the two service classes together.

    Alternative 2:

    Refactor the implementation. Just move the code into a worker class.

    @javax.jws.WebService
    public class ServiceAAA{

        MyWorker worker = new Worker();
        public String echo(String arg) {
            return worker.doSomething(arg) ;      
        }
    
    }
    

    @javax.jws.WebService
    public class ServiceBBB{

        MyWorker worker = new Worker();
        public String superEcho(String arg) {
            worker.doSomething(arg) ;  
            // and some morestuff             
        }    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an importer process which is running as a windows service (debug mode
We're currently running an svnserve instance as NT service. While this works, it's needlessly
I have a background Service which must run permanently. The service just has to
I've set up a simple, single-service server which has been working just fine with
I have a WCF service running on the IIS with a ServiceHostFactory. It's running
Context: I'm in charge of running a service written in .NET. Proprietary application. It
My application is implemented as a service (running under services.exe). I am adding a
I have a wcf application hosted in a windows service running a local windows
How do you automatically start a service after running an install from a Visual
How do I determine what account a service is running as from within 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.