我使用ContainerRequestFilter实现了RestEasy授权。但是,当我调用服务方法时,我的过滤器代码抛出了NullPointerException。请参见下面的代码片段
// A cube
var faces = [
{a: 0, b: 1, c: 2}, {a: 2, b: 3, c: 0}, // Front
{a: 1, b: 5, c: 6}, {a: 6, b: 2, c: 1}, // Right
{a: 5, b: 4, c: 7}, {a: 7, b: 6, c: 5}, // Back
{a: 4, b: 0, c: 3}, {a: 3, b: 7, c: 4}, // Left
{a: 3, b: 2, c: 6}, {a: 6, b: 7, c: 3}, // Top
{a: 4, b: 5, c: 1}, {a: 1, b: 0, c: 4}, // Bottom
];
function compareEdges(edge1, edge2) {
if(edge1[0] == edge2[0] && edge1[1] == edge2[1]) { edge1[2]++; edge2[2]++; }
var i1 = edge1[0];
var i2 = edge2[0];
if (i1 != i2)
return i1 < i2 ? -1 : 1;
var j1 = edge1[1];
var j2 = edge2[1];
if (j1 != j2)
return j1 < j2 ? -1 : 1;
return 0;
}
function discardUniqueEdges(edges) {
var i, j, n;
var count;
edges.sort(compareEdges);
count = 0;
j = 0; // The range [0, j[ of the array stores duplicated edges
for (i = 0, n = edges.length; i < n; i++) {
if (!count) {
count = 1;
continue;
}
if (!compareEdges(edges[i - 1], edges[i])) {
++count;
continue;
}
// edges[i - 1] != edges[i]
if (count <= 1)
continue;
//edges[i - 1] != edges[i] && count > 1
edges[j][0] = edges[i - 1][0];
edges[j][1] = edges[i - 1][1];
edges[j][2] = edges[i - 1][2];
j += 1;
count = 1;
}
if (count > 1) {
edges[j][0] = edges[i - 1][0];
edges[j][1] = edges[i - 1][1];
edges[j][1] = edges[i - 1][2];
j += 1;
}
edges.length = j;
return edges;
}
function extractEdges(faces) {
var edges = [];
var face;
var i, n;
// Store all edges
for (i = 0, n = faces.length; i < n; i++) {
face = faces[i];
edges.push([face.a, face.b].sort()); edges[edges.length - 1].push(0);
edges.push([face.b, face.c].sort()); edges[edges.length - 1].push(0);
edges.push([face.c, face.a].sort()); edges[edges.length - 1].push(0);
}
return discardUniqueEdges(edges);
}
var edges = extractEdges(faces);
console.log(edges.length)
console.log(edges)
requestContext.getProperty()方法返回NULL。是读取资源注释所需的任何配置。请帮我解决这个问题?
技术堆栈: Wildfly10 java1.8 RestEasy 3.0.11Final