You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Rodrigo Madera <ro...@gmail.com> on 2007/09/15 08:40:37 UTC

Declarative Services with maven-bundle-plugin

Hello community,

I'm trying to develop a Declarative Service using the maven-bundle-plugin,
but I can't find documentation on it.

Can anyone please provide a link or information?

Thanks for any help,
Rodrigo

Re: Declarative Services with maven-bundle-plugin

Posted by Stuart McCulloch <st...@jayway.net>.
On 19/09/2007, Rodrigo Madera <ro...@gmail.com> wrote:
>
> Unfortunately, that didn't work.
>
> If you use the Import-Package, it's to be used with a CLASSPATH provided
> path. However, I need an OSGi exported package.


You mean an Eclipse package, which is available in your Eclipse installation
and is
exported at runtime by the Equinox system bundle (note this package will not
be
available in other OSGi frameworks, as it is not a standard OSGi package)

Am I missing something?


The bundle-plugin works primarily with the Maven compilation classpath

You need to add a dependency to the Maven POM (as in my example) so it can
update the compilation classpath - Eclipse plugins such as q4e can help with
this, but the key issue is that you need to tell Maven about this
dependency.


> Thank you,
> Rodrigo
>
> On 9/19/07, Bertrand Delacretaz <bd...@apache.org> wrote:
> >
> > On 9/19/07, Rodrigo Madera <ro...@gmail.com> wrote:
> >
> > > ...In a normal Eclipse project I would
> > > add this to the manifest and all would be solved:
> > >
> > >         Import-Package: org.eclipse.osgi.framework.console;version="
> > 1.0.0"....
> >
> > Use the <Import-Package> statement of maven-bundle-plugin, see
> > http://felix.apache.org/site/maven-bundle-plugin-bnd.html
> >
> > -Bertrand
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > For additional commands, e-mail: users-help@felix.apache.org
> >
> >
>



-- 
Cheers, Stuart

Re: Declarative Services with maven-bundle-plugin

Posted by Rodrigo Madera <ro...@gmail.com>.
Unfortunately, that didn't work.

If you use the Import-Package, it's to be used with a CLASSPATH provided
path. However, I need an OSGi exported package.

Am I missing something?

Thank you,
Rodrigo

On 9/19/07, Bertrand Delacretaz <bd...@apache.org> wrote:
>
> On 9/19/07, Rodrigo Madera <ro...@gmail.com> wrote:
>
> > ...In a normal Eclipse project I would
> > add this to the manifest and all would be solved:
> >
> >         Import-Package: org.eclipse.osgi.framework.console;version="
> 1.0.0"....
>
> Use the <Import-Package> statement of maven-bundle-plugin, see
> http://felix.apache.org/site/maven-bundle-plugin-bnd.html
>
> -Bertrand
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Declarative Services with maven-bundle-plugin

Posted by Bertrand Delacretaz <bd...@apache.org>.
On 9/19/07, Rodrigo Madera <ro...@gmail.com> wrote:

> ...In a normal Eclipse project I would
> add this to the manifest and all would be solved:
>
>         Import-Package: org.eclipse.osgi.framework.console;version="1.0.0"....

Use the <Import-Package> statement of maven-bundle-plugin, see
http://felix.apache.org/site/maven-bundle-plugin-bnd.html

-Bertrand

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Declarative Services with maven-bundle-plugin

Posted by Rodrigo Madera <ro...@gmail.com>.
Hello again,

Comming with another problem, I have a service called Greeter with
GreeterImpl.
The only method available is "public String sayHello()".

Now I want to create an OSGi command provider for any OSGi shell.
For this, I created GreeterShell. But now I need the interfaces from (in
this case)
org.eclipse.osgi.framework.console.

The problem I have is with importing. In a normal Eclipse project I would
add this
to the manifest and all would be solved:

        Import-Package: org.eclipse.osgi.framework.console;version="1.0.0"

But I can't figure out how to do this on BND (nor SCR, of course).
How can this be done using the plugins?

Thanks for any input,
Rodrigo

On 9/18/07, Rodrigo Madera <ro...@gmail.com> wrote:
>
> Thanks, I was just putting the scr.component tag.
>
> So for the record, and those using the search facility, the solution was
> to add both scr.component and scr.service to the service implementation
> class.
>
> Thank you,
> Rodrigo
>
> On 9/18/07, Felix Meschberger <fm...@gmail.com> wrote:
> >
> > Hi Rodrigo,
> >
> > The interface is not marked. The implementation is marked with
> > @scr.component to indicate to the SCR plugin, that this class contains a
> > component with tags to be converted to a descriptor. In addition, the
> > @scr.service tag would be added to add the <service> element to the
> > descriptor.
> >
> > For example:
> >
> >         package sample;
> >         import iface.MyService
> >         /**
> >          * @scr.component
> >          * @scr.service
> >          */
> >         public class MyServiceImpl implements MyService {
> >         }
> >
> > This results in the following descriptor:
> >
> >         <?xml version="1.0" encoding="UTF-8"?>
> >         <components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
> >             <scr:component enabled="true" immediate="true"
> >         name="sample.MyServiceImpl">
> >                 <scr:implementation class="sample.MyServiceImpl" />
> >                 <scr:property name="service.pid"
> >         value=" sample.MyServiceImpl" />
> >                 <scr:service>
> >                     <provide interface="iface.MyService" />
> >                 </scr:service>
> >             </scr:component>
> >         </components>
> >
> > Hope this helps.
> >
> > You will find more applications of the SCR plugin tags in the Sling Core
> > project at [1]
> >
> > Regards
> > Felix
> >
> > [1] http://svn.apache.org/viewvc/incubator/sling/trunk/core/
> >
> >
> > Am Dienstag, den 18.09.2007, 06:14 -0300 schrieb Rodrigo Madera:
> > > Hey Bertrand,
> > >
> > > Thanks for the information. I'm already producing code with the
> > plug-in, but
> > > unfortunately with a misconfiguration somewhere. Could you provide a
> > simple
> > > example?
> > >
> > > For example, MyService interface and MyServiceImpl would be marked
> > with
> > > scr.service and scr.component respectively, correct? That's what I'm
> > doing
> > > but something is not right.
> > >
> > > Thanks for any insight,
> > > Rodrigo
> > >
> > > On 9/15/07, Bertrand Delacretaz < bdelacretaz@apache.org> wrote:
> > > >
> > > > Hi Rodrigo,
> > > >
> > > > On 9/15/07, Rodrigo Madera <ro...@gmail.com> wrote:
> > > > >... I'm trying to develop a Declarative Service using the
> > > > maven-bundle-plugin,
> > > > > but I can't find documentation on it....
> > > >
> > > > The docs are at
> > > > http://felix.apache.org/site/maven-bundle-plugin-bnd.html ,  but to
> > > > create Declarative Services you should also have a look at the
> > > > maven-scr-plugin, see
> > > > http://felix.apache.org/site/maven-scr-plugin.html
> > > >
> > > > -Bertrand
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > > > For additional commands, e-mail: users-help@felix.apache.org
> > > >
> > > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > For additional commands, e-mail: users-help@felix.apache.org
> >
> >
>

Re: Declarative Services with maven-bundle-plugin

Posted by Rodrigo Madera <ro...@gmail.com>.
Thanks, I was just putting the scr.component tag.

So for the record, and those using the search facility, the solution was to
add both scr.component and scr.service to the service implementation class.

Thank you,
Rodrigo

On 9/18/07, Felix Meschberger <fm...@gmail.com> wrote:
>
> Hi Rodrigo,
>
> The interface is not marked. The implementation is marked with
> @scr.component to indicate to the SCR plugin, that this class contains a
> component with tags to be converted to a descriptor. In addition, the
> @scr.service tag would be added to add the <service> element to the
> descriptor.
>
> For example:
>
>         package sample;
>         import iface.MyService
>         /**
>          * @scr.component
>          * @scr.service
>          */
>         public class MyServiceImpl implements MyService {
>         }
>
> This results in the following descriptor:
>
>         <?xml version="1.0" encoding="UTF-8"?>
>         <components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
>             <scr:component enabled="true" immediate="true"
>         name="sample.MyServiceImpl">
>                 <scr:implementation class="sample.MyServiceImpl" />
>                 <scr:property name="service.pid"
>         value="sample.MyServiceImpl" />
>                 <scr:service>
>                     <provide interface="iface.MyService" />
>                 </scr:service>
>             </scr:component>
>         </components>
>
> Hope this helps.
>
> You will find more applications of the SCR plugin tags in the Sling Core
> project at [1]
>
> Regards
> Felix
>
> [1] http://svn.apache.org/viewvc/incubator/sling/trunk/core/
>
>
> Am Dienstag, den 18.09.2007, 06:14 -0300 schrieb Rodrigo Madera:
> > Hey Bertrand,
> >
> > Thanks for the information. I'm already producing code with the plug-in,
> but
> > unfortunately with a misconfiguration somewhere. Could you provide a
> simple
> > example?
> >
> > For example, MyService interface and MyServiceImpl would be marked with
> > scr.service and scr.component respectively, correct? That's what I'm
> doing
> > but something is not right.
> >
> > Thanks for any insight,
> > Rodrigo
> >
> > On 9/15/07, Bertrand Delacretaz <bd...@apache.org> wrote:
> > >
> > > Hi Rodrigo,
> > >
> > > On 9/15/07, Rodrigo Madera <ro...@gmail.com> wrote:
> > > >... I'm trying to develop a Declarative Service using the
> > > maven-bundle-plugin,
> > > > but I can't find documentation on it....
> > >
> > > The docs are at
> > > http://felix.apache.org/site/maven-bundle-plugin-bnd.html ,  but to
> > > create Declarative Services you should also have a look at the
> > > maven-scr-plugin, see
> > > http://felix.apache.org/site/maven-scr-plugin.html
> > >
> > > -Bertrand
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > > For additional commands, e-mail: users-help@felix.apache.org
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Declarative Services with maven-bundle-plugin

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Rodrigo,

The interface is not marked. The implementation is marked with
@scr.component to indicate to the SCR plugin, that this class contains a
component with tags to be converted to a descriptor. In addition, the
@scr.service tag would be added to add the <service> element to the
descriptor.

For example:

        package sample;
        import iface.MyService
        /**
         * @scr.component
         * @scr.service
         */
        public class MyServiceImpl implements MyService {
        }

This results in the following descriptor:

        <?xml version="1.0" encoding="UTF-8"?>
        <components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
            <scr:component enabled="true" immediate="true"
        name="sample.MyServiceImpl">
                <scr:implementation class="sample.MyServiceImpl" />
                <scr:property name="service.pid"
        value="sample.MyServiceImpl" />
                <scr:service>
                    <provide interface="iface.MyService" />
                </scr:service>
            </scr:component>
        </components>

Hope this helps.

You will find more applications of the SCR plugin tags in the Sling Core
project at [1]

Regards
Felix

[1] http://svn.apache.org/viewvc/incubator/sling/trunk/core/


Am Dienstag, den 18.09.2007, 06:14 -0300 schrieb Rodrigo Madera:
> Hey Bertrand,
> 
> Thanks for the information. I'm already producing code with the plug-in, but
> unfortunately with a misconfiguration somewhere. Could you provide a simple
> example?
> 
> For example, MyService interface and MyServiceImpl would be marked with
> scr.service and scr.component respectively, correct? That's what I'm doing
> but something is not right.
> 
> Thanks for any insight,
> Rodrigo
> 
> On 9/15/07, Bertrand Delacretaz <bd...@apache.org> wrote:
> >
> > Hi Rodrigo,
> >
> > On 9/15/07, Rodrigo Madera <ro...@gmail.com> wrote:
> > >... I'm trying to develop a Declarative Service using the
> > maven-bundle-plugin,
> > > but I can't find documentation on it....
> >
> > The docs are at
> > http://felix.apache.org/site/maven-bundle-plugin-bnd.html ,  but to
> > create Declarative Services you should also have a look at the
> > maven-scr-plugin, see
> > http://felix.apache.org/site/maven-scr-plugin.html
> >
> > -Bertrand
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > For additional commands, e-mail: users-help@felix.apache.org
> >
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Declarative Services with maven-bundle-plugin

Posted by Rodrigo Madera <ro...@gmail.com>.
Hey Bertrand,

Thanks for the information. I'm already producing code with the plug-in, but
unfortunately with a misconfiguration somewhere. Could you provide a simple
example?

For example, MyService interface and MyServiceImpl would be marked with
scr.service and scr.component respectively, correct? That's what I'm doing
but something is not right.

Thanks for any insight,
Rodrigo

On 9/15/07, Bertrand Delacretaz <bd...@apache.org> wrote:
>
> Hi Rodrigo,
>
> On 9/15/07, Rodrigo Madera <ro...@gmail.com> wrote:
> >... I'm trying to develop a Declarative Service using the
> maven-bundle-plugin,
> > but I can't find documentation on it....
>
> The docs are at
> http://felix.apache.org/site/maven-bundle-plugin-bnd.html ,  but to
> create Declarative Services you should also have a look at the
> maven-scr-plugin, see
> http://felix.apache.org/site/maven-scr-plugin.html
>
> -Bertrand
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Declarative Services with maven-bundle-plugin

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Rodrigo,

On 9/15/07, Rodrigo Madera <ro...@gmail.com> wrote:
>... I'm trying to develop a Declarative Service using the maven-bundle-plugin,
> but I can't find documentation on it....

The docs are at
http://felix.apache.org/site/maven-bundle-plugin-bnd.html ,  but to
create Declarative Services you should also have a look at the
maven-scr-plugin, see
http://felix.apache.org/site/maven-scr-plugin.html

-Bertrand

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org