作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要向 Maven 构建或 Java 运行时添加哪些选项才能访问内部 sun.security 类? OSGI 包中有来自 Akamai 的 Java 代码需要访问内部 sun.security 类。 Apache Felix 控制台给出了 OSGI 包的错误:
sun.awt.image.codec -- Cannot be resolved
sun.io -- Cannot be resolved
sun.misc -- Cannot be resolved
sun.rmi.rmic -- Cannot be resolved
sun.security.action -- Cannot be resolved
sun.security.ec -- Cannot be resolved
sun.security.internal.interfaces -- Cannot be resolved
...
我看了this article about using internal sun classes但它仅指javac。我的 Maven 构建开始如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<modelVersion>4.0.0</modelVersion>
<artifactId>cdncache</artifactId>
<packaging>bundle</packaging>
<name>NCDN Cache</name>
<description>Classes and interfaces to expire resource from the Akamai CDN cache [build:${build.number}]\
</description>
<version>1.0-${build.number}</version>
<properties>
<!-- Skip tests, so maven execution is faster. -->
<maven.test.skip>true</maven.test.skip>
<file.encoding>utf-8</file.encoding>
</properties>
<build>
<plugins>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
com.nymag.akamai,
com.akamai.*,
...
</Export-Package>
<Private-Package>
org.apache.axis.*,
...
sun.security,
sun.security.ec,
</Private-Package>
<Bundle-Version>1.0</Bundle-Version>
<Bundle-Activator>com.nymag.akamai.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
...
最佳答案
我同意 stjohnroe 的观点,即使用特定于 VM 的类通常是不好的,但有时您必须这样做(例如,当您当前处于过渡阶段时)。如果你想这样做,你可以添加
org.osgi.framework.system.packages.extra=sun.your.package.of.choice
到框架属性。如果您使用标准的 Felix 启动器,您可以为此编辑 conf/config.properties
。
关于maven - 如何从 OSGI 包访问内部 sun.security 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4462154/
我是一名优秀的程序员,十分优秀!