mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
- Ported to new debugger command APIs (bug# 163623). This makes DSF build with 3.3 M3, but breaks compatibility with 3.2.
- Warnings cleanup.
This commit is contained in:
parent
26390e0a8c
commit
94841c4ee3
30 changed files with 175 additions and 176 deletions
|
@ -11,17 +11,18 @@
|
|||
package org.eclipse.dd.dsf.debug.ui.viewmodel;
|
||||
|
||||
import org.eclipse.dd.dsf.concurrent.DsfExecutor;
|
||||
import org.eclipse.dd.dsf.concurrent.DsfRunnable;
|
||||
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMRootLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.DMContextVMLayoutNode.DMContextVMContext;
|
||||
import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
|
||||
import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +30,6 @@ import org.eclipse.ui.IWorkbenchWindow;
|
|||
* Views such as variables and registers base their content based on the
|
||||
* selection in Debug view, and this node provides tracking of that selection.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode
|
||||
implements IVMRootLayoutNode, IDebugContextListener
|
||||
{
|
||||
|
@ -37,18 +37,18 @@ public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode
|
|||
|
||||
public DebugViewSelectionRootLayoutNode(DsfExecutor executor, IWorkbenchWindow window) {
|
||||
super(executor);
|
||||
ISelection selection = DebugContextManager.getDefault().getActiveContext(window);
|
||||
ISelection selection = DebugUITools.getDebugContextManager().getContextService(window).getActiveContext();
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
fRootVMC = new RootVMC<Object>( this, ((IStructuredSelection)selection).getFirstElement() );
|
||||
} else {
|
||||
fRootVMC = new RootVMC<Object>( this, null );
|
||||
}
|
||||
DebugContextManager.getDefault().addDebugContextListener(this, window);
|
||||
DebugUITools.getDebugContextManager().addDebugContextListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sessionDispose() {
|
||||
DebugContextManager.getDefault().removeDebugContextListener(this);
|
||||
DebugUITools.getDebugContextManager().removeDebugContextListener(this);
|
||||
super.sessionDispose();
|
||||
}
|
||||
|
||||
|
@ -75,17 +75,14 @@ public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode
|
|||
*/
|
||||
@Override
|
||||
public boolean hasDeltaFlags(Object event) {
|
||||
/*
|
||||
* TODO: This logic needs to be tested and probably enhanced.
|
||||
*/
|
||||
if (event instanceof IDMEvent && fRootVMC.getInputObject() instanceof DMContextVMContext) {
|
||||
boolean potentialMatchFound = false;
|
||||
boolean matchFound = false;
|
||||
|
||||
IDMContext eventDmc = ((IDMEvent)event).getDMContext();
|
||||
IDMContext inputDmc = ((DMContextVMContext)fRootVMC.getInputObject()).getDMC();
|
||||
for (IDMContext eventDmcAncestor : DMContexts.toList(eventDmc)) {
|
||||
IDMContext inputDmcAncestor = DMContexts.getAncestorOfType(inputDmc, eventDmcAncestor.getClass());
|
||||
IDMContext<?> eventDmc = ((IDMEvent)event).getDMContext();
|
||||
IDMContext<?> inputDmc = ((DMContextVMContext)fRootVMC.getInputObject()).getDMC();
|
||||
for (IDMContext<?> eventDmcAncestor : DMContexts.toList(eventDmc)) {
|
||||
IDMContext<?> inputDmcAncestor = DMContexts.getAncestorOfType(inputDmc, eventDmcAncestor.getClass());
|
||||
if (inputDmcAncestor != null) {
|
||||
potentialMatchFound = true;
|
||||
if (inputDmcAncestor.equals(eventDmcAncestor)) {
|
||||
|
@ -105,16 +102,17 @@ public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode
|
|||
return fRootVMC;
|
||||
}
|
||||
|
||||
public void contextActivated(ISelection selection, IWorkbenchPart part) {
|
||||
public void debugContextChanged(DebugContextEvent event) {
|
||||
final ISelection selection = event.getContext();
|
||||
getExecutor().execute(new DsfRunnable() {
|
||||
public void run() {
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
fRootVMC = new RootVMC<Object>( this, ((IStructuredSelection)selection).getFirstElement() );
|
||||
fRootVMC = new RootVMC<Object>( DebugViewSelectionRootLayoutNode.this,
|
||||
((IStructuredSelection)selection).getFirstElement() );
|
||||
} else {
|
||||
fRootVMC = new RootVMC<Object>( this, null );
|
||||
fRootVMC = new RootVMC<Object>( DebugViewSelectionRootLayoutNode.this, null );
|
||||
}
|
||||
}
|
||||
|
||||
public void contextChanged(ISelection selection, IWorkbenchPart part) {
|
||||
// No need to do anything. Element changes should be handled
|
||||
// through standard event handlers.
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
|||
import org.eclipse.dd.dsf.mi.service.MIRunControl;
|
||||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.DMContextVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.GetDataDoneWithRequestMonitor;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMContext;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.DMContextVMLayoutNode.DMContextVMContext;
|
||||
import org.eclipse.debug.internal.ui.viewers.provisional.ILabelRequestMonitor;
|
||||
import org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
|
@ -69,9 +69,16 @@ public class ThreadLayoutNode extends DMContextVMLayoutNode {
|
|||
|
||||
processes.getModelData(
|
||||
processes.getThreadForExecutionContext(dmc),
|
||||
new GetDataDoneWithRequestMonitor<IThreadDMData>(result) { public void doRun() {
|
||||
new GetDataDone<IThreadDMData>() {
|
||||
public void run() {
|
||||
if (!getStatus().isOK() || !getData().isValid()) {
|
||||
result.done();
|
||||
return;
|
||||
}
|
||||
result.setLabels(new String[] { getData().getName() });
|
||||
}});
|
||||
result.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean hasDeltaFlagsForDMEvent(IDMEvent e) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.osgi.framework.BundleContext;
|
|||
public class DsfDebugPlugin extends Plugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "org.eclipse.dd.dsf.debug.debug.service";
|
||||
public static final String PLUGIN_ID = "org.eclipse.dd.dsf.debug.debug.service"; //$NON-NLS-1$
|
||||
|
||||
// The shared instance
|
||||
private static DsfDebugPlugin fgPlugin;
|
||||
|
|
|
@ -26,7 +26,7 @@ public interface IBackEndProcess extends IDsfService {
|
|||
* same time, a service property is needed to allow clients to distinguish
|
||||
* between them.
|
||||
*/
|
||||
static final String PROCESS_ID = "org.eclipse.dsdp.DSF.debug.BackendProcess.PROCESS_ID";
|
||||
static final String PROCESS_ID = "org.eclipse.dsdp.DSF.debug.BackendProcess.PROCESS_ID"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Event indicating that the back end process has terminated.
|
||||
|
|
|
@ -30,12 +30,12 @@ public interface IModules extends IDMService {
|
|||
* types of debugging, like kernel or no-OS debugging, it's useful to
|
||||
* separate the concept of a symbol context from a process.
|
||||
*/
|
||||
public interface ISymbolDMContext extends IDMContext {}
|
||||
public interface ISymbolDMContext extends IDMContext<ISymbolDMData>{}
|
||||
|
||||
/**
|
||||
* Module context represents a single module that is loaded.
|
||||
*/
|
||||
public interface IModuleDMContext extends IDMContext<ModuleDMData> {}
|
||||
public interface IModuleDMContext extends IDMContext<IModuleDMData> {}
|
||||
|
||||
/**
|
||||
* Event indicating a change in the symbol information for given context.
|
||||
|
@ -90,7 +90,7 @@ public interface IModules extends IDMService {
|
|||
* Symbol context data includes a mapping between run-time addresses and
|
||||
* module-section-offset coordinates.
|
||||
*/
|
||||
public interface SymbolDMData extends IDMData {
|
||||
public interface ISymbolDMData extends IDMData {
|
||||
/** Convert link-time address 'addr' to run-time address */
|
||||
public long convertToRT(ModuleSectionOffset mso);
|
||||
|
||||
|
@ -99,7 +99,7 @@ public interface IModules extends IDMService {
|
|||
}
|
||||
|
||||
/** Module information. */
|
||||
public interface ModuleDMData extends IDMData {
|
||||
public interface IModuleDMData extends IDMData {
|
||||
String getName();
|
||||
String getFile();
|
||||
long getTimeStamp();
|
||||
|
|
|
@ -29,7 +29,7 @@ public interface ITargets extends IDMService {
|
|||
boolean isConnected();
|
||||
}
|
||||
|
||||
public interface ITargetStateChanged extends IDMEvent {}
|
||||
public interface ITargetStateChanged extends IDMEvent<ITargetDMContext> {}
|
||||
|
||||
public interface ICoreDMContext extends IDMContext<ICoreDMData> {}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public interface ITargets extends IDMService {
|
|||
IOS.IOSDMContext getOSDMContext();
|
||||
}
|
||||
|
||||
public interface ICoreStateChangedDMEvent extends IDMEvent {}
|
||||
public interface ICoreStateChangedDMEvent extends IDMEvent<ICoreDMContext> {}
|
||||
|
||||
public void getTargets(GetDataDone<ITargetDMContext> done);
|
||||
public void getCores(ITargetDMContext target, GetDataDone<ICoreDMContext> done);
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.osgi.framework.BundleContext;
|
|||
public class DsfUIPlugin extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "org.eclipse.dd.dsf.ui";
|
||||
public static final String PLUGIN_ID = "org.eclipse.dd.dsf.ui"; //$NON-NLS-1$
|
||||
|
||||
// The shared instance
|
||||
private static DsfUIPlugin fgPlugin;
|
||||
|
|
|
@ -98,13 +98,13 @@ abstract public class AbstractVMAdapter
|
|||
|
||||
VMProvider provider = getViewModelProvider(context);
|
||||
if (provider == null) {
|
||||
result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + object.toString(), null));
|
||||
result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + object.toString(), null)); //$NON-NLS-1$
|
||||
result.done();
|
||||
}
|
||||
provider.retrieveLabel(object, result);
|
||||
}
|
||||
@Override
|
||||
public String toString() { return "Switch to dispatch thread to execute retrieveLabel()"; }
|
||||
public String toString() { return "Switch to dispatch thread to execute retrieveLabel()"; } //$NON-NLS-1$
|
||||
});
|
||||
} catch(RejectedExecutionException e) {
|
||||
// This can happen if session is being shut down.
|
||||
|
@ -120,12 +120,12 @@ abstract public class AbstractVMAdapter
|
|||
|
||||
VMProvider provider = getViewModelProvider(context);
|
||||
if (provider == null) {
|
||||
result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + element.toString(), null));
|
||||
result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + element.toString(), null)); //$NON-NLS-1$
|
||||
result.done();
|
||||
}
|
||||
provider.isContainer(element, result);
|
||||
}
|
||||
public String toString() { return "Switch to dispatch thread to execute isContainer()"; }
|
||||
public String toString() { return "Switch to dispatch thread to execute isContainer()"; } //$NON-NLS-1$
|
||||
});
|
||||
} catch(RejectedExecutionException e) {
|
||||
// This can happen if session is being shut down.
|
||||
|
@ -141,12 +141,12 @@ abstract public class AbstractVMAdapter
|
|||
|
||||
VMProvider provider = getViewModelProvider(context);
|
||||
if (provider == null) {
|
||||
result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + element.toString(), null));
|
||||
result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + element.toString(), null)); //$NON-NLS-1$
|
||||
result.done();
|
||||
}
|
||||
provider.retrieveChildren(element, result);
|
||||
}
|
||||
public String toString() { return "Switch to dispatch thread to execute retrieveChildren()"; }
|
||||
public String toString() { return "Switch to dispatch thread to execute retrieveChildren()"; } //$NON-NLS-1$
|
||||
});
|
||||
} catch(RejectedExecutionException e) {
|
||||
// This can happen if session is being shut down.
|
||||
|
@ -155,8 +155,13 @@ abstract public class AbstractVMAdapter
|
|||
}
|
||||
|
||||
public IModelProxy createModelProxy(Object element, IPresentationContext context) {
|
||||
/*
|
||||
* Model proxy is the object that correlates events from the data model
|
||||
* into view model deltas that the view can process. We only need to
|
||||
* create a proxy for the root element of the tree.
|
||||
*/
|
||||
VMProvider provider = getViewModelProvider(context);
|
||||
if (provider != null) {
|
||||
if (provider != null && element.equals(provider.getRootLayoutNode().getRootVMC().getInputObject())) {
|
||||
return provider.getModelProxy();
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -94,7 +94,16 @@ abstract public class AbstractVMLayoutNode implements IVMLayoutNode {
|
|||
parent.getVMC(),
|
||||
new GetDataDone<IVMContext[]>() {
|
||||
public void run() {
|
||||
if (propagateError(getExecutor(), done, "Failed to retrieve elements in layout node " + AbstractVMLayoutNode.this)) return;
|
||||
if (propagateError(getExecutor(), done, "Failed to retrieve elements in layout node " + AbstractVMLayoutNode.this)) return; //$NON-NLS-1$
|
||||
|
||||
/*
|
||||
* Check for an empty list of elements. If it's empty then we
|
||||
* don't have to call the children nodes, so return here.
|
||||
*/
|
||||
if (getData().length == 0) {
|
||||
getExecutor().execute(done);
|
||||
}
|
||||
|
||||
/*
|
||||
* The execution for this node is not done until all the child nodes
|
||||
* are done. Use the tracker to wait for all children to complete.
|
||||
|
@ -152,7 +161,7 @@ abstract public class AbstractVMLayoutNode implements IVMLayoutNode {
|
|||
* that the layout node depends on, are not available.
|
||||
*/
|
||||
protected void handleFailedRetrieveLabel(ILabelRequestMonitor result) {
|
||||
result.setLabels(new String[] { "..."} );
|
||||
result.setLabels(new String[] { "..."} ); //$NON-NLS-1$
|
||||
result.done();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl
|
|||
|
||||
public IVMLayoutNode getLayoutNode() { return fVMRootLayoutNode; }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (fInputObject instanceof IAdaptable) {
|
||||
return ((IAdaptable)fInputObject).getAdapter(adapter);
|
||||
|
@ -55,7 +56,7 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl
|
|||
return fInputObject.hashCode();
|
||||
}
|
||||
|
||||
public String toString() { return "Root VMC for " + fInputObject.toString(); }
|
||||
public String toString() { return "Root VMC for " + fInputObject.toString(); } //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public AbstractVMRootLayoutNode(DsfExecutor executor) {
|
||||
|
@ -111,7 +112,7 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl
|
|||
*/
|
||||
final DoneCollector doneCollector = new DoneCollector(getExecutor()) {
|
||||
public void run() {
|
||||
if (propagateError(getExecutor(), done, "Failed to generate child deltas.")) return;
|
||||
if (propagateError(getExecutor(), done, "Failed to generate child deltas.")) return; //$NON-NLS-1$
|
||||
done.setData(rootDelta);
|
||||
getExecutor().execute(done);
|
||||
}
|
||||
|
|
|
@ -38,17 +38,18 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
|
|||
@Immutable
|
||||
public class DMContextVMContext implements IVMContext {
|
||||
private final IVMContext fParent;
|
||||
private final IDMContext fDmc;
|
||||
private final IDMContext<?> fDmc;
|
||||
|
||||
public DMContextVMContext(IVMContext parent, IDMContext dmc) {
|
||||
public DMContextVMContext(IVMContext parent, IDMContext<?> dmc) {
|
||||
fParent = parent;
|
||||
fDmc = dmc;
|
||||
}
|
||||
|
||||
public IDMContext getDMC() { return fDmc; }
|
||||
public IDMContext<?> getDMC() { return fDmc; }
|
||||
public IVMContext getParent() { return fParent; }
|
||||
public IVMLayoutNode getLayoutNode() { return DMContextVMLayoutNode.this; }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
return fDmc.getAdapter(adapter);
|
||||
}
|
||||
|
@ -66,7 +67,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return fParent.toString() + "->" + fDmc.toString();
|
||||
return fParent.toString() + "->" + fDmc.toString(); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +76,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
|
|||
|
||||
|
||||
/** Class type that the elements of this schema node are based on. */
|
||||
private Class<? extends IDMContext> fDMCClassType;
|
||||
private Class<? extends IDMContext<?>> fDMCClassType;
|
||||
|
||||
/**
|
||||
* Constructor initializes instance data, except for the child nodes.
|
||||
|
@ -84,7 +85,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
|
|||
* @param dmcClassType
|
||||
* @see #setChildNodes(IVMLayoutNode[])
|
||||
*/
|
||||
public DMContextVMLayoutNode(DsfSession session, Class<? extends IDMContext> dmcClassType) {
|
||||
public DMContextVMLayoutNode(DsfSession session, Class<? extends IDMContext<?>> dmcClassType) {
|
||||
super(session.getExecutor());
|
||||
fServices = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId());
|
||||
fDMCClassType = dmcClassType;
|
||||
|
@ -112,7 +113,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
|
|||
* DMC-specific version of {@link IVMLayoutNode#hasDeltaFlags(Object)}.
|
||||
* By default, it falls back on the super-class implementation.
|
||||
*/
|
||||
protected boolean hasDeltaFlagsForDMEvent(IDMEvent e) {
|
||||
protected boolean hasDeltaFlagsForDMEvent(IDMEvent<?> e) {
|
||||
return super.hasDeltaFlags(e);
|
||||
}
|
||||
|
||||
|
@ -129,7 +130,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
|
|||
* Adds an optimization (over the AbstractViewModelLayoutNode) which
|
||||
* narrows down the list of children based on the DMC within the event.
|
||||
*/
|
||||
public void buildDeltaForDMEvent(final IDMEvent e, final VMDelta parent, final Done done) {
|
||||
public void buildDeltaForDMEvent(final IDMEvent<?> e, final VMDelta parent, final Done done) {
|
||||
/*
|
||||
* Take the IDMContext (DMC) that the event is based on, and
|
||||
* search its ancestors. Look for the DMC class typs that this schema
|
||||
|
@ -138,7 +139,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
|
|||
* behavior and generate a IModelDelta for every element in this schema
|
||||
* node.
|
||||
*/
|
||||
IDMContext dmc = DMContexts.getAncestorOfType(e.getDMContext(), fDMCClassType);
|
||||
IDMContext<?> dmc = DMContexts.getAncestorOfType(e.getDMContext(), fDMCClassType);
|
||||
if (dmc != null) {
|
||||
IVMLayoutNode[] childNodes = getChildNodesWithDeltas(e);
|
||||
if (childNodes.length == 0) {
|
||||
|
@ -179,7 +180,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
|
|||
* @param dmcs Array of DMC objects to build return array on.
|
||||
* @return Array of IVMContext objects.
|
||||
*/
|
||||
protected IVMContext[] dmcs2vmcs(IVMContext parent, IDMContext[] dmcs) {
|
||||
protected IVMContext[] dmcs2vmcs(IVMContext parent, IDMContext<?>[] dmcs) {
|
||||
IVMContext[] vmContexts = new IVMContext[dmcs.length];
|
||||
for (int i = 0; i < dmcs.length; i++) {
|
||||
vmContexts[i] = new DMContextVMContext(parent, dmcs[i]);
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.dsf.ui.viewmodel;
|
||||
|
||||
import org.eclipse.dd.dsf.concurrent.GetDataDone;
|
||||
import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor;
|
||||
|
||||
/**
|
||||
* Convenience extension to GetDataDone, which handles notifying the
|
||||
* IAsynchronousRequestMonitor when the done is executed.
|
||||
* @param <V> Class type of data.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public abstract class GetDataDoneWithRequestMonitor<V> extends GetDataDone<V> {
|
||||
/** Monitor to be posted when this done is executed. */
|
||||
private IAsynchronousRequestMonitor fMonitor;
|
||||
|
||||
/** Constructor requires the monitor */
|
||||
public GetDataDoneWithRequestMonitor(IAsynchronousRequestMonitor monitor) {
|
||||
fMonitor = monitor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run method checks the request monitor for cancellation and checks this
|
||||
* done's status before calling doRun(). Finally it takes care of
|
||||
* notifying the request montior that request is finished.
|
||||
*/
|
||||
public final void run() {
|
||||
if (fMonitor.isCanceled()) return;
|
||||
if (!getStatus().isOK()) {
|
||||
fMonitor.setStatus(getStatus());
|
||||
} else {
|
||||
doRun();
|
||||
}
|
||||
fMonitor.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to perform the actual work. It should not call monitor.done(),
|
||||
* because it will be called by this class in run().
|
||||
*/
|
||||
protected abstract void doRun();
|
||||
}
|
|
@ -29,6 +29,7 @@ import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousLabelAdapt
|
|||
import org.eclipse.debug.internal.ui.viewers.provisional.IChildrenRequestMonitor;
|
||||
import org.eclipse.debug.internal.ui.viewers.provisional.IContainerRequestMonitor;
|
||||
import org.eclipse.debug.internal.ui.viewers.provisional.ILabelRequestMonitor;
|
||||
import org.eclipse.debug.internal.ui.viewers.provisional.IModelChangedListener;
|
||||
import org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta;
|
||||
import org.eclipse.debug.internal.ui.viewers.provisional.IModelProxy;
|
||||
|
||||
|
@ -76,6 +77,18 @@ public class VMProvider
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeModelChangedListener(IModelChangedListener listener) {
|
||||
// TODO Auto-generated method stub
|
||||
super.removeModelChangedListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModelChangedListener(IModelChangedListener listener) {
|
||||
// TODO Auto-generated method stub
|
||||
super.addModelChangedListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires given delta using a job. Processing the delta on the dispatch
|
||||
* thread can lead to dead-locks.
|
||||
|
@ -206,7 +219,7 @@ public class VMProvider
|
|||
* nothing to do, just mark the monitor done.
|
||||
*/
|
||||
if (parentVmc.getLayoutNode().getChildLayoutNodes().length == 0) {
|
||||
assert false : "We should never get here, because isContainer() should have returned false";
|
||||
assert false : "We should never get here, because isContainer() should have returned false"; //$NON-NLS-1$
|
||||
monitor.done();
|
||||
return;
|
||||
}
|
||||
|
@ -310,7 +323,7 @@ public class VMProvider
|
|||
* @param e
|
||||
*/
|
||||
@DsfServiceEventHandler
|
||||
public void eventDispatched(final IDMEvent event) {
|
||||
public void eventDispatched(final IDMEvent<?> event) {
|
||||
if (fRootLayoutNode.hasDeltaFlags(event)) {
|
||||
fRootLayoutNode.createDelta(event, new GetDataDone<IModelDelta>() {
|
||||
public void run() {
|
||||
|
@ -319,7 +332,7 @@ public class VMProvider
|
|||
}
|
||||
}
|
||||
@Override public String toString() {
|
||||
return "Result of a delta for event: '" + event.toString() + "' in VMP: '" + VMProvider.this + "'";
|
||||
return "Result of a delta for event: '" + event.toString() + "' in VMP: '" + VMProvider.this + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.osgi.framework.BundleContext;
|
|||
public class DsfPlugin extends Plugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "org.eclipse.dd.dsf";
|
||||
public static final String PLUGIN_ID = "org.eclipse.dd.dsf"; //$NON-NLS-1$
|
||||
|
||||
// The shared instance
|
||||
private static DsfPlugin fgPlugin;
|
||||
|
|
|
@ -43,7 +43,7 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
|
|||
Thread fThread;
|
||||
public Thread newThread(Runnable r) {
|
||||
assert fThread == null; // Should be called only once.
|
||||
fThread = new Thread(new ThreadGroup("DSF Thread Group"), r, "DSF Dispatch Thread", 0);
|
||||
fThread = new Thread(new ThreadGroup("DSF Thread Group"), r, "DSF Dispatch Thread", 0); //$NON-NLS-1$//$NON-NLS-2$
|
||||
return fThread;
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
|
|||
@Override
|
||||
protected void afterExecute(Runnable r, Throwable t) {
|
||||
if (r instanceof Future) {
|
||||
Future future = (Future)r;
|
||||
Future<?> future = (Future<?>)r;
|
||||
try {
|
||||
/*
|
||||
* Try to retrieve the value, which should throw exception in
|
||||
|
@ -89,14 +89,14 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
|
|||
ILog log = DsfPlugin.getDefault().getLog();
|
||||
if (log != null) {
|
||||
log.log(new Status(
|
||||
IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Uncaught exception in DSF executor thread", t));
|
||||
IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Uncaught exception in DSF executor thread", t)); //$NON-NLS-1$
|
||||
}
|
||||
// Print out the stack trace to console if assertions are enabled.
|
||||
if(ASSERTIONS_ENABLED) {
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream(512);
|
||||
PrintStream printStream = new PrintStream(outStream);
|
||||
try {
|
||||
printStream.write("Uncaught exception in session executor thread: ".getBytes());
|
||||
printStream.write("Uncaught exception in session executor thread: ".getBytes()); //$NON-NLS-1$
|
||||
} catch (IOException e2) {}
|
||||
t.printStackTrace(new PrintStream(outStream));
|
||||
System.err.println(outStream.toString());
|
||||
|
@ -180,32 +180,32 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
|
|||
traceBuilder.append(getExecutable().getClass().getName());
|
||||
|
||||
// Add executable's toString().
|
||||
traceBuilder.append("\n ");
|
||||
traceBuilder.append("\n "); //$NON-NLS-1$
|
||||
traceBuilder.append(getExecutable().toString());
|
||||
|
||||
// Append "create by" info.
|
||||
if (getExecutable() instanceof DsfExecutable) {
|
||||
DsfExecutable dsfExecutable = (DsfExecutable)getExecutable();
|
||||
if (dsfExecutable.fCreatedAt != null || dsfExecutable.fCreatedBy != null) {
|
||||
traceBuilder.append("\n created ");
|
||||
traceBuilder.append("\n created "); //$NON-NLS-1$
|
||||
if (dsfExecutable.fCreatedBy != null) {
|
||||
traceBuilder.append(" by #");
|
||||
traceBuilder.append(" by #"); //$NON-NLS-1$
|
||||
traceBuilder.append(dsfExecutable.fCreatedBy.fSequenceNumber);
|
||||
}
|
||||
if (dsfExecutable.fCreatedAt != null) {
|
||||
traceBuilder.append(" at ");
|
||||
traceBuilder.append(" at "); //$NON-NLS-1$
|
||||
traceBuilder.append(dsfExecutable.fCreatedAt.fStackTraceElements[0].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Submitted info
|
||||
traceBuilder.append("\n submitted");
|
||||
traceBuilder.append("\n submitted"); //$NON-NLS-1$
|
||||
if (fSubmittedBy != null) {
|
||||
traceBuilder.append(" by #");
|
||||
traceBuilder.append(" by #"); //$NON-NLS-1$
|
||||
traceBuilder.append(fSubmittedBy.fSequenceNumber);
|
||||
}
|
||||
traceBuilder.append(" at ");
|
||||
traceBuilder.append(" at "); //$NON-NLS-1$
|
||||
traceBuilder.append(fSubmittedAt.fStackTraceElements[0].toString());
|
||||
|
||||
// Finally write out to console
|
||||
|
|
|
@ -66,6 +66,6 @@ abstract public class Done extends DsfRunnable {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "Done: " + getStatus().toString();
|
||||
return "Done: " + getStatus().toString(); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public abstract class DoneCollector extends Done {
|
|||
*
|
||||
*/
|
||||
public DoneCollector(DsfExecutor executor) {
|
||||
setStatus(new MultiStatus(DsfPlugin.PLUGIN_ID, 0, "Collective status for set of sub-operations.", null));
|
||||
setStatus(new MultiStatus(DsfPlugin.PLUGIN_ID, 0, "Collective status for set of sub-operations.", null)); //$NON-NLS-1$
|
||||
fExecutor = executor;
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,6 @@ public abstract class DoneCollector extends Done {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Done Collector: " + getStatus().toString();
|
||||
return "Done Collector: " + getStatus().toString(); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,9 +115,9 @@ public class DsfExecutable {
|
|||
traceBuilder.append(' ');
|
||||
|
||||
// Record the event
|
||||
traceBuilder.append("DsfExecutable was never executed:\n ");
|
||||
traceBuilder.append("DsfExecutable was never executed:\n "); //$NON-NLS-1$
|
||||
traceBuilder.append(this);
|
||||
traceBuilder.append("\nCreated at:");
|
||||
traceBuilder.append("\nCreated at:"); //$NON-NLS-1$
|
||||
traceBuilder.append(fCreatedAt);
|
||||
|
||||
DsfPlugin.debug(traceBuilder.toString());
|
||||
|
|
|
@ -128,12 +128,12 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
|
|||
|
||||
/** Convenience constructor with limited arguments. */
|
||||
public DsfSequence(DsfExecutor executor) {
|
||||
this(executor, new NullProgressMonitor(), "", "", null);
|
||||
this(executor, new NullProgressMonitor(), "", "", null); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
/** Convenience constructor with limited arguments. */
|
||||
public DsfSequence(DsfExecutor executor, Done done) {
|
||||
this(executor, new NullProgressMonitor(), "", "", done);
|
||||
this(executor, new NullProgressMonitor(), "", "", done); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -285,7 +285,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
|
|||
}
|
||||
}
|
||||
public String toString() {
|
||||
return "DsfSequence \"" + fTaskName + "\", result for executing step #" + fStepIdx + " = " + getStatus();
|
||||
return "DsfSequence \"" + fTaskName + "\", result for executing step #" + fStepIdx + " = " + getStatus(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
});
|
||||
} catch(Throwable t) {
|
||||
|
@ -297,7 +297,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
|
|||
*/
|
||||
abortExecution(new Status(
|
||||
IStatus.ERROR, DsfPlugin.PLUGIN_ID, 0,
|
||||
"Unhandled exception when executing DsfSequence " + this + ", step #" + fCurrentStepIdx,
|
||||
"Unhandled exception when executing DsfSequence " + this + ", step #" + fCurrentStepIdx, //$NON-NLS-1$ //$NON-NLS-2$
|
||||
t));
|
||||
|
||||
/*
|
||||
|
@ -338,7 +338,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
|
|||
};
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DsfSequence \"" + fTaskName + "\", result for rolling back step #" + fStepIdx + " = " + getStatus();
|
||||
return "DsfSequence \"" + fTaskName + "\", result for rolling back step #" + fStepIdx + " = " + getStatus(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
});
|
||||
} catch(Throwable t) {
|
||||
|
@ -350,7 +350,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
|
|||
*/
|
||||
abortRollBack(new Status(
|
||||
IStatus.ERROR, DsfPlugin.PLUGIN_ID, 0,
|
||||
"Unhandled exception when rolling back DsfSequence " + this + ", step #" + fCurrentStepIdx,
|
||||
"Unhandled exception when rolling back DsfSequence " + this + ", step #" + fCurrentStepIdx, //$NON-NLS-1$ //$NON-NLS-2$
|
||||
t));
|
||||
|
||||
/*
|
||||
|
@ -369,7 +369,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
|
|||
if (fRollbackTaskName != null) {
|
||||
fProgressMonitor.subTask(fRollbackTaskName);
|
||||
}
|
||||
fStatus = new Status(IStatus.CANCEL, DsfPlugin.PLUGIN_ID, -1, "Sequence \"" + fTaskName + "\" cancelled.", null);
|
||||
fStatus = new Status(IStatus.CANCEL, DsfPlugin.PLUGIN_ID, -1, "Sequence \"" + fTaskName + "\" cancelled.", null); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (fDone != null) {
|
||||
fDone.setStatus(fStatus);
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
|
|||
*/
|
||||
MultiStatus newStatus =
|
||||
new MultiStatus(DsfPlugin.PLUGIN_ID, error.getCode(),
|
||||
"Sequence \"" + fTaskName + "\" failed while rolling back.", null);
|
||||
"Sequence \"" + fTaskName + "\" failed while rolling back.", null); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
newStatus.merge(error);
|
||||
newStatus.merge(fStatus);
|
||||
fStatus = newStatus;
|
||||
|
|
|
@ -24,7 +24,7 @@ class StackTraceWrapper {
|
|||
StringBuilder builder = new StringBuilder(fStackTraceElements.length * 30);
|
||||
for (int i = 0; i < fStackTraceElements.length && i < 10; i++) {
|
||||
builder.append(fStackTraceElements[i]);
|
||||
if (i < fStackTraceElements.length && i < 10) builder.append("\n at ");
|
||||
if (i < fStackTraceElements.length && i < 10) builder.append("\n at "); //$NON-NLS-1$
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
|
@ -27,20 +27,20 @@ public class AbstractDMContext<V extends IDMData> extends PlatformObject
|
|||
{
|
||||
private final String fSessionId;
|
||||
private final String fServiceFilter;
|
||||
private final IDMContext[] fParents;
|
||||
private final IDMContext<?>[] fParents;
|
||||
|
||||
/**
|
||||
* Main constructor provides all data needed to implement the IModelContext
|
||||
* interface.
|
||||
*/
|
||||
public AbstractDMContext(String sessionId, String filter, IDMContext[] parents) {
|
||||
public AbstractDMContext(String sessionId, String filter, IDMContext<?>[] parents) {
|
||||
fSessionId = sessionId;
|
||||
fServiceFilter = filter;
|
||||
fParents = parents;
|
||||
}
|
||||
|
||||
/** Convenience constructor */
|
||||
public AbstractDMContext(AbstractDsfService service, IDMContext parent) {
|
||||
public AbstractDMContext(AbstractDsfService service, IDMContext<?> parent) {
|
||||
this(service.getSession().getId(),
|
||||
service.getServiceFilter(),
|
||||
parent == null ? new IDMContext[] {} : new IDMContext[] { parent });
|
||||
|
@ -55,13 +55,13 @@ public class AbstractDMContext<V extends IDMData> extends PlatformObject
|
|||
protected boolean baseEquals(Object other) {
|
||||
if (other == null) return false;
|
||||
if ( !(other.getClass().equals(getClass()))) return false;
|
||||
IDMContext otherCtx = (IDMContext)other;
|
||||
IDMContext<?> otherCtx = (IDMContext<?>)other;
|
||||
return getSessionId().equals(otherCtx.getSessionId()) &&
|
||||
getServiceFilter().equals(otherCtx.getServiceFilter()) &&
|
||||
areParentsEqual(otherCtx.getParents());
|
||||
}
|
||||
|
||||
private boolean areParentsEqual(IDMContext[] otherParents) {
|
||||
private boolean areParentsEqual(IDMContext<?>[] otherParents) {
|
||||
if ( !(fParents.length == otherParents.length) ) return false;
|
||||
for (int i = 0; i < fParents.length; i++) {
|
||||
if (!fParents[i].equals(otherParents[i])) {
|
||||
|
@ -81,7 +81,7 @@ public class AbstractDMContext<V extends IDMData> extends PlatformObject
|
|||
|
||||
protected String baseToString() {
|
||||
StringBuffer retVal = new StringBuffer();
|
||||
for (IDMContext parent : fParents) {
|
||||
for (IDMContext<?> parent : fParents) {
|
||||
retVal.append(parent);
|
||||
}
|
||||
return retVal.toString();
|
||||
|
@ -89,7 +89,7 @@ public class AbstractDMContext<V extends IDMData> extends PlatformObject
|
|||
|
||||
public String getSessionId() { return fSessionId; }
|
||||
public String getServiceFilter() { return fServiceFilter; }
|
||||
public IDMContext[] getParents() { return fParents; }
|
||||
public IDMContext<?>[] getParents() { return fParents; }
|
||||
|
||||
/**
|
||||
* Overrides the standard platform getAdapter to provide session-specific
|
||||
|
@ -106,6 +106,7 @@ public class AbstractDMContext<V extends IDMData> extends PlatformObject
|
|||
* session is equally important.
|
||||
* @see org.eclipse.runtime.IAdapterManager
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapterType) {
|
||||
Object retVal = null;
|
||||
DsfSession session = DsfSession.getSession(fSessionId);
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.eclipse.dd.dsf.concurrent.Immutable;
|
|||
* required DM-Context reference.
|
||||
*/
|
||||
@Immutable
|
||||
public class AbstractDMEvent<V extends IDMContext> implements IDMEvent<V> {
|
||||
public class AbstractDMEvent<V extends IDMContext<?>> implements IDMEvent<V> {
|
||||
|
||||
private final V fModelContext;
|
||||
public AbstractDMEvent(V context) {
|
||||
|
|
|
@ -56,16 +56,16 @@ public class DMContexts {
|
|||
* @return true if a match is found.
|
||||
*/
|
||||
@ThreadSafe
|
||||
public static boolean isAncestorOf(IDMContext dmc, IDMContext potentialAncestor) {
|
||||
public static boolean isAncestorOf(IDMContext<?> dmc, IDMContext<?> potentialAncestor) {
|
||||
// Check the direct parents for a match.
|
||||
for (IDMContext parentDmc : dmc.getParents()) {
|
||||
for (IDMContext<?> parentDmc : dmc.getParents()) {
|
||||
if (potentialAncestor.equals(parentDmc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively check the parents' parents for a match.
|
||||
for (IDMContext parentDmc : dmc.getParents()) {
|
||||
for (IDMContext<?> parentDmc : dmc.getParents()) {
|
||||
if (isAncestorOf(parentDmc, potentialAncestor)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -80,15 +80,15 @@ public class DMContexts {
|
|||
* into a list.
|
||||
*/
|
||||
@ThreadSafe
|
||||
public static List<IDMContext> toList(IDMContext dmc) {
|
||||
public static List<IDMContext<?>> toList(IDMContext<?> dmc) {
|
||||
/*
|
||||
* This method is implemented recursively, which is not necessarily
|
||||
* the most efficient way to do this.
|
||||
*/
|
||||
List<IDMContext> list = new ArrayList<IDMContext>();
|
||||
List<IDMContext<?>> list = new ArrayList<IDMContext<?>>();
|
||||
list.add(dmc);
|
||||
|
||||
for (IDMContext parentDmc : dmc.getParents()) {
|
||||
for (IDMContext<?> parentDmc : dmc.getParents()) {
|
||||
list.addAll(toList(parentDmc));
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -73,5 +73,5 @@ public interface IDMContext<V extends IDMData> extends IAdaptable
|
|||
* the client.
|
||||
* @return parent context of this context.
|
||||
*/
|
||||
public IDMContext[] getParents();
|
||||
public IDMContext<?>[] getParents();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@ package org.eclipse.dd.dsf.datamodel;
|
|||
* this base class only identifies the DM Context that is affected.
|
||||
* @param <V> Data Model context type that is affected by this event.
|
||||
*/
|
||||
public interface IDMEvent <V extends IDMContext> {
|
||||
public interface IDMEvent <V extends IDMContext<?>> {
|
||||
V getDMContext();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public interface IDMService extends IDsfService, IDMData {
|
|||
* usually used in events to indicate that lists of contexts in this
|
||||
* service are changed.
|
||||
*/
|
||||
IDMContext getServiceContext();
|
||||
IDMContext<?> getServiceContext();
|
||||
|
||||
/**
|
||||
* Retrieves model data object for given context. This method makes it
|
||||
|
|
|
@ -42,6 +42,7 @@ abstract public class AbstractDsfService
|
|||
private DsfServicesTracker fTracker;
|
||||
|
||||
/** Properties that this service was registered with */
|
||||
@SuppressWarnings("unchecked")
|
||||
private Dictionary fProperties;
|
||||
|
||||
/** Properties that this service was registered with */
|
||||
|
@ -58,9 +59,14 @@ abstract public class AbstractDsfService
|
|||
}
|
||||
|
||||
public DsfExecutor getExecutor() { return fSession.getExecutor(); }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Dictionary getProperties() { return fProperties; }
|
||||
|
||||
public String getServiceFilter() { return fFilter; }
|
||||
|
||||
public int getStartupNumber() { return fStartupNumber; }
|
||||
|
||||
public void initialize(Done done) {
|
||||
fTracker = new DsfServicesTracker(getBundleContext(), fSession.getId());
|
||||
fStartupNumber = fSession.getAndIncrementServiceStartupCounter();
|
||||
|
@ -136,9 +142,10 @@ abstract public class AbstractDsfService
|
|||
/**
|
||||
* Generates an LDAP filter to uniquely identify this service.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private String generateFilter(Dictionary properties) {
|
||||
StringBuffer filter = new StringBuffer();
|
||||
filter.append("(&");
|
||||
filter.append("(&"); //$NON-NLS-1$
|
||||
|
||||
for (Enumeration keys = properties.keys(); keys.hasMoreElements();) {
|
||||
Object key = keys.nextElement();
|
||||
|
@ -151,7 +158,7 @@ abstract public class AbstractDsfService
|
|||
for (Object arrayValue : (Object[])value) {
|
||||
filter.append('(');
|
||||
filter.append(key.toString());
|
||||
filter.append("=*");
|
||||
filter.append("=*"); //$NON-NLS-1$
|
||||
filter.append(arrayValue.toString());
|
||||
filter.append(')');
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.osgi.framework.ServiceReference;
|
|||
public class DsfServicesTracker {
|
||||
|
||||
private static String getServiceFilter(String sessionId) {
|
||||
return ("(" + IDsfService.PROP_SESSION_ID + "=" + sessionId + ")").intern();
|
||||
return ("(" + IDsfService.PROP_SESSION_ID + "=" + sessionId + ")").intern(); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
|
||||
private static class ServiceKey
|
||||
|
@ -93,6 +93,7 @@ public class DsfServicesTracker {
|
|||
* session-ID
|
||||
* @return OSGI service reference object to the desired service, null if not found
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ServiceReference getServiceReference(Class serviceClass, String filter) {
|
||||
ServiceKey key = new ServiceKey(serviceClass.getName().intern(), filter != null ? filter : fServiceFilter);
|
||||
if (fServiceReferences.containsKey(key)) {
|
||||
|
@ -109,7 +110,7 @@ public class DsfServicesTracker {
|
|||
return references[0];
|
||||
}
|
||||
} catch(InvalidSyntaxException e) {
|
||||
assert false : "Invalid session ID syntax";
|
||||
assert false : "Invalid session ID syntax"; //$NON-NLS-1$
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -154,8 +155,8 @@ public class DsfServicesTracker {
|
|||
* to avoid leaking OSGI service references.
|
||||
*/
|
||||
public void dispose() {
|
||||
for (Iterator itr = fServices.keySet().iterator(); itr.hasNext();) {
|
||||
fBundleContext.ungetService((ServiceReference)itr.next());
|
||||
for (Iterator<ServiceReference> itr = fServices.keySet().iterator(); itr.hasNext();) {
|
||||
fBundleContext.ungetService(itr.next());
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,6 +222,7 @@ public class DsfSession
|
|||
* IModelContext.getAdapter() method.
|
||||
* @see org.eclipse.dd.dsf.datamodel.AbstractDMContext#getAdapter
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Class,Object> fAdapters = Collections.synchronizedMap(new HashMap<Class,Object>());
|
||||
|
||||
/** Returns the owner ID of this session */
|
||||
|
@ -271,10 +272,11 @@ public class DsfSession
|
|||
* @param serviceProperties properties of the service requesting the event to be dispatched
|
||||
*/
|
||||
@ThreadSafe
|
||||
@SuppressWarnings("unchecked")
|
||||
public void dispatchEvent(final Object event, final Dictionary serviceProperties) {
|
||||
getExecutor().submit(new DsfRunnable() {
|
||||
public void run() { doDispatchEvent(event, serviceProperties);}
|
||||
public String toString() { return "Event: " + event + ", from service " + serviceProperties; }
|
||||
public String toString() { return "Event: " + event + ", from service " + serviceProperties; } //$NON-NLS-1$ //$NON-NLS-2$
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -285,6 +287,7 @@ public class DsfSession
|
|||
* @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter
|
||||
*/
|
||||
@ThreadSafe
|
||||
@SuppressWarnings("unchecked")
|
||||
public void registerModelAdapter(Class adapterType, Object adapter) {
|
||||
fAdapters.put(adapterType, adapter);
|
||||
}
|
||||
|
@ -295,6 +298,7 @@ public class DsfSession
|
|||
* @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter
|
||||
*/
|
||||
@ThreadSafe
|
||||
@SuppressWarnings("unchecked")
|
||||
public void unregisterModelAdapter(Class adapterType) {
|
||||
fAdapters.remove(adapterType);
|
||||
}
|
||||
|
@ -306,6 +310,7 @@ public class DsfSession
|
|||
* @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter
|
||||
*/
|
||||
@ThreadSafe
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getModelAdapter(Class adapterType) {
|
||||
return fAdapters.get(adapterType);
|
||||
}
|
||||
|
@ -318,6 +323,7 @@ public class DsfSession
|
|||
@ThreadSafe
|
||||
public int hashCode() { return fId.hashCode(); }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void doDispatchEvent(Object event, Dictionary serviceProperties) {
|
||||
// Build a list of listeners;
|
||||
SortedMap<ListenerEntry,List<Method>> listeners = new TreeMap<ListenerEntry,List<Method>>(new Comparator<ListenerEntry>() {
|
||||
|
@ -349,8 +355,8 @@ public class DsfSession
|
|||
Method[] allMethods = entry.getValue();
|
||||
List<Method> matchingMethods = new ArrayList<Method>();
|
||||
for (Method method : allMethods) {
|
||||
assert method.getParameterTypes().length > 0 : eventClass.getName() + "." + method.getName()
|
||||
+ " signature contains zero parameters";
|
||||
assert method.getParameterTypes().length > 0 : eventClass.getName() + "." + method.getName() //$NON-NLS-1$
|
||||
+ " signature contains zero parameters"; //$NON-NLS-1$
|
||||
if ( method.getParameterTypes()[0].isAssignableFrom(eventClass) ) {
|
||||
matchingMethods.add(method);
|
||||
}
|
||||
|
@ -368,13 +374,13 @@ public class DsfSession
|
|||
}
|
||||
catch (IllegalAccessException e) {
|
||||
DsfPlugin.getDefault().getLog().log(new Status(
|
||||
IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Security exception when calling a service event handler method", e));
|
||||
assert false : "IServiceEventListener.ServiceHandlerMethod method not accessible, is listener declared public?";
|
||||
IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Security exception when calling a service event handler method", e)); //$NON-NLS-1$
|
||||
assert false : "IServiceEventListener.ServiceHandlerMethod method not accessible, is listener declared public?"; //$NON-NLS-1$
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
DsfPlugin.getDefault().getLog().log(new Status(
|
||||
IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Invocation exception when calling a service event handler method", e));
|
||||
assert false : "Exception thrown by a IServiceEventListener.ServiceHandlerMethod method";
|
||||
IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Invocation exception when calling a service event handler method", e)); //$NON-NLS-1$
|
||||
assert false : "Exception thrown by a IServiceEventListener.ServiceHandlerMethod method"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -389,17 +395,17 @@ public class DsfSession
|
|||
if (method.isAnnotationPresent(DsfServiceEventHandler.class)) {
|
||||
Class<?>[] paramTypes = method.getParameterTypes();
|
||||
if (paramTypes.length > 2) {
|
||||
throw new IllegalArgumentException("ServiceEventHandler method has incorrect number of parameters");
|
||||
throw new IllegalArgumentException("ServiceEventHandler method has incorrect number of parameters"); //$NON-NLS-1$
|
||||
}
|
||||
retVal.add(method);
|
||||
}
|
||||
}
|
||||
} catch(SecurityException e) {
|
||||
throw new IllegalArgumentException("No permission to access ServiceEventHandler method");
|
||||
throw new IllegalArgumentException("No permission to access ServiceEventHandler method"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if (retVal.isEmpty()) {
|
||||
throw new IllegalArgumentException("No methods marked with @ServiceEventHandler in listener, is listener declared public?");
|
||||
throw new IllegalArgumentException("No methods marked with @ServiceEventHandler in listener, is listener declared public?"); //$NON-NLS-1$
|
||||
}
|
||||
return retVal.toArray(new Method[retVal.size()]);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public interface IDsfService {
|
|||
* Property name for the session-id of this service. This property should be set by
|
||||
* all DSF services when they are registered with OSGI service framework.
|
||||
*/
|
||||
final static String PROP_SESSION_ID = "org.eclipse.dd.dsf.service.IService.session_id";
|
||||
final static String PROP_SESSION_ID = "org.eclipse.dd.dsf.service.IService.session_id"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Error code indicating that the service is in a state which does not allow the
|
||||
|
@ -84,6 +84,7 @@ public interface IDsfService {
|
|||
/**
|
||||
* Returns the map of properties that this service was registered with.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
Dictionary getProperties();
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue