Skip to content

Commit

Permalink
Addition of SarStructureProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomek Adamski authored and bstansberry committed Feb 12, 2013
1 parent 42467a0 commit 23c995f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
12 changes: 12 additions & 0 deletions sar/src/main/java/org/jboss/as/service/SarMessages.java
Expand Up @@ -164,4 +164,16 @@ public interface SarMessages {
*/
@Message(id = 17229, value = "Unexpected content of type '%s' named '%s', text is: %s")
String unexpectedContent(String kind, QName name, String text);

/**
* Creates an exception indicating a failure to process the resource adapter child archives for the deployment root
* represented by the {@code deploymentRoot} parameter.
*
* @param cause the cause of the error.
* @param deploymentRoot the deployment root.
*
* @return a {@link DeploymentUnitProcessingException} for the error.
*/
@Message(id = 17230, value = "Failed to process SAR child archives for [%s]")
DeploymentUnitProcessingException failedToProcessSarChild(@Cause Throwable cause, VirtualFile deploymentRoot);
}
27 changes: 14 additions & 13 deletions sar/src/main/java/org/jboss/as/service/SarStructureProcessor.java
Expand Up @@ -21,23 +21,24 @@
import org.jboss.vfs.util.SuffixMatchFilter;

public class SarStructureProcessor implements DeploymentUnitProcessor {

private static final String SAR_EXTENSION = ".sar";
private static final String JAR_EXTENSION = ".jar";

private static final SuffixMatchFilter CHILD_ARCHIVE_FILTER = new SuffixMatchFilter(JAR_EXTENSION, VisitorAttributes.RECURSE_LEAVES_ONLY);

private static final SuffixMatchFilter CHILD_ARCHIVE_FILTER = new SuffixMatchFilter(JAR_EXTENSION,
VisitorAttributes.RECURSE_LEAVES_ONLY);

private static Closeable NO_OP_CLOSEABLE = new Closeable() {
public void close() throws IOException {
// NO-OP
}
};
public void close() throws IOException {
// NO-OP
}
};

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ResourceRoot resourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
if(resourceRoot == null) {
if (resourceRoot == null) {
return;
}
final VirtualFile deploymentRoot = resourceRoot.getRoot();
Expand All @@ -49,9 +50,9 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
if (!deploymentRootName.endsWith(SAR_EXTENSION)) {
return;
}

ModuleRootMarker.mark(resourceRoot, true);

try {
final List<VirtualFile> childArchives = deploymentRoot.getChildren(CHILD_ARCHIVE_FILTER);

Expand All @@ -67,14 +68,14 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
} catch (IOException e) {
SarMessages.MESSAGES.failedToProcessSarChild(e, deploymentRoot);
}

}

@Override
public void undeploy(DeploymentUnit context) {
final List<ResourceRoot> childRoots = context.removeAttachment(Attachments.RESOURCE_ROOTS);
if(childRoots != null) {
for(ResourceRoot childRoot : childRoots) {
if (childRoots != null) {
for (ResourceRoot childRoot : childRoots) {
VFSUtils.safeClose(childRoot.getMountHandle());
}
}
Expand Down
Expand Up @@ -53,6 +53,7 @@ protected void performBoottime(OperationContext context, ModelNode operation, Mo
context.addStep(new AbstractDeploymentChainStep() {
public void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(SarExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_SAR_SUB_DEPLOY_CHECK, new SarSubDeploymentProcessor());
processorTarget.addDeploymentProcessor(SarExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_SAR, new SarStructureProcessor());
processorTarget.addDeploymentProcessor(SarExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_SAR_MODULE, new SarModuleDependencyProcessor());
processorTarget.addDeploymentProcessor(SarExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_SERVICE_DEPLOYMENT, new ServiceDeploymentParsingProcessor());
processorTarget.addDeploymentProcessor(SarExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_SAR_SERVICE_COMPONENT, new ServiceComponentProcessor());
Expand Down
Expand Up @@ -216,6 +216,7 @@ public AttachmentKey<?> getPhaseKey() {
public static final int STRUCTURE_MANAGED_BEAN_JAR_IN_EAR = 0x1400;
public static final int STRUCTURE_BUNDLE_SUB_DEPLOYMENT = 0x1450;
public static final int STRUCTURE_SAR_SUB_DEPLOY_CHECK = 0x1500;
public static final int STRUCTURE_SAR = 0x1500;
public static final int STRUCTURE_ADDITIONAL_MANIFEST = 0x1600;
public static final int STRUCTURE_SUB_DEPLOYMENT = 0x1700;
public static final int STRUCTURE_JBOSS_DEPLOYMENT_STRUCTURE = 0x1800;
Expand Down

0 comments on commit 23c995f

Please sign in to comment.