Multitenant and AbstractLifecycleBean
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2012 05:14 AM
Hi,
I created a class that extends AbstractLifecycleBean (overriding onBootstrap method) for execute my startup code. It works.
But I must run my code for each tenant.
How can I execute a method for each tenant at startup?
I read docs and wiki, but nothing…
Thanks
-ft
I created a class that extends AbstractLifecycleBean (overriding onBootstrap method) for execute my startup code. It works.
But I must run my code for each tenant.
How can I execute a method for each tenant at startup?
I read docs and wiki, but nothing…
Thanks
-ft
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2012 06:21 AM
One option is to inject the TenantAdminService and loop through the tenants, although you should consider how many tenants you may have and how long each method call may take per tenant.
Here's an example snippet:
If you scan through the existing source code and look for "getAllTenants" then you will see some similar examples.
Regards,
Jan
Here's an example snippet:
if ((tenantAdminService != null) && (tenantAdminService.isEnabled())) { for (Tenant tenant : tenantAdminService.getAllTenants()) { AuthenticationUtil.runAs(new RunAsWork<Void>() { public Void doWork() throws Exception { // do some work here // …. return null; } }, tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenant.getTenantDomain())); } }
If you scan through the existing source code and look for "getAllTenants" then you will see some similar examples.
Regards,
Jan
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2012 07:38 AM
Hi,
thanks for reply
I have tried a similar code, but the row
I will try your suggestion.
Thanks!!!!!
-ft
thanks for reply
I have tried a similar code, but the row
tenantAdminService.getDomainUser(AuthenticationUtil.getSystemUserName(), tenant.getTenantDomain()))
was different.I will try your suggestion.
Thanks!!!!!
-ft