You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by jp...@apache.org on 2013/02/07 12:38:43 UTC
svn commit: r1443423 - in /cxf/branches/2.7.x-fixes:
rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/
systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/
systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst...
Author: jpell
Date: Thu Feb 7 11:38:42 2013
New Revision: 1443423
URL: http://svn.apache.org/viewvc?rev=1443423&view=rev
Log:
CXF-4816 - fix to ensure that class level @Policies are effective in service impl classes
Removed:
cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleServiceClient.java
Modified:
cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java
cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java
cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleService.java
cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleServiceImpl.java
cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/sslcertclient.xml
cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/sslnocertclient.xml
Modified: cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java?rev=1443423&r1=1443422&r2=1443423&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java (original)
+++ cxf/branches/2.7.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java Thu Feb 7 11:38:42 2013
@@ -45,7 +45,6 @@ import org.apache.cxf.common.logging.Log
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.configuration.ConfiguredBeanLocator;
import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.endpoint.Server;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.resource.ExtendedURIResolver;
@@ -84,28 +83,30 @@ public class PolicyAnnotationListener im
addPolicies(factory, ii, cls);
break;
}
+
case ENDPOINT_SELECTED: {
Class<?> cls = (Class<?>)args[2];
+ Class<?> implCls = args.length > 3 ? (Class<?>)args[3] : null;
Endpoint ep = (Endpoint)args[1];
if (ep.getEndpointInfo().getInterface() != null) {
addPolicies(factory, ep, cls);
+
+ // this will allow us to support annotations in Implementations, but only for
+ // class level annotations. Method level annotations are not currently supported
+ // for implementations. The call has been moved here so that the ServiceInfo
+ // policy stuff is loaded before jaxws factory calls the PolicyEngineImpl
+ addEndpointImplPolicies(factory, ep, implCls);
}
break;
}
- case SERVER_CREATED: {
- Class<?> cls = (Class<?>)args[2];
- Server server = (Server)args[0];
- if (server.getEndpoint().getEndpointInfo().getInterface() != null) {
- addPolicies(factory, server, cls);
- }
- break;
- }
+
case INTERFACE_OPERATION_BOUND: {
OperationInfo inf = (OperationInfo)args[0];
Method m = (Method)args[1];
addPolicies(factory, inf, m);
break;
}
+
default:
//ignore
}
@@ -161,6 +162,7 @@ public class PolicyAnnotationListener im
//nothing
}
}
+
if (!list.isEmpty()) {
List<Policy> stuff = CastUtils.cast((List<?>)inf.getProperty(EXTRA_POLICIES));
if (stuff != null) {
@@ -216,15 +218,17 @@ public class PolicyAnnotationListener im
}
}
}
- private void addPolicies(AbstractServiceFactoryBean factory, Server server, Class<?> cls) {
- List<Policy> list = CastUtils.cast((List<?>)server.getEndpoint().getEndpointInfo()
+
+ private void addEndpointImplPolicies(AbstractServiceFactoryBean factory, Endpoint endpoint, Class<?> cls) {
+ List<Policy> list = CastUtils.cast((List<?>)endpoint.getEndpointInfo()
.getInterface().removeProperty(EXTRA_POLICIES));
if (list != null) {
- addPolicies(factory, server.getEndpoint(), cls, list, Policy.Placement.BINDING);
+ addPolicies(factory, endpoint, cls, list, Policy.Placement.BINDING);
}
if (cls == null) {
return;
}
+
Policy p = cls.getAnnotation(Policy.class);
Policies ps = cls.getAnnotation(Policies.class);
if (p != null || ps != null) {
@@ -235,9 +239,8 @@ public class PolicyAnnotationListener im
if (ps != null) {
list.addAll(Arrays.asList(ps.value()));
}
- addPolicies(factory, server.getEndpoint(), cls, list, Policy.Placement.SERVICE);
+ addPolicies(factory, endpoint, cls, list, Policy.Placement.SERVICE);
}
-
}
private void addPolicies(AbstractServiceFactoryBean factory, Endpoint endpoint, Class<?> cls,
@@ -323,6 +326,7 @@ public class PolicyAnnotationListener im
default:
}
}
+
if (!list.isEmpty()) {
List<Policy> stuff = CastUtils.cast((List<?>)ii.getProperty(EXTRA_POLICIES));
if (stuff != null) {
Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java?rev=1443423&r1=1443422&r2=1443423&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java (original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/JavaFirstPolicyServiceTest.java Thu Feb 7 11:38:42 2013
@@ -37,7 +37,7 @@ import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.service.model.MessageInfo.Type;
import org.apache.cxf.systest.ws.common.SecurityTestUtil;
-import org.apache.cxf.systest.ws.policy.javafirst.BindingSimpleServiceClient;
+import org.apache.cxf.systest.ws.policy.javafirst.BindingSimpleService;
import org.apache.cxf.systest.ws.policy.javafirst.NoAlternativesOperationSimpleServiceClient;
import org.apache.cxf.systest.ws.policy.javafirst.OperationSimpleServiceClient;
import org.apache.cxf.systest.ws.policy.server.JavaFirstPolicyServer;
@@ -53,7 +53,6 @@ import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class JavaFirstPolicyServiceTest extends AbstractBusClientServerTestBase {
@@ -153,8 +152,8 @@ public class JavaFirstPolicyServiceTest
"org/apache/cxf/systest/ws/policy/client/sslnocertclient.xml"
});
- BindingSimpleServiceClient simpleService = clientContext.getBean("BindingSimpleServiceClient",
- BindingSimpleServiceClient.class);
+ BindingSimpleService simpleService = clientContext.getBean("BindingSimpleServiceClient",
+ BindingSimpleService.class);
try {
simpleService.doStuff();
@@ -185,8 +184,8 @@ public class JavaFirstPolicyServiceTest
"org/apache/cxf/systest/ws/policy/client/sslcertclient.xml"
});
- BindingSimpleServiceClient simpleService = clientContext.getBean("BindingSimpleServiceClient",
- BindingSimpleServiceClient.class);
+ BindingSimpleService simpleService = clientContext.getBean("BindingSimpleServiceClient",
+ BindingSimpleService.class);
try {
simpleService.doStuff();
Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleService.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleService.java?rev=1443423&r1=1443422&r2=1443423&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleService.java (original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleService.java Thu Feb 7 11:38:42 2013
@@ -22,11 +22,7 @@ package org.apache.cxf.systest.ws.policy
import javax.jws.WebMethod;
import javax.jws.WebService;
-import org.apache.cxf.annotations.Policy;
-import org.apache.cxf.annotations.Policy.Placement;
-
@WebService(name = "BindingSimpleService", targetNamespace = "http://www.example.org/contract/BindingSimpleService")
-@Policy(uri = "classpath:/java_first_policies/AlternativesPolicy.xml", placement = Placement.BINDING)
public interface BindingSimpleService {
@WebMethod(operationName = "doStuff")
void doStuff();
Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleServiceImpl.java?rev=1443423&r1=1443422&r2=1443423&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleServiceImpl.java (original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/javafirst/BindingSimpleServiceImpl.java Thu Feb 7 11:38:42 2013
@@ -21,10 +21,14 @@ package org.apache.cxf.systest.ws.policy
import javax.jws.WebService;
+import org.apache.cxf.annotations.Policy;
+import org.apache.cxf.annotations.Policy.Placement;
+
@WebService(name = "BindingSimpleService",
endpointInterface = "org.apache.cxf.systest.ws.policy.javafirst.BindingSimpleService",
serviceName = "BindingSimpleService",
targetNamespace = "http://www.example.org/contract/BindingSimpleService")
+@Policy(uri = "classpath:/java_first_policies/AlternativesPolicy.xml", placement = Placement.BINDING)
public class BindingSimpleServiceImpl implements BindingSimpleService {
@Override
public void doStuff() {
Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/sslcertclient.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/sslcertclient.xml?rev=1443423&r1=1443422&r2=1443423&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/sslcertclient.xml (original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/sslcertclient.xml Thu Feb 7 11:38:42 2013
@@ -46,7 +46,7 @@
</http:conduit>
<jaxws:client id="BindingSimpleServiceClient"
- serviceClass="org.apache.cxf.systest.ws.policy.javafirst.BindingSimpleServiceClient"
+ serviceClass="org.apache.cxf.systest.ws.policy.javafirst.BindingSimpleService"
address="https://localhost:${testutil.ports.JavaFirstPolicyServer.3}/BindingSimpleService">
</jaxws:client>
Modified: cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/sslnocertclient.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/sslnocertclient.xml?rev=1443423&r1=1443422&r2=1443423&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/sslnocertclient.xml (original)
+++ cxf/branches/2.7.x-fixes/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/policy/client/sslnocertclient.xml Thu Feb 7 11:38:42 2013
@@ -41,7 +41,7 @@
</http:conduit>
<jaxws:client id="BindingSimpleServiceClient"
- serviceClass="org.apache.cxf.systest.ws.policy.javafirst.BindingSimpleServiceClient"
+ serviceClass="org.apache.cxf.systest.ws.policy.javafirst.BindingSimpleService"
address="https://localhost:${testutil.ports.JavaFirstPolicyServer.3}/BindingSimpleService">
</jaxws:client>