我需要序列化一个综合的应用程序(游戏)状态,通过网络传输或保存到磁盘并在以后检索.
当然,Bundles用于在几个用例中保存/恢复状态,因此使用它们将是理想的.但是,由于某种原因,Bundle不可序列化.
寻找一个解决方案只是出现了将Bundle转变为包裹然后编组的不可接受的黑客攻击,但这不是一个可接受的解决方案,因为无法保证可以在以后或之后解组数据.远程设备.
现在看来,唯一的解决方案似乎是从Bundle获取整个键集,获取每个包含的Object,在每个Object.Class上做一个相当大的开关/ case并手动构建一个巨大的ByteBuffer或类似的这些数据以及大小和类型信息,以便成功地重建另一方的整个事物.
不完全顺利.
有谁知道更好的方法?也许某人已经为Bundle创建了一个实用程序函数来执行此操作?
我尝试在Eclipse中运行OSGi插件.它是空捆绑,但是eclipse总是发给我错误有我的控制台消息 http://pastebin.com/dqQfpQhd有 什么问题?
我可以将gem源重定向到我的Web服务器路径,在那里我将下载所有必需的gem包并放在那里吗?我想通过" bundle install" 使用那些
GemFile将从http://rubygems.org获取那些在那里定义的那些.我经常得到一个错误,如"太多请求"(似乎是互联网拥塞问题).
是否可以将gem源路径重定向到我的本地服务器?
基本上,我的Web服务必须可以作为单个OSGi jar包进行部署.因此:
I'm attempting to use the maven-bundle-plugin to accomplish this. I've used Embed-Dependency to get all my compile and runtime dependencies in the bundle, and I've used Embed-Transitive to embed all the transitive dependencies. I then figured out how to use excludeDependencies to exclude Maven dependencies from the BND classpath (they are moved to Private-Package in the Manifest), but for the life of me I can't figure out how to get it to exclude the transitive dependencies. …
我已经安装了aptana studio 3插件来进行eclipse.但我无法安装jQuerybundle.
当我选择Command-> Bundel Developemnt-> Install Bundel-> jQuery时,会显示如下信息:
****** ~/Aptana Rubles
$ git clone git://github.com/aptana/javascript-jquery.ruble.git
Cloning into javascript-jquery.ruble...
github.com[0: 207.97.227.239]: errno=No such file or directory
fatal: unable to connect a socket (No such file or directory)
Run Code Online (Sandbox Code Playgroud) 我已经制作了一个小型API Bundle和一个应该使用API的服务包.
在我的maven pom.xml文件中,我在正确的版本中添加了对我的api包的依赖,如下所示:
<dependency>
<groupId>at.foobar.osgi.api</groupId>
<artifactId>foobarapi</artifactId>
<version>1.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我正在使用maven-bundle插件来创建捆绑包,因为我mvn clean install以前用jar文件创建.Manifest看起来像这样(服务):
Manifest-Version: 1.0
Private-Package: at.foobar.osgi.producer
Built-By: foobar
Tool: Bnd-0.0.238
Bundle-Name: foobarproducer
Created-By: Apache Maven Bundle Plugin
Bundle-Version: 1.0
Build-Jdk: 1.6.0_26
Bnd-LastModified: 1332185439257
Bundle-ManifestVersion: 2
Bundle-Activator: at.foobar.osgi.producer.Activator
Import-Package: at.foobar.osgi.api,org.osgi.framework;version="1.4"
Bundle-SymbolicName: at.foobar.osgi.producer.foobarproducer
Run Code Online (Sandbox Code Playgroud)
这对我来说似乎没问题.进口就在那里,所以一切都应该没问题.
现在我启动了equinox并安装了API和生产者包.然后我启动API,这很好.但是,当我想启动Producer服务时,我收到此错误:
org.osgi.framework.BundleException: The bundle "at.foobar.osgi.producer.foobarproducer_1.0.0 [4]" could not be resolved. Reason: Missing Constraint: Import-Package: at.foobar.osgi.api; version="0.0.0"
Run Code Online (Sandbox Code Playgroud)
看来框架找不到api,但是它的安装和启动?
ClassCastException随机发生以恢复onRestoreInstanceState()中的Vector.通常,恢复向量很好,但有时会发生异常.
我认为它发生在活动进入后台并被破坏但我不确定.
有任何想法吗?谢谢.
Stack<LocationInfo> mLocationInfoVector;
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putSerializable("locationInfos", mLocationInfoVector);
super.onSaveInstanceState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
if (savedInstanceState.getSerializable("locationInfos") != null) {
@SuppressWarnings("unchecked")
mLocationInfoVector= (Stack<LocationInfo>) savedInstanceState.getSerializable("locationInfos");
}
super.onRestoreInstanceState(savedInstanceState);
}
Run Code Online (Sandbox Code Playgroud)
添加:
我忘了附上异常日志.那是
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Stack
Run Code Online (Sandbox Code Playgroud) 当提供一个呈现捆绑脚本的简单页面时,我的asp.net MVC4 Web项目运行速度非常慢.但是,当我在页面上使用带有虚拟包路径的source属性的"硬编码"脚本标记时,性能要好得多:
@Scripts.Render("~/bundles/scripts") ~ 4 seconds
Run Code Online (Sandbox Code Playgroud)
VS
<script src='@Scripts.Url("~/bundles/scripts")'></script> < 1 second
Run Code Online (Sandbox Code Playgroud)
我BundleConfig.cs没有特殊配置,这与它看起来完全一样:
bundles.Add(new ScriptBundle("~/bundles/scripts").Include(
"~/Scripts/jquery-1.7.2.min.js",
"~/Scripts/jquery.validate.min.js",
"~/Scripts/jquery.validate.unobtrusive.js",
"~/Scripts/jquery-ui-1.9.0.custom.min.js",
"~/Scripts/bootstrap.min.js",
"~/Scripts/bootstrap-modal.js",
"~/Scripts/bootstrap-dropdown.js",
"~/Scripts/bootstrap-tooltip.js",
"~/Scripts/bootstrap-typeahead.js",
"~/Scripts/bootstrap-transition.js",
"~/Scripts/bootstrap-popover.js"));
Run Code Online (Sandbox Code Playgroud)
我web.config甚至配置为在Debug中进行优化,但我尝试在Release模式下运行并仍然得到相同的结果:
<compilation optimizeCompilations="true" debug="false" targetFramework="4.0" />
Run Code Online (Sandbox Code Playgroud)
任何想法为什么Scripts.Render这么慢?
我试图理解以下之间的区别
<dependency>
<groupId>com.myspace.order</groupId>
<artifactId>dal</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
和
<dependency>
<groupId>com.myspace.order</groupId>
<artifactId>dal</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>bundle</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)
dal工件本身具有指定为bundle的包装:
<packaging>bundle</packaging>
Run Code Online (Sandbox Code Playgroud)
现在,当我部署dal工件时,我发现它在repo中作为jar发布(其中包含一个清单).在这种情况下,我对dal的依赖应该是什么.它应该是捆绑式还是罐型?如果我正在做OSGI,我认为方法是将类型指定为bundle.它是否正确?或者,我可以在这里拥有jar依赖吗?
我试图在Mac El Capitan上安装pg Gem,但我总是遇到这个错误:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/Users/ricardolopes/Developer/homebrew/bin/pg_config
Using config values from /Users/ricardolopes/Developer/homebrew/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file … bundle ×10
osgi ×4
maven ×3
android ×2
java ×2
rubygems ×2
aptana ×1
asp.net-mvc ×1
dependencies ×1
eclipse ×1
equinox ×1
jar ×1
jquery ×1
pg ×1
serializable ×1