org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#org.pf4j.PluginManager源码实例Demo

下面列出了org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#org.pf4j.PluginManager 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dremio-oss   文件: HiveStoragePlugin.java
public HiveStoragePlugin(HiveConf hiveConf, PluginManager pf4jManager, SabotContext context, String name) {
  super(context, name);
  this.isCoordinator = context.isCoordinator();
  this.hiveConf = hiveConf;
  this.pf4jManager = pf4jManager;
  this.sabotConfig = context.getConfig();
  this.hiveSettings = new HiveSettings(context.getOptionManager());
  this.optionManager = context.getOptionManager();
  this.dremioConfig = context.getDremioConfig();

  storageImpersonationEnabled = hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS);

  // Hive Metastore impersonation is enabled if:
  // - "hive.security.authorization.enabled" is set to true,
  // - "hive.metastore.execute.setugi" is set to true (in SASL disabled scenarios) or
  // - "hive.metastore.sasl.enabled" is set to true in which case all metastore calls are impersonated as
  //     the authenticated user.
  this.metastoreImpersonationEnabled =
    hiveConf.getBoolVar(ConfVars.HIVE_AUTHORIZATION_ENABLED) ||
      hiveConf.getBoolVar(ConfVars.METASTORE_EXECUTE_SET_UGI) ||
      hiveConf.getBoolVar(ConfVars.METASTORE_USE_THRIFT_SASL);
}
 
源代码2 项目: buck   文件: TestKnownRuleTypesFactory.java
public static KnownNativeRuleTypes create(
    BuckConfig config, ToolchainProvider toolchainProvider, ProcessExecutor processExecutor) {
  PluginManager pluginManager = BuckPluginManagerFactory.createPluginManager();

  SandboxExecutionStrategyFactory sandboxExecutionStrategyFactory =
      new TestSandboxExecutionStrategyFactory();
  return KnownNativeRuleTypes.of(
      KnownBuildRuleDescriptionsFactory.createBuildDescriptions(
          config,
          processExecutor,
          toolchainProvider,
          pluginManager,
          sandboxExecutionStrategyFactory),
      ImmutableList.of(),
      KnownBuildRuleDescriptionsFactory.createBuiltInProviders(pluginManager));
}
 
源代码3 项目: dremio-oss   文件: Hive3StoragePlugin.java
public Hive3StoragePlugin(HiveConf hiveConf, PluginManager pf4jManager, SabotContext context, String name) {
  super(context, name);
  this.isCoordinator = context.isCoordinator();
  this.hiveConf = hiveConf;
  this.pf4jManager = pf4jManager;
  this.sabotConfig = context.getConfig();
  this.hiveSettings = new HiveSettings(context.getOptionManager());
  this.optionManager = context.getOptionManager();
  this.dremioConfig = context.getDremioConfig();

  storageImpersonationEnabled = hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS);

  // Hive Metastore impersonation is enabled if:
  // - "hive.security.authorization.enabled" is set to true,
  // - "hive.metastore.execute.setugi" is set to true (in SASL disabled scenarios) or
  // - "hive.metastore.sasl.enabled" is set to true in which case all metastore calls are impersonated as
  //     the authenticated user.
  this.metastoreImpersonationEnabled =
    hiveConf.getBoolVar(ConfVars.HIVE_AUTHORIZATION_ENABLED) ||
      hiveConf.getBoolVar(ConfVars.METASTORE_EXECUTE_SET_UGI) ||
      hiveConf.getBoolVar(ConfVars.METASTORE_USE_THRIFT_SASL);
}
 
源代码4 项目: pf4j-spring   文件: Boot.java
public static void main(String[] args) {
    // print logo
    printLogo();

    // retrieves the spring application context
    ApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfiguration.class);

    // retrieves automatically the extensions for the Greeting.class extension point
    Greetings greetings = applicationContext.getBean(Greetings.class);
    greetings.printGreetings();

    // stop plugins
    PluginManager pluginManager = applicationContext.getBean(PluginManager.class);
    /*
    // retrieves manually the extensions for the Greeting.class extension point
    List<Greeting> greetings = pluginManager.getExtensions(Greeting.class);
    System.out.println("greetings.size() = " + greetings.size());
    */
    pluginManager.stopPlugins();
}
 
源代码5 项目: buck   文件: AdditionalOptionsCmdLineParser.java
/**
 * Creates a new command line owner that parses arguments/options and set them into the given
 * object.
 *
 * @param bean instance of a class annotated by {@link Option}, {@link Argument} and {@link
 *     AdditionalOptions}. This object will receive values. If this is null, the processing will
 *     be skipped, which is useful if you'd like to feed metadata from other sources.
 * @throws IllegalAnnotationError if the option bean class is using args4j annotations
 *     incorrectly.
 * @see CmdLineParser#CmdLineParser(Object)
 */
public AdditionalOptionsCmdLineParser(PluginManager pluginManager, Object bean) {
  /**
   * Disable '@' syntax. We convert this ourselves in {@link BuckArgsMethods#expandAtFiles}, so
   * options passed to parseArgument() should already be properly expanded. This allows us to have
   * things like `buck run @file //:script -- @this_goes_to_the_script`, as @file is expanded
   * before hitting this method.
   */
  super(null, ParserProperties.defaults().withAtSyntax(false));
  this.pluginManager = pluginManager;

  // This is copied in simplified form from CmdLineParser constructor and put here to save the
  // reference to the plugin manager before doing the parsing of options.
  new ClassParser().parse(bean, this);
  getOptions().sort(DEFAULT_COMPARATOR);

  Set<Class<?>> visited = new HashSet<>();
  parseAnnotations(new ClassParser(), bean, visited);
}
 
源代码6 项目: buck   文件: NonModuleClassTest.java
private static void testBuckModuleHashProvider() {
  PluginManager pluginManager = BuckPluginManagerFactory.createPluginManager();
  BuckModuleJarHashProvider hashProvider = new BuckModuleJarHashProvider();
  BuckModuleManager moduleManager = new DefaultBuckModuleManager(pluginManager, hashProvider);

  try {
    moduleManager.getModuleHash(NonModuleClassTest.class);
    fail("Should throw IllegalStateException");
  } catch (IllegalStateException e) {
    assertEquals(
        "Requested module hash for class "
            + "com.facebook.buck.core.module.impl.nonmoduleclass.NonModuleClassTest but "
            + "its class loader is not PluginClassCloader",
        e.getMessage());
  }

  assertFalse(moduleManager.isClassInModule(NonModuleClassTest.class));
}
 
源代码7 项目: buck   文件: KnownBuildRuleDescriptionsFactory.java
static ImmutableList<Description<?>> createBuildDescriptions(
    BuckConfig config,
    ProcessExecutor processExecutor,
    ToolchainProvider toolchainProvider,
    PluginManager pluginManager,
    SandboxExecutionStrategyFactory sandboxExecutionStrategyFactory) {

  ImmutableList.Builder<Description<?>> builder = ImmutableList.builder();

  SandboxExecutionStrategy sandboxExecutionStrategy =
      sandboxExecutionStrategyFactory.create(processExecutor, config);

  DescriptionCreationContext descriptionCreationContext =
      DescriptionCreationContext.of(
          config, toolchainProvider, sandboxExecutionStrategy, pluginManager);
  List<DescriptionProvider> descriptionProviders =
      pluginManager.getExtensions(DescriptionProvider.class);
  for (DescriptionProvider provider : descriptionProviders) {
    builder.addAll(provider.getDescriptions(descriptionCreationContext));
  }

  return builder.build();
}
 
源代码8 项目: buck   文件: SkylarkPackageFileParserTest.java
@Before
public void setUp() {
  projectFilesystem = FakeProjectFilesystem.createRealTempFilesystem();
  skylarkFilesystem = SkylarkFilesystem.using(projectFilesystem);
  cell = new TestCellBuilder().setFilesystem(projectFilesystem).build();
  PluginManager pluginManager = BuckPluginManagerFactory.createPluginManager();
  knownRuleTypesProvider = TestKnownRuleTypesProvider.create(pluginManager);

  eventCollector = new EventCollector(EnumSet.allOf(EventKind.class));

  ProjectBuildFileParserOptions options =
      ProjectBuildFileParserOptions.builder()
          .setProjectRoot(cell.getRootCell().getRoot())
          .setAllowEmptyGlobs(false)
          .setIgnorePaths(ImmutableSet.of())
          .setBuildFileName("PACKAGE")
          .setRawConfig(
              ImmutableMap.of("dummy_section", ImmutableMap.of("dummy_key", "dummy_value")))
          .setDescriptions(ImmutableSet.of())
          .setPerFeatureProviders(ImmutableList.of())
          .setBuildFileImportWhitelist(ImmutableList.of())
          .setPythonInterpreter("skylark")
          .build();

  parser =
      SkylarkPackageFileParser.using(
          options,
          BuckEventBusForTests.newInstance(),
          skylarkFilesystem,
          BuckGlobals.of(
              SkylarkPackageModule.PACKAGE_MODULE,
              options.getDescriptions(),
              options.getUserDefinedRulesState(),
              options.getImplicitNativeRulesState(),
              new RuleFunctionFactory(new DefaultTypeCoercerFactory()),
              LabelCache.newLabelCache(),
              knownRuleTypesProvider.getUserDefinedRuleTypes(cell.getRootCell()),
              options.getPerFeatureProviders()),
          eventCollector);
}
 
源代码9 项目: buck   文件: ModuleClassTest.java
private static void testBuckModuleHashProvider(TestExtension testExtension) {
  PluginManager pluginManager = BuckPluginManagerFactory.createPluginManager();
  BuckModuleJarHashProvider hashProvider = new BuckModuleJarHashProvider();
  BuckModuleManager moduleManager = new DefaultBuckModuleManager(pluginManager, hashProvider);
  Hasher hasher = Hashing.murmur3_128().newHasher();
  hasher.putUnencodedChars("some content that never changes");
  assertEquals(hasher.hash().toString(), moduleManager.getModuleHash(testExtension.getClass()));

  assertTrue(moduleManager.isClassInModule(testExtension.getClass()));
  assertFalse(moduleManager.isClassInModule(ModuleClassTest.class));
}
 
源代码10 项目: pf4j-spring-tutorial   文件: PluginConfig.java
private RouterFunction<?> getReactiveRoutes(PluginManager pm) {
    RouterFunction<?> base = baseRoot(pm);
    RouterFunction<?> routes = pm.getExtensions(PluginInterface.class).stream()
            .flatMap(g -> g.reactiveRoutes().stream())
            .map(r-> (RouterFunction<ServerResponse>)r)
            .reduce((o,r )-> (RouterFunction<ServerResponse>) o.andOther(r))
            .orElse(null);
    return routes == null ? base : base.andOther(routes);
}
 
源代码11 项目: buck   文件: CommandRunnerParamsForTesting.java
public CommandRunnerParams build() {
  TestCellBuilder cellBuilder = new TestCellBuilder();
  if (toolchainProvider != null) {
    cellBuilder.setToolchainProvider(toolchainProvider);
  }
  Cells cell = cellBuilder.build();
  PluginManager pluginManager = BuckPluginManagerFactory.createPluginManager();
  KnownRuleTypesProvider knownRuleTypesProvider =
      TestKnownRuleTypesProvider.create(pluginManager);
  Parser parser =
      TestParserFactory.create(executor, cell.getRootCell(), knownRuleTypesProvider);

  return createCommandRunnerParamsForTesting(
      executor,
      console,
      cell,
      artifactCache,
      eventBus,
      config,
      platform,
      environment,
      javaPackageFinder,
      webServer,
      pluginManager,
      knownRuleTypesProvider,
      parser);
}
 
源代码12 项目: pf4j-spring-tutorial   文件: PluginConfig.java
private String pluginNamesMono(PluginManager pm) {
    List<String> identityList = pm.getExtensions(PluginInterface.class).stream()
            .map(g-> g.getClass().getName() + ": " + g.identify())
            .collect(Collectors.toList());
    try {
        return objectMapper.writeValueAsString(identityList);
    } catch (JsonProcessingException e) {
        return "[]";
    }
}
 
源代码13 项目: pf4j-spring-tutorial   文件: PluginConfig.java
private void registerMvcEndpoints(PluginManager pm) {
    pm.getExtensions(PluginInterface.class).stream()
            .flatMap(g -> g.mvcControllers().stream())
            .forEach(r -> ((ConfigurableBeanFactory) beanFactory)
                    .registerSingleton(r.getClass().getName(), r));
    applicationContext
            .getBeansOfType(RequestMappingHandlerMapping.class)
            .forEach((k, v) -> v.afterPropertiesSet());
}
 
源代码14 项目: buck   文件: ModuleClassTest.java
private static PluginWrapper getPluginWrapperForClass(PluginManager pluginManager, Class<?> cls)
    throws Exception {
  Field pluginDescriptorField = PluginClassLoader.class.getDeclaredField("pluginDescriptor");
  pluginDescriptorField.setAccessible(true);
  PluginDescriptor pluginDescriptor =
      (PluginDescriptor) pluginDescriptorField.get(cls.getClassLoader());

  return pluginManager.getPlugin(pluginDescriptor.getPluginId());
}
 
源代码15 项目: liiklus   文件: GRPCAuthTest.java
@SneakyThrows
static int getGRPCPort(ApplicationContext ctx) {
    var pluginManager = ctx.getBean(PluginManager.class);

    var classLoader = pluginManager.getPluginClassLoader("grpc-transport");
    var serverClazz = classLoader.loadClass(Server.class.getName());
    var getPortMethod = serverClazz.getDeclaredMethod("getPort");
    var server = ctx.getBean(serverClazz);

    return (int) getPortMethod.invoke(server);
}
 
源代码16 项目: buck   文件: ModuleWithDependenciesTest.java
private static void testBuckModuleHashProvider(List<TestExtension> testExtensions) {
  PluginManager pluginManager = BuckPluginManagerFactory.createPluginManager();
  BuckModuleJarHashProvider hashProvider = new BuckModuleJarHashProvider();
  BuckModuleManager moduleManager = new DefaultBuckModuleManager(pluginManager, hashProvider);

  TestExtension testExtension1 = testExtensions.get(0);
  TestExtension testExtension2 = testExtensions.get(1);

  String hash1 = moduleManager.getModuleHash(testExtension1.getClass());
  String hash2 = moduleManager.getModuleHash(testExtension2.getClass());

  assertNotEquals(hash1, hash2);

  TestExtension extensionFromDependentModule;
  TestExtension extensionFromIndependentModule;

  if (testExtension1 instanceof Serializable) {
    extensionFromDependentModule = testExtension2;
    extensionFromIndependentModule = testExtension1;
  } else {
    extensionFromDependentModule = testExtension1;
    extensionFromIndependentModule = testExtension2;
  }

  assertEquals(
      hash(HASH), moduleManager.getModuleHash(extensionFromIndependentModule.getClass()));
  assertEquals(
      hash(hash(HASH), HASH),
      moduleManager.getModuleHash(extensionFromDependentModule.getClass()));
}
 
源代码17 项目: exonum-java-binding   文件: RuntimeModule.java
@Override
protected void configure() {
  bind(ServiceRuntime.class).in(Singleton.class);
  expose(ServiceRuntime.class);

  bind(ClassLoadingScopeChecker.class);
  bind(new TypeLiteral<Map<String, Class<?>>>() {})
      .annotatedWith(named(DEPENDENCY_REFERENCE_CLASSES_KEY))
      .toInstance(dependencyReferenceClasses);
  bind(ServiceLoader.class).to(Pf4jServiceLoader.class);
  bind(ServicesFactory.class).to(GuiceServicesFactory.class);
  bind(BlockchainDataFactory.class).toInstance(new BlockchainDataFactory() {});
  bind(PluginManager.class).to(JarPluginManager.class);
}
 
@Test
void loadsUnloadsJarPlugins(@TempDir Path tmp) throws IOException {
  Path pluginPath = tmp.resolve("test-plugin.jar");

  String pluginId = "test-plugin";
  String version = "1.0.1";
  new ServiceArtifactBuilder()
      .setPluginId(pluginId)
      .setPluginVersion(version)
      .addExtensionClass(TestServiceModule1.class)
      .writeTo(pluginPath);

  PluginManager pluginManager = new JarPluginManager();

  // Try to load the plugin
  String loadedPluginId = pluginManager.loadPlugin(pluginPath);
  assertThat(loadedPluginId).isEqualTo(pluginId);

  // Try to start
  PluginState pluginState = pluginManager.startPlugin(pluginId);
  assertThat(pluginState).isEqualTo(PluginState.STARTED);

  // Check the extensions
  List<Class<? extends ServiceModule>> extensionClasses = pluginManager
      .getExtensionClasses(ServiceModule.class, pluginId);
  assertThat(extensionClasses).hasSize(1);
  Class<?> extensionType = extensionClasses.get(0);
  assertNamesEqual(extensionType, TestServiceModule1.class);

  // Try to stop and unload
  pluginState = pluginManager.stopPlugin(pluginId);
  assertThat(pluginState).isEqualTo(PluginState.STOPPED);
  boolean unloadResult = pluginManager.unloadPlugin(pluginId);
  assertTrue(unloadResult);
}
 
源代码19 项目: dremio-oss   文件: Hive3StoragePluginConfig.java
@Override
public StoragePlugin newPlugin(SabotContext context, String name, Provider<StoragePluginId> pluginIdProvider) {
  final PluginManager manager = new NativeLibPluginManager();

  manager.loadPlugins();
  manager.startPlugin(getPf4jPluginId());
  final StoragePluginCreator pluginCreator =
    manager.getExtensions(StoragePluginCreator.class, getPf4jPluginId()).get(0);

  return pluginCreator.createStoragePlugin(manager, this, context, name, pluginIdProvider);
}
 
源代码20 项目: dremio-oss   文件: Hive2StoragePluginConfig.java
@Override
public StoragePlugin newPlugin(SabotContext context, String name, Provider<StoragePluginId> pluginIdProvider) {
  final PluginManager manager = new NativeLibPluginManager();

  manager.loadPlugins();
  manager.startPlugin(getPf4jPluginId());
  final StoragePluginCreator pluginCreator =
    manager.getExtensions(StoragePluginCreator.class, getPf4jPluginId()).get(0);

  return pluginCreator.createStoragePlugin(manager, this, context, name, pluginIdProvider);
}
 
源代码21 项目: kork   文件: ExpressionsSupport.java
public ExpressionsSupport(
    Class<?>[] extraAllowedReturnTypes,
    List<ExpressionFunctionProvider> extraExpressionFunctionProviders,
    PluginManager pluginManager) {

  allowedReturnTypes =
      new HashSet<>(
          Arrays.asList(
              Collection.class,
              Map.class,
              SortedMap.class,
              List.class,
              Set.class,
              SortedSet.class,
              ArrayList.class,
              LinkedList.class,
              HashSet.class,
              LinkedHashSet.class,
              HashMap.class,
              LinkedHashMap.class,
              TreeMap.class,
              TreeSet.class));
  Collections.addAll(allowedReturnTypes, extraAllowedReturnTypes);

  expressionFunctionProviders =
      new ArrayList<>(
          Arrays.asList(
              new JsonExpressionFunctionProvider(), new StringExpressionFunctionProvider()));
  if (extraExpressionFunctionProviders != null) {
    expressionFunctionProviders.addAll(extraExpressionFunctionProviders);
  }

  // TODO(rz): Once plugins are no longer an incubating feature, extraExpressionFunctionProviders
  //  var could be removed
  if (pluginManager != null) {
    expressionFunctionProviders.addAll(
        pluginManager.getExtensions(ExpressionFunctionProvider.class));
  }
}
 
源代码22 项目: buck   文件: SkylarkProjectBuildFileParserTest.java
@Before
public void setUp() {
  projectFilesystem = FakeProjectFilesystem.createRealTempFilesystem();
  skylarkFilesystem = SkylarkFilesystem.using(projectFilesystem);
  cell = new TestCellBuilder().setFilesystem(projectFilesystem).build();
  PluginManager pluginManager = BuckPluginManagerFactory.createPluginManager();
  knownRuleTypesProvider = TestKnownRuleTypesProvider.create(pluginManager);
  parser = createParser(new PrintingEventHandler(EventKind.ALL_EVENTS));
}
 
源代码23 项目: buck   文件: SkylarkUserDefinedRulesParserTest.java
private void setupWorkspace(String scenario) throws IOException {
  workspace = TestDataHelper.createProjectWorkspaceForScenario(this, scenario, tmp.getRoot());
  workspace.setUp();
  projectFilesystem = new FakeProjectFilesystem(CanonicalCellName.rootCell(), tmp.getRoot());
  skylarkFilesystem = SkylarkFilesystem.using(projectFilesystem);
  cell = new TestCellBuilder().setFilesystem(projectFilesystem).build();
  PluginManager pluginManager = BuckPluginManagerFactory.createPluginManager();
  knownRuleTypesProvider = TestKnownRuleTypesProvider.create(pluginManager);
  parser = createParser(new PrintingEventHandler(EventKind.ALL_EVENTS));
}
 
源代码24 项目: buck   文件: ModuleWithExternalDependenciesTest.java
private static void testBuckModuleHashProvider(List<TestExtension> testExtensions) {
  PluginManager pluginManager = BuckPluginManagerFactory.createPluginManager();
  BuckModuleJarHashProvider hashProvider = new BuckModuleJarHashProvider();
  BuckModuleManager moduleManager = new DefaultBuckModuleManager(pluginManager, hashProvider);

  TestExtension testExtension1 = testExtensions.get(0);
  TestExtension testExtension2 = testExtensions.get(1);

  String hash1 = moduleManager.getModuleHash(testExtension1.getClass());
  String hash2 = moduleManager.getModuleHash(testExtension2.getClass());

  assertNotEquals(hash1, hash2);

  TestExtension extensionFromDependentModule;
  TestExtension extensionFromIndependentModule;

  if (testExtension1 instanceof Serializable) {
    extensionFromDependentModule = testExtension2;
    extensionFromIndependentModule = testExtension1;
  } else {
    extensionFromDependentModule = testExtension1;
    extensionFromIndependentModule = testExtension2;
  }

  assertEquals(
      hash(HASH), moduleManager.getModuleHash(extensionFromIndependentModule.getClass()));
  assertEquals(
      hash(hash(HASH), HASH),
      moduleManager.getModuleHash(extensionFromDependentModule.getClass()));
}
 
源代码25 项目: buck   文件: XCodeDescriptionsFactory.java
public static XCodeDescriptions create(PluginManager pluginManager) {
  List<XCodeDescriptionClassSupplier> xcodeDescriptionClassSuppliers =
      pluginManager.getExtensions(XCodeDescriptionClassSupplier.class);

  return new XCodeDescriptions(
      xcodeDescriptionClassSuppliers.stream()
          .flatMap(supplier -> supplier.getXCodeDescriptions().stream())
          .collect(ImmutableSet.toImmutableSet()));
}
 
源代码26 项目: buck   文件: MainRunner.java
/**
 * This constructor allows integration tests to add/remove/modify known build rules (aka
 * descriptions).
 *
 * @param console the {@link Console} to print to for this command
 * @param stdIn the input stream to the command being ran
 * @param knownRuleTypesFactoryFactory the known rule types for this command
 * @param buildId the {@link BuildId} for this command
 * @param clientEnvironment the environment variable map for this command
 * @param platform the current running {@link Platform}
 * @param projectRoot the project root of the current command
 * @param pluginManager the {@link PluginManager} for this command
 * @param moduleManager the {@link BuckModuleManager} for this command
 * @param context the {@link NGContext} from nailgun for this command
 */
@VisibleForTesting
public MainRunner(
    Console console,
    InputStream stdIn,
    KnownRuleTypesFactoryFactory knownRuleTypesFactoryFactory,
    BuildId buildId,
    ImmutableMap<String, String> clientEnvironment,
    Platform platform,
    Path projectRoot,
    PluginManager pluginManager,
    BuckModuleManager moduleManager,
    BackgroundTaskManager bgTaskManager,
    CommandMode commandMode,
    Optional<NGContext> context) {
  this.printConsole = new DuplicatingConsole(console);
  this.stdIn = stdIn;
  this.knownRuleTypesFactoryFactory = knownRuleTypesFactoryFactory;
  this.projectRoot = projectRoot;
  this.pluginManager = pluginManager;
  this.moduleManager = moduleManager;
  this.bgTaskManager = bgTaskManager;
  this.architecture = Architecture.detect();
  this.buildId = buildId;
  this.clientEnvironment = clientEnvironment;
  this.platform = platform;
  this.context = context;
  this.commandMode = commandMode;
}
 
源代码27 项目: buck   文件: TestCellBuilder.java
public Cells build() {
  ProjectFilesystem filesystem =
      this.filesystem != null ? this.filesystem : new FakeProjectFilesystem();

  BuckConfig config =
      buckConfig == null
          ? FakeBuckConfig.builder().setFilesystem(filesystem).build()
          : buckConfig;

  PluginManager pluginManager = BuckPluginManagerFactory.createPluginManager();
  ProcessExecutor processExecutor = new DefaultProcessExecutor(new TestConsole());
  ExecutableFinder executableFinder = new ExecutableFinder();

  ImmutableMap<String, String> environmentCopy = ImmutableMap.copyOf(environment);

  ToolchainProviderFactory toolchainProviderFactory =
      toolchainProvider == null
          ? new DefaultToolchainProviderFactory(
              pluginManager, environmentCopy, processExecutor, executableFinder)
          : (buckConfig, filesystemIgnore, ruleKeyConfiguration) -> toolchainProvider;

  DefaultCellPathResolver rootCellCellPathResolver =
      DefaultCellPathResolver.create(filesystem.getRootPath(), config.getConfig());

  return new Cells(
      LocalCellProviderFactory.create(
              filesystem,
              config,
              cellConfig,
              rootCellCellPathResolver.getPathMapping(),
              rootCellCellPathResolver,
              TestBuckModuleManagerFactory.create(pluginManager),
              toolchainProviderFactory,
              new DefaultProjectFilesystemFactory(),
              new ParsingUnconfiguredBuildTargetViewFactory())
          .getCellByPath(filesystem.getRootPath()));
}
 
源代码28 项目: buck   文件: BuckPluginManagerFactory.java
/** Creates a {@link PluginManager} and loads plugins. */
public static PluginManager createPluginManager() {
  PluginManager pluginManager = new DefaultBuckPluginManager();
  pluginManager.loadPlugins();
  pluginManager.startPlugins();

  return pluginManager;
}
 
源代码29 项目: buck   文件: RootCellFactory.java
public static Cell create(
    ImmutableSortedSet<AbsPath> knownRoots,
    CellProvider cellProvider,
    NewCellPathResolver newCellPathResolver,
    CellPathResolver rootCellCellPathResolver,
    ProjectFilesystem rootFilesystem,
    BuckModuleManager moduleManager,
    PluginManager pluginManager,
    BuckConfig rootConfig,
    ImmutableMap<String, String> environment,
    ProcessExecutor processExecutor,
    ExecutableFinder executableFinder) {
  Preconditions.checkState(
      !rootCellCellPathResolver.getCanonicalCellName(rootFilesystem.getRootPath()).isPresent(),
      "Root cell should be nameless");
  RuleKeyConfiguration ruleKeyConfiguration =
      ConfigRuleKeyConfigurationFactory.create(rootConfig, moduleManager);
  ToolchainProvider toolchainProvider =
      new DefaultToolchainProvider(
          pluginManager,
          environment,
          rootConfig,
          rootFilesystem,
          processExecutor,
          executableFinder,
          ruleKeyConfiguration);

  return ImmutableCellImpl.of(
      knownRoots,
      CanonicalCellName.rootCell(),
      rootFilesystem,
      rootConfig,
      cellProvider,
      toolchainProvider,
      rootCellCellPathResolver,
      newCellPathResolver,
      rootCellCellPathResolver.getCellNameResolver());
}
 
源代码30 项目: buck   文件: DefaultBuckModuleManager.java
public DefaultBuckModuleManager(
    PluginManager pluginManager, BuckModuleJarHashProvider moduleJarHashProvider) {
  this.pluginManager = pluginManager;
  this.moduleJarHashProvider = moduleJarHashProvider;

  try {
    pluginDescriptorField = PluginClassLoader.class.getDeclaredField("pluginDescriptor");
    pluginDescriptorField.setAccessible(true);
  } catch (NoSuchFieldException e) {
    throw new RuntimeException(
        "Cannot find pluginDescriptor field in " + PluginClassLoader.class.getName());
  }
}