There are 4 of them.
BY -- Joshua Bloch, Core Java Platform Group Architect, Sun Microsystems,
One is the Type Safety Enum feature. This is actually covered as a pattern in my book, 'How to do Typesafe Enums on top of Ordinary Classes.' But it is unfortunately somewhat verbose. So to do an Enum in a language like Pascal, or C++, or C#, you just say Enum Season {Winter, Spring, Summer, Fall}. Whereas to do a Typesafe Enum Pattern in Java, it was a large quantity of verbiage. Now you got a lot more power out of that because it was a real class you could put into collections, you could add methods to it, add fields to it, but unfortunately it was also somewhat more difficult to use. So this feature basically combines the power of this pattern that's described in my book with the expressivity and the ease of use of the standard Enum construct of the sort that you'll find in other languages. Most of those you'll find are merely glorified integers. They aren't type-safe, they aren't very powerful. So this one will be far more easy to use and more powerful.
There is a for each feature which is very simple. It is basically just a loop that let's you iterate over a collection or an array without explicit use of an iterator variable or an array index, when you don't need it.
Then there's autoboxing. As you know the Java type system is divided into two parts: the primitives and the objects. And in order to put a primitive into a collection you first have to box it. So an int goes into an Integer, a float goes into a Float, and so forth. And it makes for code that's a little bit messy, because you have to cast these things both going in and out of the collection. So with autoboxing you don't have to have those casts anymore.
The fourth feature is static import, which is a fairly simple feature. Currently, in order to access any static member of a class, whether it's a static field or a static method, you have to explicitly prefix it with the class name. So for instance math.pi or math.cos. And that is somewhat verbose and in particular it causes people to use an unsafe pattern. When people want to use a bunch of constants, instead of putting them in a class (and prefixing them with the class name), they put them in an interface and implement the interface to get all of its constants. But unfortunately that changes the public API of the class doing this trick because that class now implements this interface. And so what you want to is be able to do is use these static members without explicitly prefixing them. So what we're doing is we're adding an import statement much like the one that currently exists to import package members that allows you to import the static members of a class.
Instead Of,
double r = Math.cos(Math.PI * theta);
We User,
import static java.lang.Math.*;double r = cos(PI * theta);
Generics
The motivation is that currently, when you have Collection data types in Java, they are in fact Collections of Object and whenever you take anything out all you know is that it's an Object. And if you want to make it something more specific, you have to cast it explicitly. And if there's an error, so if you think there's a String in there and you cast what you've got out to a String, but in fact it's an Integer, you don't find out until runtime when your program blows up in the field. Now what Generics does for you is it takes that error and it moves it from runtime to compile time. So if you tried to take a String out of a collection of Integers, your program won't even compile any more. And furthermore, it eliminates the need for explicit casting. You declare the collection as being, say, a List of String rather than simply a List and then when you get an element, you get a String rather than getting Object and having to cast it to a String. And since you have no explicit casts, you have nothing that can fail. In fact, there are casts under the covers; the compiler generates them for you. But they don't fail; they are guaranteed to succeed.
more>>>
---> A portal for java gurus, java developers and experts. You can also find news on Google, Linux, OpenSource and latest articles on emerging Technologies and some personal stuff.
Monday, April 16, 2007
Sunday, April 8, 2007
ANT Introduction

Ant's build file is written in XML
Ant's build file consists of "project" "target" and "tasks"
The Attributes of Project are "project name="" default="" basedir=""
The Attributes of Target are "target name="" depends="" if="" unless=""
name - name of the target, depends - A comma seperated list of targets which this target depends
if - The name of the property that must be set in order for this target to execute
unless - The name of the property that must not be set for this target to execute.
TASK -- A Task is a piece of code to be executed.
List of Build-in Tasks
----------------------
1. ANT - runs ant on a supplied Buildfile. This can be used to build subProjects,
2. buildnumber file="" -- 0This is a basic task that can be used to track build number.
3. gzip or bzip2 packs a resource using GZip or BZip algorithm.
4. copy - Copies a file or resource to a new file or directory.
5. copydir - Copies a Dir tree from a source to Destination
Log4J Introduction

In Log4j version 1.2 The Category class is replaced by Logger class
There are 3 components of Log4j are 1. Logger, 2.Appender, 3.Layout
1. Logger - The set of Levels are INFO,DEBUG,FATAL, ERROR,WARN,TRACE
This is the central class in the log4j package. Most logging operations, except configuration, are done through this class.
2. Appender - In log4j the output destination is called the appender
The Appender controls how the logging is output.
ConsoleAppender, WriterAppender, FileAppender, SocketAppender, TelnetAppender
3. Layout - The Appender must have have an associated Layout so it knows how to format the output.
DateLayout, HTMLLayout, PatternLayout, SimpleLayout, XMLLayout
Sample Log4j.properties file
---------------------------------
log4j.rootLogger=debug, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
PatternLayout - the Goal of this class is to format the logging event and return the result as String.
%C - Used to output the fully qualified className
%t - Used to Output the Thread Name used to generate the logEvent
%d - Used to output the date of the logging event.
%f - Used to output the filename where the logging event occurs.
%L - Used to output the Line Number from where the logging was issued.
%M - Used to output the Method NAme associated with the logging event.
%p - Used to output the priority of the logging event. more>>>
Sunday, April 1, 2007
Web service

The W3C Web service definition encompasses many different systems, but in common usage the term refers to clients and servers that communicate XML messages that follow the SOAP-standard. Common in both the field and the terminology is the assumption that there is also a machine readable description of the operations supported by the server, a description in the WSDL. The latter is not a requirement of SOAP endpoint, but it is a prerequisite for automated client-side code generation in the mainstream Java and .NET SOAP frameworks. Some industry organizations, such as the WS-I, mandate both SOAP and WSDL in their definition of a Web service.