当前位置: 首页>>代码示例>>Java>>正文


Java DefaultPicoContainer.getComponentInstance方法代码示例

本文整理汇总了Java中org.picocontainer.defaults.DefaultPicoContainer.getComponentInstance方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultPicoContainer.getComponentInstance方法的具体用法?Java DefaultPicoContainer.getComponentInstance怎么用?Java DefaultPicoContainer.getComponentInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.picocontainer.defaults.DefaultPicoContainer的用法示例。


在下文中一共展示了DefaultPicoContainer.getComponentInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTryPicoContainer2

import org.picocontainer.defaults.DefaultPicoContainer; //导入方法依赖的package包/类
@Test
public void testTryPicoContainer2() {
  DefaultPicoContainer rootContainer = new DefaultPicoContainer();
  rootContainer.registerComponentImplementation("component1", MyComponent1.class);
  rootContainer.registerComponentImplementation("component1.1", MyComponent1.class);
  rootContainer.registerComponentImplementation("component2", MyComponent2.class);
  rootContainer.registerComponentImplementation(MyTestComponent.class);
  MyInterface1 testInstance = new MyInterface1() {
        @Override
        public void run() {
        }
      };
  rootContainer.registerComponentInstance(testInstance);
  MyTestComponent testComponent = (MyTestComponent)rootContainer.getComponentInstance(MyTestComponent.class);
  MyComponent2 component2 = (MyComponent2)rootContainer.getComponentInstance("component2");
  MyComponent1 component11 = (MyComponent1)rootContainer.getComponentInstance("component1.1");
  MyComponent1 component1 = (MyComponent1)rootContainer.getComponentInstance("component1");
  assertEquals(testInstance, component1.testObject);
  assertEquals(testInstance, component2.testObject);
  assertTrue(Arrays.asList(component2.comp1).contains(component1));
  assertTrue(Arrays.asList(component2.comp1).contains(component11));
  assertTrue(Arrays.asList(testComponent.comp1).contains(component1));
  assertTrue(Arrays.asList(testComponent.comp1).contains(component11));
  assertEquals(component2, testComponent.comp2);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ExtensionsImplTest.java

示例2: testTryPicoContainer2

import org.picocontainer.defaults.DefaultPicoContainer; //导入方法依赖的package包/类
public void testTryPicoContainer2() {
  DefaultPicoContainer rootContainer = new DefaultPicoContainer();
  rootContainer.registerComponentImplementation("component1", MyComponent1.class);
  rootContainer.registerComponentImplementation("component1.1", MyComponent1.class);
  rootContainer.registerComponentImplementation("component2", MyComponent2.class);
  rootContainer.registerComponentImplementation(MyTestComponent.class);
  MyInterface1 testInstance = new MyInterface1() {
        @Override
        public void run() {
        }
      };
  rootContainer.registerComponentInstance(testInstance);
  MyTestComponent testComponent = (MyTestComponent)rootContainer.getComponentInstance(MyTestComponent.class);
  MyComponent2 component2 = (MyComponent2)rootContainer.getComponentInstance("component2");
  MyComponent1 component11 = (MyComponent1)rootContainer.getComponentInstance("component1.1");
  MyComponent1 component1 = (MyComponent1)rootContainer.getComponentInstance("component1");
  assertEquals(testInstance, component1.testObject);
  assertEquals(testInstance, component2.testObject);
  assertTrue(Arrays.asList(component2.comp1).contains(component1));
  assertTrue(Arrays.asList(component2.comp1).contains(component11));
  assertTrue(Arrays.asList(testComponent.comp1).contains(component1));
  assertTrue(Arrays.asList(testComponent.comp1).contains(component11));
  assertEquals(component2, testComponent.comp2);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:ExtensionsImplTest.java

示例3: testTryPicoContainer

import org.picocontainer.defaults.DefaultPicoContainer; //导入方法依赖的package包/类
@Test
public void testTryPicoContainer() {
  DefaultPicoContainer rootContainer = new DefaultPicoContainer();
  rootContainer.registerComponentInstance("plugin1", new DefaultPicoContainer(rootContainer));
  rootContainer.registerComponentInstance("plugin2", new DefaultPicoContainer(rootContainer));
  MutablePicoContainer container1 = (MutablePicoContainer)rootContainer.getComponentInstance("plugin1");
  MutablePicoContainer container2 = (MutablePicoContainer)rootContainer.getComponentInstance("plugin2");
  container1.registerComponentImplementation("component1", MyComponent1.class);
  container1.registerComponentImplementation("component1.1", MyComponent1.class);
  container2.registerComponentImplementation("component2", MyComponent2.class);
  MyInterface1 testInstance = new MyInterface1() {
    @Override
    public void run() { }
  };
  rootContainer.registerComponentInstance(testInstance);
  MyComponent1 component1 = (MyComponent1)container1.getComponentInstance("component1");
  assertEquals(testInstance, component1.testObject);
  rootContainer.registerComponentInstance("component1", component1);
  MyComponent1 component11 = (MyComponent1)container1.getComponentInstance("component1.1");
  rootContainer.registerComponentInstance("component11", component11);
  MyComponent2 component2 = (MyComponent2)container2.getComponentInstance("component2");
  assertEquals(testInstance, component2.testObject);
  assertTrue(Arrays.asList(component2.comp1).contains(component1));
  assertTrue(Arrays.asList(component2.comp1).contains(component11));
  rootContainer.registerComponentInstance("component2", component2);
  rootContainer.registerComponentImplementation(MyTestComponent.class);
  MyTestComponent testComponent = (MyTestComponent)rootContainer.getComponentInstance(MyTestComponent.class);
  assertTrue(Arrays.asList(testComponent.comp1).contains(component1));
  assertTrue(Arrays.asList(testComponent.comp1).contains(component11));
  assertEquals(component2, testComponent.comp2);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:ExtensionsImplTest.java

示例4: testTryPicoContainer

import org.picocontainer.defaults.DefaultPicoContainer; //导入方法依赖的package包/类
public void testTryPicoContainer() {
    DefaultPicoContainer rootContainer = new DefaultPicoContainer();
    rootContainer.registerComponentInstance("plugin1", new DefaultPicoContainer(rootContainer));
    rootContainer.registerComponentInstance("plugin2", new DefaultPicoContainer(rootContainer));
//    rootContainer.registerComponentImplementation("plugin2", DefaultPicoContainer.class);
    MutablePicoContainer container1 = (MutablePicoContainer)rootContainer.getComponentInstance("plugin1");
    MutablePicoContainer container2 = (MutablePicoContainer)rootContainer.getComponentInstance("plugin2");
    container1.registerComponentImplementation("component1", MyComponent1.class);
    container1.registerComponentImplementation("component1.1", MyComponent1.class);
    container2.registerComponentImplementation("component2", MyComponent2.class);
    MyInterface1 testInstance = new MyInterface1() {
          @Override
          public void run() {
          }
        };
    rootContainer.registerComponentInstance(testInstance);
    MyComponent1 component1 = (MyComponent1)container1.getComponentInstance("component1");
    assertEquals(testInstance, component1.testObject);
    rootContainer.registerComponentInstance("component1", component1);
    MyComponent1 component11 = (MyComponent1)container1.getComponentInstance("component1.1");
    rootContainer.registerComponentInstance("component11", component11);
    MyComponent2 component2 = (MyComponent2)container2.getComponentInstance("component2");
    assertEquals(testInstance, component2.testObject);
    assertTrue(Arrays.asList(component2.comp1).contains(component1));
    assertTrue(Arrays.asList(component2.comp1).contains(component11));
    rootContainer.registerComponentInstance("component2", component2);
    rootContainer.registerComponentImplementation(MyTestComponent.class);
    MyTestComponent testComponent = (MyTestComponent)rootContainer.getComponentInstance(MyTestComponent.class);
    assertTrue(Arrays.asList(testComponent.comp1).contains(component1));
    assertTrue(Arrays.asList(testComponent.comp1).contains(component11));
    assertEquals(component2, testComponent.comp2);
  }
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:ExtensionsImplTest.java


注:本文中的org.picocontainer.defaults.DefaultPicoContainer.getComponentInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。