class BundleClassesFinder {

	Set<Class<?>> readOsgiServicesForClass(Class<?> clazz) {
		Set<Class<?>> osgiClasses = new HashSet<Class<?>>();
		Field[] fields = clazz.getDeclaredFields();
		for (Field field : fields) {
			if (field.isAnnotationPresent(OsgiService.class)) {
				Class<?> fieldClass = field.getType();
				osgiClasses.add(fieldClass);
			}
		}

		Constructor<?>[] constructors = clazz.getConstructors();
		for (Constructor<?> constructor : constructors) {
			Class<?>[] parameterTypes = constructor.getParameterTypes();
			Annotation[][] annotations = constructor.getParameterAnnotations();
			int j = 0;
			/**
			 * parameterTypes of constructor of inner classes contain types of parent classes in front of
			 * the array.
			 */
			for (int i = (parameterTypes.length - annotations.length); i < parameterTypes.length; i++) {
				for (Annotation annotation : annotations[j]) {
					if (annotation.annotationType().equals(OsgiService.class)) {
						osgiClasses.add(parameterTypes[i]);
						break;
					}
				}
				j++;
			}
		}
		return osgiClasses;
	}

	public  BundleClassesFinder(String basePackage);

}