0

What is jHipster at SoftUni Conf, March, 2015

Posted by JOKe on 5/12/2015 04:15:00 PM in
This is a small 10min talk that I made about jHipster. JHipster is a yeoman generator that can create a spring boot/jpa application with angular and bootstrap for a minute.

I am not fan of code generation but .. its something that may help us doing presentations or preparing an example.

The talk is in Bulgarian again



|
0

RAD with Spring @SoftUni Conf, March, 2015

Posted by JOKe on 5/12/2015 03:57:00 PM in , ,

This is a video of the presentaiton about Rapid Application Development with Spring that I made at SoftUni conf.

The video is in Bulgarian :( ... again :(



|
0

Software University : Fast REST API with Spring

Posted by JOKe on 2/12/2015 09:54:00 AM in ,
This is video from the presentation I did for Software University  conf at Sofia, Bulgaria.
And here is the presentation (slideshare) only.


All demos can be downloaded from here https://github.com/gochev/examples/tree/master/SoftUni%20Rest%20Spring
If you missed the event .. don't miss the next one. In Bulgarian Java User Group we do events like this one every month. Information about past and future events can be found here http://java-bg.org/events/

|
0

Software University Conference Presentation about Java 8

Posted by JOKe on 10/13/2014 12:09:00 PM in
This is video from the presentation I did for Software University  conf at Borovetz, Bulgaria.
And here is the presentation (slideshare) only.


I recommend to watch the previous video in my post bellow since it has more content (but I speak a bit faster there :) )

|
1

My Presentation about "Beyond new things in Java" which I held at javaday.bg event.

Posted by JOKe on 7/18/2014 08:24:00 PM in
My Presentation about "Beyond new things in Java" which I held at javaday.bg event, organized by trader.bg.

(IN BULGARIAN)


And this is the presentation only:


 

|
0

Patching a Maven library with your custom class.

Posted by JOKe on 7/18/2014 11:01:00 AM in
Sometimes you use a library that has a bug. Or maybe it doesn’t has a bug but you want to change something. Of course if it is an open source you can get the sources… build them … with your change and so on. However this first takes a lot of time and second you need the sources.
What you usually want .. is to just replace one class.. or few classes with something custom… maybe add a line .. or remove a line and so on.
Yesterday… I had an issue with jboss-logging. The version I was using was 3.2.0Beta1 and it turns out that using this version and log4j2 2.0 final basically meant that no log is send to log4j2. The reason was a null pointer exception that was catched in jboss logging class called Log4j2Logger. The bug I submitted is here https://issues.jboss.org/browse/JBLOGGING-107 and it was fixed at the same day. However I will use it as an example since I didn’t knew when this will be fixed.. and I didn’t want to wait till it is fixed.
So I was thinking what I want.. to take the jboss-logging  jar  and replace the file called Log4j2Logger. Basically as you can see in the bug I wanted to replace line 54 to be :
instead of :
this.logger.log(null, loggerClassName, translatedLevel,
parameters == null || parameters.length == 0 ? this.messageFactory.newMessage(message) :
this.messageFactory.newMessage(String.valueOf(message), parameters),
thrown);
to become :
this.logger.log(translatedLevel, parameters == null || parameters.length == 0 ? this.messageFactory.newMessage(message) : this.messageFactory.newMessage(String.valueOf(message), parameters),

And that’s it. Of course I didn’t wanted to do this manually with zip Усмивка but to use maven as well.

So what I did:

1) I created a new maven project and added as dependency the jboss-logging.
2) I set the new project groupid and artifactid as the ones in the dependancy.
I set the version to be something like “3.2.0.Beta1-log4j2-npe-fix” so I added –log4j2-npe-fix
3) I used a plugin that takes the original version, unpacks the original jar in target WITHOUT the class I want to patch in this case Log4j2Logger.class and added my own implementation in the sources of my project.
4) And well thats all... ones I build.. my patched class will go in target.. and the original classes except the class I want to patch will also go in target and voala.. I will have a library which is patched.
The full pom.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>

    <groupId>org.jboss.logging</groupId>
    <artifactId>jboss-logging</artifactId>
    <version>3.2.0.Beta1-log4j2-npe-fix</version>
    <dependencies>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>3.2.0.Beta1</version>
            <type>jar</type>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.jboss.logging</groupId>
                                    <artifactId>jboss-logging</artifactId>
                                    <version>3.2.0.Beta1</version>
                                    <type>jar</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${project.build.directory}/classes</outputDirectory>
                                    <excludes>
                                        **/Log4j2Logger.class
                                    </excludes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
 

and that’s it.. the only thing left is to update my project to use my version 3.2.0.Beta1-log4j2-npe-fix instead of the original 3.2.0.Beta1.



I hope this will help to someone to save time.
  
 

|
1

spring-loaded rocks !

Posted by JOKe on 4/22/2014 09:37:00 PM

Today I found spring loaded (https://github.com/spring-projects/spring-loaded)

in short this is a java agent that enables class reloading of already running VM.

Simply this means zero deployment time (in many cases).

It is like a free and open source alternative of JRebel.

Spring Loaded allows you to add/modify/delete methods/fields/constructors. The annotations on types/methods/fields/constructors can also be modified and it is possible to add/remove/change values in enum types.

There is a preliminary java8 support. There is also another project DCEVM ( which is also great but supports only till JRE 6 update 26). More info here http://ssw.jku.at/dcevm/

But lets stop speaking and show you how it works.

In short you just need to pass the agent when starting the vm and that’s it.

>java -javaagent:D:/Downloads/springloaded-1.2.0.BUILD-20140409.201438-12.jar -noverify org.gochev.MainClass

I am using this Build since I am running Java 8 and this is currently the latest .

The code I in my simple app is the following:

A POJO like this :

package org.gochev;

public class DynamicReloadedClass {
private int age = 30;

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}
}




and a MainClass like this:



package org.gochev;

import java.util.Scanner;

public class MainClass {
public static void main(String[] args) {
try (Scanner scanner = new Scanner(System.in)) {
while (true) {
System.out.println("test "
+ new DynamicReloadedClass().getAge());
scanner.next();
}
}
}
}


So I can change the DynamicReloadedClass while the main method in the MainClass is looping. You can see this in action here :



http://www.screencast.com/t/KIFIxv7j



Awesome ... and free ! 


|

Copyright © 2009 JOKe's Blog All rights reserved. Theme based on the Theme by Laptop Geek with changes by JOKe. | Bloggerized by FalconHive.