如何在Adobe CQ5.5中使用DataSourcePool?

时间:2014-05-29 09:53:25

标签: java osgi cq5 osgi-bundle sling

我创建了一个@Component,在实例级别的那个组件中,我正在做@Reference DataSourcePool。

但是没有找到Class DataSourcePool,所以我的课程没有编译。我正在使用CRXDE Eclipse。 我已经通过以下链接完成了所有这些。

http://helpx.adobe.com/experience-manager/using/datasourcepool.html

请参阅我的代码和快照。

package com.videojet.hiresite.database;

import java.sql.Connection;
import java.sql.DriverManager;
import com.day.commons.datasource.poolservice.DataSourcePool;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;

@Component
@Service
public class ConnectionProvider {

    @Reference
    private DataSourcePool source;

    public Connection getConnection() throws Exception
    {
        //VideojetDatasource
        Class.forName("oracle.jdbc.driver.OracleDriver");   
        return DriverManager.getConnection("jdbc:oracle:thin:@xxxxxx","xxxx","xxx");

    }

}

enter image description here

那么我是否必须在OSGi Bundle中添加一个额外的Jar才能使用?

更新 @TomekRękawekDude当我说我不使用Maven时,我的意思是。我没有按照整个教程。 这就是我使用它的CRXDE Eclipse enter image description here

2 个答案:

答案 0 :(得分:3)

将以下依赖项添加到pom.xml

<dependency>
    <groupId>com.day.commons</groupId>
    <artifactId>day.commons.datasource.poolservice</artifactId>
    <version>1.0.10</version>
    <scope>provided</scope>
</dependency>

通常,如果您想知道哪个捆绑包包含类,请打开Felix Console,选择 Main / Packages (相对路径:/system/console/depfinder)并输入完整的班级名称(如com.day.commons.datasource.poolservice.DataSourcePool)。你会得到一个<dependency>,你可以复制&amp;粘贴到pom.xml

答案 1 :(得分:0)

我解决了。 我从这里下载了Jar http://repo.adobe.com/nexus/content/groups/public/com/day/commons/day.commons.datasource.poolservice/1.0.10/

我将它粘贴到/ apps / myproject / src / testbundle / libs文件夹中,依赖项已解决。

相关问题