All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qwazr.compiler.CompilerManager Maven / Gradle / Ivy

/**
 * Copyright 2015-2016 Emmanuel Keller / QWAZR
 * 

* 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 com.qwazr.compiler; import com.qwazr.classloader.ClassLoaderManager; import com.qwazr.server.GenericServer; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.util.concurrent.ExecutorService; public class CompilerManager { public final static String SERVICE_NAME_COMPILER = "compiler"; private final JavaCompiler javaCompiler; private final CompilerServiceInterface service; public CompilerManager(final ExecutorService executor, final ClassLoaderManager classLoaderManager, final File dataDirectory) throws IOException, URISyntaxException { final File javaSourceDirectory = new File(dataDirectory, "src/main/java"); if (!classLoaderManager.javaClassesDirectory.exists()) classLoaderManager.javaClassesDirectory.mkdirs(); javaCompiler = JavaCompiler.newInstance(executor, classLoaderManager, javaSourceDirectory, classLoaderManager.javaClassesDirectory, classLoaderManager.javaLibrariesDirectory); service = new CompilerServiceImpl(this); } public CompilerManager(final ExecutorService executorService, final ClassLoaderManager classLoaderManager, final GenericServer.Builder builder) throws IOException, URISyntaxException { this(executorService, classLoaderManager, builder.getConfiguration().dataDirectory); builder.shutdownListener(new GenericServer.Listener() { @Override public void accept(GenericServer server) { javaCompiler.close(); } }); builder.contextAttribute(this); } public CompilerServiceInterface getService() { return service; } CompilerStatus getStatus() { return javaCompiler.getStatus(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy