Search in sources :

Example 1 with IServiceProvider

use of org.jowidgets.service.api.IServiceProvider in project jo-client-platform by jo-source.

the class RemotingServiceInitializer method initialize.

/**
 * Initializes the remoting services.
 * This method blocks until the remoting services are initialized, the invocation was canceled or the timeout elapsed
 *
 * @param timeout The timeout
 * @param cancelCallback Can be used to cancel the initialization
 *
 * @return True if the remoting services was initialized, false otherwise (e.g. timeout occured)
 */
public synchronized boolean initialize(final long timeout, final ICancelCallback cancelCallback) {
    if (!initialized.get()) {
        final IServiceProvider serviceProvider;
        try {
            serviceProvider = RemotingServiceProviderFactory.create(brokerId, timeout, cancelCallback);
            ServiceProvider.registerServiceProviderHolder(new DefaultServiceProviderHolder(serviceProvider));
            initialized.set(true);
        } catch (final RemotingTimeoutException e) {
        // do nothing, because this method returns false then
        } catch (final ServiceCanceledException e) {
        // do nothing, because this method returns false then
        }
    }
    return initialized.get();
}
Also used : DefaultServiceProviderHolder(org.jowidgets.service.tools.DefaultServiceProviderHolder) IServiceProvider(org.jowidgets.service.api.IServiceProvider) ServiceCanceledException(org.jowidgets.cap.common.api.exception.ServiceCanceledException)

Aggregations

ServiceCanceledException (org.jowidgets.cap.common.api.exception.ServiceCanceledException)1 IServiceProvider (org.jowidgets.service.api.IServiceProvider)1 DefaultServiceProviderHolder (org.jowidgets.service.tools.DefaultServiceProviderHolder)1