Skip to content

Commit

Permalink
Simple container now adds ClassLoaderIntercepter to services.
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Jan 23, 2014
1 parent 8b6f751 commit 8abf050
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.jboss.forge.furnace.Furnace;
import org.jboss.forge.furnace.addons.Addon;
import org.jboss.forge.furnace.exception.ContainerException;
import org.jboss.forge.furnace.proxy.ClassLoaderInterceptor;
import org.jboss.forge.furnace.proxy.Proxies;
import org.jboss.forge.furnace.spi.ExportedInstance;

/**
Expand All @@ -33,22 +35,25 @@ public SimpleExportedInstanceImpl(Furnace furnace, Addon addon, Class<T> clazz)
@Override
public T get()
{
T delegate = null;
try
{
try
{
Constructor<T> constructor = type.getConstructor(Furnace.class);
return constructor.newInstance(furnace);
delegate = constructor.newInstance(furnace);
}
catch (NoSuchMethodException e)
{
return type.newInstance();
delegate = type.newInstance();
}
}
catch (Exception e)
{
throw new ContainerException("Could not create instance of [" + type.getName() + "] through reflection.", e);
}
return Proxies.enhance(addon.getClassLoader(), delegate, new ClassLoaderInterceptor(addon.getClassLoader(),
delegate));
}

@Override
Expand Down

0 comments on commit 8abf050

Please sign in to comment.