Home » Archives for Byron Kiourtzoglou » Page 20

Author Archives: Byron Kiourtzoglou

Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.

Modify Java object in script

With this example we are going to demonstrate how to modify a Java object in script. In short, to modify a Java object using script we have followed the steps below: Create a new ScriptEngineManager. The ScriptEngineManager implements a discovery and instantiation mechanism for ScriptEngine classes and also maintains a collection of key/value pairs storing state shared by all engines created ...

Read More »

Evaluate a script file

With this example we are going to demonstrate how to evaluate a simple script file in Java. We are using the ScriptEngine interface that provides methods for the basic scripting functionality. In short, to evaluate a script file you should: Create a new ScriptEngineManager. The ScriptEngineManager implements a discovery and instantiation mechanism for ScriptEngine classes and also maintains a collection ...

Read More »

Access Java Object from a script

In this example we shall show you how to access a Java Object from a script. We are using the ScriptEngine interface that provides methods for the basic scripting functionality. To access a Java Object from a script one should perform the following steps: Create a new ScriptEngineManager. The ScriptEngineManager implements a discovery and instantiation mechanism for ScriptEngine classes and also maintains ...

Read More »

Decorating classes at injection time with Java EE 6

Let’s say you have a ticket service that lets you order tickets for a certain event. The TicketService handles the registration etc, but we want to add catering. We don’t see this as part of the ticket ordering logic, so we created a decorator. The decorator will call the TicketService and add catering for the number of tickets. The interface: ...

Read More »

client server communication example

The Server.java import gnu.cajo.Cajo; // The cajo implementation of the Grail public class Server { public static class Test { // remotely callable classes must be public // though not necessarily declared in the same class private final String greeting; // no silly requirement to have no-arg constructors public Test(String greeting) { this.greeting = greeting; } // all public methods, ...

Read More »

JUnit Rules Example

The implementation of a Rule might look like this: import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; public class LoggingRule implements TestRule { public class LoggingStatement extends Statement { private final Statement statement; public LoggingStatement(Statement aStatement, String aName) { statement = aStatement; } @Override public void evaluate() throws Throwable { System.out.println("before: " + name); statement.evaluate(); System.out.println("after: " + name); } } private ...

Read More »

Delete File from FTP Server

This is an example of how to delete a File from an FTP Server. We are using the org.apache.commons.net.ftp.FTPClient Class that encapsulates all the functionality necessary to store and retrieve files from an FTP server. Deleting a File from an FTP Server implies that you should: Create a new FTPClient. Use connect() API method to open a connection to the FTP ...

Read More »

Establish connection with FTP Server

With this example we are going to demonstrate how to establish a connection with an FTP Server. We are using the org.apache.commons.net.ftp.FTPClient Class that encapsulates all the functionality necessary to store and retrieve files from an FTP server. In short, to establish a connection with an FTP Server you should: Create a new FTPClient. Use connect() API method to open a ...

Read More »

File Upload to FTP Server

In this example we shall show you how to upload a File to an FTP Server, using the org.apache.commons.net.ftp.FTPClient Class, that encapsulates all the functionality necessary to store and retrieve files from an FTP server. To upload a File to an FTP Server one should perform the following steps: Create a new FTPClient. Use connect() API method to open a connection ...

Read More »

Capitalize words of a string

This is an example of how to capitalize the words of a String. We are using the org.apache.commons.lang3.text.WordUtils Class, that provides operations on Strings that contain words. The Class tries to handle null input gracefully. An exception will not be thrown for a null input. Trying to capitalize the words of a String implies that you should: Use capitalize(String str) API ...

Read More »