org.jboss.deployers.plugins.main
Class MainDeployerImpl

java.lang.Object
  extended by org.jboss.deployers.plugins.main.MainDeployerImpl
All Implemented Interfaces:
DeployerClient, MainDeployer, MainDeployerStructure

public class MainDeployerImpl
extends Object
implements MainDeployer, MainDeployerStructure

MainDeployerImpl.

Version:
$Revision: 87597 $
Author:
Adrian Brock, Scott Stark, Ales Justin

Constructor Summary
MainDeployerImpl()
           
 
Method Summary
 void addDeployment(Deployment deployment)
          Add a deployment
protected  void addDeployment(Deployment deployment, boolean addToDeploy)
          Add a deployment
 void change(String deploymentName, DeploymentStage stage)
          Change the state of a deployment
 void checkComplete()
          Check all the deployments are complete
 void checkComplete(Deployment... deployments)
          Check if deployments are complete
 void checkComplete(String... names)
          Check if deployments are complete
protected  boolean checkExistingTopLevelDeployment(Deployment deployment, boolean addToDeploy)
          Check for existing deployment context - redeploy.
 void checkStructureComplete(Deployment... deployments)
          Check if deployments are recognized
 void checkStructureComplete(String... names)
          Check if deployments are recognized
 void deploy(Deployment... deployments)
          Deploy the deployments
protected  void determineDeploymentContext(Deployment deployment, boolean addToDeploy)
          Determine deployment context.
 Collection<DeploymentContext> getAll()
          Get all deployments.
 org.jboss.util.graph.Graph<Map<String,org.jboss.managed.api.ManagedObject>> getDeepManagedObjects(String name)
          Get the graph of managed objects starting with the top-level deployment associated with name.
 Deployers getDeployers()
          Get the deployers
 Deployment getDeployment(String name)
          Get a deployment
 DeploymentContext getDeploymentContext(String name)
          Deprecated. 
 DeploymentContext getDeploymentContext(String name, boolean errorNotFound)
          Deprecated. 
protected  DeploymentContext[] getDeploymentContexts(String... names)
          Get the deployment contexts.
protected static String[] getDeploymentNames(Deployment... deployments)
          Get the names from deployments.
 DeploymentStage getDeploymentStage(String deploymentName)
          Get the deployment stage for a deployment
 DeploymentState getDeploymentState(String name)
          Get a the state of deployment
 DeploymentUnit getDeploymentUnit(String name)
          Get a deployment unit
 DeploymentUnit getDeploymentUnit(String name, boolean errorNotFound)
          Get a deployment context
 Collection<DeploymentContext> getErrors()
          Get errors.
 org.jboss.managed.api.ManagedDeployment getManagedDeployment(String name)
          Get the managed deployment.
 Map<String,org.jboss.managed.api.ManagedObject> getManagedObjects(DeploymentContext context)
           
 Map<String,org.jboss.managed.api.ManagedObject> getManagedObjects(String name)
          Get the managed objects for a deployment context.
 ManagedDeploymentCreator getMgtDeploymentCreator()
          Get managed deployment creator.
 Collection<Deployment> getMissingDeployer()
          Get missing deployers deployments.
 StructuralDeployers getStructuralDeployers()
          Get the structural deployers
 Collection<Deployment> getTopLevel()
          Get the top level deployments
 DeploymentContext getTopLevelDeploymentContext(String name)
          Get a top level deployment context by name
protected  void lockRead()
          Lock for read
protected  void lockWrite()
          Lock for write
 void prepareShutdown()
          Tell the main deployer we are about to shutdown
 void process()
          Process the outstanding deployments.
protected  void processManagedDeployment(DeploymentContext context, org.jboss.managed.api.ManagedDeployment parent)
          Recursively process the DeploymentContext into ManagedDeployments.
protected  void processManagedObjects(DeploymentContext context, org.jboss.util.graph.Graph<Map<String,org.jboss.managed.api.ManagedObject>> graph, org.jboss.util.graph.Vertex<Map<String,org.jboss.managed.api.ManagedObject>> parent)
          Get the managed objects for a context
protected  void processToDeploy(Collection<Deployment> deployments)
          Process added re-deployments.
protected  void processToUndeploy(Set<String> names)
          Remove added re-deployments.
 boolean removeDeployment(Deployment deployment)
          Remove a deployment
protected  boolean removeDeployment(Deployment deployment, boolean addToUndeploy)
          Remove a deployment by name
 boolean removeDeployment(String name)
          Remove a deployment by name
protected  boolean removeDeployment(String name, boolean addToUndeploy)
          Remove a deployment by name
 void setComparator(Comparator<DeploymentContext> comparator)
          Set the top deployment context comparator.
 void setDeployers(Deployers deployers)
          Set the deployers
 void setMgtDeploymentCreator(ManagedDeploymentCreator mgtDeploymentCreator)
          Set managed deployment creator.
 void setStructuralDeployers(StructuralDeployers deployers)
          Set the structural deployers
 void shutdown()
          Shutdown.
 void undeploy(Deployment... deployments)
          Undeploy the deployments
 void undeploy(String... names)
          Undeploy a deployments by name
protected  void unlockRead()
          Unlock for read
protected  void unlockWrite()
          Unlock for write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MainDeployerImpl

public MainDeployerImpl()
Method Detail

setComparator

public void setComparator(Comparator<DeploymentContext> comparator)
Set the top deployment context comparator.

Parameters:
comparator - the deployment context comparator

getDeployers

public Deployers getDeployers()
Get the deployers

Returns:
the deployers

setDeployers

public void setDeployers(Deployers deployers)
Set the deployers

Parameters:
deployers - the deployers
Throws:
IllegalArgumentException - for null deployers

getStructuralDeployers

public StructuralDeployers getStructuralDeployers()
Get the structural deployers

Returns:
the structural deployers

setStructuralDeployers

public void setStructuralDeployers(StructuralDeployers deployers)
Set the structural deployers

Parameters:
deployers - the deployers
Throws:
IllegalArgumentException - for null deployers

getMgtDeploymentCreator

public ManagedDeploymentCreator getMgtDeploymentCreator()
Get managed deployment creator.

Returns:
the managed deployment creator

setMgtDeploymentCreator

public void setMgtDeploymentCreator(ManagedDeploymentCreator mgtDeploymentCreator)
Set managed deployment creator.

Parameters:
mgtDeploymentCreator - the managed deployment creator

getDeployment

public Deployment getDeployment(String name)
Description copied from interface: DeployerClient
Get a deployment

Specified by:
getDeployment in interface DeployerClient
Parameters:
name - the name of the deployment
Returns:
the deployment or null if not found

getDeploymentContext

@Deprecated
public DeploymentContext getDeploymentContext(String name)
Deprecated. 

Description copied from interface: MainDeployerStructure
Get a deployment context

Specified by:
getDeploymentContext in interface MainDeployerStructure
Parameters:
name - the name of the context
Returns:
the context or null if not found

getDeploymentContext

@Deprecated
public DeploymentContext getDeploymentContext(String name,
                                                         boolean errorNotFound)
                                       throws DeploymentException
Deprecated. 

Description copied from interface: MainDeployerStructure
Get a deployment context

Specified by:
getDeploymentContext in interface MainDeployerStructure
Parameters:
name - the name of the context
errorNotFound - whether to throw an error if not found
Returns:
the context
Throws:
DeploymentException - for not found

getDeploymentUnit

public DeploymentUnit getDeploymentUnit(String name)
Description copied from interface: MainDeployerStructure
Get a deployment unit

Specified by:
getDeploymentUnit in interface MainDeployerStructure
Parameters:
name - the name of the unit
Returns:
the unit or null if not found

getDeploymentUnit

public DeploymentUnit getDeploymentUnit(String name,
                                        boolean errorNotFound)
                                 throws DeploymentException
Description copied from interface: MainDeployerStructure
Get a deployment context

Specified by:
getDeploymentUnit in interface MainDeployerStructure
Parameters:
name - the name of the context
errorNotFound - whether to throw an error if not found
Returns:
the context
Throws:
DeploymentException - for not found

getTopLevelDeploymentContext

public DeploymentContext getTopLevelDeploymentContext(String name)
Get a top level deployment context by name

Parameters:
name - the name
Returns:
the context

getAll

public Collection<DeploymentContext> getAll()
Get all deployments.

Returns:
all deployments

getErrors

public Collection<DeploymentContext> getErrors()
Get errors.

Returns:
the errors

getMissingDeployer

public Collection<Deployment> getMissingDeployer()
Get missing deployers deployments.

Returns:
the missing deployer deployments

getTopLevel

public Collection<Deployment> getTopLevel()
Description copied from interface: DeployerClient
Get the top level deployments

Specified by:
getTopLevel in interface DeployerClient
Returns:
the top level deployments

addDeployment

public void addDeployment(Deployment deployment)
                   throws DeploymentException
Description copied from interface: DeployerClient
Add a deployment

Specified by:
addDeployment in interface DeployerClient
Parameters:
deployment - the deployment
Throws:
DeploymentException - for any error

processToUndeploy

protected void processToUndeploy(Set<String> names)
                          throws DeploymentException
Remove added re-deployments. This method should take read lock.

Parameters:
names - the deployment names to remove
Throws:
DeploymentException - for any error

processToDeploy

protected void processToDeploy(Collection<Deployment> deployments)
                        throws DeploymentException
Process added re-deployments. This method should take read lock.

Parameters:
deployments - the deployments to process
Throws:
DeploymentException - for any error

addDeployment

protected void addDeployment(Deployment deployment,
                             boolean addToDeploy)
                      throws DeploymentException
Add a deployment

Parameters:
deployment - the deployment
addToDeploy - should we add this deployment to deploy collection
Throws:
DeploymentException - for any error

checkExistingTopLevelDeployment

protected boolean checkExistingTopLevelDeployment(Deployment deployment,
                                                  boolean addToDeploy)
Check for existing deployment context - redeploy. Method should take read lock.

Parameters:
deployment - the deployment
addToDeploy - should we add this deployment to deploy collection
Returns:
true if deployment is a redeployment, false otherwise

determineDeploymentContext

protected void determineDeploymentContext(Deployment deployment,
                                          boolean addToDeploy)
                                   throws DeploymentException
Determine deployment context. Method should take read lock.

Parameters:
deployment - the deployment
addToDeploy - should we add this deployment to deploy collection
Throws:
DeploymentException - for any error

removeDeployment

public boolean removeDeployment(Deployment deployment)
                         throws DeploymentException
Description copied from interface: DeployerClient
Remove a deployment

Specified by:
removeDeployment in interface DeployerClient
Parameters:
deployment - the deployment to remove
Returns:
false when the context was previously unknown
Throws:
DeploymentException - for any error

removeDeployment

protected boolean removeDeployment(Deployment deployment,
                                   boolean addToUndeploy)
                            throws DeploymentException
Remove a deployment by name

Parameters:
deployment - thedeployment
addToUndeploy - should we add to undeploy collection
Returns:
false when the context was previously unknown
Throws:
DeploymentException - for any error

removeDeployment

public boolean removeDeployment(String name)
                         throws DeploymentException
Description copied from interface: DeployerClient
Remove a deployment by name

Specified by:
removeDeployment in interface DeployerClient
Parameters:
name - the name of the deployment
Returns:
false when the context was previously unknown
Throws:
DeploymentException - for any error

removeDeployment

protected boolean removeDeployment(String name,
                                   boolean addToUndeploy)
                            throws DeploymentException
Remove a deployment by name

Parameters:
name - the name of the deployment
addToUndeploy - should we add to undeploy collection
Returns:
false when the context was previously unknown
Throws:
DeploymentException - for any error

deploy

public void deploy(Deployment... deployments)
            throws DeploymentException
Description copied from interface: DeployerClient
Deploy the deployments

Specified by:
deploy in interface DeployerClient
Parameters:
deployments - the deployments
Throws:
DeploymentException - for any error

undeploy

public void undeploy(Deployment... deployments)
              throws DeploymentException
Description copied from interface: DeployerClient
Undeploy the deployments

Specified by:
undeploy in interface DeployerClient
Parameters:
deployments - the deployments
Throws:
DeploymentException - for any error

undeploy

public void undeploy(String... names)
              throws DeploymentException
Description copied from interface: DeployerClient
Undeploy a deployments by name

Specified by:
undeploy in interface DeployerClient
Parameters:
names - the names of the deployments
Throws:
DeploymentException - for any error

process

public void process()
Description copied from interface: DeployerClient
Process the outstanding deployments.

Specified by:
process in interface DeployerClient

getDeploymentStage

public DeploymentStage getDeploymentStage(String deploymentName)
                                   throws DeploymentException
Description copied from interface: DeployerClient
Get the deployment stage for a deployment

Specified by:
getDeploymentStage in interface DeployerClient
Parameters:
deploymentName - the deployment name
Returns:
the stage
Throws:
DeploymentException - for any error

change

public void change(String deploymentName,
                   DeploymentStage stage)
            throws DeploymentException
Description copied from interface: DeployerClient
Change the state of a deployment

Specified by:
change in interface DeployerClient
Parameters:
deploymentName - the deployment name
stage - the stage
Throws:
DeploymentException - for any error

prepareShutdown

public void prepareShutdown()
Description copied from interface: MainDeployer
Tell the main deployer we are about to shutdown

Specified by:
prepareShutdown in interface MainDeployer

shutdown

public void shutdown()
Description copied from interface: MainDeployer
Shutdown. Removes all the deployments.

Specified by:
shutdown in interface MainDeployer

checkComplete

public void checkComplete()
                   throws DeploymentException
Description copied from interface: DeployerClient
Check all the deployments are complete

Specified by:
checkComplete in interface DeployerClient
Throws:
DeploymentException - when some deployment is not complete

getDeploymentNames

protected static String[] getDeploymentNames(Deployment... deployments)
Get the names from deployments.

Parameters:
deployments - the deployments
Returns:
depolyment names

getDeploymentContexts

protected DeploymentContext[] getDeploymentContexts(String... names)
                                             throws DeploymentException
Get the deployment contexts.

Parameters:
names - the deployment names
Returns:
depolyment contexts
Throws:
DeploymentException - if context is not found

checkComplete

public void checkComplete(Deployment... deployments)
                   throws DeploymentException
Description copied from interface: DeployerClient
Check if deployments are complete

Specified by:
checkComplete in interface DeployerClient
Parameters:
deployments - the deployment
Throws:
DeploymentException - when some deployments are not complete

checkComplete

public void checkComplete(String... names)
                   throws DeploymentException
Description copied from interface: DeployerClient
Check if deployments are complete

Specified by:
checkComplete in interface DeployerClient
Parameters:
names - the deployment name
Throws:
DeploymentException - when some deployments are not complete

checkStructureComplete

public void checkStructureComplete(Deployment... deployments)
                            throws DeploymentException
Description copied from interface: DeployerClient
Check if deployments are recognized

Specified by:
checkStructureComplete in interface DeployerClient
Parameters:
deployments - the deployments
Throws:
DeploymentException - when some deployments are not recognized

checkStructureComplete

public void checkStructureComplete(String... names)
                            throws DeploymentException
Description copied from interface: DeployerClient
Check if deployments are recognized

Specified by:
checkStructureComplete in interface DeployerClient
Parameters:
names - the deployment names
Throws:
DeploymentException - when some deployments are not recognized

getDeploymentState

public DeploymentState getDeploymentState(String name)
Description copied from interface: DeployerClient
Get a the state of deployment

Specified by:
getDeploymentState in interface DeployerClient
Parameters:
name - the name of the deployment
Returns:
the deployment state

getManagedDeployment

public org.jboss.managed.api.ManagedDeployment getManagedDeployment(String name)
                                                             throws DeploymentException
Description copied from interface: DeployerClient
Get the managed deployment.

Specified by:
getManagedDeployment in interface DeployerClient
Parameters:
name - the name of the deployment
Returns:
the managed deployment
Throws:
DeploymentException - for any error

getManagedObjects

public Map<String,org.jboss.managed.api.ManagedObject> getManagedObjects(String name)
                                                                  throws DeploymentException
Description copied from interface: DeployerClient
Get the managed objects for a deployment context. This is a mapping of the attachment names to the associated ManagedObject.

Specified by:
getManagedObjects in interface DeployerClient
Parameters:
name - the name of the deployment
Returns:
the managed object map keyed by the attachment names.
Throws:
DeploymentException - for any error

getManagedObjects

public Map<String,org.jboss.managed.api.ManagedObject> getManagedObjects(DeploymentContext context)
                                                                  throws DeploymentException
Throws:
DeploymentException

getDeepManagedObjects

public org.jboss.util.graph.Graph<Map<String,org.jboss.managed.api.ManagedObject>> getDeepManagedObjects(String name)
                                                                                                  throws DeploymentException
Description copied from interface: DeployerClient
Get the graph of managed objects starting with the top-level deployment associated with name.

Specified by:
getDeepManagedObjects in interface DeployerClient
Parameters:
name - - the name of the top-level DeploymentContext to process.
Returns:
the graph of managed objects for the top-level DeploymentContex and its children.
Throws:
DeploymentException - for any error

processManagedObjects

protected void processManagedObjects(DeploymentContext context,
                                     org.jboss.util.graph.Graph<Map<String,org.jboss.managed.api.ManagedObject>> graph,
                                     org.jboss.util.graph.Vertex<Map<String,org.jboss.managed.api.ManagedObject>> parent)
                              throws DeploymentException
Get the managed objects for a context

Parameters:
context - the context
graph - the graph
parent - the parent node
Throws:
DeploymentException - for any problem

processManagedDeployment

protected void processManagedDeployment(DeploymentContext context,
                                        org.jboss.managed.api.ManagedDeployment parent)
                                 throws DeploymentException
Recursively process the DeploymentContext into ManagedDeployments.

Parameters:
context - the context
parent - the parent
Throws:
DeploymentException - for any error

lockRead

protected void lockRead()
Lock for read


unlockRead

protected void unlockRead()
Unlock for read


lockWrite

protected void lockWrite()
Lock for write


unlockWrite

protected void unlockWrite()
Unlock for write



Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.