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.lifecycle;
18:
19: import javax.persistence.EntityManagerFactory;
20:
21: import org.compass.gps.device.jpa.JpaGpsDevice;
22: import org.compass.gps.device.jpa.JpaGpsDeviceException;
23:
24: /**
25: * <p>A global lifecycle event listener injector. Since the <code>EntityManagerFactory</code> does not
26: * allow for setting global lifecycle event listeners, actual implementations of the JPA spec can be
27: * used directly to inject global lifecycle event listeners usign propriety APIs.
28: *
29: * <p>Assume that the <code>EntityManagerFactory</code> is the native one, since the
30: * {@link org.compass.gps.device.jpa.NativeJpaExtractor} of the
31: * {@link JpaGpsDevice} was used to extract it.
32: *
33: * @author kimchy
34: * @see org.compass.gps.device.jpa.lifecycle.HibernateJpaEntityLifecycleInjector
35: * @see JpaEntityLifecycleInjectorDetector
36: */
37: public interface JpaEntityLifecycleInjector {
38:
39: /**
40: * Injects a global lifecycle listener into the concrete <code>EntityManagerFactory<code>
41: * implementation.
42: *
43: * @param entityManagerFactory The <code>EntityManagerFactory</code> to inject the global lifecycle to.
44: * @param device The Jpa device calling this injector
45: * @throws JpaGpsDeviceException
46: */
47: void injectLifecycle(EntityManagerFactory entityManagerFactory,
48: JpaGpsDevice device) throws JpaGpsDeviceException;
49:
50: /**
51: * Removes (if possible) lifecycle listeners injected using the inject method.
52: *
53: * @param entityManagerFactory The EMF to remove lifecycle from
54: * @param device The Jpa device calling
55: * @throws JpaGpsDeviceException
56: */
57: void removeLifecycle(EntityManagerFactory entityManagerFactory,
58: JpaGpsDevice device) throws JpaGpsDeviceException;
59: }
|