Coverage Report - org.apache.onami.autobind.configuration.example.map.dynamic.ExampleApp
 
Classes in this File Line Coverage Branch Coverage Complexity
ExampleApp
0%
0/10
N/A
1
 
 1  
 /**
 2  
  * Copyright (C) 2010 Daniel Manzke <daniel.manzke@googlemail.com>
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *         http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.onami.autobind.configuration.example.map.dynamic;
 17  
 
 18  
 import org.apache.onami.autobind.annotations.Bind;
 19  
 import org.apache.onami.autobind.annotations.GuiceModule;
 20  
 import org.apache.onami.autobind.configuration.StartupModule;
 21  
 import org.apache.onami.autobind.configuration.features.ConfigurationFeature;
 22  
 import org.apache.onami.autobind.example.starter.ExampleApplication;
 23  
 import org.apache.onami.autobind.scanner.ClasspathScanner;
 24  
 import org.apache.onami.autobind.scanner.PackageFilter;
 25  
 import org.apache.onami.autobind.scanner.ScannerModule;
 26  
 import org.apache.onami.autobind.scanner.asm.ASMClasspathScanner;
 27  
 
 28  
 import com.google.inject.Guice;
 29  
 import com.google.inject.Injector;
 30  
 
 31  
 
 32  
 /**
 33  
  * Example Application, which creates a new Injector with the help of the
 34  
  * provided {@link StartupModule}. It passes the {@link ASMClasspathScanner}
 35  
  * class for the {@link ClasspathScanner} and the packages (de.devsurf) which
 36  
  * should be scanned. The {@link StartupModule} binds these parameter, so we are
 37  
  * able to create and inject our {@link ScannerModule}. This Module uses the
 38  
  * {@link ClasspathScanner} to explore the Classpath and scans for Annotations.
 39  
  * 
 40  
  * All recognized Classes annotated with {@link GuiceModule} are installed in
 41  
  * the child injector and with {@link Bind} are automatically bound.
 42  
  * 
 43  
  * @author Daniel Manzke
 44  
  * 
 45  
  */
 46  
 @Bind(multiple = true)
 47  0
 public class ExampleApp implements ExampleApplication {
 48  
         @Override
 49  
         public void run() {
 50  0
                 System.setProperty("myconfig", "/configuration.properties");
 51  0
                 StartupModule starter = StartupModule.create(ASMClasspathScanner.class, PackageFilter.create(ExampleApp.class
 52  
                         ));
 53  0
                 starter.addFeature(ConfigurationFeature.class);
 54  0
                 starter.bindSystemProperties();
 55  0
                 Injector injector = Guice.createInjector(starter);
 56  0
                 System.out.println(injector.getInstance(Example.class).sayHello());
 57  0
         }
 58  
 
 59  
         public static void main(String[] args) {
 60  0
                 new ExampleApp().run();
 61  0
         }
 62  
 }