本文整理汇总了Java中org.seasar.framework.util.ClassUtil类的典型用法代码示例。如果您正苦于以下问题:Java ClassUtil类的具体用法?Java ClassUtil怎么用?Java ClassUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClassUtil类属于org.seasar.framework.util包,在下文中一共展示了ClassUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupValidator
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
/**
* バリデータをセットアップします。
*
*
* @param actionMapping
* アクションマッピング
* @param validatorResources
* 検証リソース
*/
protected void setupValidator(S2ActionMapping actionMapping,
S2ValidatorResources validatorResources) {
Map<String, Form> forms = new HashMap<String, Form>();
for (String methodName : actionMapping.getExecuteMethodNames()) {
if (actionMapping.getExecuteConfig(methodName).isValidator()) {
Form form = new Form();
form.setName(actionMapping.getName() + "_" + methodName);
forms.put(methodName, form);
}
}
for (Class<?> clazz = actionMapping.getActionFormBeanDesc()
.getBeanClass(); clazz != null && clazz != Object.class; clazz = clazz
.getSuperclass()) {
for (Field field : ClassUtil.getDeclaredFields(clazz)) {
for (Annotation anno : field.getDeclaredAnnotations()) {
processAnnotation(field.getName(), anno,
validatorResources, forms);
}
}
}
for (Iterator<Form> i = forms.values().iterator(); i.hasNext();) {
validatorResources.addForm(i.next());
}
}
示例2: getSimpleProperty
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
/**
* 単純なプロパティの値を返します。
*
* @param bean
* JavaBeans
* @param name
* プロパティ名
* @return プロパティの値
*/
protected Object getSimpleProperty(Object bean, String name) {
BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
if (!beanDesc.hasPropertyDesc(name)) {
return null;
}
PropertyDesc pd = beanDesc.getPropertyDesc(name);
if (!pd.isReadable()) {
return null;
}
Object value = pd.getValue(bean);
if (value == null) {
if (!ModifierUtil.isAbstract(pd.getPropertyType())) {
value = ClassUtil.newInstance(pd.getPropertyType());
if (pd.isWritable()) {
pd.setValue(bean, value);
}
} else if (Map.class.isAssignableFrom(pd.getPropertyType())) {
value = new HashMap<String, Object>();
if (pd.isWritable()) {
pd.setValue(bean, value);
}
}
}
return value;
}
示例3: setUp
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
@Override
public void setUp() {
getServletContext().setAttribute(Globals.MODULE_KEY, moduleConfig);
getServletContext().setAttribute(ValidatorPlugIn.VALIDATOR_KEY,
validatorResources);
originalLoader = Thread.currentThread().getContextClassLoader();
NamingConventionImpl convention = new NamingConventionImpl();
rootPackageName = ClassUtil.getPackageName(getClass());
convention.addRootPackageName(rootPackageName);
ondemand = new HotdeployBehavior();
ondemand.setNamingConvention(convention);
creator = new ActionCreator(convention);
creator.setActionCustomizer(new ActionCustomizer());
ondemand.setCreators(new ComponentCreator[] { creator });
S2ContainerBehavior.setProvider(ondemand);
ondemand.start();
}
示例4: getDbms
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
public static Dbms getDbms(String productName) {
Dbms dbms = (Dbms) dbmsInstances.get(productName);
if (dbms == null) {
String className = dbmsClassNames.getProperty("");
for (Iterator i = dbmsClassNames.keySet().iterator(); i.hasNext();) {
String productPrefix = (String) i.next();
if (productName.startsWith(productPrefix)) {
className = dbmsClassNames.getProperty(productPrefix);
break;
}
}
dbms = (Dbms) ClassUtil.newInstance(className);
dbmsInstances.put(productName, dbms);
}
return dbms;
}
示例5: setupUpdateMethodByManual
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
protected void setupUpdateMethodByManual(final Method method,
final String sql) {
final UpdateDynamicCommand cmd = new UpdateDynamicCommand(dataSource,
statementFactory);
cmd.setSql(sql);
String[] argNames = daoAnnotationReader.getArgNames(method);
if (argNames.length == 0 && isUpdateSignatureForBean(method)) {
argNames = new String[] { StringUtil.decapitalize(ClassUtil
.getShortClassName(beanClass)) };
}
cmd.setArgNames(argNames);
cmd.setArgTypes(method.getParameterTypes());
cmd
.setNotSingleRowUpdatedExceptionClass(getNotSingleRowUpdatedExceptionClass(method));
putSqlCommand(method.getName(), cmd);
}
示例6: executeGenerateAbstractSolrService
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
private void executeGenerateAbstractSolrService() {
final GenerateServiceCommand command = new GenerateServiceCommand();
command.setClasspathDir(diconDir);
command.setNamesPackageName(namesPackageName);
command.setEntityPackageName(entityPackageName);
command.setServicePackageName(servicePackageName);
command.setAbstractServiceTemplateFileName("java/gsp_abstract_solr_service.ftl");
command.setServiceClassNameSuffix("SolrService");
final List<URL> urlList = new ArrayList<URL>();
try {
urlList.add(diconDir.toURI().toURL());
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
final ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
final URLClassLoader newLoader = new URLClassLoader(urlList.toArray(new URL[] {}),
oldLoader);
try {
Thread.currentThread().setContextClassLoader(newLoader);
command.setRootPackageName(rootPackage);
Method init = ClassUtil.getDeclaredMethod(
AbstractCommand.class,
"init",
null);
init.setAccessible(true);
MethodUtil.invoke(init, command, null);
Method generateAbstractService = ClassUtil.getDeclaredMethod(
GenerateServiceCommand.class,
"generateAbstractService",
null);
generateAbstractService.setAccessible(true);
MethodUtil.invoke(generateAbstractService, command, null);
} finally {
Thread.currentThread().setContextClassLoader(oldLoader);
}
}
示例7: setSimpleProperty
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
/**
* 単純なプロパティの値を設定します。
*
* @param bean
* JavaBeans
* @param name
* パラメータ名
* @param value
* パラメータの値
* @throws ServletException
* 何か例外が発生した場合。
*/
@SuppressWarnings("unchecked")
protected void setSimpleProperty(Object bean, String name, Object value) {
if (bean instanceof Map) {
setMapProperty((Map) bean, name, value);
return;
}
BeanDesc beanDesc = BeanDescFactory.getBeanDesc(bean.getClass());
if (!beanDesc.hasPropertyDesc(name)) {
return;
}
PropertyDesc pd = beanDesc.getPropertyDesc(name);
if (!pd.isWritable()) {
return;
}
if (pd.getPropertyType().isArray()) {
pd.setValue(bean, value);
} else if (List.class.isAssignableFrom(pd.getPropertyType())) {
List<String> list = ModifierUtil.isAbstract(pd.getPropertyType()) ? new ArrayList<String>()
: (List<String>) ClassUtil
.newInstance(pd.getPropertyType());
list.addAll(Arrays.asList((String[]) value));
pd.setValue(bean, list);
} else if (value == null) {
pd.setValue(bean, null);
} else if (value instanceof String[]) {
String[] values = (String[]) value;
pd.setValue(bean, values.length > 0 ? values[0] : null);
} else {
pd.setValue(bean, value);
}
}
示例8: getArrayValue
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
/**
* 配列の値を返します。
*
* @param array
* 配列
* @param indexes
* インデックスの配列
* @param elementType
* 配列の要素の型
* @return 配列の値
*/
protected Object getArrayValue(Object array, int[] indexes,
Class<?> elementType) {
Object value = array;
elementType = convertClass(elementType);
for (int i = 0; i < indexes.length; i++) {
Object value2 = Array.get(value, indexes[i]);
if (i == indexes.length - 1 && value2 == null) {
value2 = ClassUtil.newInstance(elementType);
Array.set(value, indexes[i], value2);
}
value = value2;
}
return value;
}
示例9: getPagerCondition
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
/**
* セッション中の検索条件オブジェクトを取得します。
* <p>
* 検索条件オブジェクトが存在しない場合、新規に検索条件オブジェクトを生成します。
*
* @param request
* HttpServletRequest
* @return 検索条件オブジェクト
*/
public PagerCondition getPagerCondition(HttpServletRequest request) {
PagerCondition dto = (PagerCondition) request.getSession()
.getAttribute(pagerConditionName);
if (dto == null) {
dto = (PagerCondition) ClassUtil.newInstance(pagerConditionClass);
dto.setLimit(limit);
request.getSession().setAttribute(pagerConditionName, dto);
}
return dto;
}
示例10: getGeneratorClass
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
protected static Class getGeneratorClass(String name) {
Class clazz = (Class) generatorClasses.get(name);
if (clazz != null) {
return clazz;
}
return ClassUtil.forName(name);
}
示例11: createIdentifierGenerator
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
protected static IdentifierGenerator createIdentifierGenerator(Class clazz,
PropertyType propertyType, Dbms dbms) {
Constructor constructor = ClassUtil.getConstructor(clazz, new Class[] {
PropertyType.class, Dbms.class });
return (IdentifierGenerator) ConstructorUtil.newInstance(constructor,
new Object[] { propertyType, dbms });
}
示例12: getAdapter
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
private static Adapter getAdapter() {
try {
ClassUtil.forName("org.seasar.framework.env.Env");
} catch (ClassNotFoundRuntimeException ignore) {
return new AdapterS23();
}
return new AdapterS24();
}
示例13: AdapterS24
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
private AdapterS24() {
selectableDataSourceProxyClass = ClassUtil
.forName("org.seasar.extension.datasource.impl.SelectableDataSourceProxy");
try {
dataSourceFactoryField = selectableDataSourceProxyClass
.getDeclaredField("dataSourceFactory");
} catch (NoSuchFieldException ex) {
throw new NoSuchFieldRuntimeException(
selectableDataSourceProxyClass, "dataSourceFactory", ex);
}
dataSourceFactoryField.setAccessible(true);
getSelectableDataSourceNameMethod = ClassUtil.getMethod(
dataSourceFactoryField.getType(),
"getSelectableDataSourceName", null);
}
示例14: init
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
public void init() {
Class clazz = ResultSetHandlerFactoryImpl.class;
try {
clazz = ClassUtil.forName(TIGER_RESULT_SET_HANDLER_FACTORY);
} catch (ClassNotFoundRuntimeException ignore) {
}
ResultSetHandlerFactoryImpl factory = (ResultSetHandlerFactoryImpl) ClassUtil
.newInstance(clazz);
factory.setDtoMetaDataFactory(dtoMetaDataFactory);
factory.setRestrictNotSingleResult(restrictNotSingleResult);
resultSetHandlerFactory = factory;
}
示例15: combineProperties
import org.seasar.framework.util.ClassUtil; //导入依赖的package包/类
/**
* setterを拡張し、
* (1)スーパークラスの同メソッドを呼び、
* (2)modifiedPropertiesフィールドへsetterが呼ばれたことを記録します。
*/
private void combineProperties(final CtClass enhancedCtClass)
throws CannotCompileException {
final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(targetClass);
final int propertyDescSize = beanDesc.getPropertyDescSize();
for (int i = 0; i < propertyDescSize; i++) {
final PropertyDesc pd = beanDesc.getPropertyDesc(i);
if (!pd.hasWriteMethod() || !pd.hasReadMethod()) {
continue;
}
final String propertyName = pd.getPropertyName();
if (propertyName.equalsIgnoreCase(versionNoPropertyName)) {
continue;
}
if (propertyName.equalsIgnoreCase(timestampPropertyName)) {
continue;
}
final String setterName = pd.getWriteMethod().getName();
final String getterName = pd.getReadMethod().getName();
final String propertyClassName = ClassUtil
.getSimpleClassName(pd.getPropertyType());
final String oldName = propertyName + "Old";
final String s = "public void " + setterName + "("
+ propertyClassName + " " + propertyName + ")"
+ " { final " + propertyClassName + " " + oldName
+ " = super." + getterName + "(); " + "super."
+ setterName + "(" + propertyName + "); " + "if (!"
+ EqualsUtil.class.getName() + ".equals(" + oldName
+ ", " + propertyName + ")) "
+ modifiedPropertiesFieldName + ".add(\""
+ propertyName + "\"); }";
//System.out.println(s);
final CtMethod m = CtNewMethod.make(s, enhancedCtClass);
enhancedCtClass.addMethod(m);
}
}