Java Code Examples for com.google.inject.Inject

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: CommitViewHolder.java

  15 
vote

@Inject public CommitViewHolder(@Assisted View v,ImageSession avatarSession){
  this.avatarSession=avatarSession;
  commit_date=(TextView)v.findViewById(tv_commit_list_item_commit_date);
  commit_shortdesc=(TextView)v.findViewById(tv_commit_list_item_shortdesc);
  gravatar=(ImageView)v.findViewById(iv_commit_list_item_gravatar);
}
 

Example 2

From project Aion-Extreme, under directory /AE-go_GameServer/src/com/aionemu/gameserver/network/aion/.

Source file: AionConnection.java

  15 
vote

/** 
 * Constructor
 * @param sc
 * @param d
 * @throws IOException
 */
@Inject public AionConnection(@Assisted SocketChannel sc,@Assisted Dispatcher d,LoginServer loginServer,AionPacketHandler aionPacketHandler,PlayerService playerService) throws IOException {
  super(sc,d);
  this.loginServer=loginServer;
  this.aionPacketHandler=aionPacketHandler;
  this.playerService=playerService;
  state=State.CONNECTED;
  String ip=getIP();
  log.info("connection from: " + ip);
  sendPacket(new SM_KEY());
}
 

Example 3

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/model/.

Source file: SessionManager.java

  15 
vote

@Inject public void init(){
  telephonyManager.listen(new PhoneStateListener(){
    @Override public void onCallStateChanged(    int state,    String incomingNumber){
      if (state == TelephonyManager.CALL_STATE_IDLE) {
        continueSession();
      }
 else {
        pauseSession();
      }
    }
  }
,PhoneStateListener.LISTEN_CALL_STATE);
  eventBus.register(this);
}
 

Example 4

From project airlift, under directory /discovery/src/main/java/io/airlift/discovery/client/.

Source file: Announcer.java

  15 
vote

@Inject public Announcer(DiscoveryAnnouncementClient announcementClient,Set<ServiceAnnouncement> serviceAnnouncements){
  Preconditions.checkNotNull(announcementClient,"client is null");
  Preconditions.checkNotNull(serviceAnnouncements,"serviceAnnouncements is null");
  this.announcementClient=announcementClient;
  for (  ServiceAnnouncement serviceAnnouncement : serviceAnnouncements) {
    announcements.put(serviceAnnouncement.getId(),serviceAnnouncement);
  }
  executor=new ScheduledThreadPoolExecutor(5,new ThreadFactoryBuilder().setNameFormat("Announcer-%s").setDaemon(true).build());
}
 

Example 5

From project Android, under directory /app/src/main/java/com/github/mobile/persistence/.

Source file: OrganizationRepositories.java

  15 
vote

/** 
 * Create repositories cache for a given organization
 * @param orgs
 * @param repos
 * @param watcher
 * @param accountProvider
 */
@Inject public OrganizationRepositories(@Assisted User orgs,RepositoryService repos,WatcherService watcher,Provider<GitHubAccount> accountProvider){
  this.org=orgs;
  this.repos=repos;
  this.watcher=watcher;
  this.accountProvider=accountProvider;
}
 

Example 6

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/core/model/persistence/.

Source file: InitialDataGenerator.java

  15 
vote

@Inject public InitialDataGenerator(EntityPersister<Context> contextPersister,EntityPersister<Project> projectPersister,EntityPersister<Task> taskPersister,ContentResolverProvider provider,ResourcesProvider resourcesProvider){
  mContentResolver=provider.get();
  mResources=resourcesProvider.get();
  mContextPersister=contextPersister;
  mProjectPersister=projectPersister;
  mTaskPersister=taskPersister;
  initPresetContexts();
}
 

Example 7

From project annotare2, under directory /app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/gwt/editor/client/.

Source file: IdfData.java

  15 
vote

@Inject public IdfData(IdfServiceAsync idfService){
  this.idfService=idfService;
  new Timer(){
    @Override public void run(){
      sendChanges();
    }
  }
.scheduleRepeating(2000);
}
 

Example 8

From project Arecibo, under directory /agent/src/main/java/com/ning/arecibo/agent/.

Source file: AgentDataCollectorManager.java

  15 
vote

@Inject public AgentDataCollectorManager(AgentConfig agentConfig,EventPublisher eventPublisher,ConfigInitializer initializer,DataSourceUtils dataSourceUtils){
  this.agentConfig=agentConfig;
  this.eventPublisher=eventPublisher;
  this.initializer=initializer;
  this.dataSourceUtils=dataSourceUtils;
  this.collectorMap=new ConcurrentHashMap<String,AgentDataCollector>();
  this.configMap=new ConcurrentHashMap<String,Config>();
  this.perHostSemaphoreMap=new ConcurrentHashMap<String,Semaphore>();
}
 

Example 9

From project arquillian_deprecated, under directory /testng/src/main/java/org/jboss/arquillian/testng/.

Source file: TestNGDeploymentAppender.java

  15 
vote

public Archive<?> createAuxiliaryArchive(){
  JavaArchive archive=ShrinkWrap.create(JavaArchive.class,"arquillian-testng.jar").addPackages(true,Filters.exclude("/org/testng/junit/.*|/org/testng/eclipse/.*"),TestNG.class.getPackage(),Package.getPackage("org.jboss.arquillian.testng")).addAsServiceProvider(TestRunner.class,TestNGTestRunner.class);
  optionalPackages(archive,Filters.exclude(".*/InterceptorStackCallback\\$InterceptedMethodInvocation.*"),Inject.class.getPackage().getName());
  optionalPackages(archive,Filters.includeAll(),"com.beust");
  return archive;
}
 

Example 10

From project ballroom, under directory /showcase/src/main/java/org/jboss/as/console/client/layout/.

Source file: MainLayoutViewImpl.java

  15 
vote

@Inject public MainLayoutViewImpl(){
  mainContentPanel=new LayoutPanel();
  mainContentPanel.setStyleName("main-content-panel");
  headerPanel=new LayoutPanel();
  headerPanel.setStyleName("header-panel");
  footerPanel=new LayoutPanel();
  footerPanel.setStyleName("footer-panel");
  panel=new DockLayoutPanel(Style.Unit.PX);
  panel.addNorth(headerPanel,64);
  panel.addSouth(footerPanel,30);
  panel.add(mainContentPanel);
  headerPanel.add(new HTML("<h2>Ballroom Showcase</h2>"));
}
 

Example 11

From project candlepin, under directory /src/main/java/org/candlepin/audit/.

Source file: ActivationListener.java

  15 
vote

@Inject public ActivationListener(SubscriptionServiceAdapter subService){
  this.subscriptionService=subService;
  AnnotationIntrospector primary=new JacksonAnnotationIntrospector();
  AnnotationIntrospector secondary=new JaxbAnnotationIntrospector();
  AnnotationIntrospector pair=new AnnotationIntrospector.Pair(primary,secondary);
  mapper=new ObjectMapper();
  mapper.setAnnotationIntrospector(pair);
}
 

Example 12

From project cdk, under directory /generator/src/main/java/org/richfaces/cdk/generate/freemarker/.

Source file: CdkConfiguration.java

  15 
vote

@Inject public CdkConfiguration(ObjectWrapper wrapper,Logger log,FreeMakerUtils utils){
  super();
  this.log=log;
  setClassForTemplateLoading(this.getClass(),getTemplatesFolder());
  setTemplateUpdateDelay(10000);
  setSharedVariable("utils",utils);
  setObjectWrapper(wrapper);
}
 

Example 13

From project closure-templates, under directory /java/src/com/google/template/soy/javasrc/internal/.

Source file: GenCallCodeUtils.java

  15 
vote

/** 
 * @param javaSrcOptions The options for generating Java source code.
 * @param isComputableAsJavaExprsVisitor The IsComputableAsJavaExprsVisitor to be used.
 * @param genJavaExprsVisitorFactory Factory for creating an instance of GenJavaExprsVisitor.
 * @param translateToJavaExprVisitorFactory Factory for creating an instance ofTranslateToJavaExprVisitor.
 */
@Inject GenCallCodeUtils(SoyJavaSrcOptions javaSrcOptions,IsComputableAsJavaExprsVisitor isComputableAsJavaExprsVisitor,GenJavaExprsVisitorFactory genJavaExprsVisitorFactory,TranslateToJavaExprVisitorFactory translateToJavaExprVisitorFactory){
  this.javaSrcOptions=javaSrcOptions;
  this.isComputableAsJavaExprsVisitor=isComputableAsJavaExprsVisitor;
  this.genJavaExprsVisitorFactory=genJavaExprsVisitorFactory;
  this.translateToJavaExprVisitorFactory=translateToJavaExprVisitorFactory;
}
 

Example 14

From project cloud-management, under directory /src/main/java/com/proofpoint/cloudmanagement/service/.

Source file: InstancesResource.java

  15 
vote

@Inject public InstancesResource(Map<String,InstanceConnector> instanceConnectorMap,DnsManager dnsManager,TagManager tagManager){
  this.instanceConnectorMap=instanceConnectorMap;
  this.instanceCreationNotifiers=ConcurrentHashMultiset.<InstanceCreationNotifier>create();
  this.tagManager=tagManager;
  this.dnsManager=dnsManager;
}
 

Example 15

From project collector, under directory /src/main/java/com/ning/metrics/collector/events/parsing/.

Source file: ThriftEnvelopeEventParser.java

  15 
vote

@Inject public ThriftEnvelopeEventParser(final NumberConverter numberConverter){
  this.numberConverter=numberConverter;
  this.byteConverter=new ByteConverter(numberConverter);
  this.shortConverter=new ShortConverter(numberConverter);
  this.integerConverter=new IntegerConverter(numberConverter);
}
 

Example 16

From project components-ness-config, under directory /src/main/java/com/nesscomputing/config/.

Source file: ConfigJmxExporter.java

  15 
vote

@Inject(optional=true) synchronized void setMBeanServer(MBeanServer server){
  Preconditions.checkArgument(server != null,"null MBeanServer");
  this.server=server;
  try {
    exportConfig();
  }
 catch (  JMException e) {
    LOG.error(e,"Unable to export configuration tree to JMX");
  }
  for (  Entry<? extends Class<?>,Object> e : delayedBeanExports) {
    export(e.getKey(),e.getValue());
  }
}
 

Example 17

From project components-ness-httpserver_1, under directory /src/main/java/com/nesscomputing/httpserver/log/file/.

Source file: FileRequestLog.java

  15 
vote

@Inject public FileRequestLog(final FileRequestLogConfig requestLogConfig,final Map<String,LogField> knownFields){
  final List<String> logFields=requestLogConfig.getLogFields();
  LogFields.validateLogFields(knownFields,logFields);
  this.logFields=logFields;
  this.blackList=requestLogConfig.getBlacklist();
  this.requestLogFile=new File(requestLogConfig.getFileName());
  this.knownFields=knownFields;
}
 

Example 18

From project components-ness-jackson, under directory /src/main/java/com/nesscomputing/jackson/.

Source file: JacksonFormatObjectMapperProvider.java

  15 
vote

@Inject(optional=true) void injectObjectMappers(@Json final ObjectMapper jsonObjectMapper,@Smile final ObjectMapper smileObjectMapper){
switch (jacksonFormatConfig.getDataFormat()) {
case JSON:
    LOG.trace("Using JSON format");
  this.objectMapper=jsonObjectMapper;
break;
case SMILE:
LOG.trace("Using SMILE format");
this.objectMapper=smileObjectMapper;
break;
}
}
 

Example 19

From project components-ness-jersey, under directory /jersey/src/main/java/com/nesscomputing/jersey/exceptions/.

Source file: GuiceProvisionExceptionMapper.java

  15 
vote

@Inject @SuppressWarnings("unchecked") public GuiceProvisionExceptionMapper(final Injector injector){
  for (  Map.Entry<Key<?>,Binding<?>> binding : injector.getAllBindings().entrySet()) {
    final Key<?> key=binding.getKey();
    final Class<?> clazz=key.getTypeLiteral().getRawType();
    Class<? extends Throwable> c=null;
    if (clazz.equals(ExceptionMapper.class)) {
      final Type type=key.getTypeLiteral().getType();
      if (type instanceof ParameterizedType) {
        final Type[] params=((ParameterizedType)type).getActualTypeArguments();
        Preconditions.checkState(params != null && params.length == 1,"Not a valid Exception mapper found: %s",type);
        c=Class.class.cast(params[0]);
      }
    }
 else {
      final Class<?>[] interfaces=clazz.getInterfaces();
      if (ArrayUtils.contains(interfaces,ExceptionMapper.class)) {
        final Type type=key.getTypeLiteral().getType();
        if (type instanceof Class && !(this.getClass().equals(type))) {
          c=getExceptionType(Class.class.cast(type));
        }
      }
    }
    if (c != null) {
      exceptionMappers.put(c,ExceptionMapper.class.cast(injector.getInstance(key)));
    }
  }
}
 

Example 20

From project components-ness-jmx, under directory /src/main/java/com/nesscomputing/jmx/jolokia/.

Source file: JolokiaServlet.java

  15 
vote

@Inject public JolokiaServlet(final BackendManager backendManager,final HttpRequestHandler requestHandler){
  this.backendManager=backendManager;
  this.requestHandler=requestHandler;
  this.httpGetHandler=new HttpGetHandler();
  this.httpPostHandler=new HttpPostHandler();
}
 

Example 21

From project components-ness-mongo, under directory /src/main/java/com/nesscomputing/mongo/.

Source file: BSONTransformerBinder.java

  15 
vote

@Inject(optional=true) void injectBSONEncodingTransformers(@Named(ENCODING_NAME) final Map<Class<?>,Transformer> encodingTransformers){
  Preconditions.checkNotNull(encodingTransformers,"transformers can not be null!");
  for (  Map.Entry<Class<?>,Transformer> entry : encodingTransformers.entrySet()) {
    BSON.addEncodingHook(entry.getKey(),entry.getValue());
  }
}
 

Example 22

From project console_1, under directory /gwt/src/main/java/org/switchyard/console/client/ui/application/.

Source file: ApplicationPresenter.java

  15 
vote

/** 
 * Create a new ApplicationPresenter.
 * @param eventBus the injected EventBus.
 * @param view the injected MyView.
 * @param proxy the injected MyProxy.
 * @param placeManager the injected PlaceManager.
 * @param revealStrategy the RevealStrategy
 * @param switchYardStore the injected SwitchYardStore.
 */
@Inject public ApplicationPresenter(EventBus eventBus,MyView view,MyProxy proxy,PlaceManager placeManager,RevealStrategy revealStrategy,SwitchYardStore switchYardStore){
  super(eventBus,view,proxy);
  _placeManager=placeManager;
  _revealStrategy=revealStrategy;
  _switchYardStore=switchYardStore;
}
 

Example 23

From project eclipse-task-editor, under directory /plugins/de.sebastianbenz.task.ui/src/de/sebastianbenz/task/ui/labeling/.

Source file: TaskLabelProvider.java

  15 
vote

@Inject public TaskLabelProvider(InjectableAdapterFactoryLabelProvider delegate,StylerFactory stylerFactory,HighlightingConfiguration configuration){
  super(delegate);
  this.delegate=delegate;
  this.stylerFactory=stylerFactory;
  this.configuration=configuration;
}
 

Example 24

From project emite, under directory /examples/src/main/java/com/calclab/emite/example/pingpong/client/events/.

Source file: ConnectionEventsSupervisor.java

  15 
vote

@Inject public ConnectionEventsSupervisor(final XmppConnection connection,final PingPongDisplay display){
  this.display=display;
  connection.addStanzaReceivedHandler(this);
  connection.addStanzaSentHandler(this);
  connection.addConnectionStateChangedHandler(this);
}
 

Example 25

From project Empire, under directory /core/src/com/clarkparsia/empire/spi/.

Source file: EmpirePersistenceProvider.java

  15 
vote

/** 
 * Create a new EmpirePersistenceProvider
 * @param theFactories the list of DataSourceFactory objects available
 * @param theContainerConfig the current empire configuration
 */
@Inject EmpirePersistenceProvider(Set<DataSourceFactory> theFactories,@Named("ec") EmpireConfiguration theContainerConfig){
  mFactories=theFactories;
  mContainerConfig=theContainerConfig;
  Runtime.getRuntime().addShutdownHook(new Thread(){
    /** 
 * @inheritDoc
 */
    @Override public void run(){
      close();
    }
  }
);
}
 

Example 26

From project eventtracker, under directory /common/src/main/java/com/ning/metrics/eventtracker/.

Source file: DiskSpoolEventWriterProvider.java

  15 
vote

@Inject public DiskSpoolEventWriterProvider(final EventTrackerConfig config,final EventSender eventSender,final ScheduledExecutorService executor,final EventSerializer serializer){
  this.config=config;
  this.eventSender=eventSender;
  this.executor=executor;
  this.serializer=serializer;
}
 

Example 27

From project exo-training, under directory /gxt-showcase/src/main/java/com/sencha/gxt/explorer/client/app/ui/.

Source file: ExampleDetailViewImpl.java

  15 
vote

@Inject public ExampleDetailViewImpl(ExampleModel model){
  tabPanel=new TabPanel();
  tabPanel.setBodyBorder(true);
  tabPanel.setTabScroll(true);
  tabPanel.setCloseContextMenu(true);
  tabPanel.addSelectionHandler(new SelectionHandler<Widget>(){
    @Override public void onSelection(    SelectionEvent<Widget> event){
      Widget item=event.getSelectedItem();
      TabItemConfig config=tabPanel.getConfig(item);
      String name=config.getText();
      Example e=exampleModel.findExampleByName(name);
      presenter.selectExample(e);
    }
  }
);
}
 

Example 28

From project fools-errands, under directory /modular-mvp/base/lib/src/main/java/org/example/modular_mvp/base/client/presenters/.

Source file: MainViewImpl.java

  15 
vote

/** 
 * Create a new MainViewImpl.
 */
@Inject public MainViewImpl(ExtensionManager extensionManager){
  contentPanel=new LayoutPanel();
  contentPanel.setStyleName("main-content-panel");
  LayoutPanel headerPanel=new LayoutPanel();
  headerPanel.setStyleName("header-panel");
  LayoutPanel footerPanel=new LayoutPanel();
  footerPanel.setStyleName("footer-panel");
  panel=new DockLayoutPanel(Style.Unit.PX);
  panel.addNorth(headerPanel,64);
  panel.addSouth(footerPanel,30);
  panel.addWest(createNavigator(extensionManager),200);
  panel.add(contentPanel);
  headerPanel.add(new ContentHeaderLabel("Modular MVP Example"));
}
 

Example 29

From project gadget-server, under directory /gadget-core/src/main/java/org/overlord/gadgets/server/.

Source file: Bootstrap.java

  15 
vote

@Inject public Bootstrap(@Named(DB_DRIVER) String dbDriver,@Named(DB_URL) String dbUrl,@Named(DB_USER) String dbUser,@Named(DB_PASSWORD) String dbPassword){
  this.dbDriver=dbDriver;
  this.dbUrl=dbUrl;
  this.dbUser=dbUser;
  this.dbPassword=dbPassword;
}
 

Example 30

From project gauges-android, under directory /app/src/main/java/com/github/mobile/gauges/ui/.

Source file: GaugeListLoader.java

  15 
vote

/** 
 * Creates a gauge list loader using the given  {@link Activity} and{@link GaugesServiceProvider}
 * @param activity
 * @param gauges
 * @param serviceProvider
 */
@Inject public GaugeListLoader(final Activity activity,final List<Gauge> gauges,final GaugesServiceProvider serviceProvider){
  super(activity,gauges);
  this.gauges=gauges;
  this.activity=activity;
  this.serviceProvider=serviceProvider;
}
 

Example 31

From project grouperfish, under directory /service/src/main/java/com/mozilla/grouperfish/batch/api/guice/.

Source file: BatchSystem.java

  15 
vote

@Inject public StaticTransformProvider(final Properties properties,final @Shared FileSystem dfs,final @Local FileSystem localFs){
  final ImmutableMap.Builder<String,Transform> builder=new ImmutableMap.Builder<String,Transform>();
  builder.put("count",new LocalTransform("count",dfs,localFs));
  builder.put("textcluster",new LocalTransform("textcluster",dfs,localFs));
  if (Services.hasHadoop(properties)) {
    builder.put("coclustering",new HadoopTransform("coclustering",dfs));
  }
  transformsByName=builder.build();
}
 

Example 32

From project guice-jit-providers, under directory /core/src/com/google/inject/spi/.

Source file: InjectionPoint.java

  15 
vote

InjectableMember(TypeLiteral<?> declaringType,Annotation atInject){
  this.declaringType=declaringType;
  if (atInject.annotationType() == javax.inject.Inject.class) {
    optional=false;
    jsr330=true;
    return;
  }
  jsr330=false;
  optional=((Inject)atInject).optional();
}