Hidanushka,
Yes I checked debugging. No it is not hitting active method when I add
following reference
* @scr.reference name="tenant.tenantManagementService"
*
interface="org.wso2.carbon.appfactory.tenant.mgt.service.TenantManagementService"
cardinality="0..1"
* policy="dynamic" bind="*setTenantManagementService*" unbind="
*unsetTenantManagementService*"
Service Component Class
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.cloud.tenantdeletion.StartDeletor;
import
org.wso2.carbon.cloud.tenantdeletion.listeners.CloudUserOperationListener;
import
org.wso2.carbon.cloud.tenantdeletion.listeners.UserStoreConfgurationContextObserver;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.registry.core.service.TenantRegistryLoader;
import org.wso2.carbon.user.core.listener.UserOperationEventListener;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
*import
org.wso2.carbon.appfactory.tenant.mgt.service.TenantManagementService;*
/**
* @scr.component name="wso2.carbon.cloud.tenantdeletion" immediate="true"
* @scr.reference name="realm.service"
* interface="org.wso2.carbon.user.core.service.RealmService"
cardinality="1..1"
* policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
* @scr.reference name="registry.service"
* interface="org.wso2.carbon.registry.core.service.RegistryService"
cardinality="1..1"
* policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService
* @scr.reference name="tenant.registryloader"
* interface="org.wso2.carbon.registry.core.service.TenantRegistryLoader"
cardinality="1..1"
* policy="dynamic" bind="setTenantRegistryLoader"
unbind="unsetTenantRegistryLoader"
* * @scr.reference name="tenant.tenantManagementService" *
interface="org.wso2.carbon.appfactory.tenant.mgt.service.TenantManagementService"
cardinality="0..1" * policy="dynamic" bind="setTenantManagementService"
unbind="unsetTenantManagementService"*
*/
public class TenantDeletionServiceComponent {
private final static Log logger =
LogFactory.getLog(TenantDeletionServiceComponent.class);
private ServiceRegistration userOperationEventListenerRef;
private ServiceRegistration contextObserverRef;
/**
* Method to activate bundle.
* @param context OSGi component context.
*/
protected void activate(ComponentContext context) {
BundleContext bundleContext = context.getBundleContext();
try {
CloudUserOperationListener cloudUserOperationListener = new
CloudUserOperationListener();
UserStoreConfgurationContextObserver
userStoreConfgurationContextObserver = new
UserStoreConfgurationContextObserver();
this.userOperationEventListenerRef =
bundleContext.registerService(UserOperationEventListener.class
.getName(),
cloudUserOperationListener, null);
this.contextObserverRef =
bundleContext.registerService(Axis2ConfigurationContextObserver.class.getName(),
userStoreConfgurationContextObserver, null);
} catch (Exception e) {
logger.error("Failed to activate the Tenant Deletion service.", e);
}
if (logger.isDebugEnabled()) {
logger.debug("Tenant Deletionservice component activated
successfully.");
}
StartDeletor.getInstance().startDeletion();
}
/**
* Method to deactivate bundle.
* @param context OSGi component context.
*/
protected void deactivate(ComponentContext context) {
this.userOperationEventListenerRef.unregister();
this.contextObserverRef.unregister();
if (logger.isDebugEnabled()) {
logger.debug("Tenant Deletionservice component is deactivated ");
}
}
/**
* Method to set registry service.
* @param registryService service to get tenant data.
*/
protected void setRegistryService(RegistryService registryService) {
if (logger.isDebugEnabled()) {
logger.debug("Setting RegistryService.");
}
ServiceHolder.getInstance().setRegistryService(registryService);
}
/**
* Method to unset registry service.
* @param registryService service to get registry data.
*/
protected void unsetRegistryService(RegistryService registryService) {
if (logger.isDebugEnabled()) {
logger.debug("Unset Registry service.");
}
ServiceHolder.getInstance().setRegistryService(null);
}
/**
* Method to set realm service.
* @param realmService service to get tenant data.
*/
protected void setRealmService(RealmService realmService) {
ServiceHolder.getInstance().setRealmService(realmService);
if (logger.isDebugEnabled()) {
logger.debug("Realm service initialized");
}
}
/**
* Method to unset realm service.
* @param realmService service to get tenant data.
*/
protected void unsetRealmService(RealmService realmService) {
ServiceHolder.getInstance().setRealmService(null);
}
/**
* Method to set tenant registry loader
* @param tenantRegLoader tenant registry loader
*/
protected void setTenantRegistryLoader(TenantRegistryLoader
tenantRegLoader) {
if (logger.isDebugEnabled()) {
logger.debug("Setting TenantRegistryLoader.");
}
ServiceHolder.getInstance().setTenantRegLoader(tenantRegLoader);
}
/**
* Method to unset tenant registry loader
* @param tenantRegLoader tenant registry loader
*/
protected void unsetTenantRegistryLoader(TenantRegistryLoader
tenantRegLoader) {
if (logger.isDebugEnabled()) {
logger.debug("Unset Tenant Registry Loader.");
}
ServiceHolder.getInstance().setTenantRegLoader(null);
}
/**
* Method to set tenantManagementService
* @param tenantManagementService tenant management service
*/
* protected void setTenantManagementService(TenantManagementService
tenantManagementService) { if (logger.isDebugEnabled()) {
logger.debug("Set TenantManagementService"); }
ServiceHolder.getInstance().setTenantManagementService(tenantManagementService);
}*
/**
* Method to unset tenantManagementService
* @param tenantManagementService tenant management service
*/
* protected void unsetTenantManagementService(TenantManagementService
tenantManagementService) { if (logger.isDebugEnabled()) {
logger.debug("Unset TenantManagementService"); }
ServiceHolder.getInstance().setTenantManagementService(null); }*
}
On Tue, Jan 26, 2016 at 12:11 AM, Danushka Fernando <[email protected]>
wrote:
> Have you checked debugging? Is it hitting the activate method. And the
> activated service component, does it same as your scr reference name?
>
> Can you attach the service component code? May be its not hitting the
> service component class.
>
> Thanks & Regards
> Danushka Fernando
> Senior Software Engineer
> WSO2 inc. http://wso2.com/
> Mobile : +94716332729
>
> On Mon, Jan 25, 2016 at 12:44 PM, Nipuna Prashan <[email protected]> wrote:
>
>> Hi sameera,
>>
>> yes, service component is also active
>>
>>
>> On Mon, Jan 25, 2016 at 5:29 PM, Sameera Jayasoma <[email protected]>
>> wrote:
>>
>>> Just to be clear, I need service component activation status, not the
>>> bundle status.
>>>
>>> On Mon, Jan 25, 2016 at 5:09 PM, Sameera Jayasoma <[email protected]>
>>> wrote:
>>>
>>>> Can you check whether your service component is activated? You can type
>>>> the "ls" command.
>>>>
>>>>
>>>>
>>>> On Mon, Jan 25, 2016 at 4:56 PM, Nipuna Prashan <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I am writing an osgi component. This same component wants to be
>>>>> deployed in both Appfactory and APIManager servers. Here, I have
>>>>> imported some of the appfactory packages such as
>>>>> org.wso2.carbon.appfactory.application.mgt.* which will not be
>>>>> resolved in APIM 1.9.1.
>>>>> Then I used ;resolution:=optional in the pom file for those packages
>>>>> and I set service component reference cardinality to "0..1"
>>>>>
>>>>> @scr.reference name="application.applicationInfoService"
>>>>>
>>>>> interface="org.wso2.carbon.appfactory.application.mgt.service.ApplicationInfoService"
>>>>> cardinality="0..1"
>>>>> policy="dynamic" bind="setApplicationInfoService"
>>>>> unbind="unsetApplicationInfoService"
>>>>>
>>>>> When I start the server(APIM 1.9.1) the log that gets printed when the
>>>>> component gets activated is not printed implying it has not been
>>>>> activated, but osgi console says that the bundle has activated.
>>>>>
>>>>> What would be the problem? Any suggestions would be appreciated.
>>>>>
>>>>> --
>>>>> Nipuna Prashan
>>>>> Software Engineering Intern
>>>>> +94711852792
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Sameera Jayasoma,
>>>> Software Architect,
>>>>
>>>> WSO2, Inc. (http://wso2.com)
>>>> email: [email protected]
>>>> blog: http://blog.sameera.org
>>>> twitter: https://twitter.com/sameerajayasoma
>>>> flickr: http://www.flickr.com/photos/sameera-jayasoma/collections
>>>> Mobile: 0094776364456
>>>>
>>>> Lean . Enterprise . Middleware
>>>>
>>>>
>>>
>>>
>>> --
>>> Sameera Jayasoma,
>>> Software Architect,
>>>
>>> WSO2, Inc. (http://wso2.com)
>>> email: [email protected]
>>> blog: http://blog.sameera.org
>>> twitter: https://twitter.com/sameerajayasoma
>>> flickr: http://www.flickr.com/photos/sameera-jayasoma/collections
>>> Mobile: 0094776364456
>>>
>>> Lean . Enterprise . Middleware
>>>
>>>
>>
>>
>> --
>> *Nipuna Prashan*
>> Software Engineering Intern
>> +94711852792
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
--
*Nipuna Prashan*
Software Engineering Intern
+94711852792
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev