/*
Create the JMSContext from the supplied configuration
500729
private JMSContext createJMSContext(JMSContextInfo info, boolean tranIsActive) throws NamingException {
        inTransaction = tranIsActive;

        ConnectionFactory cf = (ConnectionFactory) new InitialContext().lookup(info.getConnectionFactoryString());

        if (inTransaction && cf instanceof XAConnectionFactory) {

            XAJMSContext xaContext = ((XAConnectionFactory) cf).createXAContext(info.getUserName(), info.getPassword());
            return xaContext.getContext();

        } else {

            return cf.createContext(info.getUserName(), info.getPassword(), info.getAcknowledgeMode());
        }
    }
152482
function ConnectionContext(connectionConfig, httpClient, config)
{
  // validate input
  Errors.assertInternal(Util.isObject(connectionConfig));
  Errors.assertInternal(Util.isObject(httpClient));

  // if a config object was specified, verify
  // that it has all the information we need
  var sfServiceConfig;
  if (Util.exists(config))
  {
    Errors.assertInternal(Util.isObject(config));
    Errors.assertInternal(Util.isObject(config.services));
    Errors.assertInternal(Util.isObject(config.services.sf));

    sfServiceConfig = config.services.sf;
  }

  // create a map that contains all the services we'll be using
  var services =
  {
    sf: new SfService(connectionConfig, httpClient, sfServiceConfig),
    largeResultSet: new LargeResultSetService(connectionConfig, httpClient)
  };

  /**
   * Returns the ConnectionConfig for use by the connection.
   *
   * @returns {ConnectionConfig}
   */
  this.getConnectionConfig = function()
  {
    return connectionConfig;
  };

  /**
   * Returns a map that contains all the available services.
   *
   * @returns {Object}
   */
  this.getServices = function()
  {
    return services;
  };

  /**
   * Returns a configuration object that can be passed as an optional argument
   * to the ConnectionContext constructor to create a new object that has the
   * same state as this ConnectionContext instance.
   *
   * @returns {Object}
   */
  this.getConfig = function()
  {
    return {
      services:
      {
        sf: services.sf.getConfig()
      }
    };
  };
}
903871
public Object createContext(Object param) throws Exception {

        Class<?>[] params = mConstr != null ? mConstr.getParameterTypes() : new Class[0];
        if (params.length > 1 && MergedClass.InvocationEventObserver.class.equals(params[1])) {
            return mConstr.newInstance(new Object[] {
                new MergingContextFactory(param),
                new MergedClass.InvocationEventObserver() {
                    public void invokedEvent(String caller, String callee, long elapsedTime) { }
                    public long currentTime() { return 0L; }
            }});
        }
        else {
            return mConstr.newInstance(new Object[] {
                new MergingContextFactory(param)});
        }
    }
421246
function createContext(message) {

	var message = message || {},
		context = {}
	
	context.headers$ = _.omit(message.properties || {}, 'headers')
	context.amqp$    = message.fields     || {}
	context.req      = {}
	context.res      = {}

	if (message.content) {
		if (message.content instanceof Buffer)
			context.req = JSON.parse(message.content.toString())
		else 
			context.req = message.content
	}

	if (message.properties.headers)
		_.merge(context.headers$, message.properties.headers)

	context.service  = this
	context.invoke   = this.invoke.bind(this)
	context.command  = this.command.bind(this)
	context.publish  = this.publish.bind(this)
	context.sleep    = this.sleep.bind(this)
	context.log      = this.log

	return context
}
512581
private void initialize(ComponentContext context,
                            Map<String, Object> properties, ConfigurationAdmin configAdmin)
                    throws InvalidFileStoreConfigurationException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, "initialize", new Object[] { context, properties });
        }
        this.properties = properties;
        this.bundleLocation = context.getBundleContext().getBundle().getLocation();
        
        // populate filestore
        SIBFileStore filestore = new SIBFileStoreImpl();
        populateFileStore(properties, filestore, configAdmin);

        // set bus properties
        // nothing to set for bus as only defaults are considered
        // uuid will be set by the processor
        SIBus bus = new SIBusImpl();

        // set the properties for mesagingengine object.first the queues or
        // topic is got from
        // Administration Config and list of SIBBestination is created
        // and then the localization list is created for those SIBdestination
        SIBMessagingEngine messagingEngine = new SIBMessagingEngineImpl();

        messagingEngine.setHighMessageThreshold((Long) properties
                        .get(JsAdminConstants.HIGHMESSAGETHRESHOLD));

        HashMap<String, BaseDestination> destinationList = new HashMap<String, BaseDestination>();
        HashMap<String, SIBLocalizationPoint> destinationLocalizationList = new HashMap<String, SIBLocalizationPoint>();

        // populate destinations of type QUEUE
        populateDestinations(properties, destinationList, destinationLocalizationList, messagingEngine.getName(), JsAdminConstants.QUEUE, configAdmin,
                             false);
        // populate destinations of type TOPICSPACE
        populateDestinations(properties, destinationList, destinationLocalizationList, messagingEngine.getName(), JsAdminConstants.TOPICSPACE, configAdmin,
                             false);
        //populate destinations of type ALIAS
        populateAliasDestinations(properties, destinationList, configAdmin);

        // processor will update the UUID via Admin.Since we dont get UUID info from server.xml
        messagingEngine.setDestinationList(destinationList);
        messagingEngine.setSibLocalizationPointList(destinationLocalizationList);

        // set all the constructed artifact to jsMEConfig
        jsMEConfig.setMessagingEngine(messagingEngine);
        jsMEConfig.setSIBFilestore(filestore);
        jsMEConfig.setSIBus(bus);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, "initialize");
        }

    }
1186632
JmsSessionImpl instantiateSession(boolean transacted, int acknowledgeMode, SICoreConnection coreConnection, JmsJcaSession jcaSession) throws JMSException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "instantiateSession", new Object[]{transacted, acknowledgeMode, coreConnection, jcaSession});
    JmsQueueSessionImpl jmsQueueSession = new JmsQueueSessionImpl(transacted, acknowledgeMode, coreConnection, this, jcaSession);
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "instantiateSession",  jmsQueueSession);
    return jmsQueueSession;
  }
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;
	}
401533
private void initConfigPropertyResolver(ServletContext context) {
		String configPropertyResolverClass = getInitParameter("configPropertyResolverClass");
		// Load a custom class to set configPropertyResolver
		configPropResolver = null;
		if (null != configPropertyResolverClass) {
			configPropResolver = (ConfigPropertyResolver) ClassLoaderResourceUtils
					.buildObjectInstance(configPropertyResolverClass);
			if (configPropResolver instanceof ServletContextAware) {
				((ServletContextAware) configPropResolver).setServletContext(context);
			}
		}
	}
806485
@Override
    public TextMessage createTextMessage() throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createTextMessage");

        TextMessage textMessage = null;

        try {
            textMessage = jmsSession.createTextMessage();
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createTextMessage", new Object[] { textMessage });
        }

        return textMessage;

    }
169784
@Override
	public Context create(String name, Tree params, CallOptions.Options opts, PacketStream stream, Context parent) {

		// Generate ID
		String id = uid.nextUID();

		// Create new Context
		if (parent == null) {
			return new Context(serviceInvoker, eventbus, id, name, params, opts, stream);
		}

		// Merge meta block
		if (parent.params != null) {
			Tree parentMeta = parent.params.getMeta(false);
			if (parentMeta != null && !parentMeta.isEmpty()) {
				Tree currentMeta = params.getMeta(true);
				if (currentMeta.isEmpty()) {
					currentMeta.setObject(parentMeta.asObject());
				} else {
					currentMeta.copyFrom(parentMeta, false);
				}
			}
		}

		// Verify call level
		if (maxCallLevel > 0 && parent.level >= maxCallLevel) {
			throw new MaxCallLevelError(broker.getNodeID(), maxCallLevel);
		}

		// Create context (nested call)
		return new Context(id, name, params, opts, stream, parent);
	}
1118947
@Override
    public T create(final CreationalContext<T> creationalContext) {
        if (proxyInstantiator == null) {
            // initializeAfterBeanDiscovery wasn't yet invoked
            // this can happen if you attempt to create bean prior to fully booting container
            throw BeanLogger.LOG.initABDnotInvoked(annotatedType);
        }
        return proxyInstantiator.newInstance(creationalContext, beanManager);
    }
1220810
@NotNull
    public final ArtifactFactoryConfig init(@NotNull final SrcGen4JContext context, final Map<String, String> vars) {
        Contract.requireArgNotNull("context", context);
        this.context = context;
        inheritVariables(vars);
        return this;
    }
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;

    }
10312
static JmxConfig from(Config config) {
    try {
      ObjectName query = new ObjectName(config.getString("query"));
      List<JmxMeasurementConfig> ms = new ArrayList<>();
      for (Config cfg : config.getConfigList("measurements")) {
        ms.add(JmxMeasurementConfig.from(cfg));
      }
      return new JmxConfig(query, ms);
    } catch (Exception e) {
      throw new IllegalArgumentException("invalid mapping config", e);
    }
  }
860746
@Override
    public ManagedObjectContext createContext() {
        Bean<T> bean = null;

        EjbDescriptor<T> ejbDescriptor = getEjbDescriptor();
        //in the case of an MDB, the bean should be null, in which case the creational context will be non-contextual
        if (!ejbDescriptor.isMessageDriven()) {
            bean = getBean();
        }

        WeldManager beanManager = getBeanManager();
        WeldCreationalContext<T> creationalContext = beanManager.createCreationalContext(bean);

        ManagedObjectContext managedObjectContext = new CDIManagedObjectState(creationalContext);

        return managedObjectContext;
    }
190104
public static JndiConfigurationSource create(Context context) {
    if (context == null) {
      throw new NullPointerException("context: null");
    }
    return new JndiConfigurationSource(createJndiConfiguration(context, null), DEFAULT_PRIORITY);
  }
558937
private static RunContext createBottomContext() {
    File spockUserHome = SpockUserHomeUtil.getSpockUserHome();
    DelegatingScript script = new ConfigurationScriptLoader(spockUserHome).loadAutoDetectedScript();
    List<Class<?>> classes = new ExtensionClassesLoader().loadClassesFromDefaultLocation();
    return new RunContext("default", spockUserHome, script, classes);
  }