On 28.07.2009, at 10:08, Carsten Ziegeler wrote:

Reto Bachmann-Gmür wrote:
Carsten Ziegeler said the following on 07/27/2009 02:41 PM:
Reto Bachmann-Gmür wrote:

Hello

I was hoping that with support for annotations the scr plugin would work with scala code as well. But in my mixed java/scala project it seems to
only look at the annotations in the java sources.

@Component
public class Service {

   @Property(value = "default value")
   static final String CONSTANT_NAME = "property.name";
}

---> results in an entry in OSGI-INF/serviceComponents.xml

package org.trialox.sandbox.scr {
   @Component class ScalaService {

       @Property{ val value = Array("default value")}
       val CONSTANT_NAME = "property.name";
   }
}

--> no mention in OSGI-INF/serviceComponents.xml

do I need particular settings for the scr plugin to have it look at the
scala file as well?


Interesting use case :)

Now, the scr plugin scans java source files - even with the annotations.
I've no idea how the maven scala integration works, so what is
generated? Is this a java source file or a compiled class?

the scala source file resides in src/main/scala, it is compiled to
bytecode by the maven plugin org.scala-tools:maven-scala-plugin from
http://scala-tools.org/repo-releases (no java code is generated).

I guess things would be much easier if the RetentionPolicy would be
CLASS and the xml generated from the class-files. Adding bind-methods
might however be harder to be done in a language agnostic fashion.

Annotations are really hard to handle (at least I didn't found an easy
way). With retention policy SOURCE we can use tools like qdox to handle
them. A retention policy of RUNTIME would allow us to directly use the
java stuff; but so far I haven't seen a good way to handle retention
policy CLASS. If someone could come up with a solution how to handle
this in the scr plugin, it should be easy to add support for scala (or
other languages doing similar stuff).

Hi,

iPOJO uses ASM to handle annotations. In iPOJO, this choice made perfect sense as the manipulation is itself built with ASM. This allows to introspect all the annotations present in the bytecode of classes. However, it will require that you compile your classes into bytecode and maybe generate what you need directly in bytecode.

Regards,

Clement



Carsten
--
Carsten Ziegeler
[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