📄 urlactionmanager.java
字号:
// Copyright 2005-2007 onetsoft.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.onetsoft.fastjsp;
import com.onetsoft.fastjsp.util.ResourceResolver;
import com.onetsoft.fastjsp.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* Url action管理
*
* @author <a href="mailto:hgw@onetsoft.com">hgw</a>
*/
class UrlActionManager implements ActionManager {
private final Map pool = new HashMap(2); //key:actionName value:action
private String componentPkg = null;
public UrlActionManager(AbstractComponent component) {
this.componentPkg = component.getClass().getPackage().getName();
}
private final static String URL = "url";
private Class findActionClass(String actionName) {
try {
String className = new StringBuffer(96).append(componentPkg)
.append('.').append(URL).append('.').
append(StringUtils.firstCharUpper(actionName)).toString();
return ResourceResolver.forName(className);
} catch (Exception e) {
/*e.printStackTrace();*/
return null;
}
}
private Class findAction(String action) {
Class cl = (Class) pool.get(action);
if (cl == null) {
synchronized (action.intern()) {
cl = (Class) pool.get(action);
if (cl == null) {
cl = findActionClass(action);
if (cl != null) {
synchronized (pool) {
pool.put(action, cl);
}
}
}
}
}
return cl;
}
public void executeAction(AbstractPageCycle cycle) {
try {
Class cl = findAction(cycle.service.data.getString(cycle.service.servicer.module.actionName));
if (cl != null) {
AbstractAction a = (AbstractAction) cl.newInstance();
a.setCycle(cycle);
a.execute();
}
} catch (InstantiationException e) {
throw new ApplicationRuntimeException(e);
} catch (IllegalAccessException e) {
throw new ApplicationRuntimeException(e);
} catch (NullPointerException e) {
throw new ApplicationRuntimeException(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -