"external" directive in Bundle-ClassPath for config resources [message #635465] |
Tue, 26 October 2010 18:47  |
Eclipse User |
|
|
|
I am looking for a way to externalize resources for optional per-installation configurations. These might include changes to the applicationContext.xml or bundle-context.xml files, locale-specific properties files, hibernate hbm.xml files and/or jasper reports. I was thinking of including the default versions in the bundles but configuring a location external to the bundle where they could be overridden. Could this be done with the external directive in Bundle-ClassPath? Since this is not a recommended approach, is there an alternate, recommended approach for doing this?
Thanks,
Ellen
|
|
|
|
|
Re: "external" directive in Bundle-ClassPath for config resources [message #635759 is a reply to message #635484] |
Wed, 27 October 2010 21:55   |
Eclipse User |
|
|
|
Thanks, Glyn. I have read the spec where it pertains to Fragment bundles and have some questions -
If Virgo attaches a fragment bundle to a host, does it log which bundle was attached?
I am assuming that the fragment bundle should be placed in the resources/usr directory - is this correct?
Does the fragment have to be named anywhere as a possible extension to the host bundle (like in a plan, etc.) or is its presence all that is needed?
Is any type of resource valid and usable by the host if included in an attached fragment? (Images, for example)or is there a limit to the types of things that should be included in the fragment?
Can a fragment bundle be used with a war bundle?
I tried making a fragment bundle that is a jar file. All it contains is an "images" directory at the bundle root and a manifest:
Manifest-Version: 1.0
Bundle-ClassPath: .
JDK_VERSION: 1.6
Built-By: estrnod
Tool: Bnd-0.0.357
Bundle-Name: Configuration Bundle
Created-By: Apache Maven Bundle Plugin
Fragment-Host: host.bundle.symbolic.name
Build-Jdk: 1.6.0_16
Bundle-Version: 1.1.0.b
Bnd-LastModified: 1288223456259
BundlePermission: [host.bundle.symbolic.name,FRAGMENT]
Bundle-ManifestVersion: 2
Bundle-SymbolicName: config.fragment.bundle
The host bundle is the original war file bundle with the "images" directory removed (moved to the fragment). This images directory was also at the root of its bundle before I moved it. The host bundle manifest:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: 1.6.0_16 (Sun Microsystems Inc.)
Built-By: estrnod
Build-Jdk: 1.6.0_16
JDK_VERSION: 1.6
Tool: Bnd-0.0.357
Bundle-Name: Web Application Bundle
Import-Library: org.springframework.spring;version="[3.0.0.RELEASE,3.0
.0.RELEASE]"
Web-ContextPath: myapp
Import-Bundle: <elided>
Bundle-Version: 1.1.0.b
BundlePermission: [host.bundle.symbolic.name,HOST]
Bnd-LastModified: 1288226901394
Bundle-ManifestVersion: 2
Import-Package: <elided>
Bundle-SymbolicName: host.bundle.symbolic.name
Both the host and fragment bundles are in the resources/usr directory. The host bundle is named in a plan in the pickup directory but the fragment bundle is not. There is no evidence that the fragment bundle was attached to the host, and when I view the website, the images are not present. Is there anything else I need to do to get the fragment to be "attached"? Or, did it probably already attach, and I just can't provide images to a war file in this manner (and need to try some other resource as an example)?
Thanks,
Ellen
|
|
|
Re: "external" directive in Bundle-ClassPath for config resources [message #635767 is a reply to message #635759] |
Wed, 27 October 2010 23:26   |
Eclipse User |
|
|
|
estrnod wrote on Thu, 28 October 2010 02:55 | Thanks, Glyn. I have read the spec where it pertains to Fragment bundles and have some questions -
If Virgo attaches a fragment bundle to a host, does it log which bundle was attached?
|
No, but you can see the relationship between fragments and hosts in the admin console or the Equinox console. For an example, see the Catalina ha and tribes bundles which attach to the main Catalina bundle.
Quote: |
I am assuming that the fragment bundle should be placed in the resources/usr directory - is this correct?
|
Yes.
Quote: |
Does the fragment have to be named anywhere as a possible extension to the host bundle (like in a plan, etc.) or is its presence all that is needed?
|
Its presence in the repository is all that is needed.
Quote: |
Is any type of resource valid and usable by the host if included in an attached fragment? (Images, for example)or is there a limit to the types of things that should be included in the fragment?
|
I think any resource is valid.
Quote: |
Can a fragment bundle be used with a war bundle?
|
I don't see why not, provided the fragment-host header in the fragment refers to the correct bundle symbolic name, which is automatically generated for a WAR file that doesn't specify a bundle symbolic name.
Quote: |
I tried making a fragment bundle that is a jar file. All it contains is an "images" directory at the bundle root and a manifest:
Manifest-Version: 1.0
Bundle-ClassPath: .
JDK_VERSION: 1.6
Built-By: estrnod
Tool: Bnd-0.0.357
Bundle-Name: Configuration Bundle
Created-By: Apache Maven Bundle Plugin
Fragment-Host: host.bundle.symbolic.name
Build-Jdk: 1.6.0_16
Bundle-Version: 1.1.0.b
Bnd-LastModified: 1288223456259
BundlePermission: [host.bundle.symbolic.name,FRAGMENT]
Bundle-ManifestVersion: 2
Bundle-SymbolicName: config.fragment.bundle
The host bundle is the original war file bundle with the "images" directory removed (moved to the fragment). This images directory was also at the root of its bundle before I moved it. The host bundle manifest:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: 1.6.0_16 (Sun Microsystems Inc.)
Built-By: estrnod
Build-Jdk: 1.6.0_16
JDK_VERSION: 1.6
Tool: Bnd-0.0.357
Bundle-Name: Web Application Bundle
Import-Library: org.springframework.spring;version="[3.0.0.RELEASE,3.0
.0.RELEASE]"
Web-ContextPath: myapp
Import-Bundle: <elided>
Bundle-Version: 1.1.0.b
BundlePermission: [host.bundle.symbolic.name,HOST]
Bnd-LastModified: 1288226901394
Bundle-ManifestVersion: 2
Import-Package: <elided>
Bundle-SymbolicName: host.bundle.symbolic.name
Both the host and fragment bundles are in the resources/usr directory. The host bundle is named in a plan in the pickup directory but the fragment bundle is not. There is no evidence that the fragment bundle was attached to the host, and when I view the website, the images are not present. Is there anything else I need to do to get the fragment to be "attached"? Or, did it probably already attach, and I just can't provide images to a war file in this manner (and need to try some other resource as an example)?
|
Take a look in the admin console. The only thing slightly out of the ordinary is the security permissions, so you could try without those and see if that helps. If it does, you are missing some permissions.
Hope that helps.
|
|
|
|
|
|
|
|
|
|
Re: "external" directive in Bundle-ClassPath for config resources [message #636521 is a reply to message #635915] |
Mon, 01 November 2010 12:55  |
Eclipse User |
|
|
|
Scoping may cause the fragment to fail to resolve because of some uses constraint failure introduced by scoping (which draws together all the exports of the contents of the scope and imports them into the generated "synthetic context" bundle).
Virgo will only flag a failure to resolve a fragment as an error if the fragment is part of a plan being deployed as it will then spot that the fragment did not resolve. (Normal OSGi semantics apply otherwise - a fragment failing to attach is not an error.)
I guess that making the plan unscoped ensures that the fragment does resolve and so it can attach to its host.
So the case I would like to understand better is where you list the fragment in the plan and you make the plan scoped (for your logging requirement). Does this work? If it does, it sounds pretty good as you are specifying (in the plan) the need for the fragment to be resolved. If it doesn't work, do you see any symptoms apart from the fragment not attaching? If there are no symptoms, this may be a bug.
|
|
|
Powered by
FUDForum. Page generated in 0.04411 seconds