Hi,
First of all @Component is mandatory.(For annotation based usage).
But this only defines your component. To actually instantiate it you should
do it deliberately. One way to do that is using @Instantiate annotation.
So your code would be like:
@Component
@Instantiate
public class foo{
@Validate
public void start()
..........
..........
}
On Fri, Oct 12, 2012 at 1:00 AM, Cook, Michael J. (OCTO) <
[email protected]> wrote:
> Sorry. Just rechecked. Used @ Component on the class. And
> @Invalidate/@validate on the methods. Just tried removing the @Component.
> Same result. No output.
>
> Mike
> Michael Cook
> VP Technology Innovation
> Comcast
> One Comcast Center
> Philadelphia, PA 19103
> (o) 215-286-8260
> (m) 609-458-0332
>
> ----- Original Message -----
> From: Cook, Michael J. (OCTO)
> Sent: Thursday, October 11, 2012 05:47 PM
> To: '[email protected]' <[email protected]>
> Subject: Re: Getting Started with iPOJO
>
> I used @validate/@invalidate alone.
>
> Mike
>
> Michael Cook
> VP Technology Innovation
> Comcast
> One Comcast Center
> Philadelphia, PA 19103
> (o) 215-286-8260
> (m) 609-458-0332
>
> ----- Original Message -----
> From: Göktürk Gezer [mailto:[email protected]]
> Sent: Thursday, October 11, 2012 05:39 PM
> To: [email protected] <[email protected]>
> Subject: Re: Getting Started with iPOJO
>
> Hi,
>
> I need to ask this first since it's not on your code snippet: Did you use
> @Component annotation for class where you've declared your start() stop()
> methods? Or did you use @Validate,@Invalidate alone?
>
>
> *Regards,*
> *Gokturk*
>
> On Thu, Oct 11, 2012 at 8:13 PM, Cook, Michael J. (OCTO) <
> [email protected]> wrote:
>
> > Hi,
> >
> > I can't seem to find a good article that will help me resolve the
> "getting
> > started" issue I am facing.
> >
> > I am using Eclipse Juno (4.2) on my Mac.
> >
> > I have downloaded and installed the iPOJO eclipse plugin, from:
> > http://clement.plop-plop.net/update/
> >
> > I have created a sample project following the instructions at:
> > http://felix.apache.org/site/ipojo-eclipse-plug-in.html
> >
> > I have integrated Felix into Eclipse as a project, following instructions
> > here: http://felix.apache.org/site/integrating-felix-with-eclipse.html
> >
> > I have downloaded the following iPOJO bundle:
> > org.apache.felix.ipojo-1.8.2.jar
> >
> > I've launched Felix in the Eclipse console and I've installed the
> > org.apache.felix.ipojo-1.8.2.jar bundle and started it.
> >
> > I've created a test bundle using iPOJO called iPojoTest.jar and I've
> > installed it and started it in the OSGI console.
> >
> > I run bundles in the console and I get:
> >
> > g! bundles
> >
> > 0|Active | 0|org.apache.felix.framework (3.0.7)
> >
> > 1|Active | 1|org.apache.felix.bundlerepository (1.6.2)
> >
> > 2|Active | 1|org.apache.felix.gogo.command (0.6.1)
> >
> > 3|Active | 1|org.apache.felix.gogo.runtime (0.6.1)
> >
> > 4|Active | 1|org.apache.felix.gogo.shell (0.6.1)
> >
> > 12|Active | 1|iPojoTest (1.4.0)
> >
> > 13|Active | 1|org.apache.felix.ipojo (1.8.2)
> >
> >
> > So, the bundle seems to have started.
> >
> > But I don't get any console output from my sysouts…
> >
> > Here are the start() and stop() methods:
> >
> >
> > @Validate
> >
> > public void start() throws IOException {
> >
> > System.out.println("I'm starting...");
> >
> > try{
> >
> > // Create file
> >
> > FileWriter fstream = new
> > FileWriter("/Users/mcook008/out.txt");
> >
> > BufferedWriter out = new BufferedWriter(fstream);
> >
> > out.write("Hello Java");
> >
> > //Close the output stream
> >
> > out.close();
> >
> > }catch (Exception e){//Catch exception if any
> >
> > System.err.println("Error: " + e.getMessage());
> >
> > }
> >
> > throw new IOException() ;
> >
> > }
> >
> > @Invalidate
> >
> > public void stop() {
> >
> > System.out.println("I'm leaving !");
> >
> > }
> >
> >
> >
> >
> > I added in the file write to see if a file would be created. There is no
> > file created. So, while OSGi thinks the bundle is ACTIVE, the start
> method
> > appears never have to been called.
> >
> >
> > Can anyone tell me what I may have done wrong or provide a clue as to
> what
> > to look at to help diagnose the problem?
> >
> >
> > Thanks,
> >
> > Mike
> >
> >
>