private String getPersistenceModuleId(final AppModule appModule) { if (appModule.getModuleId() != null) { return appModule.getModuleId(); } for (final EjbModule ejbModule : appModule.getEjbModules()) { return ejbModule.getModuleId(); } throw new IllegalStateException("Comp must be in an ejb module, this one has none: " + appModule); }
private String getPersistenceModuleId(final AppModule appModule) { if (appModule.getModuleId() != null) { return appModule.getModuleId(); } for (final EjbModule ejbModule : appModule.getEjbModules()) { if (ejbModule.getModuleId() != null) { return ejbModule.getModuleId(); } } throw new IllegalStateException("Comp must be in an ejb module, this one has none: " + appModule); }
private void applyOverrides(final AppModule appModule) { final String id = appModule.getModuleId() + "."; final Properties properties = SystemInstance.get().getProperties(); for (final Map.Entry<Object, Object> entry : properties.entrySet()) { final String key = entry.getKey().toString(); if (key.startsWith(id)) { final String property = key.substring(id.length()); if (appModule.getProperties().containsKey(property)) { log.debug("Overriding application " + appModule.getModuleId() + " property " + property + "=" + entry.getValue()); } else { log.debug("Adding application " + appModule.getModuleId() + " property " + property + "=" + entry.getValue()); } appModule.getProperties().put(property, entry.getValue()); } } }
private void applyOverrides(final AppModule appModule) { final String id = appModule.getModuleId() + "."; final Properties properties = SystemInstance.get().getProperties(); for (final Map.Entry<Object, Object> entry : properties.entrySet()) { final String key = entry.getKey().toString(); if (key.startsWith(id)) { final String property = key.substring(id.length()); if (appModule.getProperties().containsKey(property)) { log.debug("Overriding application " + appModule.getModuleId() + " property " + property + "=" + entry.getValue()); } else { log.debug("Adding application " + appModule.getModuleId() + " property " + property + "=" + entry.getValue()); } appModule.getProperties().put(property, entry.getValue()); } } }
public void switchJaxrsOffForInternalWebApp(@Observes final BeforeAppInfoBuilderEvent event) { if (event.getAppModule().getModuleId().equals(TOMITRIBE_MONITOR_CONTEXT.substring(1))) { // / is removed from id // we handle it manually, we can desire to move to auto deployment but would need to check security etc event.getAppModule().getProperties().put("openejb.jaxrs.on", "false"); } }
public static List<ContainerInfo> getContainerInfos(final AppModule module, final ConfigurationFactory configFactory) throws OpenEJBException { final List<ContainerInfo> containerInfos = new ArrayList<ContainerInfo>(); if (module.getContainers().isEmpty()) { return containerInfos; } final String prefix = module.getModuleId() + "/"; for (final Container container : module.getContainers()) { if (container.getId() == null) { throw new IllegalStateException("a container can't get a null id: " + container.getType() + " from " + module.getModuleId()); } if (!container.getId().startsWith(prefix)) { container.setId(prefix + container.getId()); } final ContainerInfo containerInfo = configFactory.createContainerInfo(container); containerInfo.originAppName = module.getModuleId(); final Object applicationWideProperty = containerInfo.properties.remove("ApplicationWide"); if (applicationWideProperty != null) { containerInfo.applicationWide = Boolean.parseBoolean(applicationWideProperty.toString().trim()); } containerInfos.add(containerInfo); } return containerInfos; } }
private boolean isOAuth2(final AppModule module) { final Container container = SystemInstance.get().getComponent(Container.class); return container != null && container.isStarted() && container.getConfiguration().getOauth2Context().replace("/", "").equals(module.getModuleId()); } }
private MdbContainerDetails findModuleContainer(final AppModule appModule, final ConfigurationFactory configurationFactory, final String containerId) { // try the containers on the AppModule final Collection<org.apache.openejb.config.sys.Container> containers = appModule.getContainers(); for (final org.apache.openejb.config.sys.Container appMopduleContainer : containers) { if (appMopduleContainer.getId().equals(containerId) || appMopduleContainer.getId().equals(appModule.getModuleId() + "/" + containerId)) { try { final ContainerInfo containerInfo = configurationFactory.createContainerInfo(appMopduleContainer); if (containerInfo != null && MdbContainerInfo.class.isInstance(containerInfo)) { return convert(MdbContainerInfo.class.cast(containerInfo)); } } catch (OpenEJBException e) { e.printStackTrace(); } } } return null; }
public synchronized AppModule deploy(AppModule appModule) throws OpenEJBException { Set<String> abstractSchemaNames = new HashSet<String>(); for (EjbModule ejbModule : appModule.getEjbModules()) { for (EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) { if (isCmpEntity(bean)) { EntityBean entity = (EntityBean) bean; String name = entity.getAbstractSchemaName(); if (name != null) { abstractSchemaNames.add(name); } } } } Map<String, String> contextData = new HashMap<String, String>(); contextData.put("appId", appModule.getModuleId()); for (EjbModule ejbModule : appModule.getEjbModules()) { contextData.put("ejbJarId", ejbModule.getModuleId()); deploy(ejbModule, contextData, abstractSchemaNames); } contextData.clear(); return appModule; }
public synchronized AppModule deploy(final AppModule appModule) throws OpenEJBException { final Set<String> abstractSchemaNames = new HashSet<String>(); for (final EjbModule ejbModule : appModule.getEjbModules()) { for (final EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) { if (isCmpEntity(bean)) { final EntityBean entity = (EntityBean) bean; final String name = entity.getAbstractSchemaName(); if (name != null) { abstractSchemaNames.add(name); } } } } final Map<String, String> contextData = new HashMap<String, String>(); contextData.put("appId", appModule.getModuleId()); for (final EjbModule ejbModule : appModule.getEjbModules()) { contextData.put("host", ejbModule.isWebapp() ? findHost(ejbModule.getModuleId(), appModule.getWebModules()) : appModule.uniqueHostIfExists()); contextData.put("hash", Integer.toString(ejbModule.hashCode())); contextData.put("ejbJarId", ejbModule.getModuleId()); deploy(ejbModule, contextData, abstractSchemaNames); } contextData.clear(); return appModule; }
/** * embedded usage * * @param classLoader classloader * @param id id supplied from embedded properties or null * @param jarFiles list of ejb modules * @return configured AppInfo * @throws OpenEJBException on error */ public AppInfo configureApplication(final ClassLoader classLoader, final String id, final List<File> jarFiles) throws OpenEJBException { final AppModule collection = loadApplication(classLoader, id, jarFiles); final AppInfo appInfo; try { appInfo = configureApplication(collection); } catch (final ValidationFailedException e) { logger.warning("configureApplication.loadFailed", collection.getModuleId(), 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, collection.getModuleId(), e.getMessage()); throw e; } return appInfo; }
public synchronized AppModule deploy(final AppModule appModule) throws OpenEJBException { final Set<String> abstractSchemaNames = new HashSet<String>(); for (final EjbModule ejbModule : appModule.getEjbModules()) { for (final EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) { if (isCmpEntity(bean)) { final EntityBean entity = (EntityBean) bean; final String name = entity.getAbstractSchemaName(); if (name != null) { abstractSchemaNames.add(name); } } } } final Map<String, String> contextData = new HashMap<String, String>(); contextData.put("appId", appModule.getModuleId()); for (final EjbModule ejbModule : appModule.getEjbModules()) { contextData.put("host", ejbModule.isWebapp() ? findHost(ejbModule.getModuleId(), appModule.getWebModules()) : appModule.uniqueHostIfExists()); contextData.put("hash", Integer.toString(ejbModule.hashCode())); contextData.put("ejbJarId", ejbModule.getModuleId()); deploy(ejbModule, contextData, abstractSchemaNames); } contextData.clear(); return appModule; }
/** * embedded usage * * @param classLoader classloader * @param id id supplied from embedded properties or null * @param jarFiles list of ejb modules * @return configured AppInfo * @throws OpenEJBException on error */ public AppInfo configureApplication(final ClassLoader classLoader, final String id, final List<File> jarFiles) throws OpenEJBException { final AppModule collection = loadApplication(classLoader, id, jarFiles); final AppInfo appInfo; try { appInfo = configureApplication(collection); } catch (final ValidationFailedException e) { logger.warning("configureApplication.loadFailed", collection.getModuleId(), 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, collection.getModuleId(), e.getMessage()); throw e; } return appInfo; }
private static EjbModule addTestClassAsManagedBean(Class<?> javaClass, URLClassLoader tempClassLoader, AppModule appModule) { final EjbJar ejbJar = new EjbJar(); final OpenejbJar openejbJar = new OpenejbJar(); final String ejbName = appModule.getModuleId() + "_" + javaClass.getName(); final ManagedBean bean = ejbJar.addEnterpriseBean(new ManagedBean(ejbName, javaClass.getName(), true)); bean.localBean(); bean.setTransactionType(TransactionType.BEAN); final EjbDeployment ejbDeployment = openejbJar.addEjbDeployment(bean); ejbDeployment.setDeploymentId(ejbName); final EjbModule e = new EjbModule(ejbJar, openejbJar); e.getProperties().setProperty("openejb.cdi.activated", "false"); e.getProperties().setProperty("openejb.test.module", "true"); e.setBeans(new Beans()); e.setClassLoader(tempClassLoader); appModule.getEjbModules().add(e); return e; }
logger.info("config.configApp", null != location ? location : appModule.getModuleId()); deployer.deploy(appModule); final AppInfoBuilder appInfoBuilder = new AppInfoBuilder(this);
final AppModule newModule = new AppModule(appModule.getClassLoader(), appModule.getModuleId(), application, false); newModule.getClientModules().addAll(appModule.getClientModules()); newModule.addPersistenceModules(appModule.getPersistenceModules());
public void addTimeoutInterceptor(@Observes final BeforeAppInfoBuilderEvent event) { LOGGER.fine(GovernanceCodes.EXTENSION_ADDING_INTERCEPTOR, "Adding governance interceptor to application > " + event.getAppModule().getModuleId()); final List<EjbModule> ejbModules = event.getAppModule().getEjbModules(); for (final EjbModule ejbModule : ejbModules) { if (ejbModule.getEjbJar().getEnterpriseBeans().length > 0) { final InterceptorBinding binding = new InterceptorBinding(); binding.setEjbName("*"); binding.getInterceptorClass().add(TimeoutGovernanceInterceptor.class.getName()); ejbModule.getEjbJar().getAssemblyDescriptor().addInterceptorBinding(binding); final Interceptor interceptor = new Interceptor(); interceptor.setInterceptorClass(TimeoutGovernanceInterceptor.class.getName()); interceptor.addAroundTimeout("timeout"); ejbModule.getEjbJar().addInterceptor(interceptor); } } } }
persistence.getPersistenceUnit().add(persistenceUnit); PersistenceModule persistenceModule = new PersistenceModule(appModule.getModuleId(), persistence); appModule.getPersistenceModules().add(persistenceModule);
final EjbModule ejbModule = new EjbModule(appModule.getClassLoader(), EAR_SCOPED_CDI_BEANS + appModule.getModuleId(), new EjbJar(), new OpenejbJar()); ejbModule.setBeans(complete); ejbModule.setFinder(finder);
final EjbModule ejbModule = new EjbModule(appModule.getClassLoader(), EAR_SCOPED_CDI_BEANS + appModule.getModuleId(), new EjbJar(), new OpenejbJar()); ejbModule.setBeans(complete); ejbModule.setFinder(finder);