001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    package org.apache.directory.server.core.interceptor.context;
021    
022    
023    import org.apache.directory.server.core.CoreSession;
024    import org.apache.directory.server.core.partition.Partition;
025    
026    
027    /**
028     * A AddContextPartition context used for Interceptors. It contains all the informations
029     * needed for the addContextPartition operation, and used by all the interceptors.  If 
030     * it does not have a partition set for it, then it will load and instantiate it 
031     * automatically using the information in the partition configuration.
032     *
033     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
034     * @version $Rev$, $Date$
035     */
036    public class AddContextPartitionOperationContext extends EmptyOperationContext
037    {
038        /** the instantiated partition class */
039        private Partition partition;
040           
041        
042        /**
043         * Creates a new instance of AddContextPartitionOperationContext.
044         *
045         * @param partition The partition to add
046         */
047        public AddContextPartitionOperationContext( CoreSession session, Partition partition )
048        {
049            super( session );
050            this.partition = partition;
051        }
052        
053        
054        /**
055         * @see Object#toString()
056         */
057        public String toString()
058        {
059            return "AddContextPartitionOperationContext for partition context '" + partition.getId() + "'";
060        }
061    
062        
063        /**
064         * @return The partition
065         */
066        public Partition getPartition()
067        {
068            return partition;
069        }
070    
071        
072        /**
073         * Set the partition.
074         * 
075         * @param partition the partition
076         */
077        public void setPartitionConfiguration( Partition partition )
078        {
079            this.partition = partition;
080        }
081        
082        
083        /**
084         * @return the operation name
085         */
086        public String getName()
087        {
088            return "AddContextPartition";
089        }
090    }