Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8221c934ba18ffd4937d00422fb7ec4ba6438e55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*******************************************************************************
 * Copyright (c) 2010 Oracle.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution. 
 * The Eclipse Public License is available at
 *     http://www.eclipse.org/legal/epl-v10.html
 * and the Apache License v2.0 is available at 
 *     http://www.opensource.org/licenses/apache2.0.php.
 * You may elect to redistribute this code under either of these licenses.
 *
 * Contributors:
 *     mkeith - Gemini JPA work 
 ******************************************************************************/
package org.eclipse.gemini.jpa;

import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

/**
 *  Detect when an existing DataSourceFactory service goes offline.
 *  Created and started when a registered DSF service was discovered 
 *  at EMF service registration time.
 */
@SuppressWarnings("rawtypes")
public class DSFOfflineTracker implements ServiceTrackerCustomizer {

    // The unit this tracker belongs to
    private PUnitInfo pUnitInfo;
    
    // The util to notify when the service goes away
    private GeminiServicesUtil servicesUtil;

    public DSFOfflineTracker(PUnitInfo pUnitInfo, GeminiServicesUtil servicesUtil) {
        this.pUnitInfo = pUnitInfo;
        this.servicesUtil = servicesUtil;
    }
    
    public Object addingService(ServiceReference ref) {
        GeminiUtil.debug("OfflineTracker.addingService - ignoring service ", ref);
        return null;
    }

    public void modifiedService(ServiceReference ref, Object service) {}

    public void removedService(ServiceReference ref, Object service) {
        GeminiUtil.debug("OfflineTracker.removingService ", ref);
        servicesUtil.dataSourceFactoryOffline(pUnitInfo, ref);
    }
}

Back to the top