public static JavaWsdlMapping readJaxrpcMapping(URL url) throws OpenEJBException { JavaWsdlMapping wsdlMapping; try { wsdlMapping = (JavaWsdlMapping) JaxbJavaee.unmarshal(JavaWsdlMapping.class, url.openStream()); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the JaxRPC mapping file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the JaxRPC mapping file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the JaxRPC mapping file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the JaxRPC mapping file: " + url.toExternalForm(), e); } return wsdlMapping; }
public static WebApp readWebApp(URL url) throws OpenEJBException { WebApp webApp; try { webApp = (WebApp) JaxbJavaee.unmarshal(WebApp.class, url.openStream()); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the web.xml file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the web.xml file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the web.xml file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the web.xml file: " + url.toExternalForm(), e); } return webApp; }
@SuppressWarnings({"unchecked"}) public static <T>T unmarshal(Class<T> type, String descriptor, URL url) throws OpenEJBException { try { return (T) JaxbJavaee.unmarshal(type, url.openStream()); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the " + descriptor + " file: "+ url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the " + descriptor + " file: "+ url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the " + descriptor + " file: "+ url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the " + descriptor + " file: "+ url.toExternalForm(), e); } }
public static ApplicationClient readApplicationClient(URL url) throws OpenEJBException { ApplicationClient applicationClient; try { applicationClient = (ApplicationClient) JaxbJavaee.unmarshal(ApplicationClient.class, url.openStream()); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the application-client.xml file: "+ url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the application-client.xml file: "+ url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the application-client.xml file: "+ url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the application-client.xml file: "+ url.toExternalForm(), e); } return applicationClient; }
public static HandlerChains readHandlerChains(URL url) throws OpenEJBException { HandlerChains handlerChains; try { handlerChains = (HandlerChains) JaxbJavaee.unmarshal(HandlerChains.class, url.openStream()); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the webservices.xml file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the webservices.xml file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the webservices.xml file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the webservices.xml file: " + url.toExternalForm(), e); } return handlerChains; }
public static TldTaglib readTldTaglib(URL url) throws OpenEJBException { TldTaglib tldTaglib; try { tldTaglib = (TldTaglib) JaxbJavaee.unmarshal(TldTaglib.class, url.openStream()); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the JSP tag library definition file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the JSP tag library definition file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the JSP tag library definition file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the JSP tag library definition file: " + url.toExternalForm(), e); } return tldTaglib; }
public static Webservices readWebservices(URL url) throws OpenEJBException { Webservices webservices; try { webservices = (Webservices) JaxbJavaee.unmarshal(Webservices.class, url.openStream()); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the webservices.xml file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the webservices.xml file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the webservices.xml file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the webservices.xml file: " + url.toExternalForm(), e); } return webservices; }
public static Connector readConnector(URL url) throws OpenEJBException { Connector connector; try { connector = (Connector) JaxbJavaee.unmarshal(Connector.class, url.openStream()); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the ra.xml file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the ra.xml file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the ra.xml file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the ra.xml file: " + url.toExternalForm(), e); } return connector; }
public static FacesConfig readFacesConfig(URL url) throws OpenEJBException { FacesConfig facesConfig; try { JAXBElement<FacesConfig> element = (JAXBElement<FacesConfig>) JaxbJavaee .unmarshal(FacesConfig.class, url.openStream()); facesConfig = element.getValue(); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the faces configuration file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the faces configuration file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the faces configuration file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the faces configuration file: " + url.toExternalForm(), e); } return facesConfig; } private Source getSource(Object o) {
public static EjbJar readEjbJar(URL url) throws OpenEJBException { try { if (isEmptyEjbJar(url)) return new EjbJar(); return (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, url.openStream()); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the ejb-jar.xml file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the ejb-jar.xml file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the ejb-jar.xml file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the ejb-jar.xml file: " + url.toExternalForm(), e); } }
private void readCmpOrm(EjbModule ejbModule) throws OpenEJBException { Object data = ejbModule.getAltDDs().get("openejb-cmp-orm.xml"); if (data == null || data instanceof EntityMappings) { return; } else if (data instanceof URL) { URL url = (URL) data; try { EntityMappings entitymappings = (EntityMappings) JaxbJavaee.unmarshal(EntityMappings.class, url.openStream()); ejbModule.getAltDDs().put("openejb-cmp-orm.xml", entitymappings); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } } }
InputStream in = persistenceUrl.openStream(); try { persistence = (Persistence) JaxbJavaee.unmarshal(Persistence.class, in, false); } catch (JAXBException e) { throw new DeploymentException("Could not parse persistence.xml file: " + persistenceUrl, e);
private void mergeWebFragments(final WebModule webModule) { // web-fragment.xml, to get jndi entries to merge, other stuff is done by tomcat ATM final Collection<URL> urls = Collection.class.cast(webModule.getAltDDs().get("web-fragment.xml")); if (urls != null) { for (final URL rawUrl : urls) { if (rawUrl != null) { final Source url = getSource(rawUrl); try { final WebFragment webFragment = WebFragment.class.cast(JaxbJavaee.unmarshal(WebFragment.class, url.get(), false)); // in tomcat if the env entry is already don't override it mergeOnlyMissingEntries(webModule.getWebApp().getPersistenceContextRefMap(), webFragment.getPersistenceContextRef()); mergeOnlyMissingEntries(webModule.getWebApp().getPersistenceUnitRefMap(), webFragment.getPersistenceUnitRef()); mergeOnlyMissingEntries(webModule.getWebApp().getMessageDestinationRefMap(), webFragment.getMessageDestinationRef()); mergeOnlyMissingEntries(webModule.getWebApp().getDataSourceMap(), webFragment.getDataSource()); mergeOnlyMissingEntries(webModule.getWebApp().getEjbLocalRefMap(), webFragment.getEjbLocalRef()); mergeOnlyMissingEntries(webModule.getWebApp().getEjbRefMap(), webFragment.getEjbRef()); mergeOnlyMissingEntries(webModule.getWebApp().getServiceRefMap(), webFragment.getServiceRef()); mergeOnlyMissingEntries(webModule.getWebApp().getEnvEntryMap(), webFragment.getEnvEntry()); mergeOnlyMissingEntries(webModule.getWebApp().getResourceEnvRefMap(), webFragment.getResourceEnvRef()); mergeOnlyMissingEntries(webModule.getWebApp().getResourceRefMap(), webFragment.getResourceRef()); } catch (final Exception e) { logger.warning("can't read " + url.toString(), e); } } } } }
private void mergeWebFragments(final WebModule webModule) { // web-fragment.xml, to get jndi entries to merge, other stuff is done by tomcat ATM final Collection<URL> urls = Collection.class.cast(webModule.getAltDDs().get("web-fragment.xml")); if (urls != null) { for (final URL rawUrl : urls) { if (rawUrl != null) { final Source url = getSource(rawUrl); try { final WebFragment webFragment = WebFragment.class.cast(JaxbJavaee.unmarshal(WebFragment.class, url.get(), false)); // in tomcat if the env entry is already don't override it mergeOnlyMissingEntries(webModule.getWebApp().getPersistenceContextRefMap(), webFragment.getPersistenceContextRef()); mergeOnlyMissingEntries(webModule.getWebApp().getPersistenceUnitRefMap(), webFragment.getPersistenceUnitRef()); mergeOnlyMissingEntries(webModule.getWebApp().getMessageDestinationRefMap(), webFragment.getMessageDestinationRef()); mergeOnlyMissingEntries(webModule.getWebApp().getDataSourceMap(), webFragment.getDataSource()); mergeOnlyMissingEntries(webModule.getWebApp().getJMSConnectionFactoriesMap(), webFragment.getJMSConnectionFactories()); mergeOnlyMissingEntries(webModule.getWebApp().getEjbLocalRefMap(), webFragment.getEjbLocalRef()); mergeOnlyMissingEntries(webModule.getWebApp().getEjbRefMap(), webFragment.getEjbRef()); mergeOnlyMissingEntries(webModule.getWebApp().getServiceRefMap(), webFragment.getServiceRef()); mergeOnlyMissingEntries(webModule.getWebApp().getEnvEntryMap(), webFragment.getEnvEntry()); mergeOnlyMissingEntries(webModule.getWebApp().getResourceEnvRefMap(), webFragment.getResourceEnvRef()); mergeOnlyMissingEntries(webModule.getWebApp().getResourceRefMap(), webFragment.getResourceRef()); } catch (final Exception e) { logger.warning("can't read " + url.toString(), e); } } } } }