com.anrisoftware.sscontrol.httpd.gitit.GititFactoryFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sscontrol-httpd-gitit Show documentation
Show all versions of sscontrol-httpd-gitit Show documentation
Wiki software Gitit - http://gitit.net
/*
* Copyright 2014 Erwin Müller
*
* This file is part of sscontrol-httpd-gitit.
*
* sscontrol-httpd-gitit 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-gitit 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-gitit. If not, see .
*/
package com.anrisoftware.sscontrol.httpd.gitit;
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;
/**
* Web service factory.
*
* @author Erwin Mueller, [email protected]
* @since 1.0
*/
@ProviderFor(WebServiceFactoryFactory.class)
public class GititFactoryFactory implements WebServiceFactoryFactory {
private static final String AUTH_METHOD = "com.anrisoftware.sscontrol.httpd.gitit.AuthMethod";
private static final String LOGIN_REQUIRED = "com.anrisoftware.sscontrol.httpd.gitit.LoginRequired";
private static final String REPOSITORY_TYPE = "com.anrisoftware.sscontrol.httpd.gitit.RepositoryType";
private static final String OVERRIDE_MODE = "com.anrisoftware.sscontrol.httpd.webservice.OverrideMode";
/**
* Gitit service name.
*/
public static final String SERVICE_NAME = "gitit";
/**
* Gitit 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 GititModule() };
private Injector injector;
public GititFactoryFactory() {
}
@Override
public WebServiceFactory getFactory() throws ServiceException {
return injector.getInstance(GititServiceFactory.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(LOGIN_REQUIRED, AUTH_METHOD, REPOSITORY_TYPE,
OVERRIDE_MODE);
c.addCompilationCustomizers(customizer);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy