Ensures that the api referenced by the Contract actually exists (is published).
@param contract
@param connection
@throws RegistrationException
552535
private void validateContract(final Contract contract, Connection connection)
            throws RegistrationException {
        QueryRunner run = new QueryRunner();
        try {
            Api api = run.query(connection, "SELECT bean FROM gw_apis WHERE org_id = ? AND id = ? AND version = ?", //$NON-NLS-1$
                    Handlers.API_HANDLER, contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion());
            if (api == null) {
                String apiId = contract.getApiId();
                String orgId = contract.getApiOrgId();
                throw new ApiNotFoundException(Messages.i18n.format("JdbcRegistry.ApiNotFoundInOrg", apiId, orgId));  //$NON-NLS-1$
            }
        } catch (SQLException e) {
            throw new RegistrationException(Messages.i18n.format("JdbcRegistry.ErrorValidatingApp"), e); //$NON-NLS-1$
        }
    }
690195
public static void trustAllSSLCertificates(HttpsURLConnection connection) {
        getTrustingSSLSocketFactory();
        connection.setSSLSocketFactory(socketFactory);
        connection.setHostnameVerifier(new HostnameVerifier() {
            public boolean verify(String s, SSLSession sslSession) {
                return true;
            }
        });
    }
978664
private void validateClient(Client client) throws RegistrationException {
        Set<Contract> contracts = client.getContracts();
        if (contracts.isEmpty()) {
            throw new NoContractFoundException(Messages.i18n.format("ESRegistry.NoContracts")); //$NON-NLS-1$
        }
        for (Contract contract : contracts) {
            validateContract(contract);
        }
    }
374555
public static void load(Connection connection) throws SQLException {
        Statement st = connection.createStatement();
        for (Function function : getBuiltInsFunctions()) {
            try {
                H2GISFunctions.registerFunction(st, function, "");
            } catch (SQLException ex) {
                // Catch to register other functions
                LOGGER.error(ex.getLocalizedMessage(), ex);
            }
        }
    }
269343
Connection registerChannel(
            final SocketChannel channel,
            final InputHandler handler,
            final int interestOps,
            final ReverseDNSPolicy dns,
            final CipherExecutor cipherService,
            final SSLEngine sslEngine) throws IOException {

        synchronized(channel.blockingLock()) {
            channel.configureBlocking (false);
            channel.socket().setKeepAlive(true);
        }

        Callable<Connection> registerTask = new Callable<Connection>() {
            @Override
            public Connection call() throws Exception {
                final VoltPort port = VoltPortFactory.createVoltPort(
                                channel,
                                VoltNetwork.this,
                                handler,
                                (InetSocketAddress)channel.socket().getRemoteSocketAddress(),
                                m_pool,
                                cipherService,
                                sslEngine);
                port.registering();

                /*
                 * This means we are used by a client. No need to wait then, trigger
                 * the reverse DNS lookup now.
                 */
                if (dns != ReverseDNSPolicy.NONE) {
                    port.resolveHostname(dns == ReverseDNSPolicy.SYNCHRONOUS);
                }

                try {
                    SelectionKey key = channel.register (m_selector, interestOps, null);

                    port.setKey (key);
                    port.registered();

                    //Fix a bug witnessed on the mini where the registration lock and the selector wakeup contained
                    //within was not enough to prevent the selector from returning the port after it was registered,
                    //but before setKey was called. Suspect a bug in the selector.wakeup() or register() implementation
                    //on the mac.
                    //The null check in invokeCallbacks will catch the null attachment, continue, and do the work
                    //next time through the selection loop
                    key.attach(port);

                    return port;
                } finally {
                    m_ports.add(port);
                    m_numPorts.incrementAndGet();
                }
            }
        };

        FutureTask<Connection> ft = new FutureTask<Connection>(registerTask);
        m_tasks.offer(ft);
        m_selector.wakeup();

        try {
            return ft.get();
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
569042
private void registerSynchronization(TransactionImpl odmgTrans, Transaction transaction)
    {
        // todo only need for development
        if (odmgTrans == null || transaction == null)
        {
            log.error("One of the given parameters was null --> cannot do synchronization!" +
                    " omdg transaction was null: " + (odmgTrans == null) +
                    ", external transaction was null: " + (transaction == null));
            return;
        }

        int status = -1; // default status.
        try
        {
            status = transaction.getStatus();
            if (status != Status.STATUS_ACTIVE)
            {
                throw new OJBRuntimeException(
                        "Transaction synchronization failed - wrong status of external container tx: " +
                        getStatusString(status));
            }
        }
        catch (SystemException e)
        {
            throw new OJBRuntimeException("Can't read status of external tx", e);
        }

        try
        {
            //Sequence of the following method calls is significant
            // 1. register the synchronization with the ODMG notion of a transaction.
            transaction.registerSynchronization((J2EETransactionImpl) odmgTrans);
            // 2. mark the ODMG transaction as being in a JTA Transaction
            // Associate external transaction with the odmg transaction.
            txRepository.set(new TxBuffer(odmgTrans, transaction));
        }
        catch (Exception e)
        {
            log.error("Cannot associate PersistenceBroker with running Transaction", e);
            throw new OJBRuntimeException(
                    "Transaction synchronization failed - wrong status of external container tx", e);
        }
    }
1228548
private Referenceable registerInstance(Referenceable referenceable) throws Exception {
        String typeName = referenceable.getTypeName();
        LOG.debug("creating instance of type {}", typeName);

        String entityJSON = InstanceSerialization.toJson(referenceable, true);
        LOG.debug("Submitting new entity {} = {}", referenceable.getTypeName(), entityJSON);
        List<String> guids = getAtlasClient().createEntity(entityJSON);
        LOG.debug("created instance for type {}, guid: {}", typeName, guids);

        return new Referenceable(guids.get(guids.size() - 1), referenceable.getTypeName(), null);
    }
540238
private static HttpEntity entityFromConnection(HttpURLConnection connection) {
        BasicHttpEntity entity = new BasicHttpEntity();
        InputStream inputStream;
        try {
            inputStream = connection.getInputStream();
        } catch (IOException ioe) {
            inputStream = connection.getErrorStream();
        }
        entity.setContent(inputStream);
        entity.setContentLength(connection.getContentLength());
        entity.setContentEncoding(connection.getContentEncoding());
        entity.setContentType(connection.getContentType());
        return entity;
    }
298412
@Override
    public boolean libraryExists(String libraryName)
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        String localePrefix = getLocalePrefixForLocateResource(facesContext);
        final List<String> contracts = facesContext.getResourceLibraryContracts(); 

        String pathToLib = null;
        Boolean libraryFound = null;
        if (libraryName != null && !ResourceValidationUtils.isValidLibraryName(
                libraryName, isAllowSlashesLibraryName()))
        {
            return false;
        }
        
        if (localePrefix != null)
        {
            //Check with locale
            pathToLib = localePrefix + '/' + libraryName;

            libraryFound = getResourceLoaderCache().libraryExists(pathToLib);
            if (libraryFound != null)
            {
                return libraryFound.booleanValue();
            }
        }
        libraryFound = getResourceLoaderCache().libraryExists(libraryName);
        if (libraryFound != null)
        {
            return libraryFound.booleanValue();
        }
        
        if (localePrefix != null)
        {
            if (!contracts.isEmpty())
            {
                for (String contract : contracts)
                {
                    for (ContractResourceLoader loader : getResourceHandlerSupport()
                            .getContractResourceLoaders())
                    {
                        if (loader.libraryExists(pathToLib, contract))
                        {
                            getResourceLoaderCache().confirmLibraryExists(pathToLib);
                            return true;
                        }
                    }
                }
            }
            
            for (ResourceLoader loader : getResourceHandlerSupport()
                    .getResourceLoaders())
            {
                if (loader.libraryExists(pathToLib))
                {
                    getResourceLoaderCache().confirmLibraryExists(pathToLib);
                    return true;
                }
            }            
        }

        //Check without locale
        if (!contracts.isEmpty())
        {
            for (String contract : contracts)
            {
                for (ContractResourceLoader loader : getResourceHandlerSupport()
                        .getContractResourceLoaders())
                {
                    if (loader.libraryExists(libraryName, contract))
                    {
                        getResourceLoaderCache().confirmLibraryExists(libraryName);
                        return true;
                    }
                }
            }
        }

        for (ResourceLoader loader : getResourceHandlerSupport()
                .getResourceLoaders())
        {
            if (loader.libraryExists(libraryName))
            {
                getResourceLoaderCache().confirmLibraryExists(libraryName);
                return true;
            }
        }

        if (localePrefix != null)
        {
            //Check with locale
            getResourceLoaderCache().confirmLibraryNotExists(pathToLib);
        }
        else
        {
            getResourceLoaderCache().confirmLibraryNotExists(libraryName);
        }
        return false;
    }
642873
static void registerIn(ConversionService conversionService) {

        LettuceAssert.notNull(conversionService, "ConversionService must not be null!");

        if (ReactiveTypes.isAvailable(ReactiveLibrary.PROJECT_REACTOR)) {

            if (ReactiveTypes.isAvailable(ReactiveLibrary.RXJAVA1)) {

                conversionService.addConverter(PublisherToRxJava1CompletableAdapter.INSTANCE);
                conversionService.addConverter(RxJava1CompletableToPublisherAdapter.INSTANCE);
                conversionService.addConverter(RxJava1CompletableToMonoAdapter.INSTANCE);

                conversionService.addConverter(PublisherToRxJava1SingleAdapter.INSTANCE);
                conversionService.addConverter(RxJava1SingleToPublisherAdapter.INSTANCE);
                conversionService.addConverter(RxJava1SingleToMonoAdapter.INSTANCE);
                conversionService.addConverter(RxJava1SingleToFluxAdapter.INSTANCE);

                conversionService.addConverter(PublisherToRxJava1ObservableAdapter.INSTANCE);
                conversionService.addConverter(RxJava1ObservableToPublisherAdapter.INSTANCE);
                conversionService.addConverter(RxJava1ObservableToMonoAdapter.INSTANCE);
                conversionService.addConverter(RxJava1ObservableToFluxAdapter.INSTANCE);
            }

            if (ReactiveTypes.isAvailable(ReactiveLibrary.RXJAVA2)) {

                conversionService.addConverter(PublisherToRxJava2CompletableAdapter.INSTANCE);
                conversionService.addConverter(RxJava2CompletableToPublisherAdapter.INSTANCE);
                conversionService.addConverter(RxJava2CompletableToMonoAdapter.INSTANCE);

                conversionService.addConverter(PublisherToRxJava2SingleAdapter.INSTANCE);
                conversionService.addConverter(RxJava2SingleToPublisherAdapter.INSTANCE);
                conversionService.addConverter(RxJava2SingleToMonoAdapter.INSTANCE);
                conversionService.addConverter(RxJava2SingleToFluxAdapter.INSTANCE);

                conversionService.addConverter(PublisherToRxJava2ObservableAdapter.INSTANCE);
                conversionService.addConverter(RxJava2ObservableToPublisherAdapter.INSTANCE);
                conversionService.addConverter(RxJava2ObservableToMonoAdapter.INSTANCE);
                conversionService.addConverter(RxJava2ObservableToFluxAdapter.INSTANCE);

                conversionService.addConverter(PublisherToRxJava2FlowableAdapter.INSTANCE);
                conversionService.addConverter(RxJava2FlowableToPublisherAdapter.INSTANCE);

                conversionService.addConverter(PublisherToRxJava2MaybeAdapter.INSTANCE);
                conversionService.addConverter(RxJava2MaybeToPublisherAdapter.INSTANCE);
                conversionService.addConverter(RxJava2MaybeToMonoAdapter.INSTANCE);
                conversionService.addConverter(RxJava2MaybeToFluxAdapter.INSTANCE);
            }

            conversionService.addConverter(PublisherToMonoAdapter.INSTANCE);
            conversionService.addConverter(PublisherToFluxAdapter.INSTANCE);

            if (ReactiveTypes.isAvailable(ReactiveLibrary.RXJAVA1)) {
                conversionService.addConverter(RxJava1SingleToObservableAdapter.INSTANCE);
                conversionService.addConverter(RxJava1ObservableToSingleAdapter.INSTANCE);
            }

            if (ReactiveTypes.isAvailable(ReactiveLibrary.RXJAVA2)) {
                conversionService.addConverter(RxJava2SingleToObservableAdapter.INSTANCE);
                conversionService.addConverter(RxJava2ObservableToSingleAdapter.INSTANCE);
                conversionService.addConverter(RxJava2ObservableToMaybeAdapter.INSTANCE);
            }
        }
    }
894305
private void validateConfiguration(ApiSource apiSource) throws GenerateException {
        if (apiSource == null) {
            throw new GenerateException("You do not configure any apiSource!");
        } else if (apiSource.getInfo() == null) {
            throw new GenerateException("`<info>` is required by Swagger Spec.");
        }
        if (apiSource.getInfo().getTitle() == null) {
            throw new GenerateException("`<info><title>` is required by Swagger Spec.");
        }

        if (apiSource.getInfo().getVersion() == null) {
            throw new GenerateException("`<info><version>` is required by Swagger Spec.");
        }

        if (apiSource.getInfo().getLicense() != null && apiSource.getInfo().getLicense().getName() == null) {
            throw new GenerateException("`<info><license><name>` is required by Swagger Spec.");
        }

        if (apiSource.getLocations() == null) {
            throw new GenerateException("<locations> is required by this plugin.");
        }

    }
754808
public Application register(Object component, Map<Class<?>, Integer> contracts) {
        config.register(component, contracts);
        return this;
    }
812950
protected void verifyRegisteredService(final RequestContext requestContext, final RegisteredService registeredService) {
        if (registeredService == null || !registeredService.getAccessStrategy().isServiceAccessAllowed()) {
            LOGGER.debug("Service [{}] is not recognized/allowed by the CAS service registry", registeredService);
            if (registeredService != null) {
                WebUtils.putUnauthorizedRedirectUrlIntoFlowScope(requestContext, registeredService.getAccessStrategy().getUnauthorizedRedirectUrl());
            }
            throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, StringUtils.EMPTY);
        }
    }
287851
private boolean contractAlreadyExists(String organizationId, String clientId, String version,
            NewContractBean bean) {
        try {
            List<ContractSummaryBean> contracts = query.getClientContracts(organizationId, clientId, version);
            for (ContractSummaryBean contract : contracts) {
                if (contract.getApiOrganizationId().equals(bean.getApiOrgId()) &&
                    contract.getApiId().equals(bean.getApiId()) &&
                    contract.getApiVersion().equals(bean.getApiVersion()) &&
                    contract.getPlanId().equals(bean.getPlanId()))
                {
                    return true;
                }
            }
            return false;
        } catch (StorageException e) {
            return false;
        }
    }
622797
public Application register(Class<?> componentClass, Map<Class<?>, Integer> contracts) {
        config.register(componentClass, contracts);
        return this;
    }
353280
public void addConnection (Connection connection) {
		if (connection == null) throw new IllegalArgumentException("connection cannot be null.");

		synchronized (connectionsLock) {
			Connection[] newConnections = new Connection[connections.length + 1];
			newConnections[0] = connection;
			System.arraycopy(connections, 0, newConnections, 1, connections.length);
			connections = newConnections;
		}

		connection.addListener(invokeListener);

		if (TRACE) trace("kryonet", "Added connection to ObjectSpace: " + connection);
	}
192700
function Contract(addressOrName, contractInterface, signerOrProvider) {
        var _this = this;
        errors.checkNew(this, Contract);
        // @TODO: Maybe still check the addressOrName looks like a valid address or name?
        //address = getAddress(address);
        if (interface_1.Interface.isInterface(contractInterface)) {
            properties_1.defineReadOnly(this, 'interface', contractInterface);
        }
        else {
            properties_1.defineReadOnly(this, 'interface', new interface_1.Interface(contractInterface));
        }
        if (abstract_signer_1.Signer.isSigner(signerOrProvider)) {
            properties_1.defineReadOnly(this, 'provider', signerOrProvider.provider);
            properties_1.defineReadOnly(this, 'signer', signerOrProvider);
        }
        else if (abstract_provider_1.Provider.isProvider(signerOrProvider)) {
            properties_1.defineReadOnly(this, 'provider', signerOrProvider);
            properties_1.defineReadOnly(this, 'signer', null);
        }
        else {
            errors.throwError('invalid signer or provider', errors.INVALID_ARGUMENT, { arg: 'signerOrProvider', value: signerOrProvider });
        }
        properties_1.defineReadOnly(this, 'estimate', {});
        properties_1.defineReadOnly(this, 'functions', {});
        properties_1.defineReadOnly(this, 'filters', {});
        Object.keys(this.interface.events).forEach(function (eventName) {
            var event = _this.interface.events[eventName];
            properties_1.defineReadOnly(_this.filters, eventName, function () {
                var args = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    args[_i] = arguments[_i];
                }
                return {
                    address: _this.address,
                    topics: event.encodeTopics(args)
                };
            });
        });
        this._events = [];
        properties_1.defineReadOnly(this, 'address', addressOrName);
        if (this.provider) {
            properties_1.defineReadOnly(this, 'addressPromise', this.provider.resolveName(addressOrName).then(function (address) {
                if (address == null) {
                    throw new Error('name not found');
                }
                return address;
            }).catch(function (error) {
                throw error;
            }));
        }
        else {
            try {
                properties_1.defineReadOnly(this, 'addressPromise', Promise.resolve(address_1.getAddress(addressOrName)));
            }
            catch (error) {
                // Without a provider, we cannot use ENS names
                errors.throwError('provider is required to use non-address contract address', errors.INVALID_ARGUMENT, { argument: 'addressOrName', value: addressOrName });
            }
        }
        Object.keys(this.interface.functions).forEach(function (name) {
            var run = runMethod(_this, name, false);
            if (_this[name] == null) {
                properties_1.defineReadOnly(_this, name, run);
            }
            else {
                errors.warn('WARNING: Multiple definitions for ' + name);
            }
            if (_this.functions[name] == null) {
                properties_1.defineReadOnly(_this.functions, name, run);
                properties_1.defineReadOnly(_this.estimate, name, runMethod(_this, name, true));
            }
        });
    }