protected void unregisterDeployer(Deployer deployer) { try { deploymentEngine.unregisterDeployer(deployer); } catch (Exception e) { logger.error("Error while removing deployer from deployment engine", e); } }
@Activate public void start(BundleContext bundleContext) throws Exception { try { // Initialize deployment engine and scan it String carbonRepositoryLocation = carbonRuntime.getConfiguration().getDeploymentConfig().getRepositoryLocation(); deploymentEngine = new DeploymentEngine(carbonRepositoryLocation); logger.debug("Starting Carbon Deployment Engine {}", deploymentEngine); deploymentEngine.start(); // Add deployment engine to the data holder for later usages/references of this object OSGiServiceHolder.getInstance().setCarbonDeploymentEngine(deploymentEngine); // Register DeploymentService DeploymentService deploymentService = new CarbonDeploymentService(deploymentEngine); serviceRegistration = bundleContext.registerService(DeploymentService.class.getName(), deploymentService, null); logger.debug("Started Carbon Deployment Engine"); // register pending deployers in the list for (Deployer deployer : deployerList) { try { deploymentEngine.registerDeployer(deployer); } catch (Exception e) { logger.error("Error while adding deployer to the deployment engine", e); } } } catch (DeploymentEngineException e) { String msg = "Could not initialize carbon deployment engine"; logger.error(msg, e); } catch (Throwable e) { logger.error(e.getMessage(), e); } }
@Reference( name = "carbon.deployer.service", service = Deployer.class, cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC, unbind = "unregisterDeployer") protected void registerDeployer(Deployer deployer) { if (deploymentEngine != null) { try { deploymentEngine.registerDeployer(deployer); } catch (Exception e) { logger.error("Error while adding deployer to the deployment engine", e); } } else { // carbon deployment engine is not initialized yet, so we keep them in a pending list deployerList.add(deployer); } }