-
-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3481 from ebean-orm/feature/boostrap-service
Use io.ebean.service.BootstrapService as common marker interface for service loading bootstrapped services
- Loading branch information
Showing
24 changed files
with
141 additions
and
157 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package io.ebean; | ||
|
||
import io.ebean.metric.MetricFactory; | ||
import io.ebean.service.*; | ||
|
||
import java.util.ServiceLoader; | ||
|
||
/** | ||
* Bootstrap internal services. | ||
*/ | ||
public final class XBootstrapService { | ||
|
||
private static final SpiContainerFactory containerFactory; | ||
private static final SpiRawSqlService rawSqlService; | ||
private static final SpiProfileLocationFactory profileLocationFactory; | ||
private static final SpiFetchGroupService fetchGroupService; | ||
private static final MetricFactory metricFactory; | ||
private static final SpiJsonService jsonService; | ||
static { | ||
SpiContainerFactory _factory = null; | ||
SpiRawSqlService _raw = null; | ||
SpiProfileLocationFactory _profile = null; | ||
SpiFetchGroupService _fetch = null; | ||
MetricFactory _metric = null; | ||
SpiJsonService _json = null; | ||
for (BootstrapService extension : ServiceLoader.load(BootstrapService.class)) { | ||
if (extension instanceof SpiContainerFactory) { | ||
_factory = (SpiContainerFactory)extension; | ||
} else if (extension instanceof SpiRawSqlService) { | ||
_raw = (SpiRawSqlService)extension; | ||
} else if (extension instanceof SpiProfileLocationFactory) { | ||
_profile = (SpiProfileLocationFactory)extension; | ||
} else if (extension instanceof SpiFetchGroupService) { | ||
_fetch = (SpiFetchGroupService)extension; | ||
} else if (extension instanceof MetricFactory) { | ||
_metric = (MetricFactory)extension; | ||
} else if (extension instanceof SpiJsonService) { | ||
_json = (SpiJsonService)extension; | ||
} | ||
} | ||
containerFactory = _factory; | ||
rawSqlService = _raw; | ||
profileLocationFactory = _profile; | ||
fetchGroupService = _fetch; | ||
metricFactory = _metric; | ||
jsonService = _json; | ||
} | ||
|
||
/** | ||
* Return the MetricFactory found in boostrap service loading. | ||
*/ | ||
public static MetricFactory metricFactory() { | ||
return metricFactory; | ||
} | ||
|
||
/** | ||
* Return the SpiJsonService found in boostrap service loading. | ||
*/ | ||
public static SpiJsonService jsonService() { | ||
return jsonService; | ||
} | ||
|
||
static SpiContainerFactory containerFactory() { | ||
return containerFactory; | ||
} | ||
|
||
static SpiRawSqlService rawSql() { | ||
return rawSqlService; | ||
} | ||
|
||
static SpiProfileLocationFactory profileLocationFactory() { | ||
return profileLocationFactory; | ||
} | ||
|
||
/** | ||
* Return the FetchGroup with the given select clause. | ||
*/ | ||
static <T> FetchGroup<T> fetchGroupOf(Class<T> cls, String select) { | ||
return fetchGroupService.of(cls, select); | ||
} | ||
|
||
/** | ||
* Return the FetchGroupBuilder with the given select clause. | ||
*/ | ||
static <T> FetchGroupBuilder<T> fetchGroupOf(Class<T> cls) { | ||
return fetchGroupService.of(cls); | ||
} | ||
|
||
/** | ||
* Return the FetchGroup Query for building fetch groups via query beans. | ||
*/ | ||
static <T> SpiFetchGroupQuery<T> fetchGroupQueryFor(Class<T> cls) { | ||
return fetchGroupService.queryFor(cls); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
28 changes: 0 additions & 28 deletions
28
ebean-api/src/main/java/io/ebean/metric/MetricServiceProvider.java
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
ebean-api/src/main/java/io/ebean/service/BootstrapService.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,7 @@ | ||
package io.ebean.service; | ||
|
||
/** | ||
* Marker interface for internal services loaded at startup. | ||
*/ | ||
public interface BootstrapService { | ||
} |
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
Oops, something went wrong.