Christian
Just as you said, before implementing a new one, I should do some more
tests/experiments with existing frameworks to avoid re-invent wheel.
Thanks rigorous suggestion very much!
Tang
Christian Schneider wrote:
There is a already a start level defined in OSGi. When loading bundles
you can set a start level for each bundle.
You can then set the start level of the OSGi framework. The framework
will then take care of starting and stopping the correct bundles.
See
http://www.osgi.org/javadoc/r4v43/core/org/osgi/service/startlevel/StartLevel.html
So there is no need to implement this system yourself. Just create a
management agent that controls the framework start level and have some
packaging/deployment in place that sets the start levels for bundles.
For example in Apache Karaf the start level is used for Clustering karaf
instances. There is one start level the system is started at by default
then it tries to get a lock for the failover cluster and if it aquires
the lock it goes to a higher start level where the application bundles
are started.
Of course you can achieve more conditional behaviour by using your own
annotations but I would strongly suggest to first do some tests with
existing frameworks before implementing a new one.
Christian
On 19.12.2013 10:07, Tang Yong wrote:
Christian,
> If you are more concerned about starting or not starting things
> conditionally this could be more interesting. I am not sure if and how
> existing frameworks handle this case.
Yes, I concerned about starting or not starting things conditionally.
> This is still too generic I think. Can you describe a bit what kind of
> rules you have in mind?
Well, I take an example as following:
[A Bundle]
Class1's definition:
@Service
@StartMode(mode=Mode.StartupMode)
public class Class1{
...
}
[B Bundle]
Class2's definition:
@Service
@StartMode(mode=Mode.CommonMode, level=20)
public class Class2{
...
}
Case1: After we installed A bundle and B bundle, if having an agent
bundle being charge of control current system's running state(eg.
decide what should start or not start), the agent can define a system
run level(eg. 15), then, once it found that Class1 from A Bundle has
"mode=Mode.StartupMode", it will start A Bundle.
Case2: If in the future, we decide to install B Bundle, and the agent
bundle found Class2 from B Bundle has "level=20" which is higher than
current system run level. Then, maybe it will not start B bundle. Of
course, this is only a simple rule.
Thanks
Tang
--
----------------------
Tang Yong
Senior Engineer
GlassFish Committer (OSGi & OSGi-JavaEE)
OSGi Alliance Supporter
Blog: http://osgizone.typepad.com/tangyong/
Nanjing Fujitsu NanDa Software Tec CO.,LTD
http://www.fujitsu.com/cn/fnst
Tel: +86-25-86630566-8310
Fax: +86-25-83317685
----------------------
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev