ADF Popup ContentDelivery attribute – ADF Tips

In Adf application we normally used popup.We have one of the property and attribute of popup is contentDelivery .
ContentDelivery attribute of an af:popup component controls the popup initialization time and how does the data get refreshed within the popup. The default content delivery is lazy. This means the content of the popup is not delivered to the client until shown the first time

Good ADF developer should know , when to use what-

immediate — The popup component is added inline within the page when the page is loaded. It does not matter if you do or do not display it, the popup component will always be loaded.

ContentDelivery should be set to immediate if and only if you are absolutely sure that the popup will be invoked at least once. Otherwise you should use the other two values.

Example: If you use a logout logic that needs confirmation than the confirmation popup should be set to immediate.

lazy — The popup component will be loaded (and cached) only when is called for the first time. If you do not explicitly set the ContentDelivery attribute when creating the popup it will implicitly be set to lazy.

This value should be used when dealing with static information(that does not change): warning messages, information messages and so on.

lazyUncached — The popup component will be loaded(but not cached) only when is invoked for the first time; and every time the popup is called it will be reloaded.

This value should be used when dealing with dynamic data.

Learn Hibernate core implementation.- How hibernate works

Lessons to learn from the Hibernate Core implementation

Hibernate is an open source Java persistence framework project. Perform powerful object relational mapping and query databases using HQL and SQL.
In general the widely used libraries are well designed and implemented, and it’s very interesting to learn from them some coding best practices. Let’s take a look inside the hibernate core library and discover some of its design keys.
In this post Hibernate Core is analyzed by JArchitect to go deep inside its design and implementation.

Package by Feature
Package-by-feature uses packages to reflect the feature set. It places all items related to a single feature (and only that feature) into a single directory/package. This results in packages with high cohesion and high modularity, and with minimal coupling between packages. Items that work closely together are placed next to each other.
Here’s a good article talking about packaging by feature.
Hibernate core contains many packages, each one is related to a specific feature hql, sql, and others.

Coupling
Low coupling is desirable because a change in one area of an application will require fewer changes throughout the entire application. In the long run, this could alleviate a lot of time, effort, and cost associated with modifying and adding new features to an application.
Here are three key benefits derived from using interfaces:
• An interface provides a way to define a contract that promotes reuse. If an object implements an interface then that object is to conform to a standard. An object that uses another object is called a consumer. An interface is a contract between an object and its consumer.
• An interface also provides a level of abstraction that makes programs easier to understand. Interfaces allow developers to start talking about the general way that code behaves without having to get in to a lot of detailed specifics.
• An interface enforce low coupling between components, what’s make easy to protect the interface consumer from any implementation changes in the classes implementing the interfaces.
Let’s search for all interfaces defined by Hibernate Core, for that we use CQLinq to query the code base.

from  t in Types where t.IsInterface select t

If our primary goal is to enforce low coupling, there’s a common mistake when using interfaces that could kill the utility of using them. It’s the using of the concrete classes instead of interfaces, and to explain better this problem let’s take the following example:
The class A implements the Interface IA who contains the calculate() method, the consumer class C is implemented like that

public class C

{

   ….

   public void calculate()

   {

     …..

     m_a.calculate();

     ….

    }

    A m_a;

}

The Class C instead of referencing the interface IA, it references the class A, in this case we lose the low coupling benefit, and this implementation has two major drawbacks:
• If we decide to use another implementation of IA, we must change the code of C class.
• If some methods are added to A not existing in IA, and C use them, we also lose the contract benefit of using interfaces.
C# introduced the explicit interface implementation capability to the language to ensure that a method from the IA will be never called from a reference to concrete classes, but only from a reference to the interface. This technique is very useful to protect developers from losing the benefit of using interfaces.
With JArchitect we can check this kind of mistakes using CQLinq, the idea is to search for all methods from concrete classes used directly by other methods.

from m in Methods  where m.NbMethodsCallingMe>0 && m.ParentType.IsClass

 && !m.ParentType.IsThirdParty && !m.ParentType.IsAbstract

let interfaces= m.ParentType.InterfacesImplemented

from i in interfaces where i.Methods.Where(a=>a.Name==m.Name &&

a.ParentType!=m.ParentType).Count()>0 

select new { m,m.ParentType,i }

For example the method getEntityPersister from SessionFactoryImpl which implements SessionFactoryImplementor interface is concerned by this problem.
Let’s search for methods invoking directly SessionFactoryImpl.getEntityPersister.
from m in Methods where m.IsUsing (“org.hibernate.internal.SessionFactoryImpl.getEntityPersister(String)”)
select new { m, m.NbBCInstructions }

Methods like SessionImpl.instantiate invoke directly getEntityPersister, instead of passing by interface, what break the benefit of using interfaces. Fortunately hibernate core doesn’t contains many methods having this problem.
Coupling with external jars
When external libs are used, it’s better to check if we can easily change a third party lib by another one without impacting the whole application, there are many reasons that can encourage us to change a third party lib. The other lib could:
– Have more features.
– More powerful.
– More secure.
Let’s take the example of antlr lib which used to parse the hql queries, and imagine that another parser more powerful than antlr was created, could we change the antlr by the new parser easily?
To answer this question let’s search which methods from hibernate use it directly:

from m in Methods where m.IsUsing ("antlr-2.7.7")
select new { m, m.NbBCInstructions }
 

And which ones used it indirectly:

from m in Projects.WithNameNotIn( "antlr-2.7.7").ChildMethods()
let depth0 = m.DepthOfIsUsing("antlr-2.7.7")
where depth0 > 1 orderby depth0
select new { m, depth0 }

Many methods use antlr directly what makes hibernate core highly coupled with it, and changing antlr with another one is not an easy task. this fact not means that we have a problem in hibernate design, but we have to be careful when using a third party lib and well check if a third party lib must be low coupled or not with the application.
Cohesion
The single responsibility principle states that a class should have one, and only one, reason to change. Such a class is said to be cohesive. A high LCOM value generally pinpoints a poorly cohesive class. There are several LCOM metrics. The LCOM takes its values in the range [0-1]. The LCOMHS (HS stands for Henderson-Sellers) takes its values in the range [0-2]. Note that the LCOMHS metric is often considered as more efficient to detect non-cohesive types.
LCOMHS value higher than 1 should be considered alarming.
In general classes more concerned by the cohesion are the classes having many methods and fields.
Let’s search for types having many methods and fields.

from t in Types where
(t.Methods.Count() > 40 || t.Fields.Count()>40) && t.IsClass
orderby t.Methods.Count() descending
select new { t, t.InstanceMethods, t.Fields,t.LCOMHS }

Only few types are concerned by this query, and for all them the LCOMHS is less than 1.
Using Annotations
Annotation-based development relieves Java developers from the pain of cumbersome configuration. And give us a powerful feature to free the source code from the boilerplate code. The resulting code is also less likely to contain bugs.
Let’s search for all annotations defined by hibernate core.
from t in Types where t.IsAnnotationClass && !t.IsThirdParty select t

Many annotations are defined, what make hibernate easy to use by developers, and the headache of configuration files is avoided.
Conclusion
Hibernate Core is a good example of open source projects to learn from, don’t hesitate to take a look inside it.

Install Oracle XE in windows 64 bit machine – workaround

I got this problem when i got my new machine of windows 8 64 bit machine.Oracle say ,it will not work in 64 bit. 🙁

what! i can use jdev in my new machine.Oh no.But i found solution on net and thought of sharing you all.

When you install oracle xe in 64 bit .you can.when you installing , you will get weird error. like

This is failed to happen because was that the installer didn’t write a Registry Key’s Data value. You can add the missing registry key’s Data value, and then click OK on the Error dialog box to continue the installation.

What is that? Installer is not able to instantiate at specified location.I went to that location file is there.

You need to add the message value from your Error dialog as Data value of the Name entry 1, like this screenshot shows:

Thats it.

you need to edit the registry.now how to open registry –

windows 7 – go to run and type regedit.

windows 8-

1 .If you are on the Windows 8 desktop, point the cursor at the lower right corner of the screen. Click the “Search” option as soon as it pops up on the left-side of the screen. If you are on the Metro UI Start Screen, point the cursor at the lower left corner of the screen and click the right mouse button. Now select the “Search” option on the context menu.

2. When you perform either of the above actions, Windows 8 will load the “Apps” screen. Type “regedit” into the search bar located on the right side of the “Apps” screen.

3. Click the “regedit” search result on the left side of the “Apps” screen. If you see a UAC dialog box, click “Yes” to open the Windows 8 Registry Editor.
if you open regedit then follow the screen shot

Click on the arrow symbol to the left of the HKEY_CLASSES_ROOT node to expand the node tree. Scroll down until you find the Installer node and click the arrow symbol to expand the node tree another level. Repeat the process for the Product, Product Key Value, and SourceList nodes, as displayed below.

Click on the Media node, which is a leaf node in the Registry tree. Click on the Name 1 and then click the Edit menu option. Within the drop down menu, click on the Modify… option to edit the Data value.

then change to

change the value to C:\Users\vinay\AppData\Local\Temp\{CCCB869D-AD3F-4CF2-B000-EDFA5B620D10}\

done… now you can work on Oracle XE on windows 64 bit machine.May be oracle will support 64 bit in 12 c. till that time enjoy

Happy coding with Vinay Kumar in Techartifact.