01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.gps.device.jpa;
18:
19: import org.compass.core.Compass;
20: import org.compass.gps.spi.CompassGpsInterfaceDevice;
21:
22: /**
23: * An abstract support class for event lifecycle JPA spec support. Requires the <code>JpaGpsDevice<code>
24: * instance to be provided (usual sub classes will simple fetch it from the Jndi location). This
25: * is the least prefereable way to use lifecycle event listerens, please see
26: * {@link JpaGpsDevice} and {@link org.compass.gps.device.jpa.lifecycle.JpaEntityLifecycleInjector}.
27: *
28: * @author kimchy
29: */
30: public abstract class AbstractDeviceJpaEntityListener extends
31: AbstractCompassJpaEntityListener {
32:
33: protected abstract JpaGpsDevice getDevice();
34:
35: protected Compass getCompass() {
36: return ((CompassGpsInterfaceDevice) getDevice().getGps())
37: .getMirrorCompass();
38: }
39:
40: protected boolean disable() {
41: return !getDevice().shouldMirrorDataChanges()
42: || getDevice().isPerformingIndexOperation();
43: }
44: }
|