use of org.apache.cxf.service.ServiceImpl in project cxf by apache.
the class STSTokenRetrieverTest 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 jbossws-cxf by jbossws.
the class JBossWSInvokerTest method getTestExchange.
// build up a fake exchange instance, the minimum required to let the flow proceed till the JBossWSInvoker
private Exchange getTestExchange() {
Exchange exchange = new ExchangeImpl();
Message message = new MessageImpl();
message.setExchange(exchange);
exchange.setInMessage(message);
exchange.put(BindingOperationInfo.class, new BindingOperationInfo());
Service service = new ServiceImpl();
MethodDispatcher md = new MethodDispatcher() {
@Override
public Method getMethod(BindingOperationInfo op) {
return this.getClass().getMethods()[0];
}
@Override
public BindingOperationInfo getBindingOperation(Method m, Endpoint endpoint) {
return null;
}
@Override
public void bind(OperationInfo o, Method... methods) {
}
};
service.put(MethodDispatcher.class.getName(), md);
exchange.put(Service.class, service);
return exchange;
}
use of org.apache.cxf.service.ServiceImpl in project jbossws-cxf by jbossws.
the class ServerBeanCustomizer method customize.
@Override
public void customize(Object beanInstance) {
if (beanInstance instanceof EndpointImpl) {
configureEndpoint((EndpointImpl) beanInstance);
}
if (beanInstance instanceof ServerFactoryBean) {
ServerFactoryBean factory = (ServerFactoryBean) beanInstance;
if (factory.getInvoker() instanceof JBossWSInvoker) {
((JBossWSInvoker) factory.getInvoker()).setTargetBean(factory.getServiceBean());
}
List<Endpoint> depEndpoints = dep.getService().getEndpoints();
if (depEndpoints != null) {
final String targetBeanName = factory.getServiceBean().getClass().getName();
for (Endpoint depEndpoint : depEndpoints) {
if (depEndpoint.getTargetBeanClass().getName().equals(targetBeanName)) {
depEndpoint.addAttachment(Object.class, factory.getServiceBean());
}
}
}
}
if (beanInstance instanceof ServiceImpl) {
ServiceImpl service = (ServiceImpl) beanInstance;
List<Endpoint> depEndpoints = dep.getService().getEndpoints();
if (depEndpoints != null) {
final Collection<org.apache.cxf.endpoint.Endpoint> eps = service.getEndpoints().values();
for (Endpoint depEp : depEndpoints) {
for (org.apache.cxf.endpoint.Endpoint ep : eps) {
if (ep.getService().getName().equals(depEp.getProperty(Message.WSDL_SERVICE)) && ep.getEndpointInfo().getName().equals(depEp.getProperty(Message.WSDL_PORT)) && ep.getEndpointInfo().getAddress().equals(depEp.getAddress())) {
depEp.addAttachment(org.apache.cxf.endpoint.Endpoint.class, ep);
}
}
}
}
}
if (beanInstance instanceof HTTPTransportFactory) {
HTTPTransportFactory factory = (HTTPTransportFactory) beanInstance;
DestinationRegistry oldRegistry = factory.getRegistry();
if (!(oldRegistry instanceof JBossWSDestinationRegistryImpl)) {
factory.setRegistry(new JBossWSDestinationRegistryImpl());
}
}
super.customize(beanInstance);
}
use of org.apache.cxf.service.ServiceImpl in project cxf by apache.
the class STSUtils method createSTSEndpoint.
// CHECKSTYLE:OFF
private static Endpoint createSTSEndpoint(Bus bus, String namespace, String transportId, String location, String soapVersion, Policy policy, QName epName, boolean sc) throws BusException, EndpointException {
// CHECKSTYLE:ON
Service service = null;
String ns = namespace + "/wsdl";
ServiceInfo si = new ServiceInfo();
QName iName = new QName(ns, sc ? "SecureConversationTokenService" : "SecurityTokenService");
si.setName(iName);
InterfaceInfo ii = new InterfaceInfo(si, iName);
OperationInfo ioi = addIssueOperation(ii, namespace, ns);
OperationInfo coi = addCancelOperation(ii, namespace, ns);
OperationInfo roi = addRenewOperation(ii, namespace, ns);
si.setInterface(ii);
service = new ServiceImpl(si);
BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
BindingFactory bindingFactory = bfm.getBindingFactory(soapVersion);
BindingInfo bi = bindingFactory.createBindingInfo(service, soapVersion, null);
si.addBinding(bi);
if (transportId == null) {
ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
ConduitInitiator ci = cim.getConduitInitiatorForUri(location);
transportId = ci.getTransportIds().get(0);
}
EndpointInfo ei = new EndpointInfo(si, transportId);
ei.setBinding(bi);
ei.setName(epName == null ? iName : epName);
ei.setAddress(location);
si.addEndpoint(ei);
if (policy != null) {
ei.addExtensor(policy);
}
BindingOperationInfo boi = bi.getOperation(ioi);
SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
if (soi == null) {
soi = new SoapOperationInfo();
boi.addExtensor(soi);
}
soi.setAction(namespace + (sc ? "/RST/SCT" : "/RST/Issue"));
boi = bi.getOperation(coi);
soi = boi.getExtensor(SoapOperationInfo.class);
if (soi == null) {
soi = new SoapOperationInfo();
boi.addExtensor(soi);
}
soi.setAction(namespace + (sc ? "/RST/SCT/Cancel" : "/RST/Cancel"));
boi = bi.getOperation(roi);
soi = boi.getExtensor(SoapOperationInfo.class);
if (soi == null) {
soi = new SoapOperationInfo();
boi.addExtensor(soi);
}
soi.setAction(namespace + (sc ? "/RST/SCT/Renew" : "/RST/Renew"));
service.setDataBinding(new SourceDataBinding());
return new EndpointImpl(bus, service, ei);
}
use of org.apache.cxf.service.ServiceImpl in project cxf by apache.
the class WSDLServiceFactory method create.
public Service create() {
List<ServiceInfo> services;
if (serviceName == null) {
try {
WSDLServiceBuilder builder = new WSDLServiceBuilder(getBus());
builder.setAllowElementRefs(allowRefs);
services = builder.buildServices(definition);
} catch (XmlSchemaException ex) {
throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
}
if (services.isEmpty()) {
throw new ServiceConstructionException(new Message("NO_SERVICE_EXC", LOG));
}
// @@TODO - this isn't good, need to return all the services
serviceName = services.get(0).getName();
// get all the service info's that match that first one.
Iterator<ServiceInfo> it = services.iterator();
while (it.hasNext()) {
if (!it.next().getName().equals(serviceName)) {
it.remove();
}
}
} else {
javax.wsdl.Service wsdlService = definition.getService(serviceName);
if (wsdlService == null) {
if ((!PartialWSDLProcessor.isServiceExisted(definition, serviceName)) && (!PartialWSDLProcessor.isBindingExisted(definition, serviceName)) && (PartialWSDLProcessor.isPortTypeExisted(definition, serviceName))) {
try {
Map<QName, PortType> portTypes = CastUtils.cast(definition.getAllPortTypes());
String existPortName = null;
PortType portType = null;
for (Map.Entry<QName, PortType> entry : portTypes.entrySet()) {
existPortName = entry.getKey().getLocalPart();
if (serviceName.getLocalPart().contains(existPortName)) {
portType = entry.getValue();
break;
}
}
WSDLFactory factory = WSDLFactory.newInstance();
ExtensionRegistry extReg = factory.newPopulatedExtensionRegistry();
Binding binding = PartialWSDLProcessor.doAppendBinding(definition, existPortName, portType, extReg);
definition.addBinding(binding);
wsdlService = PartialWSDLProcessor.doAppendService(definition, existPortName, extReg, binding);
definition.addService(wsdlService);
} catch (Exception e) {
throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
}
} else {
throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
}
}
try {
services = new WSDLServiceBuilder(getBus()).buildServices(definition, wsdlService, endpointName);
if (services.isEmpty()) {
throw new ServiceConstructionException(new Message("NO_SUCH_ENDPOINT_EXC", LOG, endpointName));
}
} catch (XmlSchemaException ex) {
throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
}
}
ServiceImpl service = new ServiceImpl(services);
setService(service);
return service;
}
Aggregations