Skip to content

Commit

Permalink
Merge pull request #418 from sahandilshan/custom-event-handler
Browse files Browse the repository at this point in the history
Fix the osgi bundle activation
  • Loading branch information
sahandilshan authored Aug 9, 2023
2 parents fadb57b + 1b336c0 commit 21cb9d0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion event-handler/custom-identity-event-handler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Steps
[[event_handler]]
name= "customUserRegistration"
subscriptions =["PRE_ADD_USER, POST_ADD_USER"]
subscriptions =["PRE_ADD_USER"]
```
4 changes: 2 additions & 2 deletions event-handler/custom-identity-event-handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven.bundle.plugin.version}</version>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
Expand All @@ -76,7 +76,7 @@
</Private-Package>
<Export-Package>
!org.wso2.carbon.identity.customhandler.internal,
org.wso2.carbon.identity.customhandler.*;version="1.0.0",
org.wso2.carbon.identity.customhandler.*;version="${project.version}",
</Export-Package>
<Import-Package>
org.osgi.framework; version="${osgi.framework.imp.pkg.version.range}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.*;
import org.wso2.carbon.identity.event.handler.AbstractEventHandler;
import org.wso2.carbon.identity.customhandler.handler.UserRegistrationCustomEventHandler;
import org.wso2.carbon.user.core.service.RealmService;

/**
* @scr.component name="org.wso2.carbon.identity.customhandler.internal.UserRegistrationCustomEventHandlerComponent" immediate="true"
* @scr.reference name="realm.service"
* interface="org.wso2.carbon.user.core.service.RealmService" cardinality="1..1"
* policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
*/
@Component(
name = "org.wso2.carbon.identity.customhandler.internal.UserRegistrationCustomEventHandlerComponent",
immediate = true
)
public class UserRegistrationCustomEventHandlerComponent {

private static Log log = LogFactory.getLog(UserRegistrationCustomEventHandlerComponent.class);
private UserRegistrationCustomEventHandlerDataHolder dataHolder = UserRegistrationCustomEventHandlerDataHolder
private final UserRegistrationCustomEventHandlerDataHolder dataHolder = UserRegistrationCustomEventHandlerDataHolder
.getInstance();

@Activate
protected void activate(ComponentContext context) {
try {
BundleContext bundleContext = context.getBundleContext();
Expand All @@ -48,12 +48,19 @@ protected void activate(ComponentContext context) {
}
}

@Deactivate
protected void deactivate(ComponentContext context) {
if (log.isDebugEnabled()) {
log.debug("custom self registration handler is de-activated");
}
}

@Reference(
name = "RealmService",
service = org.wso2.carbon.user.core.service.RealmService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetRealmService")
protected void setRealmService(RealmService realmService) {
if (log.isDebugEnabled()) {
log.debug("Setting the Realm Service");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

public class UserRegistrationCustomEventHandlerDataHolder {

private static UserRegistrationCustomEventHandlerDataHolder instance = new UserRegistrationCustomEventHandlerDataHolder();
private static final UserRegistrationCustomEventHandlerDataHolder instance =
new UserRegistrationCustomEventHandlerDataHolder();
private RealmService realmService;

public static UserRegistrationCustomEventHandlerDataHolder getInstance() {
Expand Down

0 comments on commit 21cb9d0

Please sign in to comment.