AnnotationDeployer implements DynamicDeployer { public AppModule deploy(AppModule appModule) throws OpenEJBException { final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(appModule.getClassLoader()); setModule(appModule); try { appModule = discoverAnnotatedBeans.deploy(appModule); appModule = envEntriesPropertiesDeployer.deploy(appModule); appModule = mergeWebappJndiContext.deploy(appModule); appModule = builtInEnvironmentEntries.deploy(appModule); appModule = processAnnotatedBeans.deploy(appModule); appModule = mergeWebappJndiContext.deploy(appModule); appModule = mBeanDeployer.deploy(appModule); return appModule; } finally { envEntriesPropertiesDeployer.resetAdditionalEnvEntries(); Thread.currentThread().setContextClassLoader(classLoader); removeModule(); } } AnnotationDeployer(); AppModule deploy(AppModule appModule); void deploy(CdiBeanInfo beanInfo); WebModule deploy(WebModule webModule); static DeploymentModule getModule(); static boolean isKnownEnvironmentEntryType(Class type); static boolean isShareableJNDINamespace(String jndiName); static List<Annotated<Class<?>>> sortClasses(List<Annotated<Class<?>>> list); static List<Class<?>> sortClassesParentFirst(List<Class<?>> list); static List<Annotated<Method>> sortMethods(List<Annotated<Method>> list); static URL classLocation(Class clazz); EnvEntriesPropertiesDeployer getEnvEntriesPropertiesDeployer(); static final Logger logger; static final Logger startupLogger; static final String OPENEJB_JPA_AUTO_SCAN; static final String OPENEJB_JPA_AUTO_SCAN_PACKAGE; static final Set<String> knownResourceEnvTypes; static final Set<String> knownEnvironmentEntries; }
@Test public void applicationExceptionInheritanceTest() throws Exception { EjbModule ejbModule = testModule(); AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans(); ejbModule = discvrAnnBeans.deploy(ejbModule); AssemblyDescriptor assemblyDescriptor = ejbModule.getEjbJar().getAssemblyDescriptor(); org.apache.openejb.jee.ApplicationException appEx = assemblyDescriptor.getApplicationException(BusinessException.class); assertThat(appEx, notNullValue()); assertThat(appEx.getExceptionClass(), is(BusinessException.class.getName())); assertThat(appEx.isRollback(), is(true)); appEx = assemblyDescriptor.getApplicationException(ValueRequiredException.class); assertThat(appEx, nullValue()); }
@Test public void interceptingGenericBusinessMethodCalls() throws Exception { EjbModule ejbModule = testModule(); EjbJar ejbJar = ejbModule.getEjbJar(); AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans(); ejbModule = discvrAnnBeans.deploy(ejbModule); final EnterpriseBean bean = ejbJar.getEnterpriseBean("InterceptedSLSBean"); assert bean != null; }
@Test public void testLocalBean() throws Exception { EjbModule ejbModule = testModule(); EjbJar ejbJar = ejbModule.getEjbJar(); AppModule appModule = new AppModule(Thread.currentThread().getContextClassLoader(), "myapp"); appModule.getEjbModules().add(ejbModule); AnnotationDeployer annotationDeployer = new AnnotationDeployer(); appModule = annotationDeployer.deploy(appModule); EnterpriseBean bean = ejbJar.getEnterpriseBean("TestLocalBean"); assert bean != null; assert (((SessionBean)bean).getLocalBean() != null); bean = ejbJar.getEnterpriseBean("InterceptedSLSBean"); assert bean != null; assert (((SessionBean)bean).getLocalBean() == null); }
@Test public void testResourceAdapter() throws Exception { ConnectorModule connectorModule = testConnectorModule(); AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans(); discvrAnnBeans.deploy(connectorModule); Connector connector = connectorModule.getConnector(); Assert.assertEquals("displayName", connector.getDisplayName()); Assert.assertEquals("description", connector.getDescription()); Assert.assertEquals("eisType", connector.getEisType()); Assert.assertEquals("vendorName", connector.getVendorName()); Assert.assertEquals("version", connector.getResourceAdapterVersion()); Assert.assertEquals("smallIcon", connector.getIcon().getSmallIcon()); Assert.assertEquals("largeIcon", connector.getIcon().getLargeIcon()); Assert.assertEquals("licenseDescription", connector.getLicense().getDescription()); Assert.assertEquals(true, connector.getLicense().isLicenseRequired()); List<org.apache.openejb.jee.SecurityPermission> securityPermission = connector.getResourceAdapter().getSecurityPermission(); Assert.assertEquals("description", securityPermission.get(0).getDescription()); Assert.assertEquals("permissionSpec", securityPermission.get(0).getSecurityPermissionSpec()); List<String> requiredWorkContext = connector.getRequiredWorkContext(); Assert.assertEquals(TestWorkContext.class.getName(), requiredWorkContext.get(0)); List<org.apache.openejb.jee.AuthenticationMechanism> authenticationMechanism = connector.getResourceAdapter().getOutboundResourceAdapter().getAuthenticationMechanism(); Assert.assertEquals("authMechanism", authenticationMechanism.get(0).getAuthenticationMechanismType()); Assert.assertEquals(CredentialInterface.GenericCredential.toString(), authenticationMechanism.get(0).getCredentialInterface()); Assert.assertEquals("description", authenticationMechanism.get(0).getDescription()); Assert.assertEquals(TransactionSupportType.NO_TRANSACTION, connector.getResourceAdapter().getOutboundResourceAdapter().getTransactionSupport()); Assert.assertEquals(true, connector.getResourceAdapter().getOutboundResourceAdapter().isReauthenticationSupport()); Assert.assertEquals(Connection.class.getName(), connector.getResourceAdapter().getOutboundResourceAdapter().getConnectionDefinition().get(0).getConnectionInterface()); Assert.assertEquals(ConnectionImpl.class.getName(), connector.getResourceAdapter().getOutboundResourceAdapter().getConnectionDefinition().get(0).getConnectionImplClass()); Assert.assertEquals(ConnectionFactory.class.getName(), connector.getResourceAdapter().getOutboundResourceAdapter().getConnectionDefinition().get(0).getConnectionFactoryInterface()); Assert.assertEquals(ConnectionFactoryImpl.class.getName(), connector.getResourceAdapter().getOutboundResourceAdapter().getConnectionDefinition().get(0).getConnectionFactoryImplClass()); Assert.assertEquals(TestActivation.class.getName(), connector.getResourceAdapter().getInboundResourceAdapter().getMessageAdapter().getMessageListener().get(0).getActivationSpec().getActivationSpecClass()); Assert.assertEquals(TestMessageListener.class.getName(), connector.getResourceAdapter().getInboundResourceAdapter().getMessageAdapter().getMessageListener().get(0).getMessageListenerType()); Assert.assertEquals(TestAdminObject.class.getName(), connector.getResourceAdapter().getAdminObject().get(0).getAdminObjectClass()); Assert.assertEquals(TestAdminObjectInterface.class.getName(), connector.getResourceAdapter().getAdminObject().get(0).getAdminObjectInterface()); }