java -jar C:/dev/tools/plantuml.jar -metadata startup.png
01 January 2016
Succesfully deployed my first AWS lambda. Actually it was tricky to access it externally via API gateway due to unclear documentation.
java -jar C:/dev/tools/plantuml.jar -metadata startup.png
So, coloring output of cargo under cygwin works… somehow.
great article about reactive programming
Great read: diploma thesis on Concurrent Programming for Scalable Web Architectures. Sums it up nicely.
Interesting thoughts about CDI. have to follow this blog by Laird Nelson.
Watched Testing made sweet with a Mockito
Capture method-arguments of mock-method-calls is possible.
Avoid creating new objects via "new". hard to test.
Avoid static methods. Hard to test.
Avoid singletons
Isolte non-testable code. E.g. views in MVP
Dont use mockito spies. Arggument is that tests might not be isolted if "real logic" is executed.
Write custom Mockito matcher. here
gradle build can be profiled; report is generated. nice. blog
Watched Maven for CDI Devoxx talk. Sources are here. Need to look into it further.
Building asciidoc with maven
<profile> <id>readme</id> <properties> <asciidoctor.maven.plugin.version>1.5.3</asciidoctor.maven.plugin.version> <asciidoctorj.version>1.5.4</asciidoctorj.version> <asciidoctorj.diagram.version>1.3.1</asciidoctorj.diagram.version> <jruby.version>1.7.21</jruby.version> </properties> <build> <plugins> <plugin> <groupId>org.asciidoctor</groupId> <artifactId>asciidoctor-maven-plugin</artifactId> <version>${asciidoctor.maven.plugin.version}</version> <dependencies> <!-- Comment this section to use the default jruby artifact provided by the plugin --> <dependency> <groupId>org.jruby</groupId> <artifactId>jruby-complete</artifactId> <version>${jruby.version}</version> </dependency> <!-- Comment this section to use the default AsciidoctorJ artifact provided by the plugin --> <dependency> <groupId>org.asciidoctor</groupId> <artifactId>asciidoctorj</artifactId> <version>${asciidoctorj.version}</version> </dependency> <dependency> <groupId>org.asciidoctor</groupId> <artifactId>asciidoctorj-diagram</artifactId> <version>${asciidoctorj.diagram.version}</version> </dependency> </dependencies> <executions> <execution> <id>output-html</id> <phase>generate-resources</phase> <goals> <goal>process-asciidoc</goal> </goals> <configuration> <sourceDirectory>.</sourceDirectory> <sourceDocumentName>README.adoc</sourceDocumentName> <backend>html</backend> <attributes> <!--toc>left</toc--> </attributes> </configuration> </execution> </executions> <configuration> <requires> <require>asciidoctor-diagram</require> </requires> <attributes> <!--graphvizdot>C:\dev\tools\graphviz-2.38\bin\dot.exe</graphvizdot--> </attributes> </configuration> </plugin> </plugins> </build> </profile>
Tried out Websphere Liberty Netbeans plugin. Built it myself for 8.2 but does not work. Issue filed.
Intereting read on how e.g. wildfly and websphere handle the CDI BeanManager differently.
Git behind the curtain. Insightful.
Great intro to VBox and HBox in JavaFx.
Watched this talk on the scenebuilder. Learned some neat tricks.
Launch mintty from eclipse:
$ cat .metadata/.plugins/org.eclipse.debug.core/.launches/Open\ shell.launch <?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"> <listAttribute key="org.eclipse.debug.ui.favoriteGroups"> <listEntry value="org.eclipse.ui.externaltools.launchGroup"/> </listAttribute> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="C:\cygwin64\bin\mintty.exe"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-e /bin/xhere /bin/bash.exe "${selected_resource_loc}""/> </launchConfiguration>
use of graylog is trivial
log4j.appender.graylog2=org.graylog2.log.GelfAppender # GELF UPD log4j.appender.graylog2.graylogHost=192.168.99.100 log4j.appender.graylog2.graylogPort=12201 log4j.appender.graylog2.originHost=loggenerator-server-ip log4j.appender.graylog2.layout=org.apache.log4j.PatternLayout log4j.appender.graylog2.additionalFields={'environment': 'DEV', 'application': 'MyAPP'} log4j.appender.graylog2.extractStacktrace=true log4j.appender.graylog2.addExtendedInformation=true log4j.appender.graylog2.facility=gelfappender-test
Also works generically for all different loggers: logstash-gelf
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.graylog2</groupId>
<artifactId>gelfj</artifactId>
<version>1.1.13</version>
</dependency>
Great talk on hijacking HTTP sessions. Very enlightening.
Prefer cookies over URL rewrite with JSESSIONID
web.xml cookie flags: secure & http-only
use https
validate input to protect against XSS
protected against session-fixation by creating new session-id after login
protected against crsf by unique token in each request
Does nbm maven plugin not support to install custom plugins my plugin depends on when i use the nbm:cluster goal? Seems so, need to run this after clean build:
cp /Users/daniel/Library/Application\ Support/NetBeans/8.2/modules/org-netbeans-gradle-project.jar modules/ cp /Users/daniel/Library/Application\ Support/NetBeans/8.2/config/Modules/org-netbeans-gradle-project.xml config/Modules/ cp -R /Users/daniel/Library/Application\ Support/NetBeans/8.2/modules/ext modules/ext
Great intro to event-sourcing: Handling Eventual Consistency in JVM Microservices with Event Sourcing
Arquillian with ant: here
Great talk on "Don’t Build a Distributed Monolith".
Started going through JavaOne sessions. Watched Ask the architects.
Watched great Java 8 Lambdas MOOC.
Started skimming through Javaworld talks. Watched great talk by David Blevins.
Finished watching great microservices talk by arun gupta.
Great talk on eclipse PDE tricks.
Plugin-Spy: ALT+SHIFT+F1 to see details of the selected plugin.
Plugin Registry to see plugins and extension points. There is also an CTRL+SHIFT+T like dialog.
DisplayView for debugging is nice
Add plugins to CTRL+SHIFT+T class search via context menu in plugin-view
Asciidoctor tips. gradle-plugin with continous build feature is great.
Had a first look into jigsaw: here and the official quick starter guide.
Good stuff on vim and tmux.
Ok, this seems to sum it up quiet nicely what options there are with git to handle CR/LF problems. .gitattributes is the solution. Legacy old way
core.autocrlf = input core.safecrlf = warn
Two interesting approaches to integration-test large JavaEE applications:
I like this even though it is dead simple stuff. But if you have a simple jar to build, sometimes even ant/maven are overkill. Just a two-line shell-script is fine.
javac -cp ./src/main/java ./src/main/java/com/exec/one/*.java -d ./out/ jar cvfm ExecutableOne.jar ./src/main/resources/META-INF/MANIFEST.MF -C ./out/ .
Watch vJug talk on bytecode.
Read this on JavaEE testing via arquillian and docker. It does not discuss Arquillian Cube but uses testcontainers. There even is a RemoteWebDriver to interact with dockerized selenium-based browser-tests. I have to check this in more detail.
This prior article is also nice to see how easily testcontainers can start a DB from an arquillian test.
Watched Git From the Bits Up. Creating a low-level commit:
git init echo "only work and no play make..." | git hash-object --stdin -w git cat-file -p ea5eb97b094197070c5865d5e17e8e63c3ee285d git update-index --add --cacheinfo 100644 ea5eb97b094197070c5865d5e17e8e63c3ee285d jonny.txt git write-tree git cat-file -p 6b5f7b67962e61c3f0dbe80ac8092713b5f74f2f git commit-tree 6b5f7b67962e61c3f0dbe80ac8092713b5f74f2f -m "Initial commit" git cat-file -p 9c0f5e1774d6c4abdad907ba92d4c53d76328fe1 echo 9c0f5e1774d6c4abdad907ba92d4c53d76328fe1 > .git/refs/heads/master git log git checkout HEAD -- jonny.txt git status
Improved my bash with bookmarks. Loving it. Also, nice talk on Git Mastery.
Watched this talk on Advanced Git. Checked this for good settings.
Great talk on git data-model here.
Watched Demistifyng dynamicinvoke by Venkat. Watched nice Advanced Git.
Finished Continuous Enterprise Development in Java. Great book on Arquillian.
Nice commandline-utility to track file changes. inotifywait. Works great under cygwin.
Effective Java Programming Language Guide is still the best. The free chapter on generics should be read by every Java programmer.
PECS stands for producer-extends, consumer-super
Do not use wildcard types as return types.
if a type parameter appears only once in a method declaration, replace it with a wildcard
Nice article for how to use the Java 8 API.
Great read on java agents and byte-code-manipulation with byte-buddy.
Interfacing with the wildfly http management interface with authentication enabled:
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("username", "password".toCharArray());
}
});
URL url = new URL("http://localhost:9990/management");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
wr.write("{\"address\":[\"subsystem\",\"naming\"],\"operation\":\"jndi-view\",\"json.pretty\":1}"
.getBytes());
}
try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
}
Did some JavaFX hacking.
Watched Do you really get class loaders?
Check MyClass.class.getClassLoader().getResource(…) to load class as resource and see wher located.
Use javap -private to see class details
Use -verbose:class
-XX:+HeapDumpOnOutOfMemoryError (use eclipse memory analyzer)
Watched JVM Bytecode for Dummies
javap -c -verbose
bitescript: Ruby DSL that looks close to bytecode
Continous Delivery: Every build could be a release. Maven has concept of SNAPSHOTs that by itself are not releases. Not reproduceable. Thus, generate releases each time instead of SNAPSHOT.
Also slow: You do mvn release:prepare and mvn release:perform seperately. So, two times compile, test, … cycle
Split up unit- and integration-tests. Run unit tests in test-phase and integration-tests in integration-test phase. Fail fast on unit-tests.
Multi-module builds: mvn deploy would deploy first artifact and then might fail on the second. → Do mvn deploy:deploy after all mvn install done.
Generate JaCoCo coverage report after integration-test phase
dont run mvn site in build because slow. instead e.g. call mvn pmd:check , mvn findbugs:check, mvn checkstyle:checkstyle directly. And fail build on violations.
Don’t use mvn release plugin. Does not fit nicely. SNAPSHOTS are not versioned. So, release is needed to push through pipeline. If always release, then maybe blocking the pipeline. If always SNAPSHOT first, it is cluncy because do stuff again for release → Work with SNAPSHOT but give it a version-number/buildnumber as soon as it enters the pipeline. Use mvn versions plugin (mvn versions:set -DnewVersion=1.0.203)
Watched Hacking on Wildfly 9.
Build only specific reactor project and specific test to execute:
mvn clean install -pl testsuite/standalone/ -Dtest=MyTestClass
Created my jmh benchmark to check on some IO performance. Neat project and nice maven intregration/archetype.
@BenchmarkMode(Mode.AverageTime)
public class FileAccessTest {
@Benchmark
public void testFileAccess() {
//...
}
}
Set mem limits and enable GC-log:
-Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=128m -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:gc.log
So, no idea why, but to make eclipse not behave strange sometimes, setting -vm with JDK path in eclipse.ini (otherwise, JBoss forge was complaining that it could not install arquillian plugin because not able to compile):
-vm C:\Program Files\Java\jdk1.8.0_71\bin\javaw
Set up my nexus/sonatype access. Maven stuff described here.
Watched Immutability Changes Everything.
Looking into JBoss Forge and integration with Arquillian. Really nice.
By the way, this seems to be the latest adapter to use for wildfly (JBoss Tools use an older one):
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<version>1.1.0.Final</version>
<scope>test</scope>
</dependency>
Watched Advanced Annotation Processing with JSR 269. Sources here. And more reading here and here.
Got the annotation processor to work in eclipse after manual activation of annoatations jar and setting to batch-mode. But code-completion not yet working.
@SupportedAnnotationTypes({"example.ServiceConfig"})
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class Processor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (Element element : roundEnv.getElementsAnnotatedWith(ServiceConfig.class)) {
processingEnv.getMessager().printMessage(Kind.WARNING, "++Found: " + element.getSimpleName(), null);
}
return true;
}
}
JCA deep-dive for me today. Implemented own small file-JCA-connector based on connectorz. Also found this resource interesting.
Also, watched talk on CQRS.
Reading dzone’s summary of Domain Driven Design. Nice recap.
Great read on microservices. Spotify’s organizational structure.
Watched vJug session on Junit 5.
Read up on caching with JPA. Nice summary here: Cache-coordination versus distributed caching, transactional versus non-transactional caches…
Watched latest airhacks episode. Also read up on serverless architectures. Also, this one adption of the microservice approach.
Skimmed through some talks today:
Cashless 3 0 Java EE 7 Proves Effective for Mission Critical E Payment Systems
Are You Aware of the /bin of Your JDK?: javap, jps, jinfo, jmap, jhat, stack -l (for monitors and owners), (or kill -3), jstat (like iostat), jcmd
Java EE in Practice at Lufthansa Industry Solutions: Implementing ViewScoped in Java EE 6
Taming Microservices Testing with Docker and Arquillian Cube
Watched microservices talk. Slides are here.
Especially useful was the part on cascading timeouts: first system has biggest timeout; budget gets small for services upstream.
Forked/checked out jgit and egit. That was some sweat…
Neat thing from the Developer Notes: Using a .p2f file to import/export required plugins (File/Import/Install/…). Maybe i don’t need a bash-script :-)
Provision eclipse plugins from the commandline (cygwin/bash/win7). Here for eclipse neon update-sites:
// download a plugin-zip; as an example how to provision a local zip-file
curl -L -J -O -x http://proxy.wincor-nixdorf.com:81 https://github.com/java-decompiler/jd-eclipse/releases/download/v1.0.0/jd-eclipse-site-1.0.0-RC2.zip
pushd eclipse
EXE=./eclipsec.exe
# Eclemma
ECLEMMA_IU=$($EXE -application org.eclipse.equinox.p2.director -noSplash -repository http://update.eclemma.org -list | grep EclEmma | cut -d= -f1)
echo "Installing ${ECLEMMA_IU}..."
$EXE -application org.eclipse.equinox.p2.director -noSplash -repository http://update.eclemma.org -installIUs ${ECLEMMA_IU}
# Plantuml
$EXE -application org.eclipse.equinox.p2.director -noSplash -repository http://plantuml.sourceforge.net/updatesitejuno/ -installIU net.sourceforge.plantuml
# AspectJ
$EXE -application org.eclipse.equinox.p2.director -noSplash -repository http://download.eclipse.org/tools/ajdt/46/dev/update -installIU org.eclipse.ajdt.feature.group
# Groovy
$EXE -application org.eclipse.equinox.p2.director -noSplash -repository http://dist.springsource.org/snapshot/GRECLIPSE/e4.5 -installIUs org.codehaus.groovy.eclipse.feature.feature.group
# Ivy
$EXE -application org.eclipse.equinox.p2.director -noSplash -repository http://www.apache.org/dist/ant/ivyde/updatesite -installIUs org.apache.ivyde.feature.feature.group
# ivy settings; rootdir und externalibs.props
# Java Decompiler; example for a locally zipped plugin
set +H
$EXE -application org.eclipse.equinox.p2.director -noSplash -repository jar:file:/$(cygpath -m ../jd-eclipse-site-1.0.0-RC2.zip)!/ -installIUs jd.ide.eclipse.feature.feature.group$EXE -application
set -H
JBOSS_UPDATE_SITE="http://download.jboss.org/jbosstools/neon/stable/updates/"
# JBoss Tools - General Tools
GENERAL_TOOLS=$($EXE -application org.eclipse.equinox.p2.director -noSplash -repository ${JBOSS_UPDATE_SITE} -list | grep GeneralTools | cut -d= -f1)
$EXE -application org.eclipse.equinox.p2.director -noSplash -repository ${JBOSS_UPDATE_SITE} -installIUs $GENERAL_TOOLS
# JBoss Tools - Web Tools
WEB_TOOLS=$($EXE -application org.eclipse.equinox.p2.director -noSplash -repository ${JBOSS_UPDATE_SITE} -list | grep WebTools | cut -d= -f1)
$EXE -application org.eclipse.equinox.p2.director -noSplash -repository ${JBOSS_UPDATE_SITE} -installIUs $WEB_TOOLS
# JBoss Tools - Server Adapter
$EXE -application org.eclipse.equinox.p2.director -noSplash -repository ${JBOSS_UPDATE_SITE} -installIUs grep org.eclipse.wst.server.core.serverAdapter
# Forge
$EXE -application org.eclipse.equinox.p2.director -noSplash -repository ${JBOSS_UPDATE_SITE} -installIU org.jboss.tools.forge.feature.feature.group
popd
Had to debug an eclipse plugin today but did not want to run a second instance of eclipse for the debugger; so I used jdb. It is a nice tool. Connecting the debugger via shared-memory versus as socket is configured slightly different:
-Xdebug // shared-memory (windows only) -agentlib:jdwp=transport=dt_shmem,address=eclipse,server=y,suspend=n // socket -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999
Then attach via:
// shared-memory (windows only) jdb -attach eclipse -sourcepath <path> // socket jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=9999 -sourcepath <path>
Some nice stuff:
trace go methods
traces methods on a thread
How to connect to a PID or a core-dump.
TODO: Try to look into all the tools listed here.
TODO: The handling of proxies with jGit could be improved. Got this info from forums. Will try to fix.
Wireshark comes with a nice commandline-interface called tshark
. Detailed in this article. For Windows (7)/cygwin, it was a little bit more than just the line below:
./tshark -i LAN-Verbindung -Y 'http.request.method == "GET"' -T fields -e http.request.method -e http.request.uri -e ip.dst
We also need to make sure the packets go through the whole network-stack of windows as the loopback-interface cannot be sniffed out of the box:
// before route add <external-ip> <external-gateway-ip> // after/cleanup route delete <external-ip>
Details are described in this post.
Did vert.x introductory tutorial. Very well written.
Nice overview on what spring has to offer for microservices.
Read this articel on the shades of the CAP theorem.
Watched Nine "Neins" on Java EE future. Interesting talk on what Java EE8+ should maybe adress…
Getting cargo-tracker to run on wildfly 10.
Default datasources in Java EE 7. But need to 'enable_lazy_load_no_trans':
<persistence-unit name="CargoTrackerUnit" transaction-type="JTA"> <properties> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="true" /> <property name="hibernate.enable_lazy_load_no_trans" value="true" /> <property name="hibernate.transaction.flush_before_completion" value="true" /> <property name="javax.persistence.schema-generation.database.action" value="create"/> </properties> </persistence-unit>
JCA offers:
Connection Management
Transaction Management: participate in a JTA transaction
Security
Lifecycle
Workload Management (hand of work to app-server threads. think runnable.)
Presented sources for inbound connector here. More inbound connectors from tomitribe.io.
Outbound examples from link:http://connectorz.adam-bien.com.
Watched TUT2376 Advanced CDI in Live Coding.
Metrics via CDI (part of Deltaspike)
How to enhance annotations for CDI (@InterceptorBinding, @Nobinding)
How to enhance a producer; e.g. caching
How to integrate CDI into Apache Camel
Looking into JBoss Forge. Eclipse Integration is nice: Ctrl+4 and Forge-Console view.
Watched David Blevins talk on custom CDI scopes. Playing with microscoped.
Integrated microscoped into my project for playing around; took me some time to find that I did not put the interceptor into my beans.xml.
Watched Reza Rahman’s Testing Java EE Applications using Arquillian. The Git repo with examples is here
I love multitail! Monitor multiple logs merged into one with different color for each log (similar to docker-compose output):
multitail --retry-all --mergeall -ci green -i server.log -ci blue -i access-log.txt
Watched Reza Rahman’s Down-to-Earth Microservices with Vanilla Java EE
Read Martin Fowler’s MonolithFirst