Skip to content

Commit

Permalink
Added InputComponentInjectionEnricher
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Sep 14, 2013
1 parent 5f7adda commit a3c1f99
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.addon.ui.input;

import javax.enterprise.inject.spi.InjectionPoint;

import org.jboss.forge.furnace.services.Exported;

/**
* Enriches an injected {@link InputComponent}
*
* @author <a href="ggastald@redhat.com">George Gastaldi</a>
*/
@Exported
public interface InputComponentInjectionEnricher
{
public void enrich(InjectionPoint injectionPoint, InputComponent<?, ?> input);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.jboss.forge.addon.ui.hints.InputType;
import org.jboss.forge.addon.ui.impl.facets.HintsFacetImpl;
import org.jboss.forge.addon.ui.input.InputComponent;
import org.jboss.forge.addon.ui.input.InputComponentInjectionEnricher;
import org.jboss.forge.addon.ui.input.SelectComponent;
import org.jboss.forge.addon.ui.input.UIInput;
import org.jboss.forge.addon.ui.input.UIInputMany;
Expand All @@ -45,14 +46,16 @@
*/
public class InputComponentProducer implements InputComponentFactory
{
private Environment environment;
private AddonRegistry addonRegistry;
private final AddonRegistry addonRegistry;
private final Environment environment;
private final Imported<InputComponentInjectionEnricher> enrichers;

@Inject
public InputComponentProducer(Environment environment, AddonRegistry addonRegistry)
public InputComponentProducer(AddonRegistry addonRegistry)
{
this.environment = environment;
this.addonRegistry = addonRegistry;
this.environment = addonRegistry.getServices(Environment.class).get();
this.enrichers = addonRegistry.getServices(InputComponentInjectionEnricher.class);
}

@Produces
Expand All @@ -73,6 +76,10 @@ public <T> UISelectOne<T> produceSelectOne(InjectionPoint injectionPoint)
UISelectOne<T> input = createSelectOne(name, shortName, valueType);
setupSelectComponent(input);
preconfigureInput(input, withAttributes);
for (InputComponentInjectionEnricher enricher : enrichers)
{
enricher.enrich(injectionPoint, input);
}
return input;
}
else
Expand Down Expand Up @@ -100,6 +107,10 @@ public <T> UISelectMany<T> produceSelectMany(InjectionPoint injectionPoint)
UISelectMany<T> input = createSelectMany(name, shortName, valueType);
setupSelectComponent(input);
preconfigureInput(input, withAttributes);
for (InputComponentInjectionEnricher enricher : enrichers)
{
enricher.enrich(injectionPoint, input);
}
return input;
}
else
Expand All @@ -125,6 +136,10 @@ public <T> UIInput<T> produceInput(InjectionPoint injectionPoint)
char shortName = (withAttributes == null) ? InputComponents.DEFAULT_SHORT_NAME : withAttributes.shortName();
UIInput<T> input = createInput(name, shortName, valueType);
preconfigureInput(input, withAttributes);
for (InputComponentInjectionEnricher enricher : enrichers)
{
enricher.enrich(injectionPoint, input);
}
return input;
}
else
Expand All @@ -151,6 +166,10 @@ public <T> UIInputMany<T> produceInputMany(InjectionPoint injectionPoint)
char shortName = (withAttributes == null) ? InputComponents.DEFAULT_SHORT_NAME : withAttributes.shortName();
UIInputMany<T> input = createInputMany(name, shortName, valueType);
preconfigureInput(input, withAttributes);
for (InputComponentInjectionEnricher enricher : enrichers)
{
enricher.enrich(injectionPoint, input);
}
return input;
}
else
Expand Down

0 comments on commit a3c1f99

Please sign in to comment.