private String getResourceId(String beanName, String resourceId, String type, Properties required, AppResources appResources) throws OpenEJBException { resourceId = normalizeResourceId(resourceId); String id = findResourceId(resourceId, type, required, appResources); if (id != null) return id; id = findResourceId(resourceId, null, required, appResources); if (id != null) return id; String shortName = toShortName(resourceId); String message = "No existing resource found while attempting to Auto-link unmapped resource-ref '" + resourceId + "' of type '" + type + "' for '" + beanName + "'. Looked for Resource(id=" + resourceId + ") and Resource(id=" + shortName + ")"; if (!autoCreateResources){ return installResource(beanName, resourceInfo); } else if (hasServiceProvider(shortName)) { ResourceInfo resourceInfo = configFactory.configureService(shortName, ResourceInfo.class); return installResource(beanName, resourceInfo); id = firstMatching(type, required, appResources); if (id != null) return id; return autoCreateResource(type, required, beanName);
public synchronized AppModule deploy(AppModule appModule) throws OpenEJBException { AppResources appResources = new AppResources(appModule); for (EjbModule ejbModule : appModule.getEjbModules()) { processActivationConfig(ejbModule); } resolveDestinationLinks(appModule); resolvePersistenceRefs(appModule); for (EjbModule ejbModule : appModule.getEjbModules()) { deploy(ejbModule, appResources); } for (ClientModule clientModule : appModule.getClientModules()) { deploy(clientModule, appResources); } for (ConnectorModule connectorModule : appModule.getResourceModules()) { deploy(connectorModule); } for (WebModule webModule : appModule.getWebModules()) { deploy(webModule, appResources); } for (PersistenceModule persistenceModule : appModule.getPersistenceModules()) { deploy(appModule, persistenceModule); } return appModule; }
private String findResourceId(final String resourceId, final String type, final Properties required, final AppResources appResources) { if (resourceId == null) { return null; } return findResourceId(getResourceIds(appResources, type, required), resourceId); }
if (resourceLocal && unit.getNonJtaDataSource() == null && isDataSourcePropertiesConfigured(unit.getProperties())) { continue; unit.setJtaDataSource(normalizeResourceId(unit.getJtaDataSource())); unit.setNonJtaDataSource(normalizeResourceId(unit.getNonJtaDataSource())); final String jtaWithJavaAndSlash = replaceJavaAndSlash(unit.getJtaDataSource()); for (final String potentialName : asList(prefix + jtaWithJavaAndSlash, jtaWithJavaAndSlash)) { if (potentialName == null) { final String nonJtaWithJavaAndSlash = replaceJavaAndSlash(unit.getNonJtaDataSource()); for (final String potentialName : asList(prefix + nonJtaWithJavaAndSlash, nonJtaWithJavaAndSlash)) { if (potentialName == null) { jtaDataSourceId = findResourceId(prefix + jtaWithJavaAndSlash, "DataSource", required, null); if (jtaDataSourceId == null) { // test with javax.sql.DataSource before DataSource since RA can register resources without our shortcut jtaDataSourceId = findResourceId(jtaWithJavaAndSlash, "javax.sql.DataSource", required, null); nonJtaDataSourceId = findResourceId(prefix + nonJtaWithJavaAndSlash, "DataSource", required, null); if (nonJtaDataSourceId == null) { nonJtaDataSourceId = findResourceId(nonJtaWithJavaAndSlash, "DataSource", required, null); setJtaDataSource(unit, jtaDataSourceId); setNonJtaDataSource(unit, nonJtaDataSourceId); continue; jtaDataSourceId = findResourceId(unit.getJtaDataSource(), "DataSource", required, null);
unit.setJtaDataSource(normalizeResourceId(unit.getJtaDataSource())); unit.setNonJtaDataSource(normalizeResourceId(unit.getNonJtaDataSource())); String jtaDataSourceId = findResourceId(unit.getJtaDataSource(), "DataSource", required, null); String nonJtaDataSourceId = findResourceId(unit.getNonJtaDataSource(), "DataSource", required, null); setJtaDataSource(unit, jtaDataSourceId); setNonJtaDataSource(unit, nonJtaDataSourceId); continue; jtaDataSourceId = findResourceId(unit.getJtaDataSource(), "DataSource", required, null); nonJtaDataSourceId = findResourceId(unit.getNonJtaDataSource(), "DataSource", required, null); if (jtaDataSourceId != null) setJtaDataSource(unit, jtaDataSourceId); if (nonJtaDataSourceId != null) setNonJtaDataSource(unit, nonJtaDataSourceId); continue; String possibleJta = findResourceId(unit.getJtaDataSource(), "DataSource", required, null); String possibleNonJta = findResourceId(unit.getNonJtaDataSource(), "DataSource", required, null); if (possibleJta != null && possibleJta == possibleNonJta){ ResourceInfo dataSource = configFactory.getResourceInfo(possibleJta); checkUnitDataSourceRefs(unit); jtaDataSourceId = findResourceProviderId(unit.getJtaDataSource()); nonJtaDataSourceId = findResourceProviderId(unit.getNonJtaDataSource()); logAutoCreateResource(jtaResourceInfo, "DataSource", unit.getName());
Class<? extends ContainerInfo> containerInfoType = ConfigurationFactory.getContainerInfoType(getType(bean)); if (ejbDeployment.getContainerId() == null && !skipMdb(bean)) { String containerId = getUsableContainer(containerInfoType, bean, appResources); if (containerId == null){ containerId = createContainer(containerInfoType, ejbDeployment, bean); if (!containerIds.contains(ejbDeployment.getContainerId()) && !skipMdb(bean)) { createContainer(containerInfoType, ejbDeployment, bean); processResourceRef(ref, ejbDeployment, appResources); processResourceEnvRef(ref, ejbDeployment, appResources); processResourceEnvRef(ref, ejbDeployment, appResources); if (resourceLink != null) { try { String destinationId = getResourceEnvId(bean.getEjbName(), resourceLink.getResId(), mdb.getMessageDestinationType(), appResources); resourceLink.setResId(destinationId); } catch (OpenEJBException e) {
AutoConfig autoConfig = new AutoConfig(configurationFactory); autoConfig.autoCreateResources(false); autoConfig.autoCreateContainers(true); chain.add(autoConfig); } else { chain.add(new AutoConfig(configurationFactory));
final String refType = getType(ref, ejbModule.getClassLoader()); final AppModule appModule = ejbModule.getAppModule(); if (appModule != null) { final String newId = findResourceId(appModule.getModuleId() + '/' + id.replace("java:", "").replaceAll("^comp/env/", ""), refType, new Properties(), appResources); if (newId != null) { // app scoped resources, try to find it without creating it first id = getResourceId(ejbModule.getModuleId(), newId, refType, appResources); } else { id = getResourceId(ejbDeployment.getDeploymentId(), id, refType, appResources); id = getResourceId(ejbDeployment.getDeploymentId(), id, refType, appResources); ejbDeployment.addResourceLink(link); } else { final String id = getResourceId(ejbDeployment.getDeploymentId(), link.getResId(), refType, appResources); link.setResId(id); link.setResRefName(refName);
private void checkUnitDataSourceRefs(PersistenceUnit unit) throws OpenEJBException { Properties required = new Properties(); // check that non-jta-data-source does NOT point to a JtaManaged=true datasource required.put("JtaManaged", "true"); String invalidNonJta = findResourceId(unit.getNonJtaDataSource(), "DataSource", required, null); if (invalidNonJta != null){ throw new OpenEJBException("PeristenceUnit "+unit.getName()+" <non-jta-data-source> points to a jta managed Resource. Update Resource \""+invalidNonJta +"\" to \"JtaManaged=false\", use a different Resource, or delete the <non-jta-data-source> element and a default will be supplied if possible."); } // check that jta-data-source does NOT point to a JtaManaged=false datasource required.put("JtaManaged", "false"); String invalidJta = findResourceId(unit.getJtaDataSource(), "DataSource", required, null); if (invalidJta != null){ throw new OpenEJBException("PeristenceUnit "+unit.getName()+" <jta-data-source> points to a non jta managed Resource. Update Resource \""+invalidJta +"\" to \"JtaManaged=true\", use a different Resource, or delete the <jta-data-source> element and a default will be supplied if possible."); } }
if (resourceLocal && unit.getNonJtaDataSource() == null && isDataSourcePropertiesConfigured(unit.getProperties())) { continue; unit.setJtaDataSource(normalizeResourceId(originalJtaDataSource)); final String originalNonJtaDataSource = unit.getNonJtaDataSource(); unit.setNonJtaDataSource(normalizeResourceId(originalNonJtaDataSource)); final String jtaWithJavaAndSlash = replaceJavaAndSlash(unit.getJtaDataSource()); for (final String potentialName : asList(prefix + jtaWithJavaAndSlash, originalJtaDataSource, jtaWithJavaAndSlash)) { if(potentialName == null) { final String nonJtaWithJavaAndSlash = replaceJavaAndSlash(unit.getNonJtaDataSource()); for (final String potentialName : asList(prefix + nonJtaWithJavaAndSlash, originalNonJtaDataSource, nonJtaWithJavaAndSlash)) { if(potentialName == null) { jtaDataSourceId = findResourceId(prefix + jtaWithJavaAndSlash, "DataSource", required, null); if (jtaDataSourceId == null) { // test with javax.sql.DataSource before DataSource since RA can register resources without our shortcut jtaDataSourceId = findResourceId(jtaWithJavaAndSlash, "javax.sql.DataSource", required, null); nonJtaDataSourceId = findResourceId(prefix + nonJtaWithJavaAndSlash, "DataSource", required, null); if (nonJtaDataSourceId == null) { nonJtaDataSourceId = findResourceId(nonJtaWithJavaAndSlash, "DataSource", required, null); setJtaDataSource(unit, jtaDataSourceId); setNonJtaDataSource(unit, nonJtaDataSourceId); continue; jtaDataSourceId = findResourceId(unit.getJtaDataSource(), "DataSource", required, null);
final Class<? extends ContainerInfo> containerInfoType = ConfigurationFactory.getContainerInfoType(getType(bean)); if (ejbDeployment.getContainerId() == null && !skipMdb(bean)) { String containerId = getUsableContainer(containerInfoType, bean, appResources); if (containerId == null) { containerId = createContainer(containerInfoType, ejbDeployment, bean); if (!containerIds.contains(ejbDeployment.getContainerId()) && !skipMdb(bean)) { createContainer(containerInfoType, ejbDeployment, bean); processResourceRef(ref, ejbDeployment, appResources, ejbModule); processResourceEnvRef(ref, ejbDeployment, appResources, ejbModule.getClassLoader()); processResourceEnvRef(ref, ejbDeployment, appResources, ejbModule.getClassLoader()); if (resourceLink != null) { try { final String destinationId = getResourceEnvId(bean.getEjbName(), resourceLink.getResId(), mdb.getMessageDestinationType(), appResources); resourceLink.setResId(destinationId); } catch (final OpenEJBException e) {
AutoConfig autoConfig = new AutoConfig(this); autoConfig.autoCreateResources(false); autoConfig.autoCreateContainers(false); chain.add(autoConfig); } else { chain.add(new AutoConfig(this));
final String refType = getType(ref, ejbModule.getClassLoader()); final AppModule appModule = ejbModule.getAppModule(); if (appModule != null) { final String newId = findResourceId(appModule.getModuleId() + '/' + id.replace("java:", "").replaceAll("^comp/env/", ""), refType, new Properties(), appResources); if (newId != null) { // app scoped resources, try to find it without creating it first id = getResourceId(ejbModule.getModuleId(), newId, refType, appResources); } else { id = getResourceId(ejbDeployment.getDeploymentId(), id, refType, appResources); id = getResourceId(ejbDeployment.getDeploymentId(), id, refType, appResources); ejbDeployment.addResourceLink(link); } else { final String id = getResourceId(ejbDeployment.getDeploymentId(), link.getResId(), refType, appResources); link.setResId(id); link.setResRefName(refName);
private String findResourceId(final String resourceId, final String type, final Properties required, final AppResources appResources) { if (resourceId == null) { return null; } return findResourceId(getResourceIds(appResources, type, required), resourceId); }
private void checkUnitDataSourceRefs(final PersistenceUnit unit) throws OpenEJBException { final Properties required = new Properties(); // check that non-jta-data-source does NOT point to a JtaManaged=true datasource required.put("JtaManaged", "true"); final String invalidNonJta = findResourceId(unit.getNonJtaDataSource(), "DataSource", required, null); if (invalidNonJta != null) { throw new OpenEJBException("PeristenceUnit " + unit.getName() + " <non-jta-data-source> points to a jta managed Resource. Update Resource \"" + invalidNonJta + "\" to \"JtaManaged=false\", use a different Resource, or delete the <non-jta-data-source> element and a default will be supplied if possible."); } // check that jta-data-source does NOT point to a JtaManaged=false datasource required.put("JtaManaged", "false"); final String invalidJta = findResourceId(unit.getJtaDataSource(), "DataSource", required, null); if (invalidJta != null) { throw new OpenEJBException("PeristenceUnit " + unit.getName() + " <jta-data-source> points to a non jta managed Resource. Update Resource \"" + invalidJta + "\" to \"JtaManaged=true\", use a different Resource, or delete the <jta-data-source> element and a default will be supplied if possible."); } }
final String beanType = getType(bean); final Class<? extends ContainerInfo> containerInfoType = ConfigurationFactory.getContainerInfoType(beanType); logger.debug("Bean type of bean {0} is {1}", bean.getEjbName(), beanType); if (ejbDeployment.getContainerId() == null && !skipMdb(bean)) { logger.debug("Container for bean {0} is not set, looking for a suitable container", bean.getEjbName()); String containerId = getUsableContainer(containerInfoType, bean, appResources); if (containerId == null) { logger.debug("Suitable container for bean {0} not found, creating one", bean.getEjbName()); containerId = createContainer(containerInfoType, ejbDeployment, bean); if (!containerIds.contains(ejbDeployment.getContainerId()) && !skipMdb(bean)) { logger.debug("Desired container {0} not found. Containers available: {1}. Creating a new container.", ejbDeployment.getContainerId(), createContainer(containerInfoType, ejbDeployment, bean); processResourceRef(ref, ejbDeployment, appResources, ejbModule); processResourceEnvRef(ref, ejbDeployment, appResources, ejbModule.getClassLoader()); processResourceEnvRef(ref, ejbDeployment, appResources, ejbModule.getClassLoader()); if (resourceLink != null) { try { final String destinationId = getResourceEnvId(bean.getEjbName(), resourceLink.getResId(), mdb.getMessageDestinationType(), appResources); resourceLink.setResId(destinationId); } catch (final OpenEJBException e) {
private String getResourceId(final String beanName, String resourceId, final String type, final Properties required, AppResources appResources) throws OpenEJBException { resourceId = normalizeResourceId(resourceId); String id = findResourceId(beanName + '/' + resourceId, type, required, appResources); // check first in app namespace if (id != null) { return id; id = findResourceId(resourceId, type, required, appResources); if (id != null) { return id; id = findResourceId(resourceId, null, required, appResources); if (id != null) { return id; id = findResourceId(resourceId.substring(appResources.appId.length() + 1), type, required, appResources); if (id != null) { return id; final String shortName = toShortName(resourceId); final String message = "No existing resource found while attempting to Auto-link unmapped resource-ref '" + resourceId + return installResource(beanName, resourceInfo); } else if (ServiceUtils.hasServiceProvider(shortName)) { final ResourceInfo resourceInfo = configFactory.configureService(shortName, ResourceInfo.class); return installResource(beanName, resourceInfo); id = firstMatching(beanName, type, required, appResources); if (id != null) {
@Override public synchronized AppModule deploy(final AppModule appModule) throws OpenEJBException { final AppResources appResources = new AppResources(appModule); appResources.dump(); processApplicationResources(appModule); for (final EjbModule ejbModule : appModule.getEjbModules()) { processActivationConfig(ejbModule); } resolveDestinationLinks(appModule); resolvePersistenceRefs(appModule); for (final EjbModule ejbModule : appModule.getEjbModules()) { deploy(ejbModule, appResources); } for (final ClientModule clientModule : appModule.getClientModules()) { deploy(clientModule, appResources); } for (final WebModule webModule : appModule.getWebModules()) { deploy(webModule, appResources); } for (final PersistenceModule persistenceModule : appModule.getPersistenceModules()) { deploy(appModule, persistenceModule); } // Note that there is nothing to process for resource modules. // We dont need to loop over "appModule.getConnectorModules()". return appModule; }
final AutoConfig autoConfig = new AutoConfig(this); autoConfig.autoCreateResources(false); autoConfig.autoCreateContainers(false); chain.add(autoConfig); } else { chain.add(new AutoConfig(this));
private void checkUnitDataSourceRefs(final PersistenceUnit unit) throws OpenEJBException { final Properties required = new Properties(); // check that non-jta-data-source does NOT point to a JtaManaged=true datasource required.put("JtaManaged", "true"); final String invalidNonJta = findResourceId(unit.getNonJtaDataSource(), "DataSource", required, null); if (invalidNonJta != null) { throw new OpenEJBException("PeristenceUnit " + unit.getName() + " <non-jta-data-source> points to a jta managed Resource. Update Resource \"" + invalidNonJta + "\" to \"JtaManaged=false\", use a different Resource, or delete the <non-jta-data-source> element and a default will be supplied if possible."); } // check that jta-data-source does NOT point to a JtaManaged=false datasource required.put("JtaManaged", "false"); final String invalidJta = findResourceId(unit.getJtaDataSource(), "DataSource", required, null); if (invalidJta != null) { throw new OpenEJBException("PeristenceUnit " + unit.getName() + " <jta-data-source> points to a non jta managed Resource. Update Resource \"" + invalidJta + "\" to \"JtaManaged=true\", use a different Resource, or delete the <jta-data-source> element and a default will be supplied if possible."); } }