本文整理汇总了Java中org.apache.commons.digester.RuleSet类的典型用法代码示例。如果您正苦于以下问题:Java RuleSet类的具体用法?Java RuleSet怎么用?Java RuleSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuleSet类属于org.apache.commons.digester包,在下文中一共展示了RuleSet类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadVenusService
import org.apache.commons.digester.RuleSet; //导入依赖的package包/类
private void loadVenusService(List<ServiceConfig> serviceConfigList, Map<String, InterceptorMapping> interceptors, Map<String, InterceptorStackConfig> interceptorStacks) {
for (Resource config : configFiles) {
RuleSet ruleSet = new FromXmlRuleSet(this.getClass().getResource("venusServerRule.xml"), new DigesterRuleParser());
Digester digester = new Digester();
digester.addRuleSet(ruleSet);
try {
InputStream is = config.getInputStream();
Venus venus = (Venus) digester.parse(is);
serviceConfigList.addAll(venus.getServiceConfigs());
interceptors.putAll(venus.getInterceptors());
interceptorStacks.putAll(venus.getInterceptorStatcks());
} catch (Exception e) {
throw new ConfigurationException("can not parser xml:" + config.getFilename(), e);
}
}
}
开发者ID:blusechen,项目名称:venus,代码行数:18,代码来源:XmlFileServiceManager.java
示例2: addRuleSets
import org.apache.commons.digester.RuleSet; //导入依赖的package包/类
/**
* <p>Add any custom RuleSet instances to configDigester that have
* been specified in the <code>rulesets</code> init parameter.</p>
*
* @throws ServletException
*/
private void addRuleSets() throws ServletException {
String rulesets = getServletConfig().getInitParameter("rulesets");
if (rulesets == null) {
rulesets = "";
}
rulesets = rulesets.trim();
String ruleset = null;
while (rulesets.length() > 0) {
int comma = rulesets.indexOf(",");
if (comma < 0) {
ruleset = rulesets.trim();
rulesets = "";
} else {
ruleset = rulesets.substring(0, comma).trim();
rulesets = rulesets.substring(comma + 1).trim();
}
if (log.isDebugEnabled()) {
log.debug("Configuring custom Digester Ruleset of type " + ruleset);
}
try {
RuleSet instance = (RuleSet) RequestUtils.applicationInstance(ruleset);
this.configDigester.addRuleSet(instance);
} catch (Exception e) {
log.error("Exception configuring custom Digester RuleSet", e);
throw new ServletException(e);
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:ActionServlet.java
示例3: applyRuleSets
import org.apache.commons.digester.RuleSet; //导入依赖的package包/类
/**
* Instantiate any <code>RuleSet</code> classes defined in the
* <code>rulesets</code> property and use them to add rules to our
* <code>Digester</code>.
* @param digester the Digester instance to add RuleSet objects to.
* @throws ServletException
*/
protected void applyRuleSets(Digester digester) throws ServletException {
if (this.rulesets == null || this.rulesets.trim().length() == 0) {
return;
}
rulesets = rulesets.trim();
String ruleSet = null;
while (rulesets.length() > 0) {
int comma = rulesets.indexOf(",");
if (comma < 0) {
ruleSet = rulesets.trim();
rulesets = "";
} else {
ruleSet = rulesets.substring(0, comma).trim();
rulesets = rulesets.substring(comma + 1).trim();
}
if (log.isDebugEnabled()) {
// TODO Internationalize msg
log.debug("Configuring custom Digester Ruleset of type " + ruleSet);
}
try {
RuleSet instance =
(RuleSet) RequestUtils.applicationInstance(ruleSet);
digester.addRuleSet(instance);
} catch (Exception e) {
// TODO Internationalize msg
log.error("Exception configuring custom Digester RuleSet", e);
throw new ServletException(e);
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:44,代码来源:DigestingPlugIn.java
示例4: loadConfiguration
import org.apache.commons.digester.RuleSet; //导入依赖的package包/类
private void loadConfiguration(List<ObjectPool> realPools) throws Exception {
VenusClient all = new VenusClient();
for (String configFile : configFiles) {
configFile = (String) ConfigUtil.filter(configFile);
RuleSet ruleSet = new FromXmlRuleSet(ServiceFactory.class.getResource("venusClientRule.xml"), new DigesterRuleParser());
Digester digester = new Digester();
digester.setValidating(false);
digester.addRuleSet(ruleSet);
try {
InputStream is = ResourceUtils.getURL(configFile.trim()).openStream();
VenusClient venus = (VenusClient) digester.parse(is);
for (ServiceConfig config : venus.getServiceConfigs()) {
if (config.getType() == null) {
throw new ConfigurationException("Service type can not be null:" + configFile);
}
}
all.getRemoteMap().putAll(venus.getRemoteMap());
all.getServiceConfigs().addAll(venus.getServiceConfigs());
} catch (Exception e) {
throw new ConfigurationException("can not parser xml:" + configFile, e);
}
}
// 初始化 remote,并且创建Pool
for (Map.Entry<String, Remote> entry : all.getRemoteMap().entrySet()) {
pool = createObjectPool(entry.getValue(), realPools);
}
}
开发者ID:blusechen,项目名称:venus,代码行数:30,代码来源:VenusPoolFactory.java
示例5: load
import org.apache.commons.digester.RuleSet; //导入依赖的package包/类
public void load(Resource resource){
URL eis = this.getClass().getResource("VenusSystemExceptionRule.xml");
if (eis == null) {
throw new VenusConfigException("classpath resource 'VenusSystemExceptionRule.xml' not found");
}
RuleSet ruleSet = new FromXmlRuleSet(eis, new DigesterRuleParser());
Digester digester = new Digester();
digester.addRuleSet(ruleSet);
try{
List<ExceptionConfig> list = (List<ExceptionConfig>) digester.parse(resource.getInputStream());
for (ExceptionConfig config : list) {
if (config.getErrorCode() == 0) {
Exception exception = (Exception) reflectionProvider.newInstance(config.getType());
if (exception instanceof CodedException) {
config.setErrorCode(((CodedException) exception).getErrorCode());
} else {
throw new VenusConfigException("exception type=" + config.getType()
+ " must implement CodedException or errorCode must not be null");
}
}
codeMap.put(config.getErrorCode(), config);
classMap.put(config.getType(), config);
}
}catch(Exception e){
try {
logger.error("parser "+resource.getURL()+" error", e);
} catch (IOException e1) {
logger.error("parser "+resource.getFilename()+" error", e);
}
}finally{
digester.clear();
}
}
开发者ID:blusechen,项目名称:venus,代码行数:36,代码来源:XmlVenusExceptionFactory.java
示例6: readRuleSet
import org.apache.commons.digester.RuleSet; //导入依赖的package包/类
protected RuleSet readRuleSet()
{
return new RuleSetBase()
{
@Override
public void addRuleInstances(Digester digester)
{
digester.addObjectCreate(PATTERN_ROOT, JRSimpleTemplate.class);
digester.addCallMethod(PATTERN_INCLUDED_TEMPLATE, "addIncludedTemplate", 0);
digester.addFactoryCreate(PATTERN_STYLE, JRTemplateStyleFactory.class);
digester.addSetNext(PATTERN_STYLE, "addStyle", JRStyle.class.getName());
digester.addFactoryCreate(PATTERN_STYLE_PEN, JRPenFactory.Style.class.getName());
digester.addFactoryCreate(PATTERN_BOX, JRBoxFactory.class.getName());
digester.addFactoryCreate(PATTERN_BOX_PEN, JRPenFactory.Box.class.getName());
digester.addFactoryCreate(PATTERN_BOX_TOP_PEN, JRPenFactory.Top.class.getName());
digester.addFactoryCreate(PATTERN_BOX_LEFT_PEN, JRPenFactory.Left.class.getName());
digester.addFactoryCreate(PATTERN_BOX_BOTTOM_PEN, JRPenFactory.Bottom.class.getName());
digester.addFactoryCreate(PATTERN_BOX_RIGHT_PEN, JRPenFactory.Right.class.getName());
digester.addFactoryCreate(PATTERN_PARAGRAPH, JRParagraphFactory.class.getName());
digester.addFactoryCreate(PATTERN_TAB_STOP, TabStopFactory.class.getName());
digester.addSetNext(PATTERN_TAB_STOP, "addTabStop", TabStop.class.getName());
}
};
}
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:30,代码来源:JRXmlTemplateDigesterFactory.java
示例7: addRuleSets
import org.apache.commons.digester.RuleSet; //导入依赖的package包/类
/**
* <p>Add any custom RuleSet instances to configDigester that have been
* specified in the <code>rulesets</code> init parameter.</p>
*
* @throws ServletException if an error occurs
*/
private void addRuleSets()
throws ServletException {
String rulesets = getServletConfig().getInitParameter("rulesets");
if (rulesets == null) {
rulesets = "";
}
rulesets = rulesets.trim();
String ruleset;
while (rulesets.length() > 0) {
int comma = rulesets.indexOf(",");
if (comma < 0) {
ruleset = rulesets.trim();
rulesets = "";
} else {
ruleset = rulesets.substring(0, comma).trim();
rulesets = rulesets.substring(comma + 1).trim();
}
if (log.isDebugEnabled()) {
log.debug("Configuring custom Digester Ruleset of type "
+ ruleset);
}
try {
RuleSet instance =
(RuleSet) RequestUtils.applicationInstance(ruleset);
this.configDigester.addRuleSet(instance);
} catch (Exception e) {
log.error("Exception configuring custom Digester RuleSet", e);
throw new ServletException(e);
}
}
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:46,代码来源:ActionServlet.java
示例8: init
import org.apache.commons.digester.RuleSet; //导入依赖的package包/类
public void init() {
doScanExtension();
//兼容 3.0.8以前版本
if(configFiles == null){
return;
}
for (String configFile : configFiles) {
configFile = (String) ConfigUtil.filter(configFile);
configFile = configFile.trim();
URL eis = this.getClass().getResource("VenusSystemExceptionRule.xml");
if (eis == null) {
throw new VenusConfigException("classpath resource 'VenusSystemExceptionRule.xml' not found");
}
RuleSet ruleSet = new FromXmlRuleSet(eis, new DigesterRuleParser());
Digester digester = new Digester();
digester.addRuleSet(ruleSet);
try {
InputStream is = null;
if (configFile.startsWith("classpath:")) {
configFile = configFile.substring("classpath:".length());
is = this.getClass().getClassLoader().getResourceAsStream(configFile);
} else {
is = new FileInputStream(new File(configFile));
}
List<ExceptionConfig> list = (List<ExceptionConfig>) digester.parse(is);
for (ExceptionConfig config : list) {
if (config.getErrorCode() == 0) {
Exception exception = (Exception) reflectionProvider.newInstance(config.getType());
if (exception instanceof CodedException) {
config.setErrorCode(((CodedException) exception).getErrorCode());
} else {
throw new VenusConfigException("exception type=" + config.getType()
+ " must implement CodedException or errorCode must not be null");
}
}
codeMap.put(config.getErrorCode(), config);
classMap.put(config.getType(), config);
}
} catch (Exception e) {
logger.error("parser VenusSystemExceptionRule.xml error", e);
}finally{
digester.clear();
}
}
}
开发者ID:blusechen,项目名称:venus,代码行数:50,代码来源:XmlVenusExceptionFactory.java
注:本文中的org.apache.commons.digester.RuleSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论