Advanced Java is the next advanced level concept of Java programming. … The advance java programming covers the Swings, Socket Programming, AWT, Thread Concepts as well as the Collection objects and classes. “Advanced Java” is nothing but specialization in domains such as web, networking, data base handling.
Some OF the Important features of Advance Java
- Introduction to JSP – Java Server Pages or JSP technology allows us to combine the static HTML with the Java code which makes a webpage dynamic. To begin about JSP,
- Introduction to Servlets -Servlet is a Advance Java class that creates a dynamic content after processing the user request, which was sent from the web browser. To begin learning about Servlet, lifecycle, methods,
- Servlet API Classes – To know about some of the very important classes like GenericServlet, ServletRequest, ServletResponse, ServletConfig, ServletContext,
- Request Dispatching – To understand how to dispatch the request from one Servlet to another Servlet using theRequestDispatcher and other features, please read Request Dispatching
- Session Management – To understand how to perform session management by URL rewriting, Cookies, HttpSessiontechniques withshort code examples ,
- Filters – Using the feature of filter, we can perform many tasks within a web application such as – session validation, user authentication, restricting access to a particular web resource etc. To begin about Filters with easy code examples,
- Listeners – Using the feature of Listener in Servlet, we can make a web application which responds to events taking place in a web application. To know more about Listeners,
Here the topics that you should master as part of your advance java study.
a) Introduction to Generics :
The Generics Features was added to the Java with the release of Java 5.0. The Generics was the long-waited enhancement which is added to the Java 5.0. The Generics allows to use the type or method operate on the objects of various types, mainly for the compile time type safety checking. Generics was introduced to make the coding more robust and less error prone. Through compile-time type safety checking it removes bugs from the Java code.
b) Examples of Generics
In this section we will explain you how you can use the Generics while writing the Java Program? The introduction to the Generics is the major step in the Java Language. Generics can be used to define the generic classes and methods thus bringing the generic types in the Java Programming Language.
There is lot of potential in the Generics to bring the improvements in the type safety and the maintainability of the large scale project. This tutorial will teach you how to add the Generics to the Java code in classes and the methods. Here we are also discussing about the detailed syntax of the Generics and explain its use in the Java code.
c) Type Erasure
Generics concept is introduced in Java language to provide tighter type checks at compile time and to support generic programming. The way to implement generics, the Java compiler applies type erasure to: Replace all type parameters in generic types with their bounds or Object if the type parameters are unbounded.
d) Type Boundaries
A data type is a classification mechanism whereby it can be identified that what kind of data is stored inside the variable, and what operations it supports. Java provides a richer set of primitive or basic or built-in data types than other languages like C and C++.
The question mark (?) is known as the wildcard in generic programming . It represents an unknown type. The wildcard can be used in a variety of situations such as the type of a parameter, field, or local variable; sometimes as a return type. Unlike arrays, different instantiations of a generic type are not compatible with each other, not even explicitly. This incompatibility may be softened by the wildcard if ? is used as an actual type parameter.
f) What is Generic Methods?
Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods, or with a single class declaration, a set of related types, respectively. Generics also provide compile-time type safety that allows programmers to catch invalid types at compile time.
g) Strengths and Weaknesses of Generics :
Java was design to straightforward to use, write, compile, debug, and learn than alternative programming languages. Java is far less complicated than C++ as a result of Java uses automatic memory allocation and garbage collection.
Permits you to form standard programs and reusable code.
Ability to maneuver simply from one system to a different.
Designed to create distributed computing straightforward with the networking capability that’s inherently integrated into it.
The Java language focus on security, compiler, interpreter, and runtime surroundings were every develope.
Let’s Explore Features of Java Programming Language
Java has the feature of Stack Allocation System. It helps the information to keep and might restore simply.
The potential for a program to perform many tasks at the same time at intervals a program.
A lot of memory-consuming than natively compiled languages reminiscent of C or C++ and a bit slower.
ii. Look and Feel
The default look and feel of graphical user interface applications written in Java using the Swing toolkit are extremely completely different from native applications.
iii. Single Paradigm Language
Static imports were added in Java 5.0 the procedural paradigm is better accommodated than in earlier versions of Java.
h) Legacy Code
Legacy code refers to an application system source code type that is no longer supported. Legacy code can also refer to unsupported operating systems, hardware and formats. In most cases, legacy code is converted to a modern software language and platform.
a) Java Thread Model
A thread is a lightweight process which exist within a program and executed to perform a special task. Several threads of execution may be associated with a single process. Thus a process that has only one thread is referred to as a single-threaded process, while a process with multiple threads is referred to as a multi-threaded process.
In Java Programming language, thread is a sequential path of code execution within a program. Each thread has its own local variables, program counter and lifetime. In single threaded runtime environment, operations are executes sequentially i.e. next operation can execute only when the previous one is complete. It exists in a common memory space and can share both data and code of a program. Threading concept is very important in Java through which we can increase the speed of any application. You can see diagram shown below in which a thread is executed along with its several operations with in a single process.
b)Creating and Running Threads
To execute the run() method by a thread, pass an instance of MyClass to a Thread in its constructor (A constructor in Java is a block of code similar to a method that’s called when an instance of an object is created). Here is how that is done: Thread t1 = new Thread(new MyClass ()); t1.start();
c)Manipulating Thread State | Thread Synchronization in Java Example
In Java, thread scheduler can use the thread priorities in the form of integer value to each of its thread to determine the execution schedule of threads . Thread gets the ready-to-run state according to their priorities. The thread scheduler provides the CPU time to thread of highest priority during ready-to-run state.
Sometimes, when two or more threads need shared resource, they need a proper mechanism to ensure that the resource will be used by only one thread at a time.
The mechanism we use to achieve this is known as thread synchronization.
The thread synchronization is achieved through the synchronized keyword. The statements which need to be synchronized should put into the synchronized block It is also known as critical section.
In this section we will discuss about Synchronization in java. Since java is a multi-threaded language so, when two or more thread used a shared resources that lead to two kind of errors: thread interference and memory consistency error, to avoid this error you need to synchronized object, that the resource will be used by one thread at a time and the process by which synchronization is achieved is called synchronization. Synchronized keyword in java create a critical section in which a lock is associated with the object . To enter the critical section a thread need to obtain the object lock
e)Volatile Fields vs. Synchronized Methods
volatile keyword in java is a field modifier, while synchronized modifies code blocks and methods. synchronized obtains and releases lock on monitor’s java volatile keyword doesn’t require that.
f )wait and notify
wait()-It tells the calling thread to give up the lock and go to sleep until some other thread enters the same monitor and calls notify().
notify()-It wakes up one single thread that called wait() on the same object. It should be noted that calling notify() does not actually give up a lock on a resource.
notifyAll()-It wakes up all the threads that called wait() on the same object.
g) join and sleep
join() will wait until the timeout expires or the thread finishes. sleep() will just wait for the specified amount of time unless interrupted. So it is perfectly possible for join() to return much faster than the specified time.
h) The Concurrency API
The API is located in package java.util.concurrent and contains many useful classes for handling concurrent programming. Since that time the Concurrency API has been enhanced with every new Java release and even Java 8 provides new classes and methods for dealing with concurrency.
i) Atomic Operations
An atomic operation is an operation which is performed as a single unit of work without the possibility of interference from other operations. The Java language specification guarantees that reading or writing a variable is an atomic operation(unless the variable is of type long or double )
a) The Reflection API
Reflection is an API which is used to examine or modify the behavior of methods, classes, interfaces at runtime. The required classes for reflection are provided under java.lang.reflect package.
b) Getting the implemented Interfaces
A Java class can implement multiple Java Interfaces. It is necessary that the class must implement all the methods declared in the interfaces. The interface allows sending a message to an object without concerning which classes it belongs. Class needs to provide functionality for the methods declared in the interface.
c) Retrieving the class name through Reflection API
Java Reflection is the process of analyzing and modifying all the capabilities of a class at runtime. Reflection API in Java is used to manipulate class and its members which include fields, methods, constructor, etc. at runtime
d) Finding out the superclass name of the Class
String superClass = a_class.getClass().getSuperclass().getName(); To get just the name and not the package name, use Class.getSimpleName() : String superClass = a_class.getClass().getSuperclass().getSimpleName(); However, a_class is already a Class instance so you might want to use a_class.getSuperclass() instead
e) Getting the method name used in the Application
this is a keyword in Java which is used as a reference to the object of the current class, with in an instance method or a constructor. Using this you can refer the members of a class such as constructors, variables and methods.
f) Finding out the object of the Class
You can use getClass() to get the java.lang.Class object that represents the type of the object. If you just want to know if an object is an instance of or extends a certain class, or implements a certain interface, you can use the instanceof keyword.
g) Finding out the class fields
A class variable (declared static ) is a location common to all instances. Each Java object is a distinct memory zone with some meta data (e.g. some reference to its class) and its own instance variables (perhaps inherited from a superclass).
h) Getting information about Constructor
The purpose of constructor is to initialize the object of a class while the purpose of a method is to perform a task by executing java code. Constructors cannot be abstract, final, static and synchronised while methods can be. Constructors do not have return types while methods do.
i) No Argument Constructor Example
The default constructor is a no-args constructor that the Java compiler inserts on your behalf; it contains a default call to super(); (not supper() ) which is the default behavior. … If the class being declared is the primordial class Object, then the default constructor has an empty body.
j) Class Modifier Example
Java provides a number of non-access modifiers to achieve many other functionality. The static modifier for creating class methods and variables. The final modifier for finalizing the implementations of classes, methods, and variables. The abstract modifier for creating abstract classes and methods.
k) Calling ( Invoking ) Methods through Reflection
Invoking Methods. Reflection provides a means for invoking methods on a class. … Subsequent arguments are the method’s parameters. If the underlying method throws an exception, it will be wrapped by an java.lang.reflect.InvocationTargetException .
l) The Class<T> Class
In Java there’s a single metaclass: Class. Its instances (only one per type exists) are used to represent classes and interfaces, therefore the T in Class<T> refers to the type of the class or interface that the current instance of Class represents. This generally refers to generic type in java or generic classes.
m) The java.lang.reflect Package
The java.lang.reflect package contains the classes and interfaces that, along with java.lang.Class, comprise the Java Reflection API. This package is new as of Java 1.1. Figure 14-1 shows the class hierarchy. The Constructor, Field, and Method classes represent the constructors, fields, and methods of a class.
n) Reading Type Information
Most of this metadata is type information enumerating the base class, superinterfaces, fields, and methods of the class. Type information is used to make the dynamic linking of code more reliable by verifying at runtime that clients and servers share a common view of the classes they use to communicate.
o) Navigating Inheritance Trees
In Java, the inheritance mechanism allows to define a class hierarchy with all the classes. Without explicit inheritance, a class implicitly inherits from the Object class. This Object class is the root of the class hierarchy. Some classes can’t be inherited.
p) Dynamic Instantiation
An object can be dynamically associated with a class, we talk of dynamic instantiation of object. The dynamic instantiation of an object allows you to create an object at a given time and to free this object when it is no longer used. To instantiate an object, you must: Declare a dynamic object.
q) Dynamic Invocation
Generated bytecode often requires several actual JVM method invocations for one dynamic language method invocation. Reflection is widely used and contributes to performance degradation. Also, the many different execution paths make it impossible for the JVM’s just-in-time (JIT) compiler to apply optimizations.
r) Reflecting on Generics
The Generics Reflection Rule of Thumb. Using Java Generics typically falls into one of two different situations: Declaring a class/interface as being parameterizable. Using a parameterizable class.
s) Uses for Meta-Data
Essentially, JMI can be used to write tools in Java for manipulating UML models, which can be used in Model Driven Architecture and/or Model Driven Development. … Standardized mappings from the MOF modeling constructs to Java; Reflective APIs for generic discovery and navigation of metadata models and instances
a) What is Annotations in Java?
Annotations in computer programming languages provide data about a program that is not part of the program itself by decorating them. They does not impact directly to the operation of the code to which they annotate.
Annotations are mainly used for:
Information for the compiler: Compiler uses the annotations to detect errors or suppress warnings.
Compiler-time and deployment time processing: annotation information is processed by the annotation processor in order to produce new source code and other files.
Runtime processing: some annotations are scanned at runtime by using various techniques and open source libraries.
b) Annotation Quick Introduction
Annotations behave like metadata and provide data about a program that is not part of the program itself. They are used to associate program elements with the meta tags so that the compiler can generate interdependent code to support the annotated elements. Developing annotations helps in faster development of program. Multi-value annotations are used to pass the values to multiple data members.
c) Java Custom Annotation Example
Annotations are decorators that are applied to Java constructs, such as classes, methods, or fields, that associate metadata with the construct. These decorators are benign and do not execute any code in-and-of-themselves, but can be used by runtime frameworks or the compiler to perform certain actions.
d) Aspect-Oriented Programming and Java
An aspect is a common feature that’s typically scattered across methods, classes, object hierarchies, or even entire object models. It is behavior that looks and smells like it should have structure, but you can’t find a way to express this structure in code with traditional object-oriented techniques.
For example, metrics is one common aspect. To generate useful logs from your application, you have to (often liberally) sprinkle informative messages throughout your code. However, metrics is something that your class or object model really shouldn’t be concerned about. After all, metrics is irrelevant to your actual application: it doesn’t represent a customer or an account, and it doesn’t realize a business rule. It’s simply orthogonal.
In AOP, a feature like metrics is called a crosscutting concern, as it’s a behavior that “cuts” across multiple points in your object models, yet is distinctly different. As a development methodology, AOP recommends that you abstract and encapsulate crosscutting concerns.
e) The Annotations Model
The purpose of a Java annotation is simply to associate information with the annotated program element. Java annotations may be used as modifiers in any declaration, whether package, class (including enums), interface (including annotation types), field, method, formal parameter, constructor, or local variable
f) Annotation Types and Annotations
There are 3 categories of Annotations:-
1. Marker Annotations:
The only purpose is to mark a declaration. These annotations contain no members and do not consist any data. Thus, its presence as an annotation is sufficient. Since, marker interface contains no members, simply determining whether it is present or absent is sufficient. @Override is an example of Marker Annotation.
Example: – @TestAnnotation()
2. Single value Annotations:
These annotations contain only one member and allow a shorthand form of specifying the value of the member. We only need to specify the value for that member when the annotation is applied and don’t need to specify the name of the member. However in order to use this shorthand, the name of the member must be value.
Example: – @TestAnnotation(“testing”);
3. Full Annotations:
These annotations consist of multiple data members/ name, value, pairs.
Example:- @TestAnnotation(owner=”Rahul”, value=”Class Geeks”)
g) Built-In Annotations
there are several that inform compilation:
These annotations generate or suppress compiler warnings and errors. Applying them consistently is often a good practice since adding them can prevent future programmer error.
h) Annotations vs. Descriptors (XML)
A deployment descriptor is an XML file that describes how a Java EE application or module should be deployed. … The following types of deployment descriptors are associated with GlassFish Server: Java EE Standard Descriptors.
5. SOCKETS (JAVA NETWORKING)
a) The OSI Reference Model
ISO stands for International organization of Standardization. This is called a model for Open System Interconnection (OSI) and is commonly known as OSI model. The ISO-OSI model is a seven layer architecture. It defines seven layers or levels in a complete communication system.
b) Network Protocols
The java.net package provides support for the two common network protocols − TCP − TCP stands for Transmission Control Protocol, which allows for reliable communication between two applications. TCP is typically used over the Internet Protocol, which is referred to as TCP/IP.
c) Overview of Networking through JAVA
All the Java networking classes and interfaces use java.net package. These classes and interfaces provide the functionality to develop system-independent network communication. TCP is a connection based protocol that provides a reliable flow of data between two devices.
d) Socket and ports
A socket is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to. An endpoint is a combination of an IP address and a port number.
e) Server Sockets
Java Socket Programming – Socket Server, Client example. Welcome to Java Socket programming example. Every server is a program that runs on a specific system and listens on specific port. Sockets are bound to the port numbers and when we run any server it just listens on the socket and wait for client requests.
f) URL in term of Java Network Programming
URL in term of Java Network Programming. A URL (Uniform Resource Locator) is the address of a resource on the Internet. In java network programming we can use URLs to connect and retrieve information over the Internet.
g) Datagram in network environment
The fact that datagram sockets are openly unreliable may lead you to think that they are something to avoid in network programming. … Java supports datagram socket programming through two classes: DatagramSocket and DatagramPacket. The DatagramSocket class provides an implementation for a basic datagram socket.
h) Networking in Java
Java Networking is a concept of connecting two or more computing devices together so that we can share resources. Java socket programming provides facility to share data between different computing devices.
i) The Socket Class
Class java.net.Socket. This class implements client sockets (also called just “sockets”). A socket is an endpoint for communication between two machines. The actual work of the socket is performed by an instance of the SocketImpl class.
j) The ServerSocket Class
ServerSocket Class Methods. The java.net.ServerSocket class is used by server applications to obtain a port and listen for client requests. Attempts to create a server socket bound to the specified port. An exception occurs if the port is already bound by another application.
k) Connecting Through URL Objects
Connection to the remote object represented by the URL is only initiated when the URLConnection.connect method is called. When you do this you are initializing a communication link between your Java program and the URL over the network.
l) Find Your Host Name/IP Address
Java program to find IP address of your computer. An IP(Internet Protocol) address is an identifier assigned to each computer and other device(e.g., router, mobile, etc) connected to a TCP/IP network that is used to locate and identify the node in communication with other nodes on the network.
m) How to retrieve URL information
Within your Java programs, you can create a URL object that represents a URL address. The URL object always refers to an absolute URL but can be constructed from an absolute URL, a relative URL, or from URL components.
n) Construct a DatagramPacket to receive data
DatagramPacket(buffer, buffer.length) for constructs a DatagramPacket for receiving packets of length length in more generic way. First of all create a class UDPReceiver and initialize a object buffer of byte array. After that we call the DatagramPacket
0) Echo ClientSocket
That means, a socket program written in Java language can communicate to a program written in non-Java (say C or C++) socket program. A server (program) runs on a specific computer and has a socket that is bound to a specific port. The server listens to the socket for a client to make a connection request (see Fig.
p) RMI Client And RMI Server Implementation
The RMI application comprises of the two separate programs, a server and a client. A typical server program creates some remote objects, makes references to these objects accessible, and waits for clients to invoke methods on these objects. The RMI application provides the mechanism by which the server and the client communicate and pass information back and forth. The RMI distributed application uses the RMI Registry to obtain a reference to a remote object. The server calls the registry to associate a name with a remote object. The client looks up the remote object by its name in the server?s registry and then invokes a method on it.
q) HTTP and Other TCP Servers
An Http Server is bound to an IP address and port number and listens for incoming requests and returns responses to clients. Simple http server is flexible to be added into complex projects for rendering Html elements or serving as a backend server, or even deployed in the client side to drive specific devices.
The server socket listens for incoming connections. A server creates a socket, binds the socket to an IP address and port number (for TCP and UDP), and then listens for incoming connections. When a client connects to the server, a new socket is created for communication with the client (TCP only).Jun 2, 2012
r) Datagram Clients and Servers
The example featured in this section consists of two applications: a client and a server. The server continuously receives datagram packets over a datagram socket. Each datagram packet received by the server indicates a client request for a quotation.
s) Non-Blocking Sockets
Non-blocking Socket APIs. The classes that support non-blocking socket communication in Java are as follows. A selectable channel for stream-oriented listening sockets. … An instance of this class is used to establish connection between the client and the server like the Socket class instance
6. DATABASE AND SQL FUNDAMENTALS
a) Database Management System
Database Management System: The software which is used to manage database is called Database Management System (DBMS). For Example, MySQL, Oracle etc. are popular commercial DBMS used in different applications.
b) Relational Databases
A database is a means of storing information in such a way that information can be retrieved from it. In simplest terms, a relational database is one that presents information in tables with rows and columns.
Structured Query Language) is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS).
d) Introduction to DDL (Creating and Managing Database Objects) and DML (Retrieving and Managing Data)
Data Definition Language (DDL) is a unique set of SQL commands that lets you manipulate the structure of the database. In this article, we will try to show how the JDBC DDL mechanism can be applied to a Java application.
he sequence structure is built into Java. Unless directed otherwise, the computer executes Java statements one after the other in the order in which they’re written—that is, in sequence.
f) Stored Procedures
You can run Java stored procedures in the same way as PL/SQL stored procedures. Normally, a call to a Java stored procedure is a result of database manipulation, because it is usually the result of a trigger or SQL DML call.
a) JDBC Tutorials Home Page
JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the query with the database. It is a part of JavaSE (Java Standard Edition). JDBC API uses JDBC drivers to connect with the database.
b) What is the JDBC API?
Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database. It is a Java-based data access technology used for Java database connectivity. It is part of the Java Standard Edition platform, from Oracle Corporation.
c) JDBC Drivers
There are 4 types of JDBC drivers:
JDBC-ODBC bridge driver.
Native-API driver (partially java driver)
Network Protocol driver (fully java driver)
Thin driver (fully java driver)
d) Making a Connection
When a Java application needs a database connection, one of the DriverManager.getConnection() methods is used to create a JDBC connection. The URL used is dependent upon the particular database and JDBC driver. It will always begin with the “jdbc:” protocol, but the rest is up to the particular vendor.
e) Handling SQLWarning
SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned.
8. ADVANCED JDBC
a) SQL Escape Syntax
A SQL Escape Sequences. Language features, such as outer joins and scalar function calls, are commonly implemented by database systCems. The syntax for these features is often database-specific, even when a standard syntax has been defined.
b) Using Prepared Statements
The JDBC Statement, CallableStatement, and PreparedStatement interfaces define the methods and properties that enable you to send SQL or PL/SQL commands and receive data from your database. They also define methods that help bridge data type differences between Java and SQL data types used in a database.
c) Using Callable Statements
Use the when you plan to use the SQL statements many times. The PreparedStatement interface accepts input parameters at runtime. Use the when you want to access the database stored procedures. The CallableStatement interface can also accept runtime input parameters.
d) Updatable Result Sets
A forward only updatable result set maintains a cursor which can only move in one direction (forward), and also update rows. Scrollable updatable result sets. A scrollable updatable result set maintains a cursor which can both scroll and update rows.
A transaction can end in two ways: with a commit or with a rollback. When a transaction commits, the data modifications made by its statements are saved. If a statement within a transaction fails, the transaction rolls back, undoing the effects of all statements in the transaction.
f) Commits, Rollbacks, and Savepoints
Commit, Rollback and Savepoint SQL commands. Transaction Control Language(TCL) commands are used to manage transactions in the database. These are used to manage the changes made to the data in a table by DML statements.
g) Batch Processing (Many Examples)
Batch Processing in JDBC. Instead of executing a single query, we can execute a batch (group) of queries. It makes the performance fast. The java.sql.Statement and java.sql.PreparedStatement interfaces provide methods for batch processing.
9. INTRODUCTION TO ROW SETS
a) GUI and J2EE programming
GUI stands for Graphical User Interface, a term used not only in Java but in all programming languages that support the development of GUIs. … To make graphical user interfaces in Java, use either Swing (older applications) or JavaFX.
The Java 2 Platform Enterprise Edition or the J2EE provides platform-independent Java centric environment. It was developed by Sun Microsystems which is presently merged with Oracle and is mainly used for developing, deploying, designing and building web based enterprise applications online.
10. DESIGN PATTERNS
a) What are Design Patterns?
The Factory Design Pattern or Factory Method Design Pattern is one of the most used design patterns in Java. According to GoF, this pattern “defines an interface for creating an object, but let subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses”.
b) Singleton, Factory Method, Abstract Factory
The factory method is just a method, it can be overridden in a subclass, whereas the abstract factory is an object that has multiple factory methods on it. The Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation.
c) Adapter, Composite, Decorator
Structural Patterns: Adapter, Bridge, Composite, and Decorator. Structural patterns deal with the arrangement and relationship between the classes in the system. They focus on how classes and objects are composed so as to form larger and more complex structures.
d) Data Access Object (DAO)
The Data Access Object (DAO) pattern is a structural pattern that allows us to isolate the application/business layer from the persistence layer (usually a relational database, but it could be any other persistence mechanism) using an abstract API.