Expand my Community achievements bar.

SOLVED

Component is in satisfied state but not in active state in OSGI console

Avatar

Level 4

I a trying to connect to a Oracle DB using java code in an AEM application. For that I have configured everything in connections pool in OSGI console and I am trying to get the appropriate data soure using java code. Below are the details:

package com.pnc.main.businessddaapp.dao.datasource.impl;

 

import javax.sql.DataSource;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.day.commons.datasource.poolservice.DataSourceNotFoundException;
import com.day.commons.datasource.poolservice.DataSourcePool;
import com.xxx.businessddaapp.dao.datasource.BusinessDDAApplicationDataSource;

@Component(metatype = true)

@Service

public class BusinessDDAApplicationDataSourceImpl implements  BusinessDDAApplicationDataSource {

    
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
    
    private static final String DEFAULT_BUSINESSDDA_INTEGRATION_DATASOURCE = "KIDS";


    @Reference
    private DataSourcePool source;
    
    @Override
    public DataSource getDataSource() {
        
        DataSource dataSource = null;
        
        try {
            dataSource = (DataSource) source.getDataSource(DEFAULT_BUSINESSDDA_INTEGRATION_DATASOURCE);
            return dataSource;
        } catch (DataSourceNotFoundException e) {
            logger.error("Datasource not configured/not found", e);
        } catch (Exception e) {
            logger.error("Exception while getting the datasource ", e);
        }
        return null;
        
    }

    
}

 

But for some reason, when I check the OSGI console(http://localhost:4503/system/console/components) this class/component is in satisfied state and thus its not getting called while running the application. What changes do I need to make in order to make this component active ? Do I need to add any other configurations ?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Watch the HELPX video where we step through all of the steps: 

https://youtu.be/yYo1epoZp_4

As you can see in this video - when we create the OSGi bundle using Maven and add the Database driver file - it works... 

View solution in original post

5 Replies

Avatar

Administrator

Hi 

Satisfied is a state of a bundle where all the dependencies of that bundle is reachable or available but it doesn't depict the life cycle of a bundle.

Please have a look at this excellent community article:- 

Link:- http://blog.christianposta.com/osgi/understanding-how-osgi-bundles-get-resolved-part-i/

// Understanding how OSGI bundles get resolved

 

Old Forum post:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

I hope this would help you.

 

~kautuk



Kautuk Sahni

Avatar

Administrator

Working example of DataSourcePool with MySql is :- https://helpx.adobe.com/experience-manager/using/datasourcepool.html

You could use it as a reference.

~kautuk



Kautuk Sahni

Avatar

Level 4

Hi,

Add @ Activate and @Deactivate methods it will become active inplace of satisfied..

Hope that helps.

Avatar

Correct answer by
Level 10

Watch the HELPX video where we step through all of the steps: 

https://youtu.be/yYo1epoZp_4

As you can see in this video - when we create the OSGi bundle using Maven and add the Database driver file - it works...