use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.
the class AbstractClientService method fireAsync.
public void fireAsync(IRemoteCall call) throws ECFException {
IRemoteCallable callable = getRegistration().lookupCallable(call);
if (callable == null)
// $NON-NLS-1$
throw new ECFException("Remote callable not found");
callAsync(call, callable);
}
use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.
the class TrivialClient method run.
public void run() {
try {
// Create instance of trivial container
IContainer container = ContainerFactory.getDefault().createContainer("ecf.container.trivial");
// Get appropriate container adapter...e.g. IChannelContainerAdapter
// IChannelContainerAdapter containerAdapter =
// (IChannelContainerAdapter)
// container.getAdapter(IChannelContainerAdapter.class);
// Connect
ID targetID = IDFactory.getDefault().createID(container.getConnectNamespace(), "myid");
container.connect(targetID, null);
} catch (ECFException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.
the class RemoteServiceAdmin method createProxy.
private Object createProxy(Bundle requestingBundle, ServiceReference serviceReference, IRemoteService remoteService, Map<String, Version> interfaceVersions) {
// Get symbolicName once for possible use below
String bundleSymbolicName = requestingBundle.getSymbolicName();
// Get String[] via OBJECTCLASS constant property
String[] serviceClassnames = (String[]) serviceReference.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
// Load as many of the serviceInterface classes as possible
Collection<Class> serviceInterfaceClasses = loadServiceInterfacesViaBundle(requestingBundle, serviceClassnames);
// load...otherwise the service can't be accessed
if (serviceInterfaceClasses.size() < 1)
throw new RuntimeException(// $NON-NLS-1$
"ProxyServiceFactory cannot load any serviceInterfaces=" + serviceInterfaceClasses + " for serviceReference=" + // $NON-NLS-1$
serviceReference + " via clientBundle=" + // $NON-NLS-1$
bundleSymbolicName);
// Now verify that the classes are of valid versions
if (!verifyServiceInterfaceVersionsForProxy(requestingBundle, serviceInterfaceClasses, interfaceVersions))
return null;
// Now create/get class loader for proxy. This will typically
// be an instance of ProxyClassLoader
ClassLoader cl = getProxyClassLoader(requestingBundle);
try {
return remoteService.getProxy(cl, (Class[]) serviceInterfaceClasses.toArray(new Class[serviceInterfaceClasses.size()]));
} catch (ECFException e) {
throw new ServiceException(// $NON-NLS-1$
"ProxyServiceFactory cannot create proxy for clientBundle=" + bundleSymbolicName + // $NON-NLS-1$
" from serviceReference=" + serviceReference, e);
}
}
use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.
the class ResourcesShareHandler method run.
private void run(Shell shell, final ResourcesShare share, final String projectName) {
final boolean[] ret = { false };
try {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
dialog.open();
dialog.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
monitor.beginTask("Sharing " + projectName, IProgressMonitor.UNKNOWN);
monitor.subTask("Sending request...");
share.startShare(getRosterEntry().getRoster().getUser().getID(), getRosterEntry().getUser().getID(), projectName);
monitor.subTask("Waiting for acknowledgement...");
while (true) {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
Thread.sleep(50);
Boolean response = share.getResponse();
if (response != null) {
ret[0] = response.booleanValue();
return;
}
}
} catch (ECFException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
});
} catch (InvocationTargetException e) {
IStatus status = new Status(IStatus.ERROR, SyncResourcesUI.PLUGIN_ID, "Could not send share request", e.getCause());
StatusManager.getManager().handle(status);
SyncResourcesUI.log(status);
} catch (InterruptedException e) {
// operation canceled, stop sharing this project
share.stopSharing(projectName);
return;
}
if (ret[0]) {
IRosterManager manager = getRosterEntry().getRoster().getPresenceContainerAdapter().getRosterManager();
manager.addRosterListener(new RosterListener(share, projectName, getRosterEntry()));
} else {
MessageDialog.openInformation(shell, null, "Sharing request denied.");
}
}
use of org.eclipse.ecf.core.util.ECFException in project ecf by eclipse.
the class SynchronizeWithHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IRosterEntry selectedEntry = getRosterEntry();
IRoster roster = selectedEntry.getRoster();
final IUser remoteUser = roster.getUser();
final ID localId = remoteUser.getID();
final ID remoteId = selectedEntry.getUser().getID();
IContainer container = (IContainer) roster.getPresenceContainerAdapter().getAdapter(IContainer.class);
final IResource[] resources = getResources(event);
final RemoteShare share = TeamSynchronization.getShare(container.getID());
IWorkbenchPart part = HandlerUtil.getActivePart(event);
final IWorkbenchPartSite site = part == null ? null : part.getSite();
final Shell shell = HandlerUtil.getActiveShellChecked(event);
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
final boolean[] response = { true };
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (resources.length == 1) {
monitor.beginTask(NLS.bind(Messages.SynchronizeWithHandler_SynchronizeResourceTaskName, resources[0].getName()), IProgressMonitor.UNKNOWN);
} else {
monitor.beginTask(Messages.SynchronizeWithHandler_SynchronizeResourcesTaskName, IProgressMonitor.UNKNOWN);
}
try {
if (share.sendShareRequest(localId, remoteId, resources, monitor)) {
scheduleRefreshJob(share, localId, remoteId, resources, remoteUser, site);
} else {
response[0] = false;
}
} catch (ECFException e) {
throw new InvocationTargetException(e);
} catch (OperationCanceledException e) {
// operation, but check for this just in case
if (!monitor.isCanceled()) {
throw e;
}
}
}
};
try {
dialog.run(true, true, runnable);
if (!response[0]) {
MessageDialog.openInformation(shell, null, Messages.SynchronizeWithHandler_SynchronizeRequestDenial);
}
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof ECFException) {
MessageDialog.openError(shell, null, Messages.SynchronizeWithHandler_SynchronizeRequestError);
}
// $NON-NLS-1$
TeamSynchronization.log("Failed to contact remote peer", cause);
} catch (InterruptedException e) {
Thread.interrupted();
MessageDialog.openError(shell, null, Messages.SynchronizeWithHandler_SynchronizeRequestInterrupted);
// $NON-NLS-1$
TeamSynchronization.log("Synchronization request operation was interrupted", e);
}
return null;
}
Aggregations