summaryrefslogtreecommitdiffstats
path: root/tags/cpp-sca-20060405/runtime/axis_binding/handler/src/SCAWSHandler.cpp
blob: ed57c0677ee0c56962a8d9eed35e337bdc2aaa5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 *
 *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
 *
 *  Licensed 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.
 */

/* $Rev$ $Date$ */

#include "SCAWSHandler.h"
#include <axis/Handler.hpp>
#include <string>

AXIS_CPP_NAMESPACE_USE
using std::string;

/** Construct an SCAWSHandler.
 */
SCAWSHandler::SCAWSHandler()
{ 
    return; 
}

/** Destruct an SCAWSHandler.
 */
SCAWSHandler::~SCAWSHandler()
{
}


/** Perform any necessary initialization.
 */
int SCAWSHandler::init()
{
    return AXIS_SUCCESS;
}

/** Perform any necessary finalization.
 */
int SCAWSHandler::fini()
{
    return AXIS_SUCCESS;
}

/** Get the SCA specific properties that were set in the deployment
 *  descriptor (server.wsdd) and set them into the MessageData where 
 *  they can be retrieved by the SCAWSWrapper to invoke the correct
 *  SCA Entry Point.
 *  @param pvIMsg - pointer to IMessageData
 *
 *  @see SCAWSWrapper
 */
int SCAWSHandler::invoke(void *pvIMsg)
{    
    IMessageData *pIMsg = (IMessageData*) pvIMsg;

    if(pIMsg->isPastPivot()) 
    {
        // This is a response.
    } 
    else 
    {
        // This is a request
        
        //
        // Get the SCA specific properties from the handler.
        //

        // NOTE: WE CANNOT MAKE THE SIMPLE 'GETOPTION' CALLS BECAUSE THE 
        // STD::MAP CODE WILL CAUSE AN ACCESS VIOLATION IN AXISSERVER.DLL.
        // THE GETOPTION METHOD IN HANDLER.HPP NEEDS TO BE MOVED INTO
        // AXISSERVER.DLL AND BE EXPORTED.
        //const string& strTargetNamespace = getOption("targetNamespace");
        //const string& strSCAEntryPoint = getOption("scaEntryPoint");

        // HACK
        // BECAUSE WE CANNOT MAKE ANY MAP CALLS THAT REQUIRE PARAMETERS AND
        // CANNOT SEEM TO ITERATE OVER THE MAP IN A FOR LOOP EITHER WITHOUT
        // TRAPPING, WE RESORT TO READING THE FIRST AND LAST PROPERTIES. 
        // THIS IS ACCEPTABLE AS A WORKAROUND FOR NOW BECAUSE WE ONLY
        // HAVE TWO PROPERTIES.
        string strName;
        string strValue;
        // Read the first property in the map and set its name and value
        // into the IMessageData.
        map<string, string>::const_iterator it = m_pOption->begin();
        strName = (*it).first;
        strValue = (*it).second;
        pIMsg->setProperty(strName.c_str(), strValue.c_str());
        // Read the last property in the map and set its name and value
        // into the IMessageData.
        map<string, string>::const_reverse_iterator itr = m_pOption->rbegin();
        strName = (*itr).first;
        strValue = (*itr).second;
        pIMsg->setProperty(strName.c_str(), strValue.c_str());
        // END HACK
    }

    return AXIS_SUCCESS;
}

/** Handle Faults.
 */
void SCAWSHandler::onFault(void *pvIMsg)
{

}

//
// These functions are exported from the SCAWSHandler DLL and are called by the Axis Engine
// to create/destroy instances of the SCAWSHandler class.
//
extern "C" 
{
STORAGE_CLASS_INFO
int GetClassInstance(BasicHandler **inst)
{
    *inst = new BasicHandler();
    
    SCAWSHandler* pSCAWSHandler = new SCAWSHandler();
    (*inst)->_functions = 0;
    if (pSCAWSHandler)
    {
        (*inst)->_object = pSCAWSHandler;
        return pSCAWSHandler->init();
    }
    
    return AXIS_FAIL;
}

STORAGE_CLASS_INFO
int DestroyInstance(BasicHandler *inst)
{
    if (inst)
    {
        Handler* pH = static_cast<Handler*>(inst->_object);
        pH->fini();
        delete pH;
        delete inst;
        return AXIS_SUCCESS;
    }
    return AXIS_FAIL;
}
} // extern "C"