use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class PolicyAnnotationListener method handleEvent.
public void handleEvent(Event ev, AbstractServiceFactoryBean factory, Object... args) {
switch(ev) {
case INTERFACE_CREATED:
{
InterfaceInfo ii = (InterfaceInfo) args[0];
Class<?> cls = (Class<?>) args[1];
addPolicies(factory, ii, cls);
break;
}
case ENDPOINT_SELECTED:
{
Class<?> cls = (Class<?>) args[2];
Class<?> implCls = (Class<?>) args[3];
Endpoint ep = (Endpoint) args[1];
if (ep.getEndpointInfo().getInterface() != null) {
addPolicies(factory, ep, cls);
// this will allow us to support annotations in 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 INTERFACE_OPERATION_BOUND:
{
OperationInfo inf = (OperationInfo) args[0];
Method m = (Method) args[1];
addPolicies(factory, inf, m);
break;
}
case BINDING_OPERATION_CREATED:
BindingOperationInfo boi = (BindingOperationInfo) args[1];
Method m = (Method) args[2];
addPolicies(factory, boi.getOperationInfo(), m);
break;
default:
}
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class ProxyTest method testCreateSequence.
@SuppressWarnings("unchecked")
private void testCreateSequence(boolean isServer) throws NoSuchMethodException, RMException {
Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class, Exchange.class });
Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
proxy.setReliableEndpoint(rme);
RMManager manager = control.createMock(RMManager.class);
EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes();
SourcePolicyType sp = control.createMock(SourcePolicyType.class);
EasyMock.expect(manager.getSourcePolicy()).andReturn(sp).anyTimes();
EasyMock.expect(sp.getAcksTo()).andReturn(null).anyTimes();
Duration d = DatatypeFactory.createDuration("PT12H");
EasyMock.expect(sp.getSequenceExpiration()).andReturn(d).anyTimes();
EasyMock.expect(sp.isIncludeOffer()).andReturn(Boolean.TRUE).anyTimes();
Duration dOffered = DatatypeFactory.createDuration("PT24H");
EasyMock.expect(sp.getOfferedSequenceExpiration()).andReturn(dOffered).anyTimes();
Source source = control.createMock(Source.class);
EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
Identifier offeredId = control.createMock(Identifier.class);
EasyMock.expect(source.generateSequenceIdentifier()).andReturn(offeredId).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
EndpointInfo epi = control.createMock(EndpointInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
ServiceInfo si = control.createMock(ServiceInfo.class);
EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
InterfaceInfo ii = control.createMock(InterfaceInfo.class);
EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
OperationInfo oi = control.createMock(OperationInfo.class);
org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType csr = null;
if (isServer) {
EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_ONEWAY_QNAME)).andReturn(oi).anyTimes();
Endpoint ae = control.createMock(Endpoint.class);
EasyMock.expect(rme.getApplicationEndpoint()).andReturn(ae).anyTimes();
EasyMock.expect(ae.getExecutor()).andReturn(SynchronousExecutor.getInstance()).anyTimes();
} else {
EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
csr = new org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType();
}
ExchangeImpl exchange = new ExchangeImpl();
EasyMock.expect(proxy.invoke(EasyMock.same(oi), EasyMock.isA(ProtocolVariation.class), EasyMock.isA(Object[].class), EasyMock.isA(Map.class), EasyMock.isA(Exchange.class))).andReturn(csr).anyTimes();
EndpointReferenceType defaultAcksTo = control.createMock(EndpointReferenceType.class);
AttributedURIType aut = control.createMock(AttributedURIType.class);
EasyMock.expect(aut.getValue()).andReturn("here").anyTimes();
EasyMock.expect(defaultAcksTo.getAddress()).andReturn(aut).anyTimes();
RelatesToType relatesTo = control.createMock(RelatesToType.class);
control.replay();
Map<String, Object> context = new HashMap<>();
if (isServer) {
assertNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, ProtocolVariation.RM10WSA200408, exchange, context));
} else {
assertNotNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, ProtocolVariation.RM10WSA200408, exchange, context));
}
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class ProxyTest method testTerminate.
@Test
public void testTerminate() throws NoSuchMethodException, RMException {
Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class });
Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
proxy.setReliableEndpoint(rme);
Endpoint endpoint = control.createMock(Endpoint.class);
EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
EndpointInfo epi = control.createMock(EndpointInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
ServiceInfo si = control.createMock(ServiceInfo.class);
EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
InterfaceInfo ii = control.createMock(InterfaceInfo.class);
EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
OperationInfo oi = control.createMock(OperationInfo.class);
EasyMock.expect(ii.getOperation(RM10Constants.TERMINATE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
SourceSequence ss = control.createMock(SourceSequence.class);
Identifier id = control.createMock(Identifier.class);
EasyMock.expect(ss.getIdentifier()).andReturn(id).anyTimes();
EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
expectInvoke(proxy, oi, null);
control.replay();
proxy.terminate(ss);
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class RMEndpointTest method verifyService.
private void verifyService() {
Service service = rme.getService(ProtocolVariation.RM10WSA200408);
ServiceInfo si = service.getServiceInfos().get(0);
assertNotNull("service info is null", si);
InterfaceInfo intf = si.getInterface();
assertEquals(8, intf.getOperations().size());
String ns = RM10Constants.NAMESPACE_URI;
OperationInfo oi = intf.getOperation(new QName(ns, "CreateSequence"));
assertNotNull("No operation info.", oi);
assertTrue("Operation is oneway.", !oi.isOneWay());
assertTrue("Operation is unwrapped.", !oi.isUnwrapped());
assertTrue("Operation is unwrappedCapable.", !oi.isUnwrappedCapable());
assertNull("Unexpected unwrapped operation.", oi.getUnwrappedOperation());
oi = intf.getOperation(new QName(ns, "TerminateSequence"));
assertNotNull("No operation info.", oi);
assertTrue("Operation is toway.", oi.isOneWay());
oi = intf.getOperation(new QName(ns, "TerminateSequenceAnonymous"));
assertNotNull("No operation info.", oi);
assertTrue("Operation is oneway.", !oi.isOneWay());
oi = intf.getOperation(new QName(ns, "SequenceAcknowledgement"));
assertNotNull("No operation info.", oi);
assertTrue("Operation is toway.", oi.isOneWay());
oi = intf.getOperation(new QName(ns, "CloseSequence"));
assertNotNull("No operation info.", oi);
assertTrue("Operation is toway.", oi.isOneWay());
oi = intf.getOperation(new QName(ns, "AckRequested"));
assertNotNull("No operation info.", oi);
assertTrue("Operation is toway.", oi.isOneWay());
oi = intf.getOperation(new QName(ns, "CreateSequenceOneway"));
assertNotNull("No operation info.", oi);
assertTrue("Operation is toway.", oi.isOneWay());
oi = intf.getOperation(new QName(ns, "CreateSequenceResponseOneway"));
assertNotNull("No operation info.", oi);
assertTrue("Operation is toway.", oi.isOneWay());
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class JavaFirstUtil method serviceInfo2JavaInf.
public static JavaInterface serviceInfo2JavaInf(ServiceInfo service) {
JavaInterface javaInf = new JavaInterface();
InterfaceInfo inf = service.getInterface();
for (OperationInfo op : inf.getOperations()) {
JavaMethod jm = new JavaMethod();
Method m = (Method) op.getProperty(ReflectionServiceFactoryBean.METHOD);
jm.setName(m.getName());
int i = 0;
for (Type type : m.getGenericParameterTypes()) {
JavaParameter jp = new JavaParameter();
jp.setClassName(getClassName(type));
jp.setStyle(Style.IN);
jp.setName("arg" + i++);
jm.addParameter(jp);
}
for (Type type : m.getGenericExceptionTypes()) {
JavaException jex = new JavaException();
String className = getClassName(type);
jex.setClassName(className);
jex.setName(className);
jm.addException(jex);
}
JavaReturn jreturn = new JavaReturn();
jreturn.setClassName(getClassName(m.getGenericReturnType()));
jreturn.setStyle(Style.OUT);
jm.setReturn(jreturn);
String pkg = PackageUtils.getPackageName(m.getDeclaringClass());
javaInf.setPackageName(pkg.length() == 0 ? ToolConstants.DEFAULT_PACKAGE_NAME : pkg);
javaInf.addMethod(jm);
javaInf.setName(inf.getName().getLocalPart());
jm.getParameterList();
}
return javaInf;
}
Aggregations