[ 
https://issues.apache.org/jira/browse/FELIX-6227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051492#comment-17051492
 ] 

Tom Watson commented on FELIX-6227:
-----------------------------------

I merged changes for this under commit 
[https://github.com/apache/felix-atomos/commit/8925fd8c5915279769df040cf42d46ad9f8ca22d]

 

I moved all the Atomos index functionality directly in the the 
AtomosRuntimeBase implementation.  If running in classpath mode the option 
{{atomos.load.index=FIRST}} must be specified when creating the runtime with 
{{org.apache.felix.atomos.runtime.AtomosRuntime.newAtomosRuntime(Map<String, 
String>)}}.  Otherwise the default is INGORE.

If running with a substrate native-image this {{atomos.load.index}} option is 
implicitly set to {{FIRST}}.  I debate on making the default be FIRST for 
classpath as well so that you don't have to specify the option.

When enabled the implementation will look for the first resource named 
{{atomos/bundles.index}} and will read that resource to get a list of 
{{AtomosContent}} available.  This file is a simple file that has this syntax:


{code:java}
ATOMOS_BUNDLE
<index>
<symbolic name>
<version>
<entry-path>
<entry-path>
...
ATOMOS_BUNDLE
<index>
<symbolic name>
<version>
<entry-path>
<entry-path>
...
{code}

For example, from the test case:

{code:java}
ATOMOS_BUNDLE
1
bundle.1
1.0.0
META-INF/MANIFEST.MF
OSGI-INF/common.txt
OSGI-INF/bundle.1-1.txt
OSGI-INF/bundle.1-2.txt
org/apache/felix/atomos/tests/index/bundles/b1/
ATOMOS_BUNDLE
2
bundle.2
1.0.0
META-INF/MANIFEST.MF
OSGI-INF/common.txt
OSGI-INF/bundle.2-1.txt
OSGI-INF/bundle.2-2.txt
org/apache/felix/atomos/tests/index/bundles/b2/
{code}

The index for each bundle can be any string and doesn't have to be a number, 
but it does have to be unique for each bundle included in the index.  The list 
of paths are paths to resources contained in the bundle which should be 
accessed at runtime with Bundle.getEntry APIs.  The actual resource will be 
located by prepending the path with {{atomos/<index>}}.  For example, to lookup 
the bundle manifest for {{bundle.1}} a resource with path 
{{atomos/1/META-INF/MANIFEST.MF}} will be looked up at runtime.  This means the 
{{atomos/}} folder including the {{bundles.index}} along with each index folder 
must be included on the classpath at runtime, or included in the native-image 
for substrate so that the bundle entry resources can be found at runtime.

Any directory paths (e.g {{org/apache/felix/atomos/tests/index/bundles/b2/}} 
are treated as package names.  The intention is to allow Atomos to map package 
names to bundles for the purposes of implementing 
FrameworkUtil.getBundle(Class<?>).  Note that the actual contents of the 
package should not be included in the index.  Package content typically is 
located using the class loader which will not use the {{atomos/<index>}} prefix 
to lookup the resource in a package.

It may be useful to add a more explicit way to list packages included in each 
bundle.  Note that this approach is only used if the bundle does not have the 
BND specific {{Private-Package}} header.  If the bundle has the 
{{Private-Package}} header then the packages specified by the bundle's 
{{Export-Package}} and {{Private-Package}} headers is used to do the mapping.

> Atomos index runtime independent of native image
> ------------------------------------------------
>
>                 Key: FELIX-6227
>                 URL: https://issues.apache.org/jira/browse/FELIX-6227
>             Project: Felix
>          Issue Type: Improvement
>          Components: Atomos
>            Reporter: Karl Pauls
>            Priority: Major
>
> I think it might be nice to have a general atomos runtime that works from an 
> index file similar to what is currently available with the 
> AtomosRuntimeSubstrate. 
> Something like: if an index file is given (or present) it reads the bundle 
> identities from the index files as well as their resource locations. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to