JBoss Embedded AS | API Guide

    Introduction

    The Embedded APIs to JBoss Application Server provide a code-based analouge for tasks ordinarily accomplished through traditional command-line and filesystem operations.  This guide will provide a few of the most often-used examples.

     

    Examples

    Creating a Server (assuming you have all dependencies on your ClassPath) and pointing it to JBOSS_HOME

    JBossASEmbeddedServer server = JBossASEmbeddedServerFactory.createServer();
    server.getConfiguration().jbossHome("/path/to/jbossHome");
    

     

    Deploying Files or URLs

    File[] files = null; // Assume you've got a bunch
    URL[] urls = null; // Keep assuming
    server.deploy(files);
    server.deploy(urls);
    

     

    Deploying a ShrinkWrap Archive

    String name = "slsb.jar";
    JavaArchive archive = ShrinkWrap.create(name, JavaArchive.class).addClasses(OutputBean.class,
          OutputLocalBusiness.class);
    log.info(archive.toString(true));
    // Deploy
    server.deploy(archive);
    

     

    Making Your Own Deployable Type

    // If you can represent it as a URL, you can deploy it in EmbeddedAS
    final Deployable deployable =new Deployable()
    {
       @Override
       public URL getTarget()
       {
          return someUrlIHave;
       }
     };
    server.deploy(deployable);