【Java开源代码栏目提醒】:网学会员在Java开源代码频道为大家收集整理了AuditBeanBeanInfo.java提供大家参考,希望对大家有所帮助!
package ejava.beansch7;
import java.beans.SimpleBeanInfo;
import java.beans.PropertyDescriptor;
import java.beans.MethodDescriptor;
import java.beans.EventSetDescriptor;
import java.beans.IntrospectionException;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.IntrospectionException;
import java.beans.BeanDescriptor;
/**
* Implements the Bean info for our bean. SimpleBeanInfo
* is a basic implementation of the BeanInfo Interface
*/
public class AuditBeanBeanInfo extends SimpleBeanInfo
{
public BeanDescriptor getBeanDescriptor()
{
BeanDescriptor beanDescriptor =
new BeanDescriptor(ejava.beansch7.AuditBean.class);
beanDescriptor.setDisplayName("AuditBean");
return beanDescriptor;
}
/**
* Get Property Description information to expose the properties
* to builder tools
*/
public PropertyDescriptor[] getPropertyDescriptors ()
{
try {
// Create a descriptor for file property
PropertyDescriptor fileP =
new PropertyDescriptor("file", AuditBean.class,
"getFile", "setFile");
// Create a descriptor for FileName property
PropertyDescriptor fileNameP =
new PropertyDescriptor("fileName", AuditBean.class,
"getFileName", "setFileName");
fileNameP.setDisplayName("File Name");
fileNameP.setBound(true);
// Create a descriptor for Audit Type property
PropertyDescriptor auditTypeP = new
PropertyDescriptor("AuditType", AuditBean.class);
// Set audit type property editor to audit type property
auditTypeP.setPropertyEditorClass(
AuditPropertyEditor.class);
// Return properties, so that builder tools can find them
PropertyDescriptor[] descriptors =
new PropertyDescriptor[] {fileP, fileNameP, auditTypeP};
return descriptors;
}
catch (Exception ex) {
return null;
}
}
/**
* Get the methods and its, descriptons
*/
public MethodDescriptor[] getMethodDescriptors ()
{
try {
MethodDescriptor[] descriptors = {
new MethodDescriptor (
AuditBean.class.getMethod ("auditMessage", new Class[0]))};
return descriptors;
}
catch (Exception ex) {
return null;
}
}
/**
* Get the Event Descriptors for the beans
*/
public EventSetDescriptor[] getEventSetDescriptors ()
{
try {
EventSetDescriptor[] events = {
new EventSetDescriptor (AuditBean.class,
"audit", AuditListener.class,
"notifyAuditEvent")};
return events;
}
catch (IntrospectionException ex) {
return null;
}
}
/**
* Additional Bean info is the super class information of the bean.
*
*/
public BeanInfo[] getAdditionalBeanInfo() {
Class superclass = AuditBean.class.getSuperclass();
try {
BeanInfo superBeanInfo =
Introspector.getBeanInfo(superclass);
return new BeanInfo[] { superBeanInfo };
}
catch (IntrospectionException ex) {
ex.printStackTrace();
return null;
}
}
}
上一篇:
AuditBean.java
下一篇:
一个人晕着也能去看病打针