| /********************************************************************* |
| * Copyright (c) 2009, 2012 SpringSource, a division of VMware, Inc. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| **********************************************************************/ |
| |
| package org.eclipse.virgo.ide.jdt.internal.core.classpath; |
| |
| import java.util.Arrays; |
| import java.util.Set; |
| |
| import org.eclipse.core.resources.IProject; |
| import org.eclipse.core.resources.ResourcesPlugin; |
| import org.eclipse.jdt.core.IJavaProject; |
| import org.eclipse.jdt.core.JavaCore; |
| import org.eclipse.virgo.ide.facet.core.FacetUtils; |
| import org.eclipse.virgo.ide.manifest.core.IBundleManifestChangeListener; |
| import org.eclipse.virgo.ide.manifest.internal.core.BundleManifestManager; |
| import org.eclipse.virgo.ide.runtime.core.ServerUtils; |
| import org.eclipse.virgo.ide.runtime.core.provisioning.IBundleRepositoryChangeListener; |
| import org.eclipse.virgo.kernel.repository.BundleRepository; |
| import org.eclipse.virgo.util.osgi.manifest.BundleManifest; |
| import org.eclipse.wst.server.core.IRuntime; |
| |
| /** |
| * {@link IBundleManifestChangeListener} that triggers refreshing of the bundle class path container through scheduling |
| * a new workspace job. |
| * |
| * @author Christian Dupuis |
| * @since 1.0.0 |
| */ |
| public class ServerClasspathContainerBundleManifestChangeListener implements IBundleManifestChangeListener, IBundleRepositoryChangeListener { |
| |
| /** |
| * Gets notified for every change to a given <code>bundleManifest</code> and delegates the refreshment of the class |
| * path container to the {@link ServerClasspathContainerUpdateJob}. |
| */ |
| public void bundleManifestChanged(BundleManifest newBundleManifest, BundleManifest oldBundleManifest, BundleManifest newTestBundleManifest, |
| BundleManifest oldTestBundleManifest, Set<Type> types, IJavaProject javaProject) { |
| if (newBundleManifest != null || newTestBundleManifest != null) { |
| ServerClasspathContainerUpdateJob.scheduleClasspathContainerUpdateJob(javaProject, types); |
| } |
| } |
| |
| /** |
| * Gets notified for every change of the given <code>runtime</code>'s {@link BundleRepository}. On every |
| * notification it will update <i>all</i> bundle project's {@link BundleManifest}. |
| */ |
| public void bundleRepositoryChanged(IRuntime runtime) { |
| for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { |
| if (FacetUtils.isBundleProject(project) && Arrays.asList(ServerUtils.getTargettedRuntimes(project)).contains(runtime)) { |
| ServerClasspathContainerUpdateJob.scheduleClasspathContainerUpdateJob(JavaCore.create(project), |
| BundleManifestManager.IMPORTS_CHANGED); |
| } |
| } |
| } |
| |
| } |