ClassLoader classLoader = ((XBeanServiceUnit) getServiceUnit()).getConfigurationClassLoader();
Class cl = Class.forName(pojoClass, true, classLoader);
pojo = cl.newInstance();
}
// Create factory
XFire xfire = getXFire();
ObjectServiceFactory factory = ServiceFactoryHelper.findServiceFactory(xfire, pojo.getClass(), annotations, typeMapping);
Class serviceClass = pojo.getClass();
if (serviceInterface != null) {
serviceClass = Class.forName(serviceInterface);
}
this.definition = loadDefinition();
if (definition != null) {
if (definition.getServices().size() != 1) {
throw new InvalidParameterException("The deployed wsdl defines more than one service");
}
javax.wsdl.Service wsdlSvc = (javax.wsdl.Service) definition.getServices().values().iterator().next();
if (service == null) {
service = wsdlSvc.getQName();
} else if (!service.equals(wsdlSvc.getQName())) {
throw new InvalidParameterException("The name of the Service defined by the deployed wsdl does not match the service name of the jbi endpoint");
}
if (wsdlSvc.getPorts().size() != 1) {
throw new InvalidParameterException("The Service defined in the deployed wsdl must define exactly one Port");
}
Port wsdlPort = (Port) wsdlSvc.getPorts().values().iterator().next();
if (endpoint == null) {
endpoint = wsdlPort.getName();
} else if (!endpoint.equals(wsdlPort.getName())) {
throw new InvalidParameterException("The name of the Port defined by the deployed wsdl does not match the endpoint name of the jbi endpoint");
}
Binding wsdlBinding = wsdlPort.getBinding();
if (wsdlBinding == null) {
throw new InvalidParameterException("The Port defined in the deployed wsdl does not have any binding");
}
PortType wsdlPortType = wsdlBinding.getPortType();
if (wsdlPortType == null) {
throw new InvalidParameterException("The Binding defined in the deployed wsdl does not have reference a PortType");
}
if (interfaceName == null) {
interfaceName = wsdlPortType.getQName();
} else if (!interfaceName.equals(wsdlPortType.getQName())) {
throw new InvalidParameterException("The name of the PortType defined by the deployed wsdl does not match the interface name of the jbi endpoint");
}
// Create the DOM document
description = WSDLFactory.newInstance().newWSDLWriter().getDocument(definition);
}
String svcLocalName = (service != null) ? service.getLocalPart() : null;
String svcNamespace;
if (interfaceName != null) {
svcNamespace = interfaceName.getNamespaceURI();
} else if (service != null) {
svcNamespace = service.getNamespaceURI();
} else {
svcNamespace = null;
}
Map props = new HashMap();
props.put(ObjectServiceFactory.PORT_TYPE, interfaceName);
if (style != null) {
props.put(ObjectServiceFactory.STYLE, style);
}
props.put(ObjectServiceFactory.USE, SoapConstants.USE_LITERAL);
if (serviceInterface != null) {
props.put("annotations.allow.interface", "true");
}
xfireService = factory.create(serviceClass, svcLocalName, svcNamespace, props);
xfireService.setInvoker(new BeanInvoker(getPojo()));
xfireService.setFaultSerializer(new JbiFaultSerializer(getConfiguration()));
xfireService.setProperty(SoapConstants.MTOM_ENABLED, Boolean.toString(mtomEnabled));
xfire.getServiceRegistry().register(xfireService);
// If the wsdl has not been provided,
// generate one
if (this.description == null) {
this.description = generateWsdl();