All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.equinox.internal.region.SubgraphTraverser Maven / Gradle / Ivy

Go to download

Provides the concept of a region used to isolate bundles according to the configured sharing policy, which is applied across the framework using the OSGi hook APIs.

The newest version!
/*******************************************************************************
 * Copyright (c) 2011 VMware Inc.
 * 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:
 *    SpringSource, a division of VMware - initial API and implementation and/or initial documentation
 *******************************************************************************/

package org.eclipse.equinox.internal.region;

import org.eclipse.equinox.region.Region;
import org.eclipse.equinox.region.RegionDigraphVisitor;
import org.eclipse.equinox.region.RegionDigraph.FilteredRegion;

import java.util.HashSet;
import java.util.Set;

/**
 * {@link SubgraphTraverser} is a utility for traversing a subgraph of a {@link RegionDigraph} calling a
 * {@link RegionDigraphVisitor} on the way.
 * 

* * Concurrent Semantics
* Thread safe. */ final class SubgraphTraverser { void visitSubgraph(Region startingRegion, RegionDigraphVisitor visitor) { visitRemainingSubgraph(startingRegion, visitor, new HashSet()); } private void visitRemainingSubgraph(Region r, RegionDigraphVisitor visitor, Set path) { if (!path.contains(r)) { if (visitor.visit(r)) { traverseEdges(r, visitor, path); } } } private void traverseEdges(Region r, RegionDigraphVisitor visitor, Set path) { for (FilteredRegion fr : r.getEdges()) { if (visitor.preEdgeTraverse(fr.getFilter())) { try { visitRemainingSubgraph(fr.getRegion(), visitor, extendPath(r, path)); } finally { visitor.postEdgeTraverse(fr.getFilter()); } } } } private Set extendPath(Region r, Set path) { Set newPath = new HashSet(path); newPath.add(r); return newPath; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy