-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1113 Only apply default bindings to global binder
- Loading branch information
1 parent
19c0d74
commit 66e05e9
Showing
13 changed files
with
205 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...n/java/org/dockbox/hartshorn/inject/provider/ComponentRegistryAwareComponentProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2019-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dockbox.hartshorn.inject.provider; | ||
|
||
import org.dockbox.hartshorn.inject.component.ComponentRegistry; | ||
|
||
public interface ComponentRegistryAwareComponentProvider extends ComponentProvider { | ||
|
||
ComponentRegistry componentRegistry(); | ||
} |
20 changes: 20 additions & 0 deletions
20
...ava/org/dockbox/hartshorn/inject/provider/ComponentRegistryAwareProviderOrchestrator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2019-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dockbox.hartshorn.inject.provider; | ||
|
||
public interface ComponentRegistryAwareProviderOrchestrator extends ComponentRegistryAwareComponentProvider, ComponentProviderOrchestrator { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...g/dockbox/hartshorn/launchpad/configuration/AbstractScopeFilteredBinderPostProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2019-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dockbox.hartshorn.launchpad.configuration; | ||
|
||
import org.dockbox.hartshorn.inject.InjectionCapableApplication; | ||
import org.dockbox.hartshorn.inject.binding.HierarchicalBinder; | ||
import org.dockbox.hartshorn.inject.processing.HierarchicalBinderPostProcessor; | ||
import org.dockbox.hartshorn.inject.scope.Scope; | ||
|
||
public abstract class AbstractScopeFilteredBinderPostProcessor implements HierarchicalBinderPostProcessor { | ||
|
||
@Override | ||
public void process(InjectionCapableApplication application, Scope scope, HierarchicalBinder binder) { | ||
if (this.supportsScope(scope)) { | ||
this.processBinder(application, scope, binder); | ||
} | ||
} | ||
|
||
protected abstract void processBinder(InjectionCapableApplication application, Scope scope, HierarchicalBinder binder); | ||
|
||
protected abstract boolean supportsScope(Scope scope); | ||
} |
60 changes: 60 additions & 0 deletions
60
...g/dockbox/hartshorn/launchpad/configuration/ScopeFilteredDelegateBinderPostProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2019-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dockbox.hartshorn.launchpad.configuration; | ||
|
||
import org.dockbox.hartshorn.inject.InjectionCapableApplication; | ||
import org.dockbox.hartshorn.inject.binding.HierarchicalBinder; | ||
import org.dockbox.hartshorn.inject.processing.HierarchicalBinderPostProcessor; | ||
import org.dockbox.hartshorn.inject.scope.Scope; | ||
import org.dockbox.hartshorn.inject.scope.ScopeKey; | ||
|
||
import java.util.Set; | ||
import java.util.function.Predicate; | ||
|
||
public class ScopeFilteredDelegateBinderPostProcessor extends AbstractScopeFilteredBinderPostProcessor { | ||
|
||
private final HierarchicalBinderPostProcessor processor; | ||
private final Predicate<ScopeKey> scopeFilter; | ||
|
||
public ScopeFilteredDelegateBinderPostProcessor(HierarchicalBinderPostProcessor processor, Predicate<ScopeKey> scopeFilter) { | ||
this.processor = processor; | ||
this.scopeFilter = scopeFilter; | ||
} | ||
|
||
public static ScopeFilteredDelegateBinderPostProcessor create(HierarchicalBinderPostProcessor processor, Predicate<ScopeKey> scopeFilter) { | ||
return new ScopeFilteredDelegateBinderPostProcessor(processor, scopeFilter); | ||
} | ||
|
||
public static ScopeFilteredDelegateBinderPostProcessor create(HierarchicalBinderPostProcessor processor, ScopeKey... permittedScopes) { | ||
return new ScopeFilteredDelegateBinderPostProcessor(processor, Set.of(permittedScopes)::contains); | ||
} | ||
|
||
@Override | ||
protected void processBinder(InjectionCapableApplication application, Scope scope, HierarchicalBinder binder) { | ||
this.processor.process(application, scope, binder); | ||
} | ||
|
||
@Override | ||
protected boolean supportsScope(Scope scope) { | ||
return scope != null && this.scopeFilter.test(scope.installableScopeType()); | ||
} | ||
|
||
@Override | ||
public int priority() { | ||
return this.processor.priority(); | ||
} | ||
} |
Oops, something went wrong.