public static <T>String marshal(Class<T> type, Object object) throws JAXBException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); marshal(type, object, baos); return new String(baos.toByteArray()); }
InputStream in = wsDDUrl.openStream(); try { return (Webservices) JaxbJavaee.unmarshalJavaee(Webservices.class, in); } catch (Exception e) { throw new DeploymentException("Could not read descriptor document", e);
@Override public void run() { try { JaxbJavaee.getContext(type); } catch (JAXBException e) { } } }
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; }
final URL javaeeSchemaURL = resolveJavaeeSchemaURL(type); if (javaeeSchemaURL == null) { throw new IllegalArgumentException("Can not find the xsd file against type:" + type); final URL xmlSchemaURL = JaxbJavaee.getSchemaURL("xml.xsd"); if (xmlSchemaURL == null) { throw new IllegalArgumentException("Can not find the xml.xsd file");
private static URL resolveJavaeeSchemaURL(final JavaeeSchema type) { URL schemaURL = null; if (type.equals(JavaeeSchema.WEB_APP_3_0)) { //will include web-common.xsd, jsp_2_2.xsd, javaee_6.xsd and javaee_web_services_client_1_3.xsd schemaURL = JaxbJavaee.getSchemaURL(JavaeeSchema.WEB_APP_3_0.getSchemaFileName()); } else if (type.equals(JavaeeSchema.EJB_JAR_3_1)) { schemaURL = JaxbJavaee.getSchemaURL(JavaeeSchema.EJB_JAR_3_1.getSchemaFileName()); } else if (type.equals(JavaeeSchema.APPLICATION_6)) { schemaURL = JaxbJavaee.getSchemaURL(JavaeeSchema.APPLICATION_6.getSchemaFileName()); } else if (type.equals(JavaeeSchema.APPLICATION_CLIENT_6)) { schemaURL = JaxbJavaee.getSchemaURL(JavaeeSchema.APPLICATION_CLIENT_6.getSchemaFileName()); } else if (type.equals(JavaeeSchema.CONNECTOR_1_6)) { schemaURL = JaxbJavaee.getSchemaURL(JavaeeSchema.CONNECTOR_1_6.getSchemaFileName()); } return schemaURL; }
@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); } }
final URL javaeeSchemaURL = resolveJavaeeSchemaURL(type); if (javaeeSchemaURL == null) { throw new IllegalArgumentException("Can not find the xsd file against type:" + type); final URL xmlSchemaURL = JaxbJavaee.getSchemaURL("xml.xsd"); if (xmlSchemaURL == null) { throw new IllegalArgumentException("Can not find the xml.xsd file");
private static URL resolveJavaeeSchemaURL(final JavaeeSchema type) { URL schemaURL = null; if (type.equals(JavaeeSchema.WEB_APP_3_0)) { //will include web-common.xsd, jsp_2_2.xsd, javaee_6.xsd and javaee_web_services_client_1_3.xsd schemaURL = JaxbJavaee.getSchemaURL(JavaeeSchema.WEB_APP_3_0.getSchemaFileName()); } else if (type.equals(JavaeeSchema.EJB_JAR_3_1)) { schemaURL = JaxbJavaee.getSchemaURL(JavaeeSchema.EJB_JAR_3_1.getSchemaFileName()); } else if (type.equals(JavaeeSchema.APPLICATION_6)) { schemaURL = JaxbJavaee.getSchemaURL(JavaeeSchema.APPLICATION_6.getSchemaFileName()); } else if (type.equals(JavaeeSchema.APPLICATION_CLIENT_6)) { schemaURL = JaxbJavaee.getSchemaURL(JavaeeSchema.APPLICATION_CLIENT_6.getSchemaFileName()); } else if (type.equals(JavaeeSchema.CONNECTOR_1_6)) { schemaURL = JaxbJavaee.getSchemaURL(JavaeeSchema.CONNECTOR_1_6.getSchemaFileName()); } return schemaURL; }
public static JavaWsdlMapping readJaxrpcMapping(JarFile moduleFile, String jaxrpcMappingPath) throws DeploymentException { InputStream jaxrpcInputStream; try { ZipEntry zipEntry = moduleFile.getEntry(jaxrpcMappingPath); if (zipEntry == null) { throw new DeploymentException("The JAX-RPC mapping file " + jaxrpcMappingPath + " specified in webservices.xml could not be found."); } jaxrpcInputStream = moduleFile.getInputStream(zipEntry); } catch (IOException e) { throw new DeploymentException("Could not open stream to jaxrpc mapping document", e); } try { return (JavaWsdlMapping) JaxbJavaee.unmarshalJavaee(JavaWsdlMapping.class, jaxrpcInputStream); } catch (Exception e) { throw new DeploymentException("Could not parse jaxrpc mapping document", e); } finally { try { jaxrpcInputStream.close(); } catch (IOException e) { } } }
public static <T> String marshal(final Class<T> type, final Object object) throws JAXBException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); marshal(type, object, baos); return new String(baos.toByteArray()); }
public static <T>void marshal(Class<T> type, Object object, OutputStream out) throws JAXBException { JAXBContext ctx2 = JaxbJavaee.getContext(type); Marshaller marshaller = ctx2.createMarshaller(); marshaller.setProperty("jaxb.formatted.output", true); marshaller.marshal(object, out); }
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; }
public static JavaWsdlMapping readJaxrpcMapping(final URL url) throws OpenEJBException { final JavaWsdlMapping wsdlMapping; try { wsdlMapping = (JavaWsdlMapping) JaxbJavaee.unmarshalJavaee(JavaWsdlMapping.class, IO.read(url)); } catch (final SAXException e) { throw new OpenEJBException("Cannot parse the JaxRPC mapping file: " + url.toExternalForm(), e); } catch (final JAXBException e) { throw new OpenEJBException("Cannot unmarshall the JaxRPC mapping file: " + url.toExternalForm(), e); } catch (final IOException e) { throw new OpenEJBException("Cannot read the JaxRPC mapping file: " + url.toExternalForm(), e); } catch (final Exception e) { throw new OpenEJBException("Encountered unknown error parsing the JaxRPC mapping file: " + url.toExternalForm(), e); } return wsdlMapping; }
public static <T> String marshal(final Class<T> type, final Object object) throws JAXBException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); marshal(type, object, baos); return new String(baos.toByteArray()); }
public static <T> void marshal(final Class<T> type, final Object object, final OutputStream out) throws JAXBException { final JAXBContext ctx2 = JaxbJavaee.getContext(type); final Marshaller marshaller = ctx2.createMarshaller(); marshaller.setProperty("jaxb.formatted.output", true); marshaller.marshal(object, out); }
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 JavaWsdlMapping readJaxrpcMapping(final URL url) throws OpenEJBException { final JavaWsdlMapping wsdlMapping; try { wsdlMapping = (JavaWsdlMapping) JaxbJavaee.unmarshalJavaee(JavaWsdlMapping.class, IO.read(url)); } catch (final SAXException e) { throw new OpenEJBException("Cannot parse the JaxRPC mapping file: " + url.toExternalForm(), e); } catch (final JAXBException e) { throw new OpenEJBException("Cannot unmarshall the JaxRPC mapping file: " + url.toExternalForm(), e); } catch (final IOException e) { throw new OpenEJBException("Cannot read the JaxRPC mapping file: " + url.toExternalForm(), e); } catch (final Exception e) { throw new OpenEJBException("Encountered unknown error parsing the JaxRPC mapping file: " + url.toExternalForm(), e); } return wsdlMapping; }
@Override public InputStream openStream() { try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); JaxbJavaee.marshal(descriptor.getClass(), descriptor, out); return new ByteArrayInputStream(out.toByteArray()); } catch (final JAXBException e) { throw new IllegalArgumentException("Unable to marshal descriptor", e); } } }
public static <T> void marshal(final Class<T> type, final Object object, final OutputStream out) throws JAXBException { final JAXBContext ctx2 = JaxbJavaee.getContext(type); final Marshaller marshaller = ctx2.createMarshaller(); marshaller.setProperty("jaxb.formatted.output", true); marshaller.marshal(object, out); }