Spring config for loading resources bundled

I have an osgi package for war that I created from an old web application. The problem is that in the spring configuration there are links to files that are on the class path (see below), which are good when the previous war was deployed to tomcat, as they can be found in the thr file system. However, since osgi does not have a file system concept, these files cannot be found, and I get an exception not found in the file. can anyone call me if I can continue to load class resources in this or similar way. Or I need to download them programmatically using org.springframework.osgi.io.OsgiBundleResource for an example.

<bean id="manager" class="com.xyz.abc.Manager" depends-on="workflowCache">
    <property name="configuration" value="classpath:com/xyz/abc/resource/workflow.xml"/>
</bean>

Thanks in advance.

+3
source share
2 answers

The problem here is almost not related to the fact that OSGi has no concept of a file system, but that the file is no longer in the classpath.

I assume that when the war works in regular tomcat, workflow.xml you refer to the file system and are accessible via the tomcat class path. Loader class for WAR delegates for the parent class loader that has access to the workflow.xml file.

In OSGi, your class path is determined by the Bundle-Classpath and any package import or package requirements. This workflow.xml file is obviously not available through any of these mechanisms.

There are several options:

  • Place the workflow.xml file inside the package and put it in the Bundle-Classpath. This is not so good if you want the file to be edited without restoring WAB.
  • OSGi workflow.xml . org.osgi.framework.bootdelegation com.xyz.abc.resource. : , com.xyz.abc.resource OSGi, framework
  • equinox, bundle, : Bundle-Classpath. , .

() , . OsgiBundleResource.

OSGi, Blueprint Container, Spring DM. , , Apache Aries Eclipse Gemini.

+1
, . ( classpath โ†’ )

  

, , -, , , classpath: , :

- , , .

+1

Source: https://habr.com/ru/post/1776939/


All Articles