Java Tips
Sunday, July 10, 2011
Monday, June 13, 2011
Accessing ADF ViewObject's property in Groovy
Use this to access any field in ViewObject
"adf.object.viewObject.yourPropertyName"
"adf.object.viewObject.yourPropertyName"
Labels:
adf,
groovy,
Viewobject
Wednesday, March 2, 2011
Getting context path in serlvets
if (servletContext.getMajorVersion() == 2 && servletContext.getMinorVersion() <= 4) { return servletContext.getServletContextName(); } else { return servletContext.getContextPath(); }
Labels:
context path,
servlet
Getting objects created in current java thread
There are two ways to resolve object dependency in java e.g. objects created in one method will be needed in other method in the same thread request. One way of resolving this dependency is that you pass newly created objects as parameter to method but this approach has drawback e.g. if you have created an object in one method, then that method is calling another which is calling another method and that method requires object created in first method then using first approach you will have to pass object in the parameter of second method and then second method will pass it to third method as parameter. As second method does not require it but we will have to pass it to resolve dependency of third method.
Second and most efficient approach is using ThreadLocal class. You can set object in first method to this class by this:
threadLocal.set(contextObject);
Now in third method you can get this object using this:
threadLocal.get();
Usually this approach is used with objects which are current request's context related e.g. FacesContext object is the key object in JSF and is required to use it anywhere in the request. so JSF creates instance of FacesContext in each request and set it to ThreadLocal. and then later on returns it from ThreadLocal.
Labels:
FacesContext,
java,
jsf,
object dependency,
threadlocal
Tuesday, March 1, 2011
Getting java web classloader
J2EE 1.3 (and later) containers are required to make the web application class loader visible through the context class loader of the current thread. You can access it like this:
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Labels:
classloader,
java,
web
Monday, February 14, 2011
Changing Context Root of application during deployment in Weblogic
Configuring Applications for Production Deployment: "You cannot use a deployment plan to change the context-root in an application.xml file. However, if an application is deployed as a library, you can either change the context-root through an weblogic-application.xml file or use the deployment plan to change the context-root in an weblogic-application.xml file."
Labels:
adf,
context path,
deployment
Subscribe to:
Posts (Atom)