@@ -0,0 +1,1321 @@
+package org.springframework.roo.support.osgi;%0A%0Aimport java.net.URL;%0A%0Aimport org.osgi.framework.Bundle;%0Aimport org.osgi.framework.BundleContext;%0Aimport org.springframework.roo.support.util.Assert;%0A%0A/**%0A * Helper to locate bundle symbolic names used by Spring Roo.%0A * %0A * @author Ben Alex%0A * @since 1.1.1%0A *%0A */%0Apublic abstract class BundleFindingUtils %7B%0A%09%0A%09/**%0A%09 * Locates the first bundle that contains the presented type name.%0A%09 * %0A%09 * @param context that can be used to obtain bundles to search (required)%0A%09 * @param typeNameInExternalForm a type name (eg com.foo.Bar)%0A%09 * @return the bundle symbolic name, if found (or null if not found)%0A%09 */%0A%09public static String findFirstBundleForTypeName(BundleContext context, String typeNameInExternalForm) %7B%0A%09%09Assert.notNull(context, %22Bundle context required to perform the search%22);%0A%09%09Assert.hasText(typeNameInExternalForm, %22Resource name to locate is required%22);%0A%09%09String resourceName = %22/%22 + typeNameInExternalForm.replace('.', '/') + %22.class%22;%0A%0A%09%09Bundle%5B%5D bundles = context.getBundles();%0A%09%09if (bundles == null) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%09%09%0A%09%09for (Bundle bundle : bundles) %7B%0A%09%09%09try %7B%0A%09%09%09%09URL url = bundle.getEntry(resourceName);%0A%09%09%09%09if (url != null) %7B%0A%09%09%09%09%09return bundle.getSymbolicName();%0A%09%09%09%09%7D%0A%09%09%09%7D catch (RuntimeException e) %7B%0A%09%09%09%09return null;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09return null;%0A%09%7D%0A%7D%0A

Create BundleFindingUtils class so the bundle symbolic name a given class belongs to can be easily located