This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String[] args) { | |
int argument1 = 10000; | |
int argument2 = 9999; | |
method(argument1, argument2) | |
} | |
public static void method(int parameter1, int parameter2){ | |
System.out.println(parameter1); | |
System.out.println(parameter2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//A GET method in my stupid REST service for example..... | |
public Response sendMsg(String content, @QueryParam("msgType") String msgType) { | |
//Open class loader in try-with-resource | |
//Use null in constructor if you don't want to use parent class loader. | |
//In this case it's useful because I don't load any class from system classpath. | |
try (URLClassLoader clsLoader = URLClassLoader.newInstance(new URL[] {new URL("file:/lib/ACM_0.1.0.jar")}, null)){ | |
Class<?> clazz = clsLoader.loadClass("com.hs.acm.client.message.in." + msgType); | |
Object msgObj = clazz.newInstance(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private AcmClientReqMsg getObjectFromJSon(MapMessage msg) { | |
try { | |
String msgContent = msg.getString("msgContent"); | |
String msgType = msg.getString("msgType"); | |
switch (msgType) { | |
case "MsgType1": | |
return gson.fromJson(msgContent, MsgType1.class); | |
case "MsgType2": | |
return gson.fromJson(msgContent, MsgType2.class); | |
case "MsgType3": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.core.MediaType; | |
import javax.ws.rs.core.Response; | |
/** | |
* | |
* @author dangg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.servlet.ServletContextHandler; | |
import org.eclipse.jetty.servlet.ServletHolder; | |
import org.glassfish.jersey.servlet.ServletContainer; | |
/** | |
* | |
* @author dangg | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.*; | |
public interface TimeClient { | |
void setTime(int hour, int minute, int second); | |
void setDate(int day, int month, int year); | |
void setDateAndTime(int day, int month, int year, | |
int hour, int minute, int second); | |
LocalDateTime getLocalDateTime(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.*; | |
public interface TimeClient { | |
void setTime(int hour, int minute, int second); | |
void setDate(int day, int month, int year); | |
void setDateAndTime(int day, int month, int year, | |
int hour, int minute, int second); | |
LocalDateTime getLocalDateTime(); | |
ZonedDateTime getZonedDateTime(String zoneString); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.*; | |
public interface TimeClient { | |
void setTime(int hour, int minute, int second); | |
void setDate(int day, int month, int year); | |
void setDateAndTime(int day, int month, int year, | |
int hour, int minute, int second); | |
LocalDateTime getLocalDateTime(); | |
static ZoneId getZoneId (String zoneString) { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.hs.acm.client.message.in.AcmClientReqMsg; | |
import com.hs.acm.client.message.in.JoinCallReqMsg; | |
import java.net.URL; | |
import java.net.URLClassLoader; | |
public class Test { | |
public static void main(String[] args) throws Exception { | |
URL[] urls = new URL[]{new URL("file:./lib/ACM_0.1.0.jar"), | |
new URL("file:./lib/ActiveStudy.Utility.2.0.1.jar")}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.file.*; | |
import static java.nio.file.StandardWatchEventKinds.*; | |
/* | |
Author: NguyenHaiDang@ActiveStudy | |
*/ | |
public class Watcher { | |
public static void main(String[] args) { | |
Path this_dir = Paths.get("."); | |
System.out.println("Now watching the current directory ..."); |