use of org.glassfish.api.deployment.ApplicationMetaDataProvider in project Payara by payara.
the class ApplicationLifecycle method loadDeployers.
private List<Deployer> loadDeployers(Map<Deployer, EngineInfo> containerInfosByDeployers, DeploymentContext context) throws IOException {
final ActionReport report = context.getActionReport();
final Map<Class, ApplicationMetaDataProvider> typeByProvider = getTypeByProvider();
final Map<Class, Deployer> typeByDeployer = getTypeByDeployer(containerInfosByDeployers);
final StructuredDeploymentTracing tracing = StructuredDeploymentTracing.load(context);
for (Deployer deployer : containerInfosByDeployers.keySet()) {
if (deployer.getMetaData() != null) {
for (Class dependency : deployer.getMetaData().requires()) {
if (!typeByDeployer.containsKey(dependency) && !typeByProvider.containsKey(dependency)) {
Service s = deployer.getClass().getAnnotation(Service.class);
String serviceName;
if (s != null && s.name() != null && s.name().length() > 0) {
serviceName = s.name();
} else {
serviceName = deployer.getClass().getSimpleName();
}
report.failure(logger, serviceName + " deployer requires " + dependency + " but no other deployer provides it", null);
return null;
}
}
}
}
List<Deployer> orderedDeployers = new ArrayList<>();
for (Map.Entry<Deployer, EngineInfo> entry : containerInfosByDeployers.entrySet()) {
Deployer deployer = entry.getKey();
if (logger.isLoggable(Level.FINE)) {
logger.log(FINE, "Keyed Deployer {0}", deployer.getClass());
}
DeploymentSpan span = tracing.startSpan(TraceContext.Level.CONTAINER, entry.getValue().getSniffer().getModuleType(), DeploymentTracing.AppStage.PREPARE);
loadDeployer(orderedDeployers, deployer, typeByDeployer, typeByProvider, context);
span.close();
}
return orderedDeployers;
}
use of org.glassfish.api.deployment.ApplicationMetaDataProvider in project Payara by payara.
the class ApplicationState method reloadApplicationMetaData.
private void reloadApplicationMetaData(DeploymentContext dc) throws IOException {
Deployment deployment = habitat.getService(Deployment.class);
Map<Class, ApplicationMetaDataProvider> typeByProvider = deployment.getTypeByProvider();
for (Class requiredMetaDataClasse : this.requiredMetaDataClasses()) {
ApplicationMetaDataProvider metaDataProvider = typeByProvider.get(requiredMetaDataClasse);
metaDataProvider.load(dc);
}
}
use of org.glassfish.api.deployment.ApplicationMetaDataProvider in project Payara by payara.
the class ApplicationLifecycle method getTypeByProvider.
public Map<Class, ApplicationMetaDataProvider> getTypeByProvider() {
// in reality, there is single implementation of ApplicationMetadataProvider at this point.
final Map<Class, ApplicationMetaDataProvider> typeByProvider = new HashMap<>();
final List<ApplicationMetaDataProvider> providers = habitat.<ApplicationMetaDataProvider>getAllServices(ApplicationMetaDataProvider.class);
for (ApplicationMetaDataProvider provider : providers) {
if (provider.getMetaData() != null) {
for (Class provided : provider.getMetaData().provides()) {
typeByProvider.put(provided, provider);
}
}
}
// check if everything is provided.
for (ApplicationMetaDataProvider provider : providers) {
if (provider.getMetaData() != null) {
for (Class dependency : provider.getMetaData().requires()) {
if (!typeByProvider.containsKey(dependency)) {
// at this point, I only log problems, because it maybe that what I am deploying now
// will not require this application metadata.
logger.log(WARNING, KernelLoggerInfo.applicationMetaDataProvider, new Object[] { provider, dependency });
}
}
}
}
return typeByProvider;
}
use of org.glassfish.api.deployment.ApplicationMetaDataProvider in project Payara by payara.
the class ApplicationLifecycle method loadDeployer.
private void loadDeployer(List<Deployer> results, Deployer deployer, Map<Class, Deployer> typeByDeployer, Map<Class, ApplicationMetaDataProvider> typeByProvider, DeploymentContext dc) throws IOException {
StructuredDeploymentTracing tracing = StructuredDeploymentTracing.load(dc);
if (results.contains(deployer)) {
return;
}
results.add(deployer);
if (deployer.getMetaData() != null) {
for (Class required : deployer.getMetaData().requires()) {
if (dc.getModuleMetaData(required) != null) {
continue;
}
if (typeByDeployer.containsKey(required)) {
loadDeployer(results, typeByDeployer.get(required), typeByDeployer, typeByProvider, dc);
} else {
ApplicationMetaDataProvider provider = typeByProvider.get(required);
if (provider == null) {
logger.log(SEVERE, KernelLoggerInfo.inconsistentLifecycleState, required);
} else {
LinkedList<ApplicationMetaDataProvider> providers = new LinkedList<>();
addRecursively(providers, typeByProvider, provider);
for (ApplicationMetaDataProvider p : providers) {
// this actually loads all descriptors of the app.
try (DeploymentSpan span = tracing.startSpan(TraceContext.Level.APPLICATION, null, DeploymentTracing.AppStage.LOAD, "DeploymentDescriptor")) {
dc.addModuleMetaData(p.load(dc));
}
}
}
}
}
}
}
Aggregations