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


Java DefaultPicoContainer类代码示例

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


DefaultPicoContainer类属于org.picocontainer.defaults包,在下文中一共展示了DefaultPicoContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testExtensionsNamespaces

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
@Test
public void testExtensionsNamespaces() {
  ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(new DefaultPicoContainer(), new Extensions.SimpleLogProvider());
  extensionsArea.registerExtensionPoint("plugin.ep1", TestExtensionClassOne.class.getName(), ExtensionPoint.Kind.BEAN_CLASS);
  extensionsArea.registerExtension("plugin", ExtensionComponentAdapterTest.readElement(
      "<plugin:ep1 xmlns:plugin=\"plugin\" order=\"LAST\"><text>3</text></plugin:ep1>"));
  extensionsArea.registerExtension("plugin", ExtensionComponentAdapterTest.readElement(
      "<ep1 xmlns=\"plugin\" order=\"FIRST\"><text>1</text></ep1>"));
  extensionsArea.registerExtension("plugin", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"plugin.ep1\"><text>2</text></extension>"));
  ExtensionPoint extensionPoint = extensionsArea.getExtensionPoint("plugin.ep1");
  TestExtensionClassOne[] extensions = (TestExtensionClassOne[]) extensionPoint.getExtensions();
  assertEquals(3, extensions.length);
  assertEquals("1", extensions[0].getText());
  assertEquals("2", extensions[1].getText());
  assertEquals("3", extensions[2].getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ExtensionsImplTest.java

示例3: testExtensionsWithOrdering

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
@Test
public void testExtensionsWithOrdering() {
  ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(new DefaultPicoContainer(), new Extensions.SimpleLogProvider());
  extensionsArea.registerExtensionPoint("ep1", TestExtensionClassOne.class.getName(), ExtensionPoint.Kind.BEAN_CLASS);
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" order=\"LAST\"><text>3</text></extension>"));
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" order=\"FIRST\"><text>1</text></extension>"));
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\"><text>2</text></extension>"));
  ExtensionPoint extensionPoint = extensionsArea.getExtensionPoint("ep1");
  TestExtensionClassOne[] extensions = (TestExtensionClassOne[]) extensionPoint.getExtensions();
  assertEquals(3, extensions.length);
  assertEquals("1", extensions[0].getText());
  assertEquals("2", extensions[1].getText());
  assertEquals("3", extensions[2].getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ExtensionsImplTest.java

示例4: testPicoContainer

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
public void testPicoContainer() {
// cut:start-1
    DefaultPicoContainer dc = new DefaultPicoContainer();
    try {
      // Register BaseRenderEngine as an Implementation
      // of RenderEngine
      dc.registerComponentImplementation(
          RenderEngine.class,
          BaseRenderEngine.class);
    } catch (Exception e) {
      log.error("Could not register component.");
    }

    // now only work with container
    PicoContainer container = dc;

    // Only ask for RenderEngine, we automatically
    // get an available object
    // that implements RenderEngine
    RenderEngine engine = (RenderEngine)
      container.getComponentInstance(RenderEngine.class);
    RenderContext context = new BaseRenderContext();
    String result = engine.render("__SnipSnap__", context);
// cut:end-1
    assertEquals("Rendered with PicoContainer.", "<b class=\"bold\">SnipSnap</b>", result);
  }
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:27,代码来源:PicoContainerExample.java

示例5: MonitoringPlugin

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
public MonitoringPlugin() {

        // Enable AWT headless mode so that stats will work in headless environments.
        System.setProperty("java.awt.headless", "true");

        picoContainer = new DefaultPicoContainer();
        picoContainer.registerComponentInstance(TaskEngine.getInstance());
        picoContainer.registerComponentInstance(JiveProperties.getInstance());

        // Stats and Graphing classes
        picoContainer.registerComponentImplementation(StatsEngine.class);
        picoContainer.registerComponentImplementation(GraphEngine.class);
        picoContainer.registerComponentImplementation(StatisticsModule.class);
        picoContainer.registerComponentImplementation(StatsViewer.class,
            getStatsViewerImplementation());

        // Archive classes
        picoContainer.registerComponentImplementation(ConversationManager.class);
        picoContainer.registerComponentImplementation(ArchiveInterceptor.class);
        picoContainer.registerComponentImplementation(GroupConversationInterceptor.class);
        picoContainer.registerComponentImplementation(ArchiveSearcher.class);
        picoContainer.registerComponentImplementation(ArchiveIndexer.class);
    }
 
开发者ID:coodeer,项目名称:g3server,代码行数:24,代码来源:MonitoringPlugin.java

示例6: 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

示例7: testExtensionsNamespaces

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
public void testExtensionsNamespaces() {
  ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(new DefaultPicoContainer(), new Extensions.SimpleLogProvider());
  extensionsArea.registerExtensionPoint("plugin.ep1", TestExtensionClassOne.class.getName(), ExtensionPoint.Kind.BEAN_CLASS);
  extensionsArea.registerExtension("plugin", ExtensionComponentAdapterTest.readElement(
      "<plugin:ep1 xmlns:plugin=\"plugin\" order=\"LAST\"><text>3</text></plugin:ep1>"));
  extensionsArea.registerExtension("plugin", ExtensionComponentAdapterTest.readElement(
      "<ep1 xmlns=\"plugin\" order=\"FIRST\"><text>1</text></ep1>"));
  extensionsArea.registerExtension("plugin", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"plugin.ep1\"><text>2</text></extension>"));
  ExtensionPoint extensionPoint = extensionsArea.getExtensionPoint("plugin.ep1");
  TestExtensionClassOne[] extensions = (TestExtensionClassOne[]) extensionPoint.getExtensions();
  assertEquals(3, extensions.length);
  assertEquals("1", extensions[0].getText());
  assertEquals("2", extensions[1].getText());
  assertEquals("3", extensions[2].getText());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:ExtensionsImplTest.java

示例8: testExtensionsWithOrdering

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
public void testExtensionsWithOrdering() {
  ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(new DefaultPicoContainer(), new Extensions.SimpleLogProvider());
  extensionsArea.registerExtensionPoint("ep1", TestExtensionClassOne.class.getName(), ExtensionPoint.Kind.BEAN_CLASS);
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" order=\"LAST\"><text>3</text></extension>"));
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" order=\"FIRST\"><text>1</text></extension>"));
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\"><text>2</text></extension>"));
  ExtensionPoint extensionPoint = extensionsArea.getExtensionPoint("ep1");
  TestExtensionClassOne[] extensions = (TestExtensionClassOne[]) extensionPoint.getExtensions();
  assertEquals(3, extensions.length);
  assertEquals("1", extensions[0].getText());
  assertEquals("2", extensions[1].getText());
  assertEquals("3", extensions[2].getText());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:ExtensionsImplTest.java

示例9: testUnknownAttributes

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
@Test
public void testUnknownAttributes() {
  String name = TestExtensionClassOne.class.getName();
  Element element = readElement("<bean implementation=\"123\"/>");
  DefaultPicoContainer container = new DefaultPicoContainer();
  DefaultPluginDescriptor descriptor = new DefaultPluginDescriptor("test");
  new ExtensionComponentAdapter(name, element, container, descriptor, false).getComponentInstance(container);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ExtensionComponentAdapterTest.java

示例10: testGetComponentAdapterDoesntDuplicateAdapters

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
@Test
public void testGetComponentAdapterDoesntDuplicateAdapters() throws Exception {
  MutablePicoContainer picoContainer =
    new ExtensionsAreaImpl("foo", null, new DefaultPicoContainer(), new Extensions.SimpleLogProvider()).getPicoContainer();
  picoContainer.registerComponentImplementation("runnable", ExtensionsAreaTest.class);

  List adapters = picoContainer.getComponentAdaptersOfType(ExtensionsAreaTest.class);
  assertEquals(1, adapters.size());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ExtensionsAreaTest.java

示例11: 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

示例12: testExtensionsWithOrderingUpdate

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
@Test
public void testExtensionsWithOrderingUpdate() {
  ExtensionsAreaImpl extensionsArea = new ExtensionsAreaImpl(new DefaultPicoContainer(), new Extensions.SimpleLogProvider());
  extensionsArea.registerExtensionPoint("ep1", TestExtensionClassOne.class.getName(), ExtensionPoint.Kind.BEAN_CLASS);
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" id=\"_7\" order=\"LAST\"><text>7</text></extension>"));
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" id=\"fst\" order=\"FIRST\"><text>1</text></extension>"));
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" id=\"id\"><text>3</text></extension>"));
  ExtensionPoint<TestExtensionClassOne> extensionPoint = extensionsArea.getExtensionPoint("ep1");
  TestExtensionClassOne[] extensions = extensionPoint.getExtensions();
  assertEquals(3, extensions.length);
  assertEquals("1", extensions[0].getText());
  assertEquals("3", extensions[1].getText());
  assertEquals("7", extensions[2].getText());
  TestExtensionClassOne extension = new TestExtensionClassOne("xxx");
  extensionPoint.registerExtension(extension);
  extensionPoint.unregisterExtension(extension);
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" order=\"BEFORE id\"><text>2</text></extension>"));
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" order=\"AFTER id\"><text>4</text></extension>"));
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" order=\"last, after _7\"><text>8</text></extension>"));
  extensionsArea.registerExtension("", ExtensionComponentAdapterTest.readElement(
      "<extension point=\"ep1\" order=\"after:id, before _7, after fst\"><text>5</text></extension>"));
  extensionPoint.registerExtension(new TestExtensionClassOne("6"));
  extensions = extensionPoint.getExtensions();
  assertEquals(8, extensions.length);
  assertEquals("1", extensions[0].getText());
  assertEquals("2", extensions[1].getText());
  assertEquals("3", extensions[2].getText());
  assertTrue("4".equals(extensions[3].getText()) || "5".equals(extensions[3].getText()) );
  assertTrue("4".equals(extensions[4].getText()) || "5".equals(extensions[4].getText()) );
  assertEquals("6", extensions[5].getText());
  assertEquals("7", extensions[6].getText());
  assertEquals("8", extensions[7].getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:ExtensionsImplTest.java

示例13: testPicoWithInitialRenderContext

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
public void testPicoWithInitialRenderContext() {
// cut:start-2
    DefaultPicoContainer dc = new DefaultPicoContainer();
    try {
      InitialRenderContext initialContext =
          new BaseInitialRenderContext();
      initialContext.set(RenderContext.OUTPUT_LOCALE,
                         new Locale("mywiki", "mywiki"));
      dc.registerComponentInstance(InitialRenderContext.class,
                                   initialContext);
      dc.registerComponentImplementation(RenderEngine.class,
                                         BaseRenderEngine.class);
    } catch (Exception e) {
      log.error("Could not register component.");
    }
// cut:end-2
    // now only work with container
    PicoContainer container = dc;

    // Only ask for RenderEngine, we automatically
    // get an available object
    // that implements RenderEngine
    RenderEngine engine = (RenderEngine)
      container.getComponentInstance(RenderEngine.class);

    assertNotNull("Component found.", engine);
    RenderContext context = new BaseRenderContext();
    String result = engine.render("__SnipSnap__", context);
    assertEquals("Rendered with PicoContainer and otherwiki Locale.",
                 "<b class=\"mybold\">SnipSnap</b>", result);

  }
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:33,代码来源:PicoContainerExample.java

示例14: MonitoringPlugin

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
public MonitoringPlugin() {
    instance = this;

    // Enable AWT headless mode so that stats will work in headless
    // environments.
    System.setProperty("java.awt.headless", "true");

    picoContainer = new DefaultPicoContainer();
    picoContainer.registerComponentInstance(TaskEngine.getInstance());
    picoContainer.registerComponentInstance(JiveProperties.getInstance());

    // Stats and Graphing classes
    picoContainer.registerComponentImplementation(StatsEngine.class);
    picoContainer.registerComponentImplementation(GraphEngine.class);
    picoContainer.registerComponentImplementation(StatisticsModule.class);
    picoContainer.registerComponentImplementation(StatsViewer.class,
            getStatsViewerImplementation());

    // Archive classes
    picoContainer
            .registerComponentImplementation(ConversationManager.class);
    picoContainer.registerComponentImplementation(ArchiveInterceptor.class);
    picoContainer
            .registerComponentImplementation(GroupConversationInterceptor.class);
    picoContainer.registerComponentImplementation(ArchiveSearcher.class);
    picoContainer.registerComponentImplementation(ArchiveIndexer.class);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:28,代码来源:MonitoringPlugin.java

示例15: setUp

import org.picocontainer.defaults.DefaultPicoContainer; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();

  myExtensionsArea = new ExtensionsAreaImpl("foo", null, new DefaultPicoContainer(), new Extensions.SimpleLogProvider());
  myPicoContainer = myExtensionsArea.getPicoContainer();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:ExtensionsAreaTest.java


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