You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Abdel Olakara <ol...@gmail.com> on 2009/01/12 12:37:35 UTC
Trouble running a iPOJO example
Hi all,
I have been trying to work with iPOJO today. My hello world application is
simply not working. Can anybody please help me out figure what could be the
issue?
I have a split my project into three.. one is service interface, service
implementation and service client that will use the service.
My hello service is given bellow:
package hello.service:
public interface HelloService {
public String sayHello();
}
I compiled all the projects using ant scripts. I also used bnd tool.
My hello component (service implementation):
package hello.component;
import hello.service.HelloService;
public class HelloComponent implements HelloService {
String message = "Hello World";
public String sayHello() {
return message;
}
}
metadata.xml for this project is:
<ipojo>
<component classname="hello.component.HelloComponent">
<requires field="message"/>
<provides/>
</component>
<instance component="hello.component.HelloComponent"/>
</ipojo>
My Hello client:
package hello.client;
import hello.service.HelloService;
public class HelloClient {
private HelloService m_hello;
public HelloClient() {
super();
System.out.println("Hello Client constructor...");
}
public void start() {
System.out.println("Starting client...");
System.out.println("Service: " + m_hello.sayHello());
}
public void stop() {
System.out.println("Stoping client...");
}
}
metadata.xml for the client:
<ipojo>
<component classname="hello.client.HelloClient">
<requires field="m_hello"/>
<callback transition="validate" method="start"/>
<callback transition="invalidate" method="stop"/>
</component>
<instance component="hello.client.HelloClient"/>
</ipojo>
I have also attached the complete project as a zip.
When I load the bundles, ideally when the client is loaded, the start() show
get executed. but its not.. I do not see any sys out displayed on my
console. Please help me to understand what is wrong.
Thanks in advance,
Abdel Raoof Olakara
http://technopaper.blogspot.com
Re: Trouble running a iPOJO example
Posted by Abdel Olakara <ol...@gmail.com>.
Hi Clement,
Thanks, Its working fine now.
Regards,
Abdel
On Mon, Jan 12, 2009 at 3:45 PM, Clement Escoffier <
clement.escoffier@gmail.com> wrote:
>
> Hi,
>
>
> On 12.01.2009, at 12:37, Abdel Olakara wrote:
>
> Hi all,
>>
>> I have been trying to work with iPOJO today. My hello world application
>> is simply not working. Can anybody please help me out figure what could be
>> the issue?
>> I have a split my project into three.. one is service interface, service
>> implementation and service client that will use the service.
>> My hello service is given bellow:
>>
>> package hello.service:
>>
>> public interface HelloService {
>>
>> public String sayHello();
>> }
>>
>> I compiled all the projects using ant scripts. I also used bnd tool.
>>
>> My hello component (service implementation):
>>
>> package hello.component;
>>
>> import hello.service.HelloService;
>>
>> public class HelloComponent implements HelloService {
>>
>> String message = "Hello World";
>>
>> public String sayHello() {
>> return message;
>> }
>> }
>>
>> metadata.xml for this project is:
>>
>> <ipojo>
>> <component classname="hello.component.HelloComponent">
>> <requires field="message"/>
>> <provides/>
>> </component>
>> <instance component="hello.component.HelloComponent"/>
>> </ipojo>
>>
>
> The message field is just a String, not a service dependency and does not
> need to be injected. Try with the following metadata:
>
>> <ipojo>
>> <component classname="hello.component.HelloComponent">
>> <provides/>
>>
>
>
>> </component>
>> <instance component="hello.component.HelloComponent"/>
>> </ipojo>
>>
>
>
> This will create an instance of your HelloComponent that will provide the
> Hello Service.
>
>
>
>> My Hello client:
>>
>> package hello.client;
>>
>> import hello.service.HelloService;
>>
>> public class HelloClient {
>>
>> private HelloService m_hello;
>>
>>
>> public HelloClient() {
>> super();
>> System.out.println("Hello Client constructor...");
>> }
>>
>> public void start() {
>> System.out.println("Starting client...");
>> System.out.println("Service: " + m_hello.sayHello());
>> }
>>
>> public void stop() {
>> System.out.println("Stoping client...");
>> }
>> }
>>
>> metadata.xml for the client:
>>
>> <ipojo>
>> <component classname="hello.client.HelloClient">
>> <requires field="m_hello"/>
>> <callback transition="validate" method="start"/>
>> <callback transition="invalidate" method="stop"/>
>> </component>
>> <instance component="hello.client.HelloClient"/>
>> </ipojo>
>>
>
> It should work with a consistent Hello Service provider.
> No issue were raised, because iPOJO was looking for a java.lang.String
> service :-), and your Hello service was not published as soon as a
> java.lang.String service becomes available.
>
> Regards,
>
>
> Clement
>
>
>
>>
>> I have also attached the complete project as a zip.
>> When I load the bundles, ideally when the client is loaded, the start()
>> show get executed. but its not.. I do not see any sys out displayed on my
>> console. Please help me to understand what is wrong.
>>
>>
>> Thanks in advance,
>> Abdel Raoof Olakara
>> http://technopaper.blogspot.com
>>
>> <ipojo-example.zip>---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
>
--
-- Abdel Raoof Olakara
olakara@gmail.com
http://technopaper.blogspot.com
Re: Trouble running a iPOJO example
Posted by Clement Escoffier <cl...@gmail.com>.
Hi,
On 12.01.2009, at 12:37, Abdel Olakara wrote:
> Hi all,
>
> I have been trying to work with iPOJO today. My hello world
> application is simply not working. Can anybody please help me out
> figure what could be the issue?
> I have a split my project into three.. one is service interface,
> service implementation and service client that will use the service.
> My hello service is given bellow:
>
> package hello.service:
>
> public interface HelloService {
>
> public String sayHello();
> }
>
> I compiled all the projects using ant scripts. I also used bnd tool.
>
> My hello component (service implementation):
>
> package hello.component;
>
> import hello.service.HelloService;
>
> public class HelloComponent implements HelloService {
>
> String message = "Hello World";
>
> public String sayHello() {
> return message;
> }
> }
>
> metadata.xml for this project is:
>
> <ipojo>
> <component classname="hello.component.HelloComponent">
> <requires field="message"/>
> <provides/>
> </component>
> <instance component="hello.component.HelloComponent"/>
> </ipojo>
The message field is just a String, not a service dependency and does
not need to be injected. Try with the following metadata:
> <ipojo>
> <component classname="hello.component.HelloComponent">
> <provides/>
>
> </component>
> <instance component="hello.component.HelloComponent"/>
> </ipojo>
This will create an instance of your HelloComponent that will provide
the Hello Service.
>
> My Hello client:
>
> package hello.client;
>
> import hello.service.HelloService;
>
> public class HelloClient {
>
> private HelloService m_hello;
>
>
> public HelloClient() {
> super();
> System.out.println("Hello Client constructor...");
> }
>
> public void start() {
> System.out.println("Starting client...");
> System.out.println("Service: " + m_hello.sayHello());
> }
>
> public void stop() {
> System.out.println("Stoping client...");
> }
> }
>
> metadata.xml for the client:
>
> <ipojo>
> <component classname="hello.client.HelloClient">
> <requires field="m_hello"/>
> <callback transition="validate" method="start"/>
> <callback transition="invalidate" method="stop"/>
> </component>
> <instance component="hello.client.HelloClient"/>
> </ipojo>
It should work with a consistent Hello Service provider.
No issue were raised, because iPOJO was looking for a java.lang.String
service :-), and your Hello service was not published as soon as a
java.lang.String service becomes available.
Regards,
Clement
>
>
> I have also attached the complete project as a zip.
> When I load the bundles, ideally when the client is loaded, the
> start() show get executed. but its not.. I do not see any sys out
> displayed on my console. Please help me to understand what is wrong.
>
>
> Thanks in advance,
> Abdel Raoof Olakara
> http://technopaper.blogspot.com
> <ipojo-
> example
> .zip
> >---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org