Okay, I did that. Here's the output:

g! ipojo:instances
Instance org.apache.felix.ipojo.arch.gogo.Arch-0 -> valid

g! ipojo:instance my-factory-0
g! Instance named 'my-factory-0' not found

g! ipojo:instance my-consumer-factory-0
Instance named 'my-consumer-factory-0' not found




-----Original Message-----
From: Clement Escoffier [mailto:[email protected]] 
Sent: Thursday, January 23, 2014 10:58 AM
To: Apache Felix - Users Mailing List
Subject: Re: iPOJO Components instantiated but no visible output

Hi,

Could you use the 'instances' command to retrieve the list of instances and 
their state ?
(http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-tools/ipojo-arch-command.html)

> ipojo:instances
// dump all instances and declaration
> ipojo:instance my-factory-0
// introspect the first instance 
> ipojo:instance my-consumer-factory-0
// introspect the second instance

Regards,

Clement


On 22 janv. 2014, at 20:38, Zaid Jamal Saeed Al Mahmoud 
<[email protected]> wrote:

> I have 2 iPOJO Components.
> 1- A Provider bundle that provides "Hello" service. Below is the 
> implementation of the component:
> package helloipojo;
> 
> 
> import helloipojo.service.HelloService;
> 
> import org.apache.felix.ipojo.annotations.Component;
> import org.apache.felix.ipojo.annotations.Invalidate;
> import org.apache.felix.ipojo.annotations.Provides;
> import org.apache.felix.ipojo.annotations.Validate;
> 
> 
> @Component(name="my-factory")
> @Provides
> public class HelloServiceImpl implements HelloService{
> 
>    @Override
>    public void sayHello() {
> 
>        System.out.println("Hello iPojo!");
> 
>    }
> 
> 
>    @Validate
>    public void start() throws Exception {
> 
>        System.out.println("Hello, I am ipojo bundle start method");
> 
>    }
> 
>    @Invalidate
>    public void stop() throws Exception {
> 
>        System.out.println("Bye Bye, I am ipojo bundle stop method");
> 
>    }
> 
> 
> 
> }
> 2- Consumer bundle that uses HelloService object as the follwing:
> package helloserviceconsumer;
> 
> import helloipojo.service.HelloService;
> 
> import org.apache.felix.ipojo.annotations.Component;
> import org.apache.felix.ipojo.annotations.Invalidate;
> import org.apache.felix.ipojo.annotations.Requires;
> import org.apache.felix.ipojo.annotations.Validate;
> 
> @Component(name="my-consumer-factory")
> public class HelloConsumer {
>              @Requires
>              HelloService helloObject;
> 
>              @Validate
>              private void start() {
>                       // Starting method
>                       //...
>                       helloObject.sayHello();
>                       //...
>                }
> 
>                @Invalidate
>                protected void stop() {
>                        // Stopping method
>                        if(helloObject!=null) { helloObject.sayHello(); 
> }
> 
>                        else System.out.println("hello service GONE!");
>                }
> }
> In a seperate Java application, I load these two bundles and start them on 
> Apache Felix as the following:
> Bundle b = 
> bundleContext1.installBundle("file:C:\\Users\\zaid.almahmoud\\Desktop\
> \plugins\\HelloService_1.0.0.201401222235.jar");
> b.start();
> 
> Bundle c = 
> bundleContext1.installBundle("file:C:\\Users\\zaid.almahmoud\\Desktop\
> \plugins\\HelloServiceConsumer_1.0.0.201401222257.jar");
> c.start();
> All the above works fine.
> Now, I would like to instantiate these two components dynamically and observe 
> the consumption of the bundle provider service by the bundle consumer. I used 
> Instance Declaration, as the following:
> DefaultInstanceDeclaration providerDeclaration = new 
> DefaultInstanceDeclaration(b.getBundleContext(), "my-factory");
>                            providerDeclaration.start();
> 
> DefaultInstanceDeclaration consumerDeclaration = new 
> DefaultInstanceDeclaration(c.getBundleContext(), "my-consumer-factory");
>                            consumerDeclaration.start(); No errors when 
> running the application. However, I could not see the "Hello" Messages that 
> exists in the start() methods of both the service provider and consumer. I 
> see absolutely NOTHING. That means the components are not instantiated 
> correctly. Where did I go wrong? Thanks.
> 
> 
> 
> Zaid.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to