For me, every day is a weekend!
I have been carefully through Chris' code where he uses a factory for
Applications. I see that my own version was too simple. Also I have
just read your page
http://njbartlett.github.com/#VaadinOSGi saying
"The Application objects cannot directly be registered as services
since they have session lifecycle".
So I need a factory! It seems easiest now to continue with Chris'
code as it has a factory.
For now I, have worked around the initial problem I had with
annotations ( I think that is where the problem is). I thought I
would get everything else working and then go back to that later.
I now have Chris' code well on the way to working. I put in a few more
println's and so I see his VaadinOSGiApplicationManager and
StaticResources being started up by DS.
I think now my issue is somehow the factory instance is not getting
created.
I see that helloworld.theme is just resolved and not active. I
thought this might be OK because it is just a resource. If I say
-> start 3
I get
-> org.osgi.framework.BundleException: Fragment bundles can not be
started.
To me that seems OK.
It seems to me I am nearly there.
I don't know if you are familiar with his code. I understand you
helped him on it.
The static servlet is going OK. I can specify a theme URL with firefox
http://localhost:8183/VAADIN/themes/helloworld/styles.css and see the
css. So the helloworld fragment is hitching to vaadin.jar correctly.
My analysis
=======
DS has called VaadinOSGiApplicationManager twice, first to set the
httpService, then to start. But it is not being called at
setApplicationRegistered with an instance of a factory. So the
current problem seems to be that the HelloWorld factory service is not
being created and DS has not called setApplicationRegistered.
scr info 2 prints lines ...
State: factory
Activation: delayed
I don't know if 'delayed' is correct.
Properties: component.factory =
vaadin.app
So is it that the filter spec is not allowing the connection?
I am not quite sure what initiates creating the actual factory
instance. HelloWorld is saying I am a factory component.
VaadinOSGiApplicationManager specifies it needs a factory instance
with the xml tag
target='(component.factory=
vaadin.app)'.
Can you spot something wrong??
Thanks for any help.
P.S. I see your Bndtools. I do find using bnd hard work, so I shall
take a look.
=========================================
Below are some console outputs and dumps of the component xml from the
jars I am running:
Felix console println output:
Welcome to Felix
================
->
VaadinOSGiApplicationManager: bound to httpService
VaadinOSGiApplicationManager.start:
{
component.name=com.vaadin.osgi.VaadinOSGiApplicationManager,
component.id=1,
applicationRegistered.target=(component.factory=
vaadin.app)}
VaadinOSGiApplicationManager.start: waiting = 0
VaadinOSGiApplicationManager.start: state = started & waiting for
registrations
StaticResources: bound to httpService
StaticResources: start
_____________________________________
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (2.0.5)
[ 1] [Active ] [ 1] com.vaadin.osgi (1.0.0)
[ 2] [Active ] [ 1] helloworld (1.0.0)
[ 3] [Resolved ] [ 1] helloworld.theme (6.2.3)
[ 4] [Active ] [ 1] JAXP XML (1.3.4.v200902170245)
[ 5] [Active ] [ 1] Apache Felix Bundle Repository (1.4.3)
[ 6] [Active ] [ 1] Apache Felix Configuration Admin Service
(1.2.4)
[ 7] [Active ] [ 1] Apache Felix Http Jetty (2.0.4)
[ 8] [Active ] [ 1] Apache Felix Log Service (1.0.0)
[ 9] [Active ] [ 1] Apache Felix Declarative Services (1.4.0)
[ 10] [Active ] [ 1] Apache Felix Shell Service (1.4.2)
[ 11] [Active ] [ 1] Apache Felix Shell TUI (1.4.1)
[ 12] [Active ] [ 1] JavaUtil (0)
[ 13] [Active ] [ 1] Vaadin (6.1.0.development)
->
__________________________________________________
-> scr list
Id State Name
[ 0] [active ] com.vaadin.osgi.StaticResources
[ 1] [active ] com.vaadin.osgi.VaadinOSGiApplicationManager
[ 2] [factory ] helloworld
_____________________________________________________
-> scr info 0
=========
ID: 0
Name: com.vaadin.osgi.StaticResources
Bundle: com.vaadin.osgi (1)
State: active
Default State: enabled
Activation: immediate
Configuration Policy: optional
Activate Method: start (declared in the descriptor)
Deactivate Method: stop (declared in the descriptor)
Modified Method: -
Reference: http
Satisfied: satisfied
Service Name: org.osgi.service.http.HttpService
Multiple: single
Optional: mandatory
Policy: static
Properties:
component.id = 0
component.name = com.vaadin.osgi.StaticResources
http.alias = /VAADIN
->
______________________________________________________
-> scr info 1
=========
ID: 1
Name: com.vaadin.osgi.VaadinOSGiApplicationManager
Bundle: com.vaadin.osgi (1)
State: active
Default State: enabled
Activation: immediate
Configuration Policy: optional
Activate Method: start (declared in the descriptor)
Deactivate Method: stop (declared in the descriptor)
Modified Method: -
Reference: http
Satisfied: satisfied
Service Name: org.osgi.service.http.HttpService
Multiple: single
Optional: mandatory
Policy: static
Reference: applicationRegistered
Satisfied: satisfied
Service Name: org.osgi.service.component.ComponentFactory
Target Filter: (component.factory=
vaadin.app)
Multiple: multiple
Optional: optional
Policy: dynamic
Properties:
applicationRegistered.target = (component.factory=
vaadin.app)
component.id = 1
component.name = com.vaadin.osgi.VaadinOSGiApplicationManager
-_______________________________________________________________
-> scr info 2
=========
ID: 2
Name: helloworld
Bundle: helloworld (2)
State: factory
Default State: enabled
Activation: delayed
Configuration Policy: optional
Activate Method: activate
Deactivate Method: deactivate
Modified Method: -
Factory:
vaadin.app
Services: com.vaadin.Application
Service Type: service
Properties:
component.factory =
vaadin.app
component.name = helloworld
service.description = ManagedServiceFactory for Factory
Componenthelloworld
service.pid = helloworld
service.vendor = The Apache Software Foundation
->
_____________________________________________________________
In my jars I see:
com.vaadin.osgi.jar
==============
[COMPONENTS]
OSGI-INF/com.vaadin.osgi.StaticResources.xml
<?xml version='1.0' encoding='utf-8'?>
<component name='com.vaadin.osgi.StaticResources' xmlns='http://
www.osgi.org/xmlns/scr/v1.1.0' activate='start' deactivate='stop'>
<implementation class='com.vaadin.osgi.StaticResources'/>
<property name='http.alias' value='/VAADIN'/>
<reference name='http' interface='org.osgi.service.http.HttpService'
bind='setHttp' unbind='unsetHttp'/>
</component>
OSGI-INF/com.vaadin.osgi.VaadinOSGiApplicationManager.xml
<?xml version='1.0' encoding='utf-8'?>
<component name='com.vaadin.osgi.VaadinOSGiApplicationManager'
xmlns='
http://www.osgi.org/xmlns/scr/v1.1.0' activate='start'
deactivate='stop'>
<implementation class='com.vaadin.osgi.VaadinOSGiApplicationManager'/
>
<reference name='http' interface='org.osgi.service.http.HttpService'
bind='setHttp' unbind='unsetHttp'/>
<reference name='applicationRegistered'
interface='org.osgi.service.component.ComponentFactory '
cardinality='0..n' bind='setApplicationRegistered'
unbind='unsetApplicationRegistered' policy='dynamic'
target='(component.factory=
vaadin.app)'/>
</component>
________________________________________________________
helloworld.jar
=========
[COMPONENTS]
OSGI-INF/helloworld.xml
<?xml version='1.0' encoding='utf-8'?>
<component name='helloworld' factory='
vaadin.app'>
<implementation class='helloworld.HelloWorldApplication'/>
<service>
<provide interface='com.vaadin.Application'/>
</service>
</component>