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


Java PicoContainer类代码示例

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


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

示例1: instantiateExtension

import org.picocontainer.PicoContainer; //导入依赖的package包/类
@NotNull
protected Object instantiateExtension(String implementationClass, @NotNull PicoContainer picoContainer) throws ClassNotFoundException {
  if (factoryClass != null) {
    ExtensionFactory factory = instantiate(factoryClass, picoContainer);
    return factory.createInstance(factoryArgument, implementationClass);
  }
  else {
    if (implementationClass == null) {
      throw new RuntimeException("implementation class is not specified for unknown language extension point, " +
                                 "plugin id: " +
                                 (myPluginDescriptor == null ? "<not available>" : myPluginDescriptor.getPluginId()) + ". " +
                                 "Check if 'implementationClass' attribute is specified");
    }
    //noinspection unchecked
    return instantiate(implementationClass, picoContainer);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:CustomLoadingExtensionPointBean.java

示例2: testPicoContainer

import org.picocontainer.PicoContainer; //导入依赖的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

示例3: createPicoContatiner

import org.picocontainer.PicoContainer; //导入依赖的package包/类
private MutablePicoContainer createPicoContatiner() {
	final MutablePicoContainer picoContainer = new PicoBuilder()
			.withBehaviors(new OptInCaching())
			.withComponentFactory(new CompositeInjection(new AnnotatedFieldInjection(Inject.class)))
			.build();

	picoContainer.addComponent(PicoContainer.class, picoContainer);
	picoContainer.as(Characteristics.CACHE).addComponent(Pico2InjectContext.class);

	picoContainer.as(Characteristics.CACHE).addComponent(TestLazySingleton.class);
	picoContainer.as(Characteristics.CACHE).addComponent(TestEagerSingleton.class);
	picoContainer.addComponent(TestPrototype.class);

	picoContainer.addComponent("key", "value");

	return picoContainer;
}
 
开发者ID:sdif4j,项目名称:sdif4j,代码行数:18,代码来源:Pico2Test.java

示例4: ConfigurableEP

import org.picocontainer.PicoContainer; //导入依赖的package包/类
protected ConfigurableEP(PicoContainer picoContainer, @Nullable Project project) {
  myProject = project;
  myPicoContainer = picoContainer;
  myFactory = new AtomicNotNullLazyValue<NullableFactory<T>>() {
    @NotNull
    @Override
    protected NullableFactory<T> compute() {
      if (providerClass != null) {
        return new InstanceFromProviderFactory();
      }
      else if (instanceClass != null) {
        return new NewInstanceFactory();
      }
      else if (implementationClass != null) {
        return new ImplementationFactory();
      }
      throw new RuntimeException();
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:ConfigurableEP.java

示例5: instantiateExtension

import org.picocontainer.PicoContainer; //导入依赖的package包/类
protected Object instantiateExtension(final String implementationClass, final PicoContainer picoContainer) throws ClassNotFoundException {
  if (factoryClass != null) {
    ExtensionFactory factory = instantiate(factoryClass, picoContainer);
    return factory.createInstance(factoryArgument, implementationClass);
  }
  else {
    if (implementationClass == null) {
      throw new RuntimeException("implementation class is not specified for unknown language extension point, " +
                                 "plugin id: " +
                                 (myPluginDescriptor == null ? "<not available>" : myPluginDescriptor.getPluginId()) + ". " +
                                 "Check if 'implementationClass' attribute is specified");
    }
    //noinspection unchecked
    return instantiate(implementationClass, picoContainer);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:CustomLoadingExtensionPointBean.java

示例6: registerExtension

import org.picocontainer.PicoContainer; //导入依赖的package包/类
@Override
public void registerExtension(@NotNull final PluginDescriptor pluginDescriptor, @NotNull final Element extensionElement) {
  final PluginId pluginId = pluginDescriptor.getPluginId();

  String epName = extractEPName(extensionElement);

  ExtensionComponentAdapter adapter;
  final PicoContainer container = getPluginContainer(pluginId.getIdString());
  final ExtensionPointImpl extensionPoint = getExtensionPoint(epName);
  if (extensionPoint.getKind() == ExtensionPoint.Kind.INTERFACE) {
    String implClass = extensionElement.getAttributeValue("implementation");
    if (implClass == null) {
      throw new RuntimeException("'implementation' attribute not specified for '" + epName + "' extension in '" + pluginId.getIdString() + "' plugin");
    }
    adapter = new ExtensionComponentAdapter(implClass, extensionElement, container, pluginDescriptor, shouldDeserializeInstance(extensionElement));
  }
  else {
    adapter = new ExtensionComponentAdapter(extensionPoint.getClassName(), extensionElement, container, pluginDescriptor, true);
  }
  myExtensionElement2extension.put(extensionElement, adapter);
  internalGetPluginContainer().registerComponent(adapter);
  extensionPoint.registerExtensionAdapter(adapter);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:ExtensionsAreaImpl.java

示例7: MockComponentManager

import org.picocontainer.PicoContainer; //导入依赖的package包/类
public MockComponentManager(@Nullable PicoContainer parent, @NotNull Disposable parentDisposable) {
  myPicoContainer = new IdeaPicoContainer(parent) {
    private Set<Object> myDisposableComponents = new ConcurrentHashSet<Object>();

    @Override
    @Nullable
    public Object getComponentInstance(final Object componentKey) {
      final Object o = super.getComponentInstance(componentKey);
      if (o instanceof Disposable && o != MockComponentManager.this) {
        if (myDisposableComponents.add(o))
          Disposer.register(MockComponentManager.this, (Disposable)o);
      }
      return o;
    }
  };
  myPicoContainer.registerComponentInstance(this);
  Disposer.register(parentDisposable, this);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:MockComponentManager.java

示例8: ConfigurableEP

import org.picocontainer.PicoContainer; //导入依赖的package包/类
protected ConfigurableEP(PicoContainer picoContainer, @Nullable Project project) {
  myProject = project;
  myPicoContainer = picoContainer;
  myFactory = new AtomicNotNullLazyValue<NullableFactory<T>>() {
    @Nonnull
    @Override
    protected NullableFactory<T> compute() {
      if (providerClass != null) {
        return new InstanceFromProviderFactory();
      }
      else if (instanceClass != null) {
        return new NewInstanceFactory();
      }
      else if (implementationClass != null) {
        return new ImplementationFactory();
      }
      throw new RuntimeException();
    }
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:ConfigurableEP.java

示例9: MockComponentManager

import org.picocontainer.PicoContainer; //导入依赖的package包/类
public MockComponentManager(@Nullable PicoContainer parent, @Nonnull Disposable parentDisposable) {
  myPicoContainer = new DefaultPicoContainer(parent) {
    private final Set<Object> myDisposableComponents = ContainerUtil.newConcurrentSet();

    @Override
    @Nullable
    public Object getComponentInstance(final Object componentKey) {
      final Object o = super.getComponentInstance(componentKey);
      if (o instanceof Disposable && o != MockComponentManager.this) {
        if (myDisposableComponents.add(o))
          Disposer.register(MockComponentManager.this, (Disposable)o);
      }
      return o;
    }
  };
  myPicoContainer.registerComponentInstance(this);
  Disposer.register(parentDisposable, this);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:MockComponentManager.java

示例10: main

import org.picocontainer.PicoContainer; //导入依赖的package包/类
/**
 * Run the migrations for the given system name
 *
 * @param arguments the command line arguments, if any
 * @throws Exception if anything goes wrong
 */
public static void main(final String[] arguments) throws Exception
{
    AutopatchRegistry registry = new AutopatchRegistry();
    PicoContainer pico = registry.configureContainer();

    JdbcMigrationLauncherFactory launcherFactory = new JdbcMigrationLauncherFactoryLoader().createFactory();
    StandaloneMigrationLauncher migrationLauncher = pico.getComponent(StandaloneMigrationLauncher.class);
    migrationLauncher.getMigrationUtil().setLauncherFactory(launcherFactory);
    migrationLauncher.run(arguments);
    registry.destroyContainer();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:StandaloneMigrationLauncher.java

示例11: configureContainer

import org.picocontainer.PicoContainer; //导入依赖的package包/类
public PicoContainer configureContainer(){
    pico = new DefaultPicoContainer();
    pico.addComponent(StandaloneMigrationLauncher.class);
    pico.addComponent(MigrationUtil.class);
    pico.start();
    return pico;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:AutopatchRegistry.java

示例12: resolveInstance

import org.picocontainer.PicoContainer; //导入依赖的package包/类
@Override
public Object resolveInstance(PicoContainer container, ComponentAdapter adapter, Class expectedType) {
    if (clazz.isAssignableFrom(expectedType)) {
        return obj;
    }
    return super.resolveInstance(container, adapter, expectedType);
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:8,代码来源:WFSXmlUtils_ISO.java

示例13: ConfigurableEP

import org.picocontainer.PicoContainer; //导入依赖的package包/类
protected ConfigurableEP(PicoContainer picoContainer, @Nullable Project project) {
  myProject = project;
  myPicoContainer = picoContainer;
  myProducer = new AtomicNotNullLazyValue<ObjectProducer>() {
    @NotNull
    @Override
    protected ObjectProducer compute() {
      try {
        if (providerClass != null) {
          return new ProviderProducer((ConfigurableProvider)instantiate(providerClass, myPicoContainer));
        }
        if (instanceClass != null) {
          return new ClassProducer(myPicoContainer, findClass(instanceClass));
        }
        if (implementationClass != null) {
          return new ClassProducer(myPicoContainer, findClass(implementationClass));
        }
        throw new RuntimeException("configurable class name is not set");
      }
      catch (AssertionError error) {
        LOG.error(error);
      }
      catch (LinkageError error) {
        LOG.error(error);
      }
      catch (Exception exception) {
        LOG.error(exception);
      }
      return new ObjectProducer();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ConfigurableEP.java

示例14: cloneTemplates

import org.picocontainer.PicoContainer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@NotNull
private List<T> cloneTemplates(@NotNull Collection<T> templates) {
  List<T> result = new ArrayList<T>(templates.size());
  PicoContainer container = ApplicationManager.getApplication().getPicoContainer();
  for (T template : templates) {
    Class<? extends T> aClass = (Class<? extends T>)template.getClass();
    T clone = (T)new ConstructorInjectionComponentAdapter(aClass.getName(), aClass).getComponentInstance(container);
    result.add(clone);
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ThreadLocalAnnotatorMap.java

示例15: ExtensionsAreaImpl

import org.picocontainer.PicoContainer; //导入依赖的package包/类
public ExtensionsAreaImpl(String areaClass, AreaInstance areaInstance, PicoContainer parentPicoContainer, @NotNull LogProvider logger) {
  myCreationTrace = DEBUG_REGISTRATION ? new Throwable("Area creation trace") : null;
  myAreaClass = areaClass;
  myAreaInstance = areaInstance;
  myPicoContainer = new DefaultPicoContainer(parentPicoContainer);
  myLogger = logger;
  initialize();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ExtensionsAreaImpl.java


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