Create a new session instance.

@param  {String} name
@param  {Object} handler
@param  {String|null} id
336817
function Store(name, handler, id) {
    this.setId(id);
    this.__name = name;
    this.__handler = handler;

    /**
     * The session attributes.
     *
     * @var {Object}
     * @protected
     */
    this.__attributes = {};

    /**
     * Session store started status.
     *
     * @var {Boolean}
     */
    this.__started = false;
}
1088858
public void createSession(String sessionId) {
        boolean newSession = sessionId == null;
        sessionId = newSession ? newSessionId() : sessionId;
        SessionController controller = sessions.get(sessionId);
        
        if (controller == null) {
            controller = SessionController.create(sessionId, newSession);
            sessions.put(sessionId, controller);
        }
    }
997149
private static void initStringDefinedHandler(String handler) {
		// split the class name and its label, if defined
		Tuple<String, Class> namedClass = splitClassAndName(handler);

		// create an instance of the handler
		Object handlerOrProviderObject = null;
		try {
			handlerOrProviderObject = namedClass.second.newInstance();
		} catch (Exception e) {
			logger.error("Exception:", e);
			throw new RuntimeException("Could not instantiate handler class: " + namedClass.second);
		}

		HttpHandler resolvedHandler;
		if (handlerOrProviderObject instanceof HttpHandler) {
			resolvedHandler = (HttpHandler) handlerOrProviderObject;
		} else if (handlerOrProviderObject instanceof HandlerProvider) {
			resolvedHandler = ((HandlerProvider) handlerOrProviderObject).getHandler();
		} else {
			throw new RuntimeException("Unsupported type of handler provided: " + handlerOrProviderObject);
		}
		registerMiddlewareHandler(resolvedHandler);
		handlers.put(namedClass.first, resolvedHandler);
		handlerListById.put(namedClass.first, Collections.singletonList(resolvedHandler));
	}
699877
@Override
    public void sessionCreated(HttpSessionEvent event) {

        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "HttpSession created: HttpSession ID: " + event.getSession().getId());
        }
        // nothing to do here, since later the code will add the session id to a map 

    }
278632
public void createSession(Session session) {
        sessionMap.put(session.id(), session);
        Event event = new Event();
        event.attribute("session", session);

        eventManager.fireEvent(EventType.SESSION_CREATED, event);
    }
904661
private Session loadSession(String id) throws Exception {
        if (sessionDataStore == null) {
            return null; // can't load it
        }
        try {
            SessionData data = sessionDataStore.load(id);
            if (data == null) { // session doesn't exist
                return null;
            }
            return newSession(data);
        } catch (UnreadableSessionDataException e) {
            // can't load the session, delete it
            if (isRemoveUnloadableSessions()) {
                sessionDataStore.delete(id);
            }
            throw e;
        }
    }
232611
public function register($name, $handler)
    {
        Assert::string($name, 'The handler name must be a string. Got: %s');
        Assert::notEmpty($name, 'The handler name must not be empty.');

        if (!is_object($handler)) {
            Assert::isCallable($handler, 'The handler must be a callable or an object. Got: %s');
        }

        $this->handlers[$name] = $handler;

        if (!$this->selectedHandler) {
            $this->selectedHandler = $name;
        }
    }
684067
public void sessionCreated(final HttpSessionEvent event) {
		counter++;
		final HttpSession session = event.getSession();
		final String id = session.getId();
		SESSIONS.put(id, session);
	}
145593
function newInstance (controller, args) {
    // get model from controller
    var model = controller.model
    // form to create new instance
    var form
    // get model data from input
    var data = args[model.name]
    // if pre-fill input is passed then initialize form with it
    if (defined(data)) {
        form = controller.form.newInstance({
            input: data,
            redirect: args.redirect,
        })
    }
    // otherwise use default form
    else {
        form = controller.form.newInstance({
            action: './?redirect=./',
        })
    }

    return {
        form: form,
    }
}
727370
function (eventName,handler) {
			var event;
			if (event = this.getEvent(eventName))
			{
				if (!event.once(handler,true))
					this.e.log('Invalid handler sent to event `'+eventName+'` on `'+this.getConfig('id')+'`','warning');
			} else
				this.e.log('Not existent event `'+eventName+'` on `'+this.getConfig('id')+'`','warning');
			return this;
		}
1040146
function createSession(){

    // can also check if any ealier session can be used
    if (!currentSession){
        
        const createNewSession = _setSessionReferrer();
        const currentSessionCookie = utils.getCookie(constants.sessionCookieName);

        if (currentSessionCookie && !createNewSession){

            const currentSessionSplit = currentSessionCookie.split('__');
            currentSession = new session(currentSessionSplit[0], 
                parseInt(currentSessionSplit[1]), {});
            
            logger.debug('Found existing session', currentSessionSplit[0], 
                currentSessionSplit[1]);

        } else{

            currentSession = new session(null, null, {});
            setSessionCookie();

            logger.debug('Creating new session', currentSession.getSessionToken(), 
                currentSession.getSessionUnixTime());

        }

        // associate session referrer with the session
        if (sessionReferrer){

            currentSession.setExtra('referrer', sessionReferrer);
            
        }
        
    }

    return currentSession;

}
1026792
private Event newEvent(final String id, final Exception error) {
        return new EventFactorySupport().event(this, id, new LocalAttributeMap<>("error", error));
    }
927742
function sessionCreated(err, session) {
  if (err) throw err

  console.log("session created, creating agent")

  var agentInfo = {name: "echoer", title: "an echo agent" }

  // create the agent, calling `agentCreated` when done
  session.createAgent(agentInfo, function(err, agent) {
    agentCreated(session, err, agent)
  })
}
41320
public static ConnectionHandler register(final String id, 
                                             final ConnectionHandler handler) {

        if (id == null || id.length() == 0) {
            throw new IllegalArgumentException("Invalid ID: " + id);
        } // end of if

        if (handler == null) {
            throw new IllegalArgumentException("Invalid handler: " + handler);
        } // end of if

        // ---

        return handlers.put(id, handler);
    }
757436
public ISession createSession(String sessionId, boolean newId) {
        //create local variable - JIT performance improvement
        final boolean isTraceOn = com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled();
        //need some way to checkForDuplicateCreatedIds or synchronize on some object or something ... look at in-memory
        if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            StringBuffer sb = new StringBuffer("id = ").append(sessionId).append(appNameForLogging);
            LoggingUtil.SESSION_LOGGER_WAS.entering(methodClassName, methodNames[CREATE_SESSION], sb.toString());
        }
        if (inProcessOfStopping) {
            throwException("SessionContext.createWhenStop");
        }
        BackedSession session = null;
        session = createSessionObject(sessionId);
        session.updateLastAccessTime(session.getCreationTime());
        session.setInsert(); // flag new session for insertion into store
        session.setMaxInactiveInterval((int) _smc.getSessionInvalidationTime());
        session.setUserName(ANONYMOUS_USER);
        _sessions.put(sessionId, session);
        //        if (session.duplicateIdDetected) { // could happen on zOS if key is defined incorrectly - perhaps doesn't include appname
        //                                           // other than that, this really should never happen - duplicate ids should not be generated
        //            LoggingUtil.SESSION_LOGGER_CORE.logp(Level.WARNING, methodClassName, methodNames[CREATE_SESSION], "Store.createSessionIdAlreadyExists");
        //            session = null;
        //        }

        if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[CREATE_SESSION], "session = " + session);
        }
        return session;
    }
911529
function setEventHandler(name, handler, dom, tag) {
  var eventName,
    cb = handleEvent.bind(tag, dom, handler);

  // avoid to bind twice the same event
  // possible fix for #2332
  dom[name] = null;

  // normalize event name
  eventName = name.replace(RE_EVENTS_PREFIX, '');

  // cache the listener into the listeners array
  if (!contains(tag.__.listeners, dom)) { tag.__.listeners.push(dom); }
  if (!dom[RIOT_EVENTS_KEY]) { dom[RIOT_EVENTS_KEY] = {}; }
  if (dom[RIOT_EVENTS_KEY][name]) { dom.removeEventListener(eventName, dom[RIOT_EVENTS_KEY][name]); }

  dom[RIOT_EVENTS_KEY][name] = cb;
  dom.addEventListener(eventName, cb, false);
}
178201
private static void initMapDefinedHandler(Map<String, Object> handler) {
		// If the handler is a map, the keys are the class name, values are the
		// parameters.
		for (Map.Entry<String, Object> entry : handler.entrySet()) {
			Tuple<String, Class> namedClass = splitClassAndName(entry.getKey());

			// If the values in the config are a map, construct the object using named
			// parameters.
			if (entry.getValue() instanceof Map) {
				HttpHandler httpHandler;
				try {
					httpHandler = (HttpHandler) ServiceUtil.constructByNamedParams(namedClass.second,
							(Map) entry.getValue());
				} catch (Exception e) {
					throw new RuntimeException(
							"Could not construct a handler with values provided as a map: " + namedClass.second);
				}
				registerMiddlewareHandler(httpHandler);
				handlers.put(namedClass.first, httpHandler);
				handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
			} else if (entry.getValue() instanceof List) {

				// If the values in the config are a list, call the constructor of the handler
				// with those fields.
				HttpHandler httpHandler;
				try {
					httpHandler = (HttpHandler) ServiceUtil.constructByParameterizedConstructor(namedClass.second,
							(List) entry.getValue());
				} catch (Exception e) {
					throw new RuntimeException(
							"Could not construct a handler with values provided as a list: " + namedClass.second);
				}
				registerMiddlewareHandler(httpHandler);
				handlers.put(namedClass.first, httpHandler);
				handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
			}
		}
	}