org.eclipse.core.internal.preferences.BundleStateScope Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aspectjtools Show documentation
Show all versions of aspectjtools Show documentation
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) 2022 Christoph Läubrich 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:
* Christoph Läubrich - initial API and implementation
*******************************************************************************/
package org.eclipse.core.internal.preferences;
import org.eclipse.core.internal.runtime.MetaDataKeeper;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.preferences.*;
import org.osgi.framework.Bundle;
/**
* The Bundle State Scope supply bundles with two items:
*
* - {@link #getNode(String)} returns a node for the bundle workspace
* preferences
* - {@link #getLocation()} returns the state location of the bundle that
* acquires the service
*
* The service could be acquired for example with declarative services the
* following way:
*
*
* @Reference(target = "(type=bundle)")
* private IScopeContext scopeContext;
*
*/
public class BundleStateScope implements IScopeContext {
private IPath bundleLocation;
private final Bundle usingBundle;
public BundleStateScope(Bundle usingBundle) {
this.usingBundle = usingBundle;
}
@Override
public String getName() {
return InstanceScope.INSTANCE.getName() + "/" + usingBundle.getSymbolicName(); //$NON-NLS-1$
}
@Override
public IEclipsePreferences getNode(String qualifier) {
return (IEclipsePreferences) InstanceScope.INSTANCE.getNode(usingBundle.getSymbolicName()).node(qualifier);
}
@Override
public synchronized IPath getLocation() {
if (bundleLocation == null) {
bundleLocation = MetaDataKeeper.getMetaArea().getStateLocation(usingBundle);
bundleLocation.toFile().mkdirs();
}
return bundleLocation;
}
}