Skip to content

Commit

Permalink
Use pass ArchiveModelPointer's to the object from the rule provider
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraZizka committed Jun 16, 2014
1 parent 8095bd9 commit 7991f3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Expand Up @@ -2,9 +2,7 @@

import java.util.HashMap;
import java.util.Map;
import javax.inject.Inject;
import org.apache.commons.lang.StringUtils;
import org.jboss.forge.furnace.Furnace;
import org.jboss.forge.furnace.services.Imported;
import org.jboss.windup.config.GraphRewrite;
import org.jboss.windup.config.selectables.SelectionFactory;
Expand All @@ -17,22 +15,23 @@

public class ConfigureArchiveTypes extends AbstractIterationOperator<ArchiveModel>
{
//private @Inject Imported<ArchiveModelPointer> archiveModelPointers;

private @Inject Furnace furnace;
//@Inject
private Imported<ArchiveModelPointer> archiveModelPointers;

private HashMap<String, Class> suffixToModelClass;


public ConfigureArchiveTypes(String variableName)

public ConfigureArchiveTypes(String variableName, Imported<ArchiveModelPointer> archiveModelPointers)
{
super(ArchiveModel.class, variableName);
this.archiveModelPointers = archiveModelPointers;
}


public static ConfigureArchiveTypes forVar(String variableName)
public static ConfigureArchiveTypes forVar(String variableName, Imported<ArchiveModelPointer> archiveModelPointers)
{
return new ConfigureArchiveTypes(variableName);
return new ConfigureArchiveTypes(variableName, archiveModelPointers);
}


Expand Down Expand Up @@ -71,9 +70,9 @@ else if (StringUtils.endsWith(filename, ".ear"))


private void initTypes() {
Imported<ArchiveModelPointer> pointers = furnace.getAddonRegistry().getServices(ArchiveModelPointer.class);
//Imported<ArchiveModelPointer> pointers = FurnaceHolder.getFurnace().getAddonRegistry().getServices(ArchiveModelPointer.class);

for( ArchiveModelPointer ptr : pointers ) {
for( ArchiveModelPointer ptr : this.archiveModelPointers ) {
this.suffixToModelClass.put( ptr.getArchiveFileSuffix(), ptr.getModelClass() );
}
}
Expand Down
@@ -1,6 +1,8 @@
package org.jboss.windup.rules.apps.java.scan.provider;

import java.util.List;
import javax.inject.Inject;
import org.jboss.forge.furnace.services.Imported;

import org.jboss.windup.config.RulePhase;
import org.jboss.windup.config.WindupConfigurationProvider;
Expand All @@ -9,11 +11,13 @@
import org.jboss.windup.config.operation.ruleelement.ConfigureArchiveTypes;
import org.jboss.windup.graph.GraphContext;
import org.jboss.windup.graph.model.ArchiveModel;
import org.jboss.windup.graph.model.ArchiveModelPointer;
import org.ocpsoft.rewrite.config.Configuration;
import org.ocpsoft.rewrite.config.ConfigurationBuilder;

public class ArchiveTypingConfigurationProvider extends WindupConfigurationProvider
{
private @Inject Imported<ArchiveModelPointer> archiveModelPointers;

@Override
public RulePhase getPhase()
Expand All @@ -38,7 +42,7 @@ public Configuration getConfiguration(GraphContext context)
.perform(
Iteration.over("archives").var("archive")
.perform(
ConfigureArchiveTypes.forVar("archive")
ConfigureArchiveTypes.forVar("archive", this.archiveModelPointers)
).endIteration()
);
}
Expand Down

0 comments on commit 7991f3b

Please sign in to comment.