1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.api.ldap.extras.extended.gracefulShutdown; 21 22 23 import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest; 24 25 26 /** 27 * An extended operation requesting the server to shutdown it's LDAP service 28 * port while allowing established clients to complete or abandon operations 29 * already in progress. More information about this extended request is 30 * available here: <a href="http://docs.safehaus.org:8080/x/GR">LDAP Extensions 31 * for Graceful Shutdown</a>. 32 * 33 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 34 */ 35 public class GracefulShutdownRequestImpl extends AbstractExtendedRequest implements GracefulShutdownRequest 36 { 37 private GracefulShutdownResponse response; 38 39 /** Offline time after disconnection */ 40 private int timeOffline; 41 42 /** Delay before disconnection */ 43 private int delay; 44 45 46 /** 47 * Instantiates a new graceful shutdown request. 48 * 49 * @param messageId the message id 50 */ 51 public GracefulShutdownRequestImpl( int messageId ) 52 { 53 this( messageId, UNDETERMINED, NOW ); 54 } 55 56 57 /** 58 * Instantiates a new graceful shutdown request. 59 * 60 * @param messageId the message id 61 */ 62 public GracefulShutdownRequestImpl() 63 { 64 setRequestName( EXTENSION_OID ); 65 } 66 67 68 /** 69 * Instantiates a new graceful shutdown request. 70 * 71 * @param messageId the message id 72 * @param timeOffline the offline time after disconnection, in minutes 73 * @param delay the delay before disconnection, in seconds 74 */ 75 public GracefulShutdownRequestImpl( int messageId, int timeOffline, int delay ) 76 { 77 super( messageId ); 78 setRequestName( EXTENSION_OID ); 79 this.timeOffline = timeOffline; 80 this.delay = delay; 81 } 82 83 84 // ----------------------------------------------------------------------- 85 // Parameters of the Extended Request Payload 86 // ----------------------------------------------------------------------- 87 88 /** 89 * {@inheritDoc} 90 */ 91 public int getDelay() 92 { 93 return delay; 94 } 95 96 97 /** 98 * {@inheritDoc} 99 */ 100 public void setDelay( int delay ) 101 { 102 this.delay = delay; 103 } 104 105 106 /** 107 * {@inheritDoc} 108 */ 109 public int getTimeOffline() 110 { 111 return timeOffline; 112 } 113 114 115 /** 116 * {@inheritDoc} 117 */ 118 public void setTimeOffline( int timeOffline ) 119 { 120 this.timeOffline = timeOffline; 121 } 122 123 124 @Override 125 public GracefulShutdownResponse getResultResponse() 126 { 127 if ( response == null ) 128 { 129 response = new GracefulShutdownResponseImpl(); 130 } 131 132 return response; 133 } 134 }