[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Creating heavy weight DS Components

One idea is to use a separate component factory for the service(s) provided by the BIG component. Reference the component factory from the "main" component. When the main component is activated and has completed the long running task on the thread, a single instance of the factory component is created which then provides the service.
--

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the
OSGi Alliance
hargrave@xxxxxxxxxx

office: +1 386 848 1781
mobile: +1 386 848 3788




From: Andrew Teirney <andrew@xxxxxxxxxxx>
To: equinox-dev@xxxxxxxxxxx
Date: 2009/05/29 17:48
Subject: [equinox-dev] Creating heavy weight DS Components
Sent by: equinox-dev-bounces@xxxxxxxxxxx





I currently have several use cases whereby I am using declarative
services to inject dependent services into a component instance, lets
call this component BIG.

The component BIG is intended to provide several services, however
before it can provide the services it needs to be able to utilize
those dependent service for a setup operation that can take some
lengthy amount of time (needs to access several databases/files).

At present I have been trying to do this in the activate method,
however this does have a time limit and if I understand things
correctly if this time is exceeded then the component will be disposed
of if its takes too long to construct.

So, to get around this in the activate method I spawn a thread that
does the processing in the background, and when it completes I
register the services programatically. This thread obviously has to
take into account any of its services being ripped out from underneath
whilst its using it, and the component itself being deactivated.

What I am wondering is whether this is the best possible solution to a
component being a heavyweight service (in that it takes some time to
properly construct). Other than the complexity of the solution another
aspect I don't like is that the services a component provides are not
part of the declarative services xml (a mild annoyance).

If anyone has any tips/pointers on perhaps how to handle this
heavyweight component creation problem I am encountering that would be
appreciated.

CU,
Andrew
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev