• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 Google Inc.
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 
17 package com.google.inject.tools.jmx;
18 
19 import static java.lang.annotation.RetentionPolicy.RUNTIME;
20 
21 import com.google.inject.AbstractModule;
22 import com.google.inject.BindingAnnotation;
23 import com.google.inject.Key;
24 import com.google.inject.Singleton;
25 import com.google.inject.name.Names;
26 import java.lang.annotation.Retention;
27 
28 /** @author crazybob@google.com (Bob Lee) */
29 public class JmxTest {
30 
31   interface Foo {}
32 
33   static class FooImpl implements Foo {}
34 
35   @Singleton
36   static class TransactionalFoo implements Foo {}
37 
38   static class Bar {}
39 
40   @BindingAnnotation
41   @Retention(RUNTIME)
42   @interface Transactional {}
43 
main(String[] args)44   public static void main(String[] args) throws Exception {
45     Manager.main(new String[] {TestModule.class.getName()});
46   }
47 
48   public static class TestModule extends AbstractModule {
49 
50     @Override
configure()51     protected void configure() {
52       bind(Foo.class).to(FooImpl.class);
53       bind(Bar.class);
54       bind(Foo.class).annotatedWith(Transactional.class).to(FooImpl.class);
55       bindConstant().annotatedWith(Names.named("port")).to(8080);
56       bind(Key.get(Object.class)).to(Key.get(Bar.class));
57       //      install(new ServletModule());
58     }
59   }
60 }
61