Search in sources :

Example 1 with SpringBootApplication

use of org.springframework.boot.autoconfigure.SpringBootApplication in project spring-cloud-function by spring-cloud.

the class AzureSpringFunctionInitializer method getStartClass.

private static Class<?> getStartClass(List<URL> list) {
    for (URL url : list) {
        try {
            InputStream inputStream = url.openStream();
            try {
                Manifest manifest = new Manifest(inputStream);
                String startClass = manifest.getMainAttributes().getValue("Main-Class");
                if (startClass != null) {
                    Class<?> aClass = ClassUtils.forName(startClass, org.springframework.cloud.function.adapter.azure.AzureSpringFunctionInitializer.class.getClassLoader());
                    SpringBootApplication declaredAnnotation = aClass.getDeclaredAnnotation(SpringBootApplication.class);
                    if (declaredAnnotation != null) {
                        return aClass;
                    }
                }
            } finally {
                inputStream.close();
            }
        } catch (Exception ex) {
        }
    }
    return null;
}
Also used : SpringBootApplication(org.springframework.boot.autoconfigure.SpringBootApplication) InputStream(java.io.InputStream) Manifest(java.util.jar.Manifest) URL(java.net.URL) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 Manifest (java.util.jar.Manifest)1 SpringBootApplication (org.springframework.boot.autoconfigure.SpringBootApplication)1