private boolean incompatibleClassSpace()

in jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java [134:172]


	private boolean incompatibleClassSpace(Bundle bundle) {
		BundleWiring pbWiring = bundle.adapt(BundleWiring.class);
		
		BundleCapability pbContract = getUsedCapability(pbWiring, OSGI_CONTRACT_NS, JAVA_JPA_CONTRACT);
		
		if(pbContract != null) {
			LOGGER.debug("Matching JPA contract for possible persistence bundle {}", bundle.getSymbolicName());
			
			BundleCapability implContract = getUsedCapability(pbWiring, OSGI_CONTRACT_NS, JAVA_JPA_CONTRACT);
			return !pbContract.equals(implContract);
		}
		
		// No contract required by the persistence bundle, try javax.persistence
		BundleCapability pbJavaxPersistence = getUsedCapability(pbWiring, 
					OSGI_PACKAGE_NS, JAVAX_PERSISTENCE_PKG);
			
		if(pbJavaxPersistence != null) {
			LOGGER.debug("Matching JPA API package for possible persistence bundle {}", bundle.getSymbolicName());
			
			BundleCapability implJavaxPersistence = getUsedCapability(pbWiring, 
					OSGI_PACKAGE_NS, JAVAX_PERSISTENCE_PKG);
			return !pbJavaxPersistence.equals(implJavaxPersistence);
		}

		// No jpa package required by the persistence bundle, try org.osgi.service.jpa
		BundleCapability pbJpaService = getUsedCapability(pbWiring, 
				OSGI_PACKAGE_NS, JPA_SERVICE_PKG);
		
		if(pbJpaService != null) {
			LOGGER.debug("Matching JPA service package for possible persistence bundle {}", bundle.getSymbolicName());
			
			BundleCapability implJpaService = getUsedCapability(pbWiring, 
					OSGI_PACKAGE_NS, JPA_SERVICE_PKG);
			return !pbJpaService.equals(implJpaService);
		}
		
		// If there is nothing to clash on then we must assume that it's safe
		return false;
	}