1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 241985

Made ServiceFactory accept a variable number of arguments to allow for different constructor signatures for services.
This commit is contained in:
Marc Khouzam 2008-07-29 19:55:29 +00:00
parent 475a55a1e4
commit d6faf244f9
5 changed files with 31 additions and 28 deletions

View file

@ -16,7 +16,7 @@ import org.eclipse.dd.dsf.service.DsfSession;
public abstract class AbstractDsfDebugServicesFactory implements IDsfDebugServicesFactory {
@SuppressWarnings("unchecked")
public <V> V createService(DsfSession session, Class<V> clazz) {
public <V> V createService(Class<V> clazz, DsfSession session, Object ... optionalArguments) {
if (IBreakpoints.class.isAssignableFrom(clazz)) {
return (V)createBreakpointService(session);
} else if (ICommandControl.class.isAssignableFrom(clazz)) {

View file

@ -17,5 +17,5 @@ import org.eclipse.dd.dsf.service.DsfSession;
* to easily have different service implementation for different backends.
*/
public interface IDsfDebugServicesFactory {
public <V> V createService(DsfSession session, Class<V> clazz);
<V> V createService(Class<V> clazz, DsfSession session, Object ... optionalArguments);
}

View file

@ -40,38 +40,37 @@ public class ServicesLaunchSequence extends Sequence {
//
// Create the connection.
//
fCommandControl = fLaunch.getServiceFactory().createService(fSession, GDBControl.class);
fCommandControl.initData(fLaunch.getLaunchConfiguration());
fCommandControl = fLaunch.getServiceFactory().createService(GDBControl.class, fSession, fLaunch.getLaunchConfiguration());
fCommandControl.initialize(requestMonitor);
}
},
new Step() { @Override
public void execute(RequestMonitor requestMonitor) {
fLaunch.getServiceFactory().createService(fSession, IRunControl.class).initialize(requestMonitor);
fLaunch.getServiceFactory().createService(IRunControl.class, fSession).initialize(requestMonitor);
}},
new Step() { @Override
public void execute(RequestMonitor requestMonitor) {
fLaunch.getServiceFactory().createService(fSession, IProcesses.class).initialize(requestMonitor);
fLaunch.getServiceFactory().createService(IProcesses.class, fSession).initialize(requestMonitor);
}},
new Step() { @Override
public void execute(RequestMonitor requestMonitor) {
fLaunch.getServiceFactory().createService(fSession, IMemory.class).initialize(requestMonitor);
fLaunch.getServiceFactory().createService(IMemory.class, fSession).initialize(requestMonitor);
}},
new Step() { @Override
public void execute(RequestMonitor requestMonitor) {
fLaunch.getServiceFactory().createService(fSession, IModules.class).initialize(requestMonitor);
fLaunch.getServiceFactory().createService(IModules.class, fSession).initialize(requestMonitor);
}},
new Step() { @Override
public void execute(RequestMonitor requestMonitor) {
fLaunch.getServiceFactory().createService(fSession, IStack.class).initialize(requestMonitor);
fLaunch.getServiceFactory().createService(IStack.class, fSession).initialize(requestMonitor);
}},
new Step() { @Override
public void execute(RequestMonitor requestMonitor) {
fLaunch.getServiceFactory().createService(fSession, IExpressions.class).initialize(requestMonitor);
fLaunch.getServiceFactory().createService(IExpressions.class, fSession).initialize(requestMonitor);
}},
new Step() { @Override
public void execute(RequestMonitor requestMonitor) {
fSourceLookup = (CSourceLookup)fLaunch.getServiceFactory().createService(fSession, ISourceLookup.class);
fSourceLookup = (CSourceLookup)fLaunch.getServiceFactory().createService(ISourceLookup.class, fSession);
fSourceLookup.initialize(requestMonitor);
}},
new Step() { @Override
@ -82,21 +81,21 @@ public class ServicesLaunchSequence extends Sequence {
new Step() { @Override
public void execute(final RequestMonitor requestMonitor) {
// Create the low-level breakpoint service
fLaunch.getServiceFactory().createService(fSession, IBreakpoints.class).initialize(new RequestMonitor(getExecutor(), requestMonitor));
fLaunch.getServiceFactory().createService(IBreakpoints.class, fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
}},
new Step() { @Override
public void execute(final RequestMonitor requestMonitor) {
// Create high-level breakpoint service and install breakpoints
// for the GDB debug context.
fLaunch.getServiceFactory().createService(fSession, MIBreakpointsManager.class).initialize(new RequestMonitor(getExecutor(), requestMonitor));
fLaunch.getServiceFactory().createService(MIBreakpointsManager.class, fSession).initialize(new RequestMonitor(getExecutor(), requestMonitor));
}},
new Step() { @Override
public void execute(RequestMonitor requestMonitor) {
fLaunch.getServiceFactory().createService(fSession, IRegisters.class).initialize(requestMonitor);
fLaunch.getServiceFactory().createService(IRegisters.class, fSession).initialize(requestMonitor);
}},
new Step() { @Override
public void execute(RequestMonitor requestMonitor) {
fLaunch.getServiceFactory().createService(fSession, IDisassembly.class).initialize(requestMonitor);
fLaunch.getServiceFactory().createService(IDisassembly.class, fSession).initialize(requestMonitor);
}},
};

View file

@ -34,6 +34,7 @@ import org.eclipse.dd.mi.service.MIMemory;
import org.eclipse.dd.mi.service.MIModules;
import org.eclipse.dd.mi.service.MIRegisters;
import org.eclipse.dd.mi.service.MIStack;
import org.eclipse.debug.core.ILaunchConfiguration;
public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
@ -47,12 +48,19 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
@Override
@SuppressWarnings("unchecked")
public <V> V createService(DsfSession session, Class<V> clazz) {
if (MIBreakpointsManager.class.isAssignableFrom(clazz)) {
public <V> V createService(Class<V> clazz, DsfSession session, Object ... optionalArguments) {
if (MIBreakpointsManager.class.isAssignableFrom(clazz)) {
return (V)createBreakpointManagerService(session);
}
} else if (ICommandControl.class.isAssignableFrom(clazz)) {
for (Object arg : optionalArguments) {
if (arg instanceof ILaunchConfiguration) {
return (V)createCommandControl(session, (ILaunchConfiguration)arg);
}
}
}
return super.createService(session, clazz);
return super.createService(clazz, session);
}
protected MIBreakpointsManager createBreakpointManagerService(DsfSession session) {
@ -64,9 +72,8 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
return new MIBreakpoints(session);
}
@Override
protected ICommandControl createCommandControl(DsfSession session) {
return new GDBControl(session);
protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) {
return new GDBControl(session, config);
}
@Override

View file

@ -114,13 +114,9 @@ public class GDBControl extends AbstractMIControl {
private MIInferiorProcess fInferiorProcess = null;
private PTY fPty;
public GDBControl(DsfSession session) {
super(session);
fControlDmc = new GDBControlDMContext(session.getId(), "gdbcontrol[" + ++fgInstanceCounter + "]"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void initData(ILaunchConfiguration config) {
public GDBControl(DsfSession session, ILaunchConfiguration config) {
super(session);
fSessionType = LaunchUtils.getSessionType(config);
fAttach = LaunchUtils.getIsAttach(config);
fGdbPath = LaunchUtils.getGDBPath(config);
@ -129,6 +125,7 @@ public class GDBControl extends AbstractMIControl {
} catch (CoreException e) {
fExecPath = new Path(""); //$NON-NLS-1$
}
fControlDmc = new GDBControlDMContext(session.getId(), "gdbcontrol[" + ++fgInstanceCounter + "]"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Deprecated