Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [dsdp-tm-dev] Programmatically making new connection in RSE view

Vrushali,
 
please look at the RSE Unittests. They do what you want, feel free to take the code and modify (it's under EPL).
 
The NPE could be because RSE SystemRegistry is not yet initialized. You should likely wait:
   RSECorePlugin.waitForInitCompletion()
 
For the Password thing, see
   RSEBaseConnectionTestCase.getRemoteSystemConnection()
 
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.tm.rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/core/connection/RSEBaseConnectionTestCase.java?root=DSDP_Project&view=markup
 
I strongly recommend that you get the org.eclipse.rse.tests plugin from CVS to look at it for more coding examples.
 
CVSROOT = :pserver:dev.eclipse.org/cvsroot/dsdp
Repository= org.eclipse.tm.rse/tests/org.eclipse.rse.tests
 
Cheers,
--
Martin Oberhuber, Senior Member of Technical Staff, Wind River
Target Management Project Lead, DSDP PMC Member
http://www.eclipse.org/dsdp/tm
 
 


From: dsdp-tm-dev-bounces@xxxxxxxxxxx [mailto:dsdp-tm-dev-bounces@xxxxxxxxxxx] On Behalf Of vrushali babar
Sent: Monday, December 01, 2008 11:19 AM
To: hari babu; dsdp-tm
Subject: Re: [dsdp-tm-dev] Programmatically making new connection in RSE view

 
Hi Hari,
 
It Worked though Partially.
When I run the code for the 1st time, I get following errors
 
java.lang.NullPointerException
at org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.createNode(RSEDOMExporter.java:395)
at org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.createNode(RSEDOMExporter.java:357)
at org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.createNode(RSEDOMExporter.java:321)
at org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.populateRSEDOM(RSEDOMExporter.java:138)
at org.eclipse.rse.internal.persistence.dom.RSEDOMExporter.createRSEDOM(RSEDOMExporter.java:88)
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.save(RSEPersistenceManager.java:425)BuildServerConnection
at org.eclipse.rse.internal.persistence.RSEPersistenceManager.commitProfile(RSEPersistenceManager.java:139)
at org.eclipse.rse.internal.core.model.SystemProfile.commit(SystemProfile.java:216)
at org.eclipse.rse.core.model.Host.commit(Host.java:507)
at org.eclipse.rse.ui.internal.model.SystemRegistry.createHost(SystemRegistry.java:1778)
at org.eclipse.rse.ui.internal.model.SystemRegistry.createHost(SystemRegistry.java:1701)
at org.eclipse.rse.ui.internal.model.SystemRegistry.createHost(SystemRegistry.java:2022)
at org.eclipse.rse.ui.internal.model.SystemRegistry.createHost(SystemRegistry.java:1993)
at org.eclipse.rse.ui.internal.model.SystemRegistry.createHost(SystemRegistry.java:2035)
at org.eclipse.communicationManager.handlers.BuildServerConnection.execute(BuildServerConnection.java:59)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:252)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:475)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:470)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:165)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247)
at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:630)
at org.eclipse.ui.menus.CommandContributionItem.access$10(CommandContributionItem.java:616)
at org.eclipse.ui.menus.CommandContributionItem$4.handleEvent(CommandContributionItem.java:606)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:982)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3760)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3371)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2392)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2222)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:469)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:362)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:564)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
at org.eclipse.equinox.launcher.Main.main(Main.java:1227)

 
But when i run it the next time, it gets created without prompting any error.
another doubt here..
i have already connected to a remote server by using RSE's context Menu option (new connection)where i get prompted for credentials.
These are going to be the same credentials that i'll use to make further connection to different servers. 
i can use the userId but no password from earlier connection so is there any way to
use the same password and avoid prompting dialog box for the password that user had already once entered (though for different server, password is same)?
 
Thanks a lot,
Vrushali.

 
--- On Sat, 11/29/08, hari babu <haribabu2006@xxxxxxxxx> wrote:
From: hari babu <haribabu2006@xxxxxxxxx>
Subject: Re: [dsdp-tm-dev] Programmatically making new connection in RSE view
To: vrush_com@xxxxxxxxx, "Target Management developer discussions" <dsdp-tm-dev@xxxxxxxxxxx>
Date: Saturday, November 29, 2008, 10:09 AM

Hi vrushali,
 
try the below chunk, this will create a new connection for you.
 
 
ISystemRegistry sysReg = RSECorePlugin.getDefault()
.getSystemRegistry();
if (sysReg != null) {
IRSECoreRegistry coreReg = RSECorePlugin.getDefault()
.getCoreRegistry();
if (coreReg != null) {
IRSESystemType telnetType = coreReg
.getSystemTypeById("org.eclipse.rse.systemtype.telnet");
if (telnetType != null) {
String userId = "newUser";
String connectionName = "112.134.700.7";
try {
IHost host = null;
host = sysReg.createHost(telnetType, userId,
connectionName, "new host");
ISubSystem[] subSystems = host.getSubSystems();
int i;
for (i = 0; subSystems != null && i < subSystems.length; i++) {
if (subSystems[i] instanceof IShellServiceSubSystem)
break;
}
final ISubSystem subSystem = subSystems[i];
subSystem.getConnectorService().setUserId(userId);
subSystem.getConnectorService().setPassword(userId, userId, false,
false);
IPropertySet propSet = subSystem.getConnectorService()
.getPropertySet("Telnet Settings");
IProperty commandPrompt = propSet.getProperty("Command.Prompt");
commandPrompt.setValue("#");
Map properties = new HashMap();
IConnectorService service = subSystem.getConnectorService();
properties.put("Command.Prompt", commandPrompt);
service.getPropertySet("Telnet Settings").setProperties(properties);
try {
subSystem.getConnectorService().connect(
new NullProgressMonitor());
} catch (Exception e1) {
e1.printStackTrace();
}
IHostShell hostShell = null;
IShellService shellService = ((IShellServiceSubSystem) subSystem)
.getShellService();
String env[] = new String[0];
if (shellService != null) {
try {
hostShell = shellService.launchShell("", env,
new NullProgressMonitor());
} catch (Exception e) {
e.printStackTrace();
}
}
if (hostShell != null) {
hostShell.writeToShell("eclipse-native-editor -p 3000");
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
}
 
} catch (Exception e1) {
e1.printStackTrace();
}
}


On Fri, Nov 28, 2008 at 11:00 PM, vrushali babar <vrush_com@xxxxxxxxx> wrote:
Hi,
 
I'm extending RSE APIs to develope an Eclipse plugin. is it possible to make new connections programmatically using this API's and have display of it in RSE view?
The option, New Connection, is available on the RSE's context menu; but here i want to provide a new connection just over a click without user having any knowledge of IP address. I'll be fetching the appropriate IP, making the connection and displaying it in RSE view.
 
So is there any way to connect to remote server's programmatically using RSE APIs?
 
Thanks in advance.
 
-Vrushali


_______________________________________________
dsdp-tm-dev mailing list
dsdp-tm-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dsdp-tm-dev




Back to the top