This is an automated email from the ASF dual-hosted git repository.

yasith pushed a commit to branch service-layer-improvements
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/service-layer-improvements by 
this push:
     new 9d2bf481d0 handoff lifecycle mgmt of AdaptorSupport, MessagingFactory, 
and scheduled tasks to spring and DI
9d2bf481d0 is described below

commit 9d2bf481d0be9992c9334b2c9868d09c39960d71
Author: yasithdev <[email protected]>
AuthorDate: Tue Dec 16 09:37:59 2025 -0600

    handoff lifecycle mgmt of AdaptorSupport, MessagingFactory, and scheduled 
tasks to spring and DI
---
 ...al_instantiations_to_spring_di_10161db7.plan.md | 66 ++++++++++++++++++++++
 .../helix/core/support/TaskHelperImpl.java         | 15 ++++-
 .../airavata/helix/impl/task/AiravataTask.java     |  7 ++-
 .../helix/impl/workflow/PreWorkflowManager.java    |  8 ++-
 .../helix/impl/workflow/WorkflowManager.java       | 11 +++-
 .../airavata/messaging/core/MessagingFactory.java  | 52 ++++++-----------
 .../messaging/core/stats/CountWriterTask.java      |  6 +-
 .../messaging/core/stats/LatencyWriterTask.java    |  6 +-
 .../airavata/messaging/core/stats/StatCounter.java | 24 +++++---
 .../airavata/metascheduler/core/utils/Utils.java   | 42 +++++++-------
 .../metadata/analyzer/DataInterpreterService.java  | 26 ++++++---
 .../metadata/analyzer/impl/DataAnalyzerImpl.java   | 10 +---
 .../rescheduler/ProcessReschedulingService.java    | 22 ++++++--
 .../engine/rescheduler/ProcessScannerImpl.java     | 12 ++--
 .../ComputationalResourceMonitoringService.java    | 28 +++++++--
 .../compute/job/ComputeResourceMonitor.java        |  8 ++-
 .../monitor/compute/job/MonitoringJob.java         | 17 +++++-
 .../orchestrator/job/GFACPassiveJobSubmitter.java  | 11 +++-
 .../profile/repositories/AbstractRepository.java   |  5 ++
 .../apache/airavata/profile/utils/JPAUtils.java    | 10 ++++
 .../messaging/RegistryServiceDBEventHandler.java   |  7 ++-
 .../RegistryServiceDBEventMessagingFactory.java    | 32 +++++------
 .../apache/airavata/service/AiravataService.java   | 22 +++++---
 .../experiment/impl/ExperimentServiceImpl.java     |  6 +-
 .../service/orchestrator/OrchestratorService.java  |  9 ++-
 .../messaging/SharingServiceDBEventHandler.java    |  8 ++-
 .../SharingServiceDBEventMessagingFactory.java     | 30 +++++-----
 .../sharing/repositories/AbstractRepository.java   |  5 ++
 .../apache/airavata/sharing/utils/JPAUtils.java    | 10 ++++
 .../file/server/FileServerConfiguration.java       | 11 +++-
 .../thriftapi/handler/RegistryServiceHandler.java  |  8 ---
 .../server/OrchestratorServiceServer.java          | 11 ++--
 .../thriftapi/server/RegistryServiceServer.java    |  7 ++-
 .../thriftapi/server/SharingRegistryServer.java    |  9 ++-
 34 files changed, 371 insertions(+), 190 deletions(-)

diff --git 
a/.cursor/plans/migrate_manual_instantiations_to_spring_di_10161db7.plan.md 
b/.cursor/plans/migrate_manual_instantiations_to_spring_di_10161db7.plan.md
new file mode 100644
index 0000000000..a9a5d60153
--- /dev/null
+++ b/.cursor/plans/migrate_manual_instantiations_to_spring_di_10161db7.plan.md
@@ -0,0 +1,66 @@
+---
+name: Migrate Manual Instantiations to Spring DI
+overview: Refactor manual instantiation of services (specifically 
ComputationalResourceMonitoringService) and repositories to use Spring 
Dependency Injection, and identify legacy JPA usage.
+todos:
+  - id: refactor-jobs
+    content: Refactor ComputeResourceMonitor and MonitoringJob to support DI
+    status: completed
+  - id: refactor-monitor-service
+    content: Refactor ComputationalResourceMonitoringService to be a Spring 
Bean
+    status: completed
+  - id: update-orch-server
+    content: Update OrchestratorServiceServer to inject MonitoringService
+    status: completed
+    dependencies:
+      - refactor-monitor-service
+---
+
+# Migrate Manual Instantiations to Spring DI
+
+This plan addresses the legacy manual instantiation of services and 
repositories in the Airavata codebase, specifically focusing on 
`OrchestratorServiceServer` and the `ComputationalResourceMonitoringService`. 
It also identifies legacy `JPAUtils` usage in abstract repositories.
+
+## Identified Issues
+
+1.  **OrchestratorServiceServer**: Manually instantiates 
`ComputationalResourceMonitoringService` using `new`.
+2.  **ComputationalResourceMonitoringService**: Manually creates 
`SchedulerFactoryBean` and fails to support Spring injection for Quartz jobs 
(`MonitoringJob`), leading to potential runtime errors or hacky workarounds.
+3.  **AbstractRepository (Sharing/Profile)**: Uses static 
`JPAUtils.getEntityManagerFactory()`, a legacy pattern. While most leaf 
repositories are now `JpaRepository` interfaces, the base classes remain and 
should be deprecated or refactored if still in use.
+
+## Proposed Changes
+
+### 1. Refactor `ComputeResourceMonitor` and `MonitoringJob`
+
+Enable Spring DI for Quartz jobs.
+
+-   
**[airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/ComputeResourceMonitor.java](airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/ComputeResourceMonitor.java)**:
+    -   Add no-arg constructor.
+    -   Annotate `registryService` with `@Autowired` (or use setter injection) 
to allow Spring to inject it when instantiated via a Spring-aware JobFactory.
+-   
**[airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/MonitoringJob.java](airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/MonitoringJob.java)**:
+    -   Add no-arg constructor.
+
+### 2. Refactor `ComputationalResourceMonitoringService`
+
+Convert to a proper Spring Service.
+
+-   
**[airavata-api/src/main/java/org/apache/airavata/monitor/compute/ComputationalResourceMonitoringService.java](airavata-api/src/main/java/org/apache/airavata/monitor/compute/ComputationalResourceMonitoringService.java)**:
+    -   Annotate with `@Service`.
+    -   Inject `RegistryService` via constructor.
+    -   Inject `Scheduler` (or `SchedulerFactoryBean`) instead of manually 
instantiating `SchedulerFactoryBean`.
+    -   Configure the Scheduler to use `SpringBeanJobFactory` (or ensure the 
injected one does) so `MonitoringJob` gets its dependencies.
+
+### 3. Update `OrchestratorServiceServer`
+
+Remove manual instantiation.
+
+-   
**[modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/OrchestratorServiceServer.java](modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/OrchestratorServiceServer.java)**:
+    -   Inject `ComputationalResourceMonitoringService` via constructor.
+    -   Remove `new ComputationalResourceMonitoringService(...)` call.
+    -   Remove static `monitoringService` field and use the injected instance.
+
+### 4. Cleanup/Deprecation (Optional but Recommended)
+
+-   Identify and mark 
`org.apache.airavata.sharing.repositories.AbstractRepository` and 
`org.apache.airavata.profile.repositories.AbstractRepository` as deprecated if 
they are no longer used by active repositories (which appear to be 
`JpaRepository` interfaces now).
+
+## Verification
+
+-   Verify `OrchestratorServiceServer` starts up correctly.
+-   Verify `MonitoringJob` can be triggered and has `registryService` injected.
\ No newline at end of file
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/helix/core/support/TaskHelperImpl.java
 
b/airavata-api/src/main/java/org/apache/airavata/helix/core/support/TaskHelperImpl.java
index f598bbc6b1..cee3c4e229 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/helix/core/support/TaskHelperImpl.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/helix/core/support/TaskHelperImpl.java
@@ -19,8 +19,9 @@
 */
 package org.apache.airavata.helix.core.support;
 
-import org.apache.airavata.helix.core.support.adaptor.AdaptorSupportImpl;
 import org.apache.airavata.helix.task.api.TaskHelper;
+import org.apache.airavata.helix.task.api.support.AdaptorSupport;
+import org.springframework.stereotype.Component;
 
 /**
  * TODO: Class level comments please
@@ -28,9 +29,17 @@ import org.apache.airavata.helix.task.api.TaskHelper;
  * @author dimuthu
  * @since 1.0.0-SNAPSHOT
  */
+@Component
 public class TaskHelperImpl implements TaskHelper {
 
-    public AdaptorSupportImpl getAdaptorSupport() {
-        return AdaptorSupportImpl.getInstance();
+    private final AdaptorSupport adaptorSupport;
+
+    public TaskHelperImpl(AdaptorSupport adaptorSupport) {
+        this.adaptorSupport = adaptorSupport;
+    }
+
+    @Override
+    public AdaptorSupport getAdaptorSupport() {
+        return adaptorSupport;
     }
 }
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/AiravataTask.java
 
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/AiravataTask.java
index b9e2a70407..ab045ae9ad 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/AiravataTask.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/task/AiravataTask.java
@@ -86,17 +86,20 @@ public abstract class AiravataTask extends AbstractTask {
     protected final RegistryService registryService;
     private final UserProfileService userProfileService;
     private final CredentialStoreService credentialStoreService;
+    private final MessagingFactory messagingFactory;
     private final ObjectMapper objectMapper = new ObjectMapper();
 
     public AiravataTask(
             ApplicationContext applicationContext,
             RegistryService registryService,
             UserProfileService userProfileService,
-            CredentialStoreService credentialStoreService) {
+            CredentialStoreService credentialStoreService,
+            MessagingFactory messagingFactory) {
         this.applicationContext = applicationContext;
         this.registryService = registryService;
         this.userProfileService = userProfileService;
         this.credentialStoreService = credentialStoreService;
+        this.messagingFactory = messagingFactory;
     }
 
     protected ApplicationContext getApplicationContext() {
@@ -502,7 +505,7 @@ public abstract class AiravataTask extends AbstractTask {
         if (statusPublisher == null) {
             synchronized (RabbitMQPublisher.class) {
                 if (statusPublisher == null) {
-                    statusPublisher = 
MessagingFactory.getPublisher(Type.STATUS);
+                    statusPublisher = 
messagingFactory.getPublisher(Type.STATUS);
                 }
             }
         }
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java
 
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java
index 60c29b5f14..3e1798ffba 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java
@@ -73,6 +73,7 @@ public class PreWorkflowManager extends WorkflowManager {
     private final org.apache.airavata.service.registry.RegistryService 
registryService;
     private final org.apache.airavata.service.profile.UserProfileService 
userProfileService;
     private final org.apache.airavata.service.security.CredentialStoreService 
credentialStoreService;
+    private final MessagingFactory messagingFactory;
     private Subscriber subscriber;
 
     public PreWorkflowManager(
@@ -81,9 +82,10 @@ public class PreWorkflowManager extends WorkflowManager {
             org.springframework.context.ApplicationContext applicationContext,
             org.apache.airavata.service.registry.RegistryService 
registryService,
             org.apache.airavata.service.profile.UserProfileService 
userProfileService,
-            org.apache.airavata.service.security.CredentialStoreService 
credentialStoreService) {
+            org.apache.airavata.service.security.CredentialStoreService 
credentialStoreService,
+            MessagingFactory messagingFactory) {
         // Default values, will be updated in @PostConstruct
-        super("pre-workflow-manager", false, registryService, properties);
+        super("pre-workflow-manager", false, registryService, properties, 
messagingFactory);
         this.properties = properties;
         this.taskFactory = taskFactory;
         this.applicationContext = applicationContext;
@@ -121,7 +123,7 @@ public class PreWorkflowManager extends WorkflowManager {
         List<String> routingKeys = new ArrayList<>();
         routingKeys.add(properties.rabbitmq.processExchangeName);
         this.subscriber =
-                MessagingFactory.getSubscriber(new 
ProcessLaunchMessageHandler(), routingKeys, Type.PROCESS_LAUNCH);
+                messagingFactory.getSubscriber(new 
ProcessLaunchMessageHandler(), routingKeys, Type.PROCESS_LAUNCH);
     }
 
     private String createAndLaunchPreWorkflow(String processId, boolean 
forceRun) throws Exception {
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/WorkflowManager.java
 
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/WorkflowManager.java
index ff23834d09..33d7bf88be 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/WorkflowManager.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/WorkflowManager.java
@@ -52,10 +52,13 @@ public class WorkflowManager {
 
     protected final RegistryService registryService;
     private final AiravataServerProperties properties;
+    private final MessagingFactory messagingFactory;
 
-    public WorkflowManager(RegistryService registryService, 
AiravataServerProperties properties) {
+    public WorkflowManager(
+            RegistryService registryService, AiravataServerProperties 
properties, MessagingFactory messagingFactory) {
         this.registryService = registryService;
         this.properties = properties;
+        this.messagingFactory = messagingFactory;
     }
 
     protected String workflowManagerName;
@@ -68,11 +71,13 @@ public class WorkflowManager {
             String workflowManagerName,
             boolean loadBalanceClusters,
             RegistryService registryService,
-            AiravataServerProperties properties) {
+            AiravataServerProperties properties,
+            MessagingFactory messagingFactory) {
         this.workflowManagerName = workflowManagerName;
         this.loadBalanceClusters = loadBalanceClusters;
         this.registryService = registryService;
         this.properties = properties;
+        this.messagingFactory = messagingFactory;
     }
 
     protected void initComponents() throws Exception {
@@ -100,7 +105,7 @@ public class WorkflowManager {
     }
 
     private void initStatusPublisher() throws AiravataException {
-        this.statusPublisher = MessagingFactory.getPublisher(Type.STATUS);
+        this.statusPublisher = messagingFactory.getPublisher(Type.STATUS);
     }
 
     private void initHelixAdmin() {
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/messaging/core/MessagingFactory.java
 
b/airavata-api/src/main/java/org/apache/airavata/messaging/core/MessagingFactory.java
index b02ffb2aab..a954c9b55f 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/messaging/core/MessagingFactory.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/messaging/core/MessagingFactory.java
@@ -46,7 +46,6 @@ import org.springframework.stereotype.Component;
 public class MessagingFactory {
 
     private static final Logger logger = 
LoggerFactory.getLogger(MessagingFactory.class);
-    private static MessagingFactory instance;
 
     private final AiravataServerProperties properties;
 
@@ -54,38 +53,28 @@ public class MessagingFactory {
         this.properties = properties;
     }
 
-    @jakarta.annotation.PostConstruct
-    public void init() {
-        logger.info("[BEAN-INIT] MessagingFactory.init() called - setting 
static instance");
-        instance = this;
-        logger.info("[BEAN-INIT] MessagingFactory static instance set 
successfully");
-    }
-
-    public static Subscriber getSubscriber(final MessageHandler 
messageHandler, List<String> routingKeys, Type type)
+    public Subscriber getSubscriber(final MessageHandler messageHandler, 
List<String> routingKeys, Type type)
             throws AiravataException {
-        if (instance == null) {
-            throw new IllegalStateException("MessagingFactory not initialized. 
Make sure it's a Spring bean.");
-        }
         Subscriber subscriber = null;
-        RabbitMQProperties rProperties = instance.getProperties();
+        RabbitMQProperties rProperties = getProperties();
 
         switch (type) {
             case EXPERIMENT_LAUNCH:
-                subscriber = instance.getExperimentSubscriber(rProperties);
+                subscriber = getExperimentSubscriber(rProperties);
                 subscriber.listen(
                         ((connection, channel) -> new 
ExperimentConsumer(messageHandler, connection, channel)),
                         rProperties.getQueueName(),
                         routingKeys);
                 break;
             case PROCESS_LAUNCH:
-                subscriber = instance.getProcessSubscriber(rProperties);
+                subscriber = getProcessSubscriber(rProperties);
                 subscriber.listen(
                         (connection, channel) -> new 
ProcessConsumer(messageHandler, connection, channel),
                         rProperties.getQueueName(),
                         routingKeys);
                 break;
             case STATUS:
-                subscriber = instance.getStatusSubscriber(rProperties);
+                subscriber = getStatusSubscriber(rProperties);
                 subscriber.listen(
                         (connection, channel) -> new 
StatusConsumer(messageHandler, connection, channel),
                         rProperties.getQueueName(),
@@ -98,12 +87,9 @@ public class MessagingFactory {
         return subscriber;
     }
 
-    public static Subscriber getDBEventSubscriber(final MessageHandler 
messageHandler, String serviceName)
+    public Subscriber getDBEventSubscriber(final MessageHandler 
messageHandler, String serviceName)
             throws AiravataException {
-        if (instance == null) {
-            throw new IllegalStateException("MessagingFactory not initialized. 
Make sure it's a Spring bean.");
-        }
-        RabbitMQProperties rProperties = instance.getProperties();
+        RabbitMQProperties rProperties = getProperties();
 
         // FIXME: Set autoAck to false and handle possible situations
         rProperties
@@ -123,21 +109,18 @@ public class MessagingFactory {
         return subscriber;
     }
 
-    public static Publisher getPublisher(Type type) throws AiravataException {
-        if (instance == null) {
-            throw new IllegalStateException("MessagingFactory not initialized. 
Make sure it's a Spring bean.");
-        }
-        RabbitMQProperties rProperties = instance.getProperties();
+    public Publisher getPublisher(Type type) throws AiravataException {
+        RabbitMQProperties rProperties = getProperties();
         Publisher publiser = null;
         switch (type) {
             case EXPERIMENT_LAUNCH:
-                publiser = instance.getExperimentPublisher(rProperties);
+                publiser = getExperimentPublisher(rProperties);
                 break;
             case PROCESS_LAUNCH:
-                publiser = instance.gerProcessPublisher(rProperties);
+                publiser = gerProcessPublisher(rProperties);
                 break;
             case STATUS:
-                publiser = instance.getStatusPublisher(rProperties);
+                publiser = getStatusPublisher(rProperties);
                 break;
             default:
                 throw new IllegalArgumentException("Publisher " + type + " is 
not handled");
@@ -146,11 +129,8 @@ public class MessagingFactory {
         return publiser;
     }
 
-    public static Publisher getDBEventPublisher() throws AiravataException {
-        if (instance == null) {
-            throw new IllegalStateException("MessagingFactory not initialized. 
Make sure it's a Spring bean.");
-        }
-        RabbitMQProperties rProperties = instance.getProperties();
+    public Publisher getDBEventPublisher() throws AiravataException {
+        RabbitMQProperties rProperties = getProperties();
         
rProperties.setExchangeName(DBEventManagerConstants.DB_EVENT_EXCHANGE_NAME);
         return new RabbitMQPublisher(rProperties);
     }
@@ -162,7 +142,7 @@ public class MessagingFactory {
 
     private Publisher getStatusPublisher(RabbitMQProperties rProperties) 
throws AiravataException {
         rProperties.setExchangeName(properties.rabbitmq.statusExchangeName);
-        return new RabbitMQPublisher(rProperties, 
MessagingFactory::statusRoutingkey);
+        return new RabbitMQPublisher(rProperties, this::statusRoutingkey);
     }
 
     private Publisher gerProcessPublisher(RabbitMQProperties rProperties) 
throws AiravataException {
@@ -199,7 +179,7 @@ public class MessagingFactory {
         return new RabbitMQSubscriber(sp);
     }
 
-    private static String statusRoutingkey(MessageContext msgCtx) {
+    private String statusRoutingkey(MessageContext msgCtx) {
         String gatewayId = msgCtx.getGatewayId();
         String routingKey = null;
         if (msgCtx.getType() == MessageType.EXPERIMENT) {
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/CountWriterTask.java
 
b/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/CountWriterTask.java
index 117c304be4..bc7556631d 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/CountWriterTask.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/CountWriterTask.java
@@ -32,6 +32,11 @@ public class CountWriterTask extends TimerTask {
     private File file;
     private FileOutputStream fos;
     private BufferedWriter bw;
+    private final StatCounter statCounter;
+
+    public CountWriterTask(StatCounter statCounter) {
+        this.statCounter = statCounter;
+    }
 
     public void setFile(File file) {
         this.file = file;
@@ -40,7 +45,6 @@ public class CountWriterTask extends TimerTask {
     @Override
     public void run() {
         try {
-            StatCounter statCounter = StatCounter.getInstance();
             List<Long> contPer10S = statCounter.getMessageContPer10S();
             fos = new FileOutputStream(file, false);
             bw = new BufferedWriter(new OutputStreamWriter(fos));
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/LatencyWriterTask.java
 
b/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/LatencyWriterTask.java
index 299d02a733..ef324c6937 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/LatencyWriterTask.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/LatencyWriterTask.java
@@ -35,6 +35,11 @@ public class LatencyWriterTask extends TimerTask {
     private File file;
     private FileOutputStream fos;
     private BufferedWriter bw;
+    private final StatCounter statCounter;
+
+    public LatencyWriterTask(StatCounter statCounter) {
+        this.statCounter = statCounter;
+    }
 
     public void setFile(File file) {
         this.file = file;
@@ -44,7 +49,6 @@ public class LatencyWriterTask extends TimerTask {
     public void run() {
         try {
             logger.info("########### Latency Write Task ############");
-            StatCounter statCounter = StatCounter.getInstance();
             Map<String, Long> messageTimeStamp = 
statCounter.getMessageTimeStamp();
             fos = new FileOutputStream(file, false);
             bw = new BufferedWriter(new OutputStreamWriter(fos));
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/StatCounter.java
 
b/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/StatCounter.java
index ddf02b5912..eeba31f803 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/StatCounter.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/messaging/core/stats/StatCounter.java
@@ -26,9 +26,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Timer;
 import org.apache.airavata.common.model.Message;
+import org.springframework.stereotype.Component;
+import jakarta.annotation.PostConstruct;
 
+@Component
 public class StatCounter {
-    private static StatCounter ourInstance = new StatCounter();
     private long msgCount;
     private long period = 10 * 1000;
     private long msgCountForPeriod;
@@ -40,9 +42,8 @@ public class StatCounter {
     private List<Long> messageContPer10S = new ArrayList<Long>();
     private Map<String, Long> messageTimeStamp = new HashMap<String, Long>();
 
-    public static StatCounter getInstance() {
-        return ourInstance;
-    }
+    private Timer counterTimer;
+    private Timer latencyTimer;
 
     public long getMsgCount() {
         return msgCount;
@@ -60,14 +61,19 @@ public class StatCounter {
         this.messageContPer10S = messageContPer10S;
     }
 
-    private StatCounter() {
+    public StatCounter() {
+        // Default constructor for Spring DI
+    }
+
+    @PostConstruct
+    public void init() {
         file1 = new File("/tmp/results");
         file2 = new File("/tmp/latency");
-        Timer counterTimer = new Timer();
-        Timer latencyTimer = new Timer();
-        CountWriterTask writerTask = new CountWriterTask();
+        counterTimer = new Timer();
+        latencyTimer = new Timer();
+        CountWriterTask writerTask = new CountWriterTask(this);
         writerTask.setFile(file1);
-        LatencyWriterTask latencyWriterTask = new LatencyWriterTask();
+        LatencyWriterTask latencyWriterTask = new LatencyWriterTask(this);
         latencyWriterTask.setFile(file2);
         counterTimer.scheduleAtFixedRate(writerTask, 0, 60 * 1000);
         latencyTimer.scheduleAtFixedRate(latencyWriterTask, 0, 60 * 1000);
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/metascheduler/core/utils/Utils.java
 
b/airavata-api/src/main/java/org/apache/airavata/metascheduler/core/utils/Utils.java
index 7d67990e50..7e8ba619a0 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/metascheduler/core/utils/Utils.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/metascheduler/core/utils/Utils.java
@@ -42,19 +42,27 @@ import org.springframework.stereotype.Component;
 public class Utils {
 
     private final RegistryService registryService;
+    private final MessagingFactory messagingFactory;
+    private final ApplicationContext applicationContext;
 
-    private static Publisher statusPublisher;
-    private static ApplicationContext applicationContext;
+    private Publisher statusPublisher;
+    private static ApplicationContext staticApplicationContext;
 
-    public Utils(RegistryService registryService, ApplicationContext 
applicationContext) {
+    public Utils(
+            RegistryService registryService,
+            ApplicationContext applicationContext,
+            MessagingFactory messagingFactory) {
         this.registryService = registryService;
-        Utils.applicationContext = applicationContext;
+        this.applicationContext = applicationContext;
+        this.messagingFactory = messagingFactory;
+        Utils.staticApplicationContext = applicationContext;
     }
 
     public static void saveAndPublishProcessStatus(
             ProcessState processState, String processId, String experimentId, 
String gatewayId)
             throws RegistryServiceException, AiravataException {
-        RegistryService registryService = getRegistryService();
+        Utils instance = getInstance();
+        RegistryService registryService = instance.registryService;
         ProcessStatus processStatus = new ProcessStatus(processState);
         
processStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
 
@@ -67,13 +75,14 @@ public class Utils {
                 AiravataUtils.getId(MessageType.PROCESS.name()),
                 gatewayId);
         msgCtx.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
-        getStatusPublisher().publish(msgCtx);
+        instance.getStatusPublisher().publish(msgCtx);
     }
 
     public static void updateProcessStatusAndPublishStatus(
             ProcessState processState, String processId, String experimentId, 
String gatewayId)
             throws RegistryServiceException, AiravataException {
-        RegistryService registryService = getRegistryService();
+        Utils instance = getInstance();
+        RegistryService registryService = instance.registryService;
         ProcessStatus processStatus = new ProcessStatus(processState);
         
processStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
 
@@ -86,26 +95,21 @@ public class Utils {
                 AiravataUtils.getId(MessageType.PROCESS.name()),
                 gatewayId);
         msgCtx.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
-        getStatusPublisher().publish(msgCtx);
+        instance.getStatusPublisher().publish(msgCtx);
     }
 
-    public static synchronized Publisher getStatusPublisher() throws 
AiravataException {
+    public synchronized Publisher getStatusPublisher() throws 
AiravataException {
         if (statusPublisher == null) {
-            statusPublisher = MessagingFactory.getPublisher(Type.STATUS);
+            statusPublisher = messagingFactory.getPublisher(Type.STATUS);
         }
         return statusPublisher;
     }
 
-    // Instance method for Spring DI
-    protected RegistryService getRegistryServiceInstance() {
-        return registryService;
-    }
-
     // Static method for backward compatibility - delegates to Spring-managed 
instance
-    private static RegistryService getRegistryService() {
-        if (applicationContext != null) {
-            return 
applicationContext.getBean(Utils.class).getRegistryServiceInstance();
+    private static Utils getInstance() {
+        if (staticApplicationContext != null) {
+            return staticApplicationContext.getBean("metaschedulerUtils", 
Utils.class);
         }
-        throw new RuntimeException("ApplicationContext not available. 
RegistryService cannot be retrieved.");
+        throw new RuntimeException("ApplicationContext not available. Utils 
cannot be retrieved.");
     }
 }
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/metascheduler/metadata/analyzer/DataInterpreterService.java
 
b/airavata-api/src/main/java/org/apache/airavata/metascheduler/metadata/analyzer/DataInterpreterService.java
index fbd00884dc..7bfcf0d777 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/metascheduler/metadata/analyzer/DataInterpreterService.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/metascheduler/metadata/analyzer/DataInterpreterService.java
@@ -19,7 +19,6 @@
 */
 package org.apache.airavata.metascheduler.metadata.analyzer;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import org.apache.airavata.common.utils.IServer;
@@ -35,7 +34,9 @@ import org.quartz.Trigger;
 import org.quartz.TriggerBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+import org.springframework.scheduling.quartz.SpringBeanJobFactory;
 import org.springframework.stereotype.Component;
 
 @Component
@@ -45,14 +46,17 @@ public class DataInterpreterService implements IServer {
     private static final String SERVER_NAME = "Data Interpreter Service";
     private static final String SERVER_VERSION = "1.0";
 
-    private static ServerStatus status;
-    private static Scheduler scheduler;
-    private static Map<JobDetail, Trigger> jobTriggerMap = new HashMap<>();
+    private ServerStatus status;
+    private Scheduler scheduler;
+    private Map<JobDetail, Trigger> jobTriggerMap = new HashMap<>();
 
     private final AiravataServerProperties properties;
+    private final ApplicationContext applicationContext;
 
-    public DataInterpreterService(AiravataServerProperties properties) {
+    public DataInterpreterService(
+            AiravataServerProperties properties, ApplicationContext 
applicationContext) {
         this.properties = properties;
+        this.applicationContext = applicationContext;
     }
 
     @Override
@@ -69,6 +73,10 @@ public class DataInterpreterService implements IServer {
     public void start() throws Exception {
         jobTriggerMap.clear();
         SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
+        // Use SpringBeanJobFactory to enable Spring DI for Quartz jobs
+        SpringBeanJobFactory jobFactory = new SpringBeanJobFactory();
+        jobFactory.setApplicationContext(applicationContext);
+        schedulerFactoryBean.setJobFactory(jobFactory);
         schedulerFactoryBean.afterPropertiesSet();
         scheduler = schedulerFactoryBean.getScheduler();
 
@@ -105,7 +113,9 @@ public class DataInterpreterService implements IServer {
 
     @Override
     public void stop() throws Exception {
-        scheduler.unscheduleJobs(new ArrayList(jobTriggerMap.values()));
+        scheduler.unscheduleJobs(jobTriggerMap.values().stream()
+                .map(trigger -> trigger.getKey())
+                .collect(java.util.stream.Collectors.toList()));
     }
 
     @Override
@@ -119,10 +129,10 @@ public class DataInterpreterService implements IServer {
 
     @Override
     public ServerStatus getStatus() throws Exception {
-        return DataInterpreterService.status;
+        return status;
     }
 
     public void setServerStatus(ServerStatus status) {
-        DataInterpreterService.status = status;
+        this.status = status;
     }
 }
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/metascheduler/metadata/analyzer/impl/DataAnalyzerImpl.java
 
b/airavata-api/src/main/java/org/apache/airavata/metascheduler/metadata/analyzer/impl/DataAnalyzerImpl.java
index 78c3f51c6d..d91a9b7380 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/metascheduler/metadata/analyzer/impl/DataAnalyzerImpl.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/metascheduler/metadata/analyzer/impl/DataAnalyzerImpl.java
@@ -29,29 +29,25 @@ import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Component;
 
 @Component
 public class DataAnalyzerImpl implements DataAnalyzer {
 
     private static final Logger LOGGER = 
LoggerFactory.getLogger(DataAnalyzerImpl.class);
-    private static ApplicationContext applicationContext;
 
     private final AiravataServerProperties properties;
-    private final ApplicationContext applicationContextInstance;
+    private final RegistryService registryService;
 
-    public DataAnalyzerImpl(AiravataServerProperties properties, 
ApplicationContext applicationContext) {
+    public DataAnalyzerImpl(AiravataServerProperties properties, 
RegistryService registryService) {
         this.properties = properties;
-        this.applicationContextInstance = applicationContext;
-        DataAnalyzerImpl.applicationContext = applicationContext;
+        this.registryService = registryService;
     }
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws 
JobExecutionException {
         try {
             LOGGER.debug("Executing Data Analyzer ....... ");
-            RegistryService registryService = 
applicationContextInstance.getBean(RegistryService.class);
 
             // TODO: handle multiple gateways
             String gateway = properties.services.parser.enabledGateways;
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/metascheduler/process/scheduling/engine/rescheduler/ProcessReschedulingService.java
 
b/airavata-api/src/main/java/org/apache/airavata/metascheduler/process/scheduling/engine/rescheduler/ProcessReschedulingService.java
index d57b16151f..a8b00bcddc 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/metascheduler/process/scheduling/engine/rescheduler/ProcessReschedulingService.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/metascheduler/process/scheduling/engine/rescheduler/ProcessReschedulingService.java
@@ -19,7 +19,6 @@
 */
 package 
org.apache.airavata.metascheduler.process.scheduling.engine.rescheduler;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import org.apache.airavata.common.utils.IServer;
@@ -34,7 +33,9 @@ import org.quartz.Trigger;
 import org.quartz.TriggerBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+import org.springframework.scheduling.quartz.SpringBeanJobFactory;
 import org.springframework.stereotype.Component;
 
 /**
@@ -47,14 +48,17 @@ public class ProcessReschedulingService implements IServer {
     private static final String SERVER_NAME = "Airavata Process Rescheduling 
Service";
     private static final String SERVER_VERSION = "1.0";
 
-    private static ServerStatus status;
-    private static Scheduler scheduler;
-    private static Map<JobDetail, Trigger> jobTriggerMap = new HashMap<>();
+    private ServerStatus status;
+    private Scheduler scheduler;
+    private Map<JobDetail, Trigger> jobTriggerMap = new HashMap<>();
 
     private final AiravataServerProperties properties;
+    private final ApplicationContext applicationContext;
 
-    public ProcessReschedulingService(AiravataServerProperties properties) {
+    public ProcessReschedulingService(
+            AiravataServerProperties properties, ApplicationContext 
applicationContext) {
         this.properties = properties;
+        this.applicationContext = applicationContext;
     }
 
     @Override
@@ -72,6 +76,10 @@ public class ProcessReschedulingService implements IServer {
 
         jobTriggerMap.clear();
         SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
+        // Use SpringBeanJobFactory to enable Spring DI for Quartz jobs
+        SpringBeanJobFactory jobFactory = new SpringBeanJobFactory();
+        jobFactory.setApplicationContext(applicationContext);
+        schedulerFactoryBean.setJobFactory(jobFactory);
         schedulerFactoryBean.afterPropertiesSet();
         scheduler = schedulerFactoryBean.getScheduler();
 
@@ -108,7 +116,9 @@ public class ProcessReschedulingService implements IServer {
 
     @Override
     public void stop() throws Exception {
-        scheduler.unscheduleJobs(new ArrayList(jobTriggerMap.values()));
+        scheduler.unscheduleJobs(jobTriggerMap.values().stream()
+                .map(trigger -> trigger.getKey())
+                .collect(java.util.stream.Collectors.toList()));
     }
 
     @Override
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/metascheduler/process/scheduling/engine/rescheduler/ProcessScannerImpl.java
 
b/airavata-api/src/main/java/org/apache/airavata/metascheduler/process/scheduling/engine/rescheduler/ProcessScannerImpl.java
index 95d4943065..ecf2d0e102 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/metascheduler/process/scheduling/engine/rescheduler/ProcessScannerImpl.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/metascheduler/process/scheduling/engine/rescheduler/ProcessScannerImpl.java
@@ -30,34 +30,30 @@ import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Component;
 
 @Component
 public class ProcessScannerImpl implements ProcessScanner {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(ProcessScannerImpl.class);
-    private static ApplicationContext applicationContext;
 
     private final AiravataServerProperties properties;
-    private final ApplicationContext applicationContextInstance;
+    private final RegistryService registryService;
 
-    public ProcessScannerImpl(AiravataServerProperties properties, 
ApplicationContext applicationContext) {
+    public ProcessScannerImpl(AiravataServerProperties properties, 
RegistryService registryService) {
         this.properties = properties;
-        this.applicationContextInstance = applicationContext;
-        ProcessScannerImpl.applicationContext = applicationContext;
+        this.registryService = registryService;
     }
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws 
JobExecutionException {
         try {
             LOGGER.debug("Executing Process scanner ....... ");
-            RegistryService registryService = 
applicationContextInstance.getBean(RegistryService.class);
             ProcessState state = ProcessState.QUEUED;
             List<ProcessModel> processModelList = 
registryService.getProcessListInState(state);
 
             String reSchedulerPolicyClass = 
properties.services.scheduler.computeResourceReschedulerPolicyClass;
             ReScheduler reScheduler =
-                    (ReScheduler) 
Class.forName(reSchedulerPolicyClass).newInstance();
+                    (ReScheduler) 
Class.forName(reSchedulerPolicyClass).getDeclaredConstructor().newInstance();
 
             for (ProcessModel processModel : processModelList) {
                 reScheduler.reschedule(processModel, state);
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/monitor/compute/ComputationalResourceMonitoringService.java
 
b/airavata-api/src/main/java/org/apache/airavata/monitor/compute/ComputationalResourceMonitoringService.java
index 75da6ca246..0a74b552e1 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/monitor/compute/ComputationalResourceMonitoringService.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/monitor/compute/ComputationalResourceMonitoringService.java
@@ -26,6 +26,7 @@ import org.apache.airavata.common.utils.IServer;
 import org.apache.airavata.config.AiravataServerProperties;
 import org.apache.airavata.monitor.compute.job.MonitoringJob;
 import org.apache.airavata.monitor.compute.utils.Constants;
+import org.apache.airavata.service.registry.RegistryService;
 import org.quartz.JobBuilder;
 import org.quartz.JobDetail;
 import org.quartz.Scheduler;
@@ -35,24 +36,35 @@ import org.quartz.Trigger;
 import org.quartz.TriggerBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+import org.springframework.scheduling.quartz.SpringBeanJobFactory;
+import org.springframework.stereotype.Service;
 
 /**
  * Computational Resource Monitoring Service
  */
+@Service
 public class ComputationalResourceMonitoringService implements IServer {
 
     private static final Logger logger = 
LoggerFactory.getLogger(ComputationalResourceMonitoringService.class);
     private static final String SERVER_NAME = "Airavata Compute Resource 
Monitoring Service";
     private static final String SERVER_VERSION = "1.0";
 
-    private static ServerStatus status;
-    private static Scheduler scheduler;
-    private static Map<JobDetail, Trigger> jobTriggerMap = new HashMap<>();
-    private AiravataServerProperties properties;
-
-    public ComputationalResourceMonitoringService(AiravataServerProperties 
properties) {
+    private ServerStatus status;
+    private Scheduler scheduler;
+    private Map<JobDetail, Trigger> jobTriggerMap = new HashMap<>();
+    private final AiravataServerProperties properties;
+    private final RegistryService registryService;
+    private final ApplicationContext applicationContext;
+
+    public ComputationalResourceMonitoringService(
+            AiravataServerProperties properties,
+            RegistryService registryService,
+            ApplicationContext applicationContext) {
         this.properties = properties;
+        this.registryService = registryService;
+        this.applicationContext = applicationContext;
     }
 
     @Override
@@ -70,6 +82,10 @@ public class ComputationalResourceMonitoringService 
implements IServer {
 
         jobTriggerMap.clear();
         SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
+        // Use SpringBeanJobFactory to enable Spring DI for Quartz jobs
+        SpringBeanJobFactory jobFactory = new SpringBeanJobFactory();
+        jobFactory.setApplicationContext(applicationContext);
+        schedulerFactoryBean.setJobFactory(jobFactory);
         schedulerFactoryBean.afterPropertiesSet();
         scheduler = schedulerFactoryBean.getScheduler();
 
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/ComputeResourceMonitor.java
 
b/airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/ComputeResourceMonitor.java
index 56c23b855b..fe402a6211 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/ComputeResourceMonitor.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/ComputeResourceMonitor.java
@@ -25,10 +25,16 @@ import 
org.apache.airavata.common.model.UserComputeResourcePreference;
 import org.apache.airavata.common.model.UserResourceProfile;
 import org.apache.airavata.registry.exception.RegistryServiceException;
 import org.apache.airavata.service.registry.RegistryService;
+import org.springframework.beans.factory.annotation.Autowired;
 
 public abstract class ComputeResourceMonitor {
 
-    protected final RegistryService registryService;
+    @Autowired
+    protected RegistryService registryService;
+
+    protected ComputeResourceMonitor() {
+        // No-arg constructor for Spring DI
+    }
 
     protected ComputeResourceMonitor(RegistryService registryService) {
         this.registryService = registryService;
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/MonitoringJob.java
 
b/airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/MonitoringJob.java
index 5b8df0e4a2..ae0ce6f625 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/MonitoringJob.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/monitor/compute/job/MonitoringJob.java
@@ -33,7 +33,6 @@ import 
org.apache.airavata.common.model.JobSubmissionInterface;
 import org.apache.airavata.common.model.JobSubmissionProtocol;
 import org.apache.airavata.common.model.QueueStatusModel;
 import org.apache.airavata.common.model.ResourceJobManager;
-import org.apache.airavata.helix.core.support.adaptor.AdaptorSupportImpl;
 import org.apache.airavata.helix.impl.task.submission.config.JobFactory;
 import org.apache.airavata.helix.task.api.support.AdaptorSupport;
 import org.apache.airavata.monitor.compute.job.output.OutputParser;
@@ -46,6 +45,7 @@ import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * This class is responsible to execute CR monitoring code
@@ -53,8 +53,16 @@ import org.slf4j.LoggerFactory;
 public class MonitoringJob extends ComputeResourceMonitor implements Job {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(MonitoringJob.class);
 
-    public MonitoringJob(RegistryService registryService) {
+    @Autowired
+    private AdaptorSupport adaptorSupport;
+
+    public MonitoringJob() {
+        // No-arg constructor for Spring DI
+    }
+
+    public MonitoringJob(RegistryService registryService, AdaptorSupport 
adaptorSupport) {
         super(registryService);
+        this.adaptorSupport = adaptorSupport;
     }
 
     @Override
@@ -96,7 +104,10 @@ public class MonitoringJob extends ComputeResourceMonitor 
implements Job {
             int parallelJobs,
             int jobId)
             throws Exception {
-        AdaptorSupportImpl adaptorSupport = AdaptorSupportImpl.getInstance();
+        if (this.adaptorSupport == null) {
+            throw new IllegalStateException("AdaptorSupport not injected. This 
class must be managed by Spring.");
+        }
+        AdaptorSupport adaptorSupport = this.adaptorSupport;
         GroupResourceProfile groupResourceProfile = 
getGroupResourceProfile(metaSchedulerGRP);
         //        List<GroupComputeResourcePreference> 
computeResourcePreferenceList =
         // groupResourceProfile.getComputePreferences();
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/GFACPassiveJobSubmitter.java
 
b/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/GFACPassiveJobSubmitter.java
index 5a1778995d..75f34c69c3 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/GFACPassiveJobSubmitter.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/GFACPassiveJobSubmitter.java
@@ -48,13 +48,18 @@ public class GFACPassiveJobSubmitter implements 
JobSubmitter, Watcher {
     private Publisher publisher;
     private AiravataServerProperties properties;
     private OrchestratorUtils orchestratorUtils;
+    private MessagingFactory messagingFactory;
 
     public void initialize(OrchestratorContext orchestratorContext) throws 
OrchestratorException {
         if (orchestratorContext.getPublisher() != null) {
             this.publisher = orchestratorContext.getPublisher();
         } else {
+            if (messagingFactory == null) {
+                throw new OrchestratorException("MessagingFactory must be set 
before initializing "
+                        + GFACPassiveJobSubmitter.class);
+            }
             try {
-                this.publisher = 
MessagingFactory.getPublisher(Type.PROCESS_LAUNCH);
+                this.publisher = 
messagingFactory.getPublisher(Type.PROCESS_LAUNCH);
             } catch (AiravataException e) {
                 logger.error(e.getMessage(), e);
                 throw new OrchestratorException("Cannot initialize " + 
GFACPassiveJobSubmitter.class
@@ -68,6 +73,10 @@ public class GFACPassiveJobSubmitter implements 
JobSubmitter, Watcher {
         this.properties = properties;
     }
 
+    public void setMessagingFactory(MessagingFactory messagingFactory) {
+        this.messagingFactory = messagingFactory;
+    }
+
     public void setOrchestratorUtils(OrchestratorUtils orchestratorUtils) {
         this.orchestratorUtils = orchestratorUtils;
     }
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/profile/repositories/AbstractRepository.java
 
b/airavata-api/src/main/java/org/apache/airavata/profile/repositories/AbstractRepository.java
index 48524c5986..1afddc064e 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/profile/repositories/AbstractRepository.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/profile/repositories/AbstractRepository.java
@@ -31,6 +31,11 @@ import org.slf4j.LoggerFactory;
 import org.springframework.orm.jpa.SharedEntityManagerCreator;
 import org.springframework.transaction.annotation.Transactional;
 
+/**
+ * @deprecated This class is legacy and unused. All repositories now use 
Spring Data JPA interfaces.
+ *             This class should not be extended. Use JpaRepository interfaces 
instead.
+ */
+@Deprecated
 public abstract class AbstractRepository<T, E, Id> {
     private static final Logger logger = 
LoggerFactory.getLogger(AbstractRepository.class);
 
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/profile/utils/JPAUtils.java 
b/airavata-api/src/main/java/org/apache/airavata/profile/utils/JPAUtils.java
index d629575f51..bd3d05fb83 100644
--- a/airavata-api/src/main/java/org/apache/airavata/profile/utils/JPAUtils.java
+++ b/airavata-api/src/main/java/org/apache/airavata/profile/utils/JPAUtils.java
@@ -49,6 +49,11 @@ public class JPAUtils {
         logger.info("[BEAN-INIT] ProfileService JPAUtils static instance set 
successfully");
     }
 
+    /**
+     * @deprecated Use dependency injection to inject the JPAUtils bean 
instead of calling static methods.
+     *             This method is kept for backward compatibility only.
+     */
+    @Deprecated
     public static EntityManager getEntityManager() {
         if (instance == null || instance.factory == null) {
             throw new IllegalStateException("ProfileService JPAUtils not 
initialized. Make sure it's a Spring bean.");
@@ -56,6 +61,11 @@ public class JPAUtils {
         return instance.factory.createEntityManager();
     }
 
+    /**
+     * @deprecated Use dependency injection to inject the JPAUtils bean 
instead of calling static methods.
+     *             This method is kept for backward compatibility only.
+     */
+    @Deprecated
     public static EntityManagerFactory getEntityManagerFactory() {
         if (instance == null || instance.factory == null) {
             throw new IllegalStateException("ProfileService JPAUtils not 
initialized. Make sure it's a Spring bean.");
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/registry/messaging/RegistryServiceDBEventHandler.java
 
b/airavata-api/src/main/java/org/apache/airavata/registry/messaging/RegistryServiceDBEventHandler.java
index 3dd09d62bf..386fa0f47e 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/registry/messaging/RegistryServiceDBEventHandler.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/registry/messaging/RegistryServiceDBEventHandler.java
@@ -52,9 +52,12 @@ public class RegistryServiceDBEventHandler implements 
MessageHandler {
     private static final ObjectMapper objectMapper = new ObjectMapper();
 
     private final RegistryService registryService;
+    private final RegistryServiceDBEventMessagingFactory messagingFactory;
 
-    public RegistryServiceDBEventHandler(RegistryService registryService) {
+    public RegistryServiceDBEventHandler(
+            RegistryService registryService, 
RegistryServiceDBEventMessagingFactory messagingFactory) {
         this.registryService = registryService;
+        this.messagingFactory = messagingFactory;
     }
 
     private DBEventPublisherUtils dbEventPublisherUtils = new 
DBEventPublisherUtils(DBEventService.REGISTRY);
@@ -154,7 +157,7 @@ public class RegistryServiceDBEventHandler implements 
MessageHandler {
             // send ack for received message
             logger.info("RegistryServiceDBEventHandler | Sending ack. Message 
Delivery Tag: "
                     + messageContext.getDeliveryTag());
-            
RegistryServiceDBEventMessagingFactory.getDBEventSubscriber().sendAck(messageContext.getDeliveryTag());
+            
messagingFactory.getDBEventSubscriber().sendAck(messageContext.getDeliveryTag());
         } catch (RegistryServiceException ex) {
             logger.error("Error processing message: " + ex, ex);
         } catch (ApplicationSettingsException ex) {
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/registry/messaging/RegistryServiceDBEventMessagingFactory.java
 
b/airavata-api/src/main/java/org/apache/airavata/registry/messaging/RegistryServiceDBEventMessagingFactory.java
index f7f4264fd7..3828e02256 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/registry/messaging/RegistryServiceDBEventMessagingFactory.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/registry/messaging/RegistryServiceDBEventMessagingFactory.java
@@ -48,24 +48,25 @@ public class RegistryServiceDBEventMessagingFactory {
 
     private static final Logger logger = 
LoggerFactory.getLogger(RegistryServiceDBEventMessagingFactory.class);
 
-    private static Publisher dbEventPublisher;
+    private Publisher dbEventPublisher;
 
-    private static Subscriber registryServiceDBEventSubscriber;
-    private static RegistryServiceDBEventMessagingFactory instance;
+    private Subscriber registryServiceDBEventSubscriber;
 
     private final RegistryService registryService;
+    private final MessagingFactory messagingFactory;
 
-    public RegistryServiceDBEventMessagingFactory(RegistryService 
registryService) {
+    public RegistryServiceDBEventMessagingFactory(
+            RegistryService registryService, MessagingFactory 
messagingFactory) {
         this.registryService = registryService;
-        instance = this;
+        this.messagingFactory = messagingFactory;
     }
 
-    private static Publisher getDBEventPublisher() throws AiravataException {
+    public Publisher getDBEventPublisher() throws AiravataException {
         if (null == dbEventPublisher) {
-            synchronized (RegistryServiceDBEventMessagingFactory.class) {
+            synchronized (this) {
                 if (null == dbEventPublisher) {
                     logger.info("Creating DB Event publisher.....");
-                    dbEventPublisher = MessagingFactory.getDBEventPublisher();
+                    dbEventPublisher = messagingFactory.getDBEventPublisher();
                     logger.info("DB Event publisher created");
                 }
             }
@@ -73,25 +74,20 @@ public class RegistryServiceDBEventMessagingFactory {
         return dbEventPublisher;
     }
 
-    public static Subscriber getDBEventSubscriber() throws AiravataException, 
RegistryServiceException {
+    public Subscriber getDBEventSubscriber() throws AiravataException, 
RegistryServiceException {
         if (null == registryServiceDBEventSubscriber) {
-            synchronized (RegistryServiceDBEventMessagingFactory.class) {
+            synchronized (this) {
                 if (null == registryServiceDBEventSubscriber) {
-                    logger.info("Creating DB Event publisher.....");
+                    logger.info("Creating DB Event subscriber.....");
                     RegistryServiceDBEventHandler handler;
                     String serviceName = DBEventService.REGISTRY.toString();
                     try {
-                        RegistryService service = instance != null ? 
instance.registryService : null;
-                        if (service == null) {
-                            throw new IllegalStateException(
-                                    "RegistryServiceDBEventMessagingFactory 
not initialized via Spring");
-                        }
-                        handler = new RegistryServiceDBEventHandler(service);
+                        handler = new 
RegistryServiceDBEventHandler(registryService, this);
                     } catch (Exception e) {
                         throw new AiravataException(
                                 "Failed to create registry service DB event 
handler for service: " + serviceName, e);
                     }
-                    registryServiceDBEventSubscriber = 
MessagingFactory.getDBEventSubscriber(handler, serviceName);
+                    registryServiceDBEventSubscriber = 
messagingFactory.getDBEventSubscriber(handler, serviceName);
                     logger.info("DB Event subscriber created for service: " + 
serviceName);
                 }
             }
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java 
b/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java
index ef71976a6d..3e1091b113 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java
@@ -114,7 +114,7 @@ import 
org.apache.airavata.credential.model.CredentialSummary;
 import org.apache.airavata.credential.model.PasswordCredential;
 import org.apache.airavata.credential.model.SSHCredential;
 import org.apache.airavata.credential.model.SummaryType;
-import org.apache.airavata.helix.core.support.adaptor.AdaptorSupportImpl;
+import org.apache.airavata.helix.task.api.support.AdaptorSupport;
 import org.apache.airavata.messaging.core.MessageContext;
 import org.apache.airavata.messaging.core.MessagingFactory;
 import org.apache.airavata.messaging.core.Publisher;
@@ -215,6 +215,8 @@ public class AiravataService {
     private final org.apache.airavata.service.application.ApplicationService 
applicationService;
     private final org.apache.airavata.service.security.AuthorizationService 
authorizationService;
     private final org.apache.airavata.service.sharing.SharingManager 
sharingManager;
+    private final AdaptorSupport adaptorSupport;
+    private final MessagingFactory messagingFactory;
 
     private Publisher statusPublisher;
     private Publisher experimentPublisher;
@@ -232,7 +234,9 @@ public class AiravataService {
             org.apache.airavata.service.data.DataProductService 
dataProductService,
             org.apache.airavata.service.application.ApplicationService 
applicationService,
             org.apache.airavata.service.security.AuthorizationService 
authorizationService,
-            org.apache.airavata.service.sharing.SharingManager sharingManager) 
{
+            org.apache.airavata.service.sharing.SharingManager sharingManager,
+            AdaptorSupport adaptorSupport,
+            MessagingFactory messagingFactory) {
         this.properties = properties;
         this.registryService = registryService;
         this.sharingRegistryService = sharingRegistryService;
@@ -246,6 +250,8 @@ public class AiravataService {
         this.applicationService = applicationService;
         this.authorizationService = authorizationService;
         this.sharingManager = sharingManager;
+        this.adaptorSupport = adaptorSupport;
+        this.messagingFactory = messagingFactory;
 
         logger.info("Initialized RegistryService");
         logger.info("Initialized SharingRegistryService");
@@ -257,7 +263,7 @@ public class AiravataService {
     public void initializePublishers() throws AiravataException {
         logger.info("[BEAN-INIT] AiravataService.initializePublishers() 
called");
         try {
-            statusPublisher = MessagingFactory.getPublisher(Type.STATUS);
+            statusPublisher = messagingFactory.getPublisher(Type.STATUS);
             logger.info("[BEAN-INIT] Initialized StatusPublisher");
         } catch (AiravataException e) {
             String msg = String.format(
@@ -267,7 +273,7 @@ public class AiravataService {
         }
 
         try {
-            experimentPublisher = 
MessagingFactory.getPublisher(Type.EXPERIMENT_LAUNCH);
+            experimentPublisher = 
messagingFactory.getPublisher(Type.EXPERIMENT_LAUNCH);
             logger.info("[BEAN-INIT] Initialized ExperimentPublisher");
         } catch (AiravataException e) {
             String msg = String.format(
@@ -3876,8 +3882,8 @@ public class AiravataService {
             }
         }
 
-        AgentAdaptor adaptor = AdaptorSupportImpl.getInstance()
-                .fetchComputeSSHAdaptor(gatewayId, resourceId, 
credentialToken, userId, loginUserName);
+        AgentAdaptor adaptor = adaptorSupport.fetchComputeSSHAdaptor(
+                gatewayId, resourceId, credentialToken, userId, loginUserName);
         logger.info("Resolved resource {} as compute resource to fetch storage 
details", resourceId);
 
         return new StorageInfoContext(loginUserName, credentialToken, adaptor);
@@ -3985,8 +3991,8 @@ public class AiravataService {
             }
         }
 
-        AgentAdaptor adaptor = AdaptorSupportImpl.getInstance()
-                .fetchStorageSSHAdaptor(gatewayId, resourceId, 
credentialToken, userId, loginUserName);
+        AgentAdaptor adaptor = adaptorSupport.fetchStorageSSHAdaptor(
+                gatewayId, resourceId, credentialToken, userId, loginUserName);
         logger.info("Resolved resource {} as storage resource to fetch storage 
details", resourceId);
 
         return new StorageInfoContext(loginUserName, credentialToken, adaptor);
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/service/experiment/impl/ExperimentServiceImpl.java
 
b/airavata-api/src/main/java/org/apache/airavata/service/experiment/impl/ExperimentServiceImpl.java
index 7d9aa86f74..6129f66ec7 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/service/experiment/impl/ExperimentServiceImpl.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/service/experiment/impl/ExperimentServiceImpl.java
@@ -50,12 +50,14 @@ public class ExperimentServiceImpl implements 
ExperimentService {
     private static final Logger logger = 
LoggerFactory.getLogger(ExperimentServiceImpl.class);
 
     private final RegistryService registryService;
+    private final MessagingFactory messagingFactory;
     private Publisher statusPublisher;
 
-    public ExperimentServiceImpl(RegistryService registryService) {
+    public ExperimentServiceImpl(RegistryService registryService, 
MessagingFactory messagingFactory) {
         this.registryService = registryService;
+        this.messagingFactory = messagingFactory;
         try {
-            statusPublisher = MessagingFactory.getPublisher(Type.STATUS);
+            statusPublisher = messagingFactory.getPublisher(Type.STATUS);
         } catch (Exception e) {
             logger.warn("StatusPublisher unavailable: " + e.getMessage());
         }
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/service/orchestrator/OrchestratorService.java
 
b/airavata-api/src/main/java/org/apache/airavata/service/orchestrator/OrchestratorService.java
index 90fbaac53b..0a17684999 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/service/orchestrator/OrchestratorService.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/service/orchestrator/OrchestratorService.java
@@ -105,6 +105,7 @@ public class OrchestratorService {
     private final AiravataServerProperties properties;
     private final ProcessScheduler processScheduler;
     private final SimpleOrchestratorImpl orchestrator;
+    private final MessagingFactory messagingFactory;
 
     private CuratorFramework curatorClient;
     private Publisher publisher;
@@ -115,12 +116,14 @@ public class OrchestratorService {
             RegistryService registryService,
             AiravataServerProperties properties,
             SimpleOrchestratorImpl orchestrator,
-            ProcessScheduler processScheduler) {
+            ProcessScheduler processScheduler,
+            MessagingFactory messagingFactory) {
         this.orchestratorRegistryService = orchestratorRegistryService;
         this.registryService = registryService;
         this.properties = properties;
         this.orchestrator = orchestrator;
         this.processScheduler = processScheduler;
+        this.messagingFactory = messagingFactory;
     }
 
     @PostConstruct
@@ -137,7 +140,7 @@ public class OrchestratorService {
 
     private void initializeInternal() throws OrchestratorException {
         try {
-            this.publisher = MessagingFactory.getPublisher(Type.STATUS);
+            this.publisher = messagingFactory.getPublisher(Type.STATUS);
         } catch (AiravataException e) {
             logger.warn(
                     "Failed to initialize StatusPublisher for 
OrchestratorService: {}. Publisher will be unavailable.",
@@ -922,7 +925,7 @@ public class OrchestratorService {
     private Subscriber getExperimentSubscriber() throws AiravataException {
         List<String> routingKeys = new ArrayList<>();
         routingKeys.add(properties.rabbitmq.experimentLaunchQueueName);
-        return MessagingFactory.getSubscriber(new ExperimentHandler(), 
routingKeys, Type.EXPERIMENT_LAUNCH);
+        return messagingFactory.getSubscriber(new ExperimentHandler(), 
routingKeys, Type.EXPERIMENT_LAUNCH);
     }
 
     private class ExperimentHandler implements MessageHandler {
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/sharing/messaging/SharingServiceDBEventHandler.java
 
b/airavata-api/src/main/java/org/apache/airavata/sharing/messaging/SharingServiceDBEventHandler.java
index 722c9401cc..9e9e1cef8e 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/sharing/messaging/SharingServiceDBEventHandler.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/sharing/messaging/SharingServiceDBEventHandler.java
@@ -50,9 +50,13 @@ public class SharingServiceDBEventHandler implements 
MessageHandler {
     private static final ObjectMapper objectMapper = new ObjectMapper();
 
     private final SharingRegistryService sharingRegistryService;
+    private final SharingServiceDBEventMessagingFactory messagingFactory;
 
-    public SharingServiceDBEventHandler(SharingRegistryService 
sharingRegistryService) {
+    public SharingServiceDBEventHandler(
+            SharingRegistryService sharingRegistryService,
+            SharingServiceDBEventMessagingFactory messagingFactory) {
         this.sharingRegistryService = sharingRegistryService;
+        this.messagingFactory = messagingFactory;
     }
 
     @Override
@@ -371,7 +375,7 @@ public class SharingServiceDBEventHandler implements 
MessageHandler {
             }
 
             log.info("Sending ack. Message Delivery Tag : " + 
messageContext.getDeliveryTag());
-            
SharingServiceDBEventMessagingFactory.getDBEventSubscriber().sendAck(messageContext.getDeliveryTag());
+            
messagingFactory.getDBEventSubscriber().sendAck(messageContext.getDeliveryTag());
 
         } catch (SharingRegistryException e) {
             log.error("Error processing message.", e);
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/sharing/messaging/SharingServiceDBEventMessagingFactory.java
 
b/airavata-api/src/main/java/org/apache/airavata/sharing/messaging/SharingServiceDBEventMessagingFactory.java
index 70375a0f95..003a689d0c 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/sharing/messaging/SharingServiceDBEventMessagingFactory.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/sharing/messaging/SharingServiceDBEventMessagingFactory.java
@@ -46,16 +46,17 @@ public class SharingServiceDBEventMessagingFactory {
 
     private static final Logger log = 
LoggerFactory.getLogger(SharingServiceDBEventMessagingFactory.class);
 
-    private static Publisher dbEventPublisher;
+    private Publisher dbEventPublisher;
 
-    private static Subscriber sharingServiceDBEventSubscriber;
-    private static SharingServiceDBEventMessagingFactory instance;
+    private Subscriber sharingServiceDBEventSubscriber;
 
     private final SharingRegistryService sharingRegistryService;
+    private final MessagingFactory messagingFactory;
 
-    public SharingServiceDBEventMessagingFactory(SharingRegistryService 
sharingRegistryService) {
+    public SharingServiceDBEventMessagingFactory(
+            SharingRegistryService sharingRegistryService, MessagingFactory 
messagingFactory) {
         this.sharingRegistryService = sharingRegistryService;
-        instance = this;
+        this.messagingFactory = messagingFactory;
     }
 
     /**
@@ -64,12 +65,12 @@ public class SharingServiceDBEventMessagingFactory {
      * @return
      * @throws AiravataException
      */
-    private static Publisher getDBEventPublisher() throws AiravataException {
+    public Publisher getDBEventPublisher() throws AiravataException {
         if (null == dbEventPublisher) {
-            synchronized (SharingServiceDBEventMessagingFactory.class) {
+            synchronized (this) {
                 if (null == dbEventPublisher) {
                     log.info("Creating DB Event publisher.....");
-                    dbEventPublisher = MessagingFactory.getDBEventPublisher();
+                    dbEventPublisher = messagingFactory.getDBEventPublisher();
                     log.info("DB Event publisher created");
                 }
             }
@@ -77,25 +78,20 @@ public class SharingServiceDBEventMessagingFactory {
         return dbEventPublisher;
     }
 
-    public static Subscriber getDBEventSubscriber() throws AiravataException, 
SharingRegistryException {
+    public Subscriber getDBEventSubscriber() throws AiravataException, 
SharingRegistryException {
         if (null == sharingServiceDBEventSubscriber) {
-            synchronized (SharingServiceDBEventMessagingFactory.class) {
+            synchronized (this) {
                 if (null == sharingServiceDBEventSubscriber) {
                     SharingServiceDBEventHandler handler;
                     String serviceName = DBEventService.SHARING.toString();
                     log.info("Creating DB Event subscriber for service: " + 
serviceName);
                     try {
-                        SharingRegistryService service = instance != null ? 
instance.sharingRegistryService : null;
-                        if (service == null) {
-                            throw new IllegalStateException(
-                                    "SharingServiceDBEventMessagingFactory not 
initialized via Spring");
-                        }
-                        handler = new SharingServiceDBEventHandler(service);
+                        handler = new 
SharingServiceDBEventHandler(sharingRegistryService, this);
                     } catch (Exception e) {
                         throw new AiravataException(
                                 "Failed to create sharing service DB event 
handler for service: " + serviceName, e);
                     }
-                    sharingServiceDBEventSubscriber = 
MessagingFactory.getDBEventSubscriber(handler, serviceName);
+                    sharingServiceDBEventSubscriber = 
messagingFactory.getDBEventSubscriber(handler, serviceName);
                     log.info("DB Event subscriber created for service: " + 
serviceName);
                 }
             }
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/sharing/repositories/AbstractRepository.java
 
b/airavata-api/src/main/java/org/apache/airavata/sharing/repositories/AbstractRepository.java
index 5c769c9600..8fd1f54c58 100644
--- 
a/airavata-api/src/main/java/org/apache/airavata/sharing/repositories/AbstractRepository.java
+++ 
b/airavata-api/src/main/java/org/apache/airavata/sharing/repositories/AbstractRepository.java
@@ -34,6 +34,11 @@ import org.slf4j.LoggerFactory;
 import org.springframework.orm.jpa.SharedEntityManagerCreator;
 import org.springframework.transaction.annotation.Transactional;
 
+/**
+ * @deprecated This class is legacy and unused. All repositories now use 
Spring Data JPA interfaces.
+ *             This class should not be extended. Use JpaRepository interfaces 
instead.
+ */
+@Deprecated
 public abstract class AbstractRepository<T, E, Id> {
 
     private EntityManager entityManager;
diff --git 
a/airavata-api/src/main/java/org/apache/airavata/sharing/utils/JPAUtils.java 
b/airavata-api/src/main/java/org/apache/airavata/sharing/utils/JPAUtils.java
index 569d31af4d..a6d458cd6b 100644
--- a/airavata-api/src/main/java/org/apache/airavata/sharing/utils/JPAUtils.java
+++ b/airavata-api/src/main/java/org/apache/airavata/sharing/utils/JPAUtils.java
@@ -46,6 +46,11 @@ public class JPAUtils {
         logger.info("[BEAN-INIT] SharingRegistry JPAUtils static instance set 
successfully");
     }
 
+    /**
+     * @deprecated Use dependency injection to inject the JPAUtils bean 
instead of calling static methods.
+     *             This method is kept for backward compatibility only.
+     */
+    @Deprecated
     public static EntityManager getEntityManager() {
         if (instance == null || instance.factory == null) {
             throw new IllegalStateException("SharingRegistry JPAUtils not 
initialized. Make sure it's a Spring bean.");
@@ -53,6 +58,11 @@ public class JPAUtils {
         return instance.factory.createEntityManager();
     }
 
+    /**
+     * @deprecated Use dependency injection to inject the JPAUtils bean 
instead of calling static methods.
+     *             This method is kept for backward compatibility only.
+     */
+    @Deprecated
     public static EntityManagerFactory getEntityManagerFactory() {
         if (instance == null || instance.factory == null) {
             throw new IllegalStateException("SharingRegistry JPAUtils not 
initialized. Make sure it's a Spring bean.");
diff --git 
a/modules/file-server/src/main/java/org/apache/airavata/file/server/FileServerConfiguration.java
 
b/modules/file-server/src/main/java/org/apache/airavata/file/server/FileServerConfiguration.java
index bfd1348e94..ecc9887e49 100644
--- 
a/modules/file-server/src/main/java/org/apache/airavata/file/server/FileServerConfiguration.java
+++ 
b/modules/file-server/src/main/java/org/apache/airavata/file/server/FileServerConfiguration.java
@@ -19,7 +19,6 @@
 */
 package org.apache.airavata.file.server;
 
-import org.apache.airavata.helix.core.support.adaptor.AdaptorSupportImpl;
 import org.apache.airavata.helix.task.api.support.AdaptorSupport;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Bean;
@@ -29,9 +28,15 @@ import org.springframework.stereotype.Component;
 @ConfigurationProperties
 public class FileServerConfiguration {
 
+    private final AdaptorSupport adaptorSupport;
+
+    public FileServerConfiguration(AdaptorSupport adaptorSupport) {
+        this.adaptorSupport = adaptorSupport;
+    }
+
     @Bean
-    public AdaptorSupport adaptorSupport() {
-        return AdaptorSupportImpl.getInstance();
+    public AdaptorSupport adaptorSupportBean() {
+        return adaptorSupport;
     }
 
     // RegistryService is already a @Service bean, no need to create it here
diff --git 
a/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/handler/RegistryServiceHandler.java
 
b/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/handler/RegistryServiceHandler.java
index 18f393a4ca..737da5cb02 100644
--- 
a/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/handler/RegistryServiceHandler.java
+++ 
b/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/handler/RegistryServiceHandler.java
@@ -160,7 +160,6 @@ public class RegistryServiceHandler implements 
org.apache.airavata.thriftapi.reg
     private final ComputeResourcePolicyMapper computeResourcePolicyMapper = 
ComputeResourcePolicyMapper.INSTANCE;
     private final BatchQueueResourcePolicyMapper 
batchQueueResourcePolicyMapper =
             BatchQueueResourcePolicyMapper.INSTANCE;
-    private final JobStatusMapper jobStatusMapper = JobStatusMapper.INSTANCE;
     private final GatewayUsageReportingCommandMapper 
gatewayUsageReportingCommandMapper =
             GatewayUsageReportingCommandMapper.INSTANCE;
     private final QueueStatusModelMapper queueStatusModelMapper = 
QueueStatusModelMapper.INSTANCE;
@@ -233,13 +232,6 @@ public class RegistryServiceHandler implements 
org.apache.airavata.thriftapi.reg
         return exception;
     }
 
-    private DuplicateEntryException convertToThriftDuplicateEntryException(
-            org.apache.airavata.common.exception.DuplicateEntryException e) {
-        DuplicateEntryException exception = new DuplicateEntryException();
-        exception.setMessage(e.getMessage());
-        return exception;
-    }
-
     /**
      * Fetch Apache Registry API version
      */
diff --git 
a/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/OrchestratorServiceServer.java
 
b/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/OrchestratorServiceServer.java
index 9894a74f2e..2682020b0a 100644
--- 
a/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/OrchestratorServiceServer.java
+++ 
b/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/OrchestratorServiceServer.java
@@ -48,7 +48,7 @@ public class OrchestratorServiceServer implements IServer {
 
     private TServer server;
 
-    private static ComputationalResourceMonitoringService monitoringService;
+    private final ComputationalResourceMonitoringService monitoringService;
 
     private final ProcessReschedulingService metaschedulerService;
     private final DataInterpreterService dataInterpreterService;
@@ -62,11 +62,13 @@ public class OrchestratorServiceServer implements IServer {
             ApplicationContext applicationContext,
             AiravataServerProperties properties,
             ProcessReschedulingService metaschedulerService,
-            DataInterpreterService dataInterpreterService) {
+            DataInterpreterService dataInterpreterService,
+            ComputationalResourceMonitoringService monitoringService) {
         this.applicationContext = applicationContext;
         this.properties = properties;
         this.metaschedulerService = metaschedulerService;
         this.dataInterpreterService = dataInterpreterService;
+        this.monitoringService = monitoringService;
         setStatus(ServerStatus.STOPPED);
     }
 
@@ -115,11 +117,8 @@ public class OrchestratorServiceServer implements IServer {
         //        
clusterStatusMonitorJobScheduler.scheduleClusterStatusMonitoring();
 
         try {
-            if (monitoringService == null) {
-                monitoringService = new 
ComputationalResourceMonitoringService(properties);
-                monitoringService.setServerStatus(ServerStatus.STARTING);
-            }
             if (monitoringService != null && 
!monitoringService.getStatus().equals(ServerStatus.STARTED)) {
+                monitoringService.setServerStatus(ServerStatus.STARTING);
                 monitoringService.start();
                 monitoringService.setServerStatus(ServerStatus.STARTED);
                 logger.info("Airavata compute resource monitoring service 
started ....");
diff --git 
a/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/RegistryServiceServer.java
 
b/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/RegistryServiceServer.java
index 288f1f093e..75bb1e1d14 100644
--- 
a/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/RegistryServiceServer.java
+++ 
b/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/RegistryServiceServer.java
@@ -59,6 +59,7 @@ public class RegistryServiceServer implements IServer {
     private final ExpCatalogDBInitConfig expCatalogDBInitConfig;
     private final AppCatalogDBInitConfig appCatalogDBInitConfig;
     private final ReplicaCatalogDBInitConfig replicaCatalogDBInitConfig;
+    private final RegistryServiceDBEventMessagingFactory messagingFactory;
 
     private List<DBInitConfig> dbInitConfigs;
 
@@ -67,12 +68,14 @@ public class RegistryServiceServer implements IServer {
             AiravataServerProperties properties,
             ExpCatalogDBInitConfig expCatalogDBInitConfig,
             AppCatalogDBInitConfig appCatalogDBInitConfig,
-            ReplicaCatalogDBInitConfig replicaCatalogDBInitConfig) {
+            ReplicaCatalogDBInitConfig replicaCatalogDBInitConfig,
+            RegistryServiceDBEventMessagingFactory messagingFactory) {
         this.applicationContext = applicationContext;
         this.properties = properties;
         this.expCatalogDBInitConfig = expCatalogDBInitConfig;
         this.appCatalogDBInitConfig = appCatalogDBInitConfig;
         this.replicaCatalogDBInitConfig = replicaCatalogDBInitConfig;
+        this.messagingFactory = messagingFactory;
         setStatus(ServerStatus.STOPPED);
     }
 
@@ -141,7 +144,7 @@ public class RegistryServiceServer implements IServer {
                     RegistryServiceConstants.DB_EVENT_SUBSCRIBERS);
 
             logger.info("Starting registry service db-event-handler 
subscriber.");
-            RegistryServiceDBEventMessagingFactory.getDBEventSubscriber();
+            messagingFactory.getDBEventSubscriber();
         } catch (Exception ex) {
             logger.error("Failed to start database event handlers, reason: " + 
ex.getMessage(), ex);
             return false;
diff --git 
a/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/SharingRegistryServer.java
 
b/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/SharingRegistryServer.java
index 1ebde74f4e..201cfd81ce 100644
--- 
a/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/SharingRegistryServer.java
+++ 
b/modules/thrift-api/src/main/java/org/apache/airavata/thriftapi/server/SharingRegistryServer.java
@@ -55,10 +55,15 @@ public class SharingRegistryServer implements IServer {
 
     private final ApplicationContext applicationContext;
     private final AiravataServerProperties properties;
+    private final SharingServiceDBEventMessagingFactory messagingFactory;
 
-    public SharingRegistryServer(ApplicationContext applicationContext, 
AiravataServerProperties properties) {
+    public SharingRegistryServer(
+            ApplicationContext applicationContext,
+            AiravataServerProperties properties,
+            SharingServiceDBEventMessagingFactory messagingFactory) {
         this.applicationContext = applicationContext;
         this.properties = properties;
+        this.messagingFactory = messagingFactory;
         setStatus(IServer.ServerStatus.STOPPED);
     }
 
@@ -124,7 +129,7 @@ public class SharingRegistryServer implements IServer {
                                         SharingRegistryConstants.PUBLISHERS);
 
                                 logger.info("Start sharing service DB Event 
subscriber");
-                                
SharingServiceDBEventMessagingFactory.getDBEventSubscriber();
+                                messagingFactory.getDBEventSubscriber();
                             } catch (AiravataException | 
SharingRegistryException e) {
                                 logger.error("Error starting sharing service. 
Error setting up DB event services.");
                                 server.stop();

Reply via email to