-
-
-
-
- Bay Area
-
- Massachusetts
Anything that interests me finds place here. Software dominates my interests and hence a good part of this blog as well.
-
-
-
-
- Bay Area
-
- Massachusetts
There may be situations where in you only want to log the call stack (to find out how a method got invoked). An easy way to do this is to throw a new java.lang.Exception(“”). Catch it and log it in the log file. This way you can have the call stack for a method invocation without having the bebug.
try
{
throw new java.lang.Exception("Dummy exception to display call stack");
} catch (java.lang.Exception e)
{
log.debug("stack trace", e); // This will print the exception on to the log file
}
public String[] getFieldValues( DataObject bean )
{
List<String> fieldValues = new ArrayList<String>();
try
{
// TBD: handle null key
fieldValues.add(PropertyUtils
.getSimpleProperty(bean, "key")
.toString());
PropertyDescriptor[] properties =
PropertyUtils.getPropertyDescriptors(bean);
for (PropertyDescriptor property : properties)
{
String propertyName = property.getName();
Object propertyValue =
PropertyUtils.getSimpleProperty(bean, propertyName);
if (null != propertyValue
&& !propertyValue.toString().isEmpty())
{
fieldValues.add(propertyValue.toString());
}
}
}
catch (Exception ite)
{
// TBD: handle this
}
return fieldValues.toArray(new String[0]);
}
public static boolean isBlank(String str) will return true if str is null or trimmed str is “”
You write in java and GWT compiles to javascript. Different dialects for each browser generated.
Used to write rich client applications like think client applications. GWT is a client side. Had remote procedure calls to made server side calls. On server side
JSF and other web framework support GWT. So GWT can be used to make
Put the pedal to the metal (use a tech. to achieve traction). :-)
· Use sparingly and try not to overload variable argument methods as it becomes difficult to figure out which method will get invoked. They are invoked when no other method signature matches the call.
· Zero or more arguments can be passed for variable arguments
· Variable arguments can only be used as the final set of argument in a method
e.g.
…..func1(String one, String… args) // correct
…..func1(String… args, String one) // not correct
Old:
public class Test2
{
public static void main(String[] args)
{
System.out.println(contact(",",new String[]{"one", "two", "three"}));
}
private static String contact(String seperator, String[] tokens)
{
StringBuilder s = new StringBuilder();
for (String currentValue : tokens)
{
s.append(currentValue);
s.append(seperator);
}
return s.toString();
}
}
New:
public class Test3
{
public static void main(String[] args)
{
System.out.println(contact(",","one", "two", "three"));
}
private static String contact(String seperator, String... tokens)
{
StringBuilder s = new StringBuilder();
for (String currentValue : tokens)
{
s.append(currentValue);
s.append(seperator);
}
return s.toString();
}
}
A business object is a software representation of a real life entity. The entity could be a person, process, event or place. Examples of business objects are employees, products, invoices and payments. Business objects contain business data and model business behavior/process.
Business objects are different from data object which only hold data and do not have any behavior.
There are 2 ways or 2 strategies to achieve business objects:
EJB Strategy: Uses Entity Beans to model business data (with or without Container Managed Persistence) and Session beans to model Business process.
Pojo Strategy: Use simple Pojo (Plain Old Java Objects) along with light weight persistence mechanism such as hibernate/JDO (Java Data Object) or JDBC.
Hibrid: Uses POJOs behind the scenes using EJBs. Implement session façade in session beans and use POJOs to persist data.
public interface OPCAdminFacade extends EJBObject {
public OrdersTO getOrdersByStatus(String status)
throws RemoteException, OPCAdminFacadeException;
public Map getChartInfo(String request,
Date start,
Date end,
String requestedCategory)
throws RemoteException, OPCAdminFacadeException;
}