Beginning with JDK 5, enumerations were added to the Java language, and they are now an integral and widely used part of Java. In their simplest form, Java enumerations appear similar to enumerations in other languages. However in Java, an enumeration defines a class type. By making enumerations into classes, the capabilities of the enumeration are greatly expanded. For example, in Java, an enumeration can have constructors, methods, and instance variables.
Singleton pattern is one of the commonly used design solution. It describes a technique for ensuring that only a single instance of a class is ever created. In essence, the technique takes the following approach: don’t let anyone outside the class create instances of the class.
Singletons often control access to resources such as database connections or sockets. For example, if you have a license for only one connection for your database or your JDBC driver has trouble with multithreading, the Singleton makes sure that only one connection is made or that only one thread can access the connection at a time. If you add database connections or use a JDBC driver that allows multithreading, the Singleton can be easily adjusted to allow more connections.
There are many ways to achieve singleton in java, let us implement all possible approaches with common mistakes with solutions.
Posted in Tutorials
Tagged break, class, common, core, deserialition safe, deserialization, deserialize, design, design pattern, Eager, enum, Example, Examples, getDefaultInstance, github, Initialization, instance, Java, java design pattern, java source code, java tutorial, lazy, Linux, mistakes, multithreading, object, Object restriction, pattern, private constructor, program, readResolve, reflection, reflection safe, relfection, Sample code, samples, serializable, serialize, simple, singleton, source code, standard, thread safe, Toolkit, tutorial, violation, Windows
In Java application we frequently use Hibernate. All the time when an application user modify/update its data then we save it into database and send message (SMS or Mail) to user about modification. For achieve this we retrieves existing entity from database and then compare with new entity. We follow this for each entity which results a huge number of classes or huge number of methods for comparison of each entity.
As we generally develop comparison program that does not work dynamically that is if new fields are added into entities then we modify comparison program again to cover new field. So now let us make a dynamic program for entity comparison which will be a common helper program for all entities rather than component specific.
Benefits of Program:
- Easy maintenance as it will be a common program for all entities and if entities are modified even then this program is no need to modify.
- No any additional jar required for entities comparison.
- Less time complexity.
- Reduced codes (number of classed and methods) as it is a common helper.
Limitations of Program:
- This program can be used only when the entities has primary key primitive type “id” Field (i.e. If primary key fields name is “iD” or “Id” or anything else apart from “id” then this program won’t work).
- This program work only with entities not with DTO, POJO or other classes.
Input for program:
- Two Objects of an entity (i.e. existing object and modified object).
Output of Program:
- Returns Map (String key, Object value), where key is [field Name _ Number or field Name _ New _ Number] and value is modified value.
Now a days people are very afraid about what their children are doing on Laptop/Desktop. So lets start monitoring your windows Laptop/Desktop.
You will get screen dumps of active window like if your child is watching movie, playing games or so on then you will get movies or games or any screen dumps to your email id.
Let’s Understand the features of this utility.
- It captures images from a remote system and then it mails these screen dumps to your e-mail id.
- No Installation required. These utility won’t be visible on control panel in Uninstall a program category.
- Secure as it is developed in Java programming language.
- All exceptions are handled means in any situation it won’t let user know that you are tracking his/her system screens.
Follow these simple Steps to Captures Images from remote system. Continue reading
Posted in Utility & Helper
Tagged capture, dumps, free, Java, Java Mail, mail, screen, screen captures, Screen dumps, simple mail transfer protocol, source code, utility