Sha256: 3a04f66fb58bb7ea849390c8816bc735415f4f4ddf5b2db392f2ee5ab074d360

Contents?: true

Size: 1.6 KB

Versions: 24

Compression:

Stored size: 1.6 KB

Contents

/*
 * Copyright 2015 Sadayuki Furuhashi
 *
 * Licensed 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.embulk.guice;

import com.google.inject.Injector;

class LifeCycleInjectorProxy
        extends InjectorProxy
        implements LifeCycleInjector, CloseableInjector
{
    private final Injector injector;
    private final LifeCycleManager lifeCycleManager;

    public LifeCycleInjectorProxy(Injector injector, LifeCycleManager lifeCycleManager)
    {
        this.injector = injector;
        this.lifeCycleManager = lifeCycleManager;
    }

    @Override
    protected synchronized Injector injector()
    {
        if (isDestroyed()) {
            throw new IllegalStateException("Injector already destroyed");
        }
        return injector;
    }

    @Override
    public synchronized boolean isDestroyed()
    {
        return lifeCycleManager.isDestroyed();
    }

    @Override
    public synchronized void destroy()
            throws Exception
    {
        lifeCycleManager.destroy();  // reentrant
    }

    @Override
    public void close()
            throws Exception
    {
        destroy();
    }
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
embulk-0.7.11 embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.11-java embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.10 embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.10-java embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.9 embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.9-java embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.8 embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.8-java embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.7 embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.7-java embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.6 embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.6-java embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.5 embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.5-java embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.4 embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.4-java embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.3 embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.3-java embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.2 embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java
embulk-0.7.2-java embulk-core/src/main/java/org/embulk/guice/LifeCycleInjectorProxy.java