Create a new session.

@return new JCR session handle object.
@throws ResourceException if there is an error opening the session
500823
private JcrSession openSession() throws ResourceException {
        try {
            Repository repo = mcf.getRepository();
            Session s = repo.login(cri.getCredentials(), cri.getWorkspace());
            return (JcrSession) s;
        } catch (RepositoryException e) {
            throw new ResourceException("Failed to create session: " + e.getMessage(), e);
        }
    }
928784
public void createResource(final InputStream inputStream, final String resourceName)
        throws JaxRxException {
        synchronized (resourceName) {
            if (inputStream == null) {
                throw new JaxRxException(400, "Bad user request");
            } else {
                try {
                    shred(inputStream, resourceName);
                } catch (final TTException exce) {
                    throw new JaxRxException(exce);
                }
            }
        }
    }
1342466
@Override
    protected TransportResolver createResolver(JingleSession session) {
        BridgedResolver bridgedResolver = new BridgedResolver(this.xmppConnection);
        return bridgedResolver;
    }
449446
private synchronized void createProducerSession()

  throws SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "createProducerSession");

    if (iProducerSession == null)
    {

      try
      {
        iProducerSession =
          (ProducerSessionImpl) iProxyHandler
            .getMessageProcessor()
            .getSystemConnection()
            .createSystemProducerSession(iRemoteQueue, null, null, null, null);
      }
      catch (SIException e)
      {
        // No exceptions should occur as the destination should always exists
        // as it is created at start time.
        FFDCFilter.processException(
          e,
          "com.ibm.ws.sib.processor.proxyhandler.Neighbour.createProducerSession",
          "1:434:1.107",
          this);

        SibTr.exception(tc, e);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
          SibTr.exit(tc, "createProducerSession", "SIResourceException");

        // this is already NLS'd //175907
        throw new SIResourceException(e);
      }

    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "createProducerSession");
  }
214582
@Override
    public Mp newInstance() throws DempsyException {
        try {
            return newMp.get();
        } catch(final RuntimeException rte) {
            throw new DempsyException(rte, true);
        }
    }
1267374
protected function createResource()
    {
        $resource = $this->connect($this->configuration->asArguments());

        if (!is_resource($resource)) {
            throw new RuntimeException('The SSH connection failed.');
        }

        $this->resource = $resource;

        if (null !== $this->authentication) {
            $this->authenticate();
        }
    }
195334
protected Session createSession(Connection connection) throws JMSException {
        if (connection instanceof QueueConnection) {
            return ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        }
        return connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    }
1215490
private function create(): CookieAuthSession
    {
        $response = $this->request($this->endpoint . $this->path, [
            RequestOptions::JSON => [
                'username' => $this->username,
                'password' => $this->password,
            ],
        ]);

        $body = $response->getBody();
        $body->seek(0);
        $contents = $body->getContents();

        $contents = json_decode($contents, true);

        if (isset($contents['session']['name'], $contents['session']['value'])) {
            return new CookieAuthSession($contents['session']['name'], $contents['session']['value']);
        }

        throw new \Exception('Failed to create ' . CookieAuthSession::class . '.');
    }
519914
public function createResponse()
    {
        // Cannot continue if a resource has not been set
        if (!$this->resource instanceof ResourceInterface) {
            return $this->response;
        }

        return $this->response
            ->setResource($this->resource)
            ->create();
    }
465704
def create_jdbc_resource(name, server=None, **kwargs):
    '''
    
    '''
    defaults = {
        'description': '',
        'enabled': True,
        'id': name,
        'poolName': '',
        'target': 'server'
    }

    # Data = defaults + merge kwargs + poolname
    data = defaults
    data.update(kwargs)

    if not data['poolName']:
        raise CommandExecutionError('No pool name!')

    return _create_element(name, 'resources/jdbc-resource', data, server)
106318
@Override
    public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createSession", new Object[] { transacted, acknowledgeMode });

        JmsSessionImpl jmsSession = null;

        // throw an exception if the connection is closed.
        checkClosed();

        // mark that the client id cannot be changed.
        fixClientID();

        // enforce consistency on transacted flag and acknowledge mode.
        if (transacted) {
            acknowledgeMode = Session.SESSION_TRANSACTED;
        }
        if (!transacted && isManaged) {
            if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE) {
                throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                                "INVALID_ACKNOWLEDGE_MODE_CWSIA0514",
                                                                new Object[] { acknowledgeMode },
                                                                tc
                                );
            }
            // if the ackmode is dups_ok then set it to dups_ok, for all the other combination 
            // set it to auto_ack
            if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE)
                acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;
            else
                acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
        }

        // create the jca session.
        boolean internallyTransacted = (transacted
                                        || acknowledgeMode == Session.CLIENT_ACKNOWLEDGE
                                        || acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE);
        JmsJcaSession jcaSession = createJcaSession(internallyTransacted);

        // Lock here so that another thread using the same connection doesn't reset the 
        // coreConnection to something else as as we are instantiating the Session 
        synchronized (this)
        {
            try
            {
                // We potentially have a new coreConnection becuase the creation of the JcaSession
                // detected that the coreConnection is now invalid and so a new managedConnection
                // and coreConnection was created. So reset the coreConnection for this JmsConnection
                // to the new one or we just set the old one again.
                coreConnection = jcaSession.getSICoreConnection();
            } catch (IllegalStateException e)
            {
                FFDCFilter.processException(e, "com.ibm.ws.sib.api.jms.impl.JmsConnectionImpl", "createSession#2", this);

                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(this, tc, "createSession", jmsSession);

                throw (JMSException) JmsErrorUtils.newThrowable(
                                                                JMSException.class,
                                                                "JCA_CREATE_SESS_CWSIA0024",
                                                                null,
                                                                e,
                                                                "JmsConnectionImpl.createSession#2",
                                                                this,
                                                                tc);
            }
            // instantiate the jms session, and add it to this connection's session list.
            jmsSession = instantiateSession(transacted, acknowledgeMode, coreConnection, jcaSession);
        }
        synchronized (stateLock) {
            sessions.add(jmsSession);
            // d353701 - output a warning message if there are 'lots' of sessions active.
            if (sessions.size() % SESSION_WARNING_THRESHOLD == 0) {
                // We wish to tell the user which line of their application created the session,
                // so we must obtain a line of stack trace from their application.
                String errorLocation = JmsErrorUtils.getFirstApplicationStackString();
                SibTr.warning(tc, "MANY_SESSIONS_WARNING_CWSIA0027", new Object[] { "" + sessions.size(), errorLocation });
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createSession", jmsSession);
        return jmsSession;
    }
206934
@Override
  public Session create(CassandraStorage cassandra) {
    Closer closer = Closer.create();
    try {
      Cluster cluster = closer.register(buildCluster(cassandra));
      cluster.register(new QueryLogger.Builder().build());
      Session session;
      String keyspace = cassandra.keyspace();
      if (cassandra.ensureSchema()) {
        session = closer.register(cluster.connect());
        Schema.ensureExists(keyspace, cassandra.searchEnabled(), session);
        session.execute("USE " + keyspace);
      } else {
        LOG.debug("Skipping schema check on keyspace {} as ensureSchema was false", keyspace);
        session = cluster.connect(keyspace);
      }

      initializeUDTs(session);

      return session;
    } catch (RuntimeException e) {
      try {
        closer.close();
      } catch (IOException ignored) {
      }
      throw e;
    }
  }
1327444
public LogSession.Builder sessionBuilder() {
    return new DistributedLogSession.Builder() {
      @Override
      public LogSession build() {
        return new DistributedLogSession(
            partitionId,
            sessionIdProvider.get().join(),
            clusterMembershipService,
            protocol,
            primaryElection,
            threadContextFactory.createContext());
      }
    };
  }
1168168
protected HttpSession createSession(final HttpServletRequest servletRequest) {

        LOGGER.debug("Returning an authenticated session in the default workspace");
        return  new HttpSession(repo.login(credentialsService.getCredentials(servletRequest)));
    }
581322
@Override
    public Session createSession(int sessionMode) throws JMSException {

        Session session = null;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createSession", new Object[] { sessionMode });
        try {
            if (sessionMode == JMSContext.SESSION_TRANSACTED)
                session = createSession(true, sessionMode);
            else
                session = createSession(false, sessionMode);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createSession");
        }
        return session;

    }
612985
final public function create()
    {

        $self = $this;

        $splash = $self->getSplash();
        $sessId = $this->generateId($splash);

        session_id($sessId); //Must be called before the sesion start to generate the Id
        session_cache_limiter('none');

        session_name(md5($self->cookie . $splash['agent'] . $splash['ip'] . $splash['domain']));
        session_start();

        //Create the default namespace; affix to splash;
        //The default namespace will contain vars such as -request count, - last session start time, -last session response time, etc
        //The dfault namespace will also contain, instantiated objects?
        //
        $defaultReg = new Registry("default");
        $self->registry['default'] = $defaultReg;

        //update the cookie with the expiry time
        //Create the authenticated namespace and lock it!
        $self->set("handler", $this->authenticator, "auth");

        $this->write($sessId, $splash);
    }
267991
@Override
    public ISession createSession(String id, boolean newId) {
        // assert (id!=null);
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINER)) {
            StringBuffer sb = new StringBuffer("{").append(id).append(",").append(newId).append("} ").append(appNameForLogging);
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[CREATE_SESSION], sb.toString());
        }
        MemorySession sess = null;

        // need to test on a different language
        // try creating a temporary logger with the old resource bundle, and then
        // changing the environment to French or something
        if (inProcessOfStopping) {
            throwException("SessionContext.createWhenStop");
        }
        if ((!_smc.getEnableOverflow()) && (_sessions.size() >= _smc.getInMemorySize())) {
            // if we know we're in an overflow situation, don't bother
            // creating a new session
            if (_sessionStatistics != null) {
                _sessionStatistics.incNoRoomForNewSession();
            }
            sess = overflowSession;
        }
        // We expect the second part of check below - _sessions.get(id) == null --
        // to pass unless
        // the id generator generates a dup. This really should never happen.
        // The synchronization in SessionManager.createISession will prevent
        // multiple threads
        // with the same incoming id from both getting into this code. We're no
        // longer using
        // the newId parm...it could be removed, but its now part of the IStore
        // interface.
        if ((sess == null) && (_sessions.get(id) == null)) {
            if(!_removeAttrOnInvalidate)
                sess = new MemorySession(this, id, _storeCallback);
            else{
                if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                    LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[CREATE_SESSION], "Create MemorySession with _removeAttrOnInvalidate -->" + _removeAttrOnInvalidate );
                }
                sess = new MemorySession(this, id, _storeCallback, _removeAttrOnInvalidate);
            }
            sess.setUserName(ANONYMOUS_USER);
            // since this was a newly created session, we need to update the
            // lastAccessTime to the create time
            sess.updateLastAccessTime(sess.getCreationTime());
            try {
                _sessions.put(id, sess);
            } catch (TooManySessionsException tmse) {
                // could catch this exception if multiple threads get past the
                // first overflow check and then attempt to do the sessions.put
                sess = overflowSession;
            }
        }

        // Returns a new session if everything is good
        // Returns an overflowSession is overflow is not allowed and we've already
        // hit the maximum number in memory
        // Returns null if there was an existing session with this key - should
        // never happen

        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[CREATE_SESSION], sess);
        }
        return sess;
    }