我有一个EJB,我将对象保存到数据库.在我看到的一个例子中,一旦保存了这个数据(EntityManager.persist),就会调用EntityManager.flush(); 为什么我需要这样做?我保存的对象没有附加,以后不在方法中使用.事实上,一旦保存,方法返回,我希望资源被释放.(示例代码也会在删除调用中执行此操作.)
if (somecondition) {
entityManager.persist(unAttachedEntity);
} else {
attachedEntityObject.setId(unAttachedEntity.getId());
}
entityManager.flush();
Run Code Online (Sandbox Code Playgroud) 我想知道这行代码对一个名为surl的字符串中包含的url做了什么?
String[] stokens = surl.split("\\s*,\\s*");
Run Code Online (Sandbox Code Playgroud)
让我们假装这是surl ="http:// myipaddress:8080/Map/MapServer.html"会是什么?
我正在使用谷歌浏览器插件邮递员测试一些宁静的网络服务.我的一些web服务有一个生成注释,它定义了几种类型.每次我运行我的一个服务时,似乎postman的结果总是以octect-stream形式返回.有没有办法强制postman(或可能我的服务)返回application/xml结果?我宁愿不改变注释,但如果这是我唯一的选择.
我的服务定义 -
@GET
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON,
"application/x-javascript", MediaType.APPLICATION_OCTET_STREAM } )
@Path( "/getCustomers/" )
public Response getCustomers
Run Code Online (Sandbox Code Playgroud)
我的邮差调用只是一个GET调用,标题上没有参数,如下所示:
http://myserver:8080/test/getCustomers
Run Code Online (Sandbox Code Playgroud) 我有一个xsd注释,我试图让Marshal成为一个java对象.我希望java最终得到BigDecimal的价值.我在xsd中输入什么才能使它成功?我正在使用xjc ant任务
<xjc schema="my.xsd" destdir="generated" header="false" extension="true" />
Run Code Online (Sandbox Code Playgroud)
这是相关的xsd -
<complexType name="Size">
<attribute name="height" type="BigDecimal"></attribute> <!-- this is wrong-->
</complexType>
Run Code Online (Sandbox Code Playgroud)
我想为生成的类最终得到这个 -
public class Size {
@XmlAttribute(name = "height")
protected BigDecimal height;
}
Run Code Online (Sandbox Code Playgroud) 我有一个Apache HTTP服务器来处理我对Ruby on Rails项目的所有请求.我们正在考虑添加一个Cesium地图组件.我想知道我是否可以在Apache HTTP服务器上运行Cesium而不是设置node.js环境?
我试图将数千个点放在Cesium地图上并遇到Firefox崩溃的问题.我需要使用Firefox.地图似乎能够显示15,000个点(作为图像).但是,它几乎无法使用.缩放和平移有很大的延迟并最终崩溃.有谁知道限制应该多少点?此外,有没有更好的方式来显示这些点然后我这样做?我真的希望这是我,而不是铯.我听说创建czml然后传入它比较慢,所以我有以下javascript测试:
function test(){
for (var i=0; i<15000; i++){
tempLat +=1;
tempLon +=1;
if(tempLat>90){
tempLat=0;
tempLon=0;
}
addBillboard(scene, ellipsoid, tempLat,tempLon);
}
}
//this is from the sandcastle examples for cesium.
function addBillboard(scene, ellipsoid,tempLat,tempLon) {
var primitives = scene.primitives;
var image = new Image();
image.onload = function() {
var billboards = new Cesium.BillboardCollection();
var textureAtlas = scene.context.createTextureAtlas({image : image});
billboards.textureAtlas = textureAtlas;
billboard = billboards.add({
position : ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(tempLat, tempLon)),
imageIndex : 0
});
primitives.add(billboards);
};
image.src = '../images/Cesium_Logo_overlay.png';
}
Run Code Online (Sandbox Code Playgroud) 我正在关注沙堡椭圆轮廓几何.我想知道是否有任何方法可以使椭圆线宽更宽?有一些使用width属性使折线更宽的例子,但似乎没有办法制作一个ellipseOutlineGeometry对象.sandcastle示例在末尾有一个lineWidth设置,但是对此的更改似乎不会影响椭圆轮廓的宽度.
沙箱代码:
// Create the ellipse geometry. To extrude, specify the
// height of the geometry with the extrudedHeight option.
// The numberOfVerticalLines option can be used to specify
// the number of lines connecting the top and bottom of the
// ellipse.
ellipseOutlineGeometry = new Cesium.EllipseOutlineGeometry({
center : Cesium.Cartesian3.fromDegrees(-95.0, 35.0),
semiMinorAxis : 200000.0,
semiMajorAxis : 300000.0,
extrudedHeight : 150000.0,
rotation : Cesium.Math.toRadians(45),
numberOfVerticalLines: 10
});
// Create a geometry instance using the ellipse geometry
// created above.
var extrudedEllipseOutlineInstance …
Run Code Online (Sandbox Code Playgroud) 我有一个essentailly上载的宁静的Web服务,上载了文件。我还没有为其构建UI。我想编写一个junit测试,它将调用该服务并获取上传的文件。我该怎么做?我看不到手工创建将表单传递给服务的方法。
这是我的休息服务:
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail) {
String uploadedFileLocation = "c://uploadedFiles/" + fileDetail.getFileName();
// save it
// saveToFile(uploadedInputStream, uploadedFileLocation);
String output = "File uploaded via Jersey based RESTFul Webservice to: " + uploadedFileLocation;
return Response.status(200).entity(output).build();
}
Run Code Online (Sandbox Code Playgroud) 我有一个一直在努力解决的承诺链问题。我调用一个外部 api,它返回我需要处理的数据并将其摄取到 mongo 数据库中。我正在将 nodejs 和 mongodb 与 express 一起使用。无论如何,对 api 的调用工作正常,问题是我正在同时制作大量的调用。我想放慢他们的速度,就像为一组打所有电话一样。等一下。为下一组发出所有呼叫。如果这是已知数量的集合,我会承诺将它们链接起来。我不知道有多少套,所以我在循环它们。我认为关闭是问题,但无法解决它。到示例代码!
function readApi(carFactory){
var promise = new Promise(function(resolve, reject) {
// call out to api, get set of car data from factory1
console.log(carFactory);
if (true) {
console.log('resolved');
resolve("Stuff worked!"+carFactory);
}
else {
reject(Error("It broke"));
}
});
return promise;
}
function manager(){
//singular call
readApi("this is a singular test").then(returnedThing=>{
console.log(returnedThing); //Stuff worked! this is a singular test
});
let dynamicList = ["carFactory1", "carFactory2","carFactory3","carFactory..N"];
let readApiAction = [];
dynamicList.forEach(carIter=>{
readApiAction.push(readApi(carIter));
}); …
Run Code Online (Sandbox Code Playgroud)