UcasRichard / snakeyaml

Automatically exported from code.google.com/p/snakeyaml
Apache License 2.0
0 stars 0 forks source link

Add OSGi support #96

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
SneakYaml don't aliened with OSGi standard(lack of header), so it won't run in 
any OSGi container, like Apache Felix

What is the expected output? What do you see instead?
It should be loaded as an OSGi bundle

What version of the product are you using? On what operating system?
SneakYaml 1.7

Please provide any additional information below.
I suggest you use maven bundle plugin to add OSGi headers

Original issue reported on code.google.com by longkerd...@gmail.com on 23 Nov 2010 at 1:48

GoogleCodeExporter commented 9 years ago
Feel free to provide a patch with the required changes.

Original comment by py4fun@gmail.com on 23 Nov 2010 at 1:55

GoogleCodeExporter commented 9 years ago
This may be helpful:
http://stackoverflow.com/questions/4940379/using-snakeyaml-under-osgi

Original comment by py4fun@gmail.com on 10 Feb 2011 at 11:12

GoogleCodeExporter commented 9 years ago
I was able to deploy SnakeYAML under OSGi as a wrapped bundle with the attached 
auto-generated (by Eclipse) MANIFEST.MF modified for your uses. Everything 
worked the way I was expecting, save that I had to use the 
CustomClassLoaderConstructor to workaround the way that OSGi loads classes. 
This should probably be noted in documentation somewhere.

As a possible fix to that, you could use each individual class's classloader 
for object creation. This seems to be a good solution, but would require extra 
testing to ensure that nothing breaks, of course.

The attached MANIFEST just exports every package in JAR. This may not be what 
you want to do. The general idea is to export only the minimum set of packages 
required for operation. For example, you may want to remove 
com.google.gdata.util.common.base since that appears to only be used internally.

Also Bundle-RequiredExecutionEnvironment should be changed to whatever the 
minimum JVM you can run on is.

Let me know if you need/want more information about the attached MANIFEST, etc.

Original comment by thegreen...@gmail.com on 11 Feb 2011 at 7:57

Attachments:

GoogleCodeExporter commented 9 years ago
I introduced maven bundle plugin and the generated MANIFEST does not look good.
Can someone help to fix it ?
This is the change: 
http://code.google.com/p/snakeyaml/source/diff?spec=svn0992be7861f4bb38abbc0bdce
3c151562d322ca3&r=0992be7861f4bb38abbc0bdce3c151562d322ca3&format=side&path=/pom
.xml

The list of packages is wrong:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven Bundle Plugin
Built-By: somov
Build-Jdk: 1.5.0_19
Bundle-License: LICENSE.txt
Import-Package: org.yaml.snakeyaml,org.yaml.snakeyaml.emitter,org.yaml
 .snakeyaml.error,org.yaml.snakeyaml.events,org.yaml.snakeyaml.nodes,o
 rg.yaml.snakeyaml.resolver
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bnd-LastModified: 1298455453051
Export-Package: org.yaml.snakeyaml.serializer;uses:="org.yaml.snakeyam
 l.nodes,org.yaml.snakeyaml.events,org.yaml.snakeyaml.error,org.yaml.s
 nakeyaml.emitter,org.yaml.snakeyaml.resolver,org.yaml.snakeyaml"
Bundle-Version: 1.9.0.SNAPSHOT
Bundle-Name: SnakeYAML
Bundle-Description: YAML 1.1 parser and emitter for Java
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.yaml.snakeyaml
Tool: Bnd-1.15.0

Original comment by py4fun@gmail.com on 23 Feb 2011 at 9:49

GoogleCodeExporter commented 9 years ago
This is the configuration for the bundle plugin:
<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.4</version>
    <extensions>true</extensions>
    <configuration>
      <instructions>
        <Export-Package>org.yaml.snakeyaml.*</Export-Package>
                 <Bundle-RequiredExecutionEnvironment>J2SE-1.5</Bundle-RequiredExecutionEnvironment>
      </instructions>
    </configuration>
</plugin>

Original comment by py4fun@gmail.com on 23 Feb 2011 at 2:19

GoogleCodeExporter commented 9 years ago
It will be delivered in release 1.9

Original comment by py4fun@gmail.com on 25 Feb 2011 at 4:16

GoogleCodeExporter commented 9 years ago
Issue 123 has been merged into this issue.

Original comment by py4fun@gmail.com on 28 Jun 2011 at 1:27