Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
AspectJ tools most notably contains the AspectJ compiler (AJC). AJC applies aspects to Java classes during
compilation, fully replacing Javac for plain Java classes and also compiling native AspectJ or annotation-based
@AspectJ syntax. Furthermore, AJC can weave aspects into existing class files in a post-compile binary weaving step.
This library is a superset of AspectJ weaver and hence also of AspectJ runtime.
/*******************************************************************************
* Copyright (c) 2004, 2007 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
* Sebastian Davids - fix for the bug 178028 (removals not propagated to handlers)
*******************************************************************************/
package org.eclipse.core.runtime.dynamichelpers;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.internal.registry.RegistryMessages;
import org.eclipse.core.internal.runtime.ReferenceHashSet;
import org.eclipse.core.internal.runtime.RuntimeLog;
import org.eclipse.core.runtime.*;
/**
* Implementation of the IExtensionTracker.
*
* This class can be used without OSGi running.
*
* @see org.eclipse.core.runtime.dynamichelpers.IExtensionTracker
* @since 3.1
*/
public class ExtensionTracker implements IExtensionTracker, IRegistryChangeListener {
//Map keeping the association between extensions and a set of objects. Key: IExtension, value: ReferenceHashSet.
private Map> extensionToObjects = new HashMap<>();
private ListenerList handlers = new ListenerList<>();
private final Object lock = new Object();
private boolean closed = false;
private final IExtensionRegistry registry; // the registry that this tacker works with
private static final Object[] EMPTY_ARRAY = new Object[0];
/**
* Construct a new instance of the extension tracker.
*/
public ExtensionTracker() {
this(RegistryFactory.getRegistry());
}
/**
* Construct a new instance of the extension tracker using the given registry
* containing tracked extensions and extension points.
*
* @param theRegistry the extension registry to track
* @since org.eclipse.equinox.registry 3.2
*/
public ExtensionTracker(IExtensionRegistry theRegistry) {
registry = theRegistry;
if (registry != null)
registry.addRegistryChangeListener(this);
else
RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.registry_no_default, null));
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.dynamichelpers.IExtensionTracker#registerHandler(org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler, org.eclipse.core.runtime.dynamichelpers.IFilter)
*/
@Override
public void registerHandler(IExtensionChangeHandler handler, IFilter filter) {
synchronized (lock) {
if (closed)
return;
// TODO need to store the filter with the handler
handlers.add(new HandlerWrapper(handler, filter));
}
}
/* (non-Javadoc)
* @see IExtensionTracker@unregisterHandler(IExtensionChangeHandler)
*/
@Override
public void unregisterHandler(IExtensionChangeHandler handler) {
synchronized (lock) {
if (closed)
return;
handlers.remove(new HandlerWrapper(handler, null));
}
}
/* (non-Javadoc)
* @see IExtensionTracker@registerObject(IExtension, Object, int)
*/
@Override
public void registerObject(IExtension element, Object object, int referenceType) {
if (element == null || object == null)
return;
synchronized (lock) {
if (closed)
return;
ReferenceHashSet