use of com.sun.xml.ws.api.server.Container in project metro-jax-ws by eclipse-ee4j.
the class DispatchImpl method invokeOneWay.
public final void invokeOneWay(T in) {
Container old = ContainerResolver.getDefault().enterContainer(owner.getContainer());
try {
if (LOGGER.isLoggable(Level.FINE)) {
dumpParam(in, "invokeOneWay(T)");
}
try {
checkNullAllowed(in, requestContext, binding, mode);
Packet request = createPacket(in);
request.setState(Packet.State.ClientRequest);
setProperties(request, false);
process(request, requestContext, this);
} catch (WebServiceException e) {
// it could be a WebServiceException or a ProtocolException
throw e;
} catch (Throwable e) {
// WebServiceException
throw new WebServiceException(e);
}
} finally {
ContainerResolver.getDefault().exitContainer(old);
}
}
use of com.sun.xml.ws.api.server.Container in project metro-jax-ws by eclipse-ee4j.
the class SDODatabindingTestBase method invmSetup.
protected WebServiceFeature[] invmSetup(final URL wsdlURL, final Class sei, final Class seb, final QName serviceName, final QName portName) {
DatabindingModeFeature dbmf = new DatabindingModeFeature("eclipselink.sdo");
Class implementorClass = seb;
boolean handlersSetInDD = false;
Container container = Container.NONE;
Map<String, SDDocumentSource> docs = new HashMap<String, SDDocumentSource>();
SDDocumentSource primaryWSDL = SDDocumentSource.create(wsdlURL);
docs.put(wsdlURL.toString(), primaryWSDL);
ExternalMetadataFeature exm = ExternalMetadataFeature.builder().setReader(new com.sun.xml.ws.model.ReflectAnnotationReader() {
public <A extends Annotation> A getAnnotation(final Class<A> annType, final Class<?> cls) {
if (WebService.class.equals(annType)) {
final WebService ws = cls.getAnnotation(WebService.class);
return (A) new jakarta.jws.WebService() {
public Class<? extends Annotation> annotationType() {
return WebService.class;
}
@Override
public String endpointInterface() {
return sei.getName();
}
@Override
public String name() {
return (ws != null) ? ws.name() : null;
}
@Override
public String portName() {
return (ws != null) ? ws.portName() : null;
}
@Override
public String serviceName() {
return (ws != null) ? ws.serviceName() : null;
}
@Override
public String targetNamespace() {
return (ws != null) ? ws.targetNamespace() : null;
}
@Override
public String wsdlLocation() {
return (ws != null) ? ws.wsdlLocation() : null;
}
};
}
return cls.getAnnotation(annType);
}
}).build();
BindingID bindingID = BindingID.parse(implementorClass);
WSBinding binding = bindingID.createBinding(dbmf, exm);
final WSEndpoint<?> endpoint = WSEndpoint.create(implementorClass, !handlersSetInDD, null, serviceName, portName, container, binding, primaryWSDL, docs.values(), XmlUtil.createEntityResolver(null), false);
ComponentFeature cf = new ComponentFeature(new com.sun.xml.ws.api.Component() {
public <S> S getSPI(Class<S> spiType) {
if (TransportTubeFactory.class.equals(spiType))
return (S) new TransportTubeFactory() {
public Tube doCreate(ClientTubeAssemblerContext context) {
return new InVmTransportTube(context.getCodec(), context.getBinding(), wsdlURL, endpoint);
}
};
return null;
}
});
WebServiceFeature[] f = { dbmf, cf };
return f;
}
use of com.sun.xml.ws.api.server.Container in project metro-jax-ws by eclipse-ee4j.
the class ProviderImpl method createW3CEndpointReference.
public W3CEndpointReference createW3CEndpointReference(String address, QName interfaceName, QName serviceName, QName portName, List<Element> metadata, String wsdlDocumentLocation, List<Element> referenceParameters, List<Element> elements, Map<QName, String> attributes) {
Container container = ContainerResolver.getInstance().getContainer();
if (address == null) {
if (serviceName == null || portName == null) {
throw new IllegalStateException(ProviderApiMessages.NULL_ADDRESS_SERVICE_ENDPOINT());
} else {
// check if it is run in a Java EE Container and if so, get address using serviceName and portName
Module module = container.getSPI(Module.class);
if (module != null) {
List<BoundEndpoint> beList = module.getBoundEndpoints();
for (BoundEndpoint be : beList) {
WSEndpoint wse = be.getEndpoint();
if (wse.getServiceName().equals(serviceName) && wse.getPortName().equals(portName)) {
try {
address = be.getAddress().toString();
} catch (WebServiceException e) {
// May be the container does n't support this
// just ignore the exception
}
break;
}
}
}
// address is still null? may be its not run in a JavaEE Container
if (address == null)
throw new IllegalStateException(ProviderApiMessages.NULL_ADDRESS());
}
}
if ((serviceName == null) && (portName != null)) {
throw new IllegalStateException(ProviderApiMessages.NULL_SERVICE());
}
// Validate Service and Port in WSDL
String wsdlTargetNamespace = null;
if (wsdlDocumentLocation != null) {
try {
EntityResolver er = XmlUtil.createDefaultCatalogResolver();
URL wsdlLoc = new URL(wsdlDocumentLocation);
WSDLModel wsdlDoc = RuntimeWSDLParser.parse(wsdlLoc, new StreamSource(wsdlLoc.toExternalForm()), er, true, container, ServiceFinder.find(WSDLParserExtension.class).toArray());
if (serviceName != null) {
WSDLService wsdlService = wsdlDoc.getService(serviceName);
if (wsdlService == null)
throw new IllegalStateException(ProviderApiMessages.NOTFOUND_SERVICE_IN_WSDL(serviceName, wsdlDocumentLocation));
if (portName != null) {
WSDLPort wsdlPort = wsdlService.get(portName);
if (wsdlPort == null)
throw new IllegalStateException(ProviderApiMessages.NOTFOUND_PORT_IN_WSDL(portName, serviceName, wsdlDocumentLocation));
}
wsdlTargetNamespace = serviceName.getNamespaceURI();
} else {
QName firstService = wsdlDoc.getFirstServiceName();
wsdlTargetNamespace = firstService.getNamespaceURI();
}
} catch (Exception e) {
throw new IllegalStateException(ProviderApiMessages.ERROR_WSDL(wsdlDocumentLocation), e);
}
}
// wcf3.0/3.5 rejected empty metadata element.
if (metadata != null && metadata.size() == 0) {
metadata = null;
}
return new WSEndpointReference(AddressingVersion.fromSpecClass(W3CEndpointReference.class), address, serviceName, portName, interfaceName, metadata, wsdlDocumentLocation, wsdlTargetNamespace, referenceParameters, elements, attributes).toSpec(W3CEndpointReference.class);
}
use of com.sun.xml.ws.api.server.Container in project metro-jax-ws by eclipse-ee4j.
the class Fiber method run.
/**
* DO NOT CALL THIS METHOD. This is an implementation detail
* of {@link Fiber}.
*/
@Deprecated
@Override
public void run() {
Container old = ContainerResolver.getDefault().enterContainer(owner.getContainer());
try {
assert !synchronous;
// doRun returns true to indicate an early exit from fiber processing
if (!doRun()) {
if (startedSync && suspendedCount == 0 && (next != null || contsSize > 0)) {
// We bailed out of running this fiber we started as sync, and now
// want to finish running it async
startedSync = false;
// Start back up as an async fiber
dumpFiberContext("restarting (async) after startSync");
owner.addRunnable(this);
} else {
completionCheck();
}
}
} finally {
ContainerResolver.getDefault().exitContainer(old);
}
}
use of com.sun.xml.ws.api.server.Container in project metro-jax-ws by eclipse-ee4j.
the class TubelineAssemblerFactoryImplTest method testDispatch.
/**
* Execute a sequence that corresponds to:
* <pre>
* Service.createService(null, serviceName);
* Service.addPort(portName, bindingId, address);
* </pre>
*/
private Tube testDispatch(String configFileName) throws PolicyException {
final URL wsdlLocation = null;
final QName serviceName = new QName(NAMESPACE, "Service1Service");
// Corresponds to Service.createService(wsdlLocation, serviceName)
final WSServiceDelegate serviceDelegate = new WSServiceDelegate(wsdlLocation, serviceName, Service.class);
final QName portName = new QName(NAMESPACE, "Service1Port");
final BindingID bindingId = BindingID.SOAP11_HTTP;
// Corresponds to Service.addPort(portName, bindingId, address)
serviceDelegate.addPort(portName, bindingId.toString(), ADDRESS_URL.toString());
final EndpointAddress address = new EndpointAddress(ADDRESS_URL);
final WSDLPort port = null;
final WSPortInfo portInfo = serviceDelegate.safeGetPort(portName);
final WSBinding binding = bindingId.createBinding(new AddressingFeature(true));
final Container container = MockupMetroConfigLoader.createMockupContainer("tubes-config/" + configFileName);
WSBindingProvider wsbp = new WSBindingProvider() {
public void setOutboundHeaders(List<Header> headers) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setOutboundHeaders(Header... headers) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setOutboundHeaders(Object... headers) {
throw new UnsupportedOperationException("Not supported yet.");
}
public List<Header> getInboundHeaders() {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setAddress(String address) {
throw new UnsupportedOperationException("Not supported yet.");
}
public WSEndpointReference getWSEndpointReference() {
throw new UnsupportedOperationException("Not supported yet.");
}
public WSPortInfo getPortInfo() {
return portInfo;
}
public Map<String, Object> getRequestContext() {
throw new UnsupportedOperationException("Not supported yet.");
}
public Map<String, Object> getResponseContext() {
throw new UnsupportedOperationException("Not supported yet.");
}
public Binding getBinding() {
return binding;
}
public EndpointReference getEndpointReference() {
throw new UnsupportedOperationException("Not supported yet.");
}
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void close() throws IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
public ManagedObjectManager getManagedObjectManager() {
return null;
}
public Set<Component> getComponents() {
throw new UnsupportedOperationException("Not supported yet.");
}
public <S> S getSPI(Class<S> type) {
throw new UnsupportedOperationException("Not supported yet.");
}
};
final ClientTubeAssemblerContext context = new ClientTubeAssemblerContext(address, port, wsbp, binding, container, ((BindingImpl) binding).createCodec(), null, null);
return getAssembler(bindingId).createClient(context);
}
Aggregations