Skip to content

Commit

Permalink
Adding realtime event notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashi1993 committed Nov 11, 2024
1 parent 3ce2364 commit 8f40d67
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
Expand All @@ -23,8 +23,14 @@
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.wso2.carbon.identity.oauth2.OAuth2Service;
import org.wso2.financial.services.accelerator.common.config.FinancialServicesConfigParser;
import org.wso2.financial.services.accelerator.common.config.FinancialServicesConfigurationService;
import org.wso2.financial.services.accelerator.event.notifications.service.realtime.service.RealtimeEventNotificationLoaderService;
import org.wso2.financial.services.accelerator.event.notifications.service.realtime.util.activator.PeriodicalEventNotificationConsumerJobActivator;

/**
* The Component class for activating event notification osgi service.
Expand All @@ -33,22 +39,52 @@
name = "org.wso2.financial.services.accelerator.event.notifications.service.internal.EventNotificationComponent",
immediate = true)
public class EventNotificationComponent {
private static Log log = LogFactory.getLog(EventNotificationComponent.class);
private static final Log log = LogFactory.getLog(EventNotificationComponent.class);

@Activate
protected void activate(ComponentContext context) {
log.debug("Event Notification Service Component Activated");
protected void activate(ComponentContext context) throws Exception {
log.info("Event Notification Service Component Activated");

// Check if realtime event notification enabled
if (FinancialServicesConfigParser.getInstance().isRealtimeEventNotificationEnabled()) {
/*
* Initialize the blocking queue for storing the realtime event notifications
* Initialize the quartz job for consuming the realtime event notifications
* Initialize the thread for producing the open state realtime event notifications
*/
log.debug("Event Notification####");
new Thread(new RealtimeEventNotificationLoaderService()).start();
// new PeriodicalEventNotificationConsumerJobActivator().activate();
new PeriodicalEventNotificationConsumerJobActivator().activate();
}
}

/**
* Setters for the descendent OSGI services of the EventNotificationComponent.
* This is added to run the EventNotification OSGI component after the Common module
*/
@Reference(
service = FinancialServicesConfigurationService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetConfigService"
)
public void setConfigService(FinancialServicesConfigurationService configurationService) {
EventNotificationDataHolder.getInstance().setConfigService(configurationService);
}

public void unsetConfigService(FinancialServicesConfigurationService configurationService) {
EventNotificationDataHolder.getInstance().setConfigService(null);
}

/**
* Setters for the descendent OSGI services of the EventNotificationComponent.
* This is added to run the EventNotification OSGI component after the OAuth2Service
*/
@Reference(
service = OAuth2Service.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetOAuth2Service"
)

public void setOAuth2Service(OAuth2Service oAuth2Service) {
}

public void unsetOAuth2Service(OAuth2Service oAuth2Service) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,14 @@ public LinkedBlockingQueue<RealtimeEventNotification> getRealtimeEventNotificati
public void setRealtimeEventNotificationQueue(LinkedBlockingQueue<RealtimeEventNotification> queue) {
this.realtimeEventNotificationQueue = queue;
}

public FinancialServicesConfigurationService getConfigService() {

return configService;
}

public void setConfigService(FinancialServicesConfigurationService configService) {

this.configService = configService;
}
}

0 comments on commit 8f40d67

Please sign in to comment.