After decompiling the ucp jar file, I was able to understand the labeling connection callback better and got to know that the implementation didn’t completely match with the jdbc developer guide. This post will detail out on a couple of mismatch’d points from the developer guide.
If you are monitoring a local jvm process using jconsole or jvisualvm and aren’t able to view the Threads tab on jvisualvm or connect to jconsole, this post should provide some troubleshooting information.
Any application that is started on the Java SE 6 platform will support the Attach API, and so will automatically be made available for local monitoring and management when needed. This out of box jmx support doesn’t work on Windows though. On Windows platforms, for security reasons, local monitoring and management is only supported if your default temporary directory is on a file system that allows the setting of permissions on files and directories (for example, on a New Technology File System (NTFS) file system). It is not supported on a File Allocation Table (FAT) file system, which provides insufficient access controls.
Natively Oracle is case sensitive which means if you executed a query for e.g.
select emp_id, emp_salary from employee where emp_name = 'amit';
it would search for the string ‘amit’ in lowercase. We can switch this to make the search behave case insensitively by setting the NLS_COMP and NLS_SORT parameters from Oracle’s globalization support which was previously called National Language Support (NLS).
If you are implementing a decorator pattern, you would have to implement one or more interfaces. If the interface has large number of methods, delegating each of them might be troublesome and error prone. Since there is no good way in java to implement delegates (implementing a proxy with an invocation handler is a workaround :)), a better option would be to take help of the IDE to be sure that the implementation is not error prone. Here is how to do it using Intellij IDE
As an extension to the last post on functions, below are some points about function arguments.
- Function arguments take a lot of conceptual power while reading and understanding code.
- They should be at the same level of abstraction as the function name. For e.g. String createTestableHtml(PageData pageData). Reading this function signature forces you to know the detail which isn’t particular important at that point in time.
- Arguments are most naturally interpreted as inputs to a function.
- Output arguments should be avoided. If your function must change the state of something, have it change the state of its owning object
This post details on the steps required to configure ehcache as the second level hibernate cache when jpa, hibernate and spring are used in combination
Configuring the cache
Add the below properties to the persistence.xml configuration file
<property name="hibernate.cache.use_second_level_cache" value="true"/> <property name="hibernate.cache.use_query_cache" value="true"/> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/> <property name="hibernate.generate_statistics" value="true"/>
Logback provides a support to send logged messages in an email through an SMTPAppender. The SMTPAppender accumulates logging events in one or more fixed-size buffers and sends the contents of the appropriate buffer in an email after a user-specified event occurs. By default, the email transmission is triggered by a logging event of level ERROR or higher. Moreover, by default, a single buffer is used for all events.
A sample smtp appender configuration would look like below
While watching the episode 3 of the clean coders video I noted down some important points.
Functions are the first line of code organization in your application.
- The first rule to having clean functions is that they should be small.
- Typically classes hide in large functions.
- If you find functions that can be divided into several functional areas and you have variables that are used by all those areas then what you really have is a class. After all, a class is a group of functions that use a common set of variables.
I came across this interesting article about loading and unloading of static fields which details a couple of facts I was not aware of
1. Loading – You can get a reference to a class, before it has been initialized (i.e its static fields being initialized or its static initializers being called), only when it is used does it get initialized. The link contains an example code which illustrates this fact.
2. Unloading – Static fields are unloaded when the Class’ classloader is unloaded. This is unloaded when a GC is performed and there are no strong references from the threads’ stacks.
This post adds more detail to the second point. Below are few reasons why classes are unloaded only when the classloader unloads.