private boolean hasAtInject(final EjbModule ejbModule) { final IAnnotationFinder finder = ejbModule.getFinder(); return finder != null && (!finder.findAnnotatedFields(Inject.class).isEmpty() || !finder.findAnnotatedConstructors(Inject.class).isEmpty() || !finder.findAnnotatedMethods(Inject.class).isEmpty()); }
@Override public void validate(final EjbModule ejbModule) { if (ejbModule.getBeans() == null) { return; } try { for (final Field field : ejbModule.getFinder().findAnnotatedFields(Inject.class)) { if (!field.getType().equals(InjectionPoint.class) || !HttpServlet.class.isAssignableFrom(field.getDeclaringClass())) { continue; } fail(field.getDeclaringClass().getSimpleName(), "cdi.injectionPointOnNonBean", field.getDeclaringClass().getName(), field.getName()); } } catch (final NoClassDefFoundError noClassDefFoundError) { // ignored: can't check but maybe it is because of an optional dep so ignore it // not important to skip it since the failure will be reported elsewhere // this validator doesn't check it } } }
private void findClassesAnnotatedWithWebService(final EjbModule ejbModule) { final IAnnotationFinder finder = ejbModule.getFinder(); if (finder != null) { findIncorrectAnnotationAndWarn(finder, ejbModule.toString()); } }
@Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { for (final EjbModule module : new ArrayList<>(appModule.getEjbModules())) { if (module.getFinder() == null) { continue; } EjbModule m = null; for (final Class<?> configClass : module.getFinder().findAnnotatedClasses(PersistenceUnitDefinition.class)) { m = m == null ? findModule(appModule, module) : m; configureJpa(appModule, configClass.getAnnotation(PersistenceUnitDefinition.class), m.getFinder()); } for (final Class<?> configClass : module.getFinder().findAnnotatedClasses(PersistenceUnitDefinitions.class)) { for (final PersistenceUnitDefinition persistenceUnitDefinition : configClass.getAnnotation(PersistenceUnitDefinitions.class).value()) { m = m == null ? findModule(appModule, module) : m; configureJpa(appModule, persistenceUnitDefinition, m.getFinder()); } } } return appModule; }
private void findClassesAnnotatedWithWebService(final EjbModule ejbModule) { final IAnnotationFinder finder = ejbModule.getFinder(); if (finder != null) { findIncorrectAnnotationAndWarn(finder, ejbModule.toString()); } }
@Override public void validate(final EjbModule ejbModule) { if (ejbModule.getBeans() == null) { return; } try { for (final Field field : ejbModule.getFinder().findAnnotatedFields(Inject.class)) { if (!field.getType().equals(InjectionPoint.class) || !HttpServlet.class.isAssignableFrom(field.getDeclaringClass())) { continue; } final Annotation[] annotations = field.getAnnotations(); if (annotations.length == 1 || (annotations.length == 2 && field.getAnnotation(Default.class) != null)) { throw new DefinitionException("Can't inject InjectionPoint in " + field.getDeclaringClass()); } // else we should check is there is no other qualifier than @Default but too early } } catch (final NoClassDefFoundError noClassDefFoundError) { // ignored: can't check but maybe it is because of an optional dep so ignore it // not important to skip it since the failure will be reported elsewhere // this validator doesn't check it } } }
public void validate(final EjbModule ejbModule) { if (ejbModule.getFinder() == null || ejbModule.getProperties().containsKey("openejb.cdi.activated")) { return; } if (ejbModule.getBeans() == null && hasAtInject(ejbModule.getFinder())) { warn(ejbModule.getModuleId(), "cdi.notEnabled", ejbModule.getModuleId()); } }
public void validate(final EjbModule ejbModule) { if (ejbModule.getFinder() == null || ejbModule.getProperties().containsKey("openejb.cdi.activated")) { return; } if (ejbModule.getBeans() == null && hasAtInject(ejbModule.getFinder())) { warn(ejbModule.getModuleId(), "cdi.notEnabled", ejbModule.getModuleId()); } }
private EjbModule findModule(final AppModule appModule, final EjbModule module) { EjbModule m = module; if (m.getFinder().findAnnotatedClasses(Entity.class).isEmpty()) { // switch to another module for (final EjbModule other : appModule.getEjbModules()) { if (other == module || other.getFinder() == null) { continue; } m = other; boolean done = false; for (final WebModule web : appModule.getWebModules()) { if (web.getModuleId().equals(other.getModuleId())) { // the biggest module is found, use it done = true; break; } } if (done) { break; } } } return m; }
public AppInfo configureApplication(final File jarFile) throws OpenEJBException { logger.debug("Beginning load: " + jarFile.getAbsolutePath()); try { final AppModule appModule = deploymentLoader.load(jarFile, null); final AppInfo appInfo = configureApplication(appModule); // we need the finder for web scanning so push it to what sees TomcatWebAppBuilder, ie the info tree // this is clean up in Assembler for safety and TomcatWebAppBuilder when used if (!appModule.getWebModules().isEmpty()) { for (final WebAppInfo info : appInfo.webApps) { for (final EjbModule ejbModule : appModule.getEjbModules()) { if (ejbModule.getModuleId().equals(info.moduleId) && ejbModule.getFinder() != null) { appInfo.properties.put(info, ejbModule); } } } } // TODO This is temporary -- we need to do this in AppInfoBuilder appInfo.paths.add(appInfo.path); appInfo.paths.add(jarFile.getAbsolutePath()); return appInfo; } catch (final ValidationFailedException e) { logger.warning("configureApplication.loadFailed", jarFile.getAbsolutePath(), e.getMessage()); // DO not include the stacktrace in the message throw e; } catch (final OpenEJBException e) { // DO NOT REMOVE THE EXCEPTION FROM THIS LOG MESSAGE // removing this message causes NO messages to be printed when embedded logger.warning("configureApplication.loadFailed", e, jarFile.getAbsolutePath(), e.getMessage()); throw e; } }
public static void autoJpa(final EjbModule ejbModule) { final IAnnotationFinder finder = ejbModule.getFinder(); if (ejbModule.getAppModule() != null) { for (final PersistenceModule pm : ejbModule.getAppModule().getPersistenceModules()) { for (final org.apache.openejb.jee.jpa.unit.PersistenceUnit pu : pm.getPersistence().getPersistenceUnit()) { if ((pu.isExcludeUnlistedClasses() == null || !pu.isExcludeUnlistedClasses()) && "true".equalsIgnoreCase(pu.getProperties().getProperty(OPENEJB_JPA_AUTO_SCAN))) { doAutoJpa(finder, pu); } } } } }
@Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { for (final WebModule webModule : appModule.getWebModules()) { if (webModule.getFinder() == null) { continue; } for (final EjbModule ejbModule : appModule.getEjbModules()) { // If they are the same module, they'll have the same finder if (ejbModule.getFinder() != webModule.getFinder()) { continue; } merge(ejbModule, webModule); } } return appModule; }
public void setFinderOnContextConfig(final StandardContext standardContext, final AppModule appModule) { final OpenEJBContextConfig openEJBContextConfig = findOpenEJBContextConfig(standardContext); if (openEJBContextConfig != null) { for (final EjbModule ejbModule : appModule.getEjbModules()) { if (ejbModule.getFile() != null && warPath(standardContext).equals(rootPath(ejbModule.getFile()))) { openEJBContextConfig.finder(ejbModule.getFinder(), ejbModule.getClassLoader()); break; } } } }
destroy(appModule.getEarLibFinder()); for (final EjbModule ejb : appModule.getEjbModules()) { destroy(ejb.getFinder());
webEjbModule.setFinder(finder); } else if (webEjbModule.getFinder() == null) { webEjbModule.setFinder(webModule.getFinder());
webEjbModule.setFinder(finder); } else if (webEjbModule.getFinder() == null) { webEjbModule.setFinder(webModule.getFinder());
@Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { for (final WebModule webModule : appModule.getWebModules()) { if (webModule.getFinder() == null) { continue; } for (final EjbModule ejbModule : appModule.getEjbModules()) { // If they are the same module, they'll have the same finder if (ejbModule.getFinder() != webModule.getFinder()) { final String forceMerge = ejbModule.getProperties().getProperty("openejb.ejbmodule.MergeWebappJndiContext"); // always true is not null if (forceMerge != null) { // default resource propagation for (final EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) { copy(webModule.getWebApp().getResourceEnvRefMap(), bean.getResourceEnvRefMap()); } } continue; } merge(ejbModule, webModule); } } return appModule; }
ejbModule.setFinder(new FinderFactory.OpenEJBAnnotationFinder(finalArchive).link()); web.setFinder(ejbModule.getFinder()); web.getWebApp().setMetadataComplete(ejbModule.getEjbJar().isMetadataComplete());