Skip to content

Commit

Permalink
FORGE-2221: Indication Forge is loading in console
Browse files Browse the repository at this point in the history
Signed-off-by: George Gastaldi <gegastaldi@gmail.com>
  • Loading branch information
danielsoro authored and gastaldi committed Apr 27, 2015
1 parent 36c3ffb commit 4d4f40a
Showing 1 changed file with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
import org.jboss.forge.furnace.Furnace;
import org.jboss.forge.furnace.exception.ContainerException;
import org.jboss.forge.furnace.spi.ContainerLifecycleListener;
import org.jboss.forge.furnace.versions.EmptyVersion;
import org.jboss.forge.furnace.versions.SingleVersion;
import org.jboss.forge.furnace.versions.Version;
import org.jboss.forge.furnace.versions.Versions;

public class GreetingListener implements ContainerLifecycleListener
{
private final Logger logger = Logger.getLogger(getClass().getName());
private volatile boolean showProgress = true;

@Override
public void beforeStart(Furnace furnace) throws ContainerException
Expand All @@ -44,13 +42,14 @@ public void beforeStart(Furnace furnace) throws ContainerException
out.println();
logger.info(sw.toString());
System.out.println(sw.toString());
shellProgressInformation();
}
}

@Override
public void afterStart(Furnace furnace) throws ContainerException
{
// Do nothing
showProgress = false;
}

@Override
Expand All @@ -76,4 +75,32 @@ public void afterConfigurationScan(Furnace furnace) throws ContainerException
{
// Do nothing
}

private void shellProgressInformation()
{
new Thread()
{

@Override
public void run()
{
String anim = "|/-\\";
int x = 0;
while (showProgress)
{
x++;
String data = "\r" + anim.charAt(x % anim.length());
try
{
System.out.write(data.getBytes());
Thread.sleep(50);
}
catch (Exception e)
{
break;
}
}
}
}.start();
}
}

0 comments on commit 4d4f40a

Please sign in to comment.