Search in sources :

Example 1 with MBeanInAModuleService

use of org.jboss.as.test.integration.sar.context.classloader.mbean.MBeanInAModuleService in project wildfly by wildfly.

the class MBeanTCCLTestCase method createDeployment.

/**
     * .ear
     * |
     * |---- META-INF/jboss-deployment-structure.xml
     * |
     * |---- .sar
     * |      |
     * |      |--- META-INF/jboss-service.xml (deploys the MBean whose class resides in a separate JBoss module)
     * |      |
     * |      |--- ClassA, ClassB, ClassC, ClassD (all of which will be attempted to be loaded from the MBean class which resides in a different JBoss module than this deployment)
     * |
     * |
     * |---- .jar (configured as a JBoss Module in jboss-deployment-structure.xml of the .ear)
     * |      |
     * |      |---- MBean class (which relies on TCCL to load the classes present in the .sar deployment)
     *
     * @return
     */
@Deployment
public static Archive createDeployment() {
    // create a .sar which will contain a jboss-service.xml. The actual MBean class will reside in a module which will be added as a dependency on the .sar
    final JavaArchive sar = ShrinkWrap.create(JavaArchive.class, SAR_NAME + ".sar");
    // add the jboss-service.xml to the META-INF of the .sar
    sar.addAsManifestResource(MBeanInAModuleService.class.getPackage(), "tccl-test-service.xml", "jboss-service.xml");
    // add some (dummy) classes to the .sar. These classes will then be attempted to be loaded from the MBean class (which resides in a module)
    sar.addClasses(ClassAInSarDeployment.class, ClassBInSarDeployment.class, ClassCInSarDeployment.class, ClassDInSarDeployment.class);
    // now create a plain .jar containing the MBean class. This jar will be configured as a JBoss Module, in the jboss-deployment-structure.xml of the .ear to which this
    // .jar will be added
    final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "jar-containing-mbean-class.jar");
    jar.addClasses(MBeanInAModuleService.class, MBeanInAModuleServiceMBean.class);
    // create the .ear with the .sar and the .jar and the jboss-deployment-structure.xml
    final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME + ".ear");
    ear.addAsModule(sar);
    ear.addAsModule(jar);
    ear.addAsManifestResource(MBeanTCCLTestCase.class.getPackage(), "jboss-deployment-structure.xml", "jboss-deployment-structure.xml");
    ear.addAsManifestResource(createPermissionsXmlAsset(// mbean [wildfly:name=tccl-test-mbean] needs the following permission
    new MBeanTrustPermission("register"), // MBeanInAModuleService#testClassLoadByTCCL() needs the following permission
    new RuntimePermission("getClassLoader")), "permissions.xml");
    return ear;
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) MBeanInAModuleService(org.jboss.as.test.integration.sar.context.classloader.mbean.MBeanInAModuleService) MBeanTrustPermission(javax.management.MBeanTrustPermission) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

MBeanTrustPermission (javax.management.MBeanTrustPermission)1 Deployment (org.jboss.arquillian.container.test.api.Deployment)1 MBeanInAModuleService (org.jboss.as.test.integration.sar.context.classloader.mbean.MBeanInAModuleService)1 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)1 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)1