Skip to content

Commit

Permalink
WINDUP-487: Document RulePhase implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
jsight committed Jan 28, 2015
1 parent a8b05ad commit 968ea50
Show file tree
Hide file tree
Showing 20 changed files with 153 additions and 9 deletions.
Expand Up @@ -5,7 +5,12 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link Discovery}<br/>
* Next: {@link ArchiveMetadataExtraction}
*
* <p>
* Unzipping of any input files (such as an incoming ear file) occur during this phase.
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,8 +5,13 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link ArchiveExtraction}<br />
* Next: {@link ClassifyFileTypes}
*
* <p>
* Occurs immediately after archive extraction. This handles things like calculating checksums for archives or determining the specific type of
* archive (ear vs other types of archives).
* </p>
*
*/
public class ArchiveMetadataExtraction extends RulePhase
Expand Down
Expand Up @@ -5,8 +5,14 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link ArchiveMetadataExtraction}<br/>
* Next: {@link Decompilation}<br/>
*
* <p>
* This scans files and attaches metadata to them. For example, this may find all of the Java files in an application and mark them as Java, or it may
* find all of the bash scripts in an input and identify them appropriately.
* </p>
* .
*
*/
public class ClassifyFileTypes extends RulePhase
Expand Down
Expand Up @@ -5,17 +5,22 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link ClassifyFileTypes}<br/>
* Next: {@link DiscoverProjectStructure}
*
* <p>
* Any required decompilation of an input application would occur during this phase.
* </p>
*
* @author jsightler
*
*/
public class DecompilationPhase extends RulePhase
public class Decompilation extends RulePhase
{

@Override
public List<Class<? extends WindupRuleProvider>> getExecuteAfter()
{
return asClassList(ArchiveMetadataExtraction.class);
return asClassList(ClassifyFileTypes.class);
}
}
Expand Up @@ -5,7 +5,13 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Discovering of the project structure of the input application will occur during this phase.
* Previous: {@link Decompilation}<br/>
* Next: {@link InitialAnalysis}
*
* <p>
* Discovering of the project structure of the input application will occur during this phase. This will discover which files are in which project
* (including determining subprojects) and analyze as much metadata as possible for supported project types (for example, Maven projects).
* </p>
*
* @author jsightler
*
Expand All @@ -16,6 +22,6 @@ public class DiscoverProjectStructure extends RulePhase
@Override
public List<Class<? extends WindupRuleProvider>> getExecuteAfter()
{
return asClassList(ClassifyFileTypes.class);
return asClassList(Decompilation.class);
}
}
Expand Up @@ -5,7 +5,12 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link Initialization}<br/>
* Next: {@link ArchiveExtraction}
*
* <p>
* This discovers files from the input (for example, find all of the files in the input directory).
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,8 +5,13 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link PostReportRendering}<br/>
* Next: {@link PostFinalize}
*
* <p>
* This occurs at the end of execution. {@link Rule}s in this phase are responsible for any cleanup of resources that may have been opened during
* {@link Rule}s from earlier {@link WindupRuleProvider}s.
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,9 +5,14 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link DiscoverProjectStructure}<br/>
* Next: {@link MigrationRules}
*
* <p>
* This phase occurs after the application has been unzipped, files have been discovered (including basic filetype information), and the project
* structure has been ascertained. {@link Rule}s from this phase will perform tasks such as the analysis of source code for placement within the graph
* (for use by later {@link Rule}s).
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,8 +5,13 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link ArchiveExtraction}<br/>
* Next: {@link Discovery}
*
* <p>
* This is the first phase of Windup Execution. Initialization related tasks (such as copying configuration data to the graph) should occur during
* this phase.
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,8 +5,13 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link InitialAnalysis}<br/>
* Next: {@link PostMigrationRules}
*
* <p>
* Most {@link Rule}s will go in this {@link RulePhase}. These include {@link Rule}s that detect code in the source application (or server) that will
* need to be changed and produce metadata to be reported on regarding these changes.
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,13 +5,17 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link Finalize}
*
* <p>
* This occurs immediately after finalize. This is an ideal place to put {@link Rule}s that would like to be the absolute last things to fire.
* Examples:
*
* <ul>
* <li>Reporting on the execution time of previous rules</li>
* <li>Reporting on all of the rules that have executed and which {@link WindupRuleProvider}s executed them</li>
* </ul>
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,7 +5,13 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* This occurs immediately after {@link MigrationRules}.
* Previous: {@link MigrationRules}<br/>
* Next: {@link PreReportGeneration}
*
* <p>
* This occurs immediately after {@link MigrationRules}. This can be used in cases where some rule wants to execute immediately after all other
* migration rules. The primary use case at the moment involves unit tests.
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,8 +5,13 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link ReportGeneration}<br/>
* Next: {@link ReportRendering}
*
* <p>
* This occurs immediately after the main tasks of report generation. This can be used to generate reports that will need data from all of the other
* reports that have been previously generated.
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,8 +5,13 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link ReportRendering}<br/>
* Next: {@link Finalize}
*
* <p>
* This occurs immediately after reports have been rendered. It can be used to render any reports that need to execute last. One possible use is to
* render all of the contents of the graph itself.
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,8 +5,13 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link PostMigrationRules}<br/>
* Next: {@link ReportGeneration}
*
* <p>
* This occurs immediately before {@link ReportGeneration} and can be used for initialization related tasks that will be needed by all reports during
* {@link ReportGeneration}.
* </p>
*
* @author jsightler
*
Expand All @@ -17,6 +22,6 @@ public class PreReportGeneration extends RulePhase
@Override
public List<Class<? extends WindupRuleProvider>> getExecuteAfter()
{
return asClassList(MigrationRules.class);
return asClassList(PostMigrationRules.class);
}
}
Expand Up @@ -5,7 +5,12 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link PreReportGeneration}<br/>
* Next: {@link PostReportGeneration}
*
* <p>
* During this phase, report information will be gathered and stored in the graph.
* </p>
*
* @author jsightler
*
Expand Down
Expand Up @@ -5,7 +5,12 @@
import org.jboss.windup.config.WindupRuleProvider;

/**
* Previous: {@link PostReportGeneration}<br/>
* Next: {@link PostReportRendering}
*
* <p>
* Reports will be rendered to the disk during this phase.
* </p>
*
* @author jsightler
*
Expand Down
@@ -0,0 +1,51 @@
package org.jboss.windup.reporting.freemarker;

import java.util.List;

import org.jboss.windup.config.GraphRewrite;
import org.jboss.windup.config.phase.RulePhase;

import freemarker.ext.beans.StringModel;
import freemarker.template.TemplateModelException;

/**
* Returns true if the passed in object is a and instanceof {@link RulePhase}.<br/>
*
* isRulePhase(Object):boolean
*
*/
public class IsRulePhaseMethod implements WindupFreeMarkerMethod
{

@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException
{
if (arguments.size() != 1)
{
throw new TemplateModelException(
"Error, method expects one argument (Object)");
}
StringModel stringModel = (StringModel) arguments.get(0);
Object object = stringModel.getWrappedObject();
return object instanceof RulePhase;
}

@Override
public String getMethodName()
{
return "isRulePhase";
}

@Override
public String getDescription()
{
return "Returns true if the passed in object is an instance of " + RulePhase.class.getSimpleName() + ".";
}

@Override
public void setContext(GraphRewrite event)
{

}

}
Expand Up @@ -51,9 +51,14 @@
<!-- All Rule Providers -->
<div class="panel panel-primary">
<#list getAllRuleProviders() as ruleProvider>
<#if isRulePhase(ruleProvider)>
<div class="panel-heading">
<h3 class="panel-title">Phase: ${ruleProvider.ID}</h3>
</div>
<#else>
<div class="panel-heading">
<h3 class="panel-title">${ruleProvider.ID}</h3>
Phase: ${ruleProvider.phase?replace("_", " ")?capitalize}
Phase: ${ruleProvider.phase.simpleName}
</div>
<table class="table table-striped table-bordered">
<tr>
Expand Down Expand Up @@ -100,6 +105,7 @@
</#if>
</#list>
</table>
</#if>
</#list>
</div>

Expand Down
Expand Up @@ -5,7 +5,7 @@
import org.jboss.windup.config.operation.Commit;
import org.jboss.windup.config.operation.IterationProgress;
import org.jboss.windup.config.operation.Log;
import org.jboss.windup.config.phase.DecompilationPhase;
import org.jboss.windup.config.phase.Decompilation;
import org.jboss.windup.config.phase.RulePhase;
import org.jboss.windup.config.query.Query;
import org.jboss.windup.config.query.QueryGremlinCriterion;
Expand All @@ -27,7 +27,7 @@ public class DecompileArchivesRuleProvider extends WindupRuleProvider
@Override
public Class<? extends RulePhase> getPhase()
{
return DecompilationPhase.class;
return Decompilation.class;
}

// @formatter:off
Expand Down

0 comments on commit 968ea50

Please sign in to comment.