Java Code Examples for org.jboss.shrinkwrap.descriptor.api.Descriptors#create()

The following examples show how to use org.jboss.shrinkwrap.descriptor.api.Descriptors#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceAdapterFactory.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create the work.rar deployment
 *
 * @param bc The BootstrapContext name; <code>null</code> if default
 * @return The resource adapter descriptor
 */
public static ResourceAdaptersDescriptor createWorkDeployment(String bc)
{
   ResourceAdaptersDescriptor dashRaXml = Descriptors.create(ResourceAdaptersDescriptor.class, "work-ra.xml");

   ResourceAdapterType dashRaXmlRt = dashRaXml.createResourceAdapter().archive("work.rar");
   if (bc != null)
      dashRaXmlRt.bootstrapContext(bc);
   ConnectionDefinitionsType dashRaXmlCdst = dashRaXmlRt.getOrCreateConnectionDefinitions();
   org.ironjacamar.embedded.dsl.resourceadapters20.api.ConnectionDefinitionType dashRaXmlCdt = dashRaXmlCdst
         .createConnectionDefinition().className(WorkManagedConnectionFactory.class.getName())
         .jndiName("java:/eis/WorkConnectionFactory").id("WorkConnectionFactory");

   org.ironjacamar.embedded.dsl.resourceadapters20.api.PoolType dashRaXmlPt = dashRaXmlCdt.getOrCreatePool()
         .minPoolSize(0).initialPoolSize(0).maxPoolSize(10);

   return dashRaXml;
}
 
Example 2
Source File: ResourceAdapterFactory.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create the work.rar deployment
 *
 * @param bc The BootstrapContext name; <code>null</code> if default
 * @return The resource adapter descriptor
 */
public static ResourceAdaptersDescriptor createWorkDeploymentMCFNoHashCode(String bc)
{
   ResourceAdaptersDescriptor dashRaXml = Descriptors.create(ResourceAdaptersDescriptor.class, "work-ra.xml");

   ResourceAdapterType dashRaXmlRt = dashRaXml.createResourceAdapter().archive("work.rar");
   if (bc != null)
      dashRaXmlRt.bootstrapContext(bc);
   ConnectionDefinitionsType dashRaXmlCdst = dashRaXmlRt.getOrCreateConnectionDefinitions();
   org.ironjacamar.embedded.dsl.resourceadapters20.api.ConnectionDefinitionType dashRaXmlCdt = dashRaXmlCdst
         .createConnectionDefinition().className(WorkManagedConnectionFactoryNoHashCode.class.getName())
         .jndiName("java:/eis/WorkConnectionFactory").id("WorkConnectionFactory");

   org.ironjacamar.embedded.dsl.resourceadapters20.api.PoolType dashRaXmlPt = dashRaXmlCdt.getOrCreatePool()
         .minPoolSize(0).initialPoolSize(0).maxPoolSize(10);

   return dashRaXml;
}
 
Example 3
Source File: EarTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Deployment(testable = false)
public static EnterpriseArchive createDeployment() {

    final WebArchive servletWar = ShrinkWrap.create(WebArchive.class, "servlet.war").addClass(HelloServlet.class);
    final WebArchive jaxRSWar = ShrinkWrap.create(WebArchive.class, "rest.war").addClasses(HelloApplication.class, HelloEndpoint.class);

    final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
            .addAsModule(servletWar)
            .addAsModule(jaxRSWar);


    final ApplicationDescriptor descriptor = Descriptors.create(ApplicationDescriptor.class);
    descriptor.id("TestApplication").description("My Test Application")
            .createModule().getOrCreateWeb().webUri("servlet.war").contextRoot("TestApplication").up().up()
            .createModule().getOrCreateWeb().webUri("rest.war").contextRoot("TestApplication-REST").up().up();

    ear.setApplicationXML(new StringAsset(descriptor.exportAsString()));

    return ear;
}
 
Example 4
Source File: EnableInterceptorsTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive war()
{
    String simpleName = EnableInterceptorsTest.class.getSimpleName();
    String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

    // CDI 1.0/Weld 1.x needs EnableInterceptorsInterceptor
    BeansDescriptor beansWithEnablingInterceptor = Descriptors.create(BeansDescriptor.class);
    beansWithEnablingInterceptor.getOrCreateInterceptors().clazz(EnableInterceptorsInterceptor.class.getName());
    
    // war archive needs MyBeanInterceptor enabled
    BeansDescriptor beans = Descriptors.create(BeansDescriptor.class);
    beans.getOrCreateInterceptors().clazz(MyBeanInterceptor.class.getName());
      
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
            .addPackage(EnableInterceptorsTest.class.getPackage())
            .addAsManifestResource(new StringAsset(beansWithEnablingInterceptor.exportAsString()), "beans.xml");

    return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndProxyArchive())
            .addAsLibraries(testJar)
            .addAsWebInfResource(new StringAsset(beans.exportAsString()), "beans.xml");
}
 
Example 5
Source File: SimpleCacheTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive war()
{
    String simpleName = SimpleCacheTest.class.getSimpleName();
    String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

    // CDI 1.0/Weld 1.x needs EnableInterceptorsInterceptor
    BeansDescriptor beansWithEnablingInterceptor = Descriptors.create(BeansDescriptor.class);
    beansWithEnablingInterceptor.getOrCreateInterceptors().clazz(EnableInterceptorsInterceptor.class.getName());
    
    // war archive needs SimpleCacheInterceptor enabled
    BeansDescriptor beans = Descriptors.create(BeansDescriptor.class);
    beans.getOrCreateInterceptors().clazz(SimpleCacheInterceptor.class.getName());
      
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
            .addPackage(SimpleCacheTest.class.getPackage())
            .addAsManifestResource(new StringAsset(beansWithEnablingInterceptor.exportAsString()), "beans.xml");

    return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndProxyArchive())
            .addAsLibraries(testJar)
            .addAsServiceProvider(Extension.class, SimpleCacheExtension.class)
            .addAsWebInfResource(new StringAsset(beans.exportAsString()), "beans.xml");
}
 
Example 6
Source File: DeploymentFactory.java    From knox with Apache License 2.0 5 votes vote down vote up
private static DeploymentContext createDeploymentContext(
    GatewayConfig config,
    String archivePath,
    Topology topology,
    Map<String,List<ProviderDeploymentContributor>> providers ) {
  archivePath = Urls.encode( archivePath );
  WebArchive webArchive = ShrinkWrap.create( WebArchive.class, archivePath );
  WebAppDescriptor webAppDesc = Descriptors.create( WebAppDescriptor.class );
  GatewayDescriptor gateway = GatewayDescriptorFactory.create();
  return new DeploymentContextImpl(
      config, topology, gateway, webArchive, webAppDesc, providers );
}
 
Example 7
Source File: ConnectorWithApplicationResourcesInWarTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
public static WebArchive createDeployment() {
    final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
    webAppDescriptor.version("3.0");

    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
    webArchive.addPackage("org.superbiz.connector.api");
    webArchive.addPackage("org.superbiz.connector.adapter");
    webArchive.addPackage("org.superbiz.application");
    webArchive.addAsWebInfResource(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/resources.xml"), "resources.xml");
    webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
    System.out.println("Webapp:\n" + webArchive.toString(true));

    return webArchive;
}
 
Example 8
Source File: FutureableTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive deploy()
{
    // create beans.xml with added interceptor
    BeansDescriptor beans = Descriptors.create(BeansDescriptor.class);
    beans.getOrCreateInterceptors().clazz(FutureableInterceptor.class.getName());
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "FutureableTest.jar")
            .addPackage(Service.class.getPackage().getName())
            .addAsManifestResource(new StringAsset(beans.exportAsString()), "beans.xml");

    return ShrinkWrap.create(WebArchive.class, "FutureableTest.war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
            .addAsLibraries(testJar)
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example 9
Source File: LockedTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive deploy()
{
    // create beans.xml with added interceptor
    BeansDescriptor beans = Descriptors.create(BeansDescriptor.class);
    beans.getOrCreateInterceptors().clazz(LockedInterceptor.class.getName());
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "LockedTest.jar")
            .addPackage(Service.class.getPackage().getName())
            .addAsManifestResource(new StringAsset(beans.exportAsString()), "beans.xml");

    return ShrinkWrap.create(WebArchive.class, "LockedTest.war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
            .addAsLibraries(testJar)
            .addAsWebInfResource(new StringAsset(beans.exportAsString()), "beans.xml");
}
 
Example 10
Source File: ResourceAdapterFactory.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create the test.rar deployment
 *
 * @param allocationRetry The number of allocation retries
 * @param validation True is foreground, false is background, null is none
 * @param invalidConnectionFailureCount The invalid connection failure count
 * @param connectionDefID the id of ConnectionDefinition
 * @param adminObjectID the id of AdminObject
 * @param bc the BootstrapContext
 * @return The resource adapter descriptor
 */
public static ResourceAdaptersDescriptor createTestDeployment(int allocationRetry, Boolean validation,
      int invalidConnectionFailureCount, String connectionDefID, String adminObjectID, String bc)
{
   ResourceAdaptersDescriptor dashRaXml = Descriptors.create(ResourceAdaptersDescriptor.class, "test-ra.xml");

   ResourceAdapterType dashRaXmlRt = dashRaXml.createResourceAdapter().archive("test.rar");
   if (bc != null)
      dashRaXmlRt.bootstrapContext(bc);

   ConnectionDefinitionsType dashRaXmlCdst = dashRaXmlRt.getOrCreateConnectionDefinitions();
   org.ironjacamar.embedded.dsl.resourceadapters20.api.ConnectionDefinitionType dashRaXmlCdt = dashRaXmlCdst
      .createConnectionDefinition().className(TestManagedConnectionFactory.class.getName())
      .jndiName("java:/eis/" + connectionDefID).id(connectionDefID);

   if (allocationRetry > 0)
   {
      dashRaXmlCdt.createConfigProperty().name("CreateFailureCount")
         .text(Integer.toString(allocationRetry));

      dashRaXmlCdt.getOrCreateTimeout().allocationRetry(Integer.valueOf(allocationRetry))
         .allocationRetryWaitMillis(100);
   }
   
   if (validation != null)
   {
      dashRaXmlCdt.createConfigProperty().name("InvalidConnectionFailureCount")
         .text(Integer.toString(invalidConnectionFailureCount));

      org.ironjacamar.embedded.dsl.resourceadapters20.api.ValidationType dashRaXmlVt =
         dashRaXmlCdt.getOrCreateValidation();

      if (validation)
      {
         dashRaXmlVt.validateOnMatch(Boolean.TRUE);
      }
      else
      {
         dashRaXmlVt.backgroundValidation(Boolean.TRUE).backgroundValidationMillis(0);
      }
   }

   dashRaXmlRt.getOrCreateAdminObjects().createAdminObject().className(TestAdminObjectImpl.class.getName())
      .jndiName("java:/eis/" + adminObjectID);
   
   return dashRaXml;
}
 
Example 11
Source File: EARTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Deployment
public static EnterpriseArchive createDeployment() {

    final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar");
    apiJar.addPackage("org.superbiz.connector.api");
    System.out.println("API JAR:\n" + apiJar.toString(true));

    final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar");
    implJar.addPackage("org.superbiz.connector.adapter");
    System.out.println("IMPL JAR:\n" + implJar.toString(true));

    final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar");
    rar.addAsLibraries(implJar);

    final File raXml = Basedir.basedir("../connector-sample-rar/src/main/rar/META-INF/ra.xml");
    rar.setResourceAdapterXML(raXml);
    System.out.println("RAR:\n" + rar.toString(true));

    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
    webArchive.addPackage("org.superbiz.application");

    final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
    webAppDescriptor.version("3.0");

    final File resourcesXml = Basedir.basedir("../connector-sample-war/src/main/webapp/WEB-INF/resources.xml");
    webArchive.addAsWebInfResource(resourcesXml);
    webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
    webArchive.addAsWebInfResource(resourcesXml);
    webArchive.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
    System.out.println("Webapp:\n" + webArchive.toString(true));

    final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear");
    enterpriseArchive.addAsLibraries(apiJar);
    enterpriseArchive.addAsModule(rar);
    enterpriseArchive.addAsModule(webArchive);

    ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class);
    applicationXml.displayName("connector-sample-ear");
    applicationXml.createModule()
            .getOrCreateWeb()
                .webUri("connector-sample-war.war")
                .contextRoot("/sample")
            .up().up()
            .createModule().connector("connector-sample-ra.rar")
            .up().libraryDirectory("lib");

    enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString()));
    System.out.println(enterpriseArchive.toString(true));

    return enterpriseArchive;
}
 
Example 12
Source File: DeployInWebAppsDirectoryTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
public static EnterpriseArchive createDeployment() {

        final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar");
        apiJar.addPackage("org.superbiz.connector.api");
        System.out.println("API JAR:\n" + apiJar.toString(true));

        final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar");
        implJar.addPackage("org.superbiz.connector.adapter");
        System.out.println("IMPL JAR:\n" + implJar.toString(true));

        final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar");
        rar.addAsLibraries(implJar);

        final File raXml = Basedir.basedir("../connector-sample-rar/src/main/rar/META-INF/ra.xml");
        rar.setResourceAdapterXML(raXml);
        System.out.println("RAR:\n" + rar.toString(true));

        final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
        webArchive.addPackage("org.superbiz.application");

        final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
        webAppDescriptor.version("3.0");

        final File resourcesXml = Basedir.basedir("../connector-sample-war/src/main/webapp/WEB-INF/resources.xml");
        webArchive.addAsWebInfResource(resourcesXml);
        webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
        webArchive.addAsWebInfResource(resourcesXml);
        webArchive.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
        System.out.println("Webapp:\n" + webArchive.toString(true));

        final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear");
        enterpriseArchive.addAsLibraries(apiJar);
        enterpriseArchive.addAsModule(rar);
        enterpriseArchive.addAsModule(webArchive);

        ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class);
        applicationXml.displayName("connector-sample-ear");
        applicationXml.createModule()
                .getOrCreateWeb()
                .webUri("connector-sample-war.war")
                .contextRoot("/sample")
                .up().up()
                .createModule().connector("connector-sample-ra.rar")
                .up().libraryDirectory("lib");

        enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString()));
        System.out.println(enterpriseArchive.toString(true));

        return enterpriseArchive;
    }
 
Example 13
Source File: EnvEntryTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Deployment
public static JavaArchive getArchive() {

    final EjbJarDescriptor ejbJarDescriptor = Descriptors.create(EjbJarDescriptor.class);
    ejbJarDescriptor.getOrCreateEnterpriseBeans()
        .createMessageDriven()
            .ejbName("RedBean")
            .ejbClass(RedBean.class.getName())
            .messagingType("javax.jms.MessageListener")
            .transactionType("Container")
            .messageDestinationType("javax.jms.Topic")
            .getOrCreateActivationConfig()
                .createActivationConfigProperty()
                    .activationConfigPropertyName("destinationType")
                    .activationConfigPropertyValue("javax.jms.Topic").up()
                .createActivationConfigProperty()
                    .activationConfigPropertyName("destination")
                    .activationConfigPropertyValue("red").up().up()
            .createEnvEntry().envEntryName("color").envEntryType("java.lang.String").envEntryValue("red").up().up()
        .createMessageDriven()
            .ejbName("BlueBean")
            .ejbClass(BlueBean.class.getName())
            .messagingType("javax.jms.MessageListener")
            .transactionType("Container")
            .messageDestinationType("javax.jms.Topic")
            .getOrCreateActivationConfig()
                .createActivationConfigProperty()
                    .activationConfigPropertyName("destinationType")
                    .activationConfigPropertyValue("javax.jms.Topic").up()
                .createActivationConfigProperty()
                    .activationConfigPropertyName("destination")
                    .activationConfigPropertyValue("blue").up().up()
            .createEnvEntry().envEntryName("color").envEntryType("java.lang.String").envEntryValue("blue").up().up()
        .createMessageDriven()
            .ejbName("NoColorBean")
            .ejbClass(NoColorSpecifiedBean.class.getName())
            .messagingType("javax.jms.MessageListener")
            .transactionType("Container")
            .messageDestinationType("javax.jms.Topic")
            .getOrCreateActivationConfig()
                .createActivationConfigProperty()
                    .activationConfigPropertyName("destinationType")
                    .activationConfigPropertyValue("javax.jms.Topic").up()
                .createActivationConfigProperty()
                    .activationConfigPropertyName("destination")
                    .activationConfigPropertyValue("nocolor").up().up();

    final String ejbJarXml = ejbJarDescriptor.exportAsString();


    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "jms-env-entry.jar")
            .addClasses(BaseMdbBean.class, BlueBean.class, Color.class, NoColorSpecifiedBean.class, RedBean.class, MessageBean.class)
            .add(new StringAsset("<beans/>"), "META-INF/beans.xml")
            .add(new StringAsset(ejbJarXml), "META-INF/ejb-jar.xml");

    System.out.println(archive.toString(true));

    return archive;
}
 
Example 14
Source File: ConnectorWithApplicationResourcesInEarTest.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Deployment
public static EnterpriseArchive createDeployment() {

    final JavaArchive apiJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-api.jar");
    apiJar.addPackage("org.superbiz.connector.api");
    System.out.println("API JAR:\n" + apiJar.toString(true));

    final JavaArchive implJar = ShrinkWrap.create(JavaArchive.class, "connector-sample-impl.jar");
    implJar.addPackage("org.superbiz.connector.adapter");
    System.out.println("IMPL JAR:\n" + implJar.toString(true));

    final ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class,"connector-sample-ra.rar");
    rar.addAsLibraries(implJar);

    rar.setResourceAdapterXML(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/ra.xml"));
    System.out.println("RAR:\n" + rar.toString(true));

    final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "connector-sample-war.war");
    webArchive.addPackage("org.superbiz.application");

    final WebAppDescriptor webAppDescriptor = Descriptors.create(WebAppDescriptor.class);
    webAppDescriptor.version("3.0");

    webArchive.addAsWebInfResource(ConnectorWithApplicationResourcesInEarTest.class.getResource("/connector/resources.xml"), "resources.xml");
    webArchive.setWebXML(new StringAsset(webAppDescriptor.exportAsString()));
    System.out.println("Webapp:\n" + webArchive.toString(true));

    final EnterpriseArchive enterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "connector-sample.ear");
    enterpriseArchive.addAsLibraries(apiJar);
    enterpriseArchive.addAsModule(rar);
    enterpriseArchive.addAsModule(webArchive);

    ApplicationDescriptor applicationXml = Descriptors.create(ApplicationDescriptor.class);
    applicationXml.displayName("connector-sample-ear");
    applicationXml.createModule()
            .getOrCreateWeb()
                .webUri("connector-sample-war.war")
                .contextRoot("/sample")
            .up().up()
            .createModule().connector("connector-sample-ra.rar")
            .up().libraryDirectory("lib");

    enterpriseArchive.setApplicationXML(new StringAsset(applicationXml.exportAsString()));
    System.out.println(enterpriseArchive.toString(true));

    return enterpriseArchive;
}