eclipse-ee4j / glassfish-hk2

Dynamic dependency injection framework
https://eclipse-ee4j.github.io/glassfish-hk2
Other
85 stars 57 forks source link

RunLevel of Service Not Considered During Service Narrowing and Injection #299

Open glassfishrobot opened 9 years ago

glassfishrobot commented 9 years ago

Given two run level services that implement the same contract:

@Contract
interface ServiceContract {

}

@Service
@RunLevel(5)
class PrimaryService implements ServiceContract {

}

@Service
@RunLevel(10)
class BackupService implements ServiceContract {

}

If I bring the system to run level 5 I would expect HK2 would consider the run level of the available services and returns an instance of PrimaryService if I try to inject/locate an instance of ServiceContract.

Right now HK2 service locator knows about all the discovered descriptors and during service location the service narrowing logic will return a service based on its natural ordering without any regard for the current run level of the system and the run level of the available services.

Ideally HK2 should return a ServiceContract implementation at or below the current service level.

Environment

Linux 64bit, Java 8

Affected Versions

[2.3.0]

glassfishrobot commented 6 years ago
glassfishrobot commented 9 years ago

@glassfishrobot Commented Reported by @saden1

glassfishrobot commented 9 years ago

@glassfishrobot Commented @saden1 said: Comments, concerns, questions?

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA HK2-254