Skip to content

Instantly share code, notes, and snippets.

package com.tectonica;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.nodes.Tag;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
@zach-m
zach-m / Jetty 9 + Weld 2 + Jersey 2 + Jackson 2 + Maven
Last active July 1, 2023 20:25
Jetty 9 + Weld 2 + Jersey 2 + Jackson 2 + Maven
This is a template for creating and running a Jetty web application, using Jersey + Jackson for REST, and Weld for CDI.
It is organized as a maven project, which builds a WAR file deployable to a standalone Jetty server.
The Jetty maven plugin - which is more suitable for development time - is also configured in the pom.xml.
Comments:
* As Jetty is a servlet-3.0 compatible container, no configuration is needed in web.xml
* Due to a bug in maven, it's required to use version 3.2.2 or above
* The JaxRs API classes are to be placed at the package - or below - the one where 'RestConfig.java' is
* When using in standalone Jetty installation, enable the 'cdi' module before deploying
>> java -jar start.jar --add-to-startd=cdi
@zach-m
zach-m / LogConfigConsole.java
Last active August 29, 2015 14:13
J.U.L initialization class
package com.tectonica.log;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.ConsoleHandler;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogManager;
@zach-m
zach-m / GaeEmailSender.java
Last active August 29, 2015 14:06
Wrapper for sending emails using GAE JavaMail implementation (which is different - in several aspects - from Oracle's)
package com.tectonica.util;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.mail.BodyPart;
import javax.mail.Message;
@zach-m
zach-m / EmailSender.java
Last active February 7, 2020 14:26
Utility class to use JavaMail without the hassle of Multipart assembling
package com.tectonica.util;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.mail.Authenticator;
import javax.mail.BodyPart;