com.anrisoftware.sscontrol.httpd.redmine.RedmineFactoryFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sscontrol-httpd-redmine Show documentation
Show all versions of sscontrol-httpd-redmine Show documentation
Redmine project management web application - http://www.redmine.org/
/*
* Copyright ${project.inceptionYear] Erwin Müller
*
* This file is part of sscontrol-httpd-redmine.
*
* sscontrol-httpd-redmine 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-redmine 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-redmine. If not, see .
*/
package com.anrisoftware.sscontrol.httpd.redmine;
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.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;
/**
* Redmine service factory.
*
* @author Erwin Mueller, [email protected]
* @since 1.0
*/
@ProviderFor(WebServiceFactoryFactory.class)
public class RedmineFactoryFactory implements WebServiceFactoryFactory {
private static final String AUTHENTICATION_METHOD = "com.anrisoftware.sscontrol.httpd.redmine.AuthenticationMethod";
private static final String DELIVERY_METHOD = "com.anrisoftware.sscontrol.httpd.redmine.DeliveryMethod";
private static final String SCM_INSTALL = "com.anrisoftware.sscontrol.httpd.redmine.ScmInstall";
/**
* Redmine service name.
*/
public static final String SERVICE_NAME = "redmine";
/**
* Redmine 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 RedmineModule() };
private Injector injector;
public RedmineFactoryFactory() {
}
@Override
public WebServiceFactory getFactory() throws ServiceException {
return injector.getInstance(RedmineServiceFactory.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(DELIVERY_METHOD, AUTHENTICATION_METHOD,
SCM_INSTALL);
c.addCompilationCustomizers(customizer);
}
}