/* (non-Javadoc)
@see org.jboss.arquillian.spi.client.protocol.Protocol#getExecutor(org.jboss.arquillian.spi.client.protocol.ProtocolConfiguration, org.jboss.arquillian.spi.client.protocol.metadata.ProtocolMetaData)
178469
@Override
    public ServletMethodExecutor getExecutor(ServletProtocolConfiguration protocolConfiguration,
        ProtocolMetaData metaData, CommandCallback callback) {
        Collection<HTTPContext> contexts = metaData.getContexts(HTTPContext.class);
        if (contexts.size() == 0) {
            throw new IllegalArgumentException(
                "No " + HTTPContext.class.getName() + " found in " + ProtocolMetaData.class.getName() + ". " +
                    "Servlet protocol can not be used");
        }
        return new ServletMethodExecutor(protocolConfiguration, contexts, callback);
    }
442337
@Nonnull
    public static synchronized ScheduledExecutorService get() {
        if (executorService == null) {
            // corePoolSize is set to 10, but will only be created if needed.
            // ScheduledThreadPoolExecutor "acts as a fixed-sized pool using corePoolSize threads"
            // TODO consider also wrapping in ContextResettingExecutorService
             executorService = new ImpersonatingScheduledExecutorService(new ErrorLoggingScheduledThreadPoolExecutor(10, new NamingThreadFactory(new ClassLoaderSanityThreadFactory(new DaemonThreadFactory()), "jenkins.util.Timer")), ACL.SYSTEM);
        }
        return executorService;
    }
895214
@Override
	public HttpCommandProcessor getCommandProcessor(Protocol protocol) {
		String commandProcessorName = commandProcessorNames.get(protocol);

        if (commandProcessorName == null) {
			throw new PanicInTheCougar("No HTTP Command Processor has been configured for protocol " + protocol);
        }

        HttpCommandProcessor commandProcessor = (HttpCommandProcessor)applicationContext.getBean(commandProcessorName);

        if (commandProcessor == null) {
			throw new PanicInTheCougar("No HTTP Command Processor has been configured for the name " + commandProcessorName);
        }

		return commandProcessor;
	}
343888
public com.google.api.Distribution.ExemplarOrBuilder getExemplarsOrBuilder(
      int index) {
    return exemplars_.get(index);
  }
1098092
@Nullable
    public static Executor getTtlExecutor(@Nullable Executor executor) {
        if (TtlAgent.isTtlAgentLoaded() || null == executor || executor instanceof TtlEnhanced) {
            return executor;
        }
        return new ExecutorTtlWrapper(executor);
    }
1242490
public QueryExecutor<S> executor(Filter<S> filter, OrderingList<S> ordering, QueryHints hints)
        throws RepositoryException
    {
        return analyze(filter, ordering, hints).createExecutor();
    }
280514
public static ExecutorService getSecurityContextAwareExecutor(ExecutorService original) {
        SubjectAwareExecutorService subjectAwareExecutor = new SubjectAwareExecutorService(original);
        return ThreadLocalUtil.contextAwareExecutor(subjectAwareExecutor);
    }
35321
@Override
	public JobExecutionResult execute(String jobName) throws Exception {
		Plan p = createProgramPlan(jobName);
		
		PlanExecutor executor = PlanExecutor.createLocalExecutor();
		initLogging();
		return executor.executePlan(p);
	}
846543
public static ExecutorService getQueueingExecutorService(final Queue<Runnable> taskQueue) {
        return new ExecutorService() {
            @Override
            public void execute(Runnable command) {
                taskQueue.offer(command);
            }

            @Override
            public void shutdown() {
                throw new UnsupportedOperationException();
            }

            @Override
            public List<Runnable> shutdownNow() {
                throw new UnsupportedOperationException();
            }

            @Override
            public boolean isShutdown() {
                return false;
            }

            @Override
            public boolean isTerminated() {
                return false;
            }

            @Override
            public boolean awaitTermination(long timeout, TimeUnit unit)
                    throws InterruptedException {
                return true;
            }

            @Override
            public <T> Future<T> submit(Callable<T> task) {
                Preconditions.checkNotNull(task);
                FutureTask<T> retval = new FutureTask<T>(task);
                taskQueue.offer(retval);
                return retval;
            }

            @Override
            public <T> Future<T> submit(Runnable task, T result) {
                Preconditions.checkNotNull(task);
                FutureTask<T> retval = new FutureTask<T>(task, result);
                taskQueue.offer(retval);
                return retval;
            }

            @Override
            public Future<?> submit(Runnable task) {
                Preconditions.checkNotNull(task);
                ListenableFutureTask<Object> retval = ListenableFutureTask.create(task, null);
                taskQueue.offer(retval);
                return retval;
            }

            @Override
            public <T> List<Future<T>> invokeAll(
                    Collection<? extends Callable<T>> tasks)
                    throws InterruptedException {
                throw new UnsupportedOperationException();
            }

            @Override
            public <T> List<Future<T>> invokeAll(
                    Collection<? extends Callable<T>> tasks, long timeout,
                    TimeUnit unit) throws InterruptedException {
                throw new UnsupportedOperationException();
            }

            @Override
            public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
                    throws InterruptedException, ExecutionException {
                throw new UnsupportedOperationException();
            }

            @Override
            public <T> T invokeAny(Collection<? extends Callable<T>> tasks,
                    long timeout, TimeUnit unit) throws InterruptedException,
                    ExecutionException, TimeoutException {
                throw new UnsupportedOperationException();
            }
        };
    }
474195
public static ScopedBindingBuilder bindWorkerExecutor(Binder binder, String key, Class<? extends ExecutorService> executorServiceClass)
    {
        return workerExecutorBinder(binder).addBinding(key).to(executorServiceClass);
    }
488778
private ExecutorConfig getOrFindExecutorConfig(String name) {
        ExecutorConfig cfg = executorConfigCache.get(name);
        if (cfg != null) {
            return cfg;
        } else {
            cfg = nodeEngine.getConfig().findExecutorConfig(name);
            ExecutorConfig executorConfig = executorConfigCache.putIfAbsent(name, cfg);
            return executorConfig == null ? cfg : executorConfig;
        }
    }
976657
public static ServiceAdapter<ExecutorService> forExecutorService() {
		return new SimpleServiceAdapter<ExecutorService>(false, true) {
			@Override
			protected void start(ExecutorService instance) {
			}

			@Override
			protected void stop(ExecutorService instance) throws Exception {
				List<Runnable> runnables = instance.shutdownNow();
				if (!runnables.isEmpty()) {
					logger.warn("Cancelled tasks: " + runnables);
				}
				if (!instance.isTerminated()) {
					logger.warn("Awaiting termination of " + instance + " ...");
					instance.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
				}
			}
		};
	}
1211254
@Override
    public TransactionManagerAdapter getTransactionManager(RuntimeStepExecution stepExec) throws TransactionManagementException {
    	logger.entering(CLASSNAME, "getTransactionManagerServicesManager", stepExec);
    	
    	TransactionManagerAdapter adapter = null;
    	if (osgiDS) {
    		adapter = getTransactionManagerDS(stepExec);
    	} else {
    		adapter = getTransactionManagerServicesManager(stepExec);
    	}
        
        logger.exiting(CLASSNAME, "getTransactionManager", adapter);
        return adapter;
    }
1290178
public static synchronized JSSEProvider getInstance(String inputProvider) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "getInstance: " + inputProvider);

        String contextProvider = inputProvider;
        if (contextProvider == null) {
            if (null != defaultProvider) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    Tr.exit(tc, "getInstance: " + defaultProvider);
                return defaultProvider;
            }
            contextProvider = getProviderFromProviderList();
        }

        // if still null, revert to default as usual.
        if (contextProvider == null) {
            contextProvider = Constants.IBMJSSE2_NAME;
        }

        JSSEProvider cachedProvider = providerCache.get(contextProvider);

        if (cachedProvider != null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(tc, "getInstance(cached) " + cachedProvider);
            return cachedProvider;
        }

        final String contextProviderPriv = contextProvider;
        AccessController.doPrivileged(new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                Provider provider = Security.getProvider(contextProviderPriv);

                if (provider == null) {
                    try {
                        if (contextProviderPriv.equalsIgnoreCase(Constants.IBMJSSE_NAME)) {
                            provider = (Provider) Class.forName(Constants.IBMJSSE2).newInstance();
                        } else if (contextProviderPriv.equalsIgnoreCase(Constants.SUNJSSE_NAME)) {
                            provider = (Provider) Class.forName("com.sun.net.ssl.internal.ssl.Provider").newInstance();
                        } else {
                            provider = (Provider) Class.forName(Constants.IBMJSSE2).newInstance();
                        }
                        if (provider != null) {
                            Security.addProvider(provider);
                        }
                    } catch (Exception e) {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                            Tr.debug(tc, "Exception loading provider: " + contextProviderPriv + "; " + e);
                    }
                }
                return null;
            }
        });

        Provider[] providerList = Security.getProviders();

        for (int i = 0; i < providerList.length && null == cachedProvider; i++) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Provider name [" + i + "]: " + providerList[i].getName());

            if (providerList[i].getName().equalsIgnoreCase(contextProvider)) {
                if (contextProvider.equalsIgnoreCase(Constants.IBMJSSE2_NAME) && validateProvider(Constants.IBMJSSE2_NAME)) {
                    cachedProvider = new IBMJSSEProvider();
                    providerCache.put(Constants.IBMJSSE2_NAME, cachedProvider);
                    providerCache.put(contextProvider, cachedProvider);
                } else if (contextProvider.equalsIgnoreCase(Constants.IBMJSSE_NAME) && validateProvider(Constants.IBMJSSE_NAME)) {
                    cachedProvider = new IBMJSSEProvider();
                    providerCache.put(Constants.IBMJSSE_NAME, cachedProvider);
                    providerCache.put(contextProvider, cachedProvider);
                } else if (contextProvider.equalsIgnoreCase(Constants.SUNJSSE_NAME) && validateProvider(Constants.SUNJSSE_NAME)) {
                    cachedProvider = new SunJSSEProvider();
                    providerCache.put(Constants.SUNJSSE_NAME, cachedProvider);
                    providerCache.put(contextProvider, cachedProvider);
                } else {
                    cachedProvider = new IBMJSSEProvider();
                    providerCache.put(Constants.IBMJSSE_NAME, cachedProvider);
                    providerCache.put(contextProvider, cachedProvider);
                }
            }
        } // end-provider-loop

        // if still null, default to IBM JSSE provider
        if (cachedProvider == null) {
            cachedProvider = new IBMJSSEProvider();
            providerCache.put(Constants.IBMJSSE_NAME, cachedProvider);
            providerCache.put(contextProvider, cachedProvider);
        }

        if (null == inputProvider) {
            defaultProvider = cachedProvider;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "getInstance: " + cachedProvider);
        return cachedProvider;
    }
784730
protected void bindExecutor(final Class<? extends RepositoryExecutor> executor) {
        bind(executor).in(Singleton.class);
        executorsMultibinder.addBinding().to(executor);
    }
48805
public static ExecutorService getExecutorService() {
        CHFWBundle c = instance.get().get();
        if (null != c) {
            return c.executorService;
        }
        return null;
    }
560784
AbstractCommandExecution findExecutor( AbstractCommandInstruction instr ) {

		AbstractCommandExecution result = null;

		if( RenameCommandInstruction.class.equals( instr.getClass()))
			result = new RenameCommandExecution((RenameCommandInstruction) instr);

		else if( ReplicateCommandInstruction.class.equals( instr.getClass()))
			result = new ReplicateCommandExecution((ReplicateCommandInstruction) instr, this.manager );

		else if( AssociateTargetCommandInstruction.class.equals( instr.getClass()))
			result = new AssociateTargetCommandExecution((AssociateTargetCommandInstruction) instr, this.manager );

		else if( BulkCommandInstructions.class.equals( instr.getClass()))
			result = new BulkCommandExecution((BulkCommandInstructions) instr, this.manager );

		else if( ChangeStateCommandInstruction.class.equals( instr.getClass()))
			result = new ChangeStateCommandExecution((ChangeStateCommandInstruction) instr, this.manager );

		else if( CreateInstanceCommandInstruction.class.equals( instr.getClass()))
			result = new CreateInstanceCommandExecution((CreateInstanceCommandInstruction) instr, this.manager );

		else if( EmailCommandInstruction.class.equals( instr.getClass()))
			result = new EmailCommandExecution((EmailCommandInstruction) instr, this.manager );

		else if( WriteCommandInstruction.class.equals( instr.getClass()))
			result = new WriteCommandExecution((WriteCommandInstruction) instr);

		else if( AppendCommandInstruction.class.equals( instr.getClass()))
			result = new AppendCommandExecution((AppendCommandInstruction) instr);

		else if( ExecuteCommandInstruction.class.equals( instr.getClass()))
			result = new ExecuteCommandExecution((ExecuteCommandInstruction) instr, this.manager );

		return result;
	}