Ok, now I'm lost again... I've been using the Eclipse plugin for creating the *.bnd and metadata.xml file. I right click on the xml to create my bundle jar.
How would I create that without the xml file? Would I simply hand write my MANIFEST.MF and make a jar file then? Will iPOJO do annotation searches of my jar? Do you have any examples available of this methodology? - Joel > -----Original Message----- > From: Clement Escoffier [mailto:[email protected]] > Sent: Tuesday, March 31, 2009 8:16 AM > To: [email protected] > Subject: Re: cfg files for PaxLogging and iPOJO > > Hi, > > On 31.03.2009, at 15:53, Joel Schuster wrote: > > > > > Clement, > > > > I suppose so... I really don't have enough understanding yet to say > > one way or the other. Are you saying that because the metadata.xml > > has an <instance../> declaration one is being created via the > > factory from that, and then another is being created via the factory > > from the cfg file? > > > > Here's the info from 'arch': > > > > -> arch > > Instance ArchCommand -> valid > > Instance LogClientExampleInstance -> valid > > Instance LogClientExample.154543ce-3bc2-4000-9cc8-c69c95fc090e -> > > valid > > So, two instances :-) > > In fact, one if created by the cfg file (it's the second one this this > crazzy id). The second one is created from the xml file, right? > > So, by using Managed Service Factory, each cfg file represents an > instance. You can create new instance by just writing a cfg file, or > dispose an instance by removing the cfg file from the folder. > Moreover, you can reconfigure it by updating a cfg file. > > So, to get only one instance just remove the XML file completely (as > you use annotations, you don't need it at all). The cfg file is > equivalent to the <instance/> tag from the XML file. > > (I'm going to write a FAQ on this topic.) > > > > > > > > That would seem to bear out. Ok, and so if PaxLogging is implemented > > similarly that's also why I'm seeing the two instances of that too. > > > > So, I can use a managed service instead of a factory... that's where > > I think I'm getting lost. > > The managed service factory allows you to create and dispose instances > with the CFG file (one CFG file is one instance) > The managed service allows you to reconfigure an existing instance. In > this case, the instance has to be created before. > > > Regards, > > Clement > > > > > > > > There is the 'managedservice' attribute of the @Component > > annotation. If I do not then have an <instance../> declaration in > > the metadata.xml but rather just a <component../> would a cfg file > > then be used for any created instances? > > > > - Joel > > > > > >> -----Original Message----- > >> From: Clement Escoffier [mailto:[email protected]] > >> Sent: Tuesday, March 31, 2009 7:35 AM > >> To: [email protected] > >> Subject: Re: cfg files for PaxLogging and iPOJO > >> > >> Hi, > >> > >> > >> The cfg file that you describe contains a ManagedServiceFactory > >> configuration. So, it replace the <instance> tag of the metadata.xml > >> file. So, if you have both, it will create one instance from the xml > >> file and one from the cfg file, so 2 instances. > >> > >> You can also use the ManagedService (not factory). Is that what you > >> would like? > >> > >> Regards, > >> > >> Clement > >> > >> > >> > >> On 31.03.2009, at 00:04, Joel Schuster wrote: > >> > >>> I take it back... it's working. Well, mostly. There are two > >>> instances :P. > >>> > >>> One from the File Installer and the other from the Configuration > >>> Updater. > >>> > >>> I'm wondering why they both wouldn't use the same instance. > >>> > >>> - Joel > >>> > >>>> -----Original Message----- > >>>> From: Joel Schuster [mailto:[email protected]] > >>>> Sent: Monday, March 30, 2009 3:58 PM > >>>> To: '[email protected]' > >>>> Subject: RE: cfg files for PaxLogging and iPOJO > >>>> > >>>> Karl, > >>>> > >>>> Still a no-go, I'll look at it some more tomorrow. > >>>> > >>>> Thanks for all the help. > >>>> > >>>> - Joel > >>>> > >>>>> -----Original Message----- > >>>>> From: Karl Pauls [mailto:[email protected]] > >>>>> Sent: Monday, March 30, 2009 3:50 PM > >>>>> To: [email protected] > >>>>> Subject: Re: cfg files for PaxLogging and iPOJO > >>>>> > >>>>> The number is the number of the factory configuration to create. > >>>>> As I > >>>>> said, it is a managed service factory not only a managed service. > >>>>> You > >>>>> are free to pick any number you like I think. > >>>>> > >>>>> regards, > >>>>> > >>>>> Karl > >>>>> > >>>>> On Mon, Mar 30, 2009 at 11:43 PM, Joel Schuster <[email protected]> > >>>> wrote: > >>>>>> I still can't seem to get this working... I tried both the > >>>>>> component > >>>>> name and the instance name. > >>>>>> > >>>>>> How would I determine what the -<number> would be? > >>>>>> > >>>>>> Based on what I read here: http://felix.apache.org/site/apache- > felix- > >>>>> file-install.html > >>>>>> > >>>>>> It seems to say that it would be something like: > >>>>>> LogClientExample.cfg > >>>>> like you were saying. > >>>>>> > >>>>>> Also, just because it's 'REQUIRED' doesn't keep it from being > >>>> installed > >>>>> and activated. > >>>>>> > >>>>>> Here's the info from the Configuration Status tab of the Web > >>>>>> Console: > >>>>>> > >>>>>> 48=[org.apache.felix.ipojo.Factory, > >>>>> org.osgi.service.cm.ManagedServiceFactory] > >>>>>> Bundle=com.examples.logclient (0) "com.examples.logclient" > >>>>>> Using Bundles=[org.apache.felix.configadmin (1.0.10) "Apache > >>>>>> Felix > >>>>> Configuration Admin Service"] > >>>>>> component.class=com.examples.logclient.LogClient > >>>>>> component.description=factory name="LogClientExample" > >>>>>> state="valid" > >>>>> bundle="24" implementation- > >>>>> class="com.examples.logclient.LogClient" > >>>>>> missinghandlers list="[]" > >>>>>> property name="logString" value="REQUIRED" > >>>>> type="java.lang.String" > >>>>>> requiredhandlers list="[org.apache.felix.ipojo:requires, > >>>>> org.apache.felix.ipojo:callback, > >>>>> org.apache.felix.ipojo:properties, > >>>>> org.apache.felix.ipojo:architecture]" > >>>>>> > >>>>> > >>>> > >>>> component > >>>> .properties=[org.apache.felix.ipojo.architecture.PropertyDescrip > >>>>> t...@b30913] > >>>>>> component.providedServiceSpecifications=[] > >>>>>> factory.name=LogClientExample > >>>>>> factory.state=1 > >>>>>> service.pid=LogClientExample > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>>> -----Original Message----- > >>>>>>> From: Karl Pauls [mailto:[email protected]] > >>>>>>> Sent: Monday, March 30, 2009 3:22 PM > >>>>>>> To: [email protected] > >>>>>>> Subject: Re: cfg files for PaxLogging and iPOJO > >>>>>>> > >>>>>>> Iirc, the instance name is used for the configuration and it is > >>>> really > >>>>>>> a managed service factory -- hence, the file should be named > >>>> something > >>>>>>> like this: > >>>>>>> > >>>>>>> LogClientExample-4711.cfg > >>>>>>> > >>>>>>> regards, > >>>>>>> > >>>>>>> Karl > >>>>>>> > >>>>>>> p.s.: In case you want your service to only be created and > >>>>>>> activated > >>>>>>> if there is a valid properties configuration then add: > >>>>>>> @Property(mandatory=true) > >>>>>>> > >>>>>>> > >>>>>>> On Mon, Mar 30, 2009 at 11:10 PM, Joel Schuster <[email protected] > >>>>>>> > > >>>>> wrote: > >>>>>>>> I got the PaxLogging config working. But the iPOJO isn't. > >>>>>>>> > >>>>>>>> Here's some code: > >>>>>>>> > >>>>>>>> package com.example; > >>>>>>>> > >>>>>>>> import ...*... > >>>>>>>> > >>>>>>>> @Component(name="LogClientExample", immediate=true) > >>>>>>>> public class LogClient implements Runnable { > >>>>>>>> > >>>>>>>> @Requires > >>>>>>>> private LogService logService; > >>>>>>>> > >>>>>>>> private boolean running; > >>>>>>>> > >>>>>>>> @Property > >>>>>>>> private String logString; > >>>>>>>> > >>>>>>>> @Override > >>>>>>>> public void run() { > >>>>>>>> logService.log( LogService.LOG_INFO, "LogClient > >>>>> run()."); > >>>>>>>> while( running) { > >>>>>>>> logService.log( LogService.LOG_INFO, > >>>>> "LogClient > >>>>>>> Running..." + logString); > >>>>>>>> try { > >>>>>>>> Thread.sleep( 10000); > >>>>>>>> } catch (InterruptedException e) { > >>>>>>>> logService.log( > >>>>> LogService.LOG_WARNING, > >>>>>>> "", e); > >>>>>>>> } > >>>>>>>> } > >>>>>>>> } > >>>>>>>> > >>>>>>>> @Validate > >>>>>>>> public void start() { > >>>>>>>> logService.log( LogService.LOG_INFO, "LogClient > >>>>>>> start()"); > >>>>>>>> running = true; > >>>>>>>> new Thread( this).start(); > >>>>>>>> } > >>>>>>>> > >>>>>>>> @Invalidate > >>>>>>>> public void stop() { > >>>>>>>> logService.log( LogService.LOG_INFO, "LogClient > >>>>> stop()"); > >>>>>>>> running = false; > >>>>>>>> } > >>>>>>>> } > >>>>>>>> > >>>>>>>> Then I've created a file called > >>>>>>>> 'com.example.LogClientExample.cfg' > >>>> (I > >>>>>>> tried just com.example.LogClient.cfg as well) with one line: > >>>>>>>> > >>>>>>>> logString=New Hello > >>>>>>>> > >>>>>>>> > >>>>>>>> The logs come out as "LogClient Running...null" > >>>>>>>> > >>>>>>>> Unless I put this in the metadata.xml: > >>>>>>>> > >>>>>>>> <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"> > >>>>>>>> <!-- declare your component types and instances here --> > >>>>>>>> <instance component="LogClientExample" > >>>>>>> name="LogClientExampleInstance"> > >>>>>>>> <property name="logString" > >>>>>>>> type="java.lang.String" > >>>>>>> value="Hello" /> > >>>>>>>> </instance> > >>>>>>>> </ipojo> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>>> -----Original Message----- > >>>>>>>>> From: Clement Escoffier [mailto:[email protected]] > >>>>>>>>> Sent: Monday, March 30, 2009 12:45 PM > >>>>>>>>> To: [email protected] > >>>>>>>>> Subject: Re: cfg files for PaxLogging and iPOJO > >>>>>>>>> > >>>>>>>>> Hi, > >>>>>>>>> > >>>>>>>>> To use cfg file you need: > >>>>>>>>> - File install configured on a folder (let's say 'foo') > >>>>>>>>> - A configuration admin implementation (like the Apache Felix > >>>>>>>>> one > >>>> :- > >>>>> )) > >>>>>>>>> > >>>>>>>>> Then, create a cfg file named factory-name-id. The factory > >>>>>>>>> name is > >>>>>>>>> generally the class name of your pojo. > >>>>>>>>> In this file, add one line per property: > >>>>>>>>> prop1=value1 > >>>>>>>>> prop2=value2 > >>>>>>>>> > >>>>>>>>> Copy this file in the 'foo' folder, that's it: > >>>>>>>>> File install will read the file and push the configuration in > >>>>>>>>> the > >>>>>>>>> configuration admin. > >>>>>>>>> The configuration admin will push the configuration to iPOJO > >>>>>>>>> iPOJO will create the instance and configure it (i.e you don't > >>>> need > >>>>>>>>> metadata.xml file at all) > >>>>>>>>> > >>>>>>>>> Regards, > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> Clement > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> On 30.03.2009, at 20:26, Stuart McCulloch wrote: > >>>>>>>>> > >>>>>>>>>> 2009/3/30 Joel Schuster <[email protected]> > >>>>>>>>>> > >>>>>>>>>>> I've started using PaxLogging as my LogService. However, I > >>>> can't > >>>>>>>>>>> seem to > >>>>>>>>>>> figure out how to configure it. > >>>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> you need to configure it via the ConfigAdmin service using a > >>>>>>>>>> configuration > >>>>>>>>>> pid "org.ops4j.pax.logging" > >>>>>>>>>> to point to the contents of the log4j properties file - you > >>>>>>>>>> can > >>>> do > >>>>>>>>>> this > >>>>>>>>>> using Pax ConfMan or FileInstall > >>>>>>>>>> from Apache Felix (both let you associate properties files > >>>>>>>>>> with > >>>>>>>>>> configuration pids) > >>>>>>>>>> > >>>>>>>>>> http://wiki.ops4j.org/display/ops4j/Pax+Logging#PaxLogging- > >>>>>>>>> Configuration > >>>>>>>>>> > >>>>>>>>>> you'll also need a working ConfigAdmin implementation, such > >>>>>>>>>> as > >>>> the > >>>>>>>>>> Apache > >>>>>>>>>> Felix configadmin bundle > >>>>>>>>>> > >>>>>>>>>> HTH > >>>>>>>>>> > >>>>>>>>>> I've tried creating various cfg files to no avail. > >>>>>>>>>>> > >>>>>>>>>>> As a an attempt to better understand how this should work > >>>>>>>>>>> I've > >>>>>>>>>>> created a > >>>>>>>>>>> quick iPOJO based LogClient which @Requires the LogService. > >>>>>>>>>>> > >>>>>>>>>>> This works great, so I added a String based @Property. > >>>>>>>>>>> > >>>>>>>>>>> However, I can't seem to set the property outside of the > >>>>>>>>>>> metadata.xml file. > >>>>>>>>>>> Shouldn't I be able to create a cfg file? > >>>>>>>>>>> > >>>>>>>>>>> If I can get that working it seems I should then be able to > >>>>> figure > >>>>>>>>>>> out a > >>>>>>>>>>> cfg file for the PaxLogging too. > >>>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> I'll let Clement answer the iPOJO specifics, but as long as > >>>>>>>>>> you > >>>>> can > >>>>>>>>>> associate the "org.ops4j.pax.logging" > >>>>>>>>>> configuration pid to the log4j properties using iPOJO then > >>>>>>>>>> it's > >>>>> just > >>>>>>> a > >>>>>>>>>> matter of making sure you have a > >>>>>>>>>> ConfigAdmin implementation installed to pass the > >>>>>>>>>> configuration > >>>>> onto > >>>>>>>>>> the > >>>>>>>>>> Pax-Logging service > >>>>>>>>>> > >>>>>>>>>> (note you also need both the Pax-Logging API and the Pax- > >>>>>>>>>> Logging > >>>>>>>>>> service > >>>>>>>>>> bundles installed) > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> -- > >>>>>>>>>> Cheers, Stuart > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> ---------------------------------------------------------------- > -- > >>>> -- > >>>>> - > >>>>>>>>> To unsubscribe, e-mail: [email protected] > >>>>>>>>> For additional commands, e-mail: [email protected] > >>>>>>>> > >>>>>>>> > >>>>>>>> ----------------------------------------------------------------- > -- > >>>> -- > >>>>>>>> To unsubscribe, e-mail: [email protected] > >>>>>>>> For additional commands, e-mail: [email protected] > >>>>>>>> > >>>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> -- > >>>>>>> Karl Pauls > >>>>>>> [email protected] > >>>>>>> > >>>>>>> ------------------------------------------------------------------ > -- > >> - > >>>>>>> To unsubscribe, e-mail: [email protected] > >>>>>>> For additional commands, e-mail: [email protected] > >>>>>> > >>>>>> > >>>>>> ------------------------------------------------------------------- > -- > >>>>>> To unsubscribe, e-mail: [email protected] > >>>>>> For additional commands, e-mail: [email protected] > >>>>>> > >>>>>> > >>>>> > >>>>> > >>>>> > >>>>> -- > >>>>> Karl Pauls > >>>>> [email protected] > >>>>> > >>>>> -------------------------------------------------------------------- > - > >>>>> To unsubscribe, e-mail: [email protected] > >>>>> For additional commands, e-mail: [email protected] > >>>> > >>>> > >>>> --------------------------------------------------------------------- > >>>> To unsubscribe, e-mail: [email protected] > >>>> For additional commands, e-mail: [email protected] > >>> > >>> > >>> --------------------------------------------------------------------- > >>> To unsubscribe, e-mail: [email protected] > >>> For additional commands, e-mail: [email protected] > >>> > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

