Skip to content

Instantly share code, notes, and snippets.

View jonashackt's full-sized avatar
:octocat:
TDD & CI for IaC FTW!

Jonas Hecht jonashackt

:octocat:
TDD & CI for IaC FTW!
View GitHub Profile
@jonashackt
jonashackt / gist:5ad8cf0c5af0b436ae38
Created April 16, 2015 13:36
Create non-executable jar maven
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
@jonashackt
jonashackt / package-info.java
Created April 27, 2015 13:04
generated out-of-the-box
@javax.xml.bind.annotation.XmlSchema(
namespace = "http://ws.cdyne.com/WeatherWS/",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
package com.cdyne.ws.weatherws;
@jonashackt
jonashackt / package-info.java
Created April 27, 2015 13:09
Edited generated File
@javax.xml.bind.annotation.XmlSchema(
namespace = "http://ws.cdyne.com/WeatherWS/",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
xmlns = {
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://ws.cdyne.com/WeatherWS/", prefix = "weather")
})
package com.cdyne.ws.weatherws;
@jonashackt
jonashackt / WebServiceConfig.java
Created April 27, 2015 13:16
JAXBDataBinding Spring-Configuration Bean, which should be set to the Apache CXF Endpoint
@Bean
public JAXBDataBinding jaxbDataBinding() {
JAXBDataBinding jaxbDataBinding = new JAXBDataBinding();
Map<String,String> namespaceMap = new HashMap<String, String>();
namespaceMap.put("http://ws.cdyne.com/WeatherWS/", "weather");
jaxbDataBinding.setNamespaceMap(namespaceMap);
return jaxbDataBinding;
}
@jonashackt
jonashackt / pom.xml
Last active August 29, 2015 14:20
configuration section jaxws-maven-plugin - Part 1
<configuration>
<!-- See https://jax-ws-commons.java.net/jaxws-maven-plugin/wsimport-mojo.html -->
<wsdlUrls>
<wsdlUrl>src/main/resources/Weather1.0.wsdl</wsdlUrl>
</wsdlUrls>
<sourceDestDir>target/generated-sources/wsdlimport/Weather1.0</sourceDestDir>
<!-- For accessing the imported schema, see https://netbeans.org/bugzilla/show_bug.cgi?id=241570 -->
<vmArgs>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
@jonashackt
jonashackt / pom.xml
Created April 27, 2015 13:48
configuration section jaxws-maven-plugin - Part 2
<!-- the binding.xml in the given directory is found automatically, because the directory is scanned for '.xml'-Files -->
<bindingDirectory>src/main/resources</bindingDirectory>
<!-- Arguments for JAXB2-Generator behind JAX-WS-Frontend -->
<args>
<arg>-extension</arg>
<!-- Thats a tricky parameter: The first '-B' is for passing the following argument to JAXB2-Generator
the second is needed to generate the human readable Namespace-Prefixes -->
<arg>-B-Xnamespace-prefix</arg>
</args>
</configuration>
@jonashackt
jonashackt / binding.xml
Created April 27, 2015 13:56
Defining Namespace-Prefixes for JAXB-Commons namespace-prefix Maven-Plugin
<?xml version="1.0"?>
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd
http://jaxb2-commons.dev.java.net/namespace-prefix http://java.net/projects/jaxb2-commons/sources/svn/content/namespace-prefix/trunk/src/main/resources/prefix-namespace-schema.xsd">
<jxb:bindings schemaLocation="Weather1.0.xsd">
<jxb:schemaBindings>
@jonashackt
jonashackt / ReadFile.java
Created April 28, 2015 07:17
Read Files Java 8
String requestFolder = "requests/";
String file;
URI filepathUrl = this.getClass().getClassLoader().getResource(requestFolder + fileName).toURI();
Path filepath = Paths.get(filepathUrl);
file = Files.lines(filepath).collect(Collectors.joining());
@jonashackt
jonashackt / Doc2String.java
Created April 30, 2015 13:11
org.w3c.dom.Document to String
private void printXML2Console(Node documentOrDocumentFragment)
throws TransformerFactoryConfigurationError,
TransformerConfigurationException,
TransformerException {
DOMSource domSource = new DOMSource(documentOrDocumentFragment);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(domSource, result);
@jonashackt
jonashackt / Appender.java
Created April 30, 2015 13:59
Append org.w3c.dom.Document as org.w3c.dom.Element to another org.w3c.dom.Document
// Document you want 2 append
Document document = ...;
// Create the Document
DocumentBuilderFactory docBuilderfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderfactory.newDocumentBuilder();
Document document2Append2 = docBuilder.newDocument();
// Copy the Document as ChildElement under a new Element
Element rootElement = document2Append2.createElement("root");