Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 284086 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/runtime/registry/rosgi/RosgiRegistryHost.java (+5 lines)
Lines 10-15 Link Here
10
import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
10
import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
11
import org.eclipse.pde.runtime.core.model.BackendChangeListener;
11
import org.eclipse.pde.runtime.core.model.BackendChangeListener;
12
import org.eclipse.pde.runtime.core.model.LocalRegistryBackend;
12
import org.eclipse.pde.runtime.core.model.LocalRegistryBackend;
13
import org.eclipse.pde.runtime.core.model.RegistryBackend;
13
import org.eclipse.pde.runtime.rosgi.rs.Activator;
14
import org.eclipse.pde.runtime.rosgi.rs.Activator;
14
import org.osgi.framework.BundleContext;
15
import org.osgi.framework.BundleContext;
15
import org.osgi.util.tracker.ServiceTracker;
16
import org.osgi.util.tracker.ServiceTracker;
Lines 118-121 Link Here
118
	public void setClientURI(String uri) {
119
	public void setClientURI(String uri) {
119
		this.clientURI = uri;
120
		this.clientURI = uri;
120
	}
121
	}
122
	
123
	public RegistryBackend getRegistryBackend(){
124
		return backend;
125
	}
121
}
126
}
(-)src/org/eclipse/pde/internal/runtime/registry/rosgi/IRosgiRegistryHost.java (+4 lines)
Lines 1-5 Link Here
1
package org.eclipse.pde.internal.runtime.registry.rosgi;
1
package org.eclipse.pde.internal.runtime.registry.rosgi;
2
2
3
import org.eclipse.pde.runtime.core.model.RegistryBackend;
4
3
public interface IRosgiRegistryHost {
5
public interface IRosgiRegistryHost {
4
	
6
	
5
	public boolean connectRemoteBackendChangeListener();
7
	public boolean connectRemoteBackendChangeListener();
Lines 21-24 Link Here
21
	public void disconnect();
23
	public void disconnect();
22
	
24
	
23
	public void setClientURI(String uri);
25
	public void setClientURI(String uri);
26
	
27
	public RegistryBackend getRegistryBackend();
24
}
28
}
(-)src/org/eclipse/pde/internal/runtime/registry/rosgi/RosgiRegistryBackend.java (-10 / +16 lines)
Lines 4-10 Link Here
4
4
5
import org.eclipse.core.runtime.Assert;
5
import org.eclipse.core.runtime.Assert;
6
import org.eclipse.core.runtime.IProgressMonitor;
6
import org.eclipse.core.runtime.IProgressMonitor;
7
import org.eclipse.core.runtime.content.IContentTypeManager.ISelectionPolicy;
7
import org.eclipse.core.runtime.IStatus;
8
import org.eclipse.core.runtime.Status;
8
import org.eclipse.ecf.core.IContainer;
9
import org.eclipse.ecf.core.IContainer;
9
import org.eclipse.ecf.core.IContainerManager;
10
import org.eclipse.ecf.core.IContainerManager;
10
import org.eclipse.ecf.core.identity.IDFactory;
11
import org.eclipse.ecf.core.identity.IDFactory;
Lines 20-29 Link Here
20
import org.osgi.util.tracker.ServiceTracker;
21
import org.osgi.util.tracker.ServiceTracker;
21
22
22
import ch.ethz.iks.r_osgi.RemoteOSGiService;
23
import ch.ethz.iks.r_osgi.RemoteOSGiService;
23
import ch.ethz.iks.r_osgi.Remoting;
24
24
25
public class RosgiRegistryBackend implements RegistryBackend {
25
public class RosgiRegistryBackend implements RegistryBackend {
26
	private static final String DEFAULT_PORT = "9278";
27
	private static final String DEFAULT_PROTOCOL = "r-osgi://";
26
	private static final String DEFAULT_PROTOCOL = "r-osgi://";
28
	private static final String DEFAULT_CONTAINER_TYPE = "ecf.r_osgi.peer";
27
	private static final String DEFAULT_CONTAINER_TYPE = "ecf.r_osgi.peer";
29
	
28
	
Lines 35-41 Link Here
35
	
34
	
36
	private String serverURI;
35
	private String serverURI;
37
	
36
	
37
	private String status = "not connected";
38
	
38
	public boolean connect(IProgressMonitor monitor) {
39
	public boolean connect(IProgressMonitor monitor) {
40
		status = "connecting with " + serverURI;
39
		try {
41
		try {
40
			IContainerManager containerManager = getContainerManagerService(); 
42
			IContainerManager containerManager = getContainerManagerService(); 
41
			container = containerManager.getContainerFactory().createContainer(DEFAULT_CONTAINER_TYPE);
43
			container = containerManager.getContainerFactory().createContainer(DEFAULT_CONTAINER_TYPE);
Lines 65-76 Link Here
65
			}
67
			}
66
			
68
			
67
			if (remoteRosgiHost.connectRemoteBackendChangeListener() == false) {
69
			if (remoteRosgiHost.connectRemoteBackendChangeListener() == false) {
68
				throw new Exception("Unable to connect with server");
70
				throw new Exception("Unable to connect with a server");
69
			}
71
			}
72
			status = "connected with " + serverURI;
70
			return true;
73
			return true;
71
74
72
		} catch (Exception e) {
75
		} catch (Exception e) {
76
			Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
73
			disconnect();
77
			disconnect();
78
			status = "cannot connect with " + serverURI;
74
			return false;
79
			return false;
75
		}
80
		}
76
	}
81
	}
Lines 124-140 Link Here
124
			container.disconnect();
129
			container.disconnect();
125
			container = null;
130
			container = null;
126
		}
131
		}
132
		status = "disconnected";
127
	}
133
	}
128
134
129
	private boolean registerBackendListener() {
135
	private boolean registerBackendListener() {
130
		IRemoteServiceContainerAdapter containerAdapter = 
136
		IRemoteServiceContainerAdapter containerAdapter = 
131
			(IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class); 
137
			(IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class); 	
132
		
133
		remoteBackendChangeListenerService = containerAdapter.registerRemoteService(
138
		remoteBackendChangeListenerService = containerAdapter.registerRemoteService(
134
				new String[] { BackendChangeListener.class.getName() }, backendChangeListener, null);
139
				new String[] { BackendChangeListener.class.getName() }, backendChangeListener, null);		
135
		
136
		System.out.println("BackendChangeListener RemoteService registered");
137
		
138
		return true;
140
		return true;
139
	}
141
	}
140
	
142
	
Lines 150-153 Link Here
150
	public void setURI(String uri) {
152
	public void setURI(String uri) {
151
		this.serverURI = uri;
153
		this.serverURI = uri;
152
	}
154
	}
155
156
	public String getStatus() {
157
		return status + " - ";
158
	}
153
}
159
}
(-)src/org/eclipse/pde/runtime/rosgi/rs/Activator.java (-3 / +12 lines)
Lines 1-6 Link Here
1
package org.eclipse.pde.runtime.rosgi.rs;
1
package org.eclipse.pde.runtime.rosgi.rs;
2
2
3
import org.eclipse.core.runtime.IStatus;
3
import org.eclipse.core.runtime.Plugin;
4
import org.eclipse.core.runtime.Plugin;
5
import org.eclipse.core.runtime.Status;
4
import org.eclipse.ecf.core.ContainerCreateException;
6
import org.eclipse.ecf.core.ContainerCreateException;
5
import org.eclipse.ecf.core.IContainer;
7
import org.eclipse.ecf.core.IContainer;
6
import org.eclipse.ecf.core.IContainerManager;
8
import org.eclipse.ecf.core.IContainerManager;
Lines 9-16 Link Here
9
import org.eclipse.pde.internal.runtime.registry.rosgi.IRosgiRegistryHost;
11
import org.eclipse.pde.internal.runtime.registry.rosgi.IRosgiRegistryHost;
10
import org.eclipse.pde.internal.runtime.registry.rosgi.RosgiRegistryHost;
12
import org.eclipse.pde.internal.runtime.registry.rosgi.RosgiRegistryHost;
11
import org.osgi.framework.BundleContext;
13
import org.osgi.framework.BundleContext;
14
import org.osgi.framework.ServiceReference;
12
import org.osgi.util.tracker.ServiceTracker;
15
import org.osgi.util.tracker.ServiceTracker;
13
16
17
import ch.ethz.iks.r_osgi.RemoteOSGiService;
18
14
public class Activator extends Plugin {
19
public class Activator extends Plugin {
15
20
16
	private RosgiRegistryHost host;
21
	private RosgiRegistryHost host;
Lines 38-52 Link Here
38
		try {
43
		try {
39
			container = containerManager.getContainerFactory().createContainer("ecf.r_osgi.peer");
44
			container = containerManager.getContainerFactory().createContainer("ecf.r_osgi.peer");
40
		} catch (ContainerCreateException e) {
45
		} catch (ContainerCreateException e) {
41
			// TODO Auto-generated catch block
46
			getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e));
42
			e.printStackTrace();
43
		}
47
		}
44
		IRemoteServiceContainerAdapter containerAdapter = (IRemoteServiceContainerAdapter) container
48
		IRemoteServiceContainerAdapter containerAdapter = (IRemoteServiceContainerAdapter) container
45
				.getAdapter(IRemoteServiceContainerAdapter.class); 
49
				.getAdapter(IRemoteServiceContainerAdapter.class); 
46
		serviceRegistration = containerAdapter.registerRemoteService(
50
		serviceRegistration = containerAdapter.registerRemoteService(
47
				new String[] { IRosgiRegistryHost.class.getName() }, host, null); 
51
				new String[] { IRosgiRegistryHost.class.getName() }, host, null); 
48
		
52
		
49
		System.out.println("IRosgiRegistryHost RemoteService registered");
53
		ServiceReference rosgiReference = Activator.getDefault().getBundleContext().getServiceReference("ch.ethz.iks.r_osgi.RemoteOSGiService");
54
		RemoteOSGiService rosgi = (RemoteOSGiService) Activator.getDefault().getBundleContext().getService(rosgiReference);
55
		getLog().log(new Status(IStatus.INFO, PLUGIN_ID, "org.eclipse.pde.runtime.core is listening on r-osgi protocol, port " + rosgi.getListeningPort("r-osgi")));
50
		return true;
56
		return true;
51
	}
57
	}
52
	
58
	
Lines 88-91 Link Here
88
		return container;
94
		return container;
89
	}
95
	}
90
96
97
	public IRosgiRegistryHost getHost(){
98
		return host;
99
	}
91
}
100
}
(-)src/org/eclipse/pde/runtime/core/model/RegistryBackend.java (+2 lines)
Lines 37-40 Link Here
37
37
38
	public void setURI(String uri);
38
	public void setURI(String uri);
39
39
40
	public String getStatus();
41
40
}
42
}
(-)src/org/eclipse/pde/runtime/core/model/RegistryModel.java (+4 lines)
Lines 196-201 Link Here
196
		return this.backendListener;
196
		return this.backendListener;
197
	}
197
	}
198
198
199
	public String getBackendStatus() {
200
		return backend.getStatus();
201
	}
202
199
	protected void addFragment(Bundle fragment) {
203
	protected void addFragment(Bundle fragment) {
200
		Set hostFragments = (Set) fragments.get(fragment.getFragmentHost());
204
		Set hostFragments = (Set) fragments.get(fragment.getFragmentHost());
201
		if (hostFragments == null) {
205
		if (hostFragments == null) {
(-)src/org/eclipse/pde/runtime/core/model/LocalRegistryBackend.java (+4 lines)
Lines 510-513 Link Here
510
	public void setURI(String uri) {
510
	public void setURI(String uri) {
511
		//in this backend it does nothing
511
		//in this backend it does nothing
512
	}
512
	}
513
514
	public String getStatus() {
515
		return ""; //$NON-NLS-1$
516
	}
513
}
517
}
(-)src/org/eclipse/pde/internal/runtime/pderuntimeresources.properties (-1 / +1 lines)
Lines 14-20 Link Here
14
#
14
#
15
15
16
RegistryView_connectAction_label=Connect
16
RegistryView_connectAction_label=Connect
17
RegistryView_enterURL=Enter URL:
17
RegistryView_enterURL=This dialog allows you to monitoring and managing remote OSGi application. Enter URL:
18
ActiveFormEditorSection_Active_Form_Page=Active Form Page
18
ActiveFormEditorSection_Active_Form_Page=Active Form Page
19
ActiveMenuSection_0=The active contribution item identifier:
19
ActiveMenuSection_0=The active contribution item identifier:
20
ActiveMenuSection_1=The active action set identifier:
20
ActiveMenuSection_1=The active action set identifier:
(-)src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java (-12 / +18 lines)
Lines 171-176 Link Here
171
			public IStatus run(IProgressMonitor monitor) {
171
			public IStatus run(IProgressMonitor monitor) {
172
				model.connect(monitor, true);
172
				model.connect(monitor, true);
173
				initializeModelJob = null;
173
				initializeModelJob = null;
174
				fTreeViewer.getControl().getDisplay().asyncExec(new Runnable() {
175
176
					public void run() {
177
						updateTitle();
178
					}
179
				});
174
				return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
180
				return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
175
			}
181
			}
176
		};
182
		};
Lines 369-386 Link Here
369
	private void makeActions() {
375
	private void makeActions() {
370
		fConnectAction = new Action(PDERuntimeMessages.RegistryView_connectAction_label) {
376
		fConnectAction = new Action(PDERuntimeMessages.RegistryView_connectAction_label) {
371
			public void run() {
377
			public void run() {
372
				InputDialog cd = new InputDialog(Display.getCurrent().getActiveShell(), PDERuntimeMessages.RegistryView_connectAction_label, PDERuntimeMessages.RegistryView_enterURL, new String(), new IInputValidator() {
378
				InputDialog cd = new InputDialog(Display.getCurrent().getActiveShell(), PDERuntimeMessages.RegistryView_connectAction_label, PDERuntimeMessages.RegistryView_enterURL, "r-osgi://localhost:9278", new IInputValidator() { //$NON-NLS-1$
373
379
374
					public String isValid(String url) {
380
							public String isValid(String url) {
375
						try {
381
								try {
376
							// check if it's possible to instantiate given url
382
									// check if it's possible to instantiate given url
377
							new URI(url);
383
									new URI(url);
378
						} catch (URISyntaxException e) {
384
								} catch (URISyntaxException e) {
379
							return e.getMessage();
385
									return e.getMessage();
380
						}
386
								}
381
						return null;
387
								return null;
382
					}
388
							}
383
				});
389
						});
384
				if (cd.open() == Window.OK) {
390
				if (cd.open() == Window.OK) {
385
					model.disconnect();
391
					model.disconnect();
386
					initializeModel(cd.getValue());
392
					initializeModel(cd.getValue());
Lines 534-540 Link Here
534
	}
540
	}
535
541
536
	public void updateTitle() {
542
	public void updateTitle() {
537
		setContentDescription(getTitleSummary());
543
		setContentDescription(model.getBackendStatus() + getTitleSummary());
538
	}
544
	}
539
545
540
	protected Tree getUndisposedTree() {
546
	protected Tree getUndisposedTree() {

Return to bug 284086