Class ApplicationManager
- java.lang.Object
-
- org.wso2.carbon.application.deployer.internal.ApplicationManager
-
- All Implemented Interfaces:
ApplicationManagerService
public final class ApplicationManager extends Object implements ApplicationManagerService
Manages all cApp deployment aspects. Carbon App deployment is done in two steps. A cApp is basically a p2 repo which contains artifacts as features. Step 1 : Find out the artifacts to be installed in this server and install their features through p2 Step 2 : After needed features are installed, complete the cApp deployment by sending the cApp through a chain of handlers This handler chain can contain different cApp artifact deployers. Those can be registered or unregistered using this ApplicationManager API.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCarbonApp(String tenantId, CarbonApplication carbonApp)Add a new cApp for a particular tenant.voidaddFaultyCarbonApp(String tenantId, String carbonApp, Exception error)Add a new faulty cApp for a particular tenant.ArtifactbuildAppArtifact(CarbonApplication parentApp, InputStream artifactXmlStream)Builds the artifact from the given input steam and adds it as a dependency in the provided parent carbon application.voidbuildDependencyTree(Artifact rootArtifact, List<Artifact> allArtifacts)If the given artifact is a dependent artifact for the rootArtifact, include it as the actual dependency.voidcleanupCarbonApps(org.apache.axis2.engine.AxisConfiguration axisConfig)voiddeployCarbonApp(String archPath, org.apache.axis2.engine.AxisConfiguration axisConfig)Deploy a single app by iterating all handlers and sending apps through the handler chain..ArrayList<CarbonApplication>getCarbonApps(String tenantId)Get the list of CarbonApplications for the give tenant id.HashMap<String,Exception>getFaultyCarbonApps(String tenantId)Get the list of faulty CarbonApplications for the give tenant id.static ApplicationManagergetInstance()ApplicationManager is singleton.CarbonAppPersistenceManagergetPersistenceManager(org.apache.axis2.engine.AxisConfiguration axisConfig)Retuns the persistence manger for the given axis config (tenant).voidinit()voidregisterDeploymentHandler(AppDeploymentHandler handler)All app deployers register their deployers throgh this methodvoidremoveCarbonApp(String tenantId, CarbonApplication carbonApp)Remove a cApp for a particular tenantvoidremoveFaultyCarbonApp(String tenantId, String appFilePath)Remove a faulty cApp for a particular tenantvoidundeployCarbonApp(CarbonApplication carbonApp, org.apache.axis2.engine.AxisConfiguration axisConfig)Undeploy the provided carbon App by sending it through the registered undeployment handler chain..voidunregisterDeploymentHandler(AppDeploymentHandler handler)Unregister the specified handler if it is already regitered
-
-
-
Method Detail
-
init
public void init()
-
getInstance
public static ApplicationManager getInstance()
ApplicationManager is singleton. This can be used to access the instance.- Returns:
- - ApplicationManager instance
-
registerDeploymentHandler
public void registerDeploymentHandler(AppDeploymentHandler handler)
All app deployers register their deployers throgh this method- Specified by:
registerDeploymentHandlerin interfaceApplicationManagerService- Parameters:
handler- - app deployer which implements the AppDeploymentHandler interface
-
unregisterDeploymentHandler
public void unregisterDeploymentHandler(AppDeploymentHandler handler)
Unregister the specified handler if it is already regitered- Specified by:
unregisterDeploymentHandlerin interfaceApplicationManagerService- Parameters:
handler- - input deployer handler
-
deployCarbonApp
public void deployCarbonApp(String archPath, org.apache.axis2.engine.AxisConfiguration axisConfig) throws Exception
Deploy a single app by iterating all handlers and sending apps through the handler chain..- Specified by:
deployCarbonAppin interfaceApplicationManagerService- Parameters:
archPath- - carbon app archive pathaxisConfig- - AxisConfiguration of the current tenant- Throws:
Exception- - error on registry actions
-
buildAppArtifact
public Artifact buildAppArtifact(CarbonApplication parentApp, InputStream artifactXmlStream) throws org.wso2.carbon.CarbonException
Builds the artifact from the given input steam and adds it as a dependency in the provided parent carbon application.- Parameters:
parentApp- - parent applicationartifactXmlStream- - xml input stream of the artifact.xml- Returns:
- - Artifact instance if successfull. otherwise null..
- Throws:
org.wso2.carbon.CarbonException- - error while building
-
undeployCarbonApp
public void undeployCarbonApp(CarbonApplication carbonApp, org.apache.axis2.engine.AxisConfiguration axisConfig)
Undeploy the provided carbon App by sending it through the registered undeployment handler chain..- Specified by:
undeployCarbonAppin interfaceApplicationManagerService- Parameters:
carbonApp- - CarbonApplication instanceaxisConfig- - AxisConfiguration of the current tenant
-
getCarbonApps
public ArrayList<CarbonApplication> getCarbonApps(String tenantId)
Get the list of CarbonApplications for the give tenant id. If the list is null, return an empty ArrayList- Specified by:
getCarbonAppsin interfaceApplicationManagerService- Parameters:
tenantId- - tenant id to find cApps- Returns:
- - list of tenant cApps
-
getFaultyCarbonApps
public HashMap<String,Exception> getFaultyCarbonApps(String tenantId)
Get the list of faulty CarbonApplications for the give tenant id. If the list is null, return an empty Arraylist- Specified by:
getFaultyCarbonAppsin interfaceApplicationManagerService- Parameters:
tenantId- - tenant id to find faulty cApps- Returns:
- - list of tenant faulty cApps
-
addFaultyCarbonApp
public void addFaultyCarbonApp(String tenantId, String carbonApp, Exception error)
Add a new faulty cApp for a particular tenant. If there are no faulty cApps currently, create a new ArrayList and add the new cApp.- Parameters:
tenantId-carbonApp-
-
removeFaultyCarbonApp
public void removeFaultyCarbonApp(String tenantId, String appFilePath)
Remove a faulty cApp for a particular tenant- Parameters:
tenantId-appFilePath-
-
addCarbonApp
public void addCarbonApp(String tenantId, CarbonApplication carbonApp)
Add a new cApp for a particular tenant. If there are no cApps currently, create a new ArrayList and add the new cApp.- Parameters:
tenantId- - tenant id of the cAppcarbonApp- - CarbonApplication instance
-
removeCarbonApp
public void removeCarbonApp(String tenantId, CarbonApplication carbonApp)
Remove a cApp for a particular tenant- Parameters:
tenantId- - tenant id of the cAppcarbonApp- - CarbonApplication instance
-
buildDependencyTree
public void buildDependencyTree(Artifact rootArtifact, List<Artifact> allArtifacts)
If the given artifact is a dependent artifact for the rootArtifact, include it as the actual dependency. The existing one is a dummy one. So remove it. Do this recursively for the dependent artifacts as well..- Parameters:
rootArtifact- - root to start searchallArtifacts- - all artifacts found under current cApp
-
getPersistenceManager
public CarbonAppPersistenceManager getPersistenceManager(org.apache.axis2.engine.AxisConfiguration axisConfig)
Retuns the persistence manger for the given axis config (tenant). First try to find it in the PM map. If it is not there, create a new one.- Parameters:
axisConfig- - AxisConfiguration of the current tenant- Returns:
- - CarbonAppPersistenceManager for the current tenant
-
cleanupCarbonApps
public void cleanupCarbonApps(org.apache.axis2.engine.AxisConfiguration axisConfig)
-
-