You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/10/07 10:58:05 UTC
svn commit: r702394 -
/geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventAdapter.java
Author: jdillon
Date: Tue Oct 7 01:58:04 2008
New Revision: 702394
URL: http://svn.apache.org/viewvc?rev=702394&view=rev
Log:
Add typed event support (er hack)
Added:
geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventAdapter.java (with props)
Added: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventAdapter.java?rev=702394&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventAdapter.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventAdapter.java Tue Oct 7 01:58:04 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.geronimo.gshell.event;
+
+/**
+ * Adapter for typed {@link Event} processing.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class EventAdapter<T extends Event>
+ implements EventListener
+{
+ @SuppressWarnings({"unchecked"})
+ public void onEvent(final Event event) throws Exception {
+ // HACK: Can't check the type from T, so just handle the CCE, might not be very efficent though :-(
+ try {
+ handleEvent((T)event);
+ }
+ catch (ClassCastException ignore) {}
+ }
+
+ protected abstract void handleEvent(T event) throws Exception;
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventAdapter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-event/src/main/java/org/apache/geronimo/gshell/event/EventAdapter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain