1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XCloseable.idl,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef __com_sun_star_util_XClosable_idl__
31 #define __com_sun_star_util_XClosable_idl__
33 #ifndef __com_sun_star_uno_XInterface_idl__
34 #include
<com
/sun
/star
/uno
/XInterface.idl
>
37 #ifndef __com_sun_star_util_XCloseBroadcaster_idl__
38 #include
<com
/sun
/star
/util
/XCloseBroadcaster.idl
>
41 //=============================================================================
43 module com
{ module sun
{ module star
{ module util
{
45 //=============================================================================
46 /** makes it possible to release any objects in a ordered manner by using
50 If an object should be terminated, it can be:<br>
52 <li>disposed (if it supports <member scope="com::sun::star::lang">XComponent::dispose()</member>)</li>
53 <li>closed (if it supports <member>XCloseable::close()</member>)</li>
55 First version gives the object no chance to disagree with that (e.g. if a
56 process is still running and can't be cancelled realy). Last version
57 provides this possibility, but can't guarantee real termination of called object.
58 It depends from the environment of an object, if one or both mechanism are neccessary.
62 Base interface <type>XCloseBroadcaster</type> makes it possible that any listener
63 which is interrested on life time of listened object ...
65 <li>can get a notification about closing of it</li>
66 <li>or can have a veto to break that.</li>
70 @see com::sun::star::lang::XComponent::dispose()
71 @see XCloseBroadcaster
74 published
interface XCloseable
: XCloseBroadcaster
76 //-------------------------------------------------------------------------
77 /** try to close the object
80 Must definitly be called before <member scope="com::sun::star::lang">XComponent::dispose()</member>.
81 But nobody can guarentee real closing of called object - because it can disagree with that if any
82 still running processes can't be cancelled yet. It's not allowed to block this call till internal
83 operations will be finished here. They must be cancelled or call must return imediatly by throwing
84 the <type>CloseVetoException</type>. Otherwise (if nothing exist to disagree) it must return normaly.
88 Before any internal processes will be cancelled, all registered <type>XCloseListener</type>
89 must be notified. Any of them can disagree with a <type>CloseVetoException</type> too.
90 It's forbidden to catch this exception inside the called close() method because the caller must
95 If somewhere disagree with a CloseVetoException it will not clear who has to close the object again
96 after still running processes was finished. The parameter <var>DeliverOwnership</var> regulate that.
97 If it is set to <FALSE/> the caller of the method close() will be the owner of this object in every case.
98 Then it's not allowed to call close() from any other place (may a registered XCloseListener).
99 If it is set to <TRUE/> the caller gives up his ownership. If a XCloseListener throw the veto exception
100 he will be the new owner of the closing object. This information is passed to the listener by a parameter of
101 his notification method <member>XCloseListener::queryClosing()</member>. After his operations was finished
102 he MUST try to close it again. If the closing object itselfs disagree by an exception and the parameter
103 <var>DeliverOwnership</var> was set to <TRUE/> the object will be his own owner with all consequences of that.
104 <br><strong>Note:</strong><br>
105 There is no way to get the ownership back if it was delivered!
109 If this method was already called on an object it should return without any reaction. Normaly it's possible to throw
110 a <type scope="com::sun::star::lang">DisposedException</type> for already disposed or closed objects
111 (which represent a <type scope="com::sun::star::uno">RuntimeException</type> and can be thrown by every interface call),
112 but it shouldn't be used here. The veto exception should be the only way to indicates the result.
115 @param DeliverOwnership
116 <TRUE/> delegates the ownership of ths closing object to any one which throw the CloseVetoException.
117 This new owner has to close the closing object again if his still running processes will be finished.
119 <FALSE/> let the ownership at the original one which called the close() method. He must react for possible
120 CloseVetoExceptions and try it again at a later time. This can be usefull for a generic UI handling.
122 @throws CloseVetoException
123 indicates that the closing object himself or any of his currently registered listener disagree with this close() request.
126 @see CloseVetoException
127 @see com::sun::star::lang::XComponent::dispose()
128 @see com::sun::star::lang::DisposedException
130 void close
( [in] boolean DeliverOwnership
)
131 raises
( CloseVetoException
);
134 //=============================================================================