If you need another example with the service tracker look at:
http://www.aqute.biz/Snippets/Tracker
There are also some similar examples.
Kind regards,
Peter Kriens
AM> Just Because I saw that the html message was scrubbed, here is the mail
AM> at plain text.
AM> sry for the incovenience.
AM> Aggelos Mpimpoudis wrote:
>> The following message was originally posted at the eclipse.platform
>> newsgroup
>> <http://dev.eclipse.org/newslists/news.eclipse.platform/msg62264.html>,
>> but with regards to Peter Kriens for his assistance I managed to
>> subscribe here, at the official osgi mailing list.
>> I am a new java/osgi developer for the needs of my graduate project
>> and I am in the early stages of development. (searching for tutorials
>> etc etc)
>> Well here is my original request
>>> http://i23.photobucket.com/albums/b352/grnemo/Screenshot1.jpg
>>> http://i23.photobucket.com/albums/b352/grnemo/Screenshot2.jpg
>>>
>>> Hello to all,
>>> I am a new developer of java & OSGi framework.
>>> After tutorials, java book etc etc I managed to write some code. A
>>> bundle which acts as a primitive server. I connect to a socket and
>>> whatever i write to the console it is logged to the log bundle
>>> (practicing also to the reusing bundles model)
>>> The bundle runs perfectly with the knopflerfish platform but I want
>>> to run it inside eclipse. I have a setup of the knopflerfish (plugin)
>>> I select the bundles I use etc etc but it doesn't find the log
>>> service....I don't know what else to do.
>>> I have included 2 screenshots of me working on eclipse and marked my
>>> trouble area. If you have anything in mind I would be grateful.
>>>
>>> Thank you in advance,
>>>
>>>
>>>
>>> Aggelos Mpimpoudis,
>>> Undergraduate student @ National University of Greece
>>>
>>>
>>> PS: from the little research i did until i have reached this
>>> newsgroup I found that I can eliminate this null problem by using
>>> service listeners
>>> but the context var is now my problem.
>>> void start (BundleContext context)
>>> ...
>>> ServiceListener sL = new ServiceListener() {
>>> public void serviceChanged (ServiceEvent event){
>>> ServiceReference sr = event.getServiceReference();
>>> switch (event.getType()){
>>> case ServiceEvent.REGISTERED:
>>> {
>>>
>>> logService=(LogService)context.getService(logSref);
>>> }
>>> break;
>>> default:
>>> break;
>>> }
>>> }
>>>
>>> };
>>
>> I have found more information since then, mostly from knopflerfish's
>> site <http://www.knopflerfish.org/osgi_service_tutorial.html> and
>> tutorial <http://www.knopflerfish.org/tutorials/osgi_tutorial.pdf>
>> I can't get the log service reference by any way by running as osgi
>> project from the eclipse run menu.
>> Any recommendation would be helpfull.
>>
>> I have now, something like this
>>
>>> public class Activator implements BundleActivator {
>>>
>>> private final static String
>>> filter="(objectclass=org.osgi.service.log.LogService)";
>>> private ServiceReference logSref=null;
>>> private LogService logService=null;
>>> public static BundleContext bc = null;
>>>
>>> private void startUsingService() {
>>> this.thread = new ServiceUserThread(this.service);
>>> this.thread.start();
>>> }
>>>
>>> public void start(final BundleContext bc) throws Exception {
>>> Activator.bc = bc;
>>> try {
>>> ServiceListener logServiceListener = new ServiceListener() {
>>> public void serviceChanged (ServiceEvent event){
>>> switch (event.getType()){
>>> case ServiceEvent.REGISTERED:{
>>>
>>> logService=(LogService)bc.getService(event.getServiceReference());
>>> startUsingService();
>>> }
>>> break;
>>> default:
>>> break;
>>> }
>>> }
>>>
>>> };
>>> bc.addServiceListener(logServiceListener, filter);
>>> ServiceReference[] srl = bc.getServiceReferences(null,
>>> filter);
>>> for(int i = 0; srl != null && i < srl.length; i++)
>>> logServiceListener.serviceChanged(new
>>> ServiceEvent(ServiceEvent.REGISTERED, srl[i]));
>>>
>>> }
>>> catch (Exception e) {
>>> e.printStackTrace();
>>> }
>>> }
>>>
>>>
>>> public void stop(BundleContext context) throws Exception {
>>> context.ungetService(logSref);
>>> logSref = null;
>>> logService = null;
>>> System.out.println("Goodbye World");
>>> }
>>> }
>>
>> Am I thinking the right way? Can I proceed like this?
>>
>> With great respect to the community and much enthusiasm about the osgi
>> middleware,
>>
>> Aggelos Mpimpoudis
>> | Department of Informatics And Telecommunication NKUA |
>>
>>
>>
AM> _______________________________________________
AM> OSGi Developer Mail List
AM> [email protected]
AM> http://www2.osgi.org/mailman/listinfo/osgi-dev
--
Peter Kriens Tel +33467542167
9C, Avenue St. Drιzιry AOL,Yahoo: pkriens
34160 Beaulieu, France ICQ 255570717
Skype pkriens Fax +1 8153772599
_______________________________________________
OSGi Developer Mail List
[email protected]
http://www2.osgi.org/mailman/listinfo/osgi-dev