com.anrisoftware.sscontrol.httpd.yourls.YourlsFactoryFactory Maven / Gradle / Ivy
/*
* Copyright 2015 Erwin Müller
*
* This file is part of sscontrol-httpd-yourls.
*
* sscontrol-httpd-yourls is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* sscontrol-httpd-yourls is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
* for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with sscontrol-httpd-yourls. If not, see .
*/
package com.anrisoftware.sscontrol.httpd.yourls;
import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.customizers.ImportCustomizer;
import org.mangosdk.spi.ProviderFor;
import com.anrisoftware.sscontrol.core.api.ServiceException;
import com.anrisoftware.sscontrol.core.overridemode.OverrideMode;
import com.anrisoftware.sscontrol.httpd.webservice.WebServiceFactory;
import com.anrisoftware.sscontrol.httpd.webservice.WebServiceFactoryFactory;
import com.anrisoftware.sscontrol.httpd.webservice.WebServiceInfo;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
* Yourls web service factory.
*
* @author Erwin Mueller, [email protected]
* @since 1.0
*/
@ProviderFor(WebServiceFactoryFactory.class)
public class YourlsFactoryFactory implements WebServiceFactoryFactory {
/**
* Yourls service name.
*/
public static final String SERVICE_NAME = "yourls";
/**
* Yourls service information.
*/
@SuppressWarnings("serial")
public static final WebServiceInfo INFO = new WebServiceInfo() {
@Override
public String getServiceName() {
return SERVICE_NAME;
}
};
private static final Module[] MODULES = new Module[] { new YourlsModule() };
private Injector injector;
public YourlsFactoryFactory() {
}
@Override
public WebServiceFactory getFactory() throws ServiceException {
return injector.getInstance(YourlsServiceFactory.class);
}
@Override
public WebServiceInfo getInfo() {
return INFO;
}
@Override
public void setParent(Object parent) {
this.injector = ((Injector) parent).createChildInjector(MODULES);
}
@Override
public void configureCompiler(Object compiler) throws Exception {
CompilerConfiguration c = (CompilerConfiguration) compiler;
importClasses(c);
}
private void importClasses(CompilerConfiguration c) {
ImportCustomizer customizer = new ImportCustomizer();
customizer.addImports(OverrideMode.class.getName(),
Access.class.getName());
c.addCompilationCustomizers(customizer);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy