Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * *********************************************************************************************************************
   *
   * NorthernWind - lightweight CMS
   * http://northernwind.tidalwave.it - hg clone https://bitbucket.org/tidalwave/northernwind-src
   * %%
   * Copyright (C) 2011 - 2013 Tidalwave s.a.s. (http://tidalwave.it)
   * %%
  * *********************************************************************************************************************
  *
  * 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.
  *
  * *********************************************************************************************************************
  *
  * $Id: DefaultViewFactory.java,v 09ab89e79044 2013/06/12 22:30:52 fabrizio $
  *
  * *********************************************************************************************************************
  * #L%
  */
 package it.tidalwave.northernwind.frontend.impl.ui;
 
 import  javax.annotation.Nonnull;
 import java.util.Map;
 import  it.tidalwave.util.Id;
 import  it.tidalwave.util.NotFoundException;
 import  it.tidalwave.util.spring.ClassScanner;
 import lombok.Getter;
 import lombok.Setter;
 import static it.tidalwave.util.NotFoundException.*;

The default implementation of ViewFactory.

Author(s):
Fabrizio Giudici
Version:
$Id: DefaultViewFactory.java,v 09ab89e79044 2013/06/12 22:30:52 fabrizio $ /
Stereotype:
Factory
 
 public class DefaultViewFactory implements ViewFactory
   {
     /* package */ final Map<StringViewBuilderviewBuilderMapByTypeUri = new TreeMap<>();
 
     @Getter @Setter
     private boolean logConfigurationEnabled = false;

    
/
 
     @Override @Nonnull
     public ViewAndController createViewAndController (final @Nonnull String viewTypeUri,
                                                       final @Nonnull Id viewId,
                                                       final @Nonnull SiteNode siteNode)
       throws NotFoundException, HttpStatusException
       {
         final ViewBuilder viewBuilder = throwWhenNull(.get(viewTypeUri),
                                                       String.format("Cannot find %s: available: %s",
                                                                     viewTypeUri.keySet()));
         return viewBuilder.createViewAndController(viewIdsiteNode);
       }

    
/
 
     @PostConstruct
     /* package */ void initialize() // FIXME: gets called twice
       throws IOException,
       {
         final ClassScanner classScanner = new ClassScanner().withAnnotationFilter(ViewMetadata.class);
 
         for (final Class<?> viewClass : classScanner.findClasses())
           {
             final ViewMetadata viewMetadata = viewClass.getAnnotation(ViewMetadata.class);
            final String typeUri = viewMetadata.typeUri();
            final ViewBuilder viewBuilder = new ViewBuilder(viewClassviewMetadata.controlledBy());
            .put(typeUriviewBuilder);
          }
        if ()
          {
            logConfiguration();
          }
      }

    
/
    private void logConfiguration()
      {
        log.info("View definitions:");
        for (final ViewBuilder viewBuilder : .values())
          {
            log.info(">>>> {}"viewBuilder);
          }
      }
  }
New to GrepCode? Check out our FAQ X