You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Norbert Somlai <ns...@gmail.com> on 2010/03/11 11:50:48 UTC
Configuring an iPOJO on the web console
Hello again,
I'm using this documentation
(http://felix.apache.org/site/configuration-handler.html) to create a
service whose properties are configurable on the Felix Web Console. It
looked simple at first, but now I know that I need an
OSGI-INF/metatype/metatype.xml and also the Metatype Service running. Still,
no luck, my config does not appear on the console (others do, so the
metatype service seems to work fine). Probably a stupid mistake but I can't
spot it. Can you please help?
metadata.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ipojo
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="org.apache.felix.ipojo
http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd"
xmlns="org.apache.felix.ipojo">
<component classname="com.epam.osgiapache.pricing.PricingService">
<requires field="vatservice" />
<provides>
<property name="callcount" field="callCount" value="0" />
</provides>
<callback transition="validate" method="start" />
<callback transition="invalidate" method="stop" />
<properties propagation="true"/>
</component>
<instance component="com.epam.osgiapache.pricing.PricingService">
<property name="callcount" value="0" />
<property name="managed.service.pid"
value="com.epam.osgiapache.pricing"/>
</instance>
</ipojo>
metatype.xml:
<?xml version="1.0" encoding="UTF-8"?>
<metatype:MetaData
xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
<OCD description="Pricing Service" name="com.epam.osgiapache.pricing"
id="com.epam.osgiapache.pricing">
<AD name="Call Count" id="callcount" required="true" type="Integer"
default="0"/>
</OCD>
</metatype:MetaData>
Web Console info about my bundle:
18 PricingService
Symbolic Name PricingService
Version 0
Bundle Location file:/pricingservice.jar
Last Modification Thu Mar 11 11:46:41 CET 2010
Start Level 1
Exported Packages com.epam.osgiapache.pricing,version=0.0.0
Imported Packages com.epam.osgiapache.interfaces,version=0.0.0 from
Interfaces (1)
org.apache.felix.ipojo,version=1.4.0 from org.apache.felix.ipojo (6)
org.apache.felix.ipojo.architecture,version=1.4.0 from
org.apache.felix.ipojo (6)
org.osgi.service.cm,version=1.3.0 from org.apache.felix.configadmin (5)
org.osgi.service.log,version=1.3.0 from org.apache.felix.ipojo (6)
Service ID 51 Types: org.apache.felix.ipojo.Factory,
org.osgi.service.cm.ManagedServiceFactory
Service PID: com.epam.osgiapache.pricing.PricingService
Service ID 52 Types: org.osgi.service.cm.ManagedService
Service PID: com.epam.osgiapache.pricing
Service ID 54 Types: com.epam.osgiapache.interfaces.PricingServiceInterface
Manifest Headers Bnd-LastModified: 1268304387320
Bundle-ManifestVersion: 2
Bundle-Name: PricingService
Bundle-SymbolicName: PricingService
Bundle-Version: 0
Created-By: 1.6.0_17 (Sun Microsystems Inc.) & iPOJO 1.4.0
Export-Package: com.epam.osgiapache.pricing;
uses:="com.epam.osgiapache.interfaces"
Import-Package: org.osgi.service.log; version=1.3,
com.epam.osgiapache.interfaces, org.apache.felix.ipojo.architecture;
version= 1.4.0, org.apache.felix.ipojo; version= 1.4.0, org.osgi.service.cm;
version=1.2, com.epam.osgiapache.pricing
Include-Resource: OSGI-INF/metatype/metatype.xml=metatype.xml
iPOJO-Components: component {
$classname="com.epam.osgiapache.pricing.PricingService" callback {
$transition="validate" $method="start" }callback { $transition="invalidate"
$method="stop" }provides { property { $field="callCount" $mandatory="false"
$name="callcount" $value="0" }}properties { $propagation="true"
}manipulation { field { $name="prices" $type="double[]" }field {
$name="vatservice"
$type="com.epam.osgiapache.interfaces.VATServiceInterface" }field {
$name="callCount" $type="int" }method { $name="$init" }method {
$arguments="{int}" $name="calculatePrice" $return="double" }method {
$name="start" }method { $name="stop" }interface {
$name="com.epam.osgiapache.interfaces.PricingServiceInterface" }}requires {
$field="vatservice" }}instance {
$component="com.epam.osgiapache.pricing.PricingService" property {
$name="callcount" $value="0" }property { $name="managed.service.pid"
$value="com.epam.osgiapache.pricing" }}
Manifest-Version: 1.0
Tool: Bnd-0.0.384
Web console output of the individual services in the bundle:
51 org.apache.felix.ipojo.Factory,
org.osgi.service.cm.ManagedServiceFactory
component.class com.epam.osgiapache.pricing.PricingService
component.description factory
name="com.epam.osgiapache.pricing.PricingService" state="valid" bundle="18"
implementation-class="com.epam.osgiapache.pricing.PricingService" provides
specification="com.epam.osgiapache.interfaces.PricingServiceInterface"
missinghandlers list="[]" property name="callcount" value="0" type="int"
requiredhandlers list="[org.apache.felix.ipojo:requires,
org.apache.felix.ipojo:properties, org.apache.felix.ipojo:callback,
org.apache.felix.ipojo:provides, org.apache.felix.ipojo:architecture]"
component.properties
org.apache.felix.ipojo.architecture.PropertyDescription@12bcd4b
component.providedServiceSpecifications
com.epam.osgiapache.interfaces.PricingServiceInterface
factory.name com.epam.osgiapache.pricing.PricingService
factory.state 1
Service PID com.epam.osgiapache.pricing.PricingService
52 org.osgi.service.cm.ManagedService
factory.name com.epam.osgiapache.pricing.PricingService
instance.name com.epam.osgiapache.pricing.PricingService-0
Service PID com.epam.osgiapache.pricing
54 com.epam.osgiapache.interfaces.PricingServiceInterface
callcount 0
component com.epam.osgiapache.pricing.PricingService
factory.name com.epam.osgiapache.pricing.PricingService
instance.name com.epam.osgiapache.pricing.PricingService-0
Thanks in advance, Norbert
--
View this message in context: http://old.nabble.com/Configuring-an-iPOJO-on-the-web-console-tp27861909p27861909.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Configuring an iPOJO on the web console
Posted by Norbert Somlai <ns...@gmail.com>.
Hi Geert,
Yes, that was the problem. I accidentally bumped into a bad example missing
the Designate part and copied it. Thanks!
I copy here the working solution in case someone else will have this
problem:
Relevant part of metadata.xml:
<instance component="com.epam.osgiapache.pricing.PricingService">
<property name="callcount" value="0" />
<property name="managed.service.pid"
value="com.epam.osgiapache.pricing.1"/>
</instance>
metatype.xml
<?xml version="1.0" encoding="UTF-8"?>
<metatype:MetaData
xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
<OCD description="Pricing Service" name="com.epam.osgiapache.pricing"
id="com.epam.osgiapache.pricing">
<AD name="Call Count" id="callcount" required="true" type="Integer"
default="0" />
</OCD>
<Designate pid="com.epam.osgiapache.pricing.1" bundle="*" merge="true">
</Designate>
</metatype:MetaData>
Norbert
Geert Schuring wrote:
>
> Hey Norbert,
>
> I see 2 issues that may possibly cause your problem:
> 1 - You're missing a "pid" attribute in the "properties" tag of your
> component definition.
> 2 - You're missing a "Designate" section in your metatype.xml file. This
> is what one of my metatype.xml files looks like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <metatype:MetaData
> xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"
> localization="OSGI-INF/metatype/metatype">
> <OCD id="nl.interact911.ipds.auditservice" name="IPDS AuditService">
> <AD id="server_hostname" type="String" name="Server hostname"
> description="MySQL Server hostname"/>
> <AD id="database_username" type="String" name="Database username"
> description="Login username"/>
> <AD id="database_password" type="String" name="Database password"
> description="Login pasword"/>
> <AD id="database_name" type="String" name="Database name"
> description="Database name"/>
> </OCD>
> <Designate pid="nl.interact911.ipds.auditservice">
>
> </Designate>
> </metatype:MetaData>
>
>
> The value of the "pid" attribute on the "Designate" tag should match the
> value of the "pid" tag on the "Properties" tag in your metadata.xml.
>
> Let me know if that worked...
>
> Good luck,
> Geert Schuring.
>
>>
>> A quick note: I was able to make this work (with some metadata changes)
>> using
>> FileInstall, so my first question is: is this at all possible without
>> FileInstall.
>>
>> New metadata.xml:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ipojo
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="org.apache.felix.ipojo
>> http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd"
>> xmlns="org.apache.felix.ipojo">
>> <component classname="com.epam.osgiapache.pricing.PricingService">
>> <requires field="vatservice" />
>> <provides>
>> <property name="callcount" field="callCount" />
>> </provides>
>> <callback transition="validate" method="start" />
>> <callback transition="invalidate" method="stop" />
>> <properties propagation="true">
>> <property name="callcount" field="callCount" />
>> </properties>
>> </component>
>> <instance component="com.epam.osgiapache.pricing.PricingService">
>> <property name="callcount" value="0" />
>> <property name="managed.service.pid"
>> value="com.epam.osgiapache.pricing"/>
>> </instance>
>> </ipojo>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Configuring-an-iPOJO-on-the-web-console-tp27861909p27862818.html
>> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>
>
--
View this message in context: http://old.nabble.com/Configuring-an-iPOJO-on-the-web-console-tp27861909p27914800.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Configuring an iPOJO on the web console
Posted by Geert Schuring <ge...@schuring.eu>.
Hey Norbert,
I see 2 issues that may possibly cause your problem:
1 - You're missing a "pid" attribute in the "properties" tag of your
component definition.
2 - You're missing a "Designate" section in your metatype.xml file. This
is what one of my metatype.xml files looks like:
<?xml version="1.0" encoding="UTF-8"?>
<metatype:MetaData
xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"
localization="OSGI-INF/metatype/metatype">
<OCD id="nl.interact911.ipds.auditservice" name="IPDS AuditService">
<AD id="server_hostname" type="String" name="Server hostname"
description="MySQL Server hostname"/>
<AD id="database_username" type="String" name="Database username"
description="Login username"/>
<AD id="database_password" type="String" name="Database password"
description="Login pasword"/>
<AD id="database_name" type="String" name="Database name"
description="Database name"/>
</OCD>
<Designate pid="nl.interact911.ipds.auditservice">
<Object ocdref="nl.interact911.ipds.auditservice"/>
</Designate>
</metatype:MetaData>
The value of the "pid" attribute on the "Designate" tag should match the
value of the "pid" tag on the "Properties" tag in your metadata.xml.
Let me know if that worked...
Good luck,
Geert Schuring.
>
> A quick note: I was able to make this work (with some metadata changes)
> using
> FileInstall, so my first question is: is this at all possible without
> FileInstall.
>
> New metadata.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ipojo
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="org.apache.felix.ipojo
> http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd"
> xmlns="org.apache.felix.ipojo">
> <component classname="com.epam.osgiapache.pricing.PricingService">
> <requires field="vatservice" />
> <provides>
> <property name="callcount" field="callCount" />
> </provides>
> <callback transition="validate" method="start" />
> <callback transition="invalidate" method="stop" />
> <properties propagation="true">
> <property name="callcount" field="callCount" />
> </properties>
> </component>
> <instance component="com.epam.osgiapache.pricing.PricingService">
> <property name="callcount" value="0" />
> <property name="managed.service.pid"
> value="com.epam.osgiapache.pricing"/>
> </instance>
> </ipojo>
>
> --
> View this message in context:
> http://old.nabble.com/Configuring-an-iPOJO-on-the-web-console-tp27861909p27862818.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Configuring an iPOJO on the web console
Posted by Norbert Somlai <ns...@gmail.com>.
A quick note: I was able to make this work (with some metadata changes) using
FileInstall, so my first question is: is this at all possible without
FileInstall.
New metadata.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ipojo
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="org.apache.felix.ipojo
http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd"
xmlns="org.apache.felix.ipojo">
<component classname="com.epam.osgiapache.pricing.PricingService">
<requires field="vatservice" />
<provides>
<property name="callcount" field="callCount" />
</provides>
<callback transition="validate" method="start" />
<callback transition="invalidate" method="stop" />
<properties propagation="true">
<property name="callcount" field="callCount" />
</properties>
</component>
<instance component="com.epam.osgiapache.pricing.PricingService">
<property name="callcount" value="0" />
<property name="managed.service.pid"
value="com.epam.osgiapache.pricing"/>
</instance>
</ipojo>
--
View this message in context: http://old.nabble.com/Configuring-an-iPOJO-on-the-web-console-tp27861909p27862818.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org