You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Mark Bools <ma...@principia-it.co.uk> on 2012/06/29 18:22:04 UTC

iPOJO composite and Bundle Symbolic Name

Hi all. Very new to this iPOJO composite stuff (actually, new to the whole OSGi & iPOJO thing too).

I'm having an issue with some logging during startup. I've created a logger that presents an SLF4J interface and passes log messages off to the OSGi logging service, and I provide a LogListener that interfaces to LogBack. All seemed to be working fine, but I ran into a timing issue when I create a composite using the following metadata.xml.

<ipojo
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd 
	    org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"
	xmlns="org.apache.felix.ipojo"
	xmlns:comp="org.apache.felix.ipojo.composite">
	
	<comp:composite name="DataSourceManager">
		<comp:instance component="com.itslm.omneity.data.service.DataSourceManagerImpl" />
		<comp:provides action="export"
			specification="com.itslm.omneity.data.api.DataSourceManager" />

		<!-- Will programmatically identify and load Adaptor plugins, this next 
			entry pulls in Adapters in the global scope (so, only those that are in the 
			main bundle directory) -->
		<comp:subservice action="import" specification="com.itslm.omneity.adapter.api.Adapter" />

		<comp:subservice action="import" specification="org.osgi.service.log.LogService" />
		
 	</comp:composite>

	<comp:instance component="DataSourceManager" name="DataSourceManager"/>

</ipojo>

Everything starts up fine, but any log messages output during startup of this composite were lost because the logging service seems to be imported to the component only when DataSourceManagerImpl has completed startup. No problem. I just added buffering to the logger and had the system flush that buffer when the logging service became available (a better design anyway).

However, I now get another problem: the bundle context for DataSourceManagerImpl seems to have no symbolic name at the point the logging service becomes available (getSymbolicName() returns null). Since my logging system deliberately drops 'anonymous' log messages this means nothing is being logged from DataSourceManagerImpl.

If I run the DataSourceManagerImpl in a plain bundle without wrapping them in a composite everything works fine.


Questions.

Is there a way to make these symbolic names available? Should I be specifying more in the metadata for the composite? What am I missing?

Re: iPOJO composite and Bundle Symbolic Name

Posted by Mark Bools <ma...@principia-it.co.uk>.
Gargh!

Okay, silly mistake on my part. The composite jar had no Bundle-* information in it, hence no Bundle-SymbolicName and so no name being reported to the logging system.

Everything now working as planned.


On 29 Jun 2012, at 17:22, Mark Bools wrote:

> Hi all. Very new to this iPOJO composite stuff (actually, new to the whole OSGi & iPOJO thing too).
> 
> I'm having an issue with some logging during startup. I've created a logger that presents an SLF4J interface and passes log messages off to the OSGi logging service, and I provide a LogListener that interfaces to LogBack. All seemed to be working fine, but I ran into a timing issue when I create a composite using the following metadata.xml.
> 
> <ipojo
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd 
> 	    org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"
> 	xmlns="org.apache.felix.ipojo"
> 	xmlns:comp="org.apache.felix.ipojo.composite">
> 	
> 	<comp:composite name="DataSourceManager">
> 		<comp:instance component="com.itslm.omneity.data.service.DataSourceManagerImpl" />
> 		<comp:provides action="export"
> 			specification="com.itslm.omneity.data.api.DataSourceManager" />
> 
> 		<!-- Will programmatically identify and load Adaptor plugins, this next 
> 			entry pulls in Adapters in the global scope (so, only those that are in the 
> 			main bundle directory) -->
> 		<comp:subservice action="import" specification="com.itslm.omneity.adapter.api.Adapter" />
> 
> 		<comp:subservice action="import" specification="org.osgi.service.log.LogService" />
> 		
> 	</comp:composite>
> 
> 	<comp:instance component="DataSourceManager" name="DataSourceManager"/>
> 
> </ipojo>
> 
> Everything starts up fine, but any log messages output during startup of this composite were lost because the logging service seems to be imported to the component only when DataSourceManagerImpl has completed startup. No problem. I just added buffering to the logger and had the system flush that buffer when the logging service became available (a better design anyway).
> 
> However, I now get another problem: the bundle context for DataSourceManagerImpl seems to have no symbolic name at the point the logging service becomes available (getSymbolicName() returns null). Since my logging system deliberately drops 'anonymous' log messages this means nothing is being logged from DataSourceManagerImpl.
> 
> If I run the DataSourceManagerImpl in a plain bundle without wrapping them in a composite everything works fine.
> 
> 
> Questions.
> 
> Is there a way to make these symbolic names available? Should I be specifying more in the metadata for the composite? What am I missing?