Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.nohope.test.glassfish;
  
  
 import java.io.File;
 import java.util.List;

Date: 2/11/14 Time: 1:34 PM
 
 public class GlassfishAppBuilder {
     private int port;
     private final GlassFishApplication.WebApp war;
     private final List<Commandcommands = new ArrayList<>();
 
 
         this. = SocketUtils.getAvailablePort();
         this. = app;
     }
 
     public GlassfishAppBuilder(final File war) {
         this(new GlassFishApplication.War(war));
     }
 
     public GlassfishAppBuilder(final String archiveName) {
         this(new GlassFishApplication.ScatteredWar(new ScatteredArchive(archiveName..)));
     }
 
     public GlassfishAppBuilder setPort(final int port) {
         this. = port;
         return this;
     }
 
     public GlassfishAppBuilder addCommand(final String commandfinal String... args) {
         .add(new Command(commandargs));
         return this;
     }
 
     public GlassfishAppBuilder addCommands(final List<Commandcommand) {
         .addAll(command);
         return this;
     }
 
 
     public GlassfishAppBuilder addMetadata(final String path) {
         checkAppType();
         addMetadata(pathnull);
         return this;
     }
 
     private void checkAppType() {
         if (!( instanceof GlassFishApplication.ScatteredWar)) {
             throw new IllegalStateException("This method may only be called for Scattered Archive!");
         }
     }
 
     public GlassfishAppBuilder addMetadata(final String pathfinal String name) {
         checkAppType();
         final File file = new File(path);
         if (!file.exists()) {
             throw new IllegalStateException(TStr.format("File does not exist: {}"file.getAbsolutePath()));
         }
 
         final ScatteredArchive arch = ((GlassFishApplication.ScatteredWar).getArchive();
 
         try {
             if (name == null) {
                 arch.addMetadata(file);
             } else {
                 arch.addMetadata(filename);
             }
         } catch (final IOException e) {
             throw new IllegalArgumentException(e);
         }
 
         return this;
     }
 
     public GlassfishAppBuilder addClassPath(final String path) {
         checkAppType();
         try {
             ((GlassFishApplication.ScatteredWar).getArchive().addClassPath(new File(path));
         } catch (final IOException e) {
             throw new IllegalArgumentException(e);
         }
         return this;
     }
 
     public GlassFishApplication build() {
         final GlassFishProperties props = new GlassFishProperties();
        props.setPort("http-listener");
        try {
            return new GlassFishApplication(props);
        } catch (final GlassFishException e) {
            throw new IllegalArgumentException(e);
        }
    }
New to GrepCode? Check out our FAQ X