replace DefaultEngine annotation with the new Default annotation

This commit is contained in:
Sebastian Sdorra
2014-08-24 14:54:35 +02:00
parent 50b0b6b2b8
commit be24164b88
6 changed files with 11 additions and 67 deletions

View File

@@ -52,6 +52,6 @@ import java.lang.annotation.Target;
*/
@Documented
@BindingAnnotation
@Target(ElementType.PARAMETER)
@Target({ ElementType.TYPE, ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
public @interface Default {}

View File

@@ -1,56 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.template;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.BindingAnnotation;
//~--- JDK imports ------------------------------------------------------------
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Identifies the default {@link TemplateEngine}.
*
* @author Sebastian Sdorra
* @since 1.19
*/
@BindingAnnotation
@Target({ ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface DefaultEngine {}

View File

@@ -42,6 +42,8 @@ import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.Default;
//~--- JDK imports ------------------------------------------------------------
import java.util.Collection;
@@ -81,7 +83,7 @@ public final class TemplateEngineFactory
*/
@Inject
public TemplateEngineFactory(Set<TemplateEngine> engines,
@DefaultEngine TemplateEngine defaultEngine)
@Default TemplateEngine defaultEngine)
{
if (logger.isDebugEnabled())
{
@@ -186,8 +188,8 @@ public final class TemplateEngineFactory
//~--- fields ---------------------------------------------------------------
/** default template engine */
private TemplateEngine defaultEngine;
private final TemplateEngine defaultEngine;
/** map of registered template engines */
private Map<String, TemplateEngine> engineMap;
private final Map<String, TemplateEngine> engineMap;
}

View File

@@ -38,7 +38,6 @@ package sonia.scm;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.servlet.ServletModule;
import sonia.scm.template.DefaultEngine;
import sonia.scm.template.ErrorServlet;
import sonia.scm.template.MustacheTemplateEngine;
import sonia.scm.template.TemplateEngine;
@@ -66,7 +65,7 @@ public class ScmErrorModule extends ServletModule
Multibinder.newSetBinder(binder(), TemplateEngine.class);
engineBinder.addBinding().to(MustacheTemplateEngine.class);
bind(TemplateEngine.class).annotatedWith(DefaultEngine.class).to(
bind(TemplateEngine.class).annotatedWith(Default.class).to(
MustacheTemplateEngine.class);
bind(TemplateEngineFactory.class);

View File

@@ -105,7 +105,6 @@ import sonia.scm.store.JAXBConfigurationEntryStoreFactory;
import sonia.scm.store.JAXBDataStoreFactory;
import sonia.scm.store.JAXBStoreFactory;
import sonia.scm.store.StoreFactory;
import sonia.scm.template.DefaultEngine;
import sonia.scm.template.MustacheTemplateEngine;
import sonia.scm.template.TemplateEngine;
import sonia.scm.template.TemplateEngineFactory;
@@ -242,7 +241,7 @@ public class ScmServletModule extends JerseyServletModule
bind(SCMContextProvider.class).toInstance(context);
ScmConfiguration config = getScmConfiguration(context);
ScmConfiguration config = getScmConfiguration();
CipherUtil cu = CipherUtil.getInstance();
// bind repository provider
@@ -367,7 +366,7 @@ public class ScmServletModule extends JerseyServletModule
Multibinder.newSetBinder(binder(), TemplateEngine.class);
engineBinder.addBinding().to(MustacheTemplateEngine.class);
bind(TemplateEngine.class).annotatedWith(DefaultEngine.class).to(
bind(TemplateEngine.class).annotatedWith(Default.class).to(
MustacheTemplateEngine.class);
bind(TemplateEngineFactory.class);
@@ -494,7 +493,7 @@ public class ScmServletModule extends JerseyServletModule
*
* @return
*/
private ScmConfiguration getScmConfiguration(SCMContextProvider context)
private ScmConfiguration getScmConfiguration()
{
ScmConfiguration configuration = new ScmConfiguration();

View File

@@ -63,7 +63,7 @@ import javax.servlet.ServletContext;
*
* @author Sebastian Sdorra
*/
@DefaultEngine
@Default
public class MustacheTemplateEngine implements TemplateEngine
{