use of org.apache.cxf.service.ServiceImpl in project cxf by apache.
the class ReflectionServiceFactoryBean method buildServiceFromClass.
protected void buildServiceFromClass() {
Object o = getBus().getProperty("requireExplicitContractLocation");
if (o != null && ("true".equals(o) || Boolean.TRUE.equals(o))) {
throw new ServiceConstructionException(new Message("NO_WSDL_PROVIDED", LOG, getServiceClass().getName()));
}
if (LOG.isLoggable(Level.INFO)) {
LOG.info("Creating Service " + getServiceQName() + " from class " + getServiceClass().getName());
}
populateFromClass = true;
if (Proxy.isProxyClass(this.getServiceClass())) {
LOG.log(Level.WARNING, "USING_PROXY_FOR_SERVICE", getServiceClass());
}
sendEvent(Event.CREATE_FROM_CLASS, getServiceClass());
ServiceInfo serviceInfo = new ServiceInfo();
SchemaCollection col = serviceInfo.getXmlSchemaCollection();
col.getXmlSchemaCollection().setSchemaResolver(new CatalogXmlSchemaURIResolver(this.getBus()));
col.getExtReg().registerSerializer(MimeAttribute.class, new MimeSerializer());
ServiceImpl service = new ServiceImpl(serviceInfo);
setService(service);
setServiceProperties();
serviceInfo.setName(getServiceQName());
serviceInfo.setTargetNamespace(serviceInfo.getName().getNamespaceURI());
sendEvent(Event.SERVICE_SET, getService());
createInterface(serviceInfo);
Set<?> wrapperClasses = this.getExtraClass();
for (ServiceInfo si : getService().getServiceInfos()) {
if (wrapperClasses != null && !wrapperClasses.isEmpty()) {
si.setProperty(EXTRA_CLASS, wrapperClasses);
}
}
initializeDataBindings();
boolean isWrapped = isWrapped() || hasWrappedMethods(serviceInfo.getInterface());
if (isWrapped) {
initializeWrappedSchema(serviceInfo);
}
for (OperationInfo opInfo : serviceInfo.getInterface().getOperations()) {
Method m = (Method) opInfo.getProperty(METHOD);
if (!isWrapped(m) && !isRPC(m) && opInfo.getInput() != null) {
createBareMessage(serviceInfo, opInfo, false);
}
if (!isWrapped(m) && !isRPC(m) && opInfo.getOutput() != null) {
createBareMessage(serviceInfo, opInfo, true);
}
if (opInfo.hasFaults()) {
// check to make sure the faults are elements
for (FaultInfo fault : opInfo.getFaults()) {
QName qn = (QName) fault.getProperty("elementName");
MessagePartInfo part = fault.getFirstMessagePart();
if (!part.isElement()) {
part.setElement(true);
part.setElementQName(qn);
checkForElement(serviceInfo, part);
}
}
}
}
if (LOG.isLoggable(Level.FINE) || isValidate()) {
ServiceModelSchemaValidator validator = new ServiceModelSchemaValidator(serviceInfo);
validator.walk();
String validationComplaints = validator.getComplaints();
if (!"".equals(validationComplaints)) {
if (isValidate()) {
LOG.warning(validationComplaints);
} else {
LOG.fine(validationComplaints);
}
}
}
}
use of org.apache.cxf.service.ServiceImpl in project cxf by apache.
the class STSTokenOutInterceptorTest method prepareMessage.
private MessageImpl prepareMessage(Bus bus, STSClient stsClient, String serviceAddress) throws EndpointException {
MessageImpl message = new MessageImpl();
message.put(SecurityConstants.STS_CLIENT, stsClient);
message.put(Message.ENDPOINT_ADDRESS, serviceAddress);
Exchange exchange = new ExchangeImpl();
ServiceInfo si = new ServiceInfo();
Service s = new ServiceImpl(si);
EndpointInfo ei = new EndpointInfo();
Endpoint ep = new EndpointImpl(bus, s, ei);
ei.setBinding(new BindingInfo(si, null));
message.setExchange(exchange);
exchange.put(Endpoint.class, ep);
return message;
}
use of org.apache.cxf.service.ServiceImpl in project cxf by apache.
the class ServiceInvokerInterceptorTest method createEndpoint.
Endpoint createEndpoint(Invoker i) throws Exception {
IMocksControl control = EasyMock.createNiceControl();
Endpoint endpoint = control.createMock(Endpoint.class);
ServiceImpl service = new ServiceImpl((ServiceInfo) null);
service.setInvoker(i);
service.setExecutor(new SimpleExecutor());
EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
control.replay();
return endpoint;
}
use of org.apache.cxf.service.ServiceImpl in project cxf by apache.
the class EndpointImplTest method testEqualsAndHashCode.
@Test
public void testEqualsAndHashCode() throws Exception {
Bus bus = new ExtensionManagerBus();
Service svc = new ServiceImpl();
EndpointInfo ei = new EndpointInfo();
ei.setAddress("http://nowhere.com/bar/foo");
EndpointInfo ei2 = new EndpointInfo();
ei2.setAddress("http://nowhere.com/foo/bar");
Endpoint ep = new EndpointImpl(bus, svc, ei);
Endpoint ep1 = new EndpointImpl(bus, svc, ei);
Endpoint ep2 = new EndpointImpl(bus, svc, ei2);
int hashcode = ep.hashCode();
int hashcode1 = ep1.hashCode();
int hashcode2 = ep2.hashCode();
assertTrue("hashcodes must be equal", hashcode == hashcode1);
assertTrue("hashcodes must not be equal", hashcode != hashcode2);
assertTrue("reflexivity violated", ep.equals(ep));
assertFalse("two objects must not be equal", ep.equals(ep1));
assertFalse("two objects must not be equal", ep.equals(ep2));
ep.put("custom", Boolean.TRUE);
assertTrue("hashcode must remain equal", hashcode == ep.hashCode());
}
use of org.apache.cxf.service.ServiceImpl in project cxf by apache.
the class MAPAggregatorTest method testGetReplyToUsingBaseAddress.
@Test
public void testGetReplyToUsingBaseAddress() throws Exception {
Message message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
final String localReplyTo = "/SoapContext/decoupled";
final String decoupledEndpointBase = "http://localhost:8181/cxf";
final String replyTo = decoupledEndpointBase + localReplyTo;
ServiceInfo s = new ServiceInfo();
Service svc = new ServiceImpl(s);
EndpointInfo ei = new EndpointInfo();
InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
s.setInterface(ii);
ii.addOperation(new QName("fooOp"));
SoapBindingInfo b = new SoapBindingInfo(s, "http://schemas.xmlsoap.org/soap/", Soap11.getInstance());
b.setTransportURI("http://schemas.xmlsoap.org/soap/http");
ei.setBinding(b);
ei.setAddress("http://nowhere.com/bar/foo");
ei.setName(new QName("http://nowhere.com/port", "foo"));
Bus bus = new ExtensionManagerBus();
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
DestinationFactory df = control.createMock(DestinationFactory.class);
Destination d = control.createMock(Destination.class);
bus.setExtension(dfm, DestinationFactoryManager.class);
EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df);
EasyMock.expect(df.getDestination(EasyMock.anyObject(EndpointInfo.class), EasyMock.anyObject(Bus.class))).andReturn(d);
EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo));
Endpoint ep = new EndpointImpl(bus, svc, ei);
exchange.put(Endpoint.class, ep);
exchange.put(Bus.class, bus);
exchange.setOutMessage(message);
setUpMessageProperty(message, REQUESTOR_ROLE, Boolean.TRUE);
message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY);
message.put(WSAContextUtils.REPLYTO_PROPERTY, localReplyTo);
message.put(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY, decoupledEndpointBase);
AddressingProperties maps = new AddressingProperties();
AttributedURIType id = ContextUtils.getAttributedURI("urn:uuid:12345");
maps.setMessageID(id);
maps.setAction(ContextUtils.getAttributedURI(""));
setUpMessageProperty(message, CLIENT_ADDRESSING_PROPERTIES, maps);
control.replay();
aggregator.mediate(message, false);
AddressingProperties props = (AddressingProperties) message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND);
assertEquals(replyTo, props.getReplyTo().getAddress().getValue());
control.verify();
}
Aggregations