xref: /aoo4110/main/stoc/source/javavm/interact.cxx (revision b1cdbd2c)
1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski  *
3*b1cdbd2cSJim Jagielski  * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski  * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski  * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski  * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski  * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski  * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski  * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski  *
11*b1cdbd2cSJim Jagielski  *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski  *
13*b1cdbd2cSJim Jagielski  * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski  * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski  * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski  * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski  * under the License.
19*b1cdbd2cSJim Jagielski  *
20*b1cdbd2cSJim Jagielski  *************************************************************/
21*b1cdbd2cSJim Jagielski 
22*b1cdbd2cSJim Jagielski 
23*b1cdbd2cSJim Jagielski 
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_stoc.hxx"
26*b1cdbd2cSJim Jagielski 
27*b1cdbd2cSJim Jagielski #include "interact.hxx"
28*b1cdbd2cSJim Jagielski 
29*b1cdbd2cSJim Jagielski #include "com/sun/star/java/JavaDisabledException.hpp"
30*b1cdbd2cSJim Jagielski #include "com/sun/star/java/JavaVMCreationFailureException.hpp"
31*b1cdbd2cSJim Jagielski #include "com/sun/star/task/XInteractionAbort.hpp"
32*b1cdbd2cSJim Jagielski #include "com/sun/star/task/XInteractionRetry.hpp"
33*b1cdbd2cSJim Jagielski #include "com/sun/star/task/XInteractionContinuation.hpp"
34*b1cdbd2cSJim Jagielski #include "cppuhelper/implbase1.hxx"
35*b1cdbd2cSJim Jagielski #include "osl/mutex.hxx"
36*b1cdbd2cSJim Jagielski 
37*b1cdbd2cSJim Jagielski namespace css = com::sun::star;
38*b1cdbd2cSJim Jagielski 
39*b1cdbd2cSJim Jagielski using stoc_javavm::InteractionRequest;
40*b1cdbd2cSJim Jagielski 
41*b1cdbd2cSJim Jagielski namespace {
42*b1cdbd2cSJim Jagielski 
43*b1cdbd2cSJim Jagielski class AbortContinuation:
44*b1cdbd2cSJim Jagielski     public cppu::WeakImplHelper1< css::task::XInteractionAbort >
45*b1cdbd2cSJim Jagielski {
46*b1cdbd2cSJim Jagielski public:
AbortContinuation()47*b1cdbd2cSJim Jagielski     inline AbortContinuation() {}
48*b1cdbd2cSJim Jagielski 
select()49*b1cdbd2cSJim Jagielski     virtual inline void SAL_CALL select() throw (css::uno::RuntimeException) {}
50*b1cdbd2cSJim Jagielski 
51*b1cdbd2cSJim Jagielski private:
52*b1cdbd2cSJim Jagielski     AbortContinuation(AbortContinuation &); // not implemented
53*b1cdbd2cSJim Jagielski     void operator =(AbortContinuation); // not implemented
54*b1cdbd2cSJim Jagielski 
~AbortContinuation()55*b1cdbd2cSJim Jagielski     virtual inline ~AbortContinuation() {}
56*b1cdbd2cSJim Jagielski };
57*b1cdbd2cSJim Jagielski 
58*b1cdbd2cSJim Jagielski }
59*b1cdbd2cSJim Jagielski 
60*b1cdbd2cSJim Jagielski class InteractionRequest::RetryContinuation:
61*b1cdbd2cSJim Jagielski     public cppu::WeakImplHelper1< css::task::XInteractionRetry >
62*b1cdbd2cSJim Jagielski {
63*b1cdbd2cSJim Jagielski public:
RetryContinuation()64*b1cdbd2cSJim Jagielski     inline RetryContinuation(): m_bSelected(false) {}
65*b1cdbd2cSJim Jagielski 
66*b1cdbd2cSJim Jagielski     virtual void SAL_CALL select() throw (css::uno::RuntimeException);
67*b1cdbd2cSJim Jagielski 
68*b1cdbd2cSJim Jagielski     bool isSelected() const;
69*b1cdbd2cSJim Jagielski 
70*b1cdbd2cSJim Jagielski private:
71*b1cdbd2cSJim Jagielski     RetryContinuation(RetryContinuation &); // not implemented
72*b1cdbd2cSJim Jagielski     void operator =(RetryContinuation); // not implemented
73*b1cdbd2cSJim Jagielski 
~RetryContinuation()74*b1cdbd2cSJim Jagielski     virtual inline ~RetryContinuation() {}
75*b1cdbd2cSJim Jagielski 
76*b1cdbd2cSJim Jagielski     mutable osl::Mutex m_aMutex;
77*b1cdbd2cSJim Jagielski     bool m_bSelected;
78*b1cdbd2cSJim Jagielski };
79*b1cdbd2cSJim Jagielski 
select()80*b1cdbd2cSJim Jagielski void SAL_CALL InteractionRequest::RetryContinuation::select()
81*b1cdbd2cSJim Jagielski     throw (css::uno::RuntimeException)
82*b1cdbd2cSJim Jagielski {
83*b1cdbd2cSJim Jagielski     osl::MutexGuard aGuard(m_aMutex);
84*b1cdbd2cSJim Jagielski     m_bSelected = true;
85*b1cdbd2cSJim Jagielski }
86*b1cdbd2cSJim Jagielski 
isSelected() const87*b1cdbd2cSJim Jagielski bool InteractionRequest::RetryContinuation::isSelected() const
88*b1cdbd2cSJim Jagielski {
89*b1cdbd2cSJim Jagielski     osl::MutexGuard aGuard(m_aMutex);
90*b1cdbd2cSJim Jagielski     return m_bSelected;
91*b1cdbd2cSJim Jagielski }
92*b1cdbd2cSJim Jagielski 
InteractionRequest(css::uno::Any const & rRequest)93*b1cdbd2cSJim Jagielski InteractionRequest::InteractionRequest(css::uno::Any const & rRequest):
94*b1cdbd2cSJim Jagielski     m_aRequest(rRequest)
95*b1cdbd2cSJim Jagielski {
96*b1cdbd2cSJim Jagielski     m_aContinuations.realloc(2);
97*b1cdbd2cSJim Jagielski     m_xRetryContinuation = new RetryContinuation;
98*b1cdbd2cSJim Jagielski     m_aContinuations[0] = new AbortContinuation;
99*b1cdbd2cSJim Jagielski     m_aContinuations[1] = m_xRetryContinuation.get();
100*b1cdbd2cSJim Jagielski }
101*b1cdbd2cSJim Jagielski 
getRequest()102*b1cdbd2cSJim Jagielski css::uno::Any SAL_CALL InteractionRequest::getRequest()
103*b1cdbd2cSJim Jagielski     throw (css::uno::RuntimeException)
104*b1cdbd2cSJim Jagielski {
105*b1cdbd2cSJim Jagielski     return m_aRequest;
106*b1cdbd2cSJim Jagielski }
107*b1cdbd2cSJim Jagielski 
108*b1cdbd2cSJim Jagielski css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >
getContinuations()109*b1cdbd2cSJim Jagielski SAL_CALL InteractionRequest::getContinuations()
110*b1cdbd2cSJim Jagielski     throw (css::uno::RuntimeException)
111*b1cdbd2cSJim Jagielski {
112*b1cdbd2cSJim Jagielski     return m_aContinuations;
113*b1cdbd2cSJim Jagielski }
114*b1cdbd2cSJim Jagielski 
retry() const115*b1cdbd2cSJim Jagielski bool InteractionRequest::retry() const
116*b1cdbd2cSJim Jagielski {
117*b1cdbd2cSJim Jagielski     return m_xRetryContinuation.is() && m_xRetryContinuation->isSelected();
118*b1cdbd2cSJim Jagielski }
119*b1cdbd2cSJim Jagielski 
~InteractionRequest()120*b1cdbd2cSJim Jagielski InteractionRequest::~InteractionRequest()
121*b1cdbd2cSJim Jagielski {}
122