The only example I could find is the source of SQL Plugin. However, it seemed to be too low level and I would prefer to use Spring to handle it. Here comes my solution:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:jee="http://www.springframework.org/schema/jee" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd | |
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd" | |
default-autowire="autodetect"> | |
<jee:jndi-lookup | |
id="bthDatasource" | |
jndi-name="java:comp/env/jdbc/bthDatasource" | |
proxy-interface="javax.sql.DataSource" | |
lookup-on-startup="false" /> | |
<bean id="bthJdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate"> | |
<constructor-arg ref="bthDatasource"/> | |
</bean> | |
</beans> |
You can see here, that I'm using lazy look up with proxy interface. I had to do it, because otherwise look up happens when plugin is installed or activated and for some reason, JNDI datasource that I defined was not visible to that thread.
Unfortunately, OSGI bundle makes it a bit tricky, as some required classes will be missing and you have to instruct Felix to import them:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plugin> | |
<groupId>com.atlassian.maven.plugins</groupId> | |
<artifactId>maven-confluence-plugin</artifactId> | |
<version>3.8</version> | |
<extensions>true</extensions> | |
<configuration> | |
<productVersion>${confluence.version}</productVersion> | |
<productDataVersion>${confluence.data.version}</productDataVersion> | |
<instructions> | |
<Import-Package> | |
org.springframework.aop;version="0.0.0", | |
org.springframework.aop.framework;version="0.0.0", | |
org.aopalliance.aop;version="1.0", | |
javax.sql;version="0.0.0", | |
*;version="0.0" | |
</Import-Package> | |
</instructions> | |
</configuration> | |
</plugin> |
No comments:
Post a Comment