Skip to main content

Posts

Showing posts from December, 2009

per-thread Singleton and per-thread Logging in Java

Usage of ThreadLocal : per-thread Singleton and per-thread Logging Should you require a refresh of what ThreadLocal s in Java are and how they work, refer to this article first. You can then proceed with the current article for understanding two of the most common uses of ThreadLocal s in Java. per-thread Singleton impl using ThreadLocal Suppose you have a need of having a JDBC Connection objects per thread of your application. The moment you hear the term 'per-thread', ThreadLocal automatically comes into mind as that's what it's primarily meant for. Below is a sample implementation of how easily can you actually use ThreadLocal for a per-thread JDBC Connection object in Java.

Marker Interface in Java: what, why, uses, etc.

What are Marker Interfaces in Java? An empty interface having no methods or fields/constants is called a marker interface or a tag interface. This of course means if the interface is extending other interfaces (directly or indirectly) then the super interfaces must not have any inheritable member (method or field/constant) as otherwise the definition of the marker interface (an entirely empty interface) would not be met. Since members of any interface are by default ' public ' so all members will be inheritable and hence we can say for an interface to be a marker interface, all of its direct or indirect super interfaces should also be marker. (Thanks marco for raising the point. I thought it was obvious, but mentioning all this explicitly would probably help our readers.) There are few Java supplied marker interfaces like Cloneable , Serializable , etc. One can create their own marker interfaces the same way as they create any other interface in Java. Purpose of having

Why String has been made immutable in Java?

Though, performance is also a reason (assuming you are already aware of the internal String pool maintained for making sure that the same String object is used more than once without having to create/re-claim it those many times), but the main reason why String has been made immutable in Java is 'Security'. Surprised? Let's understand why. Suppose you need to open a secure file which requires the users to authenticate themselves. Let's say there are two users named 'user1' and 'user2' and they have their own password files 'password1' and 'password2', respectively. Obviously 'user2' should not have access to 'password1' file. As we know the filenames in Java are specified by using Strings. Even if you create a 'File' object, you pass the name of the file as a String only and that String is maintained inside the File object as one of its members.

Deploying an Application to a Production Server

  The following topic explains the basic concepts of deploying WebLogic Workshop applications to WebLogic Server running in production mode. For step-by-step instructions on deploying a WebLogic Workshop application to a production server see How Do I: Deploy a WebLogic Workshop Application to a Production Server?.   Development Mode and Production Mode   Weblogic Server can be started in one of two modes: development or production mode. Development mode is the default. When you are developing, deploying and testing an application with WebLogic Workshop, the instance of Weblogic Server you are running is in development mode. In development mode, WebLogic Server behaves in ways that make it easier to iteratively develop and test an application: it automatically deploys the current application in an exploded format, server resources such as databases and JMS queues necessary for the application to run are automatically created, etc. When the development cycle is complete,

WebLogic Workshop Security Overview

  The following overview sets out the aims of security and the security technologies available in WebLogic Workshop.   Security Goals   All security technologies are designed to achieve three basic goals. 1.     Authentication of participants When a participant is authenticated it means that there is some assurance that the participant really is who they say they are. Different scenarios call for different levels of authentication. In some cases, only the web resource needs to be authenticated, while the client can remain anonymous. For example, if your web resource takes customer credit card numbers, you want your customers to have peace of mind that they are providing their card numbers to you, and not some malicious third party. But your customers may remain anonymous. In other cases, the web resource will want proof of identity from its clients. For example, if a bank provided online access to its customer's checking accounts, the bank should require some form o