/* (non-Javadoc)
@see org.apache.cxf.jaxrs.ext.ContextProvider#createContext(org.apache.cxf.message.Message)
960137
@Override
    public SseEventSink createContext(Message message) {
        MessageBodyWriter<OutboundSseEvent> writer = new OutboundSseEventBodyWriter(ServerProviderFactory.getInstance(message), message.getExchange());
        LibertySseEventSinkImpl impl = new LibertySseEventSinkImpl(writer, message);
        message.put(SseEventSink.class.getName(), impl);
        
        // treat SSE methods like async methods
        AsyncResponseImpl ar = new AsyncResponseImpl(message);
        message.put(AsyncResponseImpl.class.getName(), ar);
        
        return impl;
    }
1020310
static final Context context(Element match, int matchIndex, int matchSize) {
        return new DefaultContext(match, matchIndex, matchSize);
    }
1152946
private RequestContext createRequestContext(final HttpServletRequest req) {
        return new RequestContext() {
            @Override
            public String getCharacterEncoding() {
                return req.getCharacterEncoding();
            }

            @Override
            public String getContentType() {
                return req.getContentType();
            }

            @Override
            @Deprecated
            public int getContentLength() {
                return req.getContentLength();
            }

            @Override
            public InputStream getInputStream() throws IOException {
                return req.getInputStream();
            }
        };
    }
164367
function NodeContext(msg, parent, nodeContext, serverName) {
    this.msgContext = new mustache.Context(msg, parent);
    this.nodeContext = nodeContext;
    this.serverName = serverName;
}
775654
protected Message createControlMessage(TestContext context, String messageType) {
        if (dataDictionary != null) {
            messageBuilder.setDataDictionary(dataDictionary);
        }

        return messageBuilder.buildMessageContent(context, messageType, MessageDirection.INBOUND);
    }
795262
@SuppressWarnings("unchecked")
    public static void injectContextMethods(Object requestObject,
                                            AbstractResourceInfo cri,
                                            Message message) {

        for (Map.Entry<Class<?>, Method> entry : cri.getContextMethods().entrySet()) {
            Method method = entry.getValue();
            if (method.getParameterTypes()[0] == Application.class && cri.isSingleton()) {
                continue;
            }
            Object o = JAXRSUtils.createContextValue(message,
                                                     method.getGenericParameterTypes()[0],
                                                     entry.getKey());

            if (o != null) {
                if (!cri.isSingleton()) {
                    InjectionUtils.injectThroughMethod(requestObject, method, o, message);
                } else {
                    ThreadLocalProxy<Object> proxy = (ThreadLocalProxy<Object>) cri.getContextSetterProxy(method);
                    if (proxy != null) {
                        proxy.set(o);
                    }
                }

            }
        }
    }
1245457
protected IContext makeContext()
	{
		final HttpCallContext http = HttpCallContext.peek();

		if (http != null)
		{
			return new WebContext(http.getRequest(), http.getResponse(), http.getServletContext(), http.getRequest().getLocale());
		}
		else
		{
			return new Context();
		}
	}
96527
@Override
    public JMSContext createContext(int sessionMode) throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createContext", new Object[] { sessionMode });

        JmsJMSContextImpl jmsContext = null;

        // If the context created is container-managed, then JMSRuntimeException must be thrown
        if (jmsConnection.isManaged()) {
            JMSException jmse = (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                                          "CREATECONTEXT_IN_CONTAINER_CWSIA0513",
                                                                          null, tc);
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        }

        try {
            //CTS test failure was reported when the session mode was passed as -1,  so adding the validation
            switch (sessionMode)
            {
                case JMSContext.AUTO_ACKNOWLEDGE:
                case JMSContext.CLIENT_ACKNOWLEDGE:
                case JMSContext.DUPS_OK_ACKNOWLEDGE:
                case JMSContext.SESSION_TRANSACTED: {
                    break;
                }
                default:
                    throw (JMSRuntimeException) JmsErrorUtils.newThrowable(JMSRuntimeException.class,
                                                                           "INVALID_ACKNOWLEDGE_MODE_CWSIA0514",
                                                                           new Object[] {},
                                                                           tc
                                    );
            }

            jmsContext = new JmsJMSContextImpl(jmsConnection, sessionMode, false);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createContext", new Object[] { jmsContext });
        }
        return jmsContext;
    }
1055177
private Context createContext() throws Exception
   {
      Properties properties = new Properties();
      properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
      properties.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      return new InitialContext(properties);
   }
1337922
@Override
	public Context createContext(String path, String docBase) {

        if( log.isDebugEnabled() )
            log.debug("Creating context '" + path + "' with docBase '" +
                       docBase + "'");

        context = new StandardContext();

        context.setDocBase(docBase);
        context.setPath(path);

        ContextConfig config = new ContextConfig();
        config.setCustomAuthenticators(authenticators);
        ((Lifecycle) context).addLifecycleListener(config);

        return (context);

    }
943082
private void fillRequestContext(RequestContext context) {
        IdManager.makeSureMsgId(context);
        context.setNodeStatus(getSimpleStatus());
        context.setMessageType(MessageType.request);
        context.setSourceNodeId(nodeId);//this node id
    }
141060
private void addContext(
      final EvaluatorRuntimeProtocol.AddContextProto addContextProto)
      throws ContextClientCodeException {

    synchronized (this.contextStack) {
      try {

        final ContextRuntime currentTopContext = this.contextStack.peek();

        if (!currentTopContext.getIdentifier().equals(addContextProto.getParentContextId())) {
          throw new IllegalStateException("Trying to instantiate a child context on context with id `" +
              addContextProto.getParentContextId() + "` while the current top context id is `" +
              currentTopContext.getIdentifier() + "`");
        }

        final Configuration contextConfiguration =
            this.configurationSerializer.fromString(addContextProto.getContextConfiguration());

        final ContextRuntime newTopContext;
        if (addContextProto.hasServiceConfiguration()) {
          newTopContext = currentTopContext.spawnChildContext(contextConfiguration,
              this.configurationSerializer.fromString(addContextProto.getServiceConfiguration()));
        } else {
          newTopContext = currentTopContext.spawnChildContext(contextConfiguration);
        }

        this.contextStack.push(newTopContext);

      } catch (final IOException | BindException e) {
        throw new RuntimeException("Unable to read configuration.", e);
      }

    }
  }
768257
private static ContextHandler buildContext(String basePath) {
        ResourceConfig resourceConfig = new ResourceConfig();
        resourceConfig.packages(QueryResource.class.getPackage().getName(), ApiListingResource.class.getPackage().getName());
        ServletContainer servletContainer = new ServletContainer(resourceConfig);
        ServletHolder entityBrowser = new ServletHolder(servletContainer);
        ServletContextHandler entityBrowserContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
        entityBrowserContext.setContextPath(basePath);
        entityBrowserContext.addServlet(entityBrowser, "/*");

        FilterHolder corsFilter = new FilterHolder(CrossOriginFilter.class);
        corsFilter.setAsyncSupported(true);
        corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
        corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "*");
        corsFilter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");
        corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,POST,HEAD,DELETE,PUT,OPTIONS");

        entityBrowserContext.addFilter(corsFilter, "/*", EnumSet.allOf(DispatcherType.class));
        return entityBrowserContext;
    }
56534
protected void initContext() {
        context = createContext();
        SmartFoxContext sfsContext = (SmartFoxContext)context;
        sfsContext.setApi(getApi());
        sfsContext.setExtension(this);
    }
198069
public static Context createContext(Configuration config) {
		Context context = new Context();

		context.setProperty(Context.OS_NAME, System.getProperty("os.name"));
		context.setProperty(Context.OS_VERSION, System.getProperty("os.version"));
		context.setProperty(Context.OS_ARCHITECTURE, System.getProperty("os.arch"));

		context.setProperty(Context.JAVA_VERSION, System.getProperty("java.version"));
		context.setProperty(Context.JAVA_VENDOR, System.getProperty("java.vendor"));

		context.setProperty(Context.JAVA_RUNTIME_NAME, System.getProperty("java.runtime.name"));
		context.setProperty(Context.JAVA_RUNTIME_VERSION, System.getProperty("java.runtime.version"));

		context.setProperty(Context.JAVA_VM_NAME, System.getProperty("java.vm.name"));
		context.setProperty(Context.JAVA_VM_VERSION, System.getProperty("java.vm.version"));
		context.setProperty(Context.JAVA_VM_VENDOR, System.getProperty("java.vm.vendor"));

		context.setProperty(Context.JAVA_VM_SPEC_NAME, System.getProperty("java.vm.specification.name"));
		context.setProperty(Context.JAVA_VM_SPEC_VERSION, System.getProperty("java.vm.specification.version"));
		context.setProperty(Context.JAVA_VM_SPEC_VENDOR, System.getProperty("java.vm.specification.vendor"));

		context.setProperty(Context.JAVA_SPEC_NAME, System.getProperty("java.specification.name"));
		context.setProperty(Context.JAVA_SPEC_VERSION, System.getProperty("java.specification.version"));
		context.setProperty(Context.JAVA_SPEC_VENDOR, System.getProperty("java.specification.vendor"));

		context.setProperty(Context.JAVA_CLASS_VERSION, System.getProperty("java.class.version"));

		context.setPreProperty(Context.MEMORY_TOTAL, Runtime.getRuntime().totalMemory());
		context.setPreProperty(Context.MEMORY_FREE, Runtime.getRuntime().freeMemory());
		context.setPreProperty(Context.MEMORY_USED, Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());

		// Enriched with SCM data
		if (config.getScmInfo() != null) {
			ScmInfo scmInfo = config.getScmInfo();

			context.setPropertyNullAvoided(Context.PROBEDOCK_SCM_NAME, scmInfo.getName());
			context.setPropertyNullAvoided(Context.PROBEDOCK_SCM_VERSION, scmInfo.getVersion());
			context.setPropertyNullAvoided(Context.PROBEDOCK_SCM_DIRTY, scmInfo.isDirty());
			context.setPropertyNullAvoided(Context.PROBEDOCK_SCM_BRANCH, scmInfo.getBranch());
			context.setPropertyNullAvoided(Context.PROBEDOCK_SCM_COMMIT, scmInfo.getCommit());

			// Enriched with SCM remote data
			if (scmInfo.getRemote() != null) {
				ScmRemoteInfo scmRemoteInfo = scmInfo.getRemote();

				context.setPropertyNullAvoided(Context.PROBEDOCK_SCM_REMOTE_NAME, scmRemoteInfo.getName());
				context.setPropertyNullAvoided(Context.PROBEDOCK_SCM_REMOTE_FETCH_URL, scmRemoteInfo.getFetchUrl());
				context.setPropertyNullAvoided(Context.PROBEDOCK_SCM_REMOTE_PUSH_URL, scmRemoteInfo.getPushUrl());
				context.setPropertyNullAvoided(Context.PROBEDOCK_SCM_REMOTE_AHEAD, scmRemoteInfo.getAhead());
				context.setPropertyNullAvoided(Context.PROBEDOCK_SCM_REMOTE_BEHIND, scmRemoteInfo.getBehind());
			}
		}

		return context;
	}
339777
public void send(Message message, TestContext context) {
        String correlationKeyName = getEndpointConfiguration().getCorrelator().getCorrelationKeyName(getName());
        String correlationKey = getEndpointConfiguration().getCorrelator().getCorrelationKey(message);
        correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context);

        SshRequest request = (SshRequest) getEndpointConfiguration().getMessageConverter().convertOutbound(message, getEndpointConfiguration(), context);

        if (getEndpointConfiguration().isStrictHostChecking()) {
            setKnownHosts();
        }

        String rUser = getRemoteUser(message);
        connect(rUser);
        ChannelExec channelExec = null;
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        ByteArrayOutputStream errStream = new ByteArrayOutputStream();
        int rc;
        try {
            channelExec = openChannelExec();
            channelExec.setErrStream(errStream);
            channelExec.setOutputStream(outStream);
            channelExec.setCommand(request.getCommand());
            doConnect(channelExec);
            if (request.getStdin() != null) {
                sendStandardInput(channelExec, request.getStdin());
            }
            waitCommandToFinish(channelExec);
            rc = channelExec.getExitStatus();
        } finally {
            if (channelExec != null && channelExec.isConnected()) {
                channelExec.disconnect();
            }
            disconnect();
        }
        SshResponse sshResp = new SshResponse(outStream.toString(),errStream.toString(),rc);
        Message response = getEndpointConfiguration().getMessageConverter().convertInbound(sshResp, getEndpointConfiguration(), context)
                .setHeader("user", rUser);

        correlationManager.store(correlationKey, response);
    }
1187090
protected void createWebAppContext() {
    webapp = new WebAppContext();
    webapp.setThrowUnavailableOnStartupException(true);
    webapp.setServerClasses(getServerClasses());
    webapp.setContextPath(getContextPath());
    webapp.setTempDirectory(createTempDir("jetty-app-"));
    setSecureCookies();
  }