Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AzureFunction implements AutoCloseable #67

Merged
merged 1 commit into from Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -16,15 +16,19 @@
package io.micronaut.azure.function;

import io.micronaut.context.ApplicationContext;
import io.micronaut.context.ApplicationContextProvider;
import io.micronaut.context.env.Environment;

import java.io.Closeable;
import java.io.IOException;

/**
* A base Azure function class that sets up the Azure environment and preferred configuration.
*
* @author graemerocher
* @since 1.0.0
*/
public abstract class AzureFunction {
public abstract class AzureFunction implements ApplicationContextProvider, Closeable {
protected static ApplicationContext applicationContext;

static {
Expand All @@ -42,6 +46,19 @@ public void run() {
}));
}

@Override
public ApplicationContext getApplicationContext() {
return this.applicationContext;
}

@Override
public void close() throws IOException {
if (applicationContext != null) {
applicationContext.close();
applicationContext = null;
}
}

/**
* Default constructor.
*/
Expand Down
@@ -0,0 +1,15 @@
package io.micronaut.azure.function

import spock.lang.Specification

class AzureFunctionSpec extends Specification {

void "AzureFunction implements AutoCloseable"() {
expect:
new FooFunction() instanceof AutoCloseable
}

static class FooFunction extends AzureFunction {

}
}