diff options
Diffstat (limited to 'plugins/org.eclipse.jem.proxy/proxy')
64 files changed, 0 insertions, 11664 deletions
diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/awt/IStandardAwtBeanProxyFactory.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/awt/IStandardAwtBeanProxyFactory.java deleted file mode 100644 index 00e894e57..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/awt/IStandardAwtBeanProxyFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.awt; -/* - - - */ - - -import org.eclipse.jem.internal.proxy.core.*; -import org.eclipse.jem.internal.proxy.core.IBeanProxyFactory; -/** - * The Standard awt bean proxy factory. - * This is the Interface that the desktop will talk - * to. - * Creation date: (12/3/99 11:52:09 AM) - * @author: Joe Winchester - */ -public interface IStandardAwtBeanProxyFactory extends IBeanProxyFactory { - public static final String REGISTRY_KEY = "standard-java.awt"; //$NON-NLS-1$ - -/** - * Return a new bean proxy for the dimension argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public IDimensionBeanProxy createDimensionBeanProxyWith(int width, int height); -/** - * Return a new bean proxy for the point argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public IPointBeanProxy createPointBeanProxyWith(int x, int y); -/** - * Return a new bean proxy for the rectangle argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public IRectangleBeanProxy createBeanProxyWith(int x, int y, int width, int height); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/awt/JavaStandardAwtBeanConstants.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/awt/JavaStandardAwtBeanConstants.java deleted file mode 100644 index 57cecb79b..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/awt/JavaStandardAwtBeanConstants.java +++ /dev/null @@ -1,254 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.awt; -/* - - - */ - - -import org.eclipse.jem.internal.proxy.core.*; - -/** - * Standard AWT Constants - * - * Use the static accessor method (getConstants()) to get the appropriate - * constants instance for the registry. This is done so that until the - * the constants are needed, they aren't registered. - * - * NOTE: Since everything in here just proxies, there is - * no need to have them separated by VM. That is why - * this in the Proxy package. - * - * This is final because this can't be extended. This specific one - * will be registered with the factory for this key. Any extensions - * must be done in their own constants and registry key. - * - * Creation date: (4/7/00 4:47:48 PM) - * @author: Administrator - */ -public final class JavaStandardAwtBeanConstants { - - public static final Object REGISTRY_KEY = new Object(); - - final boolean AWTLoaded; // AWT may not be available. So non-ui JVM's don't have AWT. - final boolean AWTRegistered; // AWT was registered to be used in this VM. It may be registered, but still not available. - - final IFieldProxy dimensionHeightProxy; - final IFieldProxy dimensionWidthProxy; - final IMethodProxy setDimensionSizeHWProxy; - final IMethodProxy setDimensionSizeDProxy; - - final IFieldProxy pointXProxy; - final IFieldProxy pointYProxy; - final IMethodProxy setPointLocationXYProxy; - final IMethodProxy setPointLocationPProxy; - - final IFieldProxy rectangleHeightProxy; - final IFieldProxy rectangleWidthProxy; - final IFieldProxy rectangleXProxy; - final IFieldProxy rectangleYProxy; - final IMethodProxy setRectangleSizeHWProxy; - final IMethodProxy setRectangleSizeDProxy; - final IMethodProxy setRectangleLocationXYProxy; - final IMethodProxy setRectangleLocationPProxy; - final IMethodProxy setRectangleBoundsXYHWProxy; - final IMethodProxy setRectangleBoundsRProxy; - -/** - * Get the constants instance for the specified registry. - */ -public static JavaStandardAwtBeanConstants getConstants(ProxyFactoryRegistry registry) { - JavaStandardAwtBeanConstants constants = (JavaStandardAwtBeanConstants) registry.getConstants(REGISTRY_KEY); - if (constants == null) - registry.registerConstants(REGISTRY_KEY, constants = new JavaStandardAwtBeanConstants(registry, registry.getBeanProxyFactoryExtension(IStandardAwtBeanProxyFactory.REGISTRY_KEY) != null)); - return constants; -} - - -public JavaStandardAwtBeanConstants(ProxyFactoryRegistry registry, boolean isRegistered) { - super(); - - AWTRegistered = isRegistered; - if (!AWTRegistered) { - AWTLoaded = false; - dimensionHeightProxy = dimensionWidthProxy = pointXProxy = pointYProxy = rectangleHeightProxy = rectangleWidthProxy = rectangleXProxy = rectangleYProxy = null; - setDimensionSizeHWProxy = setDimensionSizeDProxy = setPointLocationXYProxy = setPointLocationPProxy = setRectangleSizeHWProxy = setRectangleSizeDProxy = setRectangleLocationXYProxy = setRectangleLocationPProxy = setRectangleBoundsXYHWProxy = setRectangleBoundsRProxy = null; - return; - } - - IStandardBeanTypeProxyFactory typeFactory = registry.getBeanTypeProxyFactory(); - - IBeanTypeProxy dimensionTypeProxy = typeFactory.getBeanTypeProxy("java.awt.Dimension");//$NON-NLS-1$ - if (dimensionTypeProxy != null) { - // AWT is available. - AWTLoaded = true; - IBeanTypeProxy intTypeProxy = typeFactory.getBeanTypeProxy("int"); //$NON-NLS-1$ - - dimensionHeightProxy = dimensionTypeProxy.getFieldProxy("height");//$NON-NLS-1$ - dimensionWidthProxy = dimensionTypeProxy.getFieldProxy("width");//$NON-NLS-1$ - setDimensionSizeHWProxy = dimensionTypeProxy.getMethodProxy("setSize", new IBeanTypeProxy[] {intTypeProxy, intTypeProxy}); //$NON-NLS-1$ - setDimensionSizeDProxy = dimensionTypeProxy.getMethodProxy("setSize", new IBeanTypeProxy[] {dimensionTypeProxy}); //$NON-NLS-1$ - - IBeanTypeProxy pointTypeProxy = typeFactory.getBeanTypeProxy("java.awt.Point");//$NON-NLS-1$ - pointXProxy = pointTypeProxy.getFieldProxy("x");//$NON-NLS-1$ - pointYProxy = pointTypeProxy.getFieldProxy("y"); //$NON-NLS-1$ - setPointLocationXYProxy = pointTypeProxy.getMethodProxy("setLocation", new IBeanTypeProxy[] {intTypeProxy, intTypeProxy}); //$NON-NLS-1$ - setPointLocationPProxy = pointTypeProxy.getMethodProxy("setLocation", new IBeanTypeProxy[] {pointTypeProxy}); //$NON-NLS-1$ - - - IBeanTypeProxy rectangleTypeProxy = typeFactory.getBeanTypeProxy("java.awt.Rectangle");//$NON-NLS-1$ - rectangleHeightProxy = rectangleTypeProxy.getFieldProxy("height");//$NON-NLS-1$ - rectangleWidthProxy = rectangleTypeProxy.getFieldProxy("width");//$NON-NLS-1$ - rectangleXProxy = rectangleTypeProxy.getFieldProxy("x");//$NON-NLS-1$ - rectangleYProxy = rectangleTypeProxy.getFieldProxy("y");//$NON-NLS-1$ - setRectangleSizeHWProxy = rectangleTypeProxy.getMethodProxy("setSize", new IBeanTypeProxy[] {intTypeProxy, intTypeProxy}); //$NON-NLS-1$ - setRectangleSizeDProxy = rectangleTypeProxy.getMethodProxy("setSize", new IBeanTypeProxy[] {dimensionTypeProxy}); //$NON-NLS-1$ - setRectangleLocationXYProxy = rectangleTypeProxy.getMethodProxy("setLocation", new IBeanTypeProxy[] {intTypeProxy, intTypeProxy}); //$NON-NLS-1$ - setRectangleLocationPProxy = rectangleTypeProxy.getMethodProxy("setLocation", new IBeanTypeProxy[] {pointTypeProxy}); //$NON-NLS-1$ - setRectangleBoundsXYHWProxy = rectangleTypeProxy.getMethodProxy("setBounds", new IBeanTypeProxy[] {intTypeProxy, intTypeProxy, intTypeProxy, intTypeProxy}); //$NON-NLS-1$ - setRectangleBoundsRProxy = rectangleTypeProxy.getMethodProxy("setBounds", new IBeanTypeProxy[] {rectangleTypeProxy}); //$NON-NLS-1$ - } else { - AWTLoaded = false; - dimensionHeightProxy = dimensionWidthProxy = pointXProxy = pointYProxy = rectangleHeightProxy = rectangleWidthProxy = rectangleXProxy = rectangleYProxy = null; - setDimensionSizeHWProxy = setDimensionSizeDProxy = setPointLocationXYProxy = setPointLocationPProxy = setRectangleSizeHWProxy = setRectangleSizeDProxy = setRectangleLocationXYProxy = setRectangleLocationPProxy = setRectangleBoundsXYHWProxy = setRectangleBoundsRProxy = null; - } -} - -/** - * Answer if AWT is available. - */ -public boolean isAWTAvailable() { - return AWTLoaded; -} - -/** - * Answer if AWT was registered to be available. - */ -public boolean isAWTRegistered() { - return AWTRegistered; -} - - - -/** - * getDimensionHeightFieldProxy method comment. - */ -public IFieldProxy getDimensionHeightFieldProxy() { - return dimensionHeightProxy; -} -/** - * getDimensionWidthProxy method comment. - */ -public IFieldProxy getDimensionWidthFieldProxy() { - return dimensionWidthProxy; -} -/** - * getDimensionSetSizeWHProxy method comment. - */ -public IMethodProxy getDimensionSetSizeHWProxy() { - return setDimensionSizeHWProxy; -} -/** - * getDimensionSetSizeDProxy method comment. - */ -public IMethodProxy getDimensionSetSizeDProxy() { - return setDimensionSizeDProxy; -} - -/** - * getPointXFieldProxy method comment. - */ -public IFieldProxy getPointXFieldProxy() { - return pointXProxy; -} -/** - * getPointYFieldProxy method comment. - */ -public IFieldProxy getPointYFieldProxy() { - return pointYProxy; -} -/** - * getPointSetLocationXYProxy method comment. - */ -public IMethodProxy getPointSetLocationXYProxy() { - return setPointLocationXYProxy; -} -/** - * getPointSetLocationPProxy method comment. - */ -public IMethodProxy getPointSetLocationPProxy() { - return setPointLocationPProxy; -} -/** - * getRectangleHeightFieldProxy method comment. - */ -public IFieldProxy getRectangleHeightFieldProxy() { - return rectangleHeightProxy; -} -/** - * getRectangleWidthFieldProxy method comment. - */ -public IFieldProxy getRectangleWidthFieldProxy() { - return rectangleWidthProxy; -} -/** - * getRectangleXFieldProxy method comment. - */ -public IFieldProxy getRectangleXFieldProxy() { - return rectangleXProxy; -} -/** - * getRectangleYFieldProxy method comment. - */ -public IFieldProxy getRectangleYFieldProxy() { - return rectangleYProxy; -} -/** - * getRectangleSetSizeWHProxy method comment. - */ -public IMethodProxy getRectangleSetSizeHWProxy() { - return setRectangleSizeHWProxy; -} -/** - * getRectangleSetSizeDProxy method comment. - */ -public IMethodProxy getRectangleSetSizeDProxy() { - return setRectangleSizeDProxy; -} -/** - * getRectangleSetLocationXYProxy method comment. - */ -public IMethodProxy getRectangleSetLocationXYProxy() { - return setRectangleLocationXYProxy; -} -/** - * getRectangleSetLocationPProxy method comment. - */ -public IMethodProxy getRectangleSetLocationPProxy() { - return setRectangleLocationPProxy; -} - -/** - * getRectangleSetBoundsXYHWProxy method comment. - */ -public IMethodProxy getRectangleSetBoundsXYHWProxy() { - return setRectangleBoundsXYHWProxy; -} -/** - * getRectangleSetBoundsRProxy method comment. - */ -public IMethodProxy getRectangleSetBoundsRProxy() { - return setRectangleBoundsRProxy; -} - - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/BaseProxyFactoryRegistry.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/BaseProxyFactoryRegistry.java deleted file mode 100644 index ba972293b..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/BaseProxyFactoryRegistry.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -/** - * This is the Base Registry that all implementations should subclass. - * <p> - * It is not meant to be used by customers. It provides public functions only for access of individual implementations. - * Customers should only access {@link org.eclipse.jem.internal.proxy.core.ProxyFactoryRegistry}. - * - * @since 1.1.0 - */ -public abstract class BaseProxyFactoryRegistry extends ProxyFactoryRegistry { - - private final String registryTypeID; - - /** - * Construct with registry type ID. The type id should be provided by - * each implementation. This will be used to provide specific type - * registrations through contributions. - * - * @param registryTypeID - * - * @since 1.1.0 - */ - protected BaseProxyFactoryRegistry(String registryTypeID) { - super(); - this.registryTypeID = registryTypeID; - } - - /** - * Return the reqistry type id. - * @return - * - * @since 1.1.0 - */ - public String getRegistryTypeID() { - return registryTypeID; - } - - /** - Register the current registered bean proxy factory to be used for creating IBeanProxy instances - */ - public void registerBeanProxyFactory(IStandardBeanProxyFactory aStandardFactory) { - fCurrentStandardBeanProxyFactory = aStandardFactory; - } - - /** - Register a factory to be used for creating IBeanProxy instances - */ - public void registerBeanProxyFactory(String packageName, IBeanProxyFactory aFactory) { - fRegisteredExtensionBeanProxyFactories.put(packageName, aFactory); - } - - /** - Register the current registered bean type proxy factory to be used for creating IBeanTypeProxy instances - */ - public void registerBeanTypeProxyFactory(IStandardBeanTypeProxyFactory aStandardFactory) { - fCurrentStandardBeanTypeProxyFactory = aStandardFactory; - } - - /** - Register a factory to be used for creating IBeanTypeProxy instances - */ - public void registerBeanTypeProxyFactory(String packageName, IBeanTypeProxyFactory aFactory) { - fRegisteredExtensionBeanTypeProxyFactories.put(packageName, aFactory); - } - - /** - * Set the Method Proxy Factory for this VM. - * Creation date: (3/13/00 10:58:19 AM) - */ - public void registerMethodProxyFactory(IMethodProxyFactory newMethodProxyFactory) { - fMethodProxyFactory = newMethodProxyFactory; - } - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/CollectionBeanProxyWrapper.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/CollectionBeanProxyWrapper.java deleted file mode 100644 index 51c415882..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/CollectionBeanProxyWrapper.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - -import org.eclipse.core.runtime.*; -/** - * This is a wrapper for an java.util.Collection proxy. - * It provides the collection methods to interface to - * the proxy. - */ - -public class CollectionBeanProxyWrapper { - protected final IBeanProxy fCollection; - protected final JavaStandardBeanProxyConstants fConstants; - - /** - * Construct with the collection. - */ - public CollectionBeanProxyWrapper(IBeanProxy aCollectionProxy) { - if (!aCollectionProxy.getTypeProxy().isKindOf(aCollectionProxy.getProxyFactoryRegistry().getBeanTypeProxyFactory().getBeanTypeProxy("java.util.Collection"))) //$NON-NLS-1$ - throw new ClassCastException(java.text.MessageFormat.format(ProxyMessages.ClassCast_EXC__IncorrectType, new Object[] {aCollectionProxy.getTypeProxy().getTypeName(), "java.util.Collection"})); //$NON-NLS-1$ - else - fCollection = aCollectionProxy; - - fConstants = JavaStandardBeanProxyConstants.getConstants(aCollectionProxy.getProxyFactoryRegistry()); - } - - /** - * Answer the collection proxy that this is wrappering. - */ - public IBeanProxy getBeanProxy() { - return fCollection; - } - - /** - * equals - Pass it on to the proxy to handle this. - */ - public boolean equals(Object object) { - return fCollection.equals(object); - } - - /** - * hashCode - Pass it on to the proxy to handle this. - */ - public int hashCode() { - return fCollection.hashCode(); - } - - /** - * Collection accessors - */ - public boolean add(IBeanProxy object) throws ThrowableProxy { - return ((IBooleanBeanProxy) fConstants.getCollectionAdd().invoke(fCollection, object)).booleanValue(); - } - public boolean addAll(IBeanProxy collection) throws ThrowableProxy { - return ((IBooleanBeanProxy) fConstants.getCollectionAddAll().invoke(fCollection, collection)).booleanValue(); - } - public void clear() throws ThrowableProxy { - fConstants.getCollectionClear().invoke(fCollection); - } - public boolean contains(IBeanProxy object) { - try { - return ((IBooleanBeanProxy) fConstants.getCollectionContains().invoke(fCollection, object)).booleanValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return false; - } - } - public boolean containsAll(IBeanProxy collection) { - try { - return ((IBooleanBeanProxy) fConstants.getCollectionContainsAll().invoke(fCollection, collection)).booleanValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return false; - } - } - public boolean isEmpty() { - try { - return ((IBooleanBeanProxy) fConstants.getCollectionIsEmpty().invoke(fCollection)).booleanValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return true; - } - } - public IteratorBeanProxyWrapper iterator() { - try { - IBeanProxy itr = fConstants.getCollectionIterator().invoke(fCollection); - if (itr != null) - return new IteratorBeanProxyWrapper(itr); - else - return null; - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return null; - } - } - public boolean remove(IBeanProxy object) throws ThrowableProxy { - return ((IBooleanBeanProxy) fConstants.getCollectionRemove().invoke(fCollection, object)).booleanValue(); - } - public boolean removeAll(IBeanProxy collection) throws ThrowableProxy { - return ((IBooleanBeanProxy) fConstants.getCollectionRemoveAll().invoke(fCollection, collection)).booleanValue(); - } - public boolean retainAll(IBeanProxy collection) throws ThrowableProxy { - return ((IBooleanBeanProxy) fConstants.getCollectionRetainAll().invoke(fCollection, collection)).booleanValue(); - } - public int size() { - try { - return ((IIntegerBeanProxy) fConstants.getCollectionSize().invoke(fCollection)).intValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return 0; - } - } - public IArrayBeanProxy toArray() throws ThrowableProxy { - return (IArrayBeanProxy) fConstants.getCollectionToArray().invoke(fCollection); - } - public IArrayBeanProxy toArray(IArrayBeanProxy array) throws ThrowableProxy { - return (IArrayBeanProxy) fConstants.getCollectionToArrayWithArray().invoke(fCollection, array); - } -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ConfigurationContributorAdapter.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ConfigurationContributorAdapter.java deleted file mode 100644 index 570c72bd4..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ConfigurationContributorAdapter.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; - -/** - * This is an implementation of IConfigurationContributor that does nothing. It - * can be subclassed to provide specific overrides. - * @since 1.0.0 - */ -public class ConfigurationContributorAdapter implements IConfigurationContributor { - - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributor#initialize(org.eclipse.jem.internal.proxy.core.IConfigurationContributionInfo) - */ - public void initialize(IConfigurationContributionInfo info) { - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributor#contributeClasspaths(org.eclipse.jem.internal.proxy.core.IConfigurationContributionController) - */ - public void contributeClasspaths(IConfigurationContributionController controller) throws CoreException { - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributor#contributeToConfiguration(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - public void contributeToConfiguration(ILaunchConfigurationWorkingCopy config) throws CoreException { - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributor#contributeToRegistry(org.eclipse.jem.internal.proxy.core.ProxyFactoryRegistry) - */ - public void contributeToRegistry(ProxyFactoryRegistry registry) { - } -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ContainerPathContributionMapping.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ContainerPathContributionMapping.java deleted file mode 100644 index 1f4ca36cc..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ContainerPathContributionMapping.java +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; - -import java.lang.reflect.Array; -import java.util.*; -import java.util.regex.Pattern; - - -/** - * Mapping of container paths (Regular expressions) to configuration elements. - * <p> - * It can be instantiated by clients that need to built up a subset of the mapping from the - * normal mapping done by {@link ProxyPlugin#getPluginExtensions(String)}. - * <p> - * To build one up separately clients would: - * <pre><code> - * ContainerPathContributionMapping mapping = new ContainerPathContributionMapping(contributionType); - * mapping.addContribution(containerid, pattern, contribution); - * ... - * mapping.finalizeMapping(); - * </code></pre> - * - * @since 1.2.0 - */ -public class ContainerPathContributionMapping { - - /** - * Used in {@link ContainerPathContributionMapping#containerIdToContributions} as the value of the map. - * This contains a Pattern for a container path to match against to see if the contribution - * should be used. - * <p> - * Normally it would be better to use {@link ContainerPathContributionMapping#getContributors(String, String[])} - * to get all of the contributors for all of the paths of the same container id. - * - * @since 1.2.0 - */ - public static class ContainerContributionEntry { - - private final Object contribution; - private final Pattern containerPathPattern; - - public ContainerContributionEntry(Object contribution, Pattern containerPathPattern) { - this.contribution = contribution; - this.containerPathPattern = containerPathPattern; - } - - - /** - * @return Returns the contribution. - * - * @since 1.2.0 - */ - public final Object getContribution() { - return contribution; - } - - - /** - * @return Returns the container pattern for matching. - * - * @since 1.2.0 - */ - public final Pattern getContainerPathPattern() { - return containerPathPattern; - } - } - - - /** - * Map of container ids (String, first segment of container path) to {@link ContainerContributionEntry[]}. - * <p> - * Normally it would be better to use {@link #getContributors(String, String[])} - * to get all of the contributors for all of the paths of the same container id. - * - * @since 1.2.0 - */ - public Map containerIdToContributions = Collections.EMPTY_MAP; - - // TODO When 1.5, this can go away. - private final Class contributionType; - - /** - * Create with contribution type (i.e. the array type returned from {@link #getContributors(String, String[])}. - * <p> - * TODO This will go away with 1.5 because this will be templated. - * - * @param type - * - * - * @since 1.2.0 - */ - public ContainerPathContributionMapping(Class type) { - contributionType = type; - } - - - /** - * Get the unique array of configuration elements (no duplicates) for the given container id, and - * the set of container paths for that container id. For example, "SWT_CONTAINER" as containerID and - * {"/SWT_CONTAINER/", "/SWT_CONTAINER/PDE/JFACE"} for container paths. This will then return configuration elements - * that match these two paths in the container attribute of the configuration element. The container attribute - * is a regular expression. For example "SWT_CONTAINER" will match both "/SWT_CONTAINER/" and "/SWT_CONTAINER/PDE/JFACE" - * while "SWT_CONTAINER/.* /JFACE" will match "/SWT_CONTAINER/PDE/JFACE". (Note it is actually no space between the "*" and "/" but java comment syntax won't allow it.) - * @param containerId id of all the containers in the list of paths (the first segment of all of the paths). - * @param containerPaths array of all of the paths to look for contributions for. - * @return array of configuration elements for the given list of paths. They will be in order declared within a plugin within plugin order. - * - * @since 1.2.0 - */ - public Object[] getContributors(String containerId, String[] containerPaths) { - ContainerContributionEntry[] bundleContributions = (ContainerContributionEntry[]) containerIdToContributions.get(containerId); - if (bundleContributions == null) - return (Object[]) Array.newInstance(contributionType, 0); - List contributions = new ArrayList(); - // Patterns that have been tested. Key is a pattern, value is Boolean. true if this pattern matched any of the container paths. - // This way a pattern will only be tested once for the list of paths. If the pattern is found the list again we will know if it - // should be selected or not. - // The bundleContributions are in order declared within each plugin within plugin order. - Map testedPatterns = new HashMap(); - for (int i = 0; i < bundleContributions.length; i++) { - Boolean tested = (Boolean) testedPatterns.get(bundleContributions[i].getContainerPathPattern()); - if (tested == null) { - // Need to test it. - // Run through container paths and see if any match. - tested = Boolean.FALSE; - Pattern pattern = bundleContributions[i].getContainerPathPattern(); - for (int j = 0; j < containerPaths.length; j++) { - if (pattern.matcher(containerPaths[j]).matches()) { - tested = Boolean.TRUE; - break; - } - } - testedPatterns.put(pattern, tested); - } - if (tested.booleanValue()) - contributions.add(bundleContributions[i].getContribution()); - } - return contributions.toArray((Object[]) Array.newInstance(contributionType, contributions.size())); - } - - /** - * Add contribution to mapping. This is not normally needed by clients unless the client needs to - * build up a different container path mapping than the one normally created by {@link ProxyPlugin#processContributionExtensionPoint(String)}. - * <p> - * After all contributions have been added {@link #finalizeMapping()} must be called. If this - * is not called then {@link #getContributors(String, String[])} will fail with exceptions. - - * @param containerId - * @param pattern - * @param contribution - * - * @since 1.2.0 - */ - public void addContribution(String containerId, Pattern pattern, Object contribution) { - if (containerIdToContributions == Collections.EMPTY_MAP) - containerIdToContributions = new HashMap(); // This is first call to add something. - // We will build as list, but then change to array when done. - Object contributions = containerIdToContributions.get(containerId); - if (contributions == null) { - contributions = new ArrayList(1); - containerIdToContributions.put(containerId, contributions); - } else if (!(contributions instanceof List)) { - // It must be an array, so convert back to list so that we can add to it. - List oldContributions = Arrays.asList((Object[]) contribution); - contributions = new ArrayList(oldContributions.size()); - ((List) contributions).addAll(oldContributions); - containerIdToContributions.put(containerId, contributions); - } - ((List) contributions).add(new ContainerContributionEntry(contribution, pattern)); - - } - - /** - * Finalize the mapping. This is called when clients are done with all {@link #addContribution(String)}. - * It takes the mapping from an internal format that allowed for quicker building into the final format. - * - * - * @since 1.2.0 - */ - public void finalizeMapping() { - for (Iterator iter = containerIdToContributions.entrySet().iterator(); iter.hasNext();) { - Map.Entry entry = (Map.Entry) iter.next(); - if (entry.getValue() instanceof List) - entry.setValue(((List) entry.getValue()).toArray(new ContainerContributionEntry[((List) entry.getValue()).size()])); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ContributorExtensionPointInfo.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ContributorExtensionPointInfo.java deleted file mode 100644 index 61839e0a7..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ContributorExtensionPointInfo.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; - -import java.util.Map; - - -/** - * Result from {@link ProxyPlugin#processContributionExtensionPoint(String)} - * - * @since 1.0.0 - */ -public class ContributorExtensionPointInfo { - - /** - * Contributions that are based upon container paths that are built up from - * the extension point. - * - * @since 1.2.0 - */ - public ContainerPathContributionMapping containerPathContributions; - - ContributorExtensionPointInfo() { - // Not meant to be instantiated or subclassed outside of ProxyPlugin. - } - - /** - * Map of plugin ids (String) to contributions (IConfigurationElement[]) that was found with that id. For each plugin, - * the contributions will be listed in plugin prereq order. - */ - public Map pluginToContributions; - - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/EnumerationBeanProxyWrapper.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/EnumerationBeanProxyWrapper.java deleted file mode 100644 index feb900fc5..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/EnumerationBeanProxyWrapper.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -/** - * This is a wrapper for an java.util.Enumeration proxy. - * It provides the Enumeration methods to interface to - * the proxy. - */ - -public class EnumerationBeanProxyWrapper { - protected final IBeanProxy fEnumeration; - protected final JavaStandardBeanProxyConstants fConstants; - - /** - * Construct with the collection. - */ - public EnumerationBeanProxyWrapper(IBeanProxy anEnumerationProxy) { - - fEnumeration = anEnumerationProxy; - - fConstants = JavaStandardBeanProxyConstants.getConstants(anEnumerationProxy.getProxyFactoryRegistry()); - } - - /** - * Answer the iterator proxy that this is wrappering. - */ - public IBeanProxy getBeanProxy() { - return fEnumeration; - } - - /** - * equals - Pass it on to the proxy to handle this. - */ - public boolean equals(Object object) { - return fEnumeration.equals(object); - } - - /** - * hashCode - Pass it on to the proxy to handle this. - */ - public int hashCode() { - return fEnumeration.hashCode(); - } - - /** - * Enumeration accessors - */ - public boolean hasMoreElements() { - try { - return ((IBooleanBeanProxy) fConstants.getEnumerationHasMoreElements().invoke(fEnumeration)).booleanValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return false; - } - } - public IBeanProxy nextElement() throws ThrowableProxy { - return fConstants.getEnumerationNextElement().invoke(fEnumeration); - } - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/Expression.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/Expression.java deleted file mode 100644 index 99645a746..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/Expression.java +++ /dev/null @@ -1,2546 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import java.text.MessageFormat; -import java.util.*; - -import org.eclipse.jem.internal.proxy.initParser.tree.*; - -/** - * This is implementation of IExpression. It encapsulates much of the processing required - * into a common form that will be turned into simple push/pop/evaluate type of interaction with the - * actual other side. All registry specific implementations of IExpression must subclass this class. - * <p> - * It will maintain a stack of the expressions. As the expressions come in they will be stacked if not - * able to be executed immediately. The expressions come to this class in an outside to inside order, - * but they need to be processed in an inside-out order instead. - * <p> - * Subclasses will be used for the different types of proxy interfaces. The abstract methods will - * then be the simple interface. - * <p> - * It is not meant for subclasses to override the actual create expression methods because the processing the stack - * is very sensitive and must execute in the proper sequence. So the create methods are final for this reason. - * <p> - * This class is not thread-safe. - * <p> - * This class also has API of its own and can be used by customers for advanced usage. Those advanced API are - * listed on each method as to whether it is customer API or implementers API (i.e. API for implementers of - * expression subclasses to use). - * - * - * @since 1.0.0 - */ -public abstract class Expression implements IExpression { - - /* - * We have stack here, but rather than create a class that does the - * stack protocol, will simply have some private methods to do - * the same thing for the stack. (Note: Can't use java.util.Stack - * because that is a synchronized class, and don't want the overhead). - * - * The purpose of the stack is to stack up expressions that have not yet - * been evaluated. - * - * Each expression type will control the content of what it pushes and pops. - * The expression type will be the last thing it pushes so that on popping - * we know what kind of expression is now completed and ready for evaluation. - */ - private ArrayList controlStack = new ArrayList(30); - - protected final ProxyFactoryRegistry registry; - protected final IStandardBeanProxyFactory beanProxyFactory; - protected Boolean traceFlag; - - /** - * Answer whether trace has been explicitly set. - * This is not in the IExpression interface because it is for advanced users. - * @return - * - * @since 1.1.0 - */ - public boolean isTraceSet() { - return traceFlag != null; - } - - /** - * Answer if trace is on. If not explicitly set this will answer false. - * Use {@link Expression#isTraceSet()} first to determine if this - * should be called or not. - * This is not in the IExpression interface because it is for advanced users. - * @return - * - * @since 1.1.0 - */ - public boolean isTrace() { - return traceFlag != null ? traceFlag.booleanValue() : false; - } - - /** - * Explicitly set the trace flag. This will only be honoured before any - * expressions have been created. After that this will be ignored. - * The trace is initially set to use default. Once set it cannot be unset. - * This is not in the IExpression interface because it is for advanced users. - * @param trace - * - * @since 1.1.0 - */ - public void setTrace(boolean trace) { - traceFlag = Boolean.valueOf(trace); - } - - /** - * Push an object onto the control stack. - * - * @param o - * - * @since 1.0.0 - */ - protected final void push(Object o) { - controlStack.add(o); - } - - /** - * Pop an object off of the control stack - * @return - * - * @since 1.0.0 - */ - protected final Object pop() { - return controlStack.remove(controlStack.size()-1); - } - - /** - * Peek at an object from the control stack. <code>fromTop</code> is how far from the top of the stack to look. - * If it one, then it is the top entry, two is the next one down. Zero is an invalid value for the parameter. - * @param fromTop How far from the top to peek. <code>1</code> is the top, not zero. - * @return - * - * @since 1.0.0 - */ - protected final Object peek(int fromTop) { - // 1 means the top, 2 is the next one down. - return controlStack.get(controlStack.size()-fromTop); - } - - /* - * Expression type constants. - */ - - /* - * ARRAY ACCESS expression. - * The expression stack will have: - * IExpression.ARRAYACCESS_ARRAY - * IExpression.ARRAYACCESS_INDEX (for 1 to n times depending on index count) - * PROCESS_EXPRESSION - * - * The value stack will have - * ARRAYACCESS - * Integer(index count) - */ - private static final Integer ARRAYACCESS_INDEX_1 = new Integer(1); // Use in normal case of one index count. Saves object creation. - - /* - * ARRAY CREATION expression. - * The expression stack will have: - * ARRAYCREATION_INITIALIZER - if hasInitializer - * IExpression.ARRAYCREATION_DIMENSION (for 0 to n times depending on dimension count) - * PROCESS_EXPRESSION - * - * The value stack will have - * ARRAYCREATION - * type (either a string representing the type, or an IBeanProxyType representing the type). - * Integer(dimension count) (if zero then there is an initializer) - * - * - * Note: Array Initializer works with this in that it will peek into the value stack two entries down - * to find the type of array it should be creating. - */ - private static final Integer ARRAY_CREATION_DIMENSION_1 = new Integer(1); // Use in normal case of one dimension. Save object creation. - private static final Integer ARRAY_CREATION_DIMENSION_0 = new Integer(0); // Use in normal case of initializer. Save object creation. - private static final ForExpression ARRAY_INITIALIZER = new ExpressionEnum(Integer.MIN_VALUE+1, "Array Initializer Internal"); //$NON-NLS-1$ - - /* - * ARRAY INITIALIZER expression - * The expression stack will have: - * IExpression.ARRAYINITIALIZER_EXPRESSION (for n times depending on number of expressions count) - * PROCESS_EXPRESSION - * - * The value stack will have - * ARRAYINITIALIZER - * type (either a string representing the type, or an IBeanProxyType representing the type). - * I.e. if array being created is int[][], the value pushed here will be int[]. This is because when created - * the array will wind up with int[expressioncount][] in the end. - * Integer (expression count) - * - * Note: Imbedded Array Initializers works with this in that it will peek into the value stack two entries down - * to find the type of array it should be creating. - */ - private static final Integer ARRAYINITIALIZER_COUNT_0 = new Integer(0); // Use in normal case of empty array. Save object creation. - private static final Integer ARRAYINITIALIZER_COUNT_1 = new Integer(1); // Use in normal case of one element array. Save object creation. - private static final Integer ARRAYINITIALIZER_COUNT_2 = new Integer(2); // Use in normal case of two element array. Save object creation. - - /* - * CAST expression. - * The expression stack will have: - * IExpression.CAST_EXPRESSION - * PROCESS_EXPRESSION - * - * The value stack will have: - * CAST - * type (either a string representing the type, or an IBeanProxyType representing the type). - */ - - /* - * CLASS INSTANCE CREATION expression. - * The expression stack will have: - * IExpression.CLASSINSTANCECREATION_ARGUMENT (for 0 to n times depending on argument count) - * PROCESS_EXPRESSION - * - * The value stack will have - * CLASSINSTANCECREATION - * type (either a string representing the type, or an IBeanProxyType representing the type). - * Integer(argument count) - * - * - * Note: Array Initializer works with this in that it will peek into the value stack two entries down - * to find the type of array it should be creating. - */ - private static final Integer CLASS_INSTANCE_CREATION_ARGUMENTS_1 = new Integer(1); // Use in normal case of one argument. Save object creation. - private static final Integer CLASS_INSTANCE_CREATION_ARGUMENTS_0 = new Integer(0); // Use in normal case of no arguments (default ctor). Save object creation. - - /* - * CONDITIONAL expression. - * Since this can cause skipping of expressions (e.g. if condition is false, then the true condition should not be evaluated), - * we need to have a process expression and process call to the other side for each expression so that it can - * determine if it should be ignored or not. - * - * The expression stack will have: - * IExpression.CONDITIONAL_CONDITION - * PROCESS_EXPRESSION - * IExpression.CONDITIONAL_TRUE - * PROCESS_EXPRESSION - * IExpression.CONDITIONAL_FALSE - * PROCESS_EXPRESSION - * - * The value stack will have: - * CONDITIONAL - * CONDITIONAL_CONDITION - * CONDITIONAL - * CONDITIONAL_TRUE - * CONDITIONAL - * CONDITIONAL_FALSE - * - */ - - /* - * PREFIX expression. - * The expression stack will have: - * IExpression.PREFIX_OPERAND - * PROCESS_EXPRESSION - * - * The value stack will have: - * PREFIX - * operator (using Integer prefix operator constants defined here) - */ - - /* - * INFIX expression. - * Since two types of infix operators (conditional and AND or) can cause skipping of expressions (e.g. once - * conditional and sees a false expression, the rest of the expressions are skipped and should not be evaluated), - * we need to have a process expression and process call to the other side for each expression so that it can - * determine if it should be ignored or not. - * - * The expression stack will have: - * IExpression.INFIX_LEFT - * PROCESS_EXPRESSION - * IExpression.INFIX_RIGHT - * PROCESS_EXPRESSION - * (for 0 to n times depending upon extended count) - * IExpression.INFIX_EXTENDED - * PROCESS_EXPRESSION - * - * The value stack will have: - * INFIX - * operator (using Integer infix operator constants defined here) - * IN_LEFT - * (for (extendedCount) times) This will cover the right one and all but last extended - * INFIX - * operator (using Integer infix operator constants defined here) - * IN_OTHER - * INFIX - * operator (using Integer infix operator constants defined here) - * IN_LAST (this is covers either the right one if no extended, or the last extended) - */ - - /* - * INSTANCEOF expression. - * The expression stack will have: - * IExpression.INSTANCEOF_EXPRESSION - * PROCESS_EXPRESSION - * - * The value stack will have: - * INSTANCEOF - * type (either a string representing the type, or an IBeanProxyType representing the type). - */ - - /* - * Field access expression. - * The expression stack will have: - * IExpression.FIELD_RECEIVER (if hasReceiver is true) - * PROCESS_EXPRESSION - * - * The value stack will have: - * FIELDACCESS - * name (the name of the field) - * Boolean (true if has receiver) - */ - - /* - * Method invocation expression. - * The expression stack will have: - * IExpression.METHOD_RECEIVER (if hasReceiver is true) - * IExpression.METHOD_ARGUMENT (0 to n times for how many arguments). - * PROCESS_EXPRESSION - * - * The value stack will have: - * METHODINVOCATION - * name (the name of the method) - * Boolean (true if has receiver) - * argCount (the number of arguments). - */ - private static final Integer METHOD_ARGUMENTS_1 = new Integer(1); // Use in normal case of one argument. Save object creation. - private static final Integer METHOD_ARGUMENTS_0 = new Integer(0); // Use in normal case of no arguments. Save object creation. - - - /* - * Assignment expression - * The expression stack will have: - * IExpression.ASSIGNMENT_RIGHT - * IExpression.ASSIGNMENT_LEFT - * PROCESS_EXPRESSION - * - * The value stack will have: - * ASSIGNMENT - * left expression (variable reference) - * right expression - */ - - /* - * Assignment proxy expression - * The expression stack will have: - * IExpression.ASSIGNMENT_RIGHT - * PROCESS_EXPRESSION - * - * The value stack will have: - * ASSIGNMENT_PROXY - * expression proxy (an expression proxy) - */ - - /* - * Next valid for expression stack. This is kept as a stack also. - * As the expressions come in, the appropriate order (in reverse) - * of expression types will be pushed, and then popped as they - * come in. - * - * Since we can't have an array list of ints, will simulate the - * stack here. - */ - private ForExpression[] nextForExpressionStack = new ForExpression[30]; - private int nextForExpressionStackPos = -1; // Position of top entry in stack. - private boolean expressionValid = true; // Is the expression currently valid. - private String invalidMsg = null; // Msg for being invalid if default msg not sufficient. - private List expressionProxies; // List of expression proxies. The index of the proxy is its id. This list must never shrink in size. - - // A MarkEntry. To allow restore in case of error. - private static class MarkEntry { - public int markID; - public int controlStackPos; // Position of control stack at time of mark. - public int nextExpressionStackPos; // Position of nextForExpression stack at time of mark. - public int expressionProxiesPos; // Position of expressionProxies list at time of mark. - } - - private int highestMarkID = 0; // Next mark id. '0' is invalid, as in no marks. This is incremented for each new mark. Never decremented. - private MarkEntry currentMarkEntry; // Just a convienence to the current mark entry so no need to look into the list every time. - private List markEntries; // Stack of mark entries. - - // This class is here so we can add our special internal ForExpression: PROCESS_EXPRESSION. These are never used outside Expression. - private static class ExpressionEnum extends ForExpression { - - public ExpressionEnum(int value, String name) { - super(value, name); - } - - } - - // This is pushed onto the next expression stack, and when it is popped, then the expression is complete and ready to be pushed to the proxy side. - private static final ForExpression PROCESS_EXPRESSION = new ExpressionEnum(Integer.MIN_VALUE, "Process Expression"); //$NON-NLS-1$ - - // This is pushed onto the next expression stack for end block and will test if this there to make sure that it is being called correctly. - private static final ForExpression BLOCKEND_EXPRESSION = new ExpressionEnum(PROCESS_EXPRESSION.getValue()-2, "End Block Expression"); //$NON-NLS-1$ - - // This is pushed onto the next expression stack for end try and will test if this there to make sure that it is being called correctly. - private static final ForExpression TRYEND_EXPRESSION = new ExpressionEnum(BLOCKEND_EXPRESSION.getValue()-1, "End Try Expression"); //$NON-NLS-1$ - - // This is pushed onto the next expression stack for catch and will test if this there to make sure that it is being called correctly. - private static final ForExpression TRYCATCH_EXPRESSION = new ExpressionEnum(TRYEND_EXPRESSION.getValue()-1, "Catch Expression"); //$NON-NLS-1$ - - - // This is pushed onto the next expression stack for begin thread transfer and will test if this there to make sure that it is being called correctly. - private static final ForExpression THREADTRANSFER_EXPRESSION = new ExpressionEnum(TRYCATCH_EXPRESSION.getValue()-1, "Catch Expression"); //$NON-NLS-1$ - - // This is pushed onto the next expression stack for end subexpression and will test if this there to make sure that it is being called correctly. - private static final ForExpression SUBEXPRESSIONEND_EXPRESSION = new ExpressionEnum(THREADTRANSFER_EXPRESSION.getValue()-2, "End Subexpression"); //$NON-NLS-1$ - - /** - * Check the for expression, and if legal, set to the next valid for expression type, - * if it can. If the stack entry is ROOTEXPRESSION, and the forExpression is ROOTEXPRESSION, - * then the expression is allowed, but it is not popped. It must be popped later when appropriate. - * <p> - * This is for "block" expressions. We don't want to pop down the stack passed the ROOTEXPRESSION - * that got added by the create block until we get an end block. That allows root expressions to - * be added to the block without the stack popping up past the block start in the stack. - * - * @param forExpression - * @throws IllegalStateException - * - * @since 1.0.0 - */ - protected final void checkForExpression(ForExpression forExpression) throws IllegalStateException { - if (expressionValid) { - if (nextForExpressionStackPos == -1) - if (forExpression == ForExpression.ROOTEXPRESSION) - return; // valid. We are at the root (i.e. nothing is waiting). - else - ; // invalid. drop through - else if (nextForExpressionStack[nextForExpressionStackPos] == forExpression) { - // Valid, either the root expression matched (We don't implicitly pop those. That needs to be done explicitly). - // Or we matched non-root, those will be popped. - if (forExpression != ForExpression.ROOTEXPRESSION) { - popForExpression(); // Pop the stack since stack not a root expression. - } - return; - } - } else { - String expMsg = invalidMsg != null ? MessageFormat.format(ProxyMessages.Expression_InInvalidStateDueTo_EXC_, new Object[] {invalidMsg}) : ProxyMessages.Expression_InInvalidState_EXC_; - throw new IllegalStateException(expMsg); - } - - // If we got here, then invalid. - ForExpression expected = nextForExpressionStackPos >= 0 ? nextForExpressionStack[nextForExpressionStackPos] : ForExpression.ROOTEXPRESSION; - expressionValid = false; - throw new IllegalStateException(MessageFormat.format(ProxyMessages.Expression_TypeSentInInvalidOrder_EXC_, new Object[] {forExpression, expected})); - } - - /** - * Pop the top for expression, whatever it is. - * @throws IllegalStateException thrown if try to pop through through the current mark entry. The endMark is the only one who can do this. - * @since 1.1.0 - */ - protected final void popForExpression() throws IllegalStateException { - if (expressionValid && nextForExpressionStackPos >= 0) { - nextForExpressionStackPos--; - if (currentMarkEntry != null && nextForExpressionStackPos < currentMarkEntry.nextExpressionStackPos) { - nextForExpressionStackPos++; // Restore to what it was - throwInvalidMarkNesting(); - } - } - } - - /* - * @throws IllegalStateException - * - * @since 1.1.0 - */ - private void throwInvalidMarkNesting() throws IllegalStateException { - expressionValid = false; - throw new IllegalStateException(MessageFormat.format(ProxyMessages.Expression_InvalidMarkNesting, new Object[] {new Integer(currentMarkEntry != null ? currentMarkEntry.markID : 0)})); - } - - /** - * Peek into the for expression stack to see if the top entry is the passed in value. It will - * not pop the stack nor throw any exceptions. - * - * @param forExpression The top expression flag will be compared against this value. - * @return <code>true</code> if the top expression equals the parameter passed in. - * - * @since 1.0.0 - */ - protected final boolean peekForExpression(ForExpression forExpression) { - if (expressionValid) { - if (nextForExpressionStackPos == -1) - if (forExpression == ForExpression.ROOTEXPRESSION) - return true; // valid. We are at the root (i.e. nothing is waiting). - else - ; // invalid. drop through - else if (nextForExpressionStack[nextForExpressionStackPos] == forExpression) - return true; // Valid, the top expression matched. - } - return false; - } - - /** - * Mark this expression as now invalid. - */ - protected final void markInvalid() { - expressionValid = false; - } - - /** - * Mark this expression as now invalid, but supply a message to go with it. - * - * @param msg - * - * @since 1.0.0 - */ - protected final void markInvalid(String msg) { - invalidMsg = msg; - markInvalid(); - } - - public void close() { - nextForExpressionStackPos = -1; - controlStack.clear(); - if (expressionProxies != null) - markAllProxiesNotResolved(expressionProxies); // They weren't processed, close must of been called early. - expressionProxies = null; - markEntries = null; - expressionValid = false; - closeProxy(); - } - - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#isValid() - */ - public boolean isValid() { - return expressionValid; - } - - /* - * Check if the pending expression is ready for evaluation. - * It is complete if the next entry on the stack is a PROCESS_EXPRESSION - */ - private boolean expressionReady() { - if (nextForExpressionStackPos >= 0 && nextForExpressionStack[nextForExpressionStackPos] == PROCESS_EXPRESSION) { - checkForExpression(PROCESS_EXPRESSION); // pop it - return true; - } else - return false; - } - - /* - * Push the next expression type. - */ - private void pushForExpression(ForExpression nextExpression) { - if (++nextForExpressionStackPos >= nextForExpressionStack.length) { - // Increase stack size. - ForExpression[] newStack = new ForExpression[nextForExpressionStackPos*2]; // So room to grow without excessive allocations. - System.arraycopy(nextForExpressionStack, 0, newStack, 0, nextForExpressionStack.length); - nextForExpressionStack = newStack; - } - nextForExpressionStack[nextForExpressionStackPos] = nextExpression; - } - - /* - * Check if expression is complete, and if it is, process it. - */ - private void processExpression() { - while (expressionReady()) { - try { - // We've received all of the expressions for the expression, so process it. - int expType = ((InternalExpressionTypes) pop()).getValue(); - switch (expType) { - case InternalExpressionTypes.CAST_EXPRESSION_VALUE: - pushCastToProxy((IProxyBeanType) pop()); - break; - case InternalExpressionTypes.INSTANCEOF_EXPRESSION_VALUE: - pushInstanceofToProxy((IProxyBeanType) pop()); - break; - case InternalExpressionTypes.PREFIX_EXPRESSION_VALUE: - pushPrefixToProxy((PrefixOperator)pop()); - break; - case InternalExpressionTypes.INFIX_EXPRESSION_VALUE: - pushInfixToProxy((InfixOperator) pop(), (InternalInfixOperandType) pop()); - break; - case InternalExpressionTypes.ARRAY_ACCESS_EXPRESSION_VALUE: - pushArrayAccessToProxy(((Integer) pop()).intValue()); - break; - case InternalExpressionTypes.ARRAY_CREATION_EXPRESSION_VALUE: - pushArrayCreationToProxy((IProxyBeanType) pop(), ((Integer) pop()).intValue()); - break; - case InternalExpressionTypes.ARRAY_INITIALIZER_EXPRESSION_VALUE: - pushArrayInitializerToProxy((IProxyBeanType) pop(), ((Integer) pop()).intValue(), ((Integer) pop()).intValue()); - break; - case InternalExpressionTypes.CLASS_INSTANCE_CREATION_EXPRESSION_VALUE: - pushClassInstanceCreationToProxy((IProxyBeanType) pop(), ((Integer) pop()).intValue()); - break; - case InternalExpressionTypes.FIELD_ACCESS_EXPRESSION_VALUE: - pushFieldAccessToProxy(pop(), ((Boolean) pop()).booleanValue()); - break; - case InternalExpressionTypes.METHOD_EXPRESSION_VALUE: - pushMethodInvocationToProxy(pop(), ((Boolean) pop()).booleanValue(), ((Integer) pop()).intValue()); - break; - case InternalExpressionTypes.CONDITIONAL_EXPRESSION_VALUE: - pushConditionalToProxy((InternalConditionalOperandType) pop()); - break; - case InternalExpressionTypes.ASSIGNMENT_PROXY_EXPRESSION_VALUE: - pushAssignmentToProxy((ExpressionProxy) pop()); - break; - case InternalExpressionTypes.ASSIGNMENT_EXPRESSION_VALUE: - pushAssignmentToProxy(); - break; - case InternalExpressionTypes.BLOCK_END_EXPRESSION_VALUE: - pushBlockEndToProxy(((Integer) pop()).intValue()); - break; - case InternalExpressionTypes.TRY_END_EXPRESSION_VALUE: - pushTryEndToProxy(((Integer) pop()).intValue()); - break; - case InternalExpressionTypes.THROW_EXPRESSION_VALUE: - pushThrowToProxy(); - break; - case InternalExpressionTypes.IF_TEST_EXPRESSION_VALUE: - pushIfTestToProxy(); - break; - case InternalExpressionTypes.IF_ELSE_EXPRESSION_VALUE: - pushIfElseToProxy((InternalIfElseOperandType) pop()); - break; - case InternalExpressionTypes.SUBEXPRESSION_END_EXPRESSION_VALUE: - pushSubexpressionEndToProxy(((Integer) pop()).intValue()); - break; - default: - internalProcessUnknownExpressionType(expType); - break; - } - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - } - - - private void internalProcessUnknownExpressionType(int expressionType) throws IllegalArgumentException { - if (!processUnknownExpressionType(expressionType)) - throw new IllegalArgumentException(); - } - - /** - * An unknown expression type was found in the processing of expression stack. Subclasses can override - * to process new types of expressions. - * <p> - * Overrides must return <code>true</code> if they processed the expression type. If they return <code>false</code> - * it means they didn't understand it either and we should do default processing for unknow type. - * @param expressionType - * @return <code>true</code> if type was processed, <code>false</code> if not known by subclass either. - * - * @since 1.0.0 - */ - protected boolean processUnknownExpressionType(int expressionType) { - return false; - } - - /** - * Create the expression. - * - * @param registry - * - * @since 1.0.0 - */ - protected Expression(ProxyFactoryRegistry registry) { - this.registry = registry; - this.beanProxyFactory = this.registry.getBeanProxyFactory(); - } - - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#getRegistry() - */ - public ProxyFactoryRegistry getRegistry() { - return registry; - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#invokeExpression() - */ - public final void invokeExpression() throws ThrowableProxy, IllegalStateException, NoExpressionValueException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); // We are at the root. - popForExpression(); // Get rid of any intermediate roots. - checkForExpression(ForExpression.ROOTEXPRESSION); // We should be at true root now. We don't have more than one intermediate root pushed in sequence. - List proxies = expressionProxies; - expressionProxies = null; - pushInvoke(processExpressionProxyCallbacks(proxies), proxies); - } finally { - markInvalid(); // Mark invalid so any new calls after this will fail. - close(); - } - } - - /* - * Process the expression proxy callbacks, if any. - * @return the number of proxies that have callbacks. - */ - private int processExpressionProxyCallbacks(List proxies) { - if (proxies != null) { - // Strip list down to only those with callbacks and send on. - int proxiesWithCallbacks = 0; - for (ListIterator eps = proxies.listIterator(); eps.hasNext();) { - ExpressionProxy proxy = (ExpressionProxy) eps.next(); - if (!proxy.hasListeners()) - eps.set(null); // Remove it from the list. No one cares. - else - proxiesWithCallbacks++; - } - return proxiesWithCallbacks; - } - return 0; - } - - /** - * Called to validate this is a valid proxy for this expression. This could happen - * if a proxy from another expression is sent to this expression. If the proxy - * is a bean proxy or is an expression proxy for this expression, then this - * just returns. Else it will throw the {@link IllegalArgumentException}. - * @param proxy - * @throws IllegalArgumentException if the proxy is an expression proxy for another expression. - * - * @since 1.1.0.1 - */ - private void validateProxy(IProxy proxy) throws IllegalArgumentException { - if (proxy != null && (proxy.isExpressionProxy() && ((ExpressionProxy) proxy).getExpression() != this)) - throw new IllegalArgumentException(ProxyMessages.Expression_InvalidProxy); - } - - /** - * Called by subclass to fill in the value of an expression proxy. See {@link Expression#pullProxyValue(int, List))} for an example of who would call it. - * @param ep - * @param beanproxy - * - * @since 1.1.0 - */ - protected void fireProxyResolved(ExpressionProxy ep, IBeanProxy beanproxy) { - ep.fireResolved(beanproxy); - } - - /** - * Called by subclass to fire proxy was not resolved. See {@link Expression#pullProxyValue(int, List))} for an example of who would call it. - * @param ep - * - * @since 1.1.0 - */ - protected void fireProxyNotResolved(ExpressionProxy ep) { - ep.fireNotResolved(); - } - - /** - * Called by subclass to fire proxy resolved to a void return type. See {@link Expression#pullProxyValue(int, List))} for an example of who would call it. - * @param ep - * - * @since 1.1.0 - */ - protected void fireProxyVoid(ExpressionProxy ep) { - ep.fireVoidResolved(); - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#getExpressionValue() - */ - public final IBeanProxy getExpressionValue() throws ThrowableProxy, NoExpressionValueException, IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); // We are at the root. - popForExpression(); // Get rid of any intermediate roots. - checkForExpression(ForExpression.ROOTEXPRESSION); // We should be at true root now. We don't have more than one intermediate root pushed in sequence. - List proxies = expressionProxies; - expressionProxies = null; - return pullProxyValue(processExpressionProxyCallbacks(proxies), proxies); // Get the top value. - } finally { - markInvalid(); // Mark invalid so any new calls after this will fail. - close(); - } - } - - - /** - * Mark the list of proxies as not resolved. - * - * @since 1.1.0 - */ - protected void markAllProxiesNotResolved(List proxies) { - if (proxies != null) { - for (ListIterator eps = proxies.listIterator(); eps.hasNext();) { - ExpressionProxy proxy = (ExpressionProxy) eps.next(); - if (proxy != null && proxy.hasListeners()) - fireProxyNotResolved(proxy); - } - } - } - - private int blockNumber = -1; // Current block number. This is always incrementing. - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createBlockBegin() - */ - public final int createBlockBegin() throws IllegalStateException { - try { - // Blocks are special, they can be anywhere at root, of could be the true or else clause of an if/else. - if (peekForExpression(ForExpression.ROOTEXPRESSION)) - checkForExpression(ForExpression.ROOTEXPRESSION); - else if (peekForExpression(ForExpression.IF_TRUE)) - checkForExpression(ForExpression.IF_TRUE); - else - checkForExpression(ForExpression.IF_ELSE); - - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(BLOCKEND_EXPRESSION); - pushForExpression(ForExpression.ROOTEXPRESSION); - - pushBlockBeginToProxy(++blockNumber); - push(new Integer(blockNumber)); - push(InternalExpressionTypes.BLOCK_END_EXPRESSION); - processExpression(); - return blockNumber; - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createBlockBreak(int) - */ - public final void createBlockBreak(int blockNumber) throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - pushBlockBreakToProxy(blockNumber); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createBlockEnd() - */ - public final void createBlockEnd() throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - popForExpression(); // Remove the root expression since block is done. - checkForExpression(BLOCKEND_EXPRESSION); // This needs to be next for it to be valid. - processExpression(); // Now let it handle the previously pushed end block, containing the block number being ended. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createArrayAccess(int, int) - */ - public final void createArrayAccess(ForExpression forExpression, int indexCount) { - try { - checkForExpression(forExpression); - pushForExpression(PROCESS_EXPRESSION); - int i = indexCount; - while (i-- > 0) - pushForExpression(ForExpression.ARRAYACCESS_INDEX); - pushForExpression(ForExpression.ARRAYACCESS_ARRAY); - - push(indexCount == 1 ? ARRAYACCESS_INDEX_1 : new Integer(indexCount)); - push(InternalExpressionTypes.ARRAY_ACCESS_EXPRESSION); - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createArrayCreation(int, java.lang.String, int) - */ - public final void createArrayCreation(ForExpression forExpression, String type, int dimensionExpressionCount) - throws IllegalStateException { - pushArrayCreation(forExpression, getProxyBeanType(type), dimensionExpressionCount); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createArrayCreation(org.eclipse.jem.internal.proxy.initParser.tree.ForExpression, org.eclipse.jem.internal.proxy.core.IProxyBeanType, int) - */ - public final void createArrayCreation(ForExpression forExpression, IProxyBeanType type, int dimensionExpressionCount) - throws IllegalStateException, IllegalArgumentException { - pushArrayCreation(forExpression, type, dimensionExpressionCount); - } - - private void pushArrayCreation(ForExpression forExpression, IProxyBeanType type, int dimensionExpressionCount) throws IllegalStateException, IllegalArgumentException { - try { - checkForExpression(forExpression); - validateProxy(type); - switch (dimensionExpressionCount) { - case 0: - push(ARRAY_CREATION_DIMENSION_0); - break; - case 1: - push(ARRAY_CREATION_DIMENSION_1); - break; - default: - push(new Integer(dimensionExpressionCount)); - break; - } - push(type); - push(InternalExpressionTypes.ARRAY_CREATION_EXPRESSION); - - pushForExpression(PROCESS_EXPRESSION); - if (dimensionExpressionCount == 0) - pushForExpression(ARRAY_INITIALIZER); - else { - while (dimensionExpressionCount-- > 0) - pushForExpression(ForExpression.ARRAYCREATION_DIMENSION); - } - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createArrayInitializer(int) - */ - public final void createArrayInitializer(int expressionCount) throws IllegalStateException { - try { - // This is special, we could be waiting for an array initializer or an array initializer expression. - // We will peek to see what it is and handle it. - if (peekForExpression(ARRAY_INITIALIZER)) - checkForExpression(ARRAY_INITIALIZER); - else - checkForExpression(ForExpression.ARRAYINITIALIZER_EXPRESSION); - - // At this point in time that stack may either have: - // array_type, array_creation - // strip_count, array_type, array_initializer - // So we can get the array type from peek(2), and get the command type from peek(1). - // Then if the command type is array_creation, strip_count will be inited to 0, while - // else it will be inited to peek(3). From that we can increment the strip_count to - // use for this initializer. - // - // We need to peek here because we will be adding various pushes to the stack and we - // need to get the info while it is still at the top of the stack. - Object arrayType = peek(2); - int stripCount = 0; - if (peek(1) == InternalExpressionTypes.ARRAY_INITIALIZER_EXPRESSION) - stripCount = ((Integer) peek(3)).intValue(); - - switch (expressionCount) { - case 0: - push(ARRAYINITIALIZER_COUNT_0); - break; - case 1: - push(ARRAYINITIALIZER_COUNT_1); - break; - case 2: - push(ARRAYINITIALIZER_COUNT_2); - break; - default: - push(new Integer(expressionCount)); - break; - } - - if (arrayType instanceof String) { - String at = (String) arrayType; - int i = at.lastIndexOf("[]"); //$NON-NLS-1$ - if (i == -1) - throw new IllegalArgumentException(MessageFormat.format( - ProxyMessages.Expression_ArrayTypeNotAnArray_EXC_, new Object[] { arrayType})); - arrayType = getProxyBeanType(at); - } else if (!(arrayType instanceof IProxyBeanType)) { - throw new IllegalArgumentException(MessageFormat.format( - ProxyMessages.Expression_ArrayTypeNotAnArray_EXC_, new Object[] { arrayType})); - } - push(new Integer(++stripCount)); - push(arrayType); - push(InternalExpressionTypes.ARRAY_INITIALIZER_EXPRESSION); - - pushForExpression(PROCESS_EXPRESSION); - while (expressionCount-- > 0) - pushForExpression(ForExpression.ARRAYINITIALIZER_EXPRESSION); - - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createCastExpression(int, java.lang.String) - * A cast expression has one nested expression. - */ - public final void createCastExpression(ForExpression forExpression, String type) throws IllegalStateException { - pushCast(forExpression, getProxyBeanType(type)); // Push this onto the local stack to wait for completion. - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createCastExpression(org.eclipse.jem.internal.proxy.initParser.tree.ForExpression, org.eclipse.jem.internal.proxy.core.IProxyBeanType) - */ - public final void createCastExpression(ForExpression forExpression, IProxyBeanType type) throws IllegalStateException, IllegalArgumentException { - pushCast(forExpression, type); // Push this onto the local stack to wait for completion. - } - - /* - * Push for a cast. - */ - private void pushCast(ForExpression forExpression, IProxyBeanType type) throws IllegalStateException, IllegalArgumentException { - try { - checkForExpression(forExpression); - validateProxy(type); - push(type); - push(InternalExpressionTypes.CAST_EXPRESSION); - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.CAST_EXPRESSION); // The next expression must be for the cast expression. - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createClassInstanceCreation(int, java.lang.String, int) - */ - public final void createClassInstanceCreation(ForExpression forExpression, String type, int argumentCount) - throws IllegalStateException { - pushClassInstanceCreation(forExpression, getProxyBeanType(type), argumentCount); // Push this onto the local stack to wait for completion. - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createClassInstanceCreation(org.eclipse.jem.internal.proxy.initParser.tree.ForExpression, org.eclipse.jem.internal.proxy.core.IProxyBeanType, int) - */ - public final void createClassInstanceCreation(ForExpression forExpression, IProxyBeanType type, int argumentCount) - throws IllegalStateException, IllegalArgumentException { - pushClassInstanceCreation(forExpression, type, argumentCount); // Push this onto the local stack to wait for completion. - } - - /* - * Push for a class instance creation - */ - private void pushClassInstanceCreation(ForExpression forExpression, IProxyBeanType type, int argumentCount) throws IllegalStateException, IllegalArgumentException { - try { - checkForExpression(forExpression); - validateProxy(type); - switch (argumentCount) { - case 0: - push(CLASS_INSTANCE_CREATION_ARGUMENTS_0); - break; - case 1: - push(CLASS_INSTANCE_CREATION_ARGUMENTS_1); - break; - default: - push(new Integer(argumentCount)); - break; - } - push(type); - push(InternalExpressionTypes.CLASS_INSTANCE_CREATION_EXPRESSION); - - pushForExpression(PROCESS_EXPRESSION); - while (argumentCount-- > 0) - pushForExpression(ForExpression.CLASSINSTANCECREATION_ARGUMENT); - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createConditionalExpression(int) - */ - public final void createConditionalExpression(ForExpression forExpression) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.CONDITIONAL_FALSE); - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.CONDITIONAL_TRUE); - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.CONDITIONAL_CONDITION); - - push(InternalConditionalOperandType.CONDITIONAL_FALSE); - push(InternalExpressionTypes.CONDITIONAL_EXPRESSION); - push(InternalConditionalOperandType.CONDITIONAL_TRUE); - push(InternalExpressionTypes.CONDITIONAL_EXPRESSION); - push(InternalConditionalOperandType.CONDITIONAL_TEST); - push(InternalExpressionTypes.CONDITIONAL_EXPRESSION); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createFieldAccess(int, java.lang.String, boolean) - */ - public final void createFieldAccess(ForExpression forExpression, String fieldName, boolean hasReceiver) throws IllegalStateException, IllegalArgumentException { - try { - // Only for string fieldnames is this invalid when no receiver because no way to determine receiver. (Don't handle implicit "this" yet for fields). - // For the accessor that takes a IFieldProxy we can get away with no receiver because the field proxy can determine if static or not, and if not - // static it will fail at evaluation time. - if (!hasReceiver) - throw new IllegalArgumentException(MessageFormat.format( - ProxyMessages.Expression_CannotHandleNoReceiveOnFieldAccess_EXC_, new Object[] { fieldName})); - pushFieldAccess(forExpression, fieldName, hasReceiver); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createIfElse(boolean) - */ - public final void createIfElse(boolean hasElseClause) throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - - pushForExpression(PROCESS_EXPRESSION); - if (hasElseClause) { - pushForExpression(ForExpression.IF_ELSE); - } - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.IF_TRUE); - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.IF_CONDITION); - - // We still push an else clause so that we know when finished. We don't have a pushForExpression for it because there - // won't be any. But the else clause processing will be on the push stack so that we can clean up when end of if stmt occurs. - push(InternalIfElseOperandType.ELSE_CLAUSE); - push(InternalExpressionTypes.IF_ELSE_EXPRESSION); - - push(InternalIfElseOperandType.TRUE_CLAUSE); - push(InternalExpressionTypes.IF_ELSE_EXPRESSION); - push(InternalExpressionTypes.IF_TEST_EXPRESSION); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* - * Push the field access. - * @param forExpression - * @param field String if field name, or IProxyField. - * @param hasReceiver - * @throws IllegalAccessException - * - * @since 1.1.0 - */ - private void pushFieldAccess(ForExpression forExpression, Object field, boolean hasReceiver) throws IllegalStateException { - try { - checkForExpression(forExpression); - push(hasReceiver ? Boolean.TRUE : Boolean.FALSE); // We have a receiver - push(field); - push(InternalExpressionTypes.FIELD_ACCESS_EXPRESSION); - - pushForExpression(PROCESS_EXPRESSION); - if (hasReceiver) - pushForExpression(ForExpression.FIELD_RECEIVER); - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createInfixExpression(int, int, int) - */ - public final void createInfixExpression(ForExpression forExpression, InfixOperator operator, int extendedOperandCount) throws IllegalStateException { - try { - checkForExpression(forExpression); - push(InternalInfixOperandType.INFIX_LAST_OPERAND); - push(operator); - push(InternalExpressionTypes.INFIX_EXPRESSION); - int i = extendedOperandCount; - while (i-- > 0) { - push(InternalInfixOperandType.INFIX_OTHER_OPERAND); - push(operator); - push(InternalExpressionTypes.INFIX_EXPRESSION); - } - push(InternalInfixOperandType.INFIX_LEFT_OPERAND); - push(operator); - push(InternalExpressionTypes.INFIX_EXPRESSION); - - i = extendedOperandCount; - while (i-- > 0) { - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.INFIX_EXTENDED); - } - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.INFIX_RIGHT); - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.INFIX_LEFT); - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createInstanceofExpression(int, java.lang.String) - */ - public final void createInstanceofExpression(ForExpression forExpression, String type) throws IllegalStateException { - pushInstanceof(forExpression, getProxyBeanType(type)); // Push this onto the local stack to wait for completion. - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createInstanceofExpression(org.eclipse.jem.internal.proxy.initParser.tree.ForExpression, org.eclipse.jem.internal.proxy.core.IProxyBeanType) - */ - public final void createInstanceofExpression(ForExpression forExpression, IProxyBeanType type) throws IllegalStateException, IllegalArgumentException { - pushInstanceof(forExpression, type); // Push this onto the local stack to wait for completion. - } - - /* - * Push for a cast. - */ - private void pushInstanceof(ForExpression forExpression, IProxyBeanType type) throws IllegalStateException, IllegalArgumentException { - try { - checkForExpression(forExpression); - validateProxy(type); - push(type); - push(InternalExpressionTypes.INSTANCEOF_EXPRESSION); - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.INSTANCEOF_VALUE); // The next expression must be for the instance of expression. - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createMethodInvocation(int, java.lang.String, boolean, int) - */ - public final void createMethodInvocation(ForExpression forExpression, String name, boolean hasReceiver, int argumentCount) - throws IllegalStateException, IllegalArgumentException { - try { - // Only for string methodnames is this invalid when no receiver because no way to determine receiver. (Don't handle implicit "this" yet for methods). - // For the accessor that takes a IFieldProxy we can get away with no receiver because the field proxy can determine if static or not, and if not - // static it will fail at evaluation time. - if (!hasReceiver) - throw new IllegalArgumentException(MessageFormat.format( - ProxyMessages.Expression_MethodsNeedReceiver_EXC_, new Object[] { name})); - - pushMethodInvocation(forExpression, name, hasReceiver, argumentCount); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /** - * @param forExpression - * @param method String for method name, IMethodProxy otherwise. - * @param hasReceiver - * @param argumentCount - * @throws ThrowableProxy - * @throws NoExpressionValueException - * - * @since 1.1.0 - */ - private void pushMethodInvocation(ForExpression forExpression, Object method, boolean hasReceiver, int argumentCount) throws IllegalArgumentException, IllegalStateException { - try { - checkForExpression(forExpression); - switch (argumentCount) { - case 0: - push(METHOD_ARGUMENTS_0); - break; - case 1: - push(METHOD_ARGUMENTS_1); - break; - default: - push(new Integer(argumentCount)); - break; - } - push(hasReceiver ? Boolean.TRUE : Boolean.FALSE); - push(method); - push(InternalExpressionTypes.METHOD_EXPRESSION); - - pushForExpression(PROCESS_EXPRESSION); - while (argumentCount-- > 0) - pushForExpression(ForExpression.METHOD_ARGUMENT); - if (hasReceiver) - pushForExpression(ForExpression.METHOD_RECEIVER); - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createPrefixExpression(int, org.eclipse.jem.internal.proxy.initParser.tree.PrefixOperator) - */ - public final void createPrefixExpression(ForExpression forExpression, PrefixOperator operator) throws IllegalStateException { - try { - checkForExpression(forExpression); - push(operator); - push(InternalExpressionTypes.PREFIX_EXPRESSION); - - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.PREFIX_OPERAND); - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /** - * Create a new instance using the initialization string. The result must be compatible with the - * given type. This is not on the IExpression interface because it is not for use of regular - * customers. It is here for the allocation processer to create entries that are just strings. - * <p> - * This is not customer advanced API. This API for the implementers of registries and expression subclasses. - * - * @param forExpression - * @param initializationString - * @param type - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @since 1.1.0 - */ - public final void createNewInstance(ForExpression forExpression, String initializationString, IProxyBeanType type) throws IllegalStateException, IllegalArgumentException{ - try { - checkForExpression(forExpression); - validateProxy(type); - pushNewInstanceToProxy(initializationString, type); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createNull(int) - */ - public final void createNull(ForExpression forExpression) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushToProxy(null); - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createTypeLiteral(int, java.lang.String) - */ - public final void createTypeLiteral(ForExpression forExpression, String type) throws IllegalStateException { - createProxyExpression(forExpression, getProxyBeanType(type)); - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createTypeReceiver(java.lang.String) - */ - public final void createTypeReceiver(String type) throws IllegalStateException { - pushTypeReceiver(getProxyBeanType(type)); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createTypeReceiver(org.eclipse.jem.internal.proxy.core.IProxyBeanType) - */ - public final void createTypeReceiver(IProxyBeanType type) throws IllegalStateException, IllegalArgumentException { - validateProxy(type); - pushTypeReceiver(type); - } - - /* - * Push for a type receiver. - * @param type - * - * @since 1.0.0 - */ - private void pushTypeReceiver(IProxyBeanType type) throws IllegalStateException { - try { - // This is special because type receivers are only valid as the receiver for a field access or a method access. - // Since each has a different forExpression we need to test for one or the other. It doesn't make any difference - // which one it is, but it must be one or the other. - if (peekForExpression(ForExpression.FIELD_RECEIVER)) - checkForExpression(ForExpression.FIELD_RECEIVER); - else - checkForExpression(ForExpression.METHOD_RECEIVER); - - pushTypeReceiverToProxy(type); - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* - * For all of the primitive types we will be creating a IBeanProxy for them. That is because that - * would be the expected result of the expression, and no need to get the other side involved. - */ - - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createPrimitiveLiteral(int, boolean) - */ - public final void createPrimitiveLiteral(ForExpression forExpression, boolean value) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushToProxy(beanProxyFactory.createBeanProxyWith(value)); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createPrimitiveLiteral(int, char) - */ - public final void createPrimitiveLiteral(ForExpression forExpression, char value) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushToProxy(beanProxyFactory.createBeanProxyWith(value)); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createPrimitiveLiteral(int, byte) - */ - public final void createPrimitiveLiteral(ForExpression forExpression, byte value) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushToProxy(beanProxyFactory.createBeanProxyWith(value)); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createPrimitiveLiteral(int, double) - */ - public final void createPrimitiveLiteral(ForExpression forExpression, double value) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushToProxy(beanProxyFactory.createBeanProxyWith(value)); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createPrimitiveLiteral(int, float) - */ - public final void createPrimitiveLiteral(ForExpression forExpression, float value) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushToProxy(beanProxyFactory.createBeanProxyWith(value)); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createPrimitiveLiteral(int, int) - */ - public final void createPrimitiveLiteral(ForExpression forExpression, int value) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushToProxy(beanProxyFactory.createBeanProxyWith(value)); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createPrimitiveLiteral(int, long) - */ - public final void createPrimitiveLiteral(ForExpression forExpression, long value) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushToProxy(beanProxyFactory.createBeanProxyWith(value)); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createPrimitiveLiteral(int, short) - */ - public final void createPrimitiveLiteral(ForExpression forExpression, short value) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushToProxy(beanProxyFactory.createBeanProxyWith(value)); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createStringLiteral(int, java.lang.String) - */ - public final void createStringLiteral(ForExpression forExpression, String value) throws IllegalStateException { - try { - checkForExpression(forExpression); - pushToProxy(beanProxyFactory.createBeanProxyWith(value)); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createProxyExpression(int, org.eclipse.jem.internal.proxy.core.IProxy) - */ - public final void createProxyExpression(ForExpression forExpression, IProxy proxy) throws IllegalStateException, IllegalArgumentException { - try { - checkForExpression(forExpression); - validateProxy(proxy); - pushToProxy(proxy); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createAssignmentExpression(int) - */ - public final void createAssignmentExpression(ForExpression forExpression) throws IllegalStateException { - try { - checkForExpression(forExpression); - push(InternalExpressionTypes.ASSIGNMENT_EXPRESSION); - - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.ASSIGNMENT_RIGHT); - pushForExpression(ForExpression.ASSIGNMENT_LEFT); - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createAssignmentExpression(int) - */ - public final ExpressionProxy createProxyAssignmentExpression(ForExpression forExpression) throws IllegalStateException { - try { - checkForExpression(forExpression); - ExpressionProxy proxy = allocateExpressionProxy(NORMAL_EXPRESSION_PROXY); - push(proxy); - push(InternalExpressionTypes.ASSIGNMENT_PROXY_EXPRESSION); - - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.ASSIGNMENT_RIGHT); - processExpression(); // See if previous expression is ready for processing. - return proxy; - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /** - * Called by registries to create an expression proxy for a bean type. It is not in the interface because it should - * only be called by the proxy registry to create an expression proxy. It shouldn't be called outside of the registries - * because there may already exist in the registry the true IBeanTypeProxy, and that one should be used instead. - * <p> - * This is not customer advanced API. This API for the implementers of registries and expression subclasses. - * - * @param typeName - * @return expression proxy that is hooked up and will notify when resolved. It can be called at any time. The resolution will occur at this point in the - * execution stack, but since it will not interfere with the stack this is OK, other than it could throw a ClassNotFoundException on the - * execution. - * - * @since 1.1.0 - */ - public final IProxyBeanType createBeanTypeExpressionProxy(String typeName) { - IBeanTypeExpressionProxy proxy = (IBeanTypeExpressionProxy) allocateExpressionProxy(BEANTYPE_EXPRESSION_PROXY); - proxy.setTypeName(typeName); - // This can be sent at any time. It doesn't matter what is on the expression stack. It will be sent to be resolved immediately. - pushBeanTypeToProxy(proxy); - return proxy; - } - - /** - * Called by registries to create an expression proxy for a method. It is not in the interface because it should - * only be called by the proxy registry to create an expression proxy. It shouldn't be called outside of the registries - * because there may already exist in the registry the true IMethodProxy, and that one should be used instead. - * <p> - * This is not customer advanced API. This API for the implementers of registries and expression subclasses. - * - * @param declaringType - * @param methodName - * @param parameterTypes parameter types or <code>null</code> if no parameter types. - * @return - * - * @throws IllegalArgumentException - * @since 1.1.0 - */ - public final IProxyMethod createMethodExpressionProxy(IProxyBeanType declaringType, String methodName, IProxyBeanType[] parameterTypes) throws IllegalArgumentException{ - validateProxy(declaringType); - if (parameterTypes != null && parameterTypes.length > 0) { - for (int i = 0; i < parameterTypes.length; i++) { - validateProxy(parameterTypes[i]); - } - } - ExpressionProxy proxy = allocateExpressionProxy(METHOD_EXPRESSION_PROXY); - // This can be sent at any time. It doesn't matter what is on the expression stack. It will be sent to be resolved immediately. - pushMethodToProxy(proxy, declaringType, methodName, parameterTypes); - return (IProxyMethod) proxy; - } - - /** - * Called by registries to create an expression proxy for a field. It is not in the interface because it should - * only be called by the proxy registry to create an expression proxy. It shouldn't be called outside of the registries - * because there may already exist in the registry the true IFieldProxy, and that one should be used instead. - * <p> - * This is not customer advanced API. This API for the implementers of registries and expression subclasses. - * - * @param declaringType - * @param fieldName - * @return - * - * @throws IllegalArgumentException - * @since 1.1.0 - */ - public final IProxyField createFieldExpressionProxy(IProxyBeanType declaringType, String fieldName) throws IllegalArgumentException { - validateProxy(declaringType); - ExpressionProxy proxy = allocateExpressionProxy(FIELD_EXPRESSION_PROXY); - // This can be sent at any time. It doesn't matter what is on the expression stack. It will be sent to be resolved immediately. - pushFieldToProxy(proxy, declaringType, fieldName); - return (IProxyField) proxy; - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createProxyReassignmentExpression(org.eclipse.jem.internal.proxy.initParser.tree.ForExpression, org.eclipse.jem.internal.proxy.core.ExpressionProxy) - */ - public final void createProxyReassignmentExpression(ForExpression forExpression, ExpressionProxy proxy) throws IllegalStateException, IllegalArgumentException { - try { - checkForExpression(forExpression); - if (!proxy.isValidForReassignment()) - throw new IllegalArgumentException(MessageFormat.format(ProxyMessages.Expression_CreateProxyReassignmentExpression_InvalidForReassignment_EXC_, new Object[]{proxy.toString()})); - push(proxy); - push(InternalExpressionTypes.ASSIGNMENT_PROXY_EXPRESSION); - - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.ASSIGNMENT_RIGHT); - processExpression(); // See if previous expression is ready for processing. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - protected static final int NORMAL_EXPRESSION_PROXY = 0; - protected static final int BEANTYPE_EXPRESSION_PROXY = 1; - protected static final int METHOD_EXPRESSION_PROXY = 2; - protected static final int FIELD_EXPRESSION_PROXY = 3; - /** - * Allocate a new ExpressionProxy - * @return new ExpressionProxy. - * - * @since 1.1.0 - */ - protected final ExpressionProxy allocateExpressionProxy(int proxyType) { - if (expressionProxies == null) - expressionProxies = new ArrayList(); - // It is very important that this always creates a proxy id that is greater than all previous. This is - // so that it can be assured that proxies will be resolved in order of creation. - // Currently this is done here by using expressionProxies.size(). - ExpressionProxy proxy = createExpressionProxy(proxyType, expressionProxies.size()); - expressionProxies.add(proxy); - return proxy; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createFieldAccess(org.eclipse.jem.internal.proxy.initParser.tree.ForExpression, org.eclipse.jem.internal.proxy.core.IProxyField, boolean) - */ - public final void createFieldAccess(ForExpression forExpression, IProxyField fieldProxy, boolean hasReceiver) throws IllegalStateException, IllegalArgumentException { - validateProxy(fieldProxy); - pushFieldAccess(forExpression, fieldProxy, hasReceiver); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createMethodInvocation(org.eclipse.jem.internal.proxy.initParser.tree.ForExpression, org.eclipse.jem.internal.proxy.core.IProxyMethod, boolean, int) - */ - public final void createMethodInvocation(ForExpression forExpression, IProxyMethod methodProxy, boolean hasReceiver, int argumentCount) throws IllegalArgumentException, - IllegalStateException { - validateProxy(methodProxy); - pushMethodInvocation(forExpression, methodProxy, hasReceiver, argumentCount); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createSimpleFieldAccess(org.eclipse.jem.internal.proxy.core.IProxyField, org.eclipse.jem.internal.proxy.core.IProxy) - */ - public final ExpressionProxy createSimpleFieldAccess(IProxyField field, IProxy receiver) throws IllegalStateException, IllegalArgumentException { - validateProxy(field); - validateProxy(receiver); - ExpressionProxy result = createProxyAssignmentExpression(ForExpression.ROOTEXPRESSION); - createFieldAccess(ForExpression.ASSIGNMENT_RIGHT, field, receiver != null); - if (receiver != null) - createProxyExpression(ForExpression.FIELD_RECEIVER, receiver); - return result; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createSimpleFieldSet(org.eclipse.jem.internal.proxy.core.IProxyField, org.eclipse.jem.internal.proxy.core.IProxy, org.eclipse.jem.internal.proxy.core.IProxy, boolean) - */ - public final ExpressionProxy createSimpleFieldSet(IProxyField field, IProxy receiver, IProxy value, boolean wantResult) throws IllegalStateException, IllegalArgumentException { - validateProxy(field); - validateProxy(receiver); - ExpressionProxy result = null; - ForExpression forExpression = ForExpression.ROOTEXPRESSION; - if (wantResult) { - result = createProxyAssignmentExpression(forExpression); - forExpression = ForExpression.ASSIGNMENT_RIGHT; - } - createAssignmentExpression(forExpression); - createFieldAccess(ForExpression.ASSIGNMENT_LEFT, field, receiver != null); - if (receiver != null) - createProxyExpression(ForExpression.FIELD_RECEIVER, receiver); - createProxyExpression(ForExpression.ASSIGNMENT_RIGHT, value); - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createSimpleMethodInvoke(org.eclipse.jem.internal.proxy.core.IMethodProxy, org.eclipse.jem.internal.proxy.core.IProxy, org.eclipse.jem.internal.proxy.core.IProxy[], boolean) - */ - public final ExpressionProxy createSimpleMethodInvoke(IProxyMethod method, IProxy receiver, IProxy[] arguments, boolean wantResult) - throws IllegalStateException, IllegalArgumentException { - validateProxy(method); - validateProxy(receiver); - if (arguments != null && arguments.length > 0) { - for (int i = 0; i < arguments.length; i++) { - validateProxy(arguments[i]); - } - } - ForExpression nextExpression = ForExpression.ROOTEXPRESSION; - ExpressionProxy result = null; - if (wantResult) { - result = createProxyAssignmentExpression(nextExpression); - nextExpression = ForExpression.ASSIGNMENT_RIGHT; - } - createMethodInvocation(nextExpression, method, receiver != null, arguments != null ? arguments.length : 0); - if (receiver != null) - createProxyExpression(ForExpression.METHOD_RECEIVER, receiver); - if (arguments != null) { - for (int i = 0; i < arguments.length; i++) { - createProxyExpression(ForExpression.METHOD_ARGUMENT, arguments[i]); - } - } - return result; - } - - private int subexpressionNumber = -1; // Current subexpression number. This is always incrementing. - - public void createSubexpression() throws IllegalStateException { - try { - // Subexpressions are special, they can be anywhere. - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(SUBEXPRESSIONEND_EXPRESSION); - pushForExpression(ForExpression.ROOTEXPRESSION); - - pushSubexpressionBeginToProxy(++subexpressionNumber); - push(new Integer(subexpressionNumber)); - push(InternalExpressionTypes.SUBEXPRESSION_END_EXPRESSION); - processExpression(); - return; - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - public void createSubexpressionEnd() throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - popForExpression(); // Remove the root expression since block is done. - checkForExpression(SUBEXPRESSIONEND_EXPRESSION); // This needs to be next for it to be valid. - processExpression(); // Now let it handle the previously pushed end subexpression, containing the subexpression number being ended. - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - - private int tryNumber = -1; // Current try number. This is always incrementing. - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createTry() - */ - public final void createTry() throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - pushForExpression(PROCESS_EXPRESSION); // Set up so that when reached we can process the TRY_END that we've pushed data for later in this method. - pushForExpression(TRYEND_EXPRESSION); // Must get a try end before we can process it. - pushForExpression(TRYCATCH_EXPRESSION); // Must get a catch/finally clause (or try end, which knows how to handle this). - pushForExpression(ForExpression.ROOTEXPRESSION); // Expecting root expressions for the try clause. - - pushTryBeginToProxy(++tryNumber); - push(new Integer(tryNumber)); - push(InternalExpressionTypes.TRY_END_EXPRESSION); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createTryCatchClause(org.eclipse.jem.internal.proxy.core.IProxyBeanType, boolean) - */ - public final ExpressionProxy createTryCatchClause(IProxyBeanType exceptionType, boolean wantExceptionReturned) - throws IllegalStateException, IllegalArgumentException { - validateProxy(exceptionType); - return pushTryCatch(exceptionType, wantExceptionReturned); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createTryCatchClause(java.lang.String, boolean) - */ - public final ExpressionProxy createTryCatchClause(String exceptionType, boolean wantExceptionReturned) - throws IllegalStateException { - return pushTryCatch(getProxyBeanType(exceptionType), wantExceptionReturned); - } - - /** - * @param exceptionType - * @param wantExceptionReturned - * @return - * @throws IllegalStateException - * - * @since 1.1.0 - */ - private ExpressionProxy pushTryCatch(IProxyBeanType exceptionType, boolean wantExceptionReturned) throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - popForExpression(); // Remove the root expression since try or previous catch clause is done. - checkForExpression(TRYCATCH_EXPRESSION); // This needs to be next for it to be valid. - pushForExpression(TRYCATCH_EXPRESSION); // Set up for a following catch/finally clause. - pushForExpression(ForExpression.ROOTEXPRESSION); // Root expressions are next for the catch clause. - - int tryNumber = ((Integer) peek(2)).intValue(); // Get the try#. It should be in this place on the stack. - - ExpressionProxy ep = null; - if (wantExceptionReturned) - ep = allocateExpressionProxy(NORMAL_EXPRESSION_PROXY); - pushTryCatchClauseToProxy(tryNumber, exceptionType, ep); - - processExpression(); - return ep; - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createTryEnd() - */ - public final void createTryEnd() throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - popForExpression(); // Remove the root expression since try or previous catch clause is done. - if (peekForExpression(TRYCATCH_EXPRESSION)) - checkForExpression(TRYCATCH_EXPRESSION); // This may of been next if no finally clause was added. If a finally clause was added this would not be here. - checkForExpression(TRYEND_EXPRESSION); // And this needs to be after that to be valid. - - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createTryFinallyClause() - */ - public final void createTryFinallyClause() throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - popForExpression(); // Remove the root expression since try or previous catch clause is done. - checkForExpression(TRYCATCH_EXPRESSION); // This needs to be next for it to be valid. - pushForExpression(ForExpression.ROOTEXPRESSION); // Root expressions are next for the finally clause. - - int tryNumber = ((Integer) peek(2)).intValue(); // Get the try#. It should be in this place on the stack. - - pushTryFinallyClauseToProxy(tryNumber); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createRethrow() - */ - public final void createRethrow() throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - popForExpression(); // Remove the root expression since try or previous catch clause is done. - checkForExpression(TRYCATCH_EXPRESSION); // This needs to be next for it to be valid. - // It is in a valid state, so put the catch and root back on so that things work correctly. - pushForExpression(TRYCATCH_EXPRESSION); - pushForExpression(ForExpression.ROOTEXPRESSION); - - int tryNumber = ((Integer) peek(2)).intValue(); // Get the try#. It should be in this place on the stack. - - pushRethrowToProxy(tryNumber); - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IExpression#createThrow() - */ - public final void createThrow() throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - push(InternalExpressionTypes.THROW_EXPRESSION); - pushForExpression(PROCESS_EXPRESSION); - pushForExpression(ForExpression.THROW_OPERAND); // The next expression must be for the throw value. - processExpression(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - - public final int mark() throws IllegalStateException { - try { - checkForExpression(ForExpression.ROOTEXPRESSION); - ++highestMarkID; - currentMarkEntry = new MarkEntry(); - currentMarkEntry.markID = highestMarkID; - currentMarkEntry.controlStackPos = controlStack.size() - 1; - currentMarkEntry.nextExpressionStackPos = nextForExpressionStackPos; - currentMarkEntry.expressionProxiesPos = expressionProxies != null ? expressionProxies.size() - 1 : -1; - if (markEntries == null) - markEntries = new ArrayList(5); - markEntries.add(currentMarkEntry); - pushMarkToProxy(highestMarkID); - return highestMarkID; - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - public void endMark(int markNumber) throws IllegalStateException { - if (isValid()) { - // Can only do a valid end mark if we are at root. If not at root, we fall through and treat as invalid. - if (peekForExpression(ForExpression.ROOTEXPRESSION)) { - checkForExpression(ForExpression.ROOTEXPRESSION); // Now remove it if it should be removed. - // If the current mark number is not the same as the incoming mark number, we have improper nesting. - if (currentMarkEntry == null || currentMarkEntry.markID != markNumber) - throwInvalidMarkNesting(); // We have improper nesting. - // We are popping the current mark. Since we are valid, just move up one in the mark stack. - MarkEntry me = (MarkEntry) markEntries.remove(markEntries.size()-1); - if (!markEntries.isEmpty()) - currentMarkEntry = (MarkEntry) markEntries.get(markEntries.size()-1); - else - currentMarkEntry = null; - pushEndmarkToProxy(markNumber, false); - if (me.controlStackPos != controlStack.size()-1 || me.nextExpressionStackPos != nextForExpressionStackPos) - throwInvalidMarkNesting(); // The stacks should be back to the same size at this point for a valid end mark. - return; - } - } - - // It was invalid, or became invalid. - if (markEntries == null) - throwInvalidMarkNesting(); // We have no marks, so this is an invalid end mark. - - // We are invalid, need to pop to the given markNumber. - // Starting from the end we search back to find the entry for the given mark number. We do it - // from the end because it is more likely to be closer to the end than to the beginning. - for (int i = markEntries.size()-1; i >=0; i--) { - MarkEntry me = (MarkEntry) markEntries.get(i); - if (me.markID == markNumber) { - // Found it. - // Trim the control stack down to the size at time of mark. (No easy way to do this other than repeated remove's. - // We do it backwards to eliminate repeated shuffling of entries. - for (int j = controlStack.size()-1; j > me.controlStackPos; j--) { - controlStack.remove(j); - } - - // Trim the expression stack. This is simple, just reset the next entry pointer. - nextForExpressionStackPos = me.nextExpressionStackPos; - - if (expressionProxies != null) { - // Now we need to mark all of the expression proxies that occured after the mark as - // not resolved (since someone may be listening), and remove them, and reuse the proxies. - for (int j = expressionProxies.size()-1; j > me.expressionProxiesPos; j--) { - ExpressionProxy proxy = (ExpressionProxy) expressionProxies.remove(j); - if (proxy != null && proxy.hasListeners()) - fireProxyNotResolved(proxy); - } - } - - // Now that we know it is valid, we want to remove all of the mark entries above it in the stack - // since those are now invalid. We couldn't remove them as we were searching for the entry because - // if the entry wasn't found we didn't want to wipe out the probably valid ones. - for (int j = markEntries.size()-1; j >= i; j--) { - markEntries.remove(j); - } - - if (!markEntries.isEmpty()) - currentMarkEntry = (MarkEntry) markEntries.get(markEntries.size()-1); - else - currentMarkEntry = null; - pushEndmarkToProxy(markNumber, true); - expressionValid = true; - return; - } - } - throwInvalidMarkNesting(); // The mark number wasn't found, so this is an invalid end mark. - } - - /** - * Begin the transfer of the expression to another thread. - * <p> - * This is used when the expression needs to continue to be built up, but it needs - * to be done on a different thread. The reason for doing something special other - * than just using it on the other thread is that some proxy registries connections are - * tied through the thread. If you switched to another thread the connections would not - * be properly set up. - * This is not on the IExpression interface because even though it is API, it is tricky - * to use and so not exposed to everyone. Users can legitimately cast to Expression and - * use this as API for advanced use. - * <p> - * This is used to begin the transfer. It puts it into a state ready for the transfer. Calling this - * method will cause a synchronization of the expression up to the current level. This means - * that it will not return until the expression has been completely processed in the proxy registry - * up to this point. Typically the connection is a pipe where the instructions are just pushed onto - * it and the caller is not held up waiting for the registry to process it. - * <p> - * Then when the other thread is done, it will call beginTransferThread itself to signal that it is done - * and that the old thread can pick it up. Then the old thread will call transferThread to pick up processing. - * <p> - * It will be: - * <pre><code> - * ... expression stuff ... - * expression.beginTransferThread() - * ... do what is necessary to get to the other thread ... - * ... on other thread: - * expression.transferThread(); - * try { - * ... do your expression stuff on this thread ... - * } finally { - * expression.beginTransferThread(); // This is to return it to old thread. - * } - * ... tell old thread to pick up ... - * ... back on old thread: - * expression.transferThread(); - * ... do more expression stuff ... - * expression.invokeExpression(); - * </code></pre> - * - * @throws IllegalStateException - * @throws ThrowableProxy Thrown if there was an exception with the remote vm during this request. - * @since 1.1.0 - */ - public final void beginTransferThread() throws IllegalStateException, ThrowableProxy { - try { - pushForExpression(THREADTRANSFER_EXPRESSION); - pushBeginTransferThreadToProxy(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - /** - * Transfer the expression to the current thread. - * <p> - * This is called to actually transfer to the current thread. It must be the next call against - * the expression after the beginTransferThread, but on the new thread. - * <p> - * This is not on the IExpression interface because even though it is API, it is tricky - * to use and so not exposed to everyone. Users can legitimately cast to Expression and - * use this as API for advanced use. - * @see Expression#beginTransferThread() for a full explanation. - * @throws IllegalStateException - * - * @since 1.1.0 - */ - public final void transferThread() throws IllegalStateException { - try { - checkForExpression(THREADTRANSFER_EXPRESSION); - pushTransferThreadToProxy(); - } catch (RuntimeException e) { - markInvalid(); - throw e; - } - } - - - /** - * Get the IProxyBeanType for the type string sent in. - * @param type - * @return - * - * @since 1.1.0 - */ - protected IProxyBeanType getProxyBeanType(String type) { - return getRegistry().getBeanTypeProxyFactory().getBeanTypeProxy(this, type); - } - - /** - * Create the expression proxy subclass that is applicable for this kind of processor. - * @param proxyType type of proxy. {@link Expression#NORMAL_EXPRESSION_PROXY - * @param proxyID the id of the new expression proxy. - * - * @return - * - * @since 1.1.0 - */ - protected abstract ExpressionProxy createExpressionProxy(int proxyType, int proxyID); - - /** - * Push this proxy to the other side. It will simply take the proxy and push it onto - * its evaluation stack. It will be treated as the result of an expression. It's just - * that the expression was evaluatable on this side (since it is already a proxy). - * - * @param proxy - * - * @since 1.0.0 - */ - protected abstract void pushToProxy(IProxy proxy); - - /** - * Tell the other side we are complete. This will always be called after expression evaluation, or - * if expression was prematurely closed. - * <p> - * <b>Note:</b> The implementation must be able to handle multiple invocations, where the first call is a valid close and any - * subsequent call should be ignored. - * - * @throws ThrowableProxy - * - * @since 1.0.0 - */ - protected abstract void closeProxy(); - - /** - * Do invoke. This should simply make sure everything is done and throw any pending errors. - * <p> - * <b>Note:</b> The expression proxies MUST be resolved (callbacks called) in the order they are found in the expressionProxies list. This - * is so that the contract is followed that resolution notifications will occur in the order of creation. - * - * @param proxycount Number of Expression Proxies that need a callback. - * @param list of expression proxies. If proxycount > 0, then process the non-null entries in the list. They will be of type ExpressionProxy. - * @throws ThrowableProxy - * - * @since 1.0.0 - */ - protected abstract void pushInvoke(int proxycount, List expressionProxies) throws ThrowableProxy, NoExpressionValueException; - - /** - * Pull the top expression value from the evaluation stack. It will also under - * the covers call closeProxy. It also must process the expression proxy callbacks. It must do the expression proxy callbacks first, and then - * process the result value. If an error had occured sometime during processing, it should still process the proxy callbacks before throwing - * an exception. - * <p> - * <b>Note:</b> The expression proxies MUST be resolved (callbacks called) in the order they are found in the expressionProxies list. This - * is so that the contract is followed that resolution notifications will occur in the order of creation. Also <b>REQUIRED</b> is that - * the entire list must be processed of proxies must be processed by this call. It cannot do some or none. - * - * @param proxycount Number of Expression Proxies that need a callback. - * @param list of expression proxies. If proxycount > 0, then process the non-null entries in the list. They will be of type ExpressionProxy. - * @return The top level evaluation stack value. - * @throws ThrowableProxy - * @throws NoExpressionValueException - * - * @since 1.0.0 - */ - protected abstract IBeanProxy pullProxyValue(int proxycount, List expressionProxies) throws ThrowableProxy, NoExpressionValueException; - - /** - * Push to proxy the cast expression. The expression to use will be on the top of its evaluation stack. - * The result of the cast expression will be placed onto the evaluation stack. - * - * @param type Cast type. - * - * @since 1.0.0 - */ - protected abstract void pushCastToProxy(IProxyBeanType type); - - /** - * Push to proxy the instanceof expression. The expression to use will be on the top of its evaluation stack. - * The result of the instanceof expression will be placed onto the evaluation stack. - * - * @param type Instanceof type. - * - * @since 1.0.0 - */ - protected abstract void pushInstanceofToProxy(IProxyBeanType type); - - /** - * Push to proxy the infix operation. This is called on the completion of each operand of the expression. - * So it will be called a minimum of two times. - * - * @param operator The operator. - * @param operandType The operand type. left, other, or last. - * - * @since 1.0.0 - */ - protected abstract void pushInfixToProxy(InfixOperator operator, InternalInfixOperandType operandType); - - /** - * Push to proxy the prefix expression. The expression to use will be on top of its evaluation stack. - * The result of the prefix operation will be placed onto the evaluation stack. - * - * @param operator - * - * @see IExpressionConstants#PRE_MINUS - * @since 1.0.0 - */ - protected abstract void pushPrefixToProxy(PrefixOperator operator); - - - /** - * Push to proxy the array access. The result will be placed onto the evaluation stack. - * - * @param indexCount - * - * @since 1.0.0 - */ - protected abstract void pushArrayAccessToProxy(int indexCount); - - /** - * Push to proxy the array creation. The result will be placed onto the evaluation stack. - * @param type The array type. - * @param dimensionCount - * - * @since 1.0.0 - */ - protected abstract void pushArrayCreationToProxy(IProxyBeanType type, int dimensionCount); - - /** - * Push to proxy the array initializer. The resulting array will be placed onto the evaluation stack. - * @param type The array type. (must be an array type). - * @param stripDimCount the number of dimensions that must be stripped from the array type. This is needed - * because the first array initializer needs to be for the component type of the array (array minus one dimension), and - * each initializer after that needs one more dimension stripped off. But since we are working with possible expression - * proxies for "type", we can't create the appropriate component types of the array. So we need to tell the - * processor how many dims to strip from the original type (which is what is sent in on every initializer push, the original type). - * @param expressionCount - * - * @since 1.0.0 - */ - protected abstract void pushArrayInitializerToProxy(IProxyBeanType type, int stripDimCount, int expressionCount); - - /** - * Push to proxy the class instance creation. The resulting class instance will be placed onto the evaluation stack. - * - * @param type Class type. - * @param argumentCount The number of arguments. - * - * @since 1.0.0 - */ - protected abstract void pushClassInstanceCreationToProxy(IProxyBeanType type, int argumentCount); - - /** - * Push to proxy the type receiver. The resulting class will be placed onto the evaluation stack, along with it also - * being the expression type. - * @param type Class type. - * - * @since 1.0.0 - */ - protected abstract void pushTypeReceiverToProxy(IProxyBeanType type); - - /** - * Push to proxy the field access. The result value will be placed onto the evaluation stack. - * @param field The name of the field if string, or an IFieldProxy. - * @param hasReceiver Has receiver flag. - * - * @since 1.0.0 - */ - protected abstract void pushFieldAccessToProxy(Object field, boolean hasReceiver); - - /** - * Push to proxy the method invocation. The result value will be placed onto the evaluation stack. - * - * @param method String for method name or IProxyMethod - * @param hasReceiver - * @param argCount - * - * @since 1.0.0 - */ - protected abstract void pushMethodInvocationToProxy(Object method, boolean hasReceiver, int argCount); - - /** - * Push to proxy the conditional expression. This will be called on each part of expression. The expression type - * will be the current part (e.g. test, true, false). - * - * @param expressionType The expression type. - * - * @since 1.0.0 - */ - protected abstract void pushConditionalToProxy(InternalConditionalOperandType expressionType); - - /** - * Push to the proxy the expression proxy. Whatever the last expression value is will be assigned to the ExpressionProxy. - * - * @param proxy - * - * @since 1.1.0 - */ - protected abstract void pushAssignmentToProxy(ExpressionProxy proxy); - - /** - * Push the assignment expression. The operands are already on the stack. - * - * @since 1.1.0 - */ - protected abstract void pushAssignmentToProxy(); - - - /** - * Push the begin block expression. - * @param blockNumber - * - * @since 1.1.0 - */ - protected abstract void pushBlockBeginToProxy(int blockNumber); - - /** - * Push the end block expression. - * @param blockNumber - * - * @since 1.1.0 - */ - protected abstract void pushBlockEndToProxy(int blockNumber); - - /** - * Push the break block expression. - * @param blockNumber - * - * @since 1.1.0 - * - */ - protected abstract void pushBlockBreakToProxy(int blockNumber); - - /** - * Push the begin try expression. - * @param tryNumber - * - * @since 1.1.0 - */ - protected abstract void pushTryBeginToProxy(int tryNumber); - - /** - * Push the catch clause to proxy. - * @param tryNumber - * @param exceptionType - * @param ep ExpressionProxy to be assigned with the exception or <code>null</code> if exception is not to be assigned. - * - * @since 1.1.0 - */ - protected abstract void pushTryCatchClauseToProxy(int tryNumber, IProxyBeanType exceptionType, ExpressionProxy ep); - - /** - * Push the finally clause to proxy. - * @param tryNumber - * - * @since 1.1.0 - */ - protected abstract void pushTryFinallyClauseToProxy(int tryNumber); - - /** - * Push try end to proxy. - * @param tryNumber - * - * @since 1.1.0 - */ - protected abstract void pushTryEndToProxy(int tryNumber); - - /** - * Push the throw of the exception to proxy. - * @param exception - * - * @since 1.1.0 - */ - protected abstract void pushThrowToProxy(); - - /** - * Push a rethrow to proxy. - * @param tryNumber - * - * @since 1.1.0 - */ - protected abstract void pushRethrowToProxy(int tryNumber); - - /** - * Push the BeanType Expression proxy to be resolved on the execution side. - * @param proxy - * - * @since 1.1.0 - */ - protected abstract void pushBeanTypeToProxy(IBeanTypeExpressionProxy proxy); - - /** - * Push the Method Expression proxy to be resolved on the execution side. - * @param proxy - * @param declaringType - * @param methodName - * @param parameterTypes parameter types or <code>null</code> if no parameters. - * - * @since 1.1.0 - */ - protected abstract void pushMethodToProxy(ExpressionProxy proxy, IProxyBeanType declaringType, String methodName, IProxyBeanType[] parameterTypes); - - /** - * Push the Field Expression Proxy to be resolved on the execution side. - * @param proxy - * @param declaringType - * @param fieldName - * - * @since 1.1.0 - */ - protected abstract void pushFieldToProxy(ExpressionProxy proxy, IProxyBeanType declaringType, String fieldName); - - /** - * Push the If test condition to proxy. - * - * @since 1.1.0 - */ - protected abstract void pushIfTestToProxy(); - - /** - * Push a true or else clause to proxy. - * @param clauseType - * - * @since 1.1.0 - */ - protected abstract void pushIfElseToProxy(InternalIfElseOperandType clauseType); - - /** - * Push to proxy a new instance using an initialization string. - * @param initializationString - * @param resultType - * - * @since 1.1.0 - */ - protected abstract void pushNewInstanceToProxy(String initializationString, IProxyBeanType resultType); - - /** - * Push the mark id to proxy. - * - * @param markID - * - * @since 1.1.0 - */ - protected abstract void pushMarkToProxy(int markID); - - /** - * Push the end mark id to proxy. - * - * @param markID - * @param restore <code>true</code> if this is a restore due to error, <code>false</code> if this is just a normal end mark. - * - * @since 1.1.0 - */ - protected abstract void pushEndmarkToProxy(int markID, boolean restore); - - /** - * Push the begin transfer thread to proxy. - * - * - * @since 1.1.0 - */ - protected abstract void pushBeginTransferThreadToProxy() throws ThrowableProxy; - - /** - * Push the actual transfer to the current thread to proxy. - * - * - * @since 1.1.0 - */ - protected abstract void pushTransferThreadToProxy(); - - /** - * Push the subexpression begin to proxy. - * @param subexpressionNumber - * - * @since 1.1.0 - */ - protected abstract void pushSubexpressionBeginToProxy(int subexpressionNumber); - - /** - * Push the subexpression end to proxy. - * @param subexpressionNumber - * - * @since 1.1.0 - */ - protected abstract void pushSubexpressionEndToProxy(int subexpressionNumber); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ExpressionProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ExpressionProxy.java deleted file mode 100644 index ec12faad8..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ExpressionProxy.java +++ /dev/null @@ -1,349 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import java.util.EventObject; -import java.util.logging.Level; - - -/** - * This is a proxy for an IExpression evaluation value. It is used as a place holder proxy value for result of an expression, and - * then the value can be used in a later expression, or at the end, it can callback and return a proxy in the IDE - * side in a callback for usage later on outside of the IExpression. - * <p> - * After receiving the resolved event, listeners should not hold onto the ExpressionProxy because it would then be invalid. At that - * point they should instead hold onto the resolved bean proxy. - * - * @see org.eclipse.jem.internal.proxy.core.IExpression#assignExpressionProxy() - * @see org.eclipse.jem.internal.proxy.core.IExpression#createExpressionProxyExpression(int, ExpressionProxy) - * @since 1.1.0 - */ -public class ExpressionProxy implements IProxy { - - public ProxyFactoryRegistry getProxyFactoryRegistry() { - return getExpression().getRegistry(); - } - - /** - * The event object for the resolved event of the proxy listener. - * <p> - * The source will be the ExpressionProxy that is being resolved. - * @since 1.1.0 - */ - public static class ProxyEvent extends EventObject { - - /** - * Comment for <code>serialVersionUID</code> - * - * @since 1.1.0 - */ - private static final long serialVersionUID = -2305781662465107377L; - private final IBeanProxy proxy; - - /** - * @param source the expression proxy for the event. - * @param proxy the bean proxy the expression proxy (source) resolved to. - * - * @since 1.1.0 - */ - public ProxyEvent(ExpressionProxy source, IBeanProxy proxy) { - super(source); - this.proxy = proxy; - } - - /** - * Construct the event with no proxy. Used for not resolved and void. - * @param source - * - * @since 1.1.0 - */ - public ProxyEvent(ExpressionProxy source) { - this(source, null); - } - - /** - * Get the proxy value that the expression proxy (source) resolved to. - * @return - * - * @since 1.1.0 - */ - public IBeanProxy getProxy() { - return proxy; - } - } - - /** - * Listener for expression proxy events. - * - * @since 1.1.0 - */ - public interface ProxyListener { - /** - * The expression proxy has been resolved. The event contains the resolved proxy. - * At this point, any listeners should no longer hold onto the ExpressionProxy - * because it is now invalid. They should hold onto the resolved bean proxy instead. - * - * @param event - * - * @since 1.1.0 - */ - public void proxyResolved(ProxyEvent event); - - /** - * This is called for ExpressionProxies that have a callback listener, but the proxy - * was never resolved. This means that the expression that assigns to the proxy was - * not executed. In this case the event does not have a bean proxy in it. - * - * @param event - * - * @since 1.1.0 - */ - public void proxyNotResolved(ProxyEvent event); - - /** - * This is called for ExpressionProxies that were assigned to an expression that - * had a <code>VOID</code> return type. This is usually for method invocations that - * have a void return type. In this case the event does not have a bean proxy in it. - * @param event - * - * @since 1.1.0 - */ - public void proxyVoid(ProxyEvent event); - } - - /** - * An implementation of ProxyListener that does nothing. It can be - * used as a superclass for individual listeners that are only interested - * in some of the events. - * - * @since 1.1.0 - */ - public static class ProxyAdapter implements ProxyListener { - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.ExpressionProxy.ProxyListener#proxyNotResolved(org.eclipse.jem.internal.proxy.core.ExpressionProxy.ProxyEvent) - */ - public void proxyNotResolved(ProxyEvent event) { - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.ExpressionProxy.ProxyListener#proxyResolved(org.eclipse.jem.internal.proxy.core.ExpressionProxy.ProxyEvent) - */ - public void proxyResolved(ProxyEvent event) { - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.ExpressionProxy.ProxyListener#proxyVoid(org.eclipse.jem.internal.proxy.core.ExpressionProxy.ProxyEvent) - */ - public void proxyVoid(ProxyEvent event) { - } - } - - final private int proxyID; - final private int proxyType; - private ListenerList listenerList; - private Expression expression; - - /** - * Create with the given proxy id. - * @param proxyid - * - * @since 1.1.0 - */ - public ExpressionProxy(int proxyid, int proxyType, Expression expression) { - this.proxyID = proxyid; - this.proxyType = proxyType; - this.expression = expression; - } - - /** - * Get the expression this proxy is for. - * @return - * - * @since 1.1.0 - */ - public Expression getExpression() { - return expression; - } - - /** - * Used internally in expression to get the proxy type. - * @return - * - * @since 1.1.0 - */ - protected final int getProxyType() { - return proxyType; - } - - /** - * Return the proxy id. - * @return - * - * @since 1.1.0 - */ - public final int getProxyID() { - return proxyID; - } - - /** - * Add a listener. If listener already added, it has no effect. - * @param listener - * - * @since 1.1.0 - */ - public void addProxyListener(ProxyListener listener) { - if (listenerList == null) - listenerList = new ListenerList(); - listenerList.add(listener); - } - - /** - * Remove a listener. If listener not already added, then no error. - * @param listener - * - * @since 1.1.0 - */ - public void removeProxyListener(ProxyListener listener) { - if (listenerList != null) - listenerList.remove(listener); - } - - /** - * Used by internal subclasses or Expression to know if anyone is listening. - * @return - * - * @since 1.1.0 - */ - protected final boolean hasListeners() { - return listenerList != null && !listenerList.isEmpty(); - } - - /** - * The proxy has been fired (one of the events has occurred). Subclasses should clean - * up and not hold onto anything that would be expensive in case the proxy is still - * held onto be someone. For example the default clears the listener list. - * <p> - * <b>Note:</b> Subclasses must call super.dispose(). - * - * @since 1.1.0 - */ - protected void dispose() { - listenerList = null; - expression = null; - } - - /** - * Used by internal subclasses or by Expression to fire the resolved event. Once fired all listeners are removed. - * This is because only one kind of firing can be done for a expression proxy and then the proxy is dead. This - * prevents listeners from being held on to if any one accidently still holds the proxy. - * @param proxy - * - * @since 1.1.0 - */ - protected void fireResolved(IBeanProxy proxy) { - if (hasListeners()) { - ProxyEvent event = new ProxyEvent(this, proxy); - Object[] listeners = listenerList.getListeners(); - for (int i = 0; i < listeners.length; i++) { - try { - ((ProxyListener) listeners[i]).proxyResolved(event); - } catch (RuntimeException e) { - ProxyPlugin.getPlugin().getLogger().log(e, Level.WARNING); - } - } - } - dispose(); - } - - /** - * Used by internal subclasses or by Expression to fire the not resolved event. Once fired all listeners are removed. - * This is because only one kind of firing can be done for a expression proxy and then the proxy is dead. This - * prevents listeners from being held on to if any one accidently still holds the proxy. - * - * @since 1.1.0 - */ - protected void fireNotResolved() { - if (hasListeners()) { - ProxyEvent event = new ProxyEvent(this); - Object[] listeners = listenerList.getListeners(); - for (int i = 0; i < listeners.length; i++) { - try { - ((ProxyListener) listeners[i]).proxyNotResolved(event); - } catch (RuntimeException e) { - ProxyPlugin.getPlugin().getLogger().log(e, Level.WARNING); - } - - } - } - dispose(); - } - - /** - * Used by internal subclasses or by Expression to fire the void resolved event. Once fired all listeners are removed. - * This is because only one kind of firing can be done for a expression proxy and then the proxy is dead. This - * prevents listeners from being held on to if any one accidently still holds the proxy. - * - * @since 1.1.0 - */ - protected void fireVoidResolved() { - if (hasListeners()) { - ProxyEvent event = new ProxyEvent(this); - Object[] listeners = listenerList.getListeners(); - for (int i = 0; i < listeners.length; i++) { - try { - ((ProxyListener) listeners[i]).proxyVoid(event); - } catch (RuntimeException e) { - ProxyPlugin.getPlugin().getLogger().log(e, Level.WARNING); - } - - } - } - dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IProxy#isBeanProxy() - */ - public final boolean isBeanProxy() { - return false; - } - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IProxy#isExpressionProxy() - */ - public final boolean isExpressionProxy() { - return true; - } - - /** - * Is this proxy valid for reassignment. By default only if the type is NORMAL_EXPRESSION_PROXY. - * Subclasses may override and return true in their cases. - * - * @return - * - * @since 1.1.0 - */ - public boolean isValidForReassignment() { - return getProxyType() == Expression.NORMAL_EXPRESSION_PROXY; - } - - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() { - return super.toString()+": "+getProxyID(); //$NON-NLS-1$ - } -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IAccessibleObjectProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IAccessibleObjectProxy.java deleted file mode 100644 index d563228b9..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IAccessibleObjectProxy.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - -/** - * Proxy for an AccessibleObject. - * - * @since 1.0.0 - */ -public interface IAccessibleObjectProxy extends IBeanProxy { - - /** - * Is the proxy accessible or not? - * - * @return <code>true</code> if accessible. - */ - public boolean isAccessible() throws ThrowableProxy; - - /** - * Set the accessible flag on the proxy. - * - * @param flag <code>true</code> if accessible. - * @throws ThrowableProxy - */ - public void setAccessible(boolean flag) throws ThrowableProxy; - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IArrayBeanProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IArrayBeanProxy.java deleted file mode 100644 index 8bdbaa278..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IArrayBeanProxy.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Proxy wrappering an array. - */ -public interface IArrayBeanProxy extends IBeanProxy { - /** - * Get the object at the specified index. - */ - IBeanProxy get(int index) throws ThrowableProxy; - - IBeanProxy getCatchThrowableException(int index); - - /** - * Get the object at the specified multi-dimensional index. - * The array must be at least the number of dimensions specified, - * and each index along the way must exist. - * The number of dimensions can't be greater than the number - * of dimensions of the real object. - */ - IBeanProxy get(int [] indexes) throws ThrowableProxy; - - /** - * Get a snapshot of the array. It will return an array of proxies of the - * complete first dimension of the array. This is useful if you need - * to be working with more than one entry of the array. You can save - * accesses to the vm by doing this. - * <p> - * NOTE: This is a snapshot. It will not see changes to the array. - * If an entry is set into the returned array of proxies, this will - * not be reflected into the real array. Also any changes in the - * contents of the first dimension of the real array will not - * be reflected into this returned array of proxies. The proxies - * returned are real proxies, so any changes to them will be reflected - * back and forth. Treat this as an array copy to a new array. - * - * @return array of proxies of the first dimension of the array. - * @throws ThrowableProxy - * - * @since 1.1.0 - */ - IBeanProxy[] getSnapshot() throws ThrowableProxy; - - /** - * Set the object at the specified index. - */ - void set(IBeanProxy value, int index) throws ThrowableProxy; - - /** - * Set the object at the specified multi-dimensional index. - * The array must be at least the number of dimensions specified, - * and each index along the way must exist. - * The number of dimensions can't be greater than the number - * of dimensions of the real object. - */ - void set(IBeanProxy value, int [] indexes) throws ThrowableProxy; - - /** - * Get the length of the first dimension of this array. - * If there are multi-dimensions, you must get the appropriate - * dimension from the get method to see the size of that dimension. - * - * e.g. - * int [3] returns 3 - * int [3][2] returns 3 - * - * ((IArrayBeanProxy) get(1)).getLength() returns 2 - * Since arrays do not have to be homogenous, there could - * be a different length array for each of the arrays - * returned from the first dimension, the returned length - * from get(2) and get(3) could result in a different value - * from get(1). - */ - int getLength(); - - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IArrayBeanTypeProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IArrayBeanTypeProxy.java deleted file mode 100644 index aceff093e..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IArrayBeanTypeProxy.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * A Proxy for an array type. - */ - -public interface IArrayBeanTypeProxy extends IBeanTypeProxy { - /** - * getComponentType: Get the component type of this array. - * e.g. (new Object[3]).getClass().getComponentType() will - * return "java.lang.Object". - * and (new Object[3][2][1]).getClass().getComponentType() will - * return "Object[][]"; - */ - public IBeanTypeProxy getComponentType(); - /** - * Return the final type, i.e. the final non-array type. - * i.e. int[][] will return int. - */ - public IBeanTypeProxy getFinalComponentType(); - /** - * Return the number of dimensions for this type. - * i.e. int [][] will return 2. - */ - public int getDimensions(); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanProxy.java deleted file mode 100644 index 7fc92f42e..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanProxy.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Bean Proxy interface. This is the - * root interface for any bean proxy instance. - * Creation date: (12/3/99 11:37:01 AM) - * @author: Joe Winchester - */ -public interface IBeanProxy extends IProxy { -/** - * equals: Equal if: - * 1) This proxy == (identity) to the other object - * 2) Else if other is an IBeanProxy, then if - * equals on the server. - * 3) If this is a constant proxy and the other is too or is a constant - * value (e.g. IStringBeanProxy.equals(String), then true if values are equals. - */ -public boolean equals(Object anObject); - -/** - * Test for identity among this bean proxy and the other bean proxy. - * For some proxy systems, this may be redundent and you can be assured - * that if the objects being proxied are identical you will receive the - * same proxy for both. However, other implementations may not have this - * condition. Therefor this method was created. - * - * There is one restriction, constants may not necessarily be identical. - * For instance, in some implementations, the Boolean proxy (i.e. an instance of class Boolean) is a constant, i.e. - * it cannot be changed. In those cases a new proxy may be created for each - * access and so they will not be considered to be identical. In those cases false will be returned. - * But in other implementations a new proxy will not be created and so sameAs will return true. - * - * Primitives will return true if just equal because in Java primitives are identical if the same value. - * - * @param aBeanProxy - * @return true if they are identical (i.e. ==) and not just equals. - */ -public boolean sameAs(IBeanProxy aBeanProxy); - -/** - * Return the registry this proxy was created with. - */ -public ProxyFactoryRegistry getProxyFactoryRegistry(); -/** - * Return the proxied class of the bean - * Creation date: (12/3/99 11:37:01 AM) - * @author: Joe Winchester - */ -public IBeanTypeProxy getTypeProxy(); - -/** - * Return a string representation of the bean itself - * This could be done by finding the toString() method by a findMethod() - * on the type proxy, etc... but toString() is so ubiquitous that it is - * explicitly declared on the IBeanProxy interface - * Creation date: (12/3/99 11:37:01 AM) - * @author: Joe Winchester - */ -public String toBeanString(); -/** - * Is this bean still valid? It could be invalid because it - * was specifically released but someone is still holding onto it. - */ -public boolean isValid(); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanProxyFactory.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanProxyFactory.java deleted file mode 100644 index 510d8f908..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanProxyFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Bean Proxy Factory for creating bean proxies. - * Creation methods are actually package protected. - * All creation is done through the IBeanTypeProxy. - * Specific factories may have helper methods that - * allow creation of specific types, such as the - * standard factory allows creation of Boolean, int's, etc. - * Creation date: (12/3/99 11:52:09 AM) - * @author: Joe Winchester - */ -public interface IBeanProxyFactory { - /** - * The factory is being terminated. - * <p> - * It should clean up its resources. - * It should not reference any other factory because they could of - * already been terminated. - * <p> - * For example, if it is holding onto IREMBeanProxy's, it doesn't - * need to call release on them except if they are constants because - * the BeanProxyFactory has all non-constant bean proxies registered - * and will call the release itself. - * <p> - * Note: This is not meant to be called by users. It will be called internally by the proxy registry when necessary. - * - * @param wait <code>true</code> should wait for completion, <code>false</code> don't necessarily wait. False is just - * a suggestion. The factory may not permit not waiting. True must be honoured and it must wait. - * - * @since 1.0.2 - */ - public void terminateFactory(boolean wait); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanTypeExpressionProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanTypeExpressionProxy.java deleted file mode 100644 index 8966aa17d..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanTypeExpressionProxy.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - - -/** - * An internal interface for the registries to create the appropriate beantype expression proxy. - * Not to be implemented or referenced by customers. - * @since 1.1.0 - */ -public interface IBeanTypeExpressionProxy extends IProxyBeanType { - - /** - * Allow the expression to set the type name. - * @param typeName - * - * @since 1.1.0 - */ - public void setTypeName(String typeName); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanTypeProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanTypeProxy.java deleted file mode 100644 index 30f733fd9..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanTypeProxy.java +++ /dev/null @@ -1,319 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import org.eclipse.jem.internal.proxy.common.AmbiguousMethodException; - -/** - * A proxy for a BeanType (i.e. Java type/class). Creation date: (12/3/99 11:38:06 AM) - * - * @author: Joe Winchester - */ -public interface IBeanTypeProxy extends IBeanProxy, IProxyBeanType { - - /** - * Find the most compatible constructor (out of the declared constructors). This means it will - * find either an exact match or an override that is compatible, e.g. X(Object j) is returned when looking with arg type of "java.lang.String". - * @param argumentTypes array of arg types or <code>null</code> if none. (In case of null, this is the default ctor, so just use that). - * @return - * @throws NoSuchMethodException - * @throws AmbiguousMethodException - * @throws IllegalAccessException - * - * @since 1.1.0 - */ - public IConstructorProxy getCompatibleConstructor(IBeanTypeProxy[] argumentTypes) throws AmbiguousMethodException, NoSuchMethodException, IllegalAccessException; - - /** - * Find the most compatible public method, including inheritied. This means it will - * find either an exact match or an override that is compatible, e.g. xyz(Object j) is returned when looking with arg type of "java.lang.String". - * @param methodName - * @param argumentTypes array of arg types or <code>null</code> if none. (In case of null, just use getMethod(String methodName) since only one is compatible then. - * @return - * @throws AmbiguousMethodException - * @throws NoSuchMethodException - * - * @since 1.1.0 - */ - public IMethodProxy getCompatibleMethod(String methodName, IBeanTypeProxy[] argumentTypes) throws AmbiguousMethodException, NoSuchMethodException; - - /** - * Return the constructor proxy on the receiver with the specified arguments Creation date: (12/3/99 2:25:07 PM) - */ - public IConstructorProxy getConstructorProxy(String[] argumentClassNames); - - /** - * Return the constructor proxy on the receiver with the specified types Creation date: (12/3/99 2:25:07 PM) - */ - public IConstructorProxy getConstructorProxy(IBeanTypeProxy[] argumentTypes); - - /** - * Return an array of public constructors for this class. - * - * @return an array of constructor proxies or <code>null</code> if an error. - * - * @since 1.1.0 - */ - public IConstructorProxy[] getConstructors(); - - /** - * Return the declared constructor proxy on the receiver with the specified arguments Creation date: (12/3/99 2:25:07 PM) - */ - public IConstructorProxy getDeclaredConstructorProxy(String[] argumentClassNames); - - /** - * Return the declared constructor proxy on the receiver with the specified types Creation date: (12/3/99 2:25:07 PM) - */ - public IConstructorProxy getDeclaredConstructorProxy(IBeanTypeProxy[] argumentTypes); - - /** - * Return an array of declared constructors for this class. - * - * @return an array of constructor proxies or <code>null</code> if an error. - * - * @since 1.1.0 - */ - public IConstructorProxy[] getDeclaredConstructors(); - - /** - * Return the array of field proxies. - * @return - * - * @since 1.1.0 - */ - public IFieldProxy[] getFields(); - - /** - * Return the array of declared field proxies. - * @return - * - * @since 1.1.0 - */ - public IFieldProxy[] getDeclaredFields(); - - /** - * Return the fieldproxy on the receiver with the specified name Creation date: (12/3/99 2:25:07 PM) - */ - public IFieldProxy getFieldProxy(String fieldName); - - /** - * Return the declared fieldproxy on the receiver with the specified name - */ - public IFieldProxy getDeclaredFieldProxy(String fieldName); - - /** - * Return the method proxy on the receiver with the specified name and no arguments. - * - * @param methodName - * @return - * @since 1.0.0 - */ - public IMethodProxy getMethodProxy(String methodName); - - /** - * Return the method proxy on the receiver with the qualified class names as string arguments - * - * @param methodName - * @param argumentClassNames - * @return - * @since 1.0.0 - */ - public IMethodProxy getMethodProxy(String methodName, String[] argumentClassNames); - - /** - * Return the method proxy on the receiver with the specified name and one argument - * - * @param methodName - * @param argumentClassName - * @return - * @since 1.0.0 - */ - public IMethodProxy getMethodProxy(String methodName, String argumentClassName); - - /** - * Return the method proxy on the receiver with the beanTypes as arguments - * - * @param methodName - * @param argumentTypes - * @return - * @since 1.0.0 - */ - public IMethodProxy getMethodProxy(String methodName, IBeanTypeProxy[] argumentTypes); - - /** - * Return an array of public methods for this class. - * - * @return an array of method proxies or <code>null</code> if an error. - * - * @since 1.1.0 - */ - public IMethodProxy[] getMethods(); - - /** - * Return the declared method proxy on the receiver with the specified arguments Creation date: (12/3/99 2:25:07 PM) - */ - public IMethodProxy getDeclaredMethodProxy(String methodName, String[] argumentClassNames); - - /** - * Return the declared method proxy on the receiver with the specified types Creation date: (12/3/99 2:25:07 PM) - */ - public IMethodProxy getDeclaredMethodProxy(String methodName, IBeanTypeProxy[] argumentTypes); - - /** - * Return an array of declared methods for this class. - * - * @return an array of method proxies or <code>null</code> if an error. - * - * @since 1.1.0 - */ - public IMethodProxy[] getDeclaredMethods(); - - /** - * Return the invokable on the receiver with the specified name and no arguments. - * <p> - * The method proxy is not retrieved. Instead the method will be looked up - * each time on the vm. Because of this these are suitable only for one-shot invokations. If it is to be invoked often, then a method proxy should - * be retrieved instead. - * <p> - * Though typical for one-shot deal the invokable can be used over and over. There is just overhead because the method is looked up each time. So a reasonable compromise - * would be if using it infrequently or is used closely together once or twice it is better to use a Invokable instead of a method proxy. - * <p> - * Note there is no guarantee that the method is available. This won't be known until the actual invoke is done. - * - * @param methodName - * @return - * @since 1.0.0 - */ - public IInvokable getInvokable(String methodName); - - /** - * Return the method proxy on the receiver with the qualified class names as string arguments - * <p> - * The method proxy is not retrieved. Instead the method will be looked up - * each time on the vm. Because of this these are suitable only for one-shot invokations. If it is to be invoked often, then a method proxy should - * be retrieved instead. - * <p> - * Though typical for one-shot deal the invokable can be used over and over. There is just overhead because the method is looked up each time. So a reasonable compromise - * would be if using it infrequently or is used closely together once or twice it is better to use a Invokable instead of a method proxy. - * <p> - * Note there is no guarantee that the method is available. This won't be known until the actual invoke is done. - * - * @param methodName - * @param argumentClassNames - * @return - * @since 1.0.0 - */ - public IInvokable getInvokable(String methodName, String[] argumentClassNames); - - /** - * Return the method proxy on the receiver with the specified name and one argument - * <p> - * The method proxy is not retrieved. Instead the method will be looked up - * each time on the vm. Because of this these are suitable only for one-shot invokations. If it is to be invoked often, then a method proxy should - * be retrieved instead. - * <p> - * Though typical for one-shot deal the invokable can be used over and over. There is just overhead because the method is looked up each time. So a reasonable compromise - * would be if using it infrequently or is used closely together once or twice it is better to use a Invokable instead of a method proxy. - * <p> - * Note there is no guarantee that the method is available. This won't be known until the actual invoke is done. - * - * @param methodName - * @param argumentClassName - * @return - * @since 1.0.0 - */ - public IInvokable getInvokable(String methodName, String argumentClassName); - - /** - * Return the method proxy on the receiver with the beanTypes as arguments - * <p> - * The method proxy is not retrieved. Instead the method will be looked up - * each time on the vm. Because of this these are suitable only for one-shot invokations. If it is to be invoked often, then a method proxy should - * be retrieved instead. - * <p> - * Though typical for one-shot deal the invokable can be used over and over. There is just overhead because the method is looked up each time. So a reasonable compromise - * would be if using it infrequently or is used closely together once or twice it is better to use a Invokable instead of a method proxy. - * <p> - * Note there is no guarantee that the method is available. This won't be known until the actual invoke is done. - * - * @param methodName - * @param argumentTypes - * @return - * @since 1.0.0 - */ - public IInvokable getInvokable(String methodName, IBeanTypeProxy[] argumentTypes); - - /** - * Return the constructor proxy on the receiver with no arguments Creation date: (12/3/99 2:25:07 PM) - */ - public IConstructorProxy getNullConstructorProxy(); - - /** - * Answer the type proxy for the superclass Creation date: (12/3/99 2:25:07 PM) - */ - public IBeanTypeProxy getSuperBeanTypeProxy(); - - /** - * Answer the name of the type we are proxying This is the fully qualified name. For arrays it will return the format: [Lclassname; Creation date: - * (12/3/99 2:25:07 PM) - */ - public String getTypeName(); - - /** - * Answer the formal format type name. For normal classes, this just the same as getTypeName(), but for arrays, it is of the format classname[] - */ - public String getFormalTypeName(); - - /** - * Answer a boolean as to whether we are an array type. - */ - public boolean isArray(); - - /** - * Answer a boolean as to whether we are a type or an interface Creation date: (12/3/99 2:25:07 PM) - */ - public boolean isInterface(); - - /** - * Answer a boolean as to whether we are a primitive or not. - */ - public boolean isPrimitive(); - - /** - * Answer a boolean as to whether we are a kind of the argument We can either be it, inherit from it, or implement it - */ - public boolean isKindOf(IBeanTypeProxy aBeanProxyType); - - /** - * Return a new instance Creation date: (12/3/99 2:25:07 PM) - */ - public IBeanProxy newInstance() throws ThrowableProxy; - - /** - * Return a new instance of this type using the initialization string to create the proxy. ClassCastException is thrown if the initstring doesn't - * result in an object compatible with this type. InstantiationException is thrown when the initialization string cannot be parsed correctly. - * Creation date: (12/3/99 2:25:07 PM) - */ - public IBeanProxy newInstance(String initializationString) throws ThrowableProxy, ClassCastException, InstantiationException; - - /** - * Return the exception message that happened when trying to find this bean type. Class not found is not such an exception. In that case the bean - * type will be returned as a null instead. An example of such is an initialization error during loading the class, i.e. it was found but some - * static failed to initialize. - * - * Return null if there is no initialization error. - */ - public String getInitializationError(); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanTypeProxyFactory.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanTypeProxyFactory.java deleted file mode 100644 index ce1164672..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBeanTypeProxyFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Factory for creating BeanTypeProxy's. - * This is a common tag interface so that - * the factory can be registered. But each - * VM requires a different interface that - * extends this interface. That extended - * interface is what must be implemented in - * each VM. - * Creation date: (12/3/99 2:26:00 PM) - * @author: Joe Winchester - */ -public interface IBeanTypeProxyFactory extends IBeanProxyFactory { - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBooleanBeanProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBooleanBeanProxy.java deleted file mode 100644 index 625d83964..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IBooleanBeanProxy.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Optimized implementation that should be used for Boolean proxies that - * allows the IDE VM to get the boolean value easily - * Creation date: (2/6/00 8:58:22 AM) - * @author: Joe Winchester - */ -public interface IBooleanBeanProxy extends IBeanProxy { -/** - * Return the proxied boolean as a boolean that the IDE can use - * Creation date: (2/6/00 8:58:32 AM) - */ -boolean booleanValue(); -Boolean getBooleanValue(); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ICallback.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ICallback.java deleted file mode 100644 index 7f8a02d4e..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ICallback.java +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - -import java.io.InputStream; - -/** - * Users will create a callback of this interface - * and register it with the factory. Then when ever - * the callback occurs, this callback will be called - * with data from the proxy. It can return a value too. - * - * Or an InputStream can be returned to supply the data. - * - * @since 1.0.0 - */ -public interface ICallback { - - /** - * This is the entry point of the callback. - * It will be called whenever the callback - * occurred. It will be on its own thread. - * A particular thread cannot be requested. - * <p> - * The implementation MUST return. This is - * because the callback will not be completed - * until it is returned, and the process will - * not continue on the remote vm until it is - * returned. - * <p> - * The value returned must either be an - * IBeanProxy or IBeanProxy[]. It is typed - * to Object to allow either one, but it - * will be checked, and if it isn't, then - * null will be returned instead to the - * caller. - * - * @param msgID - * @param parm The beanproxy - will not be null - * @return - * - * @since 1.0.0 - */ - public Object calledBack(int msgID, IBeanProxy parm); - - /** - * This is the entry point of the callback. - * It will be called whenever the callback - * occurred. It will be on its own thread. - * A particular thread cannot be requested. - * <p> - * The parms will be an array of IBeanProxys, - * or an entry could be another array of IBeanProxys, - * or null if null was sent to callBackWithParms. - * The final component of any entry will be an - * IBeanProxy. It is up to the developers to - * agree on the format of the parms. - * <p> - * The implementation MUST return. This is - * because the callback will not be completed - * until it is returned, and the process will - * not continue on the remote vm until it is - * returned. - * <p> - * The value returned must either be an - * IBeanProxy or IBeanProxy[]. It is typed - * to Object to allow either one, but it - * will be checked, and if it isn't, then - * null will be returned instead to the - * caller. - * - * @param msgID - * @param parms - * @return - * - * @see org.eclipse.jem.internal.proxy.common.ICallbackHandler#callbackWithParms(int, int, Object[]) - * @since 1.0.0 - */ - public Object calledBack(int msgID, Object[] parms); - - /** - * This is the entry point of the callback. - * It will be called whenever the callback - * occurred. It will be on its own thread. - * A particular thread cannot be requested. - * <p> - * The parm will be an object. This occurs - * if remote vm just wanted to send some objects. - * They will not be proxies. It is recommended - * that this be used only for small items. For - * anything large, the callbackStream should be - * used instead. - * <p> - * The implementation MUST return. This is - * because the callback will not be completed - * until it is returned, and the process will - * not continue on the remote vm until it is - * returned. - * <p> - * The value returned must either be an - * IBeanProxy or IBeanProxy[]. It is typed - * to Object to allow either one, but it - * will be checked, and if it isn't, then - * null will be returned instead to the - * caller. - * - * @param msgID - * @param parm The parm or <code>null</code> if null was sent. - * @return - * - * @see ICallback#calledBackStream(int, InputStream) - * @since 1.0.0 - */ - public Object calledBack(int msgID, Object parm); - - /** - * This is the entry point of the callback. - * It will be called whenever the callback stream - * occurred. It will be on its own thread. - * A particular thread cannot be requested. - * <p> - * The callback should continue to read from the InputStream - * until it returns -1 indicating no more data. The stream can - * be closed. In that case the next time the remote vm wants to - * send data it will first check that the stream has not been closed. - * If it has, it will raise an exception on that side. - * <p> - * The implementation MUST return. This is - * because the callback will not be completed - * until it is returned, and the process will - * not continue on the remote vm until it is - * returned. - * - * @param msgID - * @param is - * - * @since 1.0.0 - */ - public void calledBackStream(int msgID, InputStream is); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ICallbackRegistry.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ICallbackRegistry.java deleted file mode 100644 index 0e3c561f7..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ICallbackRegistry.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - -/** - * This is the registry for handling callbacks. - * It is used to register and deregister callbacks. - * - * Callbacks are split into two parts: - * 1) CallbackProxy. This is any proxy that implements the - * interface ICallback. (Or the - * equivalent one if not standard remote vm). This is the - * object which will actually submit the callback on the remote - * vm. For example, any kind of listener. It would implement - * both the ICallback and the appropriate listener interface. - * Then when it gets called as a listener, it will redirect the - * call to the remote vm callback handler to submit it to the - * proxy side. - * 2) Callback. This is on this side and is the object that will - * be notified of the callback and will execute at that time. - * - */ - -public interface ICallbackRegistry { - - /** - * Register this callback proxy and this callback. - * - * The process is to: - * 1) Create the callbackProxy and the callback - * 2) register these with registerCallback - * 3) Now connect the callbackProxy so that it will start notifying. - * For example, if it is a normal listener, at this time do the - * addListener call to add the callbackProxy to the appropriate object. - * You don't want it to start notifying before registering it. - * (Though it won't hust it, it will just return null). - */ - public void registerCallback(IBeanProxy callbackProxy, ICallback cb); - - /** - * Same as {@link ICallbackRegistry#registerCallback(IBeanProxy, ICallback) registerCallback} except that - * it is deferred off into an expression. - * - * @param callbackProxy - * @param cb - * @param expression - * - * @since 1.1.0 - */ - public void registerCallback(IProxy callbackProxy, ICallback cb, IExpression expression); - - /** - * Deregister the callback proxy. This will remove it from the - * registry and release the callback. - * - * The process is to: - * 1) Stop the proxy from listening so it no notifies. This is usually - * removeListener on the remote vm. You don't want it notifying - * after it deregister (though it won't hurt it, it will just return null). - * 2) deregister it. - */ - public void deregisterCallback(IBeanProxy callbackProxy); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ICharacterBeanProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ICharacterBeanProxy.java deleted file mode 100644 index b2e7c3ed9..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ICharacterBeanProxy.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Optimized implementation that should be used for character proxies that - * allows the IDE VM to get the character value easily - * Creation date: (2/6/00 8:58:22 AM) - * @author: Joe Winchester - */ -public interface ICharacterBeanProxy extends IBeanProxy, INumberBeanProxy { -/** - * Return the proxied character as a char that the IDE can use - * Creation date: (2/6/00 8:58:32 AM) - */ -char charValue(); -/** - * Return the proxied character as a Character that the IDE can use - * Creation date: (2/6/00 8:58:32 AM) - */ -Character characterValue(); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributionController.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributionController.java deleted file mode 100644 index 03267f944..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributionController.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - -import java.net.URL; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IJavaProject; -import org.osgi.framework.Bundle; -; -/** - * Controls contribution to the configuration. This allows the classpath - * to be modified in an acceptable manner, so that duplicates aren't in - * the path, or adding a project to the path in an acceptable way. - * - * If only deleting or moving entries from the classpath, that can be done directly - * to the classpath list passed in. Adding entries needs to go through this - * controller. - * - * This is meant to be implemented by developers of proxy launch configurations. - * - * @version 1.0 - * @author - */ -public interface IConfigurationContributionController { - - /** - * Append to the user classpath. - */ - public static final int APPEND_USER_CLASSPATH = 0; - - /** - * Prepend to the user classpath. This will stick it in position 0. If - * another prepend comes along, it will go in pos 0 and this one will move to 1. - */ - public static final int PREPEND_USER_CLASSPATH = 1; - - - /** - * Append to the boot classpath. - */ - public static final int APPEND_BOOT_CLASSPATH = 2; - - /** - * Prepend to the boot classpath. - */ - public static final int PREPEND_BOOT_CLASSPATH = 3; - - /** - * Append a folder to the java.library.path (for things like - * dll's). This should result in a folder only. - * The nlsLocalize flag contribute via plugin will be - * ignored for this type flag. - */ - public static final int APPEND_JAVA_LIBRARY_PATH = 4; - - /** - * Get the java project that we are contributing for. - * - * @return javaproject, may be <code>null</code> - * - * @since 1.0.0 - */ - public IJavaProject getJavaProject(); - - /** - * Add a project to the classpath. The type flag tells where to add it. - * - * @param project - * @throws CoreException - * - * @since 1.0.0 - */ - public void contributeProject(IProject project) throws CoreException; - - /** - * Add an external file/folder to the classpath. The type flag tells where to add it. - * - * @param classpath - * @param typeFlag One of <code>APPEND_USER_CLASSPATH</code>, <code>APPEND_BOOT_CLASSPATH</code>, <code>PREPEND_BOOT_CLASSPATH</code>, or <code>APPEND_JAVA_LIBRARY_PATH</code>. - * - * @deprecated use contributeClasspath(URL, int) instead. - * @see #contributeClasspath(URL, int) - * @since 1.0.0 - */ - public void contributeClasspath(String classpath, int typeFlag); - - /** - * Add an external file/folder to the classpath. The type flag tells where to add it. - * - * @param classpathURL - * @param typeFlag One of <code>APPEND_USER_CLASSPATH</code>, <code>APPEND_BOOT_CLASSPATH</code>, <code>PREPEND_BOOT_CLASSPATH</code>, or <code>APPEND_JAVA_LIBRARY_PATH</code>. - * - * @since 1.0.0 - */ - public void contributeClasspath(URL classpathURL, int typeFlag); - - /** - * Add an external files/folders to the classpath. The type flag tells where to add it. - * - * @param classpaths - * @param typeFlag One of <code>APPEND_USER_CLASSPATH</code>, <code>APPEND_BOOT_CLASSPATH</code>, <code>PREPEND_BOOT_CLASSPATH</code>, or <code>APPEND_JAVA_LIBRARY_PATH</code>. - * - * @deprecated use contributeClasspath(URL[], int) instead. - * @see #contributeClasspath(URL[], int) - * @since 1.0.0 - */ - public void contributeClasspath(String[] classpaths, int typeFlag); - - /** - * Add an external files/folders to the classpath. The type flag tells where to add it. - * - * @param classpathURLs - * @param typeFlag One of <code>APPEND_USER_CLASSPATH</code>, <code>APPEND_BOOT_CLASSPATH</code>, <code>PREPEND_BOOT_CLASSPATH</code>, or <code>APPEND_JAVA_LIBRARY_PATH</code>. - * - * @since 1.0.0 - */ - public void contributeClasspath(URL[] classpathURLs, int typeFlag); - - /** - * Add a file/folder from a plugin in the running Eclipse to the classpath. The type flag tells where to add it. - * In development mode it will find the bin class files instead if proxy.jars is setup correctly. - * <p> - * If nlsLocalize is <code>true</code>, then it will also search through the fragments in this manner: - * (Note: if <code>false</code> it will still search in the fragments, but it will only return the first file found that matches. - * <p> - * Find in the plugin and all of the fragments those that match the name exactly - * <p> - * This is useful for nls where the nls for the filename will be in one or more of the fragments of the plugin. - * - * @param bundle The bundle it can be found in. - * @param relativePath Path to file/folder relative to bundle root. Or <code>null</code> if it is the bundle/fragment itself (for when the bundle has been jar'ed up). - * <b>Note: </b>If it is <code>APPEND_JAVA_LIBRARY_PATH</code>, it should be folder and nlsLocalize will be ignored. - * In this case be careful that if a folder and the plugin is jarred that the folder <b>IS NOT THE ROOT OF THE PLUGIN</b>. This will - * cause the entire plugin to be extracted instead of just the directory containing the libraries. If the libraries are in the root - * of a jarred plugin then a separate cache directory should be created instead and the libraries of interest extracted to there. And - * then point to the cache directory instead. - * @param typeFlag One of <code>APPEND_USER_CLASSPATH</code>, <code>APPEND_BOOT_CLASSPATH</code>, <code>PREPEND_BOOT_CLASSPATH</code>, or <code>APPEND_JAVA_LIBRARY_PATH</code>. - * @param nlsLocalize The usual value should be <code>false</code>. Use <code>true</code> if should look through fragments to gather them all as described in this methods description. This will work for jarred bundles/fragments too. - * - * @since 1.0.0 - */ - public void contributeClasspath(Bundle bundle, String relativePath, int typeFlag, boolean nlsLocalize); - - /** - * Same as {@link #contributeClasspath(Bundle, String, int, boolean)} except an IPath can be used as the relative path. - * - * @param bundle - * @param relativePath path to file within bundle. Or <code>null</code> if it is the bundle/fragment itself (for when the bundle has been jar'ed up). - * @param typeFlag - * @param nlsLocalize - * - * @see #contributeClasspath(Bundle, String, int, boolean) - * @since 1.0.0 - */ - public void contributeClasspath(Bundle bundle, IPath relativePath, int typeFlag, boolean nlsLocalize); - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributionInfo.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributionInfo.java deleted file mode 100644 index 9d25a4524..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributionInfo.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import java.util.Map; - -import org.eclipse.jdt.core.IJavaProject; - -/** - * This interface will be passed to the IConfigurationContributor initialize method. It has info - * that may be needed by the contributor. It may be saved for later use, but if classpaths have changed, - * it won't be kept up to date. - * <p> - * This interface is not intended to be implemented by clients. - * </p> - * - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributor#initialize(IConfigurationContributionInfo) - * @since 1.0.0 - */ -public interface IConfigurationContributionInfo { - - /** - * Hold the visible and hidden container paths. - * A visible container path means it has been exported up to the top-level project. And also - * the array of those not visible. The paths are the String form (i.e. IPath.toString()). - * <p> - * These are the values of the {@link IConfigurationContributionInfo#getContainerIds()} map. - * - * @since 1.2.0 - */ - public static class ContainerPaths { - - private final String[] visiblePath; - private final String[] hiddenPaths; - private final String containerId; - - ContainerPaths(String containerId, String[] visiblePath, String[] hiddenPaths) { - // Not meant to be subclassed or constructed by clients. - this.containerId = containerId; - this.visiblePath = visiblePath; - this.hiddenPaths = hiddenPaths; - } - - - /** - * @return Returns the containerId. - * - * @since 1.2.0 - */ - public final String getContainerId() { - return containerId; - } - - /** - * Array of visible container paths. A path is visible if it is exported up to and can - * see by the top-level project. - * - * @return - * - * @since 1.2.0 - */ - public final String[] getVisibleContainerPaths() { - return visiblePath; - } - - /** - * Array of hidden container paths. A path is hidden if it is not exported up to and cannot - * see by the top-level project. - * - * @return - * - * @since 1.2.0 - */ - public final String[] getHiddenContainerPaths() { - return hiddenPaths; - } - - /** - * Get all of the paths together, both visible and hidden. - * @return - * - * @since 1.2.0 - */ - public String[] getAllPaths() { - String[] allPaths = new String[visiblePath.length+hiddenPaths.length]; - System.arraycopy(visiblePath, 0, allPaths, 0, visiblePath.length); - System.arraycopy(hiddenPaths, 0, allPaths, visiblePath.length, hiddenPaths.length); - return allPaths; - } - } - - /** - * Get the java project that we are contributing for. - * - * @return javaproject, may be <code>null</code> - * - * @since 1.0.0 - */ - public IJavaProject getJavaProject(); - - /** - * Return the map of containers (the key) that are found in the classpath. This is useful for determining - * if the container impliments a contributor interface. - * <p> - * Value will be {@link ContainerPaths} - * - * @return Map of containers. Keys of type String for container id (e.g. "SWT_CONTAINER" for a container classpath of "/SWT_CONTAINER/PDE/xyz". - * Values will be {@link ContainerPaths} Empty if launch not in a project. - * - * @since 1.0.0 - */ - public Map getContainers(); - - /** - * Return the map of container ids that are found in the classpath. - * <p> - * Key will be String and it is the first segment of a container path. Value will {@link ContainerPaths}. This - * will contain all of the visible and hidden paths that the project can see. All of the paths will have - * the key (container id) as the first segment of the path. - * - * @return map of container ids. Keys of type String. Values will be {@link ContainerPaths} Empty if launch not in a project. - * - * @since 1.0.0 - */ - public Map getContainerIds(); - - /** - * Return the map of plugin ids (the key) that are found in the classpath. - * <p> - * Value will <code>Boolean</code> and will be true if plugin was visible to top-level project. - * - * @return map of plugin ids. Key of type String. Empty if launch not in a project. - * - * @since 1.0.0 - */ - public Map getPluginIds(); - - /** - * Return the map of project paths (the key) that are found in the classpath. The top-level project - * will NOT be in this list since it is assumed to be visible to itself. - * <p> - * Value will <code>Boolean</code> and will be true if project was visible to top-level project. - * - * @return map of project paths. Key of type <code>IPath</code>. Empty if launch not in a project. - * - * @see org.eclipse.core.runtime.IPath - * @since 1.0.0 - */ - public Map getProjectPaths(); - - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributor.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributor.java deleted file mode 100644 index d456b480a..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributor.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; - - -/** - * This interface is used to contribute to the configuration that will be - * used to start a proxy registry. - * - * @since 1.0.0 - */ -public interface IConfigurationContributor { - - /** - * Called first before any of the other calls. This can be used to do any internal initializations - * required by the other calls. That way the other calls can have the order changed as the implementation - * requires. - * <p> - * NOTE: For those who nest configuration contributors (i.e. within an implementation of a contributor, more - * contributors are discovered) then it is imperitive that when those contributors are discovered that this method - * be called on them too. This is necessary so the contract with contributors can be followed. It is best if the - * discoveries are actually done in the initialize method itself so that it can pass the launch info right there. - * - * @param info info contains things like containers visible, etc. - * - * @see IConfigurationContributionInfo - * @since 1.0.0 - */ - public void initialize(IConfigurationContributionInfo info); - - /** - * Contribute to the classpath. The controller is used to do the actual contribution. - * - * @param controller - * @throws CoreException - * - * @since 1.0.0 - */ - public void contributeClasspaths(IConfigurationContributionController controller) throws CoreException; - - /** - * Contribute updates to the configuration. It will be called before the launch has started. - * - * @param config - * @throws CoreException - * - * @since 1.0.0 - */ - public void contributeToConfiguration(ILaunchConfigurationWorkingCopy config) throws CoreException; - - /** - * Contribute to the registry (or interact with the remote vm) after the registry has been - * created. - * - * @param registry - * - * @since 1.0.0 - */ - public void contributeToRegistry(ProxyFactoryRegistry registry); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConstructorProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConstructorProxy.java deleted file mode 100644 index 0bc00835c..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConstructorProxy.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * This is a proxy that allows a constructor to exist in the target VM - * and be referenced in the IDE VM - * Creation date: (1/17/00 1:21:52 PM) - * @author: Joe Winchester - */ -public interface IConstructorProxy extends IAccessibleObjectProxy { -/** - * Return a new instance with no creation arguments, - * i.e. for a null constructor - * Creation date: (1/17/00 1:22:11 PM) - */ -IBeanProxy newInstance() throws ThrowableProxy; -/** - * Return a new instance with the specified creation arguments - * Creation date: (1/17/00 1:22:11 PM) - */ -IBeanProxy newInstance(IBeanProxy[] creationArguments) throws ThrowableProxy; - -IBeanProxy newInstanceCatchThrowableExceptions(); -IBeanProxy newInstanceCatchThrowableExceptions(IBeanProxy[] creationArguments); - -IBeanTypeProxy[] getParameterTypes(); - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IDimensionBeanProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IDimensionBeanProxy.java deleted file mode 100644 index 549c1cb4f..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IDimensionBeanProxy.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - - -/** - * Interface to a Dimension bean proxy. - * <p> - * These are common for different windowing systems, e.g. AWT and SWT. So this here - * is common interface for them. - * Creation date: (4/7/00 3:46:39 PM) - * @author: Administrator - */ -public interface IDimensionBeanProxy extends IBeanProxy { - public int getHeight(); - public int getWidth(); - public void setHeight(int height); - public void setWidth(int width); - public void setSize(int width, int height); - public void setSize(IDimensionBeanProxy dim); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IExpression.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IExpression.java deleted file mode 100644 index 561fe4112..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IExpression.java +++ /dev/null @@ -1,1009 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import org.eclipse.jem.internal.proxy.initParser.tree.*; -import org.eclipse.jem.internal.proxy.initParser.tree.IExpressionConstants; -import org.eclipse.jem.internal.proxy.initParser.tree.NoExpressionValueException; - -/** - * This is an expression. It will be evaluated on the other side. The difference between an - * expression and using IMethodProxy's, IConstructorProxy's, etc. is the granularity. The proxies - * are one round-trip to the other side for each access or execution. The expression builds them up - * and will execute them all at once on the other side. Another difference is that the reflection - * will be done on the other side too. For instance when invoking a method, the method name is - * passed into the expression as a string then reflected and then invoked, while with method - * proxies, the string is used to find the proxy on the other side, and then a later round-trip - * will be used to invoke it. - * <p> - * Also an expression is a one-time use object. It can't be reused a second time. A new one must be - * built up again. - * <p> - * We are not using separate instances of expressions, and types of expressions, because we don't - * want to build up many objects (in a form of an expression tree) that will then be thrown away - * (one for each expression in the nested list of expressions). We just build the command list as - * we build the expression. - * <p> - * To use, you call the IStandardBeanProxyFactory's createExpression method. An IExpression is - * returned. From there you will start creating the contents of the expression. And then you will - * finally either getExpressionValue() to get the final value of the expression, or use - * invokeExpression() to just execute the expression(s). If you use getExpressionValue(), there can - * only be one root expression. If you use invokeExpression there can be more than one root - * expression, and they will all be executed. - * <p> - * Since sequence is so important, it will be tested and if anything is done out of order an - * IllegalStateException will be thrown. - * <p> - * Each time an expression is created, one argument passed in will be <code>forExpression</code> flag. - * This is a set of constants used as a clue for what expression this expression is being created. - * This is for a sanity check on the state. For example, when creating the array expression for an - * array access, the ARRAYACCESS_ARRAY flag is passed in. This way if the current expression on the - * stack is not for an array access waiting for the array expression, an IllegalStateException will be thrown. - * Without this flag, it would be easy to accidently create the wrong expression at the wrong time. - * Once such an error occurs, this IExpression will no longer be valid. IllegalStateException will be thrown - * for any type of access. - * <p> - * It is guarenteed that the entire stack of commands will be sent without stopping except for IllegalStateException - * due to out of order expressions. - * <p> - * <b>Note:</b> This interface is not meant to be neither instantiated nor implemented by customers. - * It is the interface into the expression processing. It is to be instantiated through the createExpression request. - * The {@link org.eclipse.jem.internal.proxy.core.Expression} class is available as API. It is not meant to - * be instantiated by customers, but customers can take the IExpression and cast to Expression for some advanced - * API. - * - * @see org.eclipse.jem.internal.proxy.core.IStandardBeanProxyFactory#createExpression() - * @see java.lang.IllegalStateException - * @since 1.0.0 - */ -public interface IExpression extends IExpressionConstants { - - /** - * Return the registry this expression is working against. - * @return - * - * @since 1.1.0 - */ - public ProxyFactoryRegistry getRegistry(); - - /** - * Invoke the expression(s). If there is more than one root expression, it will invoke them - * in the order created. If the expression stack is not complete, then <code>IllegalStateException</code> - * will be thrown. - * - * @throws ThrowableProxy - * @throws IllegalStateException - * @throws NoExpressionValueException - * - * @since 1.0.0 - */ - public void invokeExpression() throws ThrowableProxy, NoExpressionValueException, IllegalStateException; - - /** - * Return whether the expression is valid. It would be invalid if any of the create... calls had thrown an - * exception or if the expression has already been evaluated (invoked or getExpressionValue()). - * - * @return <code>true</code> if expression is valid, <code>false</code> if there had been some error, or if the expression has already been evaluated. - * - * @since 1.1.0 - */ - public boolean isValid(); - - /** - * Close the expression. This needs to be called if for some reason {@link IExpression#invokeExpression()} or {@link IExpression#getExpressionValue()} - * were not called. It is not an error to always call this after these calls. It will not have any problems with the expression already - * being closed. invoke and getvalue automatically call close for you. If you don't call close in case of an error, the resources - * for the expression will not be freed up. - * - * - * @since 1.1.0 - */ - public void close(); - - /** - * Invoke the root expression and return the value of the expression. If the expression stack - * is not complete, or if there is more than one root expression, then <code>IllegalStateException</code> - * will be thrown. - * - * @return The value of the root expression. - * - * @throws ThrowableProxy - * @throws IllegalStateException - * @throws NoExpressionValueException - * - * @since 1.0.0 - */ - public IBeanProxy getExpressionValue() throws ThrowableProxy, NoExpressionValueException, IllegalStateException; - - /** - * Create an Array Access (e.g. x[3]). - * This must be followed by create expressions for: - * <pre> - * <code>ARRAYACCESS_ARRAY</code> - * <code>ARRAYACCESS_INDEX</code> an indexCount times. - * </pre> - * <p> - * So the array access must be followed by 1+indexCount expressions. - * - * @param forExpression This is for what expression this expression is being created. - * @param indexCount The number of index expressions that will be created. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createArrayAccess(ForExpression forExpression, int indexCount) throws IllegalStateException; - - /** - * Create an Array Creation (e.g. <code>new int[3]</code> or <code>new int[3][]</code> or <code>new int[] {3, 4}</code>). - * If <code>dimensionExpressionCount</code> is zero, then there must be an initializer. This is because - * if there are any dimension expressions, then initializers are invalid and visa-versa. - * <p> - * The dimensionExpressionCount is for how many dimensions have an expression in them. For instance, - * <code>new int[3]</code> will have a dimensionExpressionCount of 1. While - * <code>new int[3][]</code> will also have count of 1. And finally - * <code>new int []</code> will have a count of 0. - * <p> - * This must be followed by create expressions for: - * <pre> - * <code>ARRAYCREATION_DIMENSION</code> a dimensionExpressionCount times, - * or an <code>createArrayInitializer()</code> if dimension count is 0. - * </pre> - * - * @param forExpression - * @param type This is the type. It must be fully-qualified and if an inner class, it must have the "$" format. It must also include the correct number of <code>[]</code> at the end. - * @param dimensionExpressionCount - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createArrayCreation(ForExpression forExpression, String type, int dimensionExpressionCount) throws IllegalStateException; - - /** - * Create an Array Creation (e.g. <code>new int[3]</code> or <code>new int[3][]</code> or <code>new int[] {3, 4}</code>). - * If <code>dimensionExpressionCount</code> is zero, then there must be an initializer. This is because - * if there are any dimension expressions, then initializers are invalid and visa-versa. - * <p> - * The dimensionExpressionCount is for how many dimensions have an expression in them. For instance, - * <ol> - * <li><code>new int[3]</code> will have a dimensionExpressionCount of 1. While - * <li><code>new int[3][]</code> will also have count of 1. And finally - * <li><code>new int []</code> will have a count of 0. - * </ol> - * The expressions that follow if dimensionExpressionCount is not zero must evaluate to be compatible to an int type (i.e. byte, char, short, or int). - * Each expression will be used to create an array for that dimension of that size. For example <code>new int[3][]</code> will have an - * dimension expression that evaluates to "3", and so it will create an array int[3][]. - * <p> - * This must be followed by create expressions for: - * dimensionExpressionCount times an: <code>ARRAYCREATION_DIMENSION</code> - * or an createArrayInitializer if dimension count is 0. - * - * @param forExpression - * @param type This is the type. This must be the actual type with the correct total number of dimensions (e.g. "java.lang.Object[][]"). - * @param dimensionExpressionCount number of int valued expressions that follow that give the size for each dimension. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @since 1.0.0 - */ - public void createArrayCreation(ForExpression forExpression, IProxyBeanType type, int dimensionExpressionCount) throws IllegalStateException, IllegalArgumentException; - - /** - * Create an array initializer. (e.g. <code>{2,3}</code>). - * This one is unusual in that there is no forExpression. That is because array initializers are only valid in - * certain places. And so if called when not expected, this is an IllegalStateException. - * <p> - * This must be followed by createExpressions for: - * expressionCount times an: <code>ARRAYINITIALIZER_EXPRESSION</code> - * except if the expression is another array initializer. That is valid and doesn't have a forExpression, - * but it does count as one of the expressionCounts. - * - * @param expressionCount Number of expressions, may be 0. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createArrayInitializer(int expressionCount) throws IllegalStateException; - - /** - * Create a cast expression (e.g. <code>(short)10</code> or <code>(java.lang.String) "asd"</code>) - * <p> - * This must be followed by createExpressions for: - * <code>CAST_EXPRESSION</code> - * - * @param forExpression - * @param type This is the type. It must be fully-qualified and if an inner class, it must have the "$" format. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createCastExpression(ForExpression forExpression, String type) throws IllegalStateException; - - /** - * Create a cast expression (e.g. <code>(short)10</code> or <code>(java.lang.String) "asd"</code>) - * <p> - * This must be followed by createExpressions for: - * <code>CAST_EXPRESSION</code> - * - * @param forExpression - * @param type This is the type. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @since 1.0.0 - */ - public void createCastExpression(ForExpression forExpression, IProxyBeanType type) throws IllegalStateException, IllegalArgumentException; - - /** - * Create a new class instance expression (e.g. <code>new java.lang.Integer(5)</code>) - * <p> - * This must be followed by createExpressions for: - * argumentCount times an: <code>CLASSINSTANCECREATION_ARGUMENT</code> - * - * <p> - * <b>Note:</b> This method can throw {@link org.eclipse.jem.internal.proxy.common.UnresolvedCompilationError} while processing - * and can be caught by an Expression try/catch. This is not thrown such that it can be caught by a real java try/catch. - * - * @param forExpression - * @param type This is the type. It must be fully-qualified and if an inner class, it must have the "$" format. - * @param argumentCount - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createClassInstanceCreation(ForExpression forExpression, String type, int argumentCount) throws IllegalStateException; - - /** - * Create a new class instance expression (e.g. <code>new java.lang.Integer(5)</code>) - * <p> - * This must be followed by createExpressions for: - * argumentCount times an: <code>CLASSINSTANCECREATION_ARGUMENT</code> - * - * <p> - * <b>Note:</b> This method can throw {@link org.eclipse.jem.internal.proxy.common.UnresolvedCompilationError} while processing - * and can be caught by an Expression try/catch. This is not thrown such that it can be caught by a real java try/catch. - * - * @param forExpression - * @param type This is the type. - * @param argumentCount - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @since 1.0.0 - */ - public void createClassInstanceCreation(ForExpression forExpression, IProxyBeanType type, int argumentCount) throws IllegalStateException, IllegalArgumentException; - - /** - * Create a conditional expression (e.g. <code>x != 3 ? 4 : 5</code>) - * <p> - * This must be followed by createExpressions for: - * <code>CONDITIONAL_CONDITION</code> - * <code>CONDITIONAL_TRUE</code> - * <code>CONDITIONAL_FALSE</code> - * - * @param forExpression - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createConditionalExpression(ForExpression forExpression) throws IllegalStateException; - - /** - * Create a field access (e.g. <code>java.awt.Color.red</code>) - * <p> - * Note: At this time we require a receiver. In the future it may be possible to not have one, but - * for that we need a <code>this</code> object to know who the receiver implicitly is. - * The receiver may be a "type receiver" if it is a type, e.g. <code>java.awt.Color</code>. - * <p> - * This must be followed by createExpressions for: - * <code>FIELD_RECEIVER</code> if hasReceiver is <code>true</code> - * - * @param forExpression - * @param fieldName The name of the field. - * @param hasReceiver Has a receiver flag. Currently this must always be true. This is because can't tell what class to look into for the field without a receiver. - * @throws IllegalArgumentException - * @throws IllegalStateException - * - * @see IExpression#createTypeReceiver(String) - * @since 1.0.0 - */ - public void createFieldAccess(ForExpression forExpression, String fieldName, boolean hasReceiver) throws IllegalArgumentException, IllegalStateException; - - /** - * Create a field access (e.g. <code>java.awt.Color.red</code>) - * <p> - * Note: At this time we require a receiver for non-static access. In the future it may be possible to not have one, but - * for that we need a <code>this</code> object to know who the receiver implicitly is. - * The receiver may be a "type receiver" if it is a type, e.g. <code>java.awt.Color</code>. - * <p> - * This must be followed by createExpressions for: - * <pre> - * <code>FIELD_RECEIVER</code> if hasReceiver is <code>true</code> - * </pre> - * - * @param forExpression - * @param fieldProxy The field proxy for the field. - * @param hasReceiver Has a receiver flag. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @see IExpression#createTypeReceiver(String) - * @since 1.0.0 - */ - public void createFieldAccess(ForExpression forExpression, IProxyField fieldProxy, boolean hasReceiver) throws IllegalStateException, IllegalArgumentException; - - /** - * Create an if/else stmt. Since this is a statment, there is no ForExpression. ROOT_EXPRESSION must be the next expression type. - * <p< - * This must be followed by createExpressions for: - * <pre> - * <code>IF_CONDITION</code> The if test, must return boolean. - * <code>IF_TRUE</code> The if condition is true clause. The clause may be an expression, or a block. - * <code>IF_ELSE</code> if hasElseClause is <code>true</code>. The else clause. The clause may be an expression, or a block. - * </pre> - * - * @param hasElseClause - * @throws IllegalStateException - * - * @since 1.1.0 - */ - public void createIfElse(boolean hasElseClause) throws IllegalStateException; - - /** - * Create an infix expression (e.g. <code>3 + 4</code> or <code>3 + 4 + 5</code>). - * <p> - * If there are more than 2 operands (all with the same operator) then for convienence all of - * the expression can be done in one expression than requiring several, one for each operator. - * If they are different operators, then different expressions will be required. - * <p> - * <pre> - * This must be followed by createExpressions for: - * <code>INFIX_LEFT</code> - * <code>INFIX_RIGHT</code> - * extendedOperandCount times an: <code>INFIX_EXTENDED</code> - * </pre> - * - * @param forExpression - * @param operator The operator. - * @param extendedOperandCount The number of extended operands. May be zero. - * @throws IllegalStateException - * - * @see org.eclipse.jem.internal.proxy.common.IExpressionConstants#IN_AND - * @since 1.0.0 - */ - public void createInfixExpression(ForExpression forExpression, InfixOperator operator, int extendedOperandCount) throws IllegalStateException; - - /** - * Create an instanceof expression (e.g. <code>x instanceof java.lang.String</code> - * <p> - * This must be followed by createExpression for: - * <code>INSTANCEOF_VALUE</code> - * @param forExpression - * @param type This is the type. It must be fully-qualified and if an inner class, it must have the "$" format. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createInstanceofExpression(ForExpression forExpression, String type) throws IllegalStateException; - - /** - * Create an instanceof expression (e.g. <code>x instanceof java.lang.String</code> - * <p> - * This must be followed by createExpression for: - * <code>INSTANCEOF_VALUE</code> - * @param forExpression - * @param type This is the type. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @since 1.0.0 - */ - public void createInstanceofExpression(ForExpression forExpression, IProxyBeanType type) throws IllegalStateException, IllegalArgumentException; - - /** - * Create a method invocation expression (e.g. <code>java.lang.String.valueOf(10)</code>). - * When using a string the method invoked will be the one most compatible with the arguments sent. - * This allows overloading a method to occur when coming in from a parse tree, since the parse tree - * doesn't know the exact method to use. - * <p> - * Note: At this time we require a receiver. In the future it may be possible to not have one, but - * for that we need a <code>this</code> object to know who the receiver implicitly is. - * The receiver may be a "type receiver" if it is a type, e.g. <code>java.awt.Color</code>. - * <p> - * This must be followed by createExpression for: - * <code>METHOD_RECEIVER</code> - * argumentCounts times expressions for: <code>METHOD_ARGUMENT</code> - * - * @param forExpression - * @param name The name of the method - * @param hasReceiver Has a receiver flag. Currently this must always be true. - * @param argumentCount Count of number of arguments. May be zero. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @see IExpression#createTypeReceiver(String) - * @since 1.0.0 - */ - public void createMethodInvocation(ForExpression forExpression, String name, boolean hasReceiver, int argumentCount) throws IllegalStateException, IllegalArgumentException; - - /** - * Create a method invocation expression (e.g. <code>java.lang.String.valueOf(10)</code>) - * <p> - * Note: At this time we require a receiver. In the future it may be possible to not have one, but - * for that we need a <code>this</code> object to know who the receiver implicitly is. - * The receiver may be a "type receiver" if it is a type, e.g. <code>java.awt.Color</code>. - * <p> - * This must be followed by createExpression for: - * <code>METHOD_RECEIVER</code> - * argumentCounts times expressions for: <code>METHOD_ARGUMENT</code> - * - * @param forExpression - * @param methodProxy The proxy of the method - * @param hasReceiver Has a receiver flag. Currently this must always be true. - * @param argumentCount Count of number of arguments. May be zero. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @see IExpression#createTypeReceiver(String) - * @since 1.0.0 - */ - public void createMethodInvocation(ForExpression forExpression, IProxyMethod methodProxy, boolean hasReceiver, int argumentCount) throws IllegalStateException, IllegalArgumentException; - - /** - * Create a prefix expression (e.g. <code>!flag</code> or <code>-(3+4)</code>). - * If you are just trying to create a signed numeric literal, just use the createPrimitiveLiteral passing in a - * negative value. You don't need to use prefix expression for that. - * <p> - * <pre> - * This must be followed by createExpressions for: - * <code>PREFIX_OPERAND</code> - * </pre> - * @param forExpression - * @param operator The operator. The values come from IExpressionConstants, the prefix constants. - * @throws IllegalStateException - * - * @see org.eclipse.jem.internal.proxy.common.IExpressionConstants#PRE_PLUS - * @since 1.0.0 - */ - public void createPrefixExpression(ForExpression forExpression, PrefixOperator operator) throws IllegalStateException; - - /** - * Create a reference to <code>null</code>. - * - * @param forExpression - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createNull(ForExpression forExpression) throws IllegalStateException; - - /** - * Create a type literal (e.g. <code>java.lang.String.class</code>). This is used when the type is being used as value itself, not - * as a receiver for a field or method or constructor or instanceof. Like as an argument to a method. - * <p> - * Note: If you want a type literal to be an IProxyBeanType, just use {@link IExpression#createProxyExpression(ForExpression, IProxy)} and pass in the - * IProxyBeanType. - * - * @param forExpression - * @param type This is the type. It must be fully-qualified and if an inner class, it must have the "$" format. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createTypeLiteral(ForExpression forExpression, String type) throws IllegalStateException; - - /** - * Create a type receiver. This is where a type is used as the receiver of a field access or a method invocation. - * (e.g. <code>java.lang.String.valueOf(10)</code>). For this the "java.lang.String" IBeanTypeProxy is the type receiver. - * <p> - * This is unusual in that there is no forExpression. It isn't needed because these are only valid - * in certain situations (method or field receiver) and if used anywhere else it is an error. - * - * @param type This is the type. It must be fully-qualified and if an inner class, it must have the "$" format. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createTypeReceiver(String type) throws IllegalStateException; - - /** - * Create a type receiver. This is where a type is used as the receiver of a field access or a method invocation. - * (e.g. <code>java.lang.String.valueOf(10)</code>). For this the "java.lang.String" IProxyBeanType is the type receiver. - * <p> - * This is unusual in that there is no forExpression. It isn't needed because these are only valid - * in certain situations (method or field receiver) and if used anywhere else it is an error. - * - * @param type This is the type proxy. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @since 1.0.0 - */ - public void createTypeReceiver(IProxyBeanType type) throws IllegalStateException, IllegalArgumentException; - - /** - * Create a boolean primitive literal (e.g. <code>true</code>). - * - * @param forExpression - * @param value The boolean value for the literal. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createPrimitiveLiteral(ForExpression forExpression, boolean value) throws IllegalStateException; - - /** - * Create a character literal (e.g. <code>'a'</code> or <code>'\n'</code>) - * - * @param forExpression - * @param value The character value for this literal. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createPrimitiveLiteral(ForExpression forExpression, char value) throws IllegalStateException; - - /** - * Create a byte literal (e.g. <code>(byte)10</code>) - * - * @param forExpression - * @param value The byte value for this literal. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createPrimitiveLiteral(ForExpression forExpression, byte value) throws IllegalStateException; - - /** - * Create a double literal (e.g. <code>10d</code>) - * - * @param forExpression - * @param value The double value for this literal. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createPrimitiveLiteral(ForExpression forExpression, double value) throws IllegalStateException; - - /** - * Create a float literal (e.g. <code>10f</code>) - * - * @param forExpression - * @param value The float value for this literal. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createPrimitiveLiteral(ForExpression forExpression, float value) throws IllegalStateException; - - /** - * Create a int literal (e.g. <code>100000</code>) - * - * @param forExpression - * @param value The int value for this literal. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createPrimitiveLiteral(ForExpression forExpression, int value) throws IllegalStateException; - - /** - * Create a long literal (e.g. <code>10l</code>) - * - * @param forExpression - * @param value The long value for this literal. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createPrimitiveLiteral(ForExpression forExpression, long value) throws IllegalStateException; - - /** - * Create a short literal (e.g. <code>(short)10</code>) - * - * @param forExpression - * @param value The short value for this literal. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createPrimitiveLiteral(ForExpression forExpression, short value) throws IllegalStateException; - - /** - * Create a string literal (e.g. <code>"asdf"</code>). The value is the actual string, with escapes already - * translated into the true character values. - * - * @param forExpression - * @param value The string value for this literal. - * @throws IllegalStateException - * - * @since 1.0.0 - */ - public void createStringLiteral(ForExpression forExpression, String value) throws IllegalStateException; - - /** - * Create a subexpression. - * <p> - * A subexpression allows, at any time, to fork off the expression stack and do some other sets of expressions. - * When the cooresponding {@link #createSubexpressionEnd()} is called, all of the expression results on the - * stack that accumulated during the subexpression evaluation will be thrown away and the stack will be - * what it was at the start of subexpression. Any ExpressionProxies that were resolved during the evaluation - * will not be thrown away and will still be valid. - * <p> - * This is useful if in the middle of an expression (such as method invocation and an argument is needed) to - * go off and get the necessary value. This will allow expressions that require ROOTEXPRESSION state like a - * try/catch. If you know the expression doesn't need this, then it is more efficient to not use subexpression. - * <p> - * For example: - * <pre><code> - * new XYZ( - * {(subexpression) - * try { - * x = 3*y.get(); - * } catch (Exception e) { - * x =4; - * } - * (end subexpression)} - * x); - * </code></pre> - * - * In the above example, we needed to calculate "x" as the argument for XYZ, but it was too complicated and - * could throw exceptions. So we used a subexpression instead. - * <p> - * Of course the following would of been the better way to do it without subexpressions. But sometimes - * your code is in a position that you don't know you need to do this until it is too late. - * <pre><code> - * try { - * x = 3*y.get(); - * } catch (Exception e) { - * x =4; - * } - * new XYZ(x); - * </code></pre> - * @throws IllegalStateException - * - * @since 1.1.0 - */ - public void createSubexpression() throws IllegalStateException; - - public void createSubexpressionEnd() throws IllegalStateException; - - /** - * Create an expression that has an existing bean proxy as its value. - * - * @param forExpression This is for what expression this expression is being created. - * @param proxy The proxy that should be used as a value, either a bean proxy or an expression proxy. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @since 1.0.0 - */ - public void createProxyExpression(ForExpression forExpression, IProxy proxy) throws IllegalStateException, IllegalArgumentException; - - /** - * Create an assignment expression between a VariableReference and an expression. The left operand must be a variable reference (e.g. FieldAccess or - * ArrayAccess). The right operand may be any expression that results in a value. - * <p> - * <pre> - * This must be followed by createExpressions for: - * <code>ASSIGNMENT_LEFT</code> - * <code>ASSIGNMENT_RIGHT</code> - * </pre> - * @param forExpression - * @throws ThrowableProxy - * @throws IllegalStateException - * @throws NoExpressionValueException - * - * @since 1.1.0 - */ - public void createAssignmentExpression(ForExpression forExpression) throws IllegalStateException; - - /** - * Create an assignment expression (e.g. x = 3+4) where x will be assigned to the ExpressionProxy. - * It may be used later on as a value in {@link IExpression#createExpressionProxyExpression(int, ExpressionProxy)}. - * Or if callbacks were added, the callbacks would be called to return the true IBeanProxy value of the expression proxy when the complete - * IExpression has been evaluated. The value of the assignment expression (e.g. x) will be passed on into the next expression. - * <p> - * <pre> - * This must be followed by createExpressions for: - * <code>ASSIGNMENT_RIGHT</code> - * </pre> - * <p> - * <b>Note:</b> It is guarenteed as part of the contract that expression proxies will be notified through the listeners of the final state in the - * order the expression proxies were created. - * @param forExpression This is for what expression this expression is being created. - * @return a proxy to the expression value. - * @throws IllegalStateException - * - * @since 1.1.0 - */ - public ExpressionProxy createProxyAssignmentExpression(ForExpression forExpression) throws IllegalStateException; - - /** - * Create a reassignment expression. This is like the original proxy assignment except that instead of returning a new proxy, it - * reassigns the new value to the existing proxy. This cannot be used on IBeanTypeExpressionProxy's. That is because - * they are controlled by the registry and severe errors would occur if they were reassigned. - * <p> - * <pre> - * This must be followed by createExpressions for: - * <code>ASSIGNMENT_RIGHT</code> - * </pre> - * <p> - * <b>Note:</b> Since we are not creating a new proxy, the notification on the callbacks will be in the original order of proxies. This - * does not change the notification position of this proxy. - * - * @param forExpression - * @param proxy - * @throws IllegalStateException - * @throws IllegalArgumentException if the expression proxy is for a BeanType instead of just a standard expression proxy. - * - * @since 1.1.0 - */ - public void createProxyReassignmentExpression(ForExpression forExpression, ExpressionProxy proxy) throws IllegalStateException, IllegalArgumentException; - - /** - * A simple method invocation. This is a helper to make it easier for a simple method invoke. It uses only the - * method proxy (not a string to look it up), it uses a IBeanProxy receiver (not a complicated expression), and the - * arguments are a mixture of IBeanProxies and ExpressionProxies. Also it can be called only when the next - * expression must be a RootExpression. - * - * @param method methodproxy of the method - * @param receiver the receiver proxy or <code>null</code> if a static method - * @param arguments array of arguments, where each element can only be either <code>null</code> for a null argument, <code>IProxy</code>. The array can be <code>null</code> if no arguments. - * @param wantResult <code>true</code> if you want an ExpressionProxy back, otherwise it will return <code>null</code>. For performance reasons, only use <code>true</code> if you really need the expression proxy. - * @return expression proxy if "wantResult" was true, else <code>null</code>. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @since 1.1.0 - */ - public ExpressionProxy createSimpleMethodInvoke(IProxyMethod method, IProxy receiver, IProxy[] arguments, boolean wantResult) throws IllegalStateException, IllegalArgumentException; - - /** - * A simple field access. This is a helper to make it easier for a simple field access. It uses only the - * field proxy (not a string to look it up), and the bean proxy that is the receiver. Also it can be called only when the next - * expression must be a RootExpression. It doesn't allow complicated field access, such as <code>fielda.fieldb.fieldc</code>. - * Since this is a field access, it will always return an ExpressionProxy. It doesn't make sense to have a simple field access - * that doesn't return one. - * - * @param field field proxy of the field. - * @param receiver the receiver proxy. It may be <code>null</code> for static fields. - * @return expression proxy to the result of the access. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @since 1.1.0 - */ - public ExpressionProxy createSimpleFieldAccess(IProxyField field, IProxy receiver) throws IllegalStateException, IllegalArgumentException; - - /** - * A simple field set. This is a helper to make it easier for a simple field access. It uses only the - * field proxy (not a string to look it up), and the bean proxy that is the receiver. Also it can be called only when the next - * expression must be a RootExpression. It doesn't allow complicated field access setting, such as <code>fielda.fieldb.fieldc = 3</code>. - * - * @param field field proxy of the field. - * @param receiver the receiver proxy. It may be <code>null</code> if this is a static field. - * @param value the value proxy to set it to or <code>null</code> if set to null value. - * @param wantResult <code>true</code> if you want an ExpressionProxy back, otherwise it will return <code>null</code>. For performance reasons, only use <code>true</code> if you really need the expression proxy. - * @return expression proxy if "wantResult" was true, else <code>null</code>. - * @throws IllegalStateException - * @throws IllegalArgumentException - * - * @since 1.1.0 - */ - public ExpressionProxy createSimpleFieldSet(IProxyField field, IProxy receiver, IProxy value, boolean wantResult) throws IllegalStateException, IllegalArgumentException; - - /** - * Begin a block. No need for a forExpression because it must currently be at ROOTEXPRESSION. - * <p> - * Eventually {@link Expression#createBlockEnd()} must be called. You should use this pattern: - * <pre><code> - * exp.createBeginBlock(); - * try { - * exp.create something else. - * ... - * } finally { - * exp.createEndBlock(); - * } - * </code></pre> - * - * @return blocknumber for the block just opened. Can be used in {@link Expression#createBlockBreak(int)}. - * @throws IllegalStateException - * - * @since 1.1.0 - */ - public int createBlockBegin() throws IllegalStateException; - - /** - * Does a break for the specified block number. No need for a forExpression because it must currently be at ROOTEXPRESSION. - * @param blockNumber - * @throws IllegalStateException - * - * @since 1.1.0 - */ - public void createBlockBreak(int blockNumber) throws IllegalStateException; - - /** - * End a block. It will always end the inner most block that currently is on the stack. No need for a forExpression because it must currently be at ROOTEXPRESSION. - * @throws IllegalStateException - * - * @see Expression#createBlockBegin() - * @since 1.1.0 - */ - public void createBlockEnd() throws IllegalStateException; - - /** - * Create a try/catch statement. No need for a forExpression because it must currently be at ROOTEXPRESSION. - * There must be at least one catch or finally clause before try end or this is invalid. - * <p> - * This should be executed in the following way: - * <pre><code> - * exp.createTry(); - * try { - * ... create other exceptions ... - * ... create catch/finally clauses as needed. - * } finally { - * if (exp.isValid()) - * exp.createTryEnd(); - * } - * </code></pre> - * @throws IllegalStateException - * - * @since 1.1.0 - */ - public void createTry() throws IllegalStateException; - - - /** - * Create a catch clause for the inner most try statement. No need for a forExpression because it must currently be at ROOTEXPRESSION. - * <p> - * Using this you can get just the exception as a proxy and/or execute some expressions as part of the catch clause. - * <p> - * This can be followed by RootExpressions, or another catch, or a finally, or a try end. - * - * @param exceptionType the type of the exception to catch on. - * @param wantExceptionReturned <code>true</code> if you want an expression proxy for the exception. - * @return the ExpressionProxy for the exception if <code>wantExceptionReturned</code> is <code>true</code>, <code>null</code> otherwise. - * - * @throws IllegalStateException - * @throws IllegalArgumentException - * @since 1.1.0 - */ - public ExpressionProxy createTryCatchClause(IProxyBeanType exceptionType, boolean wantExceptionReturned) throws IllegalStateException, IllegalArgumentException; - - /** - * Create a catch clause for the inner most try statement. No need for a forExpression because it must currently be at ROOTEXPRESSION. - * <p> - * Using this you can get just the exception as a proxy and/or execute some expressions as part of the catch clause. - * <p> - * This can be followed by RootExpressions, or another catch, or a finally, or a try end. - * - * @param exceptionType the type of the exception to catch on. - * @param wantExceptionReturned <code>true</code> if you want an expression proxy for the exception. - * @return the ExpressionProxy for the exception if <code>wantExceptionReturned</code> is <code>true</code>, <code>null</code> otherwise. - * - * @throws IllegalStateException - * @since 1.1.0 - */ - public ExpressionProxy createTryCatchClause(String exceptionType, boolean wantExceptionReturned) throws IllegalStateException;; - - /** - * Create a finally clause for the inner most try statement. No need for a forExpression because it must currently be at ROOTEXPRESSION. - * There must be no more catch clauses for the try statement after this finally clause. - * - * @throws IllegalStateException - * @since 1.1.0 - */ - public void createTryFinallyClause() throws IllegalStateException;; - - /** - * Create the end of the inner most try statement. No need for a forExpression because it must currently be at ROOTEXPRESSION. - * There must be no more catch/finally clauses after this except if a new try statement is started. - * - * @throws IllegalStateException - * @since 1.1.0 - */ - public void createTryEnd() throws IllegalStateException;; - - /** - * Create a throw. No need for a forExpression because it must currently be at ROOTEXPRESSION. - * The next expression is the exception to be thrown. - * <p> - * This must be followed by createExpression for: - * <code>THROW_OPERAND</code> - * - * @throws IllegalStateException - * - * @since 1.1.0 - */ - public void createThrow() throws IllegalStateException; - - /** - * Create a rethrow. This must be within a catch clause or there is an error. - * <p> - * This is a shortcut for: - * <pre><code> - * try { - * .. do something .. - * } catch (AnException e) { - * .. do something .. - * throw e; - * } - * </code></pre> - * @throws IllegalStateException - * - * @since 1.1.0 - */ - public void createRethrow() throws IllegalStateException; - - - /** - * Mark the expression stack so that if there are IllegalStateExceptions errors that would make the - * expression invalid, you can restore back to this mark point and the expression will now be valid - * again and at the state it was when mark was created. All marks must be ended, and at the same nesting - * level. - * <p> - * No need for a forExpression because it must currently be at ROOTEXPRESSION. - * <p> - * It must be used in conjunction with endMark. You must use <code>mark;try/finally{endMark;}</code> because - * the mark/endMark must match up. - * <pre><code> - * int mark = expression.mark(); - * try { - * expression.create ... - * } catch (IllegalStateException e) { - * process the error. - * } finally { - * expression.endMark(mark); // After this, the expression will be valid again. - * } - * </code></pre> - * <p> - * However, the following code would be invalid nesting, and will throw an IllegalStateException on the createTryEnd. This is because - * we tried to end the Try statement within the mark. This is invalid because if we let it go through it would - * of popped the stack and when we got to the endMark the stack would of been popped past it and it could not - * be restored to the same state as it was at the time of the mark. The try would of already been ended. - * <pre><code> - * expression.createTry(); - * int mark = expression.mark(); - * try { - * expression.create ... - * expression.createTryEnd(); - * } catch (IllegalStateException e) { - * process the error. The expression is now invalid. - * } finally { - * expression.endMark(mark); // After this, the expression will be valid again, if it had gone invalid. - * } - * </code></pre> - * <p> - * If not at RootExpression at time of mark() request, an IllegalStateException will be thrown. - * @return mark number, this number will be used in the cooresponding endMark. - * @throws IllegalStateException - * - * @see IExpression#endMark(int) - * @since 1.1.0 - */ - public int mark() throws IllegalStateException; - - /** - * The end mark for a mark. - * <p> - * No need for a forExpression because it must currently be at ROOTEXPRESSION. - * @param markNumber - * @throws IllegalStateException - * - * @see IExpression#mark() - * @since 1.1.0 - */ - public void endMark(int markNumber) throws IllegalStateException; -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IExtensionRegistration.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IExtensionRegistration.java deleted file mode 100644 index f3ebe3822..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IExtensionRegistration.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - - -/** - * Extensions point ("extensions" elements of the "org.eclipse.jem.proxy.contributors" extension point). - * <p> - * Implementers of this interface are called when the appropriate registry type for a given classPath/plugin is present. - * It is used to register the registry type specific extensions. - * @since 1.1.0 - */ -public interface IExtensionRegistration { - - /** - * This will be called before any contributeToRegistry's have been called. Typically all that - * should be done in here is to register extension factories or constants. It is best if no - * actual proxy calls are made. This is because the registry does not yet have all of the - * appropriate extensions registered and it would be possible to accidently reference a bean type - * that has not yet had its appropriate factory registered. - * <p> - * <b>Note:</b> This may be called more than once if used in more than one extension or if used in a plugin and a container path and both are found. - * Should take this into account and not register twice. - * @param baseRegistry - * - * @since 1.1.0 - */ - public void register(BaseProxyFactoryRegistry baseRegistry); - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IFieldProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IFieldProxy.java deleted file mode 100644 index b79db1b40..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IFieldProxy.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * A Proxy to a field that allows the field value to be retrieved and set - * This allows target VM proxying of the field and is analagous to the java.lang.Reflect.Field - * in the same way IMethodProxy is analagous to java.lang.Reflect.Method - * Creation date: (1/17/00 12:17:52 PM) - * @author: Joe Winchester - */ -public interface IFieldProxy extends IAccessibleObjectProxy, IProxyField { -/** - * Return the type of the field. - */ -IBeanTypeProxy getFieldType(); - -/** - * Return the value of us on the subject argument. - * If the field is a primitive type, the return proxy - * will be of the primitive type too. - * Creation date: (1/17/00 12:28:48 PM) - */ -IBeanProxy get(IBeanProxy aSubject) throws ThrowableProxy; - -/** - * Set the argument as the field value on the subject - * Creation date: (1/17/00 12:28:48 PM) - */ -void set(IBeanProxy aSubject, IBeanProxy argument) throws ThrowableProxy; - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IIntegerBeanProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IIntegerBeanProxy.java deleted file mode 100644 index a8dd2b48d..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IIntegerBeanProxy.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Interface to an integer bean proxy. - * We originally had only an Integer proxy, - * so the use of it was throughout the system. - * We are now supporting Number instead, but - * because there were so many places using int, - * we've left it in. - * Creation date: (2/6/00 8:52:42 AM) - * @author: Joe Winchester - */ -public interface IIntegerBeanProxy extends INumberBeanProxy { -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IInvokable.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IInvokable.java deleted file mode 100644 index c55167500..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IInvokable.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - - -/** - * Interface for invoking method calls on the vm. - * IMethodProxy implements it for when you have a method proxy available, - * but you can also get a straight invokable which will get the - * proxy on the vm at the time of execution. - * <p> - * The method proxy factory can be used to return either method - * proxies when the invokable will be used over and over, and - * it can return IInvokable's when it is one shot deal. Though even - * when one-shot deal it can be used over and over. There is just overhead because the - * method is looked up each time. So a reasonable compromise would be if - * using it infrequently or use closely together once or twice it is better - * to use a Invokable instead of a method proxy. - * @since 1.0.0 - */ -public interface IInvokable { - - /** - * Invoke us on the subject - * Creation date: (12/3/99 11:37:12 AM) - * @author Joe Winchester - */ - IBeanProxy invoke(IBeanProxy subject) throws ThrowableProxy; - - /** - * Invoke us on the subject with the specified argument - * Creation date: (12/3/99 11:37:12 AM) - * @author Joe Winchester - */ - IBeanProxy invoke(IBeanProxy subject, IBeanProxy argument) throws ThrowableProxy; - - /** - * Invoke us on the subject with the specified arguments - * Creation date: (12/3/99 11:37:12 AM) - * @author Joe Winchester - */ - IBeanProxy invoke(IBeanProxy subject, IBeanProxy[] arguments) throws ThrowableProxy; - - /** - * Invoke us on the subject, however catch all exceptions - * Only to be used when you don't want ThrowableExceptions. This should - * not be the normal way to invoke. - * Creation date: (12/3/99 11:37:12 AM) - * @author Joe Winchester - */ - IBeanProxy invokeCatchThrowableExceptions(IBeanProxy subject); - - /** - * Invoke us on the subject with the specified argument, however catch all exceptions - * Only to be used when you don't want ThrowableExceptions. This should - * not be the normal way to invoke. - * Creation date: (12/3/99 11:37:12 AM) - * @author Joe Winchester - */ - IBeanProxy invokeCatchThrowableExceptions(IBeanProxy subject, IBeanProxy argument); - - /** - * Invoke us on the subject with the specified arguments, however catch all exceptions - * Only to be used when you don't want ThrowableExceptions. This should - * not be the normal way to invoke. - * Creation date: (12/3/99 11:37:12 AM) - * @author Joe Winchester - */ - IBeanProxy invokeCatchThrowableExceptions(IBeanProxy subject, IBeanProxy[] arguments); - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IMethodProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IMethodProxy.java deleted file mode 100644 index e04442c40..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IMethodProxy.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -/** - * Interface for Method Proxies Creation date: (12/3/99 11:36:29 AM) - * - * @author: Joe Winchester - */ -public interface IMethodProxy extends IAccessibleObjectProxy, IInvokable, IProxyMethod { - - /** - * Answer the class the method is defined in. Creation date: (12/3/99 11:37:12 AM) - * - * @author Joe Winchester - */ - IBeanTypeProxy getClassType(); - - /** - * Answer the name of the method Creation date: (12/3/99 11:37:12 AM) - * - * @author Joe Winchester - */ - String getName(); - - /** - * Answer the parameter types of the method Creation date: (12/3/99 11:37:12 AM) - * - * @author Joe Winchester - */ - IBeanTypeProxy[] getParameterTypes(); - - /** - * Answer the return type of the method Creation date: (12/3/99 11:37:12 AM) - * - * @author Joe Winchester - */ - IBeanTypeProxy getReturnType(); - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IMethodProxyFactory.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IMethodProxyFactory.java deleted file mode 100644 index 216cdcc1a..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IMethodProxyFactory.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -/** - * Factory for creating method proxies. - * - * The factory exists for use, but generally it is better to go through the bean type proxy to get a method proxy. This is useful for setting up a - * bunch of method proxies in initialization routines so you don't need to have a bean type proxy for each. - * - * Creation date: (12/3/99 6:21:52 PM) - * - * @author: Joe Winchester - */ -public interface IMethodProxyFactory extends IBeanProxyFactory { - - /** - * Return a method proxy for the specified name, arguments from the class. - * - * @param className - * @param methodName - * @param parameterTypes - * parameter type names or <code>null</code> for parameterTypes means no parameters. - * @return a method proxy or null if can't be found. - * @since 1.0.0 - */ - IMethodProxy getMethodProxy(String className, String methodName, String[] parameterTypes); - - /** - * Return an IProxyMethod for the specified name, arguments from the given class. - * @param expression - * @param className - * @param methodName - * @param parameterTypes - * @return - * - * @since 1.1.0 - */ - IProxyMethod getMethodProxy(IExpression expression, String className, String methodName, String[] parameterTypes); - - /** - * Return an IProxyField for the specified name, arguments from the given class. - * @param expression - * @param className - * @param fieldName - * @return - * - * @since 1.1.0 - */ - IProxyField getFieldProxy(IExpression expression, String className, String fieldName); - - - /** - * Return an invokable for the specified name, arguments from the class. The method proxy is not retrieved. Instead the method will be looked up - * each time on the vm. Because of this these are suitable only for one-shot invokations. If it is to be invoked often, then a method proxy should - * be retrieved instead. - * <p> - * Though typical for one-shot deal the invokable can be used over and over. There is just overhead because the method is looked up each time. So a reasonable compromise - * would be if using it infrequently or is used closely together once or twice it is better to use a Invokable instead of a method proxy. - * <p> - * Note there is no guarantee that the method is available. This won't be known until the actual invoke is done. - * - * @param className - * @param methodName - * @param parameterTypes - * parameter type names or <code>null</code> for parameterTypes means no parameters. - * @return an invokable - * @since 1.0.0 - */ - IInvokable getInvokable(String className, String methodName, String[] parameterTypes); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/INumberBeanProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/INumberBeanProxy.java deleted file mode 100644 index efe7a4297..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/INumberBeanProxy.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Interface to an integer bean proxy. - * Creation date: (2/6/00 8:52:42 AM) - * @author: Joe Winchester - */ -public interface INumberBeanProxy extends IBeanProxy { -/** - * Return the primitive byte value of the proxied Number - * Creation date: (2/6/00 8:52:59 AM) - */ -byte byteValue(); -/** - * Return the primitive double value of the proxied Number - * Creation date: (2/6/00 8:52:59 AM) - */ -double doubleValue(); -/** - * Return the primitive float value of the proxied Number - * Creation date: (2/6/00 8:52:59 AM) - */ -float floatValue(); -/** - * Return the primitive int value of the proxied Number - * Creation date: (2/6/00 8:52:59 AM) - */ -int intValue(); -/** - * Return the primitive long value of the proxied Number - * Creation date: (2/6/00 8:52:59 AM) - */ -long longValue(); -/** - * Return the value as a Number. - * Creation date: (2/6/00 8:52:59 AM) - */ -Number numberValue(); -/** - * Return the primitive short value of the proxied Number - * Creation date: (2/6/00 8:52:59 AM) - */ -short shortValue(); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IPDEContributeClasspath.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IPDEContributeClasspath.java deleted file mode 100644 index 6c1687066..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IPDEContributeClasspath.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import org.eclipse.core.runtime.CoreException; - - -/** - * Contribute to classpath PDE entries that are needed for a launch. - * <p> - * Use the <code>INSTANCE()</code> to access the contributor. If the value - * is <code>null</code>, then PDE is not available. - * - * @since 1.0.2 - */ -public interface IPDEContributeClasspath { - - public static IPDEContributeClasspath INSTANCE = PDEContributeClasspathInstance.getInstance(); - - /** - * Return the classpath contributions for the plugins in the given project. - * <p> - * This will add in the libraries from any fragments of any plugin that this - * project references, either directly or indirectly through other plugins. - * <p> - * It is used by launches to get the fragment libraries since these are not - * added by default to the classpath for a project by PDE. That is because they - * aren't needed for compilation purposes, but they are needed for running. - * - * @param controller the controller to contribute to. - * @param info configuration info for the project - * @throws CoreException - * - * @since 1.0.2 - */ - public abstract void getPDEContributions(IConfigurationContributionController controller, IConfigurationContributionInfo info) throws CoreException; -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IPointBeanProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IPointBeanProxy.java deleted file mode 100644 index a41a51aa5..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IPointBeanProxy.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Interface to a Point bean proxy. - * <p> - * These are common for different windowing systems, e.g. AWT and SWT. So this here - * is common interface for them. - * Creation date: (4/7/00 3:46:39 PM) - * @author: Administrator - */ -public interface IPointBeanProxy extends IBeanProxy { - public int getX(); - public int getY(); - public void setX(int x); - public void setY(int y); - public void setLocation(int x, int y); - public void setLocation(IPointBeanProxy point); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxy.java deleted file mode 100644 index dfaf838a6..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxy.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - - -/** - * A common interface for proxies. It is used by the expression processor to easily distinquish between - * a proxy and an Expression proxy. - * @since 1.1.0 - */ -public interface IProxy { - - /** - * Return the registry this proxy was created with. - * @return - * - * @since 1.1.0 - */ - public ProxyFactoryRegistry getProxyFactoryRegistry(); - - /** - * Is this a bean proxy (including all of the subinterfaces of it, like IMethodProxy). - * @return <code>true</code> if this is a bean proxy. - * - * @since 1.1.0 - */ - public boolean isBeanProxy(); - - /** - * Is this an expression proxy. - * @return <code>true</code> if this is an expression proxy. - * - * @since 1.1.0 - */ - public boolean isExpressionProxy(); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyBeanType.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyBeanType.java deleted file mode 100644 index 59635a732..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyBeanType.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - - -/** - * This interface is for IBeanTypeProxy's and BeanTypeExpressionProxy's so that we can lazily - * get the beantype proxy and have the expression process it when needed. - * - * @since 1.1.0 - */ -public interface IProxyBeanType extends IProxy { - - /** - * Answer the name of the type we are proxying This is the fully qualified name. For arrays it will return the format: [Lclassname; - * @return - * - * @since 1.1.0 - */ - public String getTypeName(); - - /** - * Get the IProxyMethod for the method from this beantype. It may be either a resolved method proxy (if already resolved) or - * it may be an ExpressionProxy if not yet resolved. - * - * @param expression - * @param methodName - * @param parameterTypes array of parameter types or <code>null</code> if no parameters. - * @return - * - * @since 1.1.0 - */ - public IProxyMethod getMethodProxy(IExpression expression, String methodName, IProxyBeanType[] parameterTypes); - - /** - * Get the IProxyMethod for the method from this beantype where the method has no arguments. It may be either a resolved method proxy (if already resolved) or - * it may be an ExpressionProxy if not yet resolved. - * <p> - * This is a shortcut for getMethodProxy() that takes arguments names where the names have been sent as null. - * - * @param expression - * @param methodName - * @return - * - * @since 1.1.0 - */ - public IProxyMethod getMethodProxy(IExpression expression, String methodName); - - /** - * Get the IProxyMethod for the method from this beantype. It may be either a resolved method proxy (if already resolved) or - * it may be an ExpressionProxy if not yet resolved. - * - * @param expression - * @param methodName - * @param parameterTypes array of parameter types or <code>null</code> if no parameters. - * @return - * - * @since 1.1.0 - */ - public IProxyMethod getMethodProxy(IExpression expression, String methodName, String[] parameterTypes); - - /** - * Get the IProxyyField for the field from this beantype. It may be either a resolved field proxy (if already resolved) or - * it may be an ExpressionProxy if not yet resolved. - * - * @param expression - * @param fieldName - * @return - * - * @since 1.1.0 - */ - public IProxyField getFieldProxy(IExpression expression, String fieldName); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyConstants.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyConstants.java deleted file mode 100644 index 0d819f3f6..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyConstants.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -/** - * Constants used with the plugin xml. - * - * @since 1.0.0 - */ -public interface IProxyConstants { - - /** - * Launch group id for proxy launch configurations. - */ - public static final String ID_PROXY_LAUNCH_GROUP = "org.eclipse.jem.proxy"; //$NON-NLS-1$ - - /** - * Launch configuration type for local proxy. It is local in that it is on the same machine, but a different - * VM then the one running the IDE. - * - * It here because this is the default config type when no launch config specified for a project. - */ - public static final String LOCAL_LAUNCH_TYPE = "org.eclipse.jem.proxy.LocalProxyLaunchConfigurationType"; //$NON-NLS-1$ - - /** - * Attribute on Proxy Launch Configuration: - * - * Key used in Launch Configuration for attaching AWT/Swing to the registry. This means simply - * that AWT/Swing should be treated as being in the registry or not. It doesn't actually prevent - * them from being there. - * - * The default value for this attribute is "true", so it should be set only to "false". - */ - public static final String ATTRIBUTE_AWT_SWING = "org.eclipse.jem.proxy.AWT/Swing"; //$NON-NLS-1$ - - /** - * Attribute on Proxy Launch Configuration: - * - * Key used in Launch Configuration for the contributors and returning the registry. After retrieving key, - * go back to ProxyLaunchSupport to retrieve the contributors. And it uses it to return the registry. - * - * Not to be set by contributors. This will be set only by the ProxyLaunchSupport start implementation methods. - * It is here only because external developer's launch configurations will need to be able to access this. - */ - public static final String ATTRIBUTE_LAUNCH_KEY = "org.eclipse.jem.proxy.LaunchKey"; //$NON-NLS-1$ - - /** - * Attribute on Proxy Launch Configuration: - * - * VM title used for the launch registry. - * - * Not to be set by contributors. This will be set only by the ProxyLaunchSupport start implementation methods. - * It is here only because external developer's launch configurations will need to be able to access this. - */ - public static final String ATTRIBUTE_VM_TITLE = "org.eclipse.jem.proxy.vmtitle"; //$NON-NLS-1$ - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyField.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyField.java deleted file mode 100644 index 1f2e1da3a..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyField.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - - -/** - * This interface is for IFieldProxy's and FieldExpressionProxy's so that we can lazily - * get the field proxy and have the expression process it when needed. - * @since 1.1.0 - */ -public interface IProxyField extends IProxy { - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyMethod.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyMethod.java deleted file mode 100644 index f260a234f..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IProxyMethod.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - - -/** - * This interface is for IMethodProxy's and MethodExpressionProxy's so that we can lazily - * get the method proxy and have the expression process it when needed. - * - * @since 1.1.0 - */ -public interface IProxyMethod extends IProxy { - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IRectangleBeanProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IRectangleBeanProxy.java deleted file mode 100644 index f38660d37..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IRectangleBeanProxy.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Interface to a Rectangle bean proxy. - * <p> - * These are common for different windowing systems, e.g. AWT and SWT. So this here - * is common interface for them. - * Creation date: (4/7/00 3:46:39 PM) - * @author: Administrator - */ -public interface IRectangleBeanProxy extends IBeanProxy { - public int getX(); - public int getY(); - public void setX(int x); - public void setY(int y); - public void setLocation(int x, int y); - public void setLocation(IPointBeanProxy point); - - public int getHeight(); - public int getWidth(); - public void setHeight(int height); - public void setWidth(int width); - public void setSize(int width, int height); - public void setSize(IDimensionBeanProxy dim); - - public void setBounds(int x, int y, int width, int height); - public void setBounds(IRectangleBeanProxy rect); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IStandardBeanProxyFactory.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IStandardBeanProxyFactory.java deleted file mode 100644 index 4353e522c..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IStandardBeanProxyFactory.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; - - -/* - - - */ - - -/** - * The Standard base bean proxy factory. - * This is the Interface that the desktop will talk - * to. - * Creation date: (12/3/99 11:52:09 AM) - * @author: Joe Winchester - */ -public interface IStandardBeanProxyFactory extends IBeanProxyFactory { - -/** - * Get the {@link org.eclipse.jem.internal.proxy.common.IVMServer} proxy for the - * this registry. This is only needed if you need to give the IVMserver to a proxy so that - * it can access it. - * <p> - * <b>Note:</b> Does not need to be given to callback proxies because they are given - * an {@link org.eclipse.jem.internal.proxy.common.IVMCallbackServer} on initialization, and - * that interface implements the IVMServer interface too. - * - * @return - * - * @since 1.1.0 - */ -public IBeanProxy getIVMServerProxy(); -/** - * Return a new bean proxy for the primitive integer argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public IIntegerBeanProxy createBeanProxyWith(int aPrimitiveInteger); -/** - * Return a new bean proxy for the primitive character argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public ICharacterBeanProxy createBeanProxyWith(char aPrimitiveCharacter); -/** - * Return a new bean proxy for the primitive byte argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public INumberBeanProxy createBeanProxyWith(byte aPrimitiveByte); -/** - * Return a new bean proxy for the primitive short argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public INumberBeanProxy createBeanProxyWith(short aPrimitiveShort); -/** - * Return a new bean proxy for the primitive long argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public INumberBeanProxy createBeanProxyWith(long aPrimitiveLong); -/** - * Return a new bean proxy for the primitive float argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public INumberBeanProxy createBeanProxyWith(float aPrimitiveFloat); -/** - * Return a new bean proxy for the primitive double argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public INumberBeanProxy createBeanProxyWith(double aPrimitiveDouble); -/** - * Return a new bean proxy for the Boolean argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public IBooleanBeanProxy createBeanProxyWith(Boolean aBoolean); -/** - * Return a new bean proxy for the Integer argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public IIntegerBeanProxy createBeanProxyWith(Integer anInteger); -/** - * Return a new bean proxy for the Character argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public ICharacterBeanProxy createBeanProxyWith(Character aCharacter); -/** - * Return a new bean proxy for the Number argument, can handle any of the numbers. - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public INumberBeanProxy createBeanProxyWith(Number aNumber); -/** - * Return a new bean proxy for the string argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public IStringBeanProxy createBeanProxyWith(String aString); - -/** - * Convert the non-primitive proxy to a primitive proxy, if it - * of one of the wrapper types. If not, then just return the proxy as is. - * <p> - * I.E. BooleanClassProxy will convert to BooleanTypeProxy, but ObjectClassProxy will just return unchanged. - * @param nonPrimitiveProxy - * @return either the primitive proxy that nonPrimitive wrappers, or the non-primitive if not a wrapper type. - * - * @since 1.0.0 - */ -public IBeanProxy convertToPrimitiveBeanProxy(IBeanProxy nonPrimitiveProxy); -/** - * Return a new bean proxy for the boolean argument - * Creation date: (12/3/99 11:52:20 AM) - * @author Joe Winchester - */ -public IBooleanBeanProxy createBeanProxyWith(boolean aBoolean); -/** - * Create an array bean proxy. - * - * - (int, new int[2] {3, 4}) will create: - * int [3] [4] - * - * - (int[], new int[1] {1}) - * int [1] - * - * - (int[], new int[2] {2,3}) - * int [2] [3] - * - * - * - (int[], null) or (int[], new int[0]) or (int, null) or (int, new int[0]) - * int [0]... - * or - * (int[][]..., null) or (int[][]..., new int[0]) - * int[0][]... - * This is because an array instance with no specified dimensions is not valid. - * - * - (int[][], new int[1] {3}) - * int[3][] - */ -public IArrayBeanProxy createBeanProxyWith(IBeanTypeProxy type, int[] dimensions) throws ThrowableProxy; -/** - * Create a one-dimensional array. - * The result will be the same as calling - * createBeanProxyWith(IBeanTypeProxy type, new int[1] {x}) - * where 'x' is the value passed in as the dimension. - */ -public IArrayBeanProxy createBeanProxyWith(IBeanTypeProxy type, int dimension) throws ThrowableProxy; - -/** - * Create a bean proxy from an initialization string. - * <p> - * It is not recommended that this method be commonly used. That is because no type checking will be performed - * on the result. Whatever it evaluates to be will be what it is. It is useful for the rare cases where the desired - * result type is not known. - * <p> - * It is recommended instead to use the newInstance(initString) method on the appropriate IBeanTypeProxy so that the - * result can be type-checked to make sure the string evaluates to something of that type. - * - * @param initializationString - * @return - * @throws ThrowableProxy - * @throws InstantiationException - * @throws ClassCastException - * - * @since 1.0.0 - */ -public IBeanProxy createBeanProxyFrom(String initializationString) throws ThrowableProxy, InstantiationException, ClassCastException; - -/** - * Release the proxy. In the case of Remote VM, this means - * it will remove the proxy on the client side, and remove - * the reference to the real object on the server side. On the server - * side the real object may not go away because something else could - * be holding onto it, but it won't be held simply because the client - * is holding onto it. - */ -public void releaseProxy(IBeanProxy proxy); - -/** - * Create an expression. - * @return The expression. - * - * @since 1.0.0 - */ -public IExpression createExpression(); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IStandardBeanTypeProxyFactory.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IStandardBeanTypeProxyFactory.java deleted file mode 100644 index 77df7e9de..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IStandardBeanTypeProxyFactory.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - -import java.util.Set; -/** - * The standard bean type proxy factory. - * This is the Interface that the desktop will talk - * to, the one that is returned when getCurrent() is called. - * Creation date: (3/10/00 11:00:50 AM) - * @author: Richard Lee Kulp - */ -public interface IStandardBeanTypeProxyFactory extends IBeanProxyFactory { - -/** - * Used by other registered bean type proxy factories to - * register their bean type proxies with the standard factory - * so that it will be cached there. - * <p><b>Note:</b> This is not meant to be called by customers. It is here for the usage - * of registry extensions. - * @param aBeanTypeProxy - * @param permanent indicates that beantype will never be released, - * not even if explicit request is made. - * - * @since 1.1.0 - */ -void registerBeanTypeProxy(IBeanTypeProxy aBeanTypeProxy, boolean permanent); - -/** - * Used by other registered bean type proxy factories to - * register their proxy bean type with the standard factory - * so that it will be cached there. - * <p><b>Note:</b> This is not meant to be called by customers. It is here for the usage - * of registry extensions. - * @param aBeanTypeProxy - * @param permanent indicates that beantype will never be released, - * not even if explicit request is made. - * - * @since 1.1.0 - */ -void registerBeanTypeProxy(IProxyBeanType aBeanTypeProxy, boolean permanent); - -/** - * Return the beanType proxy for the given class name. - * It must be fully qualified. And for arrays it can handle - * either the jni type ([Ljava.lang.Object;) or the Java EMF Model - * formal type (java.lang.Object[]). - */ -IBeanTypeProxy getBeanTypeProxy(String className); - -/** - * Get the beantype proxy suitable for an expression. - * - * @param expression - * @param typeName - * @return - * - * @since 1.1.0 - */ -IProxyBeanType getBeanTypeProxy(IExpression expression, String typeName); - -/** - * Return an Array type proxy for the given class name of - * the specified dimensions. This is a helper method. The - * same result can be gotton from getBeanTypeProxy. - * e.g. - * getBeanTypeProxy("java.lang.Object", 3) - * is the same as: - * getBeanTypeProxy("[[[Ljava.lang.Object;") - * - * They both result in a type of: - * Object [][][] - * - * or if using the JNI format (proxy format) - * getBeanTypeProxy("[Ljava.langObject;", 3) - * becomes - * Object [][][][] - * - * or if using the standard java format (as in actual code) - * getBeanTypeProxy("java.langObject[];", 3) - * becomes - * Object [][][][] - */ -IBeanTypeProxy getBeanTypeProxy(String componentClassName, int dimensions); - -/** - * Return an Array type proxy for the given class name of - * the specified dimensions. This is a helper method. The - * same result can be gotton from getBeanTypeProxy. - * e.g. - * getBeanTypeProxy("java.lang.Object", 3) - * is the same as: - * getBeanTypeProxy("[[[Ljava.lang.Object;") - * - * They both result in a type of: - * Object [][][] - * - * or if using the JNI format (proxy format) - * getBeanTypeProxy("[Ljava.langObject;", 3) - * becomes - * Object [][][][] - * - * or if using the standard java format (as in actual code) - * getBeanTypeProxy("java.langObject[];", 3) - * becomes - * Object [][][][] - * - * @param expression - * @param componentClassName - * @param dimensions - * @return - * - * @since 1.1.0 - */ -IProxyBeanType getBeanTypeProxy(IExpression expression, String componentClassName, int dimensions); - -/** - * Test if a specific bean type has been registered. Don't access and create - * if it isn't currently registered. - */ -boolean isBeanTypeRegistered(String className); - -/** - * Registered types. Return a set of strings that are the registered classes. - * This Set isn't synchronized, there may be changes while accessing it. - */ -Set registeredTypes(); - -/** - * Maintain list of not found types. This list is types that were requested, - * but didn't exist. This method sets whether list should be maintained or not. - * If set to false, the list will be empty. The default is false. - * - * @param maintain - */ -void setMaintainNotFoundTypes(boolean maintain); - -/** - * Maintain list of not found types. This list is types that were requested, - * but didn't exist. This method returns whether list should be maintained or not. - * If false, the list will be empty. The default is false. - * - * @return maintaining not found types. - */ -boolean isMaintainNotFoundTypes(); - -/** - * Maintain list of not found types. This list is types that were requested, - * but didn't exist. - * - * @param className Classname to search for to see if ever not found. - * @return true if the bean type had been searched for but was not found. If not maintaining, then result will be false. - */ -boolean isBeanTypeNotFound(String className); - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IStringBeanProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IStringBeanProxy.java deleted file mode 100644 index 2078fad25..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IStringBeanProxy.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Optimized implementation that should be used for string proxies that - * allows the IDE VM to get the string value easily - * Creation date: (2/6/00 8:58:22 AM) - * @author: Joe Winchester - */ -public interface IStringBeanProxy extends IBeanProxy { -/** - * Return the proxied string as a string that the IDE can use - * Creation date: (2/6/00 8:58:32 AM) - */ -String stringValue(); -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IUIRunner.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IUIRunner.java deleted file mode 100644 index 9356c2d2f..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IUIRunner.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; - - -/** - * Interface that doesn't require UI. The implementation will. This will - * only be used if within UI environment. - * - * <package-protected> because should only be used within here. - * - * @since 1.0.0 - */ -interface IUIRunner { - /** - * Handle the build. If not in UI thread, just call back to ProxyLaunchSupport - * to handle the build. If on UI thread, then use the IProgressService to do it. - * This will keep the UI from "locking", though it will be disabled it won't deadlock. - * - * @param pm - * - * @since 1.0.0 - */ - public void handleBuild(IProgressMonitor pm) throws CoreException; -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IteratorBeanProxyWrapper.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IteratorBeanProxyWrapper.java deleted file mode 100644 index 43f64fc98..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IteratorBeanProxyWrapper.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -import java.text.MessageFormat; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -/** - * This is a wrapper for an java.util.Iterator proxy. - * It provides the iterator methods to interface to - * the proxy. - */ - -public class IteratorBeanProxyWrapper { - protected final IBeanProxy fIterator; - protected final JavaStandardBeanProxyConstants fConstants; - - /** - * Construct with the collection. - */ - public IteratorBeanProxyWrapper(IBeanProxy anIteratorProxy) { - if (!anIteratorProxy.getTypeProxy().isKindOf(anIteratorProxy.getProxyFactoryRegistry().getBeanTypeProxyFactory().getBeanTypeProxy("java.util.Iterator"))) //$NON-NLS-1$ - throw new ClassCastException(MessageFormat.format(ProxyMessages.ClassCast_EXC__IncorrectType, new Object[] {anIteratorProxy.getTypeProxy().getTypeName(), "java.util.Iterator"})); //$NON-NLS-1$ - else - fIterator = anIteratorProxy; - - fConstants = JavaStandardBeanProxyConstants.getConstants(anIteratorProxy.getProxyFactoryRegistry()); - } - - /** - * Answer the iterator proxy that this is wrappering. - */ - public IBeanProxy getBeanProxy() { - return fIterator; - } - - /** - * equals - Pass it on to the proxy to handle this. - */ - public boolean equals(Object object) { - return fIterator.equals(object); - } - - /** - * hashCode - Pass it on to the proxy to handle this. - */ - public int hashCode() { - return fIterator.hashCode(); - } - - /** - * Iterator accessors - */ - public boolean hasNext() { - try { - return ((IBooleanBeanProxy) fConstants.getIteratorHasNext().invoke(fIterator)).booleanValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return false; - } - } - public IBeanProxy next() throws ThrowableProxy { - return fConstants.getIteratorNext().invoke(fIterator); - } - public void remove() throws ThrowableProxy { - fConstants.getIteratorRemove().invoke(fIterator); - } - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/JavaStandardBeanProxyConstants.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/JavaStandardBeanProxyConstants.java deleted file mode 100644 index df46f1607..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/JavaStandardBeanProxyConstants.java +++ /dev/null @@ -1,347 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * Standard Proxy constants. - * - * Use the static accessor method (getConstants()) to get the appropriate - * constants instance for the registry. This is done so that until the - * the constants are needed, they aren't registered. - * - * There are some standard utility functions too. - * - * NOTE: Since everything in here just proxies, there is - * no need to have them separated by VM. That is why - * this in the Proxy package. - * - * This is final because this can't be extended. This specific one - * will be registered with the factory for this key. Any extensions - * must be done in their own constants and registry key. - * - * Creation date: (4/7/00 4:47:48 PM) - * @author: Administrator - */ -public final class JavaStandardBeanProxyConstants { - public static final Object REGISTRY_KEY = new Object(); - - final IBeanTypeProxy fCollectionType; - final IBeanTypeProxy fListType; - final IBeanTypeProxy fIteratorType; - final IBeanTypeProxy fListIteratorType; - final IBeanTypeProxy fEnumerationType; - final IBeanTypeProxy fSystemType; - final IBeanTypeProxy fStringType; - - IMethodProxy fCollectionAdd, fCollectionAddAll, fCollectionClear, fCollectionContains, - fCollectionContainsAll, fCollectionIsEmpty, fCollectionIterator, fCollectionRemove, - fCollectionRemoveAll, fCollectionRetainAll, fCollectionSize, fCollectionToArray, - fCollectionToArrayWithArray; - - IMethodProxy fListAddWithInt, fListAddAllWithInt, fListGet, fListIndexOf, fListLastIndexOf, - fListListIterator, fListListIteratorWithInt, fListRemoveInt, - fListSet, fListSubList; - - IMethodProxy fIteratorHasNext, fIteratorNext, fIteratorRemove; - - IMethodProxy fListIteratorAdd, fListIteratorHasPrevious, fListIteratorNextIndex, fListIteratorPrevious, - fListIteratorPreviousIndex, fListIteratorRemove, fListIteratorSet; - - IMethodProxy fEnumerationHasMoreElements, fEnumerationNextElement; - - IMethodProxy fSystemArraycopy; - -/** - * Get the constants instance for the specified registry. - */ -public static JavaStandardBeanProxyConstants getConstants(ProxyFactoryRegistry registry) { - JavaStandardBeanProxyConstants constants = (JavaStandardBeanProxyConstants) registry.getConstants(REGISTRY_KEY); - if (constants == null) - registry.registerConstants(REGISTRY_KEY, constants = new JavaStandardBeanProxyConstants(registry)); - return constants; -} - - -/** - * IDEJavaBeanConstants constructor comment. - */ -private JavaStandardBeanProxyConstants(ProxyFactoryRegistry registry) { - super(); - - IStandardBeanTypeProxyFactory typeFactory = registry.getBeanTypeProxyFactory(); - fCollectionType = typeFactory.getBeanTypeProxy("java.util.Collection");//$NON-NLS-1$ - fListType = typeFactory.getBeanTypeProxy("java.util.List"); //$NON-NLS-1$ - fIteratorType = typeFactory.getBeanTypeProxy("java.util.Iterator"); //$NON-NLS-1$ - fListIteratorType = typeFactory.getBeanTypeProxy("java.util.ListIterator"); //$NON-NLS-1$ - fEnumerationType = typeFactory.getBeanTypeProxy("java.util.Enumeration"); //$NON-NLS-1$ - fSystemType = typeFactory.getBeanTypeProxy("java.lang.System"); //$NON-NLS-1$ - fStringType = typeFactory.getBeanTypeProxy("java.lang.String"); //$NON-NLS-1$ -} - -public IBeanTypeProxy getStringType() { - return fStringType; -} - -/** - * Collection method accessors - */ -public IMethodProxy getCollectionAdd() { - if (fCollectionAdd == null) - fCollectionAdd = fCollectionType.getMethodProxy("add", "java.lang.Object"); //$NON-NLS-1$ //$NON-NLS-2$ - return fCollectionAdd; -} - -public IMethodProxy getCollectionAddAll(){ - if (fCollectionAddAll == null) - fCollectionAddAll = fCollectionType.getMethodProxy("addAll", "java.util.Collection"); //$NON-NLS-1$ //$NON-NLS-2$ - return fCollectionAddAll; -} - -public IMethodProxy getCollectionClear() { - if (fCollectionClear == null) - fCollectionClear = fCollectionType.getMethodProxy("clear"); //$NON-NLS-1$ - return fCollectionClear; -} - -public IMethodProxy getCollectionContains() { - if (fCollectionContains == null) - fCollectionContains = fCollectionType.getMethodProxy("contains", "java.lang.Object"); //$NON-NLS-1$ //$NON-NLS-2$ - return fCollectionContains; -} - -public IMethodProxy getCollectionContainsAll() { - if (fCollectionContainsAll == null) - fCollectionContainsAll = fCollectionType.getMethodProxy("containsAll", "java.util.Collection"); //$NON-NLS-1$ //$NON-NLS-2$ - return fCollectionContainsAll; -} - -public IMethodProxy getCollectionIsEmpty() { - if (fCollectionIsEmpty == null) - fCollectionIsEmpty = fCollectionType.getMethodProxy("isEmpty"); //$NON-NLS-1$ - return fCollectionIsEmpty; -} - -public IMethodProxy getCollectionIterator() { - if (fCollectionIterator == null) - fCollectionIterator = fCollectionType.getMethodProxy("iterator"); //$NON-NLS-1$ - return fCollectionIterator; -} - -public IMethodProxy getCollectionRemove() { - if (fCollectionRemove == null) - fCollectionRemove = fCollectionType.getMethodProxy("remove", "java.lang.Object"); //$NON-NLS-1$ //$NON-NLS-2$ - return fCollectionRemove; -} - -public IMethodProxy getCollectionRemoveAll() { - if (fCollectionRemoveAll == null) - fCollectionRemoveAll = fCollectionType.getMethodProxy("removeAll", "java.util.Collection"); //$NON-NLS-1$ //$NON-NLS-2$ - return fCollectionRemoveAll; -} - -public IMethodProxy getCollectionRetainAll() { - if (fCollectionRetainAll == null) - fCollectionRetainAll = fCollectionType.getMethodProxy("retainAll", "java.util.Collection"); //$NON-NLS-1$ //$NON-NLS-2$ - return fCollectionRetainAll; -} - -public IMethodProxy getCollectionSize() { - if (fCollectionSize == null) - fCollectionSize = fCollectionType.getMethodProxy("size"); //$NON-NLS-1$ - return fCollectionSize; -} - -public IMethodProxy getCollectionToArray() { - if (fCollectionToArray == null) - fCollectionToArray = fCollectionType.getMethodProxy("toArray"); //$NON-NLS-1$ - return fCollectionToArray; -} - -public IMethodProxy getCollectionToArrayWithArray() { - if (fCollectionToArrayWithArray == null) - fCollectionToArrayWithArray = fCollectionType.getMethodProxy("toArray", "[Ljava.lang.Object;"); //$NON-NLS-1$ //$NON-NLS-2$ - return fCollectionToArrayWithArray; -} - -/** - * Iterator accessors - */ - -public IMethodProxy getIteratorHasNext() { - if (fIteratorHasNext == null) - fIteratorHasNext = fIteratorType.getMethodProxy("hasNext"); //$NON-NLS-1$ - return fIteratorHasNext; -} - -public IMethodProxy getIteratorNext() { - if (fIteratorNext == null) - fIteratorNext = fIteratorType.getMethodProxy("next"); //$NON-NLS-1$ - return fIteratorNext; -} - -public IMethodProxy getIteratorRemove() { - if (fIteratorRemove == null) - fIteratorRemove = fIteratorType.getMethodProxy("remove"); //$NON-NLS-1$ - return fIteratorRemove; -} - -/** - * Listaccessors - */ - -public IMethodProxy getListAddWithInt() { - if (fListAddWithInt == null) - fListAddWithInt = fListType.getMethodProxy("add", new String[] {"int", "java.lang.Object"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return fListAddWithInt; -} - -public IMethodProxy getListAddAllWithInt() { - if (fListAddAllWithInt == null) - fListAddAllWithInt = fListType.getMethodProxy("addAll", new String[] {"int", "java.util.Collection"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return fListAddAllWithInt; -} - -public IMethodProxy getListGet() { - if (fListGet == null) - fListGet = fListType.getMethodProxy("get", "int"); //$NON-NLS-1$ //$NON-NLS-2$ - return fListGet; -} - -public IMethodProxy getListIndexOf() { - if (fListIndexOf == null) - fListIndexOf = fListType.getMethodProxy("indexOf", "java.lang.Object"); //$NON-NLS-1$ //$NON-NLS-2$ - return fListIndexOf; -} - -public IMethodProxy getListLastIndexOf() { - if (fListLastIndexOf == null) - fListLastIndexOf = fListType.getMethodProxy("lastIndexOf", "java.lang.Object"); //$NON-NLS-1$ //$NON-NLS-2$ - return fListLastIndexOf; -} - -public IMethodProxy getListListIterator() { - if (fListListIterator == null) - fListListIterator = fListType.getMethodProxy("listIterator"); //$NON-NLS-1$ - return fListListIterator; -} - -public IMethodProxy getListListIteratorWithInt() { - if (fListListIteratorWithInt == null) - fListListIteratorWithInt = fListType.getMethodProxy("listIterator", "int"); //$NON-NLS-1$ //$NON-NLS-2$ - return fListListIteratorWithInt; -} - -public IMethodProxy getListRemoveInt() { - if (fListRemoveInt == null) - fListRemoveInt = fListType.getMethodProxy("remove", "int"); //$NON-NLS-1$ //$NON-NLS-2$ - return fListRemoveInt; -} - -public IMethodProxy getListSet() { - if (fListSet == null) - fListSet = fListType.getMethodProxy("set", new String[] {"int", "java.lang.Object"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return fListSet; -} - -public IMethodProxy getListSubList() { - if (fListSubList == null) - fListSubList = fListType.getMethodProxy("subList", new String[] {"int", "int"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return fListSubList; -} - -/** - * ListIterator accessors - */ - -public IMethodProxy getListIteratorAdd() { - if (fListIteratorAdd == null) - fListIteratorAdd = fListIteratorType.getMethodProxy("add", "java.lang.Object"); //$NON-NLS-1$ //$NON-NLS-2$ - return fListIteratorAdd; -} - -public IMethodProxy getListIteratorHasPrevious() { - if (fListIteratorHasPrevious == null) - fListIteratorHasPrevious = fListIteratorType.getMethodProxy("hasPrevious"); //$NON-NLS-1$ - return fListIteratorHasPrevious; -} - -public IMethodProxy getListIteratorNextIndex() { - if (fListIteratorNextIndex == null) - fListIteratorNextIndex = fListIteratorType.getMethodProxy("nextIndex"); //$NON-NLS-1$ - return fListIteratorNextIndex; -} - -public IMethodProxy getListIteratorPrevious() { - if (fListIteratorPrevious == null) - fListIteratorPrevious = fListIteratorType.getMethodProxy("previous"); //$NON-NLS-1$ - return fListIteratorPrevious; -} - -public IMethodProxy getListIteratorPreviousIndex() { - if (fListIteratorPreviousIndex == null) - fListIteratorPreviousIndex = fListIteratorType.getMethodProxy("previousIndex"); //$NON-NLS-1$ - return fListIteratorPreviousIndex; -} - -public IMethodProxy getListIteratorSet() { - if (fListIteratorSet == null) - fListIteratorSet = fListIteratorType.getMethodProxy("set", "java.lang.Object"); //$NON-NLS-1$ //$NON-NLS-2$ - return fListIteratorSet; -} - -public IMethodProxy getListIteratorRemove() { - if (fListIteratorRemove == null) - fListIteratorRemove = fListIteratorType.getMethodProxy("remove"); //$NON-NLS-1$ - return fListIteratorRemove; -} - -protected IMethodProxy getSystemArraycopy() { - if (fSystemArraycopy == null) - fSystemArraycopy = fSystemType.getMethodProxy("arraycopy", new String[] {"java.lang.Object", "int", "java.lang.Object", "int", "int"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - return fSystemArraycopy; -} - -/** - * Enumeration accessors - */ -public IMethodProxy getEnumerationHasMoreElements() { - if (fEnumerationHasMoreElements == null) - fEnumerationHasMoreElements = fEnumerationType.getMethodProxy("hasMoreElements"); //$NON-NLS-1$ - return fEnumerationHasMoreElements; -} - -public IMethodProxy getEnumerationNextElement() { - if (fEnumerationNextElement == null) - fEnumerationNextElement = fEnumerationType.getMethodProxy("nextElement"); //$NON-NLS-1$ - return fEnumerationNextElement; -} - -/** - * Utility function to copy an array. - */ -public void arraycopy(IBeanProxy src, int srcPosition, IBeanProxy dest, int destPosition, int length) throws ThrowableProxy { - IStandardBeanProxyFactory factory = src.getProxyFactoryRegistry().getBeanProxyFactory(); - IBeanProxy[] args = new IBeanProxy[] { - src, - factory.createBeanProxyWith(srcPosition), - dest, - factory.createBeanProxyWith(destPosition), - factory.createBeanProxyWith(length) - }; - - getSystemArraycopy().invoke(null, args); -} -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ListBeanProxyWrapper.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ListBeanProxyWrapper.java deleted file mode 100644 index a47278327..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ListBeanProxyWrapper.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -import java.text.MessageFormat; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -/** - * This is a wrapper for an java.util.Collection proxy. - * It provides the collection methods to interface to - * the proxy. - */ - -public class ListBeanProxyWrapper extends CollectionBeanProxyWrapper { - /** - * Construct with the List. - */ - public ListBeanProxyWrapper(IBeanProxy aListProxy) { - super(aListProxy); - - if (!aListProxy.getTypeProxy().isKindOf(aListProxy.getProxyFactoryRegistry().getBeanTypeProxyFactory().getBeanTypeProxy("java.util.List"))) //$NON-NLS-1$ - throw new ClassCastException(MessageFormat.format(ProxyMessages.ClassCast_EXC__IncorrectType, new Object[] {aListProxy.getTypeProxy().getTypeName(), "java.util.List"})); //$NON-NLS-1$ - } - - - /** - * List accessors - */ - public void add(int index, IBeanProxy object) throws ThrowableProxy { - fConstants.getListAddWithInt().invoke(fCollection, new IBeanProxy[] {fCollection.getProxyFactoryRegistry().getBeanProxyFactory().createBeanProxyWith(index), object}); - } - public boolean addAll(int index, IBeanProxy aCollection) throws ThrowableProxy { - return ((IBooleanBeanProxy) fConstants.getListAddAllWithInt().invoke(fCollection, new IBeanProxy[] {fCollection.getProxyFactoryRegistry().getBeanProxyFactory().createBeanProxyWith(index), aCollection})).booleanValue(); - } - public IBeanProxy get(int index) throws ThrowableProxy { - return fConstants.getListGet().invoke(fCollection, fCollection.getProxyFactoryRegistry().getBeanProxyFactory().createBeanProxyWith(index)); - } - public int indexOf(IBeanProxy object) { - try { - return ((IIntegerBeanProxy) fConstants.getListIndexOf().invoke(fCollection, object)).intValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return -1; - } - } - public int lastIndexOf(IBeanProxy object) { - try { - return ((IIntegerBeanProxy) fConstants.getListLastIndexOf().invoke(fCollection, object)).intValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return -1; - } - } - public ListIteratorBeanProxyWrapper listIterator() { - try { - IBeanProxy itr = fConstants.getListListIterator().invoke(fCollection); - if (itr != null) - return new ListIteratorBeanProxyWrapper(itr); - else - return null; - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return null; - } - } - public ListIteratorBeanProxyWrapper listIterator(int index) { - try { - IBeanProxy itr = fConstants.getListListIteratorWithInt().invoke(fCollection, fCollection.getProxyFactoryRegistry().getBeanProxyFactory().createBeanProxyWith(index)); - if (itr != null) - return new ListIteratorBeanProxyWrapper(itr); - else - return null; - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return null; - } - } - public IBeanProxy remove(int index, IBeanProxy object) throws ThrowableProxy { - return fConstants.getListSet().invoke(fCollection, fCollection.getProxyFactoryRegistry().getBeanProxyFactory().createBeanProxyWith(index)); - } - public IBeanProxy set(int index, IBeanProxy object) throws ThrowableProxy { - return fConstants.getListRemoveInt().invoke(fCollection, new IBeanProxy[] {fCollection.getProxyFactoryRegistry().getBeanProxyFactory().createBeanProxyWith(index), object}); - } - public ListBeanProxyWrapper subList(int fromIndex, int toIndex) throws ThrowableProxy { - IBeanProxy list = fConstants.getListSubList().invoke(fCollection, new IBeanProxy[] {fCollection.getProxyFactoryRegistry().getBeanProxyFactory().createBeanProxyWith(fromIndex), fCollection.getProxyFactoryRegistry().getBeanProxyFactory().createBeanProxyWith(toIndex)}); - if (list != null) - return new ListBeanProxyWrapper(list); - else - return null; - } - - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ListIteratorBeanProxyWrapper.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ListIteratorBeanProxyWrapper.java deleted file mode 100644 index e19802886..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ListIteratorBeanProxyWrapper.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -import java.text.MessageFormat; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -/** - * This is a wrapper for an java.util.ListIterator proxy. - * It provides the ListIterator methods to interface to - * the proxy. - */ - -public class ListIteratorBeanProxyWrapper extends IteratorBeanProxyWrapper { - - /** - * Construct with the ListIterator. - */ - public ListIteratorBeanProxyWrapper(IBeanProxy anIteratorProxy) { - super(anIteratorProxy); - - if (!anIteratorProxy.getTypeProxy().isKindOf(anIteratorProxy.getProxyFactoryRegistry().getBeanTypeProxyFactory().getBeanTypeProxy("java.util.ListIterator"))) //$NON-NLS-1$ - throw new ClassCastException(MessageFormat.format(ProxyMessages.ClassCast_EXC__IncorrectType, new Object[] {anIteratorProxy.getTypeProxy().getTypeName(), "java.util.ListIterator"})); //$NON-NLS-1$ - } - - - /** - * ListIterator accessors - */ - public void add(IBeanProxy object) throws ThrowableProxy { - fConstants.getListIteratorAdd().invoke(fIterator, object); - } - public boolean hasPrevious() { - try { - return ((IBooleanBeanProxy) fConstants.getListIteratorHasPrevious().invoke(fIterator)).booleanValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return false; - } - } - public int nextIndex() { - try { - return ((IIntegerBeanProxy) fConstants.getListIteratorNextIndex().invoke(fIterator)).intValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return -1; - } - } - public IBeanProxy previous() throws ThrowableProxy { - return fConstants.getListIteratorPrevious().invoke(fIterator); - } - public int previousIndex() { - try { - return ((IIntegerBeanProxy) fConstants.getListIteratorPreviousIndex().invoke(fIterator)).intValue(); - } catch (ThrowableProxy e) { - // This shouldn't occur, so just log it. - ProxyPlugin.getPlugin().getLogger().log(new Status(IStatus.ERROR, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.UnexpectedException_EXC_, e)); - return -1; - } - } - public void remove() throws ThrowableProxy { - fConstants.getListIteratorRemove().invoke(fIterator); - } - public void set(IBeanProxy object) throws ThrowableProxy { - fConstants.getListIteratorSet().invoke(fIterator, object); - } - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ListenerList.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ListenerList.java deleted file mode 100644 index d4b47e99c..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ListenerList.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -/** - * This class is used to maintain a list of listeners, and - * is used in the implementations of several classes within jem - * which allow you to register listeners of various kinds. - * It is a fairly lightweight object, occupying minimal space when - * no listeners are registered. - * <p> - * Note that the <code>add</code> method checks for and eliminates - * duplicates based on identity (not equality). Likewise, the - * <code>remove</code> method compares based on identity. - * </p> - * <p> - * Use the <code>getListeners</code> method when notifying listeners. - * Note that no garbage is created if no listeners are registered. - * The recommended code sequence for notifying all registered listeners - * of say, <code>FooListener.eventHappened</code>, is: - * <pre> - * Object[] listeners = myListenerList.getListeners(); - * for (int i = 0; i < listeners.length; ++i) { - * ((FooListener) listeners[i]).eventHappened(event); - * } - * </pre> - * </p> - */ - -public class ListenerList { - - /** - * The initial capacity of the list. Always >= 1. - */ - private int capacity; - - /** - * The current number of listeners. - * Maintains invariant: 0 <= size <= listeners.length. - */ - private int size; - - /** - * The list of listeners. Initially <code>null</code> but initialized - * to an array of size capacity the first time a listener is added. - * Maintains invariant: listeners != null IFF size != 0 - */ - private Object[] listeners = null; - - /** - * The empty array singleton instance, returned by getListeners() - * when size == 0. - */ - private static final Object[] EmptyArray = new Object[0]; - - /** - * Creates a listener list with an initial capacity of 1. - */ - public ListenerList() { - this(1); - } - - /** - * Creates a listener list with the given initial capacity. - * - * @param capacity the number of listeners which this list can initially accept - * without growing its internal representation; must be at least 1 - */ - public ListenerList(int capacity) { - if (!(capacity >= 1)) - throw new IllegalArgumentException(); - this.capacity = capacity; - } - - /** - * Adds the given listener to this list. Has no effect if an identical listener - * is already registered. - * - * @param listener the listener - */ - public void add(Object listener) { - if (listener == null) - throw new IllegalArgumentException(); - if (size == 0) { - listeners = new Object[capacity]; - } else { - // check for duplicates using identity - for (int i = 0; i < size; ++i) { - if (listeners[i] == listener) { - return; - } - } - // grow array if necessary - if (size == listeners.length) { - System.arraycopy( - listeners, - 0, - listeners = new Object[size * 2 + 1], - 0, - size); - } - } - listeners[size++] = listener; - } - - /** - * Removes all listeners from this list. - */ - public void clear() { - size = 0; - listeners = null; - } - - /** - * Returns an array containing all the registered listeners, - * in the order in which they were added. - * <p> - * The resulting array is unaffected by subsequent adds or removes. - * If there are no listeners registered, the result is an empty array - * singleton instance (no garbage is created). - * Use this method when notifying listeners, so that any modifications - * to the listener list during the notification will have no effect on the - * notification itself. - * </p> - * - * @return the list of registered listeners - */ - public Object[] getListeners() { - if (size == 0) - return EmptyArray; - Object[] result = new Object[size]; - System.arraycopy(listeners, 0, result, 0, size); - return result; - } - - /** - * Returns whether this listener list is empty. - * - * @return <code>true</code> if there are no registered listeners, and - * <code>false</code> otherwise - */ - public boolean isEmpty() { - return size == 0; - } - - /** - * Removes the given listener from this list. Has no effect if an identical - * listener was not already registered. - * - * @param listener the listener - */ - public void remove(Object listener) { - if (listener == null) - throw new IllegalArgumentException(); - for (int i = 0; i < size; ++i) { - if (listeners[i] == listener) { - if (size == 1) { - listeners = null; - size = 0; - } else { - System.arraycopy( - listeners, - i + 1, - listeners, - i, - --size - i); - listeners[size] = null; - } - return; - } - } - } - - /** - * Returns the number of registered listeners. - * - * @return the number of registered listeners - */ - public int size() { - return size; - } - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/MapJNITypes.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/MapJNITypes.java deleted file mode 100644 index 7ed975fa2..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/MapJNITypes.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import org.eclipse.jem.internal.proxy.common.MapTypes; - - -/** - * This is a public class to map between JNI and normal format (e.g. "[Ljava.lang.String;" to "java.lang.String[]") and back again. - * This is for arrays, non-arrays will be left alone since they are already correct. - * @since 1.1.0 - */ -public class MapJNITypes { - - /** - * Convert the formal type name to the JNI format. - * @param formalTypeName - * @return JNI format - * - * @since 1.1.0 - */ - public static String getJNITypeName(String formalTypeName) { - return MapTypes.getJNIFormatName(formalTypeName); - } - - /** - * Convert the JNI format to the formal type name. - * @param jniTypeName - * @return formal type name or "" if not valid. - * - * @since 1.1.0 - */ - public static String getFormalTypeName(String jniTypeName) { - return MapTypes.getFormalTypeName(jniTypeName); - } - - /** - * Return whether the formal type name is for a primitive or not. - * @param formalType - * @return <code>true</code> if for a primitive. - * - * @since 1.1.0 - */ - public static boolean isFormalTypePrimitive(String formalType) { - return MapTypes.MAP_TYPENAME_TO_SHORTSIG.get(formalType) != null; - } - - /** - * Convert the formal type name, with the given number of dimensions, - * to an array JNI type. - * @param finalComponent final component name, should not be an array type. - * @param dimensions number of dimensions for the array. - * @return - * - * @since 1.1.0 - */ - public static String getJNITypeName(String finalComponent, int dimensions) { - return MapTypes.getJNITypeName(finalComponent, dimensions); - } -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/PDEContributeClasspath.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/PDEContributeClasspath.java deleted file mode 100644 index ba030614f..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/PDEContributeClasspath.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.*; -import java.util.logging.Level; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.pde.core.plugin.*; - -/** - * Contribute to classpath PDE entries that are needed for a launch. - * <p> - * This is a special class that should not be referenced directly from code. Reference it through the interface that it implements. - * - * @see org.eclipse.jem.internal.proxy.core.IPDEContributeClasspath - * @since 1.0.2 - */ -class PDEContributeClasspath implements IPDEContributeClasspath { - - public void getPDEContributions(IConfigurationContributionController controller, IConfigurationContributionInfo info) throws CoreException { - if (!info.getPluginIds().isEmpty()) { - Collection pluginIds = info.getPluginIds().keySet(); - - IPluginModelBase[] allModels = PluginRegistry.getAllModels(); - List fragments = new ArrayList(); - for (int i = 0; i < allModels.length; i++) { - if (allModels[i].isFragmentModel()) { - fragments.add(allModels[i]); - } - } - - for (Iterator itr = fragments.iterator(); itr.hasNext();) { - IFragmentModel fragmentModel = (IFragmentModel) itr.next(); - IFragment fragment = fragmentModel.getFragment(); - if (pluginIds.contains(fragment.getPluginId())) { - // We'll do a cheat for now and assume fragment is for same version of plugin. PDECore actually - // checks the version of the fragment against the version of the plugin to see they are for each - // other, but we'll just assume they are for now. Change this later if we actually do run into this case. - IResource resource = fragment.getModel().getUnderlyingResource(); - if (resource != null) { - IProject fragProject = resource.getProject(); - if (fragProject.hasNature(JavaCore.NATURE_ID)) { - controller.contributeProject(fragProject); - } - continue; - } - - IPluginLibrary[] libraries = fragment.getLibraries(); - for (int j = 0; j < libraries.length; j++) { - IPluginLibrary library = libraries[j]; - String name = library.getName(); - String expandedName = expandLibraryName(name); - - IPluginModelBase model = library.getPluginModel(); - URL url = getPath(model, expandedName); - if (url != null) - controller.contributeClasspath(url, IConfigurationContributionController.APPEND_USER_CLASSPATH); - } - } - } - } - - return; - } - - private URL getPath(IPluginModelBase model, String libraryName) { - try { - IResource resource = model.getUnderlyingResource(); - if (resource != null) { - IResource jarFile = resource.getProject().findMember(libraryName); - if (jarFile != null) - return jarFile.getFullPath().toFile().toURL(); - } else { - File file = new File(model.getInstallLocation(), libraryName); - if (file.exists()) - return file.toURL(); - } - } catch (MalformedURLException e) { - ProxyPlugin.getPlugin().getLogger().log(e, Level.WARNING); - } - return null; - } - - /** - * This utility method was originally copied from method of same name, in org.eclipse.pde.internal.core.ClasspathUtilCore. It was not API, and - * seems safe enough to copy here. But, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=182555 - * in case there is ever an API method provided to codify these Eclipse rules. - */ - private static String expandLibraryName(String source) { - if (source == null || source.length() == 0) - return ""; //$NON-NLS-1$ - if (source.indexOf("$ws$") != -1) //$NON-NLS-1$ - source = source.replaceAll("\\$ws\\$", //$NON-NLS-1$ - "ws" + IPath.SEPARATOR + TargetPlatform.getWS()); //$NON-NLS-1$ - if (source.indexOf("$os$") != -1) //$NON-NLS-1$ - source = source.replaceAll("\\$os\\$", //$NON-NLS-1$ - "os" + IPath.SEPARATOR + TargetPlatform.getOS()); //$NON-NLS-1$ - if (source.indexOf("$nl$") != -1) //$NON-NLS-1$ - source = source.replaceAll("\\$nl\\$", //$NON-NLS-1$ - "nl" + IPath.SEPARATOR + TargetPlatform.getNL()); //$NON-NLS-1$ - if (source.indexOf("$arch$") != -1) //$NON-NLS-1$ - source = source.replaceAll("\\$arch\\$", //$NON-NLS-1$ - "arch" + IPath.SEPARATOR + TargetPlatform.getOSArch()); //$NON-NLS-1$ - return source; - } -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/PDEContributeClasspathInstance.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/PDEContributeClasspathInstance.java deleted file mode 100644 index 90c7529e2..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/PDEContributeClasspathInstance.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import java.util.logging.Level; - -import org.eclipse.core.runtime.Platform; - - - -/** - * Accessor to the IPDEContributeClasspath instance to use. - * <pacakge-protected> because only IPDEContributeClasspath should access it. - * - * @since 1.0.2 - */ -class PDEContributeClasspathInstance { - - /** - * Get the instance to use. - * @return the instance to use or <code>null</code> if PDE not available. - * - * @since 1.0.2 - */ - public static IPDEContributeClasspath getInstance() { - if (Platform.getBundle("org.eclipse.pde.core") != null) { //$NON-NLS-1$ - try { - Class pdeClass = Class.forName("org.eclipse.jem.internal.proxy.core.PDEContributeClasspath"); //$NON-NLS-1$ - return (IPDEContributeClasspath) pdeClass.newInstance(); - } catch (ClassNotFoundException e) { - // PDE not available, this is ok. - } catch (InstantiationException e) { - ProxyPlugin.getPlugin().getLogger().log(e.getCause(), Level.WARNING); - } catch (IllegalAccessException e) { - ProxyPlugin.getPlugin().getLogger().log(e, Level.WARNING); - } - } - return null; - } -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/PDEProcessForPlugin.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/PDEProcessForPlugin.java deleted file mode 100644 index b77dc516a..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/PDEProcessForPlugin.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.pde.core.plugin.*; - -import org.eclipse.jem.internal.proxy.core.ProxyPlugin.FoundIDs; - - -/* - * Used for PDE Processing for the Proxy Plugin class. It will be optionally loaded - * if PDE plugin is installed. This allows usage in an installation that doesn't have - * PDE installed. - * - * @since 1.0.2 - */ -class PDEProcessForPlugin implements ProxyPlugin.IPDEProcessForPlugin { - - /* - * (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.ProxyPlugin.IPDEProcessForPlugin#processPlugin(org.eclipse.jdt.core.IJavaProject, java.util.Map, boolean, boolean) - */ - public void findPlugins(IJavaProject project, FoundIDs foundIds, boolean visible, boolean first) { - IPluginModelBase m = PluginRegistry.findModel(project.getProject()); - if (m instanceof IPluginModel) { - // it is a plugin, process it. - IPlugin plugin = ((IPluginModel) m).getPlugin(); - if (foundIds.pluginIds.containsKey(plugin.getId())) - return; // already processed it - foundIds.pluginIds.put(plugin.getId(), first || visible ? Boolean.TRUE : Boolean.FALSE); - expandPlugin(plugin, foundIds, visible, first); - } - return; - } - - private void expandPlugin(IPluginBase plugin, FoundIDs foundIds, boolean visible, boolean first) { - IPluginImport[] imports = plugin.getImports(); - for (int i = 0; i < imports.length; i++) { - IPluginImport pi = imports[i]; - Boolean piValue = (Boolean) foundIds.pluginIds.get(pi.getId()); - boolean importVisible = first || (visible && pi.isReexported()); - if (piValue != null && (!importVisible || piValue.booleanValue())) - continue; // we already processed it, this time not visible, or this time visible and was previously visible. - // Now either first time, or it was there before, but now visible, but this time it is visible. - // We want it to become visible in that case. - foundIds.pluginIds.put(pi.getId(), importVisible ? Boolean.TRUE : Boolean.FALSE); - - // Note: this search does not take into account the IPluginImport's version or match level - // but neither did the previous version - IPluginModelBase model = PluginRegistry.findModel(pi.getId()); - if (model != null && model.isEnabled()) { - IPluginBase foundPlugin = model.getPluginBase(); - if (foundPlugin != null) { - expandPlugin(foundPlugin, foundIds, importVisible, false); - } - } - } - } -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyFactoryRegistry.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyFactoryRegistry.java deleted file mode 100644 index c87f1910a..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyFactoryRegistry.java +++ /dev/null @@ -1,327 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -import java.util.Hashtable; -import java.util.Iterator; - -import org.eclipse.jem.util.TimerTests; - -/** - * Registry of proxy factories on a per-VM basis. - * There can be multiple VM's, this would be required by the - * desktop because more than one project could be open, and each - * would require their own VM because the classpaths would be different. - * This class may be subclassed to provide more factories for a particular - * VM. - * Creation date: (3/13/00 10:48:10 AM) - * @author: Richard Lee Kulp - */ -public abstract class ProxyFactoryRegistry { - - protected boolean fIsValid = true; // The registry is valid until terminated. - protected ListenerList registryListeners = new ListenerList(); - - /** - * IRegistryListener - * Listen for the registry being terminated. - */ - public interface IRegistryListener { - /** - * Method registryTerminated. - * - * The registry has been terminated. When this is called the registry - * is no longer valid. It should not be assumed any calls can be made - * to the registry. - * - * @param registry - */ - public void registryTerminated(ProxyFactoryRegistry registry); - } - - - // Factory registration IS NOT a dynamic registration. Once registered for a VM or an instance - // they should not be changed. This is because references are cached in other objects. - // The VM associated with this Registry shouldn't exited and restarted because - // the cached object will then have invalid references to no longer existing objects. - // If the VM needs to be restarted, then all proxies need to be tossed. - - // - // Individual ProxyFactoryRegistry, applies to a particular VM. - // - - // *************************** - // - // IBeanProxyFactory Registry - // - - // The standard bean proxy factory, the one the desktop will use for packages that have not - // been extended and registered by customization developers. - protected IStandardBeanProxyFactory fCurrentStandardBeanProxyFactory; - - // The directory of registered extension factories, typically registered by package. - final protected Hashtable fRegisteredExtensionBeanProxyFactories = new Hashtable(); - - // *************************** - // - // IBeanTypeProxyFactory Registry - // - - // The standard bean type proxy factory, the one the desktop will use for packages that have not - // been extended and registered by customization developers. - protected IStandardBeanTypeProxyFactory fCurrentStandardBeanTypeProxyFactory; - - // The directory of registered extension factories, typically registered by package. - final protected Hashtable fRegisteredExtensionBeanTypeProxyFactories = new Hashtable(); - - - // *************************** - // - // Other factories - // - - protected IMethodProxyFactory fMethodProxyFactory = null; // Method Proxy Factory - - // *************************** - // - // Constants Registry. Different extensions can store - // objects by key as a registry of constants. - // For example, java.awt extension will store an object - // which has some pre-fetched method proxies stored in it so - // that they don't need to be continually recreated. - // - // This feature should be used with care, so that - // only proxies that really need to be cached should - // be cached. - // - // Don't store proxies to live beans in here because - // those will be created and destroyed over and over, - // and the instance in this cache will get stale. - // Should only store things like often used method - // proxies that once created are rarely changed. - // - // Since the proxies can be on any VM, you should have - // an interface defining what's available in your - // constants entry, and access it through that. - - protected final Hashtable fRegisteredConstants = new Hashtable(); - - /** - * ProxyFactoryRegistry constructor comment. - */ - public ProxyFactoryRegistry() { - super(); - } - - /** - * Method addRegistryListener. - * @param listener - */ - public void addRegistryListener(IRegistryListener listener) { - registryListeners.add(listener); - } - - /** - * Method removeRegistryListener. - * @param listener - */ - public void removeRegistryListener(IRegistryListener listener) { - registryListeners.remove(listener); - } - - protected void fireRegistryTerminated() { - if (!registryListeners.isEmpty()) { - Object[] list = registryListeners.getListeners(); - for (int i = 0; i < list.length; i++) { - ((IRegistryListener) list[i]).registryTerminated(this); - } - } - } - - /** - Return the current factory to be used for creating IBeanProxy instances - */ - public IStandardBeanProxyFactory getBeanProxyFactory() { - if (fCurrentStandardBeanProxyFactory == null) { - throw new RuntimeException(ProxyMessages.ProxyFactory_EXC__NoBeanProxyFactory); - } - return fCurrentStandardBeanProxyFactory; - } - /** - Return the current registered bean proxy factory to be used for creating IBeanProxy instances - */ - public IBeanProxyFactory getBeanProxyFactoryExtension(String packageName) { - return (IBeanProxyFactory)fRegisteredExtensionBeanProxyFactories.get(packageName); - } - - /** - Return the current factory to be used for creating IBeanTypeProxy instances - */ - public IStandardBeanTypeProxyFactory getBeanTypeProxyFactory() { - if (fCurrentStandardBeanTypeProxyFactory == null) { - throw new RuntimeException(ProxyMessages.ProxyFactory_EXC__NoBeanTypeProxyFactory); - } - return fCurrentStandardBeanTypeProxyFactory; - } - /** - Return the current registered bean type proxy factory to be used for creating IBeanTypeProxy instances - */ - public IBeanTypeProxyFactory getBeanTypeProxyFactoryExtension(String packageName) { - return (IBeanTypeProxyFactory)fRegisteredExtensionBeanTypeProxyFactories.get(packageName); - } - /** - * Return the requested constants entry - */ - public Object getConstants(Object key) { - return fRegisteredConstants.get(key); - } - /** - * Return the MethodProxyFactory for this VM. - * Creation date: (3/13/00 10:54:59 AM) - * @return org.eclipse.jem.internal.proxy.core.IMethodProxyFactory - */ - public IMethodProxyFactory getMethodProxyFactory() { - return fMethodProxyFactory; - } - - - /** - * Set the requested constants entry for this VM. - */ - public void registerConstants(Object key, Object constant) { - fRegisteredConstants.put(key, constant); - } - - /** - * Remove the constants for the given key. - * @param key - * - * @since 1.1.0 - */ - public void deregisterConstants(Object key) { - fRegisteredConstants.remove(key); - } - /** - * Release the proxy, no longer needed. - * This is a helper method to easily access the release from the bean proxy factory. - */ - public void releaseProxy(IBeanProxy proxy) { - // To simply things if release is called when the factory is down (invalid), then just - // go on because the proxy is already released. - if (fCurrentStandardBeanProxyFactory != null) - fCurrentStandardBeanProxyFactory.releaseProxy(proxy); - } - - /** - * Is this a valid registry, i.e. is it not terminated. - */ - public boolean isValid() { - return fIsValid; - } - - /** - * Terminate the registry without waiting. - * <p> - * Terminate the registry, but don't necessarily wait for it. - * - * @see #terminateRegistry(boolean) - * @since 1.0.0 - */ - public final void terminateRegistry() { - terminateRegistry(false); - } - - /** - * Terminate the registry. - * <p> - * This will go through each factory and terminate it, and - * let the subclass terminate. It will then remove all of the factories so that - * if there are any proxies still hanging around they won't hold onto everything, - * just the this registry will be held onto. - *<p> - * Note during termination, the factories should not reference any other factory. - * It can assume that the factories will take care of themselves and they should - * only release their resources. - * <p> - * The constants registry will not be terminated because they aren't factories. - * However, they will be cleared (no longer referenced) from here so that they - * can be GC'd. - * - * @param wait <code>true</code> to wait for complete termination, <code>false</code> to kick off termination but return ASAP. - * @since 1.0.2 - */ - public final void terminateRegistry(boolean wait) { - if (!fIsValid) - return; // Already or are already terminating. Don't do it again and don't notify again. - fIsValid = false; - if (fCurrentStandardBeanTypeProxyFactory != null) { -// TimerTests.basicTest.startStep("Terminate Bean Type Factory"); - fCurrentStandardBeanTypeProxyFactory.terminateFactory(wait); -// TimerTests.basicTest.stopStep("Terminate Bean Type Factory"); - fCurrentStandardBeanTypeProxyFactory = null; - } - if (fCurrentStandardBeanProxyFactory != null) { - fCurrentStandardBeanProxyFactory.terminateFactory(wait); - fCurrentStandardBeanProxyFactory = null; - } - if (fMethodProxyFactory != null) { - fMethodProxyFactory.terminateFactory(wait); - fMethodProxyFactory = null; - } - - Iterator itr = fRegisteredExtensionBeanTypeProxyFactories.values().iterator(); - while (itr.hasNext()) { - ((IBeanProxyFactory) itr.next()).terminateFactory(wait); - } - fRegisteredExtensionBeanTypeProxyFactories.clear(); - - itr = fRegisteredExtensionBeanProxyFactories.values().iterator(); - while (itr.hasNext()) { - ((IBeanProxyFactory) itr.next()).terminateFactory(wait); - } - fRegisteredExtensionBeanProxyFactories.clear(); - - fRegisteredConstants.clear(); - - TimerTests.basicTest.startStep("Registry Terminated"); //$NON-NLS-1$ - registryTerminated(wait); - TimerTests.basicTest.stopStep("Registry Terminated"); //$NON-NLS-1$ - -// TimerTests.basicTest.startStep("Registry Terminated Notification"); - fireRegistryTerminated(); // Let everyone know that we are gone. This is fired even if wait is false because at this point in time the registry is invalid. -// TimerTests.basicTest.stopStep("Registry Terminated Notification"); - } - - - /** - * Terminate the Registry. - * <p> - * It is up to each registry to determine what this means. - * <p> - * The wait parm is a suggestion if it is <code>false</code>, but it must be honoured if <code>true</code> - * - * @param wait wait for registry to terminate flag. - * - * @since 1.0.2 - */ - protected abstract void registryTerminated(boolean wait); - - /** - * Get the callback registry. - */ - public abstract ICallbackRegistry getCallbackRegistry(); - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyFindSupport.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyFindSupport.java deleted file mode 100644 index fe977cf87..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyFindSupport.java +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import java.io.*; -import java.net.URL; -import java.util.ArrayList; -import java.util.Properties; - -import org.eclipse.core.runtime.*; -import org.osgi.framework.Bundle; - - -/** - * Utility to help finding files. It is used to find them within plugins of the current platform or to find them in the PDE target platform. - * Also if in the current platform and the current platform is in development mode it will find the bin directories for the jars instead since - * there are no jars in that case. - * It can also extract non-local files (such as files within a jar) and make a cache of them so that are a local file and not extracted everytime - * they are needed. - * - * TODO If we ever get back to continuing development we should add to this PDE Target support. And test the code here - * since it hasn't been tested yet. Also note that in configuration contributor, - * when we add the library path we expect it to be a folder. This would be a problem with jarred plugins because the directory containing the - * libraries may be the root of the plugin and localizing a directory would extract and cache the entire plugin. Need to change to figure out - * how to only extract the dll/so needed instead. Also, none of these handle the case where the bundle is actually non-local (e.g. "http:/"). - * @since 1.2.0 - */ -public class ProxyFindSupport { - - - /** - * Find the filename relative to the platform bundle. It will search in the bundle and in all fragments for the file name. - * It will return a URL for each found file. - * <p> - * This is useful for NLS purposes. In NLS situations the main bundle would contain the main non-library jar with the default properties files. - * Then a fragment for each set of languages will be installed. Within each fragment will be a jar with the same filepath, and it will - * contain the properties files for that language. This would be done only for plugin non-library jars. - * The NLS for library jars of a plugin (i.e. those jars that are the <runtime> jars for the plugin) are usually library jars themselves in - * the fragment, and they usually have a different name than the main library jar. So this should not be used for library jars. - * <p> - * If in development mode, then if the jar is not found it will look in the plugin project's build.properties to find the output directory - * of the jar. If not in the build.properties (meaning it isn't being built by PDE), it will look in the proxy.jars file (if there is one). - * This file is used for jars that are built in a separate project from the plugin but will be found in the plugin at execution. - * - * @param bundle bundle and its fragments to look in. - * @param filenameWithinBundle path to filename within the bundle and fragments. <b>This must be a file, not a directory.</b> - * For finding the bundle itself (only when the bundle is packaged as a jar), use <@link #platformFind(Bundle)>. This does not use - * the platform shortcuts like "$os$". It finds the files exactly as specified. - * @param asLocal <code>true</code> if the urls need to point to local filesystem files. This may cause caching of files locally. This - * could happen if the file is within a plugin that is jarred. <code>false</code> if the url can be a non-local filesystem url. - * @return array of URL's for found files. - * - * @since 1.2.0 - */ - public static URL[] platformFindAll(Bundle bundle, IPath filenameWithinBundle, boolean asLocal) { - Bundle[] fragments = Platform.getFragments(bundle); - ArrayList urls = new ArrayList((fragments == null ? 0 : fragments.length) + 1); - String filename = filenameWithinBundle.toString(); - URL url = internalFindFromBundleOnly(bundle, filename, asLocal); - if (url != null) - urls.add(url); - if (fragments != null) { - for (int i = 0; i < fragments.length; i++) { - Bundle fragment = fragments[i]; - url = internalFindFromBundleOnly(fragment, filename, asLocal); - if (url != null) - urls.add(url); - } - } - return (URL[]) urls.toArray(new URL[urls.size()]); - } - - /** - * @param bundle - * @param filenameWithinBundle - * @param asLocal - * @return - * - * @since 1.2.0 - */ - private static URL internalFindFromBundleOnly(Bundle bundle, String filenameWithinBundle, boolean asLocal) { - try { - URL pvm = bundle.getEntry(filenameWithinBundle); - if (pvm != null) - return asLocal ? FileLocator.toFileURL(pvm) : pvm; - } catch (IOException e) { - } - if (ProxyPlugin.getPlugin().isDevMode()) { - return findDev(bundle, filenameWithinBundle, asLocal); - } else - return null; - } - - /** - * Find the filename relative to the platform bundle. It will search in the bundle and in all fragments for the file name. It will return - * URL for the file if found. - * <p> - * If in development mode, then if the jar is not found it will look in the plugin project's build.properties to find the output directory - * of the jar. If not in the build.properties (meaning it isn't being built by PDE), it will look in the proxy.jars file (if there is one). - * This file is used for jars that are built in a separate project from the plugin but will be found in the plugin at execution. - * - * @param bundle bundle and its fragments to look in. - * @param filenameWithinBundle path to filename within the bundle and fragments. <b>This must be a file, not a directory.</b> - * For finding the bundle itself (only when the bundle is packaged as a jar), use <@link #platformFind(Bundle)>. - * @param asLocal <code>true</code> if the urls need to point to local filesystem files. This may cause caching of files locally. This - * could happen if the file is within a plugin that is jarred. <code>false</code> if the url can be a non-local filesystem url. - * @return the found url or <code>null</code> if not found. - * - * @since 1.2.0 - */ - public static URL platformFind(Bundle bundle, IPath filenameWithinBundle, boolean asLocal) { - try { - URL pvm = FileLocator.find(bundle, filenameWithinBundle, null); - if (pvm != null) - return asLocal ? FileLocator.toFileURL(pvm) : pvm; - } catch (IOException e) { - } - if (ProxyPlugin.getPlugin().isDevMode()) { - return findDev(bundle, filenameWithinBundle.toString(), asLocal); - } else - return null; - - } - - private static final String BUILDPROPERTIES = "build.properties"; //$NON-NLS-1$ - private static final String PROXYJARS = "proxy.jars"; //$NON-NLS-1$ - - private static URL findDev(Bundle bundle, String filenameWithinBundle, boolean asLocal) { - // Got this far and in dev mode means it wasn't found, so we'll try for development style. - // It is assumed that in dev mode, we are running with the IDE as local and any - // build outputs will be local so local file protocol will be returned - // from Platform.resolve(). We won't be running in dev mode with our entireplugin being in a jar, - // or on a separate system. - try { - URL bp = bundle.getEntry(BUILDPROPERTIES); - if (bp != null) { - InputStream ios = null; - try { - ios = bp.openStream(); - Properties props = new Properties(); - props.load(ios); - String pathString = props.getProperty("output."+filenameWithinBundle.toString()); //$NON-NLS-1$ - if (pathString != null) { - URL pvm = bundle.getEntry(pathString); - if (pvm != null) - return asLocal ? FileLocator.toFileURL(pvm) : pvm; - } - } finally { - if (ios != null) - ios.close(); - } - } - } catch (IOException e) { - } - - try { - URL pvm = bundle.getEntry(PROXYJARS); - if (pvm != null) { - InputStream ios = null; - try { - ios = pvm.openStream(); - Properties props = new Properties(); - props.load(ios); - String pathString = props.getProperty(filenameWithinBundle.toString()); - if (pathString != null) { - URL url = FileLocator.resolve(bundle.getEntry("/")); // It is assumed that if in debug mode, then this plugin is an imported plugin within the developement workspace. //$NON-NLS-1$ - if (url.getProtocol().equals("file")) { //$NON-NLS-1$ - File file = new File(url.getFile()).getParentFile(); // This gets us to workspace root of development workspace. - file = new File(file, pathString); - return file.toURL(); - } - } - } finally { - if (ios != null) - ios.close(); - } - } - } catch (IOException e) { - } - return null; - } - - - /** - * Find the bundle and all active fragments libraries. This should normally be used only when the bundle is packaged as a jar and not as a directory. It will - * return the urls to the jars of the bundle and fragments. If in development mode it will find the bundle's "." output directory. - * @param bundle - * @return array of URL's for the jarred bundle and fragments. If the bundle/fragments are not packaged as jars, then the array will be empty. - * - * @since 1.2.0 - */ - public static URL[] platformFind(Bundle bundle) { - return null; - } - - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyLaunchSupport.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyLaunchSupport.java deleted file mode 100644 index 4a18afbed..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyLaunchSupport.java +++ /dev/null @@ -1,871 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.MessageFormat; -import java.util.*; -import java.util.logging.Level; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.IJobManager; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.*; -import org.eclipse.jdt.core.*; -import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.osgi.framework.Bundle; - -import org.eclipse.jem.internal.proxy.core.IConfigurationContributionInfo.ContainerPaths; -import org.eclipse.jem.internal.proxy.core.ProxyPlugin.FoundIDs; -import org.eclipse.jem.util.PerformanceMonitorUtil; -import org.eclipse.jem.util.TimerTests; - - -/** - * This is the used to launch the proxy registries. - * This is a static helper class, it is not meant to be instantiated. - * - * @since 1.0.0 - */ -public class ProxyLaunchSupport { - - // The key for the persisten property is in ProxyPlugin so that it can set it on startup without - // causing this class to be initialized. We don't want this class initialized until the very last - // moment when needed. This is because it needs UI to be active when initialized to query some - // values and if ProxyPlugin.start() causes this class to initialize, it may be too soon. - // - // If a project's persistent property is set with this value, that means there is at least one - // launch configuration with this project, but none are selected as the default. This is here - // so that we can check in the object contribution that if not set then don't show the menu - // item at all. This is to clean up the popup menu so not so cluttered. - // If the property is trully not set, then there is no default and there are no configurations for it. - public static final String NOT_SET = "...not..set.."; //$NON-NLS-1$ - - public static final String EXPRESSION_TRACING = "/debug/traceexpressions"; // Trace IExpressions. //$NON-NLS-1$ - - /** - * Timer threshold for indicating any expressions that took longer than this. - * If not set, then threshold will default to 100ms. - * It will only be used if traceexpressions is true. - */ - public static final String EXPRESSION_TRACEING_TIMER_THRESHOLD = "/debug/traceexpressionstimethreshold"; //$NON-NLS-1$ - - /* - * Registry of launch key to LaunchInfo classes. - */ - private static Map LAUNCH_INFO = new HashMap(2); - - /** - * Public only for access by other launch delegates to set up if they go outside of ProxyLaunchSupport, - * e.g. IDE proxy. Must not be used for any purpose. - * - * @since 1.0.0 - */ - public static class LaunchSupportIConfigurationContributionInfo implements IConfigurationContributionInfo { - - /** - * Construct with no settings. This is to be used by other launch delegates that - * don't have a {@link FoundIDs} available to fill in the fields. Those - * delegates must fill the fields themselves. - * - * - * @since 1.2.0 - */ - public LaunchSupportIConfigurationContributionInfo(IJavaProject javaProject) { - this.javaProject = javaProject; - } - - public LaunchSupportIConfigurationContributionInfo(IJavaProject javaProject, FoundIDs foundIDs) { - this(javaProject); - containerIds = foundIDs.containerIds; - containers = foundIDs.containers; - pluginIds = foundIDs.pluginIds; - projectPaths = foundIDs.projects; - } - - /* (non-Javadoc) - * Map of containers (IClasspathContainer) found in classpath (including required projects). - * This is for each project found. If there was a container in more than one project with the - * id, this set will contain the container from each such project. They are not considered the - * same because they come from a different project. - * <p> - * The key will be the containers, and the value will be a <code>Boolean</code>, where true means it - * is visible to the top-level project. - * <p> - * This is used for determining if a project's container implements the desired contributor. - * - * Will be empty if no project sent in to launch configuration. - * - * @see org.eclipse.jdt.core.IClasspathContainer - * - */ - public Map containers = Collections.EMPTY_MAP; - - - /* (non-Javadoc) - * Map of unique container id strings found in classpath (including required projects). - * If a container with the same id was found in more than one project, only one id will - * be in this set since they are the same. - * <p> - * The key will be the container ids, and the value will be ContainerPaths - * - * Will be empty if no project sent in to launch configuration. - * - */ - public Map containerIds = Collections.EMPTY_MAP; - - /* (non-Javadoc) - * Set of unique plugin id strings found in classpath (including required projects). - * If a required plugin with the same id was found in more than one project, only one id will - * be in this set since they are the same. - * <p> - * The key will be the plugin ids, and the value will be a <code>Boolean</code>, where true means it - * is visible to the top-level project. - * - * Will be empty if no project sent in to launch configuration. - */ - public Map pluginIds = Collections.EMPTY_MAP;; - - /* (non-Javadoc) - * Map of unique projects found in classpath (including required projects), but not including top-level project. - * <p> - * The key will be the <code>IPath</code> for the project, and the value will be a <code>Boolean</code>, where true means it - * is visible to the top-level project. - * - * Will be <code>null</code> if no project sent in to launch configuration. - */ - public Map projectPaths; - - /* (non-Javadoc) - * Java project for this launch. <code>null</code> if not for a project. - */ - public IJavaProject javaProject; - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributionInfo#getContainerIds() - */ - public Map getContainerIds() { - return containerIds; - } - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributionInfo#getContainers() - */ - public Map getContainers() { - return containers; - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributionInfo#getJavaProject() - */ - public IJavaProject getJavaProject() { - return javaProject; - } - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributionInfo#getPluginIds() - */ - public Map getPluginIds() { - return pluginIds; - } - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributionInfo#getProjectPaths() - */ - public Map getProjectPaths() { - return projectPaths; - } - - } - - /** - * LaunchInfo for a launch. Stored by key and retrievable by the key. - * This is only passed to launch delegates. It should not be passed on to - * others, though the IConfigurationContributionInfo may be. - * - * <p> - * This class is not intended to be subclassed by clients. - * </p> - * - * @see ProxyLaunchSupport#getInfo(String) - * @see IConfigurationContributionInfo - * @since 1.0.0 - */ - public static class LaunchInfo { - /** - * Contributors for this launch. It will never be <code>null</code>. It may be empty. - */ - public IConfigurationContributor[] contributors; - - /** - * The registry returned from the launch. The launch needs to set this before it returns. - */ - public ProxyFactoryRegistry resultRegistry; - - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributionInfo#getJavaProject() - */ - public IJavaProject getJavaProject() { - return configInfo.getJavaProject(); - } - - /** - * Return the IConfigurationContributionInfo for this launch. - * @return - * - * @since 1.0.0 - */ - public IConfigurationContributionInfo getConfigInfo() { - return configInfo; - } - - protected IConfigurationContributionInfo configInfo; - - } - - /** - * Start an implementation using the default config for the given project. - * <p> - * This will wait for build. If you - * know the build has been suspended by your thread, then you must use the other method that takes a waitForThread - * boolean, and you must pass in false. Otherwise it will deadlock. - * - * @param project The project. It must be a java project, and it cannot be <code>null</code>. - * @param vmTitle title for VM. It may be <code>null</code>. - * @param aContribs The contributions array. It may be <code>null</code>. - * @param pm - * @return The created registry. - * @throws CoreException - * - * @see ProxyLaunchSupport#startImplementation(IProject, String, IConfigurationContributor[], boolean, IProgressMonitor) - * @since 1.0.0 - */ - public static ProxyFactoryRegistry startImplementation( - IProject project, - String vmTitle, - IConfigurationContributor[] aContribs, - IProgressMonitor pm) - throws CoreException { - return startImplementation(project, vmTitle, aContribs, true, pm); - } - - /** - * Start an implementation using the default config for the given project. - * <p> - * If you know the build has been suspended by your thread, then you must use call this with false for waitForThread. Otherwise it will deadlock. - * - * @param project The project. It must be a java project, and it cannot be <code>null</code>. - * @param vmTitle title for VM. It may be <code>null</code>. - * @param aContribs The contributions array. It may be <code>null</code>. - * @param waitForBuild wait for the build. If caller knows that the build has been suspended by this thread, then it must call this with false. Otherwise a deadlock will occur. - * @param pm - * @return The created registry. - * @throws CoreException - * - * @since 1.0.0 - */ - public static ProxyFactoryRegistry startImplementation( - IProject project, - String vmTitle, - IConfigurationContributor[] aContribs, - boolean waitForBuild, - IProgressMonitor pm) - throws CoreException { - // First find the appropriate launch configuration to use for this project. - // The process is: - // 1) See if the project's persistent property has a setting for "proxyLaunchConfiguration", if it does, - // get the configuration of that name and create a working copy of it. - // 2) If not, then get the "org.eclipse.jem.proxy.LocalProxyLaunchConfigurationType" - // and create a new instance working copy. - - IJavaProject javaProject = JavaCore.create(project); - if (javaProject == null) { - throw new CoreException( - new Status( - IStatus.WARNING, - ProxyPlugin.getPlugin().getBundle().getSymbolicName(), - 0, - MessageFormat.format( - ProxyMessages.Not_Java_Project_WARN_, - new Object[] { project.getName()}), - null)); - } - - // First if specific set. - String launchName = project.getPersistentProperty(ProxyPlugin.PROPERTY_LAUNCH_CONFIGURATION); - ILaunchConfiguration config = null; - if (launchName != null && !NOT_SET.equals(launchName)) { - ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(); - for (int i = 0; i < configs.length; i++) { - if (configs[i].getName().equals(launchName)) { - config = configs[i]; - break; - } - } - if (config == null || !config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "").equals(project.getName())) { //$NON-NLS-1$ - project.setPersistentProperty(ProxyPlugin.PROPERTY_LAUNCH_CONFIGURATION, (String) null); // Config not found, or for a different project, so no longer the default. - config = null; - } - } - - if (config == null) { - ILaunchConfigurationWorkingCopy configwc = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(IProxyConstants.LOCAL_LAUNCH_TYPE).newInstance(null, DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom("LocalProxy_"+project.getName())); //$NON-NLS-1$ - configwc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName()); - config = configwc; - } - - return startImplementation(config, vmTitle, aContribs, waitForBuild, pm); - } - - /** - * Launch a registry using the given configuration. - * <p> - * This will wait for build. If you - * know the build has been suspended by your thread, then you must use the other method that takes a waitForThread - * boolean, and you must pass in false. Otherwise it will deadlock. - * - * @param config - * @param vmTitle title for VM. It may be <code>null</code>. - * @param aContribs The contributions array. It may be <code>null</code>. - * @param pm - * @return The registry from this configuration. - * @throws CoreException - * - * @see ProxyLaunchSupport#startImplementation(ILaunchConfiguration, String, IConfigurationContributor[], boolean, IProgressMonitor) - * @since 1.0.0 - */ - public static ProxyFactoryRegistry startImplementation( - ILaunchConfiguration config, - String vmTitle, - IConfigurationContributor[] aContribs, - IProgressMonitor pm) - throws CoreException { - return startImplementation(config, vmTitle, aContribs, true, pm); - } - - /** - * Launch a registry using the given configuration. - * <p> - * If you know the build has been suspended by your thread, then you must use you must pass in false for waitForThread. Otherwise it will deadlock. - * - * @param config - * @param vmTitle title for VM. It may be <code>null</code>. - * @param aContribs The contributions array. It may be <code>null</code>. - * @param waitForBuild wait for the build. If caller knows that the build has been suspended by this thread, then it must call this with false. Otherwise a deadlock will occur. - * @param pm - * @return The registry from this configuration. - * @throws CoreException - * - * @since 1.0.0 - */ - public static ProxyFactoryRegistry startImplementation( - ILaunchConfiguration config, - String vmTitle, - IConfigurationContributor[] aContribs, - boolean waitForBuild, - IProgressMonitor pm) - throws CoreException { - - if (pm == null) - pm = new NullProgressMonitor(); - String stepId = "Pre-launch VM ( " + vmTitle + " )"; //$NON-NLS-1$ //$NON-NLS-2$ - TimerTests.basicTest.startStep(stepId); - if (vmTitle.equals("Beaninfo")) //$NON-NLS-1$ - PerformanceMonitorUtil.getMonitor().snapshot(125); - final ILaunchConfigurationWorkingCopy configwc = config.getWorkingCopy(); - - pm.beginTask("", 400); //$NON-NLS-1$ - pm.subTask(ProxyMessages.ProxyLaunch); - if (waitForBuild) { - // See if build needed or waiting or inprogress, if so, wait for it to complete. We've - // decided too difficult to determine if build would affect us or not, so just wait. - if (UI_RUNNER != null) - UI_RUNNER.handleBuild(new SubProgressMonitor(pm, 100)); - else - runBuild(new SubProgressMonitor(pm, 100)); - - if (pm.isCanceled()) - return null; - } - - if (aContribs != null) { - IConfigurationContributor[] newContribs = new IConfigurationContributor[aContribs.length+1]; - System.arraycopy(aContribs, 0, newContribs, 1, aContribs.length); - newContribs[0] = new ProxyContributor(); - aContribs = newContribs; - } else - aContribs = new IConfigurationContributor[] {new ProxyContributor()}; - - String launchKey = String.valueOf(System.currentTimeMillis()); - LaunchInfo launchInfo = new LaunchInfo(); - synchronized (ProxyLaunchSupport.class) { - while (LAUNCH_INFO.containsKey(launchKey)) { - launchKey += 'a'; // Just add something on to make it unique. - } - LAUNCH_INFO.put(launchKey, launchInfo); - } - - String projectName = configwc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null); - aContribs = fillInLaunchInfo(aContribs, launchInfo, projectName); - - try { - configwc.setAttribute(IProxyConstants.ATTRIBUTE_LAUNCH_KEY, launchKey); - if (vmTitle != null && vmTitle.length()>0) - configwc.setAttribute(IProxyConstants.ATTRIBUTE_VM_TITLE, vmTitle); - - if (ATTR_PRIVATE != null) - configwc.setAttribute(ATTR_PRIVATE, true); - - // Let contributors modify the configuration. - final IConfigurationContributor[] contribs = aContribs; - final LaunchInfo linfo = launchInfo; - for (int i = 0; i < contribs.length; i++) { - // First run the initialize. - // Run in safe mode so that anything happens we don't go away. - final int ii = i; - SafeRunner.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Don't need to do anything. Platform.run logs it for me. - } - - public void run() throws Exception { - contribs[ii].initialize(linfo.getConfigInfo()); - } - }); - - // Now run the contribute to configuration. - // Run in safe mode so that anything happens we don't go away. - SafeRunner.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Don't need to do anything. Platform.run logs it for me. - } - - public void run() throws Exception { - contribs[ii].contributeToConfiguration(configwc); - } - }); - } - pm.worked(100); - - configwc.launch(ILaunchManager.RUN_MODE, new SubProgressMonitor(pm, 100)); - - final ProxyFactoryRegistry reg = launchInfo.resultRegistry; - if (!pm.isCanceled() && reg == null) - throw new CoreException(new Status(IStatus.WARNING, ProxyPlugin.getPlugin().getBundle().getSymbolicName(), 0, ProxyMessages.ProxyLaunchSupport_RegistryCouldNotStartForSomeReason_WARN_, null)); - if (pm.isCanceled()) { - if (reg != null) - reg.terminateRegistry(); - return null; - } - - performExtensionRegistrations((BaseProxyFactoryRegistry) reg, launchInfo); - -// TimerTests.basicTest.startStep("contribute to registry"); - for (int i = 0; i < contribs.length; i++) { - final int ii = i; - // Run in safe mode so that anything happens we don't go away. - SafeRunner.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - // Don't need to do anything. Platform.run logs it for me. - } - - public void run() throws Exception { -// String stepid = "contribute to registry for " + contribs[ii].getClass(); -// TimerTests.basicTest.startStep(stepid); - contribs[ii].contributeToRegistry(reg); -// TimerTests.basicTest.stopStep(stepid); - } - }); - } -// TimerTests.basicTest.stopStep("contribute to registry"); - } finally { - // Clean up and return. - LAUNCH_INFO.remove(launchKey); - } - - pm.done(); - if (vmTitle.equals("Beaninfo")) //$NON-NLS-1$ - PerformanceMonitorUtil.getMonitor().snapshot(126); - TimerTests.basicTest.stopStep(stepId); - return launchInfo.resultRegistry; - } - - /** - * Create a default IConfigurationContributionInfo for the given project. This is useful info even when not launching a - * vm. - * - * @param javaProject - * @return new contrib info. - * @throws JavaModelException - * - * @since 1.1.0 - */ - public static IConfigurationContributionInfo createDefaultConfigurationContributionInfo(IJavaProject javaProject) throws JavaModelException { - LaunchSupportIConfigurationContributionInfo configInfo = new LaunchSupportIConfigurationContributionInfo(javaProject, - ProxyPlugin.getPlugin().getIDsFound(javaProject)); - return configInfo; - - } - - /** - * Use in calling {@link ProxyLaunchSupport#fillInLaunchInfo(IConfigurationContributor[], LaunchInfo, String)} for the configuration - * contributors array if there are no incoming contributors. - * - * @since 1.1.0 - */ - public static final IConfigurationContributor[] EMPTY_CONFIG_CONTRIBUTORS = new IConfigurationContributor[0]; - /** - * Fill in the launch info config info and contribs. The contribs sent in may be expanded due to extension - * points and a new one created. Either the expanded copy or the original (if no change) will be stored in - * the launchinfo and returned from this call. - * - * @param aContribs this should never be <code>null</code>. Pass in {@link ProxyLaunchSupport#EMPTY_CONFIG_CONTRIBUTORS} in that case. - * @param launchInfo - * @param projectName - * @return a modified aContribs if any change was made to it. This will never be <code>null</code>. It will return an empty list if aContribs was null and no changes were made. - * @throws JavaModelException - * @throws CoreException - * - * @since 1.0.0 - */ - public static IConfigurationContributor[] fillInLaunchInfo(IConfigurationContributor[] aContribs, LaunchInfo launchInfo, String projectName) throws JavaModelException, CoreException { - if (projectName != null) { - projectName = projectName.trim(); - if (projectName.length() > 0) { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - IJavaProject javaProject = JavaCore.create(project); - if (javaProject != null && javaProject.exists()) { - launchInfo.configInfo = createDefaultConfigurationContributionInfo(javaProject); - if (!launchInfo.configInfo.getContainerIds().isEmpty() || !launchInfo.configInfo.getContainers().isEmpty() || !launchInfo.configInfo.getPluginIds().isEmpty()) { - List computedContributors = new ArrayList(launchInfo.configInfo.getContainerIds().size()+launchInfo.configInfo.getContainers().size()+launchInfo.configInfo.getPluginIds().size()); - // Note: We don't care about the visibility business here. For contributors to proxy it means - // some classes in the projects/plugins/etc. need configuration whether they are visible or not. - // This is because even though not visible, some other visible class may instantiate it. So it - // needs the configuration. - // First handle explicit classpath containers that implement IConfigurationContributor - for (Iterator iter = launchInfo.configInfo.getContainers().keySet().iterator(); iter.hasNext();) { - IClasspathContainer container = (IClasspathContainer) iter.next(); - if (container instanceof IConfigurationContributor) - computedContributors.add(container); - } - - // Second add in contributors that exist for a container id. - for (Iterator iter = launchInfo.configInfo.getContainerIds().values().iterator(); iter.hasNext();) { - ContainerPaths paths = (ContainerPaths) iter.next(); - IConfigurationElement[] contributors = ProxyPlugin.getPlugin().getContainerConfigurations(paths.getContainerId(), paths.getAllPaths()); - if (contributors != null) - for (int i = 0; i < contributors.length; i++) { - Object contributor = contributors[i].createExecutableExtension(ProxyPlugin.PI_CLASS); - if (contributor instanceof IConfigurationContributor) - computedContributors.add(contributor); - } - } - - // Finally add in contributors that exist for a plugin id. - for (Iterator iter = launchInfo.configInfo.getPluginIds().keySet().iterator(); iter.hasNext();) { - String pluginId = (String) iter.next(); - IConfigurationElement[] contributors = ProxyPlugin.getPlugin().getPluginConfigurations(pluginId); - if (contributors != null) - for (int i = 0; i < contributors.length; i++) { - Object contributor = contributors[i].createExecutableExtension(ProxyPlugin.PI_CLASS); - if (contributor instanceof IConfigurationContributor) - computedContributors.add(contributor); - } - } - - // Now turn into array - if (!computedContributors.isEmpty()) { - IConfigurationContributor[] newContribs = new IConfigurationContributor[aContribs.length - + computedContributors.size()]; - System.arraycopy(aContribs, 0, newContribs, 0, aContribs.length); - IConfigurationContributor[] cContribs = (IConfigurationContributor[]) computedContributors - .toArray(new IConfigurationContributor[computedContributors.size()]); - System.arraycopy(cContribs, 0, newContribs, aContribs.length, cContribs.length); - aContribs = newContribs; - } - } - } - } - } - - launchInfo.contributors = aContribs; - return aContribs; - } - - /** - * Execute the extension registrations that are valid for this type of registry and the launchinfo paths. - * <p> - * This is meant to be called only by registry implementations that do not launch through a launch configration after the registry is created but - * before the {@link IConfigurationContributor#contributeToRegistry(ProxyFactoryRegistry)} is called. This will be called automatically - * by registries that used a launch configuration to launch. - * - * @param baseRegistry - * @param launchInfo - * @throws CoreException - * - * @since 1.1.0 - */ - public static void performExtensionRegistrations(final BaseProxyFactoryRegistry baseRegistry, LaunchInfo launchInfo) throws CoreException { - IConfigurationContributionInfo configInfo = launchInfo.configInfo; - if (configInfo != null && (!configInfo.getContainerIds().isEmpty() || !configInfo.getPluginIds().isEmpty())) { - String registryID = baseRegistry.getRegistryTypeID(); - // Note: We don't care about the visibility business here. For contributors to proxy it means - // some classes in the projects/plugins/etc. need configuration whether they are visible or not. - // This is because even though not visible, some other visible class may instantiate it. So it - // needs the configuration. - - // First call registrations that exist for a container id. - for (Iterator iter = configInfo.getContainerIds().values().iterator(); iter.hasNext();) { - ContainerPaths paths = (ContainerPaths) iter.next(); - IConfigurationElement[] contributors = ProxyPlugin.getPlugin().getContainerExtensions(paths.getContainerId(), paths.getAllPaths()); - if (contributors != null) - for (int i = 0; i < contributors.length; i++) { - if (registryID.equals(contributors[i].getAttribute(ProxyPlugin.PI_REGISTRY_TYPE))) { - try { - final IExtensionRegistration contributor = (IExtensionRegistration) contributors[i].createExecutableExtension(ProxyPlugin.PI_CLASS); - SafeRunner.run(new ISafeRunnable() { - - public void run() throws Exception { - contributor.register(baseRegistry); - } - - public void handleException(Throwable exception) { - // Don't need to do anything, Platform logs it for me. - } - - }); - } catch (ClassCastException e) { - // If not right class, just ignore it. - } - } - } - } - - // Finally add in contributors that exist for a plugin id. - for (Iterator iter = configInfo.getPluginIds().keySet().iterator(); iter.hasNext();) { - String pluginId = (String) iter.next(); - IConfigurationElement[] contributors = ProxyPlugin.getPlugin().getPluginExtensions(pluginId); - if (contributors != null) - for (int i = 0; i < contributors.length; i++) { - if (registryID.equals(contributors[i].getAttribute(ProxyPlugin.PI_REGISTRY_TYPE))) { - try { - final IExtensionRegistration contributor = (IExtensionRegistration) contributors[i].createExecutableExtension(ProxyPlugin.PI_CLASS); - SafeRunner.run(new ISafeRunnable() { - - public void run() throws Exception { - contributor.register(baseRegistry); - } - - public void handleException(Throwable exception) { - // Don't need to do anything, Platform logs it for me. - } - - }); - } catch (ClassCastException e) { - // If not right class, just ignore it. - } - } - } - } - } -} - - - /* - * Run the build. If the original launch was in the UI thread, this will - * be called under control of an IProgressService so that it is in a separate - * thread and the UI will remain responsive (in that either a busy cursor comes - * up or eventually a progress dialog). - * If the pm is canceled, this will just return, but the caller must check if the pm is canceled. - * - * <package-protected> so that only the UI handler will access it. - */ - static void runBuild(IProgressMonitor pm) throws CoreException { - boolean autobuilding = ResourcesPlugin.getWorkspace().isAutoBuilding(); - if (!autobuilding) { - try { - // We are not autobuilding. So kick off a build right here and - // wait for it. (If we already within a build on this thread, then this - // will return immediately without building. We will take that risk. If - // some other thread is building, we will wait for it finish before we - // can get it and do our build. - ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, pm); - } catch (OperationCanceledException e) { - // The pm is already marked canceled, so caller can check that instead. - } - } else { - pm.beginTask("", 200); //$NON-NLS-1$ - IJobManager jobManager = Job.getJobManager(); - Job currentJob = jobManager.currentJob(); - if (currentJob == null || (!currentJob.belongsTo(ResourcesPlugin.FAMILY_AUTO_BUILD) && !currentJob.belongsTo(ResourcesPlugin.FAMILY_MANUAL_BUILD))) { - if (jobManager.find(ResourcesPlugin.FAMILY_AUTO_BUILD).length > 0 || jobManager.find(ResourcesPlugin.FAMILY_MANUAL_BUILD).length >0) { - // We are not within a build job. If we were, then we don't do the build. We will take - // that risk. The problem is that if within the build, we can't wait for it to finish because - // we would stop the thread and so the build would not complete. - pm.subTask(ProxyMessages.ProxyWaitForBuild); - try { - while (true) { - try { - jobManager.join(ResourcesPlugin.FAMILY_AUTO_BUILD, new SubProgressMonitor(pm, 100)); - jobManager.join(ResourcesPlugin.FAMILY_MANUAL_BUILD, new SubProgressMonitor(pm, 100)); - break; - } catch (InterruptedException e) { - } - } - } catch (OperationCanceledException e) { - } - } - } - pm.done(); - } - } - - - /* - * This prevents the launch from being shown. However these constants are in UI component, and we don't - * want to pre-req that. So we will get them reflectively instead. - * public but only so that launch delegate can get to it. - */ - public static String ATTR_PRIVATE; - private static IUIRunner UI_RUNNER = null; - - static { - ATTR_PRIVATE = null; - try { - // See if we have a UI bundle and it is active. If it exists but is not active, - // then we won't do anything. If we were running a UI application, it should already - // of been active before we got here. - Bundle uiBundle = Platform.getBundle("org.eclipse.ui"); //$NON-NLS-1$ - if (uiBundle != null && uiBundle.getState() == Bundle.ACTIVE) { - try { - // We have a UI bundle, so we can load our UIRunner class and it will load fine. - UI_RUNNER = (IUIRunner) Class.forName("org.eclipse.jem.internal.proxy.core.UIRunner").newInstance(); //$NON-NLS-1$ - } catch (InstantiationException e1) { - ProxyPlugin.getPlugin().getLogger().log(e1, Level.WARNING); - } - - // So that we can run headless (w/o ui), need to do class forName for debugui contants - Bundle debuguiBundle = Platform.getBundle("org.eclipse.debug.ui"); //$NON-NLS-1$ - if (debuguiBundle != null && debuguiBundle.getState() == Bundle.ACTIVE) { - Class debugUIConstants = debuguiBundle.loadClass("org.eclipse.debug.ui.IDebugUIConstants"); //$NON-NLS-1$ - ATTR_PRIVATE = (String) debugUIConstants.getField("ATTR_PRIVATE").get(null); //$NON-NLS-1$ - } - } - } catch (SecurityException e) { - } catch (ClassNotFoundException e) { - } catch (NoSuchFieldException e) { - } catch (IllegalArgumentException e) { - } catch (IllegalAccessException e) { - } - } - - /* (non-Javadoc) - * Only referenced by launch delegates. public because they are in other packages, - * or even external developers packages. Not meant to be generally available. - * - * This is needed because we can't pass the generic info into a launch configuration - * because a launch configuration can't take objects. Only can take strings and numbers. - */ - public static synchronized LaunchInfo getInfo(String key) { - return (LaunchInfo) LAUNCH_INFO.get(key); - } - - /** - * Convert the string path into a valid url. - * @param path - * @return the url or <code>null</code> if not convertable (i.e. not well-formed). - * - * @since 1.0.0 - */ - public static URL convertStringPathToURL(String path) { - try { - return path != null ? new File(path).toURL() : null; - } catch (MalformedURLException e) { - return null; - } - } - - /** - * Convert the string paths into a valid urls. - * - * @param paths - * @return the urls or <code>null</code> if paths is null. Any path not convertable (i.e. not well-formed) will not be in the final list. - * So this means the result length may be smaller than the paths length. - * - * @since 1.0.0 - */ - public static URL[] convertStringPathsToURL(String[] paths) { - if (paths != null) { - URL[] result = new URL[paths.length]; - int nextURL = 0; - for (int i = 0; i < paths.length; i++) { - URL url = convertStringPathToURL(paths[i]); - if (url != null) - result[nextURL++] = url; - } - if (nextURL == 0) - return null; // None were found. - - if (nextURL != result.length) { - URL[] nr = new URL[nextURL]; - System.arraycopy(result, 0, nr, 0, nr.length); - result = nr; - } - return result; - } else - return null; - } - - /** - * Convert the urls to string array. It is assumed the urls are in file protocol. It handles platform and JDK reqts. too. - * @param urls - * @return string paths or <code>null</code> if urls is <code>null</code>. Any <code>null</code> entry of urls will result in - * a corresponding <code>null</code> in the strings. - * - * @since 1.0.0 - */ - public static String[] convertURLsToStrings(URL[] urls) { - if (urls != null) { - String[] strings = new String[urls.length]; - for (int i = 0; i < urls.length; i++) { - // [132378] There is a problem with IBM JDK's. They can't handle the getFile() from a URL in the java lib path on Windows. - // That is because the normalized format of a file url on windows is "file:/D:/asdfasf". But IBM JDKs can't handle the - // leading slash. Sun JDKs do. - URL url = urls[i]; - if (url != null) { - strings[i] = url.getFile(); - if(strings[i].startsWith("/") && Platform.getOS().equals(Platform.OS_WIN32)) //$NON-NLS-1$ - strings[i] = strings[i].substring(1); - } - } - return strings; - } else - return null; - } - - /* (non-Javadoc) - * Local contributor used to make sure that certain jars are in the path. - * - * @since 1.0.0 - */ - static class ProxyContributor extends ConfigurationContributorAdapter { - public void contributeClasspaths(IConfigurationContributionController controller) { - // Add the required jars to the end of the classpath. (We want proxyCommon and initParser (+ initParser NLS), but they are in the runtime of the proxy bundle (which is jarred up), so we contribute the bundle instead. - controller.contributeClasspath(ProxyPlugin.getPlugin().getBundle(), (IPath) null, IConfigurationContributionController.APPEND_USER_CLASSPATH, true); //$NON-NLS-1$ - } - } - -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyMessages.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyMessages.java deleted file mode 100644 index 81786529f..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyMessages.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; - -import org.eclipse.osgi.util.NLS; - -public final class ProxyMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.jem.internal.proxy.core.messages";//$NON-NLS-1$ - - private ProxyMessages() { - // Do not instantiate - } - - public static String UnexpectedException_EXC_; - public static String ClassCast_EXC__IncorrectType; - public static String ProxyFactory_EXC__NoBeanProxyFactory; - public static String ProxyFactory_EXC__NoBeanTypeProxyFactory; - public static String Not_Java_Project_WARN_; - public static String No_VM_WARN_; - public static String No_Implementation_WARN_; - public static String ProxyLaunch; - public static String ProxyWaitForBuild; - public static String Expression_InInvalidStateDueTo_EXC_; - public static String Expression_InInvalidState_EXC_; - public static String Expression_TypeSentInInvalidOrder_EXC_; - public static String Expression_ArrayTypeNotAnArray_EXC_; - public static String Expression_CannotHandleNoReceiveOnFieldAccess_EXC_; - public static String Expression_MethodsNeedReceiver_EXC_; - public static String Expression_InvalidMarkNesting; - public static String ProxyPlugin_CleanupDefaultProxyLaunchConfigurations; - public static String ProxyLaunchSupport_RegistryCouldNotStartForSomeReason_WARN_; - public static String Expression_CreateProxyReassignmentExpression_InvalidForReassignment_EXC_; - - static { - NLS.initializeMessages(BUNDLE_NAME, ProxyMessages.class); - } - - public static String Expression_InvalidProxy; -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyPlugin.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyPlugin.java deleted file mode 100644 index dfd3fd5e3..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyPlugin.java +++ /dev/null @@ -1,1371 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -import java.io.*; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.*; -import java.util.Map.Entry; -import java.util.logging.Level; -import java.util.regex.Pattern; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.*; -import org.eclipse.jdt.core.*; -import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.eclipse.jdt.launching.JavaRuntime; -import org.eclipse.osgi.service.resolver.BundleSpecification; -import org.eclipse.osgi.util.ManifestElement; -import org.osgi.framework.*; - -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.jem.util.logger.proxyrender.EclipseLogger; - -import org.eclipse.jem.internal.proxy.core.IConfigurationContributionInfo.ContainerPaths; - -/** - * The plugin class for the org.eclipse.jem.internal.proxy.core plugin. - */ - -public class ProxyPlugin extends Plugin { - - /** - * This interface is for a listener that needs to know if this plugin (ProxyPlugin) is being shutdown. - * It is needed because there are some extensions that get added dynamically that need to know when the - * plugin is being shutdown. Can't use new bundle listener for this because it notifies AFTER shutdown. - * - * @since 1.0.0 - */ - public interface IProxyPluginShutdownListener { - /** - * ProxyPlugin is in shutdown. - * - * @since 1.0.0 - */ - public void shutdown(); - } - - private static ProxyPlugin PROXY_PLUGIN = null; - public static final String PREFERENCES_VM_NOVERIFY_KEY = "JEM_PREFERENCES_VM_NOVERIFY_KEY"; // Key for NOVERIFY option of VM //$NON-NLS-1$ - public static final String PDE_NATURE_ID = "org.eclipse.pde.PluginNature" ; //$NON-NLS-1$ - - // If this is set to true, then in development mode and it will try for proxy jars in directories. - private boolean devMode; - - private ListenerList shutdownListeners; - - public ProxyPlugin() { - super(); - PROXY_PLUGIN = this; - devMode = Platform.inDevelopmentMode(); - } - - public boolean isDevMode() { - return devMode; - } - - /** - * Access the singleton - * @return the singleton plugin - * - * @since 1.0.0 - */ - public static ProxyPlugin getPlugin() { - return PROXY_PLUGIN; - } - - private Logger logger; - public Logger getLogger() { - if (logger == null) - logger = EclipseLogger.getEclipseLogger(this); - return logger; - } - - /** - * This will take the bundle and file name and make it local and return that - * fully qualified. It will look in fragments, but only returns first found. If there can be multiples use - * the one for bundles and it fragments. - * <p> - * If we are in development and it will pick it up from the path - * that is listed in the proxy.jars file located in the bundle passed in. This allows development code to be - * used in place of the actual runtime jars. If the runtime jars are found, - * they will be used. - * <p> - * For example if looking for file runtime/xyz.jar in bundle abc, then in bundle directory for abc, - * there should be a file called proxy.jars. This should only be in development, this file should not - * be distributed for production. It would be distributed in the SDK environment when testing is desired. - * <p> - * The format of the file is: - * runtimefile=/projectname/builddirectory - * <p> - * For this to work when the actual jar is not found, the Eclipse must of been started in - * dev mode (i.e. the bundle location will be a project within the developer Eclipse. That way - * we can go up one level for the current install location and assume the above projectname - * will be found relative to the directory. - * <p> - * For the above example: - * runtime/xyz.jar=/xyzproject/bin - * <p> - * It will return "." if file can't be found. It means nothing but it won't cause jvm to crash. - * - * @param bundle - * @param filenameWithinBundle - * @return the path to the file or <code>"."</code> if not found. - * - * @since 1.0.0 - */ - public String localizeFromBundleOnly(Bundle bundle, String filenameWithinBundle) { - URL url = urlLocalizeFromBundleOnly(bundle, filenameWithinBundle); - return url != null ? getFileFromURL(url) : "."; //$NON-NLS-1$ - } - public String localizeFromBundleAndFragments(Bundle bundle, String filenameWithinBundle) { - URL url = urlLocalizeFromBundleAndFragments(bundle, filenameWithinBundle); - return url != null ? getFileFromURL(url) : "."; //$NON-NLS-1$ - } - - /** - * Just like localizeFromBundle except it will return an array of Strings. It will look for the filename - * within the bundle and any fragments of the bundle. If none are found, an empty array will be returned. - * <p> - * To find the files in the fragments that are in the runtime path (i.e. libraries), it will need to use a suffix, - * This is because the JDT will get confused if a runtime jar in a fragment has the same name - * as a runtime jar in the main bundle. - * NOTE: This is obsolete. JDT no longer has this problem. So we can find libraries in fragments that have the - * same file path. - * <p> - * So we will use the following search pattern: - * <ol> - * <li>Find in all of the fragments those that match the name exactly in the same paths if paths are supplied.</li> - * <li>Find in all of the fragments, in their runtime path (library stmt), those that match the name - * but have a suffix the same as the uniqueid of the fragment (preceeded by a period). This is so that it can be easily - * found but yet be unique in the entire list of fragments. For example if looking for "runtime/xyz.jar" - * and we have fragment "a.b.c.d.frag", then in the runtime path we will look for the file - * "runtime/xyz.a.b.c.d.frag.jar". Note: This is obsolete. Still here only for possible old code. Will go - * away in future.</li> - * <p> - * If the files in the fragments are not in the fragments library path then it can have the same name. NOTE: Obsolete, - * JDT can now handle same name. - * <p> - * This is useful for nls where the nls for the filename will be in one or more of the fragments of the plugin. - * - * @param bundle - * @param filenameWithinBundle - * @return - * - * @since 1.0.0 - */ - public String[] localizeAllFromBundleAndFragments(Bundle bundle, String filenameWithinBundle) { - URL[] urls = urlLocalizeAllFromBundleAndFragments(bundle, filenameWithinBundle); - String[] result = new String[urls.length]; - for (int i = 0; i < urls.length; i++) { - result[i] = getFileFromURL(urls[i]); - } - return result; - } - - public static String getFileFromURL(URL url) { - // We need to do this in a device independent way. The URL will always put a leading '/' in the - // file part of the URL, but on Windows we need to have this '/' removed. Some JRE's don't understand it. - return new File(url.getFile()).getAbsolutePath(); - - } - - public URL urlLocalizeFromBundleAndFragments(Bundle bundle, String filenameWithinBundle) { - return urlLocalizeFromBundleAndFragments(bundle, new Path(filenameWithinBundle)); - } - public URL urlLocalizeFromBundleAndFragments(Bundle bundle, IPath filenameWithinBundle) { - try { - URL pvm = FileLocator.find(bundle, filenameWithinBundle, null); - if (pvm != null) - return FileLocator.toFileURL(pvm); - } catch (IOException e) { - } - if (devMode) { - URL[] urls = findDevAllFromBundleAndFragments(bundle, filenameWithinBundle.toString()); - if (urls.length > 0) - return urls[0]; - else - return null; - } else - return null; - } - - /** - * Like <code>localizeFromBundleAndFragments</code> except it returns URL's instead. - * - * @param bundle - * @param filenameWithinBundle - * @return - * - * @see ProxyPlugin#localizeFromBundleAndFragments(Bundle, String) - * @since 1.0.0 - */ - public URL[] urlLocalizeAllFromBundleAndFragments(Bundle bundle, String filenameWithinBundle) { - return urlLocalizeAllBundleAndFragments(bundle, Platform.getFragments(bundle), filenameWithinBundle); - } - public URL[] urlLocalizeAllFromBundleAndFragments(Bundle bundle, IPath filenameWithinBundle) { - return urlLocalizeAllBundleAndFragments(bundle, Platform.getFragments(bundle), filenameWithinBundle.toString()); - } - - /** - * @param bundle - * @param filenameWithinBundle - * @param fragments - * @return - * - * @since 1.0.0 - */ - private URL[] urlLocalizeAllBundleAndFragments(Bundle bundle, Bundle[] fragments, String filenameWithinBundle) { - - ArrayList urls = new ArrayList((fragments == null ? 0 : fragments.length) + 1); - URL url = internalUrlLocalizeFromBundleOnly(bundle, filenameWithinBundle); - if (url != null) - urls.add(url); - if (fragments != null) { - for (int i = 0; i < fragments.length; i++) { - Bundle fragment = fragments[i]; - url = internalUrlLocalizeFromBundleOnly(fragment, filenameWithinBundle); - if (url != null) - urls.add(url); - } - } - return (URL[]) urls.toArray(new URL[urls.size()]); - } - - private static final String PROXYJARS = "proxy.jars"; //$NON-NLS-1$ - - /** - * @see ProxyPlugin#localizeFromBundle(Bundle, String) - * - * This is just a helper to return a url instead. - * - * @param bundle - * @param filenameWithinBundle - * @return - * - * @since 1.0.0 - */ - public URL urlLocalizeFromBundleOnly(Bundle bundle, String filenameWithinBundle) { - // If the filenameWithinBundle begins with one of these special characters, - // it might be in a fragment. - if (filenameWithinBundle.charAt(0) == '$' - && (filenameWithinBundle.regionMatches(true, 0, "$nl$", 0, "$nl$".length()) //$NON-NLS-1$ //$NON-NLS-2$ - || filenameWithinBundle.regionMatches(true, 0, "$os$", 0, "$os$".length()) || filenameWithinBundle.regionMatches(true, 0, //$NON-NLS-1$ //$NON-NLS-2$ - "$ws$", 0, "$ws$".length()))) //$NON-NLS-1$ //$NON-NLS-2$ - return urlLocalizeFromBundleAndFragments(bundle, filenameWithinBundle); - try { - URL pvm = new URL(bundle.getEntry("/"), filenameWithinBundle); //$NON-NLS-1$ - pvm = verifyFound(FileLocator.toFileURL(pvm)); - if (pvm != null) - return pvm; - } catch (IOException e) { - } - return findDev(bundle, filenameWithinBundle); - - } - - protected URL internalUrlLocalizeFromBundleOnly(Bundle bundle, String filenameWithinBundle) { - try { - URL pvm = bundle.getEntry(filenameWithinBundle); - if (pvm != null) - return FileLocator.toFileURL(pvm); - } catch (IOException e) { - } - return findDev(bundle, filenameWithinBundle); - - } - - private URL verifyFound(URL pvm) throws IOException { - if (devMode) { - // Need to test if found in devmode. Otherwise we will just assume it is found. If not found on remote and moved to cache, an IOException would be thrown. - if (pvm != null) { - InputStream ios = null; - try { - ios = pvm.openStream(); - if (ios != null) - return pvm; // Found it, so return it. - } finally { - if (ios != null) - ios.close(); - } - } - } else - return pvm; - return null; - } - - /** - * @see ProxyPlugin#localizeFromBundle(bundle, String) - * - * This is just a helper to return a url instead. - * - * @param bundle - * @param filenameWithinBundle - * @return - * - * @since 1.0.0 - */ - public URL urlLocalizeFromBundleOnly(Bundle bundle, IPath filenameWithinBundle) { - return urlLocalizeFromBundleOnly(bundle, filenameWithinBundle.toString()); - } - - private URL findDev(Bundle bundle, String filenameWithinBundle) { - if (devMode) { - // Got this far and in dev mode means it wasn't found, so we'll try for development style. - // It is assumed that in dev mode, we are running with the IDE as local and any - // build outputs will be local so local file protocol will be returned - // from Platform.resolve(). We won't be running in dev mode with our entireplugin being in a jar, - // or on a separate system. - try { - URL pvm = bundle.getEntry(PROXYJARS); - if (pvm != null) { - InputStream ios = null; - try { - ios = pvm.openStream(); - Properties props = new Properties(); - props.load(ios); - String pathString = props.getProperty(filenameWithinBundle.toString()); - if (pathString != null) { - URL url = FileLocator.resolve(bundle.getEntry("/")); // It is assumed that if in debug mode, then this plugin is an imported plugin within the developement workspace. //$NON-NLS-1$ - if (url.getProtocol().equals("file")) { //$NON-NLS-1$ - File file = new File(url.getFile()).getParentFile(); // This gets us to workspace root of development workspace. - file = new File(file, pathString); - return file.toURL(); - } - } - } finally { - if (ios != null) - ios.close(); - } - } - } catch (IOException e) { - } - } - - return null; - - } - private URL[] findDevAllFromBundleAndFragments(Bundle bundle, String filenameWithinBundle) { - Bundle [] fragments = Platform.getFragments(bundle); - ArrayList urls = new ArrayList((fragments == null ? 0 : fragments.length) + 1); - URL url = findDev(bundle, filenameWithinBundle); - if (url != null) - urls.add(url); - if (fragments != null) { - for (int i = 0; i < fragments.length; i++) { - Bundle fragment = fragments[i]; - url = findDev(fragment, filenameWithinBundle); - if (url != null) - urls.add(url); - } - } - return (URL[]) urls.toArray(new URL[urls.size()]); - } - - /** - * Get the urls for the bundle and all fragments. This is used when bundles/fragments are jarred. It won't work correctly if not - * a jarred bundle and fragments. This would most likely be used for NLS - * purposes to bring in the bundle and all of the nls. If a specific fragment was wanted use {@link #urlLocalizeBundle(Bundle)} instead. - * - * @param bundle - * @return urls for bundle and all fragments. - * - * @since 1.2.0 - */ - public URL[] urlLocalizeBundleAndFragments(Bundle bundle) { - Bundle[] fragments = Platform.getFragments(bundle); - List urls = new ArrayList((fragments == null ? 0 : fragments.length) + 1); - URL[] burls = urlLocalizeBundle(bundle); - if (burls != null) { - urls.addAll(Arrays.asList(burls)); - } - if (fragments != null) { - for (int i = 0; i < fragments.length; i++) { - burls = urlLocalizeBundle(fragments[i]); - if (burls != null) - urls.addAll(Arrays.asList(burls)); - } - } - - return (URL[]) urls.toArray(new URL[urls.size()]); - - } - - /** - * Get the urls for the bundle libraries only. If a fragment is wanted, then pass in the fragment instead. - * If bundle and all fragments are wanted use {@link #urlLocalizeBundleAndFragments(Bundle)} instead. - * <p> - * If in dev mode, it will use the binary output directory for the plugin libraries from the build.properties file. - * - * @param bundle - * @return URL array of local library references for the bundle or null if can't resolve to local. - * - * @since 1.2.0 - */ - public URL[] urlLocalizeBundle(Bundle bundle) { - URL[] pvms; - try { - pvms = new URL[] {FileLocator.resolve(bundle.getEntry("/"))}; //$NON-NLS-1$ - if (pvms[0].getProtocol().equals("jar")) { //$NON-NLS-1$ - // The bundle is a jar, so use as is. - pvms[0] = getFilePath(pvms[0]); - return pvms; - } - } catch (IOException e) { - pvms = null; - } - try { - // It is a directory. We could be in either development mode or not. Walk the manifest classpath and find the libraries. - Properties buildProps = null; - String libraries = (String) bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH); - ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, libraries); - List urls = new ArrayList(); - if (elements != null) { - for (int i = 0; i < elements.length; i++) { - try { - URL pvm = bundle.getEntry(elements[i].getValue()); - if (pvm != null) { - urls.add(FileLocator.toFileURL(pvm)); - continue; - } - } catch (IOException e) { - } - if (devMode) { - // Not found as a jar, so see if can be found in devmode. - if (buildProps == null) { - buildProps = new Properties(); - try { - URL bp = bundle.getEntry("build.properties"); //$NON-NLS-1$ - if (bp != null) { - InputStream ios = null; - try { - ios = bp.openStream(); - buildProps.load(ios); - } finally { - if (ios != null) - ios.close(); - } - } - } catch (IOException e) { - } - } - String pathString = buildProps.getProperty("output."+elements[i].getValue()); //$NON-NLS-1$ - if (pathString != null) { - try { - urls.add(FileLocator.toFileURL(bundle.getEntry(pathString))); - } catch (IOException e) { - } - } - } - } - return (URL[]) urls.toArray(new URL[urls.size()]); - } else if (devMode) { - // If dev mode then we would look in the build.properties to find the output.. entry. This tells where the binaries are - // for project. If there is no "output.." entry then either it is not a runnable plugin or the rare case is it is only - // classfiles in a folder. In that case see if there is a "source.." entry and use that. - try { - URL bp = bundle.getEntry("build.properties"); //$NON-NLS-1$ - if (bp != null) { - InputStream ios = null; - try { - ios = bp.openStream(); - Properties props = new Properties(); - props.load(ios); - String pathString = props.getProperty("output.."); //$NON-NLS-1$ - if (pathString != null) { - return new URL[] {FileLocator.resolve(bundle.getEntry(pathString))}; - } else if ((pathString = props.getProperty("source..")) != null) { //$NON-NLS-1$ - // Probably a class folder, so use the source instead. - return new URL[] {FileLocator.resolve(bundle.getEntry(pathString))}; - } else - return pvms; // Try the root of the plugin. - } finally { - if (ios != null) - ios.close(); - } - } - } catch (IOException e) { - } - - } - } catch (BundleException e) { - } - return null; - } - - /** - * Returns a url as file url if it can. If it is already a file url, it will just return it. - * If it is "jar:file:...." type protocol, then it will strip it down to the file part, which is - * the jar itself, and not the file within the jar. - * @param l - * @return - * - * @since 1.2.0 - */ - public static URL getFilePath(URL l) { - if (l != null) { - if (l.getProtocol().equals("file")) //$NON-NLS-1$ - return l; - else if (l.getProtocol().equals("jar")) { //$NON-NLS-1$ - String f = l.getFile(); - int idx = f.lastIndexOf('!'); - if (idx>=0) - f = f.substring(0,idx); - try { - return getFilePath(new URL(f)); - } catch (MalformedURLException e) {} - } - } - return null; - } - - /** - * A helper to order the plugins into pre-req order. - * If A eventually depends on B, then B will be ahead of A in the - * list of plugins. (I.e. B is a pre-req somewhere of A). - * - * @param bundlesToOrder - Bundles of interest. The results will have these in thiee correct order. - * @return An array of the Bundlers in there order from no prereqs in set to the leaves. - * - * @since 1.0.0 - */ - public static Bundle[] orderPlugins(final Set bundlesToOrder) { - Map prereqsMap = new HashMap(bundlesToOrder.size()*3); - int ndx = bundlesToOrder.size(); - Bundle[] result = new Bundle[ndx]; - Map dependents = getDependentCounts(false, bundlesToOrder, prereqsMap); // We want the inactive ones too. That way have complete order. They can be ignored later if necessary. - // keep iterating until all have been visited. This will actually find them in reverse order from what we - // want, i.e. it will find the leaves first. So we will build result array in reverse order. - while (!dependents.isEmpty()) { - // loop over the dependents list. For each entry, if there are no dependents, visit - // the bundle and remove it from the list. Make a copy of the keys so we don't end up - // with concurrent accesses (since we are deleting the values as we go) - Iterator ib = dependents.entrySet().iterator(); - while (ib.hasNext()) { - Map.Entry entry = (Map.Entry) ib.next(); - Bundle bundle = (Bundle) entry.getKey() ; - int[] count = (int[]) entry.getValue(); - if (count != null && count[0] <= 0) { - if (bundlesToOrder.contains(bundle)) { - result[--ndx] = bundle; - if (ndx == 0) - return result; // We've ordered all that we care about. Anything left over is unimportant. - } - ib.remove(); - // decrement the dependent count for all of the prerequisites. - Bundle[] requires = getPrereqs(bundle, prereqsMap); - for (int j = 0; j < requires.length; j++) { - Bundle prereq = requires[j]; - int[] countPrereq = (int[]) dependents.get(prereq); - if (countPrereq != null) - --countPrereq[0]; - } - } - } - } - return result; - } - - /** - * Get all of the prereqs for this bundle, all of the way down to the root. - * They will be in top-down depth-first order. There won't be duplicates. They will show up - * only once the first time they are found. - * - * @param bundle - * @return list of all pre-reqs. - * - * @since 1.0.0 - */ - public static List getAllPrereqs(Bundle bundle) { - List prereqs = new ArrayList(); - getAllPrereqs(bundle, prereqs, new HashMap()); - return prereqs; - } - - private static void getAllPrereqs(Bundle bundle, List prereqs, Map prereqsMap) { - Bundle[] prs = getPrereqs(bundle, prereqsMap); - for (int i = 0; i < prs.length; i++) { - Bundle pre = prs[i]; - if (prereqsMap.containsKey(pre)) - continue; // Already processed this one once. - prereqs.add(pre); // Add to the list of pre-reqs accumulated so far. - getAllPrereqs(pre, prereqs, prereqsMap); - } - } - - private static Bundle[] getPrereqs(Bundle bundle, Map prereqsMap) { - Bundle[] prereqs = (Bundle[]) prereqsMap.get(bundle); - if (prereqs == null) { - prereqs = getPrereqs(bundle); - prereqsMap.put(bundle, prereqs); - } - return prereqs; - } - - public static Bundle[] getPrereqs(Bundle bundle) { - Bundle[] l = (Bundle[]) pluginRequiredMap.get(bundle.getSymbolicName()); - if (l == null) { - BundleSpecification specs[] = Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId()).getRequiredBundles(); - ArrayList bundles = new ArrayList(specs.length); - for (int i = 0; i < specs.length; i++) { - Bundle b = Platform.getBundle(specs[i].getName()); - if (b != null) - bundles.add(b); - } - l = (Bundle[]) bundles.toArray(new Bundle[bundles.size()]); - pluginRequiredMap.put(bundle.getSymbolicName(), l); - } - return l; - } - - private static Map getDependentCounts(boolean activeOnly, Set startingSet, Map prereqsMap) { - // Try to maintain independents in order from the starting set (which happens to be ordered, and hopefully reversed.). - // Trying to have leaves show up in same order they are found in the Eclipse extensions, so we should - // have the starting set be in reverse order from that. The actual process - // builds them in reverse order from the starting set, so we expect the startingSet to be in reverse order so they will be in forward order - // hopefully. This is just a heuristic. There is no guarentee it will actually produce the - // desired output. - Map dependents = new LinkedHashMap(startingSet.size()); - // build a table of all dependent counts. The table is keyed by descriptor and - // the value the integer number of dependent plugins. - List processNow = new ArrayList(startingSet); - List processNext = new ArrayList(processNow.size()); - if (!processNow.isEmpty()) { - // Go through the first time from the starting set to get an entry into the list. - // If there is an entry, then it won't be marked for processNext. Only new entries - // are added to processNext in the following loop. - int pnSize = processNow.size(); - for (int i = 0; i < pnSize; i++) { - Bundle bundle = (Bundle) processNow.get(i); - if (activeOnly && bundle.getState() != Bundle.ACTIVE) - continue; - // ensure there is an entry for this descriptor (otherwise it will not be visited) - int[] entry = (int[]) dependents.get(bundle); - if (entry == null) - dependents.put(bundle, new int[1]); - } - } - - // Now process the processNow to find the requireds, increment them, and add to processNext if never found before. - while (!processNow.isEmpty()) { - processNext.clear(); - int pnSize = processNow.size(); - for (int i = 0; i < pnSize; i++) { - Bundle bundle = (Bundle) processNow.get(i); - if (activeOnly && bundle.getState() != Bundle.ACTIVE) - continue; - Bundle[] requires = getPrereqs(bundle, prereqsMap); - for (int j = 0; j < requires.length; j++) { - Bundle prereq = requires[j]; - if (prereq == null || activeOnly - && bundle.getState() != Bundle.ACTIVE) - continue; - int[] entry = (int[]) dependents.get(prereq); - if (entry == null) { - dependents.put(prereq, new int[]{1}); - processNext.add(prereq); // Never processed before, so we add it to the next process loop. - } else - ++entry[0]; - } - } - - // Now swap the lists so that we processNext will be now and visa-versa. - List t = processNext; - processNext = processNow; - processNow = t; - } - return dependents; - } - - /** - * Add a shutdown listener - * @param listener - * - * @since 1.0.0 - */ - public void addProxyShutdownListener(IProxyPluginShutdownListener listener) { - if (shutdownListeners == null) - shutdownListeners = new ListenerList(); - shutdownListeners.add(listener); - } - - /** - * Remove a shutdown listener - * @param listener - * - * @since 1.0.0 - */ - public void removeProxyShutdownListener(IProxyPluginShutdownListener listener) { - if (shutdownListeners != null) - shutdownListeners.remove(listener); - } - - private ILaunchConfigurationListener launchListener = new ILaunchConfigurationListener() { - public void launchConfigurationAdded(ILaunchConfiguration configuration) { - try { - if (!configuration.isWorkingCopy() && IProxyConstants.ID_PROXY_LAUNCH_GROUP.equals(configuration.getCategory())) - startCleanupJob(); - } catch (Exception e) { - } - } - - public void launchConfigurationChanged(ILaunchConfiguration configuration) { - try { - if (!configuration.isWorkingCopy() && IProxyConstants.ID_PROXY_LAUNCH_GROUP.equals(configuration.getCategory())) - startCleanupJob(); - } catch (Exception e) { - } - } - - public void launchConfigurationRemoved(ILaunchConfiguration configuration) { - try { - // On delete you can't tell the category or anything because all of that info has already removed. - if (!configuration.isWorkingCopy()) - startCleanupJob(); - } catch (Exception e) { - } - } - }; - - private Job cleanupJob = new Job(ProxyMessages.ProxyPlugin_CleanupDefaultProxyLaunchConfigurations) { - { - setSystem(true); // So it doesn't show up in progress monitor. No need to interrupt user. - setPriority(Job.SHORT); // A quick running job. - } - protected IStatus run(IProgressMonitor monitor) { - synchronized (this) { - if (monitor.isCanceled()) - return Status.CANCEL_STATUS; - } - // all we want to do is find out if any launch configurations (from proxy launch group) exist for - // a project. If they don't, then unset the project's property. If they do, and the property is not - // set, then set it to NOT_SET to indicate not set, but there are some configs for it. - // We just gather the project names that have launch configurations. - try { - Set projectNames = new HashSet(); - ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(); - for (int i = 0; i < configs.length; i++) { - if (IProxyConstants.ID_PROXY_LAUNCH_GROUP.equals(configs[i].getCategory()) - && (ProxyLaunchSupport.ATTR_PRIVATE == null || !configs[i].getAttribute(ProxyLaunchSupport.ATTR_PRIVATE, false))) - projectNames.add(configs[i].getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "")); //$NON-NLS-1$ - } - - IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); - IJavaElement[] children = model.getChildren(); - int cancelCount = 10; - for (int j = 0; j < children.length; j++) { - if (children[j].getElementType() == IJavaElement.JAVA_PROJECT) { - if (--cancelCount <= 0) - synchronized (this) { - cancelCount = 10; // Rest for next set of ten. - // Checking on every 10 projects because they may be many projects, while only few configs. - // This way it will stop sooner. - if (monitor.isCanceled()) - return Status.CANCEL_STATUS; - } - IProject p = ((IJavaProject) children[j]).getProject(); - if (projectNames.contains(p.getName())) { - // This project has a launch config. If it has a setting, then do nothing, else need to put on not set. - if (p.getPersistentProperty(ProxyPlugin.PROPERTY_LAUNCH_CONFIGURATION) == null) - p.getProject().setPersistentProperty( - ProxyPlugin.PROPERTY_LAUNCH_CONFIGURATION, - ProxyLaunchSupport.NOT_SET); - } else { - // This project has no launch configs. Remove any setting if it exists. - p.setPersistentProperty(ProxyPlugin.PROPERTY_LAUNCH_CONFIGURATION, (String) null); - } - } - } - return Status.OK_STATUS; - } catch (CoreException e) { - return e.getStatus(); - } - } - }; - - private void startCleanupJob() { - cleanupJob.cancel(); // Stop what we are doing. - cleanupJob.schedule(1000l); // Schedule to start in one second. - } - - - /* (non-Javadoc) - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) - */ - public void start(final BundleContext context) throws Exception { - super.start(context); - DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(launchListener); - context.addBundleListener(new BundleListener() { - public void bundleChanged(BundleEvent event) { - if (event.getBundle() != ProxyPlugin.this.getBundle()) - return; // Not of interest to us. - switch (event.getType()) { - case BundleEvent.STARTED: - context.removeBundleListener(this); // Since we don't care anymore - startCleanupJob(); - break; - case BundleEvent.STOPPED: - case BundleEvent.UNINSTALLED: - case BundleEvent.UNRESOLVED: - context.removeBundleListener(this); // We stopped before we started, so remove ourselves. - break; - } - } - }); - getPluginPreferences().setDefault(PREFERENCES_VM_NOVERIFY_KEY, true); - } - - - /* (non-Javadoc) - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - // Handle case where debug plugin shuts down before we do since order not guarenteed. - if (DebugPlugin.getDefault() != null) - DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(launchListener); - cleanupJob.cancel(); // Stop what we are doing. - if (shutdownListeners != null) { - Object[] listeners = shutdownListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - ((IProxyPluginShutdownListener) listeners[i]).shutdown(); - } - } - super.stop(context); - } - - public static final String PI_CONFIGURATION_CONTRIBUTION_EXTENSION_POINT = "org.eclipse.jem.proxy.contributors"; //$NON-NLS-1$ - public static final String PI_EXTENSION_REGISTRATION_EXTENSION_POINT = "org.eclipse.jem.proxy.extensions"; //$NON-NLS-1$ - public static final String PI_CONTAINER = "container"; //$NON-NLS-1$ - public static final String PI_PLUGIN = "plugin"; //$NON-NLS-1$ - public static final String PI_CLASS = "class"; //$NON-NLS-1$ - public static final String PI_REGISTRY_TYPE = "registryType"; //$NON-NLS-1$ - public static final Map pluginRequiredMap = new HashMap(50); - - /* - * Processed extension point info for contributors. - */ - protected ContributorExtensionPointInfo contributions; - - /* - * Processed extension point info for registry extensions. - */ - protected ContributorExtensionPointInfo extensions; - - - /** - * These are public only so that jem.ui can access this constant. Not meant to be accessed by others. - */ - public static final QualifiedName PROPERTY_LAUNCH_CONFIGURATION = new QualifiedName("org.eclipse.jem.proxy", "proxyLaunchConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ - - /** - * Return the plugin ordered array of configuration elements for the given container, or <code>null</code> if not contributed. - * - * @param containerid the first segment of all of the container paths is the container id. - * @param containerPaths array of container paths to match against for contributions. The paths must all be of the same container id. - * @return Array of configuration elements. - * - * @since 1.0.0 - */ - public synchronized IConfigurationElement[] getContainerConfigurations(String containerid, String[] containerPaths) { - if (contributions == null) - processProxyContributionExtensionPoint(); - return (IConfigurationElement[]) contributions.containerPathContributions.getContributors(containerid, containerPaths); - } - - /** - * Return the plugin ordered array of configuration elements for the given plugin, or <code>null</code> if not contributed. - * - * @param pluginid - * @return Array of configuration elements or <code>null</code> if this plugin has no contributions. - * - * @since 1.0.0 - */ - public synchronized IConfigurationElement[] getPluginConfigurations(String pluginid) { - if (contributions == null) - processProxyContributionExtensionPoint(); - return (IConfigurationElement[]) contributions.pluginToContributions.get(pluginid); - } - - /** - * Return the plugin ordered array of configuration elements for the given container, or <code>null</code> if not contributed. - * - * @param containerid the first segment of all of the container paths is the container id. - * @param containerPaths array of container paths to match against for contributions. The paths must all be of the same container id. - * @return Array of configuration elements. - * - * @since 1.0.0 - */ - public synchronized IConfigurationElement[] getContainerExtensions(String containerid, String[] containerPaths) { - if (extensions == null) - processProxyExtensionExtensionPoint(); - return (IConfigurationElement[]) extensions.containerPathContributions.getContributors(containerid, containerPaths); - } - - /** - * Return the plugin ordered array of configuration elements for the given plugin, or <code>null</code> if not contributed. - * - * @param pluginid - * @return Array of configuration elements or <code>null</code> if this plugin has no contributions. - * - * @since 1.0.0 - */ - public synchronized IConfigurationElement[] getPluginExtensions(String pluginid) { - if (extensions == null) - processProxyExtensionExtensionPoint(); - return (IConfigurationElement[]) extensions.pluginToContributions.get(pluginid); - } - - protected synchronized void processProxyContributionExtensionPoint() { - contributions = processContributionExtensionPoint(PI_CONFIGURATION_CONTRIBUTION_EXTENSION_POINT); - } - - protected synchronized void processProxyExtensionExtensionPoint() { - extensions = processContributionExtensionPoint(PI_EXTENSION_REGISTRATION_EXTENSION_POINT); - } - - /** - * Process the extension point looking contributors. It will find entries that have the "container" or "plugin" attributes - * set on them. - * - * @param extensionPoint fully-qualified extension point id, including plugin id of the extension point. - * @return the contributor info record. - * - * @since 1.0.0 - */ - public static ContributorExtensionPointInfo processContributionExtensionPoint(String extensionPoint) { - // We are processing this once because it is accessed often (once per vm per project). - // This can add up so we get it together once here. - IExtensionPoint extp = Platform.getExtensionRegistry().getExtensionPoint(extensionPoint); - ContributorExtensionPointInfo result = new ContributorExtensionPointInfo(); - result.containerPathContributions = new ContainerPathContributionMapping(IConfigurationElement.class); - if (extp == null) { - result.pluginToContributions = Collections.EMPTY_MAP; - return result; - } - - IExtension[] extensions = extp.getExtensions(); - if (extensions.length > 0) { - // Need to be in plugin order so that first ones processed have no dependencies on others. - // Gather in extension order. - // We want the list in reverse order of found extensions for a bundle. This is a heuristic to try - // to get leaves ordered in the order found from the extension list. Since the orderPlugins actually - // reverses the leaf order, hopefully this will set it back to what we want at the end. - HashMap bundlesToExtensions = new LinkedHashMap(extensions.length); - for (int i = extensions.length-1; i >= 0; i--) { - Bundle bundle = Platform.getBundle(extensions[i].getContributor().getName()); - IExtension[] ext = (IExtension[]) bundlesToExtensions.get(bundle); - if (ext == null) - bundlesToExtensions.put(bundle, new IExtension[] { extensions[i]}); - else { - // More than one extension defined in this plugin. - IExtension[] newExt = new IExtension[ext.length + 1]; - System.arraycopy(ext, 0, newExt, 0, ext.length); - newExt[newExt.length - 1] = extensions[i]; - bundlesToExtensions.put(bundle, newExt); - } - } - - // Now order them so we process in required order. - Bundle[] ordered = ProxyPlugin.orderPlugins(bundlesToExtensions.keySet()); - Map patternStringToID_Pattern = new HashMap(); // Map of string patterns to the {container id, compiled pattern}. This so that we use the same compiled pattern everywhere. - result.pluginToContributions = new HashMap(ordered.length); - for (int i = 0; i < ordered.length; i++) { - IExtension[] exts = (IExtension[]) bundlesToExtensions.get(ordered[i]); - for (int j = 0; j < exts.length; j++) { - IConfigurationElement[] configs = exts[j].getConfigurationElements(); - // Technically we expect the config elements to have a name of "contributor", but since that - // is all that can be there, we will ignore it. The content is what is important. - for (int k = 0; k < configs.length; k++) { - String containerPattern = configs[k].getAttribute(PI_CONTAINER); - if (containerPattern != null) { - Object[] id_Pattern = (Object[]) patternStringToID_Pattern.get(containerPattern); - if (id_Pattern == null) { - int slash = containerPattern.indexOf('/'); - String containerID = slash != -1 ? containerPattern.substring(0, slash) : containerPattern; - // The pattern becomes for the containerPattern "SWT_CONTAINER" becomes "SWT_CONTAINER(/.*)*". This - // means to match the string must start with "SWT_CONTAINER" and it must have either nothing after this - // or it must have a "/" and any characters after that. So this means it will not match "SWT_CONTAINERXZ" - // but it will match "SWT_CONTAINER/XYZ". - id_Pattern = new Object[] { containerID, Pattern.compile(containerPattern + "(/.*)*")}; //$NON-NLS-1$ - patternStringToID_Pattern.put(containerPattern, id_Pattern); - } - result.containerPathContributions.addContribution((String) id_Pattern[0], (Pattern) id_Pattern[1], configs[k]); - } - - String plugin = configs[k].getAttribute(PI_PLUGIN); - if (plugin != null) { - List contributions = (List) result.pluginToContributions.get(plugin); - if (contributions == null) { - contributions = new ArrayList(1); - result.pluginToContributions.put(plugin, contributions); - } - contributions.add(configs[k]); - } - } - } - } - - // Finalize the mappings for both container paths and plugins. - result.containerPathContributions.finalizeMapping(); - for (Iterator iter = result.pluginToContributions.entrySet().iterator(); iter.hasNext();) { - Map.Entry entry = (Map.Entry) iter.next(); - entry.setValue(((List) entry.getValue()).toArray(new IConfigurationElement[((List) entry.getValue()).size()])); - } - } else - result.pluginToContributions = Collections.EMPTY_MAP; - return result; - } - - /** - * The result of the {@link ProxyPlugin#getIDsFound(IJavaProject)}. - * - * @since 1.2.0 - */ - public static class FoundIDs { - - /** - * Map of (containerIds(String)->{@link ContainerPaths}) of containers classpaths found in the project's classpath. - * - */ - public Map containerIds = new HashMap(2); - - /** - * Map of (containers({@link IClasspathContainer})->Boolean) of containers found in the project's classpath. The value will be <code>true</code> if the container is visible to the top-level project. - */ - public Map containers = new HashMap(2); - - /** - * Map of (pluginIds(String)->Boolean) of plugin ids found in the project's classpath if the project is a plugin project. The value will be <code>true</code> if the plugin is visible to the top-level project. - */ - public Map pluginIds; - - /** - * Map of (projects({@link IPath}->Boolean) of project found in the project's classpath. The value will be <code>true</code> if the project is visible to the top-level project. - */ - public Map projects = new HashMap(2); - - FoundIDs() { - // not meant to be instantiated or subclassed by clients. - } - } - - /** - * For the given java project, return the maps of found ids. - * - * @param jproject - * @return the found ids. - * - * @since 1.0.0 - */ - public FoundIDs getIDsFound(IJavaProject jproject) throws JavaModelException { - IPath projectPath = jproject.getProject().getFullPath(); - FoundIDs foundIDs = new FoundIDs(); - foundIDs.projects.put(projectPath, Boolean.TRUE); - expandProject(projectPath, foundIDs, true, true); - - // The containerIds values will actually be an Map[] {Map(visibleIPath->pathString), Map(hiddenIPath->pathString)}. Needs to be converted to a ContainerPaths now - // that we are done. - for (Iterator itr = foundIDs.containerIds.entrySet().iterator(); itr.hasNext();) { - Map.Entry entry = (Entry) itr.next(); - Map[] value = (Map[]) entry.getValue(); - entry.setValue(new ContainerPaths((String) entry.getKey(), (String[]) value[0].values().toArray(new String[value[0].size()]), (String[]) value[1].values().toArray(new String[value[1].size()]))); - } - - if (foundIDs.pluginIds == null) - foundIDs.pluginIds = Collections.EMPTY_MAP; - - foundIDs.projects.remove(projectPath); // Don't need to include itself now, was needed for testing so if ciruclar we don't get into a loop. - if (foundIDs.projects.isEmpty()) - foundIDs.projects = Collections.EMPTY_MAP; - - return foundIDs; - - } - - private static final IPath JRE_CONTAINER_PATH = new Path(JavaRuntime.JRE_CONTAINER); - - /* - * The passed in visible flag tells if this project is visible and its contents are visible if they are exported. - * Only exception is if first is true, then all contents are visible to the top level project. - */ - private void expandProject(IPath projectPath, FoundIDs foundIds, boolean visible, boolean first) throws JavaModelException { - IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(projectPath.lastSegment()); - if (res == null) - return; // Not exist so don't delve into it. - IJavaProject project = (IJavaProject)JavaCore.create(res); - if (project == null || !project.exists() || !project.getProject().isOpen()) - return; // Not exist as a java project or not open, so don't delve into it. - - IClasspathEntry[] entries = project.getRawClasspath(); - for (int i = 0; i < entries.length; i++) { - IClasspathEntry entry = entries[i]; - Boolean currentFlag = null; // Current setting value. - boolean newFlag; // The new setting value. - switch (entry.getEntryKind()) { - case IClasspathEntry.CPE_PROJECT: - // Force true if already true, or this is the first project, or this project is visible and the entry is exported. These override a previous false. - currentFlag = (Boolean) foundIds.projects.get(entry.getPath()); - newFlag = (currentFlag != null && currentFlag.booleanValue()) || first || (visible && entry.isExported()); - if (currentFlag == null || currentFlag.booleanValue() != newFlag) - foundIds.projects.put(entry.getPath(), newFlag ? Boolean.TRUE : Boolean.FALSE ); - if (currentFlag == null) - expandProject(entry.getPath(), foundIds, visible && entry.isExported(), false); - break; - case IClasspathEntry.CPE_CONTAINER: - if (!first && JavaRuntime.JRE_CONTAINER.equals(entry.getPath().segment(0))) //$NON-NLS-1$ - break; // The first project determines the JRE, so any subsequent ones can be ignored. - Map[] paths = (Map[]) foundIds.containerIds.get(entry.getPath().segment(0)); - if (paths == null) { - paths = new Map[] {new HashMap(2), new HashMap(2)}; - foundIds.containerIds.put(entry.getPath().segment(0), paths); - } - currentFlag = null; - if (paths[0].containsKey(entry.getPath())) - currentFlag = Boolean.TRUE; - else if (paths[1].containsKey(entry.getPath())) - currentFlag = Boolean.FALSE; - newFlag = (currentFlag != null && currentFlag.booleanValue()) || first || (visible && entry.isExported()); - if (currentFlag == null || currentFlag.booleanValue() != newFlag) { - if (newFlag) { - // It is visible, remove from hidden, if there, and add to visible. - paths[1].remove(entry.getPath()); - paths[0].put(entry.getPath(), entry.getPath().toString()); - } else { - // It is hidden, remove from visible, if there, and add to hidden. - paths[0].remove(entry.getPath()); - paths[1].put(entry.getPath(), entry.getPath().toString()); - } - } - - IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project); - // Force true if already true, or this is the first project, or this project is visible and the entry is exported. These override a previous false. - currentFlag = (Boolean) foundIds.containers.get(container); - newFlag = (currentFlag != null && currentFlag.booleanValue()) || first || (visible && entry.isExported()); - if (currentFlag == null || currentFlag.booleanValue() != newFlag) - foundIds.containers.put(container, newFlag ? Boolean.TRUE : Boolean.FALSE ); - break; - case IClasspathEntry.CPE_VARIABLE: - // We only care about JRE_LIB. If we have that, then we will treat it as JRE_CONTAINER. Only - // care about first project too, because the first project is the one that determines the JRE type. - if (first && JavaRuntime.JRELIB_VARIABLE.equals(entry.getPath().segment(0))) { //$NON-NLS-1$ - paths = (Map[]) foundIds.containerIds.get(JavaRuntime.JRE_CONTAINER); - if (paths == null) { - paths = new Map[] {new HashMap(2), new HashMap(2)}; - foundIds.containerIds.put(JavaRuntime.JRE_CONTAINER, paths); - } - currentFlag = null; - if (paths[0].containsKey(JRE_CONTAINER_PATH)) - currentFlag = Boolean.TRUE; - else if (paths[1].containsKey(JRE_CONTAINER_PATH)) - currentFlag = Boolean.FALSE; - newFlag = (currentFlag != null && currentFlag.booleanValue()) || first || (visible && entry.isExported()); - if (currentFlag == null || currentFlag.booleanValue() != newFlag) { - if (newFlag) { - // It is visible, remove from hidden, if there, and add to visible. - paths[1].remove(JRE_CONTAINER_PATH); - paths[0].put(JRE_CONTAINER_PATH, JavaRuntime.JRE_CONTAINER); - } else { - // It is hidden, remove from visible, if there, and add to hidden. - paths[0].remove(JRE_CONTAINER_PATH); - paths[1].put(JRE_CONTAINER_PATH, JavaRuntime.JRE_CONTAINER); - } - } - } - break; - default: - break; - } - } - - findPlugins(foundIds, visible, first, project); - } - - /** - * Find the plugins that the given project references, either directly or indirectly. - * <p> - * The map will be of plugin ids to a Boolean. If the boolean is <code>BooleanTRUE</code>, - * then the plugin is visible to the given project. the visible and first flags - * will modify this. If first is true, then all direct plugins will be visible, - * else only exported plugins will be visible. If visible is false and first is false, then it doesn't matter, all of the - * plugins will not be visible. - * <p> - * Visible means that classes in the plugin can be referenced directly from code. Not visible - * means that they can only be referenced from some other plugin in the list. In other words, - * visible ones can be directly referenced, but invisible ones can only be referenced from - * plugins that can see it. - * <p> - * For most uses, first and visible should be true. Then it will treat the project as the toplevel - * project and will return true for those that are visible to it, either directly or indirectly. - * These flags were added for more special cases where may be calling on a project that is deeper - * down in the classpath were visibilty has already been decided. - * <p> - * Note: PDE must be installed for this to return anything, otherwise it will leave - * the map alone. - * - * @param foundIds foundIds structure to get plugin info from. - * @param visible <code>true</code> means this project is visible, so any plugins visible to it will be visible, else none will be visible. - * @param first <code>true</code> if this is the top project of interest. This means that all plugins within the project are visible. Else only exported projects will be visible. - * @param project project to start looking from - * - * @since 1.0.2 - */ - public void findPlugins(FoundIDs foundIds, boolean visible, boolean first, IJavaProject project) { - try { - // To prevent unnecessary loading of the PDE plugin, find the plugins only if this project is a PDE plugin project. - if (isPDEProject(project)) { - IPDEProcessForPlugin pdeprocess = getPDEProcessForPlugin(); - if (pdeprocess != null) { - if (foundIds.pluginIds == null) - foundIds.pluginIds = new HashMap(); - pdeprocess.findPlugins(project, foundIds, visible, first); // expand the plugins for this project, if any. - } - } - } catch (CoreException e) { - } - } - - /** - * - * @param project - * - * @return true if this is a Plugin project or false if not - * @throws CoreException - * - * @since 1.1.0 - */ - public static boolean isPDEProject(IJavaProject project) throws CoreException { - return project.getProject().hasNature(PDE_NATURE_ID); - } - - - /* - * Interface for processing Plugins. Used when PDE plugin is present in the installation. - * - * @since 1.0.2 - */ - interface IPDEProcessForPlugin { - - /* - * Go through the project and find all of the plugins it references, either directly or through - * the referenced plugins, and mark them as visible or not. - */ - public abstract void findPlugins(IJavaProject project, FoundIDs foundIds, boolean visible, boolean first); - } - - /* - * Try to get the pde process for plugin. If already tried once and not found, then forget it. - * <package-protected> because PDEContributeClasspath needs it too. - */ - private IPDEProcessForPlugin pdeProcessForPlugin; - private boolean triedPDEProcess; - IPDEProcessForPlugin getPDEProcessForPlugin() { - if (!triedPDEProcess) { - triedPDEProcess = true; - if (Platform.getBundle("org.eclipse.pde.core") != null) { //$NON-NLS-1$ - try { - Class classPDEProcess = Class.forName("org.eclipse.jem.internal.proxy.core.PDEProcessForPlugin"); //$NON-NLS-1$ - pdeProcessForPlugin = (IPDEProcessForPlugin) classPDEProcess.newInstance(); - } catch (ClassNotFoundException e) { - // Not found, do nothing. - } catch (InstantiationException e) { - getLogger().log(e, Level.WARNING); - } catch (IllegalAccessException e) { - getLogger().log(e, Level.WARNING); - } - } - } - return pdeProcessForPlugin; - } - - /** - * This tries to find a jar in the bundle specified, and the attached source using the - * PDE source location extension point. The jar must exist for source to be attachable. - * The source must be in the standard PDE source plugin. I.e. it must be in a directory - * of the name "bundlename_bundleversion", and in the same path from there as in the - * jar, plus the name must be "jarnamesrc.zip". - * <p> - * The returned URL's will not be Platform.resolve(). They will be in form returned from - * Platform.find(). - * - * @param bundle bundle to search, will search fragments too. - * @param filepath filepath from the root of the bundle/fragment where the jar will be found. - * @return two URL's. [0] is the URL to the jar, <code>null</code> if not found, [2] is the URL to the source zip, <code>null</code> if not found. - * - * @since 1.0.0 - */ - public URL[] findPluginJarAndAttachedSource(Bundle bundle, IPath filepath) { - // This is a bit kludgy, but the algorithm is to find the file first, and then get the root url of the bundle/fragment - // that matches the found file. This will be used to calculate the name of the directory under the source. From there - // all of the source extensions will be searched for the source zip file. - // This is assuming that find returns a url where the file part of the url is a standard path and doesn't have - // things like special chars to indicate within a jar. That would appear when it is resolved, but I think that the - // unresolved ones from find are typically "jarbundle://nnn/path" or something like that. This is a gray area. - URL jarURL = FileLocator.find(bundle, filepath, null); - if (jarURL == null) - return new URL[2]; - - // Found it, so let's try to find which bundle/fragment it was found in. - String jarString = jarURL.toExternalForm(); - // First the bundle itself. - String installLoc = bundle.getEntry("/").toExternalForm(); //$NON-NLS-1$ - URL sourceURL = null; - if (jarString.startsWith(installLoc)) - sourceURL = getSrcFrom(bundle, installLoc, jarString); - else { - // Now look in the fragments. - Bundle[] frags = Platform.getFragments(bundle); - for (int i = 0; i < frags.length; i++) { - installLoc = frags[i].getEntry("/").toExternalForm(); //$NON-NLS-1$ - if (jarString.startsWith(installLoc)) { - sourceURL = getSrcFrom(frags[i], installLoc, jarString); - break; - } - } - } - return new URL[] {jarURL, sourceURL}; - } - - private URL getSrcFrom(Bundle bundle, String installLoc, String jarString) { - // format of path in a PDE source plugin is (under the "src" directory from the extension point), - // "bundlename_bundleversion/pathOfJar/jarnamesrc.zip". However there is no way to know - // which extension has the source in it, so we need to search them all. - - IPath srcPath = new Path(bundle.getSymbolicName()+"_"+ (String) bundle.getHeaders("").get(Constants.BUNDLE_VERSION)); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$ - srcPath = srcPath.append(new Path(jarString.substring(installLoc.length()))); - if (srcPath.segmentCount() < 2) - return null; // Something is not right. No jar name. - srcPath = srcPath.removeFileExtension(); // Remove the .jar. - String jarName = srcPath.lastSegment(); // This should be the jar name. - srcPath = srcPath.removeLastSegments(1).append(jarName+"src.zip"); //$NON-NLS-1$ - - // Now look through all of the src extensions. Can't tell if the extension is from a fragment or a bundle, so we need to - // use Platform.find() to look in the bundle and fragment. So we may get a dup search if there is a fragment source - // (for example platform source and win32 platform source (which is a fragment of platform source). - IConfigurationElement[] ces = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.pde.core.source"); //$NON-NLS-1$ - for (int i = 0; i < ces.length; i++) { - IPath srcsrch = new Path(ces[i].getAttribute("path")).append(srcPath); //$NON-NLS-1$ - Bundle srcBundle = Platform.getBundle(ces[i].getDeclaringExtension().getContributor().getName()); - URL srcUrl = FileLocator.find(srcBundle, srcsrch, null); - if (srcUrl != null) { - return srcUrl; - } - } - return null; - } -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ThrowableProxy.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ThrowableProxy.java deleted file mode 100644 index 94ce4b434..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ThrowableProxy.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jem.internal.proxy.core; -/* - - - */ - - -/** - * This is a proxy wrapper for an exception being thrown on the - * remove VM. The standard exception methods refer to this proxy. - * To refer to the proxied exception itself, the methods defined - * in here would be used. - */ -public abstract class ThrowableProxy extends java.lang.Exception implements IBeanProxy { - /** - * Constructs an <code>Exception</code> with no specified detail message. - */ - public ThrowableProxy() { - super(); - } - - /** - * @param message - * @param cause - * - * @since 1.1.0 - */ - protected ThrowableProxy(String message, Throwable cause) { - super(message, cause); - } - /** - * @param cause - * - * @since 1.1.0 - */ - protected ThrowableProxy(Throwable cause) { - super(cause); - } - /** - * Constructs an <code>Exception</code> with the specified detail message. - * - * @param s the detail message. - */ - public ThrowableProxy(String s) { - super(s); - } - - - public abstract String getProxyLocalizedMessage(); - public abstract String getProxyMessage(); - public abstract void printProxyStackTrace(java.io.PrintWriter writer); - public abstract void printProxyStackTrace(java.io.PrintStream stream); - public abstract void printProxyStackTrace(); - - public String toString() { - return super.toString() + "Proxy: " + toBeanString(); //$NON-NLS1$ - toString's aren't nls'ed. //$NON-NLS-1$ - } -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/UIRunner.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/UIRunner.java deleted file mode 100644 index 06fdbf173..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/UIRunner.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - - - */ -package org.eclipse.jem.internal.proxy.core; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Level; - -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; - - -/** - * The actual implementation of IUIRunner to run the build under - * IProgressService control if in the UI thread. - * - * <package-protected> because should only be used within here. - * - * @since 1.0.0 - */ -class UIRunner implements IUIRunner { - - /* - * Special class that takes a progress monitor 1 and only handles isCanceled from it, - * but everything else is forwarded to progress monitor 2. This allows the pm that - * is sent into handleBuild to signal a cancel even though the progress service - * sends in its own pm. - * - * @since 1.0.0 - */ - private static class UIRunnerProgressMonitor extends ProgressMonitorWrapper { - private IProgressMonitor pmcancel; - - public UIRunnerProgressMonitor(IProgressMonitor pmcancel, IProgressMonitor pmmain) { - super(pmmain); - this.pmcancel = pmcancel; - } - - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled() - */ - public boolean isCanceled() { - return pmcancel.isCanceled() || super.isCanceled(); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean) - */ - public void setCanceled(boolean value) { - super.setCanceled(value); - pmcancel.setCanceled(value); // Cancel it too now. - } - } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IUIRunner#handleBuild(org.eclipse.core.runtime.IProgressMonitor) - */ - public void handleBuild(final IProgressMonitor pm) throws CoreException { - if (!PlatformUI.isWorkbenchRunning() || Display.getCurrent() == null) { - ProxyLaunchSupport.runBuild(pm); - } else { - pm.beginTask("", 100); //$NON-NLS-1$ - try { - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - IProgressMonitor uipm = new UIRunnerProgressMonitor(pm, monitor); - try { - ProxyLaunchSupport.runBuild(uipm); - } catch (CoreException e) { - throw new InvocationTargetException(e); - } - if (uipm.isCanceled()) { - pm.setCanceled(true); // Make sure that cancel got through (could of come from monitor instead). - throw new InterruptedException(); - } - } - }); - } catch (InvocationTargetException e) { - if (e.getCause() instanceof CoreException) - throw (CoreException) e.getCause(); - ProxyPlugin.getPlugin().getLogger().log(e.getCause(), Level.WARNING); - } catch (InterruptedException e) { - // It was canceled, launch will be canceled too. pm is already marked canceled and caller can check that - } - pm.done(); - } - } -} diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/messages.properties b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/messages.properties deleted file mode 100644 index e6e08c398..000000000 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/messages.properties +++ /dev/null @@ -1,49 +0,0 @@ -############################################################################### -# Copyright (c) 2003, 2005 IBM Corporation 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: -# IBM Corporation - initial API and implementation -############################################################################### -# -# $Source: /cvsroot/webtools/jeetools.move/webtools.javaee.git/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/messages.properties,v $ -# $Revision: 1.12 $ $Date: 2005/08/24 20:39:05 $ -# - - - -# -# Exception Messages. All of these messages are the text of an java exception. -# -UnexpectedException_EXC_ = IWAV0064E Unexpected exception thrown. - -# {0} and {1} are java classes (e.g. java.lang.Object) -ClassCast_EXC__IncorrectType = IWAV0065E "{0}" is neither a subclass of, nor does it implement, class "{1}". - -# Standard Bean Proxy Factory and Standard Bean Type Proxy Factory are terms in beaninfo. They are the -# standard (i.e. base) factories for beans or bean types. Bean types are java classes. -ProxyFactory_EXC__NoBeanProxyFactory = IWAV0066E No Standard Bean Proxy Factory has been set. -ProxyFactory_EXC__NoBeanTypeProxyFactory = IWAV0067E No Standard Bean Type Proxy Factory has been set. - - -# {0} is the title of a project. -Not_Java_Project_WARN_ = IWAV0068W Project "{0}" is not a java project. -No_VM_WARN_ = IWAV0069W Project "{0}" has no Java JRE defined to use to run programs within this project. -No_Implementation_WARN_ = IWAV0070W Cannot find a proxy implementation to use for project "{0}." - -ProxyLaunch = Launching Local Proxy VM -ProxyWaitForBuild = Waiting for build to complete -Expression_InInvalidStateDueTo_EXC_ = IWAV0162E Expression is in invalid state due to "{0}" -Expression_InInvalidState_EXC_ = IWAV0163E Expression is in invalid state -Expression_TypeSentInInvalidOrder_EXC_ = IWAV0164E Expression type sent in invalid order, received: {0}, expected {1}. -Expression_ArrayTypeNotAnArray_EXC_ = IWAV0165E ArrayType "{0}" is not an array. -Expression_CannotHandleNoReceiveOnFieldAccess_EXC_ = IWAV0166E Access by field name ({0}) (not by proxy) requires a receiver. -Expression_MethodsNeedReceiver_EXC_ = IWAV0167E Access by method name ({0}) (not by proxy) requires a receiver. -Expression_InvalidMarkNesting = IWAV0168E Improper nesting of mark statements in Expression. Tried to pop or endMark to before current mark. Tried to go past Mark# {0}. -Expression_InvalidProxy=Expression Proxy is for a different expression -ProxyPlugin_CleanupDefaultProxyLaunchConfigurations = Clean up default proxy launch configurations. -ProxyLaunchSupport_RegistryCouldNotStartForSomeReason_WARN_ = IWAV0168W Registry could not be started for some reason. -Expression_CreateProxyReassignmentExpression_InvalidForReassignment_EXC_=Invalid expression type for reassignment: {0} |