Monthly Archives: October 2014

What is the difference between an interface and abstract class?

What is the difference between an interface and abstract class?

Similarities

  • You cannot instantiate them
  • They may contain a mix of methods declared with or without an implementation

Differences

Interface abstract class
All fields are automatically public, static, and final, and all methods that you declare or define (as default methods) are public Can declare fields that are not static and final, and define public, protected, and private concrete methods
Can implement number of interfaces Can extend only one class, whether or not it is abstract,

Resources:
Abstract Classes Compared to Interfaces

Java EE Interceptors

Java EE Interceptors

Technology to do method call intercept. Common uses of interceptors are logging, auditing, and profiling.

Java EE Interceptor

Java EE Interceptor

Terminology

target class – class in which Interceptors are defined. Interceptor methods are invoked in conjunction with the methods (of target class) or lifecycle events of the target class.
interceptor method –  methods which handles the interceptor invocation. It could be defined in target class as interceptor method or defined in separate class called interceptor class.
interceptor class – contains interceptor methods

 

Interceptor Metadata Annotations

Interceptor Metadata Annotation Description
javax.interceptor.AroundInvoke Designates the method as an interceptor method.
javax.interceptor.AroundTimeout Designates the method as a timeout interceptor, for interposing on timeout methods for enterprise bean timers.
javax.annotation.PostConstruct Designates the method as an interceptor method for post-construct lifecycle events.
javax.annotation.PreDestroy Designates the method as an interceptor method for pre-destroy lifecycle events.

 

Resources

XML Schema Definition – XSD Introduction

XML Schema Definition – XSD Introduction

An XML Schema:

  • defines elements that can appear in a document
  • defines attributes that can appear in a document
  • defines which elements are child elements
  • defines the order of child elements
  • defines the number of child elements
  • defines whether an element is empty or can include text
  • defines data types for elements and attributes
  • defines default and fixed values for elements and attributes

XML Schema supports data types. With support for data types:

  • It is easier to describe allowable document content
  • It is easier to validate the correctness of data
  • It is easier to work with data from a database
  • It is easier to define data facets (restrictions on data)
  • It is easier to define data patterns (data formats)
  • It is easier to convert data between different data types

Resources:

W3Schools XML Schema