[jboss-cvs] JBossAS SVN: r107259 - projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 2 08:00:58 EDT 2010
Author: alesj
Date: 2010-08-02 08:00:55 -0400 (Mon, 02 Aug 2010)
New Revision: 107259
Added:
projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreAnyChecker.java
projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreCauseChecker.java
projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreChecker.java
projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreCurrentChecker.java
Modified:
projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreSetErrorHandler.java
Log:
More config on error handling.
Added: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreAnyChecker.java
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreAnyChecker.java (rev 0)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreAnyChecker.java 2010-08-02 12:00:55 UTC (rev 107259)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.scanning.plugins.visitor;
+
+/**
+ * Check any agaist the pre ignored.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class IgnoreAnyChecker extends IgnoreCurrentChecker
+{
+ public static IgnoreChecker INSTANCE = new IgnoreAnyChecker();
+
+ public boolean ignore(Throwable current, Iterable<Class<Throwable>> ignored)
+ {
+ while(current != null)
+ {
+ if (super.ignore(current, ignored))
+ return true;
+
+ current = current.getCause();
+ }
+ return false;
+ }
+}
\ No newline at end of file
Copied: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreCauseChecker.java (from rev 107258, projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreSetErrorHandler.java)
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreCauseChecker.java (rev 0)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreCauseChecker.java 2010-08-02 12:00:55 UTC (rev 107259)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.scanning.plugins.visitor;
+
+/**
+ * Check cause agaist the pre ignored.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class IgnoreCauseChecker extends IgnoreCurrentChecker
+{
+ public boolean ignore(Throwable current, Iterable<Class<Throwable>> ignored)
+ {
+ Throwable cause = current.getCause();
+ while (cause != null)
+ {
+ current = cause;
+ cause = current.getCause();
+ }
+
+ return super.ignore(current, ignored);
+ }
+}
\ No newline at end of file
Copied: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreChecker.java (from rev 107258, projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreSetErrorHandler.java)
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreChecker.java (rev 0)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreChecker.java 2010-08-02 12:00:55 UTC (rev 107259)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.scanning.plugins.visitor;
+
+/**
+ * Should we ignore throwable.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface IgnoreChecker
+{
+ /**
+ * Check if we should ignore current throwable.
+ *
+ * @param current the current throwable
+ * @param ignored the pre ignored set
+ * @return true if we should ignore, false otherwise
+ */
+ boolean ignore(Throwable current, Iterable<Class<Throwable>> ignored);
+}
\ No newline at end of file
Added: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreCurrentChecker.java
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreCurrentChecker.java (rev 0)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreCurrentChecker.java 2010-08-02 12:00:55 UTC (rev 107259)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.scanning.plugins.visitor;
+
+/**
+ * Just check current throwable against the pre ignored.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class IgnoreCurrentChecker implements IgnoreChecker
+{
+ public boolean ignore(Throwable current, Iterable<Class<Throwable>> ignore)
+ {
+ for (Class<Throwable> i : ignore)
+ {
+ if (i.isInstance(current))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
Modified: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreSetErrorHandler.java
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreSetErrorHandler.java 2010-08-02 11:34:14 UTC (rev 107258)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/IgnoreSetErrorHandler.java 2010-08-02 12:00:55 UTC (rev 107259)
@@ -42,24 +42,16 @@
@SuppressWarnings({"unchecked"})
private Set<Class<Throwable>> ignore = new HashSet<Class<Throwable>>();
+ private IgnoreChecker checker = IgnoreAnyChecker.INSTANCE;
+
public void handleError(ResourceVisitor visitor, ResourceContext resource, Throwable t)
{
- Throwable cause = t.getCause();
- while (cause != null)
+ if (checker != null && checker.ignore(t, ignore))
{
- t = cause;
- cause = t.getCause();
- }
+ if (log.isTraceEnabled())
+ log.trace("Ignoring resource (" + resource + ") at visitor (" + visitor + "), error: " + t);
- for (Class<Throwable> i : ignore)
- {
- if (i.isInstance(t))
- {
- if (log.isTraceEnabled())
- log.trace("Ignoring resource (" + resource + ") at visitor (" + visitor + "), error: " + t);
-
- return;
- }
+ return;
}
throw new RuntimeException("Error visiting resource: " + resource + ", visitor: " + visitor, t);
}
@@ -79,4 +71,9 @@
ignore.remove(t);
}
+
+ public void setChecker(IgnoreChecker checker)
+ {
+ this.checker = checker;
+ }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list