You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Felix Meschberger <fm...@gmail.com> on 2007/09/19 07:52:59 UTC
Re: Import-Package question (was: Declarative Services with
maven-bundle-plugin)
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 <ro...@gmail.com> 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 <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
> > > >
> > > >
> > >
> >
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Import-Package question (was: Declarative Services with maven-bundle-plugin)
Posted by Stuart McCulloch <st...@jayway.net>.
On 19/09/2007, Rodrigo Madera <ro...@gmail.com> wrote:
>
> I know this is terribly off-topic, but taking advantage of your knowledge,
> what would the main difference of q4e be in your opinion?
FYI, q4e only supports Eclipse 3.3 and above, and requires Java 5 (but both
are worth upgrading to)
it's certainly worth trying out ... and can be easily removed if you don't
like it :)
Carlos Sanchez would be better placed to provide exact details as he is one
of the project owners - he reads this list and blogged about q4e at
http://www.jroller.com/carlossg/entry/introducing_q4e_a_new_eclipse
anyway, from the FAQ lists the differences so far...
What are the differences between this plugin and m2eclipse (aka Tycho)?
The objective of this plugin is to be part of the Eclipse
Foundation<http://www.eclipse.org/>,
for that reason the license is EPL and we are going to follow the foundation
procedures. Thanks to the sponsorship of DevZuz <http://www.devzuz.com/>, an
Eclipse Strategic Developer
Member<http://www.eclipse.org/membership/showMember.php?member_id=824>we
are in a good position to achieve this goal.
Besides the objective, there are technical differences. While m2eclipse
shows Maven output in a console, Q is based in events and will show them in
an organized way that allows filtering by severity, search,... Functionality
like the dependency graph, or creation of new projects using the archetype
mechanism are only present in Q.
Also it's implemented in several modules with reusability and extension in
mind so other people can develop their own plugins taking advantage of the
functionality they need (see for instance Candy for
Appfuse<http://ramblingabout.wordpress.com/2007/09/02/candy-for-appfuse-will-be-under-extreme-refactoring/>).
Thanks for the input,
> Rodrigo
>
> On 9/19/07, Stuart McCulloch <st...@jayway.net> wrote:
> >
> > On 19/09/2007, Rodrigo Madera <ro...@gmail.com> wrote:
> > >
> > > Thank you for your replies.
> > >
> > > However, this comes to mind:
> > >
> > > 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.
> > >
> > > This yields a chicken and the egg problem. I use Eclipse with M2 to
> > code.
> > > If the bundle doesn't generate the data at design level, Eclipse is as
> > > good
> > > as notepad.
> >
> >
> > yes, this is a long-running problem with Eclipse/PDE + Maven :(
> >
> > Eclipse/PDE expects the manifest at the top of the project and uses it
> to
> > augment
> > the compilation classpath. Maven uses dependencies to augment the
> > compilation
> > classpath and puts generated content in the target folder.
> >
> > unfortunately this can mean that adding an import in the Eclipse/PDE
> > manifest
> > will get things compiling in Eclipse (because the jar is available
> inside
> > Eclipse)
> > but break Maven because it doesn't know about this dependency.
> >
> > I think there are ways to link the Eclipse installation and maven
> > repository, but
> > haven't tried them myself. Btw, there's also a new plugin for Eclipse
> > called
> > q4e:
> >
> > http://code.google.com/p/q4e
> >
> > which might help you with the dependency management part...
> >
> > I'm still trying out the earlier recommendation and will post results
> > here.
> > >
> > > Thanks,
> > > Rodrigo
> > >
> > >
> > > 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 <ro...@gmail.com> 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 <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
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > > > For additional commands, e-mail: users-help@felix.apache.org
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > Cheers, Stuart
> >
>
--
Cheers, Stuart
Re: Import-Package question (was: Declarative Services with maven-bundle-plugin)
Posted by Rodrigo Madera <ro...@gmail.com>.
I know this is terribly off-topic, but taking advantage of your knowledge,
what would the main difference of q4e be in your opinion?
Thanks for the input,
Rodrigo
On 9/19/07, Stuart McCulloch <st...@jayway.net> wrote:
>
> On 19/09/2007, Rodrigo Madera <ro...@gmail.com> wrote:
> >
> > Thank you for your replies.
> >
> > However, this comes to mind:
> >
> > 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.
> >
> > This yields a chicken and the egg problem. I use Eclipse with M2 to
> code.
> > If the bundle doesn't generate the data at design level, Eclipse is as
> > good
> > as notepad.
>
>
> yes, this is a long-running problem with Eclipse/PDE + Maven :(
>
> Eclipse/PDE expects the manifest at the top of the project and uses it to
> augment
> the compilation classpath. Maven uses dependencies to augment the
> compilation
> classpath and puts generated content in the target folder.
>
> unfortunately this can mean that adding an import in the Eclipse/PDE
> manifest
> will get things compiling in Eclipse (because the jar is available inside
> Eclipse)
> but break Maven because it doesn't know about this dependency.
>
> I think there are ways to link the Eclipse installation and maven
> repository, but
> haven't tried them myself. Btw, there's also a new plugin for Eclipse
> called
> q4e:
>
> http://code.google.com/p/q4e
>
> which might help you with the dependency management part...
>
> I'm still trying out the earlier recommendation and will post results
> here.
> >
> > Thanks,
> > Rodrigo
> >
> >
> > 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 <ro...@gmail.com> 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 <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
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > > For additional commands, e-mail: users-help@felix.apache.org
> > >
> > >
> >
>
>
>
> --
> Cheers, Stuart
>
Re: Import-Package question (was: Declarative Services with
maven-bundle-plugin)
Posted by Felix Meschberger <fm...@gmail.com>.
Hi,
Am Mittwoch, den 19.09.2007, 14:44 +0800 schrieb Stuart McCulloch:
> yes, this is a long-running problem with Eclipse/PDE + Maven :(
In fact, I do not use the PDE part of Eclipse for bundle development.
Instead I use the Eclipse Maven2 plugin and the Maven Eclipse plugin to
somewhat bridge the gap - with the slight drawback, that non-exported
classes are still visible while building the bundles.
Regards
Felix
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Import-Package question (was: Declarative Services with maven-bundle-plugin)
Posted by Stuart McCulloch <st...@jayway.net>.
On 19/09/2007, Rodrigo Madera <ro...@gmail.com> wrote:
>
> Thank you for your replies.
>
> However, this comes to mind:
>
> 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.
>
> This yields a chicken and the egg problem. I use Eclipse with M2 to code.
> If the bundle doesn't generate the data at design level, Eclipse is as
> good
> as notepad.
yes, this is a long-running problem with Eclipse/PDE + Maven :(
Eclipse/PDE expects the manifest at the top of the project and uses it to
augment
the compilation classpath. Maven uses dependencies to augment the
compilation
classpath and puts generated content in the target folder.
unfortunately this can mean that adding an import in the Eclipse/PDE
manifest
will get things compiling in Eclipse (because the jar is available inside
Eclipse)
but break Maven because it doesn't know about this dependency.
I think there are ways to link the Eclipse installation and maven
repository, but
haven't tried them myself. Btw, there's also a new plugin for Eclipse called
q4e:
http://code.google.com/p/q4e
which might help you with the dependency management part...
I'm still trying out the earlier recommendation and will post results here.
>
> Thanks,
> Rodrigo
>
>
> 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 <ro...@gmail.com> 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 <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
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > For additional commands, e-mail: users-help@felix.apache.org
> >
> >
>
--
Cheers, Stuart
Re: Import-Package question (was: Declarative Services with maven-bundle-plugin)
Posted by Rodrigo Madera <ro...@gmail.com>.
Thank you for your replies.
However, this comes to mind:
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.
This yields a chicken and the egg problem. I use Eclipse with M2 to code.
If the bundle doesn't generate the data at design level, Eclipse is as good
as notepad.
I'm still trying out the earlier recommendation and will post results here.
Thanks,
Rodrigo
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 <ro...@gmail.com> 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 <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
> > > > >
> > > > >
> > > >
> > >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>