Hi Rodrigo,

Just to clarify one other point: There are two maven plugins involved:

* The Maven SCR Plugin converts the JavaDoc tags @scr.* into a
Declarative
  Services descriptor file
* The Maven Bundle Plugin with the help of the BND tool creates the
  Bundle manifest from the project contents and the pluging
configuration
  in the pom.xml.

If your code refers to a class in the org.eclipse.osgi.framework.console
package, the Bundle plugin will automatically create an import for this
package.

Regards
Felix

Am Mittwoch, den 19.09.2007, 12:47 +0800 schrieb Stuart McCulloch:
> Hi Rodrigo,
> 
> (I've started a new thread for this topic - rather than have multiple topics
> in one thread)
> 
> On 19/09/2007, Rodrigo Madera <[EMAIL PROTECTED]> wrote:
> >
> > 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?
> 
> 
> if your code imports org.eclipse.osgi.framework.console and you have the
> console bundle marked as a "provided" maven dependency (which you need
> for it to compile) then it should be automatically added to the manifest.
> 
> for example, this POM:
> 
> ===================================================================
> <?xml version="1.0" encoding="UTF8"?>
> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd"; xmlns="
> http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance";>
> 
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>examples.console</groupId>
>   <artifactId>myConsole</artifactId>
>   <version>1.0-SNAPSHOT</version>
> 
>   <name>myConsole example</name>
>   <packaging>bundle</packaging>
> 
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>org.apache.felix</groupId>
>         <artifactId>maven-bundle-plugin</artifactId>
>         <version>1.0.0</version>
>         <extensions>true</extensions>
>         <configuration>
>           <instructions>
>             <Bundle-Activator>examples.console.internal.Activator
> </Bundle-Activator>
>             <Private-Package>examples.console.internal</Private-Package>
>           </instructions>
>         </configuration>
>       </plugin>
>     </plugins>
>   </build>
> 
>   <dependencies>
>     <dependency>
>       <groupId>org.osgi</groupId>
>       <artifactId>osgi_R4_core</artifactId>
>       <version>1.0</version>
>     </dependency>
>     <dependency>
>       <groupId>org.osgi</groupId>
>       <artifactId>osgi_R4_compendium</artifactId>
>       <version>1.0</version>
>     </dependency>
>     <dependency>
>       <groupId>org.eclipse</groupId>
>       <artifactId>osgi</artifactId>
>       <version>3.3.0-v20070530</version>
>       <scope>provided</scope>
>     </dependency>
>   </dependencies>
> 
>   <repositories>
>     <repository>
>       <id>eclipse</id>
>       <url>http://repo1.maven.org/eclipse</url>
>     </repository>
>   </repositories>
> 
> </project>
> ===================================================================
> 
> and this Java class:
> 
> ===================================================================
> package examples.console.internal;
> 
> import org.eclipse.osgi.framework.console.CommandProvider;
> 
> import org.osgi.framework.BundleActivator;
> import org.osgi.framework.BundleContext;
> 
> public class Activator
>     implements BundleActivator
> {
>     static class MyCommands implements CommandProvider
>     {
>         public String getHelp()
>         {
>             return "don't panic :)";
>         }
>     }
> 
>     public void start( BundleContext bc )
>         throws Exception
>     {
>     }
> 
>     public void stop( BundleContext bc )
>         throws Exception
>     {
>     }
> }
> ===================================================================
> 
> produce the following manifest using "mvn clean install":
> 
> ===================================================================
> Manifest-Version: 1.0
> Bundle-SymbolicName: examples.console.myConsole
> Import-Package: org.eclipse.osgi.framework.console;version=1.0,org.osg
>  i.framework;version=1.4
> Bundle-Activator: examples.console.internal.Activator
> Created-By: 1.5.0 (IBM Corporation)
> Bundle-ManifestVersion: 2
> Bundle-Name: myConsole example
> Bnd-LastModified: 1190176961184
> Tool: Bnd-0.0.160
> Bundle-Version: 1.0.0.SNAPSHOT
> Private-Package: examples.console.internal
> ===================================================================
> 
> which has org.eclipse.osgi.framework.console;version=1.0 as an import
> 
> HTH
> 
> Thanks for any input,
> > Rodrigo
> >
> > On 9/18/07, Rodrigo Madera <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 < [EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > > Hi Rodrigo,
> > > > > >
> > > > > > On 9/15/07, Rodrigo Madera <[EMAIL PROTECTED]> 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: [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]

Reply via email to