org.jboss.deployers.structure.spi.helpers
Class AbstractDeploymentUnit

java.lang.Object
  extended by org.jboss.deployers.spi.attachments.helpers.AbstractAttachments
      extended by org.jboss.deployers.spi.attachments.helpers.AbstractMutableAttachments
          extended by org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit
All Implemented Interfaces:
Externalizable, Serializable, Attachments, MutableAttachments, DeploymentUnit
Direct Known Subclasses:
AbstractVFSDeploymentUnit

public class AbstractDeploymentUnit
extends AbstractMutableAttachments
implements DeploymentUnit

AbstractDeploymentUnit.

This is just a wrapper to the deployment context that restricts people from "poking" behind the scenes.

Version:
$Revision: 1.1 $
Author:
Adrian Brock, Scott.Stark@jboss.org, Ales Justin
See Also:
Serialized Form

Constructor Summary
AbstractDeploymentUnit()
          For serialization
AbstractDeploymentUnit(DeploymentContext deploymentContext)
          Create a new AbstractDeploymentUnit.
 
Method Summary
 Object addAttachment(String name, Object attachment)
          Add attachment
 DeploymentUnit addComponent(String name)
          Add a component
 void addControllerContextName(Object name)
          Add controller context name.
 void addIDependOn(org.jboss.dependency.spi.DependencyItem dependency)
          Add a dependency
 void clear()
          Clear the attachments
 void clearChangeCount()
          Reset the change count to zero.
 boolean createClassLoader(ClassLoaderFactory factory)
          Create the classloader
protected  DeploymentContext createComponentDeploymentContext(String name, DeploymentContext parent)
          Create a component deployment context
protected  DeploymentUnit createComponentDeploymentUnit(DeploymentContext component)
          Create a component deployment unit
<T> Set<? extends T>
getAllMetaData(Class<T> type)
          Get all the metadata for the expected type
 Object getAttachment(String name)
          Get attachment
 Map<String,Object> getAttachments()
          Get all the attachments
 int getChangeCount()
          Get the number of changes that have happened.
 List<DeploymentUnit> getChildren()
          Get the children
 ClassLoader getClassLoader()
          Gets the classloader for this deployment unit
 DeploymentUnit getComponent(String name)
          Get component.
protected  DeploymentContext getComponentContext(String name)
          Get component deployment context.
 List<DeploymentUnit> getComponents()
          Get the components
 Object getControllerContextName()
          Get underlying controller context name.
 Set<Object> getControllerContextNames()
          Get the controller context names.
 org.jboss.dependency.spi.DependencyInfo getDependencyInfo()
          Get the dependency info
protected  DeploymentContext getDeploymentContext()
          Get the deployment context
 MainDeployer getMainDeployer()
          Get the main deployer
 org.jboss.metadata.spi.MetaData getMetaData()
          Get the metadata for this deployment unit
 org.jboss.metadata.spi.MutableMetaData getMutableMetaData()
          Get the mutable metadata for this deployment unit
 org.jboss.metadata.spi.scope.ScopeKey getMutableScope()
          Get the mutable scope
 String getName()
          Get the deployment units name
 DeploymentUnit getParent()
          Get the parent deployment unit
 String getRelativePath()
          Get the path of this deployment relative to the top of the deployment vfs path ------------------- relative path deploy/some.ear "" deploy/some.ear/x.ejb "/x.ejb" deploy/some.ear/y.sar "/y.sar" deploy/some.ear/y.sar/z.rar "/y.sar/z.rar"
 ClassLoader getResourceClassLoader()
          Get a resource classloader
 DeploymentResourceLoader getResourceLoader()
          Get a resource loader
 org.jboss.metadata.spi.scope.ScopeKey getScope()
          Get the scope
 String getSimpleName()
          Get the simple vfs name of the deployment unit.
 DeploymentUnit getTopLevel()
          Get the top leve deployment unit
 MutableAttachments getTransientManagedObjects()
          Get the transient managed objects
 boolean hasAttachments()
          Are there any attachments
 boolean isAttachmentPresent(String name)
          Is the attachment present
 boolean isComponent()
          Whether this unit is a component
 boolean isTopLevel()
          Whether this unit is a top level deployment
 void readExternal(ObjectInput in)
           
 Object removeAttachment(String name)
          Remove attachment
 void removeClassLoader(ClassLoaderFactory factory)
          Remove the classloader
 boolean removeComponent(String name)
          Remove a component
 void removeControllerContextName(Object name)
          Remove controller context name.
 void removeIDependOn(org.jboss.dependency.spi.DependencyItem dependency)
          Remove a dependency
 void setMutableScope(org.jboss.metadata.spi.scope.ScopeKey key)
          Set the mutable scope
 void setRequiredStage(DeploymentStage stage)
          Set the required stage.
 void setScope(org.jboss.metadata.spi.scope.ScopeKey key)
          Set the scope
 String toString()
           
 void visit(DeploymentUnitVisitor visitor)
          Visit the unit and the children
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.jboss.deployers.spi.attachments.helpers.AbstractMutableAttachments
addAttachment, addAttachment, removeAttachment, removeAttachment, setAttachments
 
Methods inherited from class org.jboss.deployers.spi.attachments.helpers.AbstractAttachments
getAttachment, getAttachment, isAttachmentPresent, isAttachmentPresent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.deployers.spi.attachments.MutableAttachments
addAttachment, addAttachment, removeAttachment, removeAttachment, setAttachments
 
Methods inherited from interface org.jboss.deployers.spi.attachments.Attachments
getAttachment, getAttachment, isAttachmentPresent, isAttachmentPresent
 

Constructor Detail

AbstractDeploymentUnit

public AbstractDeploymentUnit()
For serialization


AbstractDeploymentUnit

public AbstractDeploymentUnit(DeploymentContext deploymentContext)
Create a new AbstractDeploymentUnit.

Parameters:
deploymentContext - the deployment context
Throws:
IllegalArgumentException - for a null deployment context
Method Detail

getName

public String getName()
Description copied from interface: DeploymentUnit
Get the deployment units name

Specified by:
getName in interface DeploymentUnit
Returns:
the name;

getControllerContextNames

public Set<Object> getControllerContextNames()
Description copied from interface: DeploymentUnit
Get the controller context names.

Specified by:
getControllerContextNames in interface DeploymentUnit
Returns:
the names

addControllerContextName

public void addControllerContextName(Object name)
Description copied from interface: DeploymentUnit
Add controller context name.

Specified by:
addControllerContextName in interface DeploymentUnit
Parameters:
name - the controller context name

removeControllerContextName

public void removeControllerContextName(Object name)
Description copied from interface: DeploymentUnit
Remove controller context name.

Specified by:
removeControllerContextName in interface DeploymentUnit
Parameters:
name - the controller context name

getSimpleName

public String getSimpleName()
Description copied from interface: DeploymentUnit
Get the simple vfs name of the deployment unit. This is the simple name of the virtual file . vfs path ------------------- simple name deploy/some.ear "some.ear" deploy/some.ear/x.ejb "x.ejb" deploy/some.ear/y.sar "y.sar" deploy/some.ear/y.sar/z.rar "z.rar" deploy/complexwithappxml.ear/module-mbean1.sar/submbean.sar submbean.sar

Specified by:
getSimpleName in interface DeploymentUnit
Returns:
the deployment unit simple path

getRelativePath

public String getRelativePath()
Description copied from interface: DeploymentUnit
Get the path of this deployment relative to the top of the deployment vfs path ------------------- relative path deploy/some.ear "" deploy/some.ear/x.ejb "/x.ejb" deploy/some.ear/y.sar "/y.sar" deploy/some.ear/y.sar/z.rar "/y.sar/z.rar"

Specified by:
getRelativePath in interface DeploymentUnit
Returns:
the top-level deployment relative path

getScope

public org.jboss.metadata.spi.scope.ScopeKey getScope()
Description copied from interface: DeploymentUnit
Get the scope

Specified by:
getScope in interface DeploymentUnit
Returns:
the scope

setScope

public void setScope(org.jboss.metadata.spi.scope.ScopeKey key)
Description copied from interface: DeploymentUnit
Set the scope

Specified by:
setScope in interface DeploymentUnit
Parameters:
key - the scope key

getMutableScope

public org.jboss.metadata.spi.scope.ScopeKey getMutableScope()
Description copied from interface: DeploymentUnit
Get the mutable scope

Specified by:
getMutableScope in interface DeploymentUnit
Returns:
the mutable scope

setMutableScope

public void setMutableScope(org.jboss.metadata.spi.scope.ScopeKey key)
Description copied from interface: DeploymentUnit
Set the mutable scope

Specified by:
setMutableScope in interface DeploymentUnit
Parameters:
key - the mutable scope key

getMetaData

public org.jboss.metadata.spi.MetaData getMetaData()
Description copied from interface: DeploymentUnit
Get the metadata for this deployment unit

Specified by:
getMetaData in interface DeploymentUnit
Returns:
the metadata

getMutableMetaData

public org.jboss.metadata.spi.MutableMetaData getMutableMetaData()
Description copied from interface: DeploymentUnit
Get the mutable metadata for this deployment unit

Specified by:
getMutableMetaData in interface DeploymentUnit
Returns:
the metadata

getClassLoader

public ClassLoader getClassLoader()
Description copied from interface: DeploymentUnit
Gets the classloader for this deployment unit

Specified by:
getClassLoader in interface DeploymentUnit
Returns:
the classloader

createClassLoader

public boolean createClassLoader(ClassLoaderFactory factory)
                          throws DeploymentException
Description copied from interface: DeploymentUnit
Create the classloader

Specified by:
createClassLoader in interface DeploymentUnit
Parameters:
factory - the classloader factory
Returns:
false if the classloader already exists
Throws:
DeploymentException - for any error

removeClassLoader

public void removeClassLoader(ClassLoaderFactory factory)
Description copied from interface: DeploymentUnit
Remove the classloader

Specified by:
removeClassLoader in interface DeploymentUnit
Parameters:
factory - the original factory used to create the classloader

isTopLevel

public boolean isTopLevel()
Description copied from interface: DeploymentUnit
Whether this unit is a top level deployment

Specified by:
isTopLevel in interface DeploymentUnit
Returns:
true if a top level deployment

getTopLevel

public DeploymentUnit getTopLevel()
Description copied from interface: DeploymentUnit
Get the top leve deployment unit

Specified by:
getTopLevel in interface DeploymentUnit
Returns:
the top level deployment unit

getParent

public DeploymentUnit getParent()
Description copied from interface: DeploymentUnit
Get the parent deployment unit

Specified by:
getParent in interface DeploymentUnit
Returns:
the parent or null if there is no parent

getChildren

public List<DeploymentUnit> getChildren()
Description copied from interface: DeploymentUnit
Get the children

Specified by:
getChildren in interface DeploymentUnit
Returns:
the children

getComponents

public List<DeploymentUnit> getComponents()
Description copied from interface: DeploymentUnit
Get the components

Specified by:
getComponents in interface DeploymentUnit
Returns:
the components

createComponentDeploymentContext

protected DeploymentContext createComponentDeploymentContext(String name,
                                                             DeploymentContext parent)
Create a component deployment context

Parameters:
name - the name
parent - the parent
Returns:
the deployment context

createComponentDeploymentUnit

protected DeploymentUnit createComponentDeploymentUnit(DeploymentContext component)
Create a component deployment unit

Parameters:
component - the component contextr
Returns:
the deployment unit

isComponent

public boolean isComponent()
Description copied from interface: DeploymentUnit
Whether this unit is a component

Specified by:
isComponent in interface DeploymentUnit
Returns:
true for a component

addComponent

public DeploymentUnit addComponent(String name)
Description copied from interface: DeploymentUnit
Add a component

Specified by:
addComponent in interface DeploymentUnit
Parameters:
name - the name
Returns:
the new deployment unit

getComponentContext

protected DeploymentContext getComponentContext(String name)
Get component deployment context.

Parameters:
name - the name
Returns:
component component context or null if no match

getComponent

public DeploymentUnit getComponent(String name)
Description copied from interface: DeploymentUnit
Get component.

Specified by:
getComponent in interface DeploymentUnit
Parameters:
name - the name
Returns:
component if matching component exists, else null

removeComponent

public boolean removeComponent(String name)
Description copied from interface: DeploymentUnit
Remove a component

Specified by:
removeComponent in interface DeploymentUnit
Parameters:
name - the name
Returns:
true when removed

getAllMetaData

public <T> Set<? extends T> getAllMetaData(Class<T> type)
Description copied from interface: DeploymentUnit
Get all the metadata for the expected type

Specified by:
getAllMetaData in interface DeploymentUnit
Type Parameters:
T - the type to get
Parameters:
type - the type
Returns:
a set of metadata matching the type

getTransientManagedObjects

public MutableAttachments getTransientManagedObjects()
Description copied from interface: DeploymentUnit
Get the transient managed objects

Specified by:
getTransientManagedObjects in interface DeploymentUnit
Returns:
the managed objects

addAttachment

public Object addAttachment(String name,
                            Object attachment)
Description copied from interface: MutableAttachments
Add attachment

Specified by:
addAttachment in interface MutableAttachments
Parameters:
name - the name of the attachment
attachment - the attachment
Returns:
any previous attachment

clear

public void clear()
Description copied from interface: MutableAttachments
Clear the attachments

Specified by:
clear in interface MutableAttachments

clearChangeCount

public void clearChangeCount()
Description copied from interface: MutableAttachments
Reset the change count to zero.

Specified by:
clearChangeCount in interface MutableAttachments

getChangeCount

public int getChangeCount()
Description copied from interface: MutableAttachments
Get the number of changes that have happened.

Specified by:
getChangeCount in interface MutableAttachments
Returns:
number of adds/removes that have happened since creation or clearChangeCount.

removeAttachment

public Object removeAttachment(String name)
Description copied from interface: MutableAttachments
Remove attachment

Specified by:
removeAttachment in interface MutableAttachments
Parameters:
name - the name of the attachment
Returns:
the attachment or null if not present

getAttachment

public Object getAttachment(String name)
Description copied from interface: Attachments
Get attachment

Specified by:
getAttachment in interface Attachments
Parameters:
name - the name of the attachment
Returns:
the attachment or null if not present

getAttachments

public Map<String,Object> getAttachments()
Description copied from interface: Attachments
Get all the attachments

Specified by:
getAttachments in interface Attachments
Returns:
the unmodifiable attachments

hasAttachments

public boolean hasAttachments()
Description copied from interface: Attachments
Are there any attachments

Specified by:
hasAttachments in interface Attachments
Returns:
true if there are any attachments, false otherwise.

isAttachmentPresent

public boolean isAttachmentPresent(String name)
Description copied from interface: Attachments
Is the attachment present

Specified by:
isAttachmentPresent in interface Attachments
Parameters:
name - the name of the attachment
Returns:
true when the attachment is present

getResourceClassLoader

public ClassLoader getResourceClassLoader()
Description copied from interface: DeploymentUnit
Get a resource classloader

Specified by:
getResourceClassLoader in interface DeploymentUnit
Returns:
the resource classloader loader

getResourceLoader

public DeploymentResourceLoader getResourceLoader()
Description copied from interface: DeploymentUnit
Get a resource loader

Specified by:
getResourceLoader in interface DeploymentUnit
Returns:
the resource loader

addIDependOn

public void addIDependOn(org.jboss.dependency.spi.DependencyItem dependency)
Description copied from interface: DeploymentUnit
Add a dependency

Specified by:
addIDependOn in interface DeploymentUnit
Parameters:
dependency - the dependency to add

visit

public void visit(DeploymentUnitVisitor visitor)
           throws DeploymentException
Description copied from interface: DeploymentUnit
Visit the unit and the children

Specified by:
visit in interface DeploymentUnit
Parameters:
visitor - the visitor
Throws:
DeploymentException - for any error in the visitor

getControllerContextName

public Object getControllerContextName()
Description copied from interface: DeploymentUnit
Get underlying controller context name.

Specified by:
getControllerContextName in interface DeploymentUnit
Returns:
the controller context name

setRequiredStage

public void setRequiredStage(DeploymentStage stage)
Description copied from interface: DeploymentUnit
Set the required stage.

Specified by:
setRequiredStage in interface DeploymentUnit
Parameters:
stage - the required stage

getDependencyInfo

public org.jboss.dependency.spi.DependencyInfo getDependencyInfo()
Description copied from interface: DeploymentUnit
Get the dependency info

Specified by:
getDependencyInfo in interface DeploymentUnit
Returns:
the dependency

removeIDependOn

public void removeIDependOn(org.jboss.dependency.spi.DependencyItem dependency)
Description copied from interface: DeploymentUnit
Remove a dependency

Specified by:
removeIDependOn in interface DeploymentUnit
Parameters:
dependency - the dependency to remove

getMainDeployer

public MainDeployer getMainDeployer()
Description copied from interface: DeploymentUnit
Get the main deployer

Specified by:
getMainDeployer in interface DeploymentUnit
Returns:
the deployer or null if not associated with a main deployer

getDeploymentContext

protected DeploymentContext getDeploymentContext()
Get the deployment context

Returns:
the deployment context

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class AbstractAttachments
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class AbstractAttachments
Parameters:
out - the output
Throws:
IOException - for any error

toString

public String toString()
Overrides:
toString in class Object


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