01: /**
02: * Copyright (C) 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: */package com.google.inject.tools.jmx;
16:
17: import com.google.inject.AbstractModule;
18: import com.google.inject.BindingAnnotation;
19: import com.google.inject.Key;
20: import com.google.inject.Singleton;
21: import com.google.inject.name.Names;
22: import java.lang.annotation.Retention;
23: import static java.lang.annotation.RetentionPolicy.RUNTIME;
24:
25: /**
26: * @author crazybob@google.com (Bob Lee)
27: */
28: public class JmxTest {
29:
30: interface Foo {
31: }
32:
33: static class FooImpl implements Foo {
34: }
35:
36: @Singleton
37: static class TransactionalFoo implements Foo {
38: }
39:
40: static class Bar {
41: }
42:
43: @BindingAnnotation
44: @Retention(RUNTIME)
45: @interface Transactional {
46: }
47:
48: public static void main(String[] args) throws Exception {
49: Manager.main(new String[] { TestModule.class.getName() });
50: }
51:
52: public static class TestModule extends AbstractModule {
53:
54: protected void configure() {
55: bind(Foo.class).to(FooImpl.class);
56: bind(Bar.class);
57: bind(Foo.class).annotatedWith(Transactional.class).to(
58: FooImpl.class);
59: bindConstant().annotatedWith(Names.named("port")).to(8080);
60: bind(Key.get(Object.class)).to(Key.get(Bar.class));
61: // install(new ServletModule());
62: }
63: }
64: }
|