/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections; using System.Collections.Specialized; using Apache.NMS.XMS.Util; using Apache.NMS.Policies; using Apache.NMS.Util; using IBM.XMS; namespace Apache.NMS.XMS { /// /// An Initial Context for querying object repositories for object /// definitions. /// public class InitialContext : IDisposable { public IBM.XMS.InitialContext xmsInitialContext; #region Constructors /// /// Constructs an InitialContext object. /// /// Environment settings. public InitialContext(Hashtable environment) { this.xmsInitialContext = new IBM.XMS.InitialContext(environment); } /// /// Constructs an InitialContext object specifying the /// repository URL. /// /// Environment settings. /// Repository URL. public InitialContext(Hashtable environment, string repositoryURL) { this.xmsInitialContext = new IBM.XMS.InitialContext(environment); this.RepositoryURL = repositoryURL; } #endregion #region Initial Context Properties (configure via ConnectionFactory URL parameters) // http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.msc.doc/props_inctx.htm?lang=en /// /// Repository URL. /// [UriAttribute("ic.RepositoryURL")] public string RepositoryURL { get { return (string)this.xmsInitialContext.Environment[XMSC.IC_URL]; } set { this.xmsInitialContext.Environment[XMSC.IC_URL] = value; } } /// /// Initial context provider URL. /// [UriAttribute("ic.ProviderURL")] public string ProviderURL { get { return (string)this.xmsInitialContext.Environment[XMSC.IC_PROVIDER_URL]; } set { this.xmsInitialContext.Environment[XMSC.IC_PROVIDER_URL] = value; } } /// /// Initial context security protocol. /// [UriAttribute("ic.SecurityProtocol")] public string SecurityProtocol { get { return (string)this.xmsInitialContext.Environment[XMSC.IC_SECURITY_PROTOCOL]; } set { this.xmsInitialContext.Environment[XMSC.IC_SECURITY_PROTOCOL] = value; } } /// /// Initial context security authentication. /// [UriAttribute("ic.SecurityAuthentication")] public string SecurityAuthentication { get { return (string)this.xmsInitialContext.Environment[XMSC.IC_SECURITY_AUTHENTICATION]; } set { this.xmsInitialContext.Environment[XMSC.IC_SECURITY_AUTHENTICATION] = value; } } /// /// Initial context security principal. /// [UriAttribute("ic.SecurityPrincipal")] public string SecurityPrincipal { get { return (string)this.xmsInitialContext.Environment[XMSC.IC_SECURITY_PRINCIPAL]; } set { this.xmsInitialContext.Environment[XMSC.IC_SECURITY_PRINCIPAL] = value; } } /// /// Initial context security credentials. /// [UriAttribute("ic.SecurityCredentials")] public string SecurityCredentials { get { return (string)this.xmsInitialContext.Environment[XMSC.IC_SECURITY_CREDENTIALS]; } set { this.xmsInitialContext.Environment[XMSC.IC_SECURITY_CREDENTIALS] = value; } } #endregion #region InitialContext Methods /// /// Create an object from an object definition that is retrieved from /// the repository of administered objects. /// /// Requested object name. /// Requested object, or null if the requested object is /// not found. public object Lookup(string objectName) { return this.xmsInitialContext.Lookup(objectName); } /// /// Add a new property to the environment. /// /// Property name. /// Property value. /// Old property value. public object AddToEnvironment( string propertyName, object propertyValue) { return this.xmsInitialContext.AddToEnvironment( propertyName, propertyValue); } /// /// Remove a property from the environment. /// /// Property name. /// Old property value. public object RemoveFromEnvironment(string propertyName) { return this.xmsInitialContext.RemoveFromEnvironment(propertyName); } #endregion #region IDisposable public void Dispose() { this.xmsInitialContext.Close(); } #endregion } }