1
2
3
4
5
6
7
8 package it.imolinfo.jbi4ejb.runtime;
9
10 import it.imolinfo.jbi4ejb.Logger;
11 import it.imolinfo.jbi4ejb.LoggerFactory;
12 import it.imolinfo.jbi4ejb.descriptor.ProviderServiceDescriptor;
13 import it.imolinfo.jbi4ejb.jbi.xfire.EjbTransport;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.codehaus.xfire.XFire;
19 import org.codehaus.xfire.aegis.AegisBindingProvider;
20 import org.codehaus.xfire.aegis.type.TypeMapping;
21 import org.codehaus.xfire.annotations.AnnotationServiceFactory;
22 import org.codehaus.xfire.service.Service;
23 import org.codehaus.xfire.service.binding.ObjectServiceFactory;
24 import org.codehaus.xfire.soap.SoapConstants;
25
26
27
28
29
30
31 public class ProviderServiceCreator {
32
33
34 private static final Logger LOG = LoggerFactory
35 .getLogger(ProviderServiceCreator.class);
36
37
38
39
40 public ProviderServiceCreator() {}
41
42
43
44
45
46
47
48
49
50 @SuppressWarnings("unchecked")
51 public Service createJbiService(
52 ProviderServiceDescriptor serviceDescriptor, XFire xfire) {
53
54 LOG.debug("Creating xfire service: " + serviceDescriptor.getServiceName());
55
56 ObjectServiceFactory factory = new ObjectServiceFactory(xfire.getTransportManager(), null);
57
58 Map<String, Object> props = new HashMap<String, Object>();
59
60 props.put(ObjectServiceFactory.PORT_TYPE, serviceDescriptor
61 .getPortTypeName());
62 props.put(ObjectServiceFactory.STYLE, SoapConstants.STYLE_WRAPPED);
63 props.put(ObjectServiceFactory.USE, SoapConstants.USE_LITERAL);
64
65 props.put(AnnotationServiceFactory.ALLOW_INTERFACE, Boolean.TRUE);
66
67 factory.getSoap11Transports().clear();
68 factory.getSoap12Transports().clear();
69 factory.getSoap11Transports().add(EjbTransport.EJB_BINDING);
70
71 Service service = null;
72
73 service = factory.create(serviceDescriptor.getEjbProxy()
74 .getRemoteInterfaceClass(), serviceDescriptor.getServiceName()
75 .getLocalPart(), serviceDescriptor.getServiceName()
76 .getNamespaceURI(), props);
77
78
79 service.setInvoker(new ProviderServiceInvoker(serviceDescriptor));
80
81
82
83
84 AegisBindingProvider abp = (AegisBindingProvider) factory
85 .getBindingProvider();
86
87 TypeMapping typeMapping = abp.getTypeMapping(service);
88 typeMapping.register(new ByteType());
89
90
91 return service;
92 }
93
94 }