Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2009, Red Hat Middleware LLC, and individual contributors
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.jboss.as.arquillian.container.embedded;
 
 import  org.jboss.arquillian.spi.ContainerMethodExecutor;
 import  org.jboss.arquillian.spi.Context;
 import  org.jboss.arquillian.spi.LifecycleException;
 
 import java.io.File;
JBossASEmbeddedContainer

Author(s):
Thomas.Diesler@jboss.com
Kabir Khan
Since:
17-Nov-2010
 
     private StandaloneServer server;
 
     @Override
     public void start(Context contextthrows LifecycleException {
         try {
             String jbossHomeKey = "jboss.home";
             String jbossHomeProp = System.getProperty(jbossHomeKey);
             if (jbossHomeProp == null)
                 throw new IllegalStateException("Cannot find system property: " + jbossHomeKey);
 
             File jbossHomeDir = new File(jbossHomeProp).getAbsoluteFile();
             if (jbossHomeDir.isDirectory() == false)
                 throw new IllegalStateException("Invalid jboss home directory: " + jbossHomeDir);
 
             File modulesJar = new File(jbossHomeDir + "/jboss-modules.jar");
             if (modulesJar.exists() == false)
                 throw new IllegalStateException("Cannot find: " + modulesJar);
 
             Properties sysprops = new Properties();
             sysprops.putAll(System.getProperties());
             sysprops.setProperty("jboss.home.dir"jbossHomeDir.getAbsolutePath());
             sysprops.setProperty("java.util.logging.manager""org.jboss.logmanager.LogManager");
             sysprops.setProperty("logging.configuration""file:" + jbossHomeDir + "/standalone/configuration/logging.properties");
             sysprops.setProperty("org.jboss.boot.log.file"jbossHomeDir + "/standalone/log/boot.log");
 
 
              = EmbeddedServerFactory.create(jbossHomeDirsysprops, System.getenv(), getSystemPackages(sysprops"org.jboss.logmanager"));
             .start();
 
             waitForMBean(., 5000);
 
         } catch (Throwable th) {
             throw handleStartThrowable(th);
         }
     }
 
     private String[] getSystemPackages(Properties propsString...packages) {
         if (Boolean.valueOf(props.getProperty("org.jboss.surefire.modular"..toString()))){
             //The forked surefire plugin passes in this property, so we don't need system packages to work
             return new String[0];
         }
         return packages;
     }
 
     @Override
     public void stop(Context contextthrows LifecycleException {
         try {
             if ( != null)
                 .stop();
         } catch (Exception e) {
             throw new LifecycleException("Could not stop container"e);
         }
     }
 
     @Override
        return ManagementFactory.getPlatformMBeanServer();
    }
    @Override
    protected ContainerMethodExecutor getContainerMethodExecutor() {
    }
    private LifecycleException handleStartThrowable(Throwable ththrows LifecycleException {
        if (th instanceof UndeclaredThrowableException)
        if (th instanceof InvocationTargetException)
            throw handleStartThrowable(((InvocationTargetExceptionth).getTargetException());
        if (th instanceof RuntimeException)
            throw (RuntimeExceptionth;
        return new LifecycleException("Could not start container"th);
    }
New to GrepCode? Check out our FAQ X