01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.openjpa.event;
20:
21: import org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager;
22: import org.apache.openjpa.lib.util.Localizer;
23: import org.apache.openjpa.lib.conf.Configuration;
24: import org.apache.openjpa.conf.OpenJPAConfiguration;
25:
26: /**
27: * {@link EventManager} responsible for notifying listeners of
28: * {@link BrokerFactoryEvent}s.
29: *
30: * @since 1.0.0
31: */
32: public class BrokerFactoryEventManager extends
33: AbstractConcurrentEventManager {
34:
35: private static final Localizer _loc = Localizer
36: .forPackage(BrokerFactoryEventManager.class);
37:
38: private final Configuration _conf;
39:
40: public BrokerFactoryEventManager(Configuration conf) {
41: _conf = conf;
42: }
43:
44: protected void fireEvent(Object event, Object listener) {
45: try {
46: BrokerFactoryEvent e = (BrokerFactoryEvent) event;
47: ((BrokerFactoryListener) listener).eventFired(e);
48: } catch (Exception e) {
49: _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME).warn(
50: _loc.get("broker-factory-listener-exception"), e);
51: }
52: }
53: }
|