WSTCPDelegatepublic final class WSTCPDelegate extends Object implements WSTCPAdapterRegistry, TCPMessageListener
Fields Summary |
---|
private static final Logger | logger | private final Map | fixedUrlPatternEndpoints | private final List | pathUrlPatternEndpoints | private volatile TCPAdapter | serviceChannelWSAdapter | private WSTCPAdapterRegistry | customWSRegistryCustom registry, where its possible to delegate Adapter search |
Constructors Summary |
---|
public WSTCPDelegate()
|
Methods Summary |
---|
public void | destroy()
logger.log(Level.FINE, MessagesMessages.WSTCP_1105_WSTCP_DELEGATE_DESTROY());
| public void | freeAdapters(java.lang.String contextPath, java.util.List adapters)
for(TCPAdapter adapter : adapters) {
final String urlPattern = contextPath + adapter.urlPattern;
logger.log(Level.FINE, MessagesMessages.WSTCP_1100_WSTCP_DELEGATE_DEREGISTER_ADAPTER(urlPattern));
if (fixedUrlPatternEndpoints.remove(urlPattern) == null) {
pathUrlPatternEndpoints.remove(adapter);
}
}
| private TCPAdapter | getServiceChannelWSAdapter()Returns TCPAdapter for service channel
cannot do that once in constructor because of GF startup performance
initialize it lazy
if (serviceChannelWSAdapter == null) {
registerServiceChannelWSAdapter();
}
return serviceChannelWSAdapter;
| public TCPAdapter | getTarget(com.sun.xml.ws.transport.tcp.util.WSTCPURI tcpURI)Determines which {@link TCPAdapter} serves the given request.
TCPAdapter result = null;
final String path = tcpURI.path;
if (path != null) {
result = fixedUrlPatternEndpoints.get(path);
if (result == null) {
for (TCPAdapter candidate : pathUrlPatternEndpoints) {
if (path.startsWith(candidate.getValidPath())) {
result = candidate;
break;
}
}
}
}
if (result == null && customWSRegistry != null) {
logger.log(Level.FINE, MessagesMessages.WSTCP_1102_WSTCP_DELEGATE_GOING_TO_CUSTOM_REG(tcpURI));
return customWSRegistry.getTarget(tcpURI);
}
return result;
| public void | onError(com.sun.xml.ws.transport.tcp.util.ChannelContext channelContext, com.sun.xml.ws.transport.tcp.util.WSTCPError error)Implementation of TCPMessageListener.onError
method is called if error occured during frame processing
on upper level
sendErrorResponse(channelContext, error);
| public void | onMessage(com.sun.xml.ws.transport.tcp.util.ChannelContext channelContext)Implementation of TCPMessageListener.onMessage
method is called once request message come
if (logger.isLoggable(Level.FINE)) {
final Connection connection = channelContext.getConnection();
logger.log(Level.FINE, MessagesMessages.WSTCP_1103_WSTCP_DELEGATE_ON_MESSAGE(connection.getHost(), connection.getPort(),
connection.getLocalHost(), connection.getLocalPort()));
}
try {
TCPAdapter target = null;
if (channelContext.getChannelId() > 0) {
final WSTCPURI tcpURI = channelContext.getTargetWSURI();
target = getTarget(tcpURI);
} else {
target = getServiceChannelWSAdapter();
}
if (target != null) {
target.handle(channelContext);
} else {
TCPAdapter.sendErrorResponse(channelContext,
WSTCPError.createNonCriticalError(TCPConstants.UNKNOWN_CHANNEL_ID,
MessagesMessages.WSTCP_0026_UNKNOWN_CHANNEL_ID(channelContext.getChannelId())));
}
} catch (WSTCPException e) {
final Connection connection = channelContext.getConnection();
logger.log(Level.SEVERE, MessagesMessages.WSTCP_0023_TARGET_EXEC_ERROR(connection.getHost(), connection.getPort()), e);
sendErrorResponse(channelContext, e.getError());
if (e.getError().isCritical()) {
channelContext.getConnectionSession().close();
}
} catch (JAXWSExceptionBase e) {
final Connection connection = channelContext.getConnection();
logger.log(Level.SEVERE, MessagesMessages.WSTCP_0023_TARGET_EXEC_ERROR(connection.getHost(), connection.getPort()), e);
sendErrorResponse(channelContext, WSTCPError.createNonCriticalError(TCPConstants.GENERAL_CHANNEL_ERROR,
MessagesMessages.WSTCP_0025_GENERAL_CHANNEL_ERROR(MessagesMessages.WSTCP_0004_CHECK_SERVER_LOG())));
} catch (IOException e) {
final Connection connection = channelContext.getConnection();
logger.log(Level.SEVERE, MessagesMessages.WSTCP_0023_TARGET_EXEC_ERROR(connection.getHost(), connection.getPort()), e);
throw e;
} catch (Exception e) {
final Connection connection = channelContext.getConnection();
logger.log(Level.SEVERE, MessagesMessages.WSTCP_0023_TARGET_EXEC_ERROR(connection.getHost(), connection.getPort()), e);
sendErrorResponse(channelContext, WSTCPError.createNonCriticalError(TCPConstants.GENERAL_CHANNEL_ERROR,
MessagesMessages.WSTCP_0025_GENERAL_CHANNEL_ERROR(MessagesMessages.WSTCP_0004_CHECK_SERVER_LOG())));
} finally {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, MessagesMessages.WSTCP_1104_WSTCP_DELEGATE_ON_MESSAGE_COMPLETED());
}
}
| public void | registerAdapters(java.lang.String contextPath, java.util.List adapters)
for(TCPAdapter adapter : adapters)
registerEndpointUrlPattern(contextPath, adapter);
| private void | registerEndpointUrlPattern(java.lang.String contextPath, TCPAdapter adapter)
final String urlPattern = contextPath + adapter.urlPattern;
logger.log(Level.FINE, MessagesMessages.WSTCP_1101_WSTCP_DELEGATE_REGISTER_ADAPTER(urlPattern));
if (urlPattern.endsWith("/*")) {
pathUrlPatternEndpoints.add(adapter);
} else {
if (fixedUrlPatternEndpoints.containsKey(urlPattern)) {
// Warning because of duplication
} else {
fixedUrlPatternEndpoints.put(urlPattern, adapter);
}
}
| private synchronized void | registerServiceChannelWSAdapter()
if (serviceChannelWSAdapter == null) {
WSEndpoint<ServiceChannelWSImpl> endpoint = ServiceChannelCreator.getServiceChannelEndpointInstance();
final String serviceNameLocal = endpoint.getServiceName().getLocalPart();
serviceChannelWSAdapter = new TCPServiceChannelWSAdapter(serviceNameLocal,
TCPConstants.SERVICE_CHANNEL_URL_PATTERN,
endpoint,
this);
registerEndpointUrlPattern(TCPConstants.SERVICE_CHANNEL_CONTEXT_PATH,
serviceChannelWSAdapter);
}
| private void | sendErrorResponse(com.sun.xml.ws.transport.tcp.util.ChannelContext channelContext, com.sun.xml.ws.transport.tcp.util.WSTCPError error)
try {
TCPAdapter.sendErrorResponse(channelContext, error);
} catch (Throwable e) {
logger.log(Level.SEVERE, MessagesMessages.WSTCP_0002_SERVER_ERROR_MESSAGE_SENDING_FAILED(), e);
throw new IOException(e.getClass().getName() + ": " + e.getMessage());
}
| public void | setCustomWSRegistry(WSTCPAdapterRegistry customWSRegistry)
this.customWSRegistry = customWSRegistry;
|
|