@SuppressWarnings("unchecked") private void addWebPersistenceDD(final String name, final Map<String, Object> otherDD, final AppModule appModule) { if (otherDD.containsKey(name)) { List<URL> persistenceUrls = (List<URL>) appModule.getAltDDs().get(name); if (persistenceUrls == null) { persistenceUrls = new ArrayList<URL>(); appModule.getAltDDs().put(name, persistenceUrls); } if (otherDD.containsKey(name)) { final Object otherUrl = otherDD.get(name); if (otherUrl instanceof URL && !persistenceUrls.contains(otherUrl)) { persistenceUrls.add((URL) otherUrl); } else if (otherUrl instanceof List) { final List<URL> otherList = (List<URL>) otherDD.get(name); for (final URL url : otherList) { if (!persistenceUrls.contains(url)) { persistenceUrls.add(url); } } } } } }
@SuppressWarnings("unchecked") private static void addWebPersistenceDD(final String name, final Map<String, Object> otherDD, final AppModule appModule) { if (otherDD.containsKey(name)) { List<URL> persistenceUrls = (List<URL>) appModule.getAltDDs().get(name); if (persistenceUrls == null) { persistenceUrls = new ArrayList<URL>(); appModule.getAltDDs().put(name, persistenceUrls); } if (otherDD.containsKey(name)) { final Object otherUrl = otherDD.get(name); if (otherUrl instanceof URL && !persistenceUrls.contains(otherUrl)) { persistenceUrls.add((URL) otherUrl); } else if (otherUrl instanceof List) { final List<URL> otherList = (List<URL>) otherDD.get(name); for (final URL url : otherList) { if (!persistenceUrls.contains(url)) { persistenceUrls.add(url); } } } } } }
private void configureDescriptor(final AppModule appModule, final Descriptor descriptor) { URL resource = appModule.getClassLoader().getResource(descriptor.path()); try { appModule.getAltDDs().put(descriptor.name(), resource == null ? new File(descriptor.path()).toURI().toURL() : resource); } catch (final MalformedURLException e) { throw new IllegalArgumentException(e); } } }
private SunApplication getSunApplication(AppModule appModule) { Object altDD = appModule.getAltDDs().get("sun-application.xml"); if (altDD instanceof String) { try { altDD = JaxbSun.unmarshal(SunApplication.class, new ByteArrayInputStream(((String)altDD).getBytes())); } catch (Exception e) { // todo warn about not being able to parse sun descriptor } } if (altDD instanceof URL) { try { altDD = JaxbSun.unmarshal(SunApplication.class, ((URL)altDD).openStream()); } catch (Exception e) { // todo warn about not being able to parse sun descriptor } } if (altDD instanceof SunApplication) { return (SunApplication) altDD; } return null; }
@SuppressWarnings({"unchecked"}) protected static void addPersistenceUnits(AppModule appModule, URL... urls) throws OpenEJBException { // OPENEJB-1059: Anything in the appModule.getAltDDs() map has already been // processed by the altdd code, so anything in here should not cause OPENEJB-1059 List<URL> persistenceUrls = (List<URL>) appModule.getAltDDs().get("persistence.xml"); if (persistenceUrls == null) { persistenceUrls = new ArrayList<URL>(); appModule.getAltDDs().put("persistence.xml", persistenceUrls); } for (URL url : urls) { // OPENEJB-1059: looking for an altdd persistence.xml file in all urls // delegates to xbean finder for going throughout the list ResourceFinder finder = new ResourceFinder("", appModule.getClassLoader(), url); Map<String, URL> descriptors = getDescriptors(finder, false); // if a persistence.xml has been found, just pull it to the list if (descriptors.containsKey("persistence.xml")) { URL descriptor = descriptors.get("persistence.xml"); // don't add it if already present if (persistenceUrls.contains(descriptor)) continue; // log if it is an altdd String urlString = descriptor.toExternalForm(); if (!urlString.contains("META-INF/persistence.xml")) { logger.info("AltDD persistence.xml -> " + urlString); } persistenceUrls.add(descriptor); } } }
private static void addPersistenceXml(final Archive<?> archive, final String prefix, final AppModule appModule) { Node persistenceXml = archive.get(prefix.concat(PERSISTENCE_XML)); if (persistenceXml == null && WEB_INF.equals(prefix)) { persistenceXml = archive.get(WEB_INF_CLASSES.concat(META_INF).concat(PERSISTENCE_XML)); } if (persistenceXml != null) { final Asset asset = persistenceXml.getAsset(); if (UrlAsset.class.isInstance(asset)) { appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(get(URL.class, "url", asset))); } else if (FileAsset.class.isInstance(asset)) { try { appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(get(File.class, "file", asset).toURI().toURL())); } catch (final MalformedURLException e) { appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(new AssetSource(persistenceXml.getAsset(), null))); } } else if (ClassLoaderAsset.class.isInstance(asset)) { final URL url = get(ClassLoader.class, "classLoader", asset).getResource(get(String.class, "resourceName", asset)); if (url != null) { appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(url)); } else { appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(new AssetSource(persistenceXml.getAsset(), null))); } } else { appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(new AssetSource(persistenceXml.getAsset(), null))); } } }
private SunApplication getSunApplication(final AppModule appModule) { Object altDD = appModule.getAltDDs().get("sun-application.xml"); if (altDD instanceof String) { try { altDD = JaxbSun.unmarshal(SunApplication.class, new ByteArrayInputStream(((String) altDD).getBytes())); } catch (final Exception e) { // todo warn about not being able to parse sun descriptor } } if (altDD instanceof URL) { try { altDD = JaxbSun.unmarshal(SunApplication.class, IO.read((URL) altDD)); } catch (final Exception e) { // todo warn about not being able to parse sun descriptor } } if (altDD instanceof SunApplication) { return (SunApplication) altDD; } return null; }
private SunApplication getSunApplication(final AppModule appModule) { Object altDD = appModule.getAltDDs().get("sun-application.xml"); if (altDD instanceof String) { try { altDD = JaxbSun.unmarshal(SunApplication.class, new ByteArrayInputStream(((String) altDD).getBytes())); } catch (final Exception e) { // todo warn about not being able to parse sun descriptor } } if (altDD instanceof URL) { try { altDD = JaxbSun.unmarshal(SunApplication.class, IO.read((URL) altDD)); } catch (final Exception e) { // todo warn about not being able to parse sun descriptor } } if (altDD instanceof SunApplication) { return (SunApplication) altDD; } return null; }
persistenceUrls = (List<URL>) appModule.getAltDDs().get("persistence.xml"); } catch (final ClassCastException e) { final Object value = appModule.getAltDDs().get("persistence.xml"); added.add(persistenceUrls.iterator().next()); appModule.getAltDDs().put("persistence.xml", persistenceUrls); appModule.getAltDDs().put("persistence.xml", persistenceUrls); List<URL> persistenceFragmentsUrls = (List<URL>) appModule.getAltDDs().get("persistence-fragment.xml"); if (persistenceFragmentsUrls == null) { persistenceFragmentsUrls = new ArrayList<URL>(); appModule.getAltDDs().put("persistence-fragment.xml", persistenceFragmentsUrls);
persistenceUrls = (List<URL>) appModule.getAltDDs().get("persistence.xml"); } catch (final ClassCastException e) { final Object value = appModule.getAltDDs().get("persistence.xml"); added.add(persistenceUrls.iterator().next()); appModule.getAltDDs().put("persistence.xml", persistenceUrls); appModule.getAltDDs().put("persistence.xml", persistenceUrls); List<URL> persistenceFragmentsUrls = (List<URL>) appModule.getAltDDs().get("persistence-fragment.xml"); if (persistenceFragmentsUrls == null) { persistenceFragmentsUrls = new ArrayList<URL>(); appModule.getAltDDs().put("persistence-fragment.xml", persistenceFragmentsUrls);
application.setApplicationName(id); final AppModule collection = new AppModule(classLoader, id, application, standaloneModule); final Map<String, Object> altDDs = collection.getAltDDs(); for (final Map.Entry<String, Object> entry : module.getAltDDs().entrySet()) { final Object existingValue = altDDs.get(entry.getKey());
application.setApplicationName(id); final AppModule collection = new AppModule(classLoader, id, application, standaloneModule); final Map<String, Object> altDDs = collection.getAltDDs(); for (final Map.Entry<String, Object> entry : module.getAltDDs().entrySet()) { final Object existingValue = altDDs.get(entry.getKey());
public AppInfo configureApplication(ClassLoader classLoader, String id, List<File> jarFiles) throws OpenEJBException { AppModule collection = new AppModule(classLoader, id); Map<String, Object> altDDs = collection.getAltDDs(); for (Map.Entry<String, Object> entry : module.getAltDDs().entrySet()) { Object existingValue = altDDs.get(entry.getKey());
List<URL> persistenceUrls = (List<URL>) appModule.getAltDDs().get("persistence.xml"); if (persistenceUrls != null) { for (URL persistenceUrl : persistenceUrls) {
ResourceFinder finder = new ResourceFinder("", standardContext.getLoader().getClassLoader()); List<URL> persistenceUrls = finder.findAll("META-INF/persistence.xml"); appModule.getAltDDs().put("persistence.xml", persistenceUrls); } catch (IOException e) { logger.warning("Cannot load persistence-units from 'META-INF/persistence.xml' : " + e.getMessage(), e);
final List<Object> persistenceUrls = (List<Object>) appModule.getAltDDs().get("persistence.xml"); if (persistenceUrls != null) { for (final Object persistenceUrl : persistenceUrls) { final List<URL> persistenceFragmentUrls = (List<URL>) appModule.getAltDDs().get("persistence-fragment.xml"); if (persistenceFragmentUrls != null) { for (final URL persistenceFragmentUrl : persistenceFragmentUrls) {
finder = FinderFactory.createFinder(appModule); } catch (final Exception e) { finder = new FinderFactory.ModuleLimitedFinder(new FinderFactory.OpenEJBAnnotationFinder(new WebappAggregatedArchive(appModule.getClassLoader(), appModule.getAltDDs(), xmls)));
finder = FinderFactory.createFinder(appModule); } catch (final Exception e) { finder = new FinderFactory.ModuleLimitedFinder(new FinderFactory.OpenEJBAnnotationFinder(new WebappAggregatedArchive(appModule.getClassLoader(), appModule.getAltDDs(), xmls)));