Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

cvs commit: ws-fx/sandesha/src/org/apache/sandesha/server Sender.java: msg#00167

apache.webservices.fx.devel

Subject: cvs commit: ws-fx/sandesha/src/org/apache/sandesha/server Sender.java

jaliya 2004/08/18 01:18:23

Added: sandesha/src/org/apache/sandesha/server Sender.java
Log:
This class is used as the sener for Sandesha. Currently used by the server to
send asynchronous responses, acks etc..

Revision Changes Path
1.1 ws-fx/sandesha/src/org/apache/sandesha/server/Sender.java

Index: Sender.java
===================================================================
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* 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.
*
*/
package org.apache.sandesha.server;

import javax.xml.rpc.ServiceException;

import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.sandesha.Constants;
import org.apache.sandesha.IStorageManager;
import org.apache.sandesha.RMMessageContext;

/**
* @author JEkanayake
*
*/
public class Sender implements Runnable {
private IStorageManager storageManager;

public Sender() {
storageManager = new ServerStorageManager();
}

public void run() {

while (true) {
long startTime = System.currentTimeMillis();
boolean hasMessages = true;
do {
RMMessageContext rmMessageContext =
storageManager.getNextMessageToSend();
if (rmMessageContext == null)
hasMessages = false;
else {
//Send the message.

switch
(rmMessageContext.getMessageType()) {
case
Constants.MSG_TYPE_CREATE_SEQUENCE_REQUEST :
{
//Send the
message.
//may get the
reply back to here.

}
case
Constants.MSG_TYPE_CREATE_SEQUENCE_RESPONSE :
{
//Send creat
seq message.
//No response
and we can just close the connection
try {
Service
service = new Service();
Call
call = (Call) service.createCall();

call.setTargetEndpointAddress(rmMessageContext.getOutGoingAddress());

call.setRequestMessage(

rmMessageContext.getMsgContext().getResponseMessage());

call.invoke();
} catch
(ServiceException e1) {

System.out.println("(!)(!)(!)Cannot send the create sequence response.");

e1.printStackTrace();
} catch
(AxisFault e) {

e.printStackTrace();
}
}
case
Constants.MSG_TYPE_TERMINATE_SEQUENCE :
{

}
case
Constants.MSG_TYPE_ACKNOWLEDGEMENT :
{
try {
Service
service = new Service();
Call
call = (Call) service.createCall();

call.setTargetEndpointAddress(rmMessageContext.getOutGoingAddress());

call.setRequestMessage(

rmMessageContext.getMsgContext().getResponseMessage());

call.invoke();
} catch
(ServiceException e1) {

System.out.println("(!)(!)(!)Cannot send the Ack message.");

e1.printStackTrace();
} catch
(AxisFault e) {

e.printStackTrace();
}
}
case
Constants.MSG_TYPE_SERVICE_RESPONSE :
{
}
}

}

} while (hasMessages);

long timeGap = System.currentTimeMillis() - startTime;
if ((timeGap - Constants.SENDER_SLEEP_TIME) <= 0) {
try {
System.out.println("Sender thread is
sleeping .............................");

Thread.sleep(Constants.SENDER_SLEEP_TIME - timeGap);
} catch (Exception ex) {
ex.printStackTrace();
}

}
}
}

}






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
hardware.arm.at...    cms.citadel.dev...    video.gstreamer...    java.facelets.u...    misc.basics.qna...    web.wiki.instik...    network.uip.use...    xdg.devel/2003-...    tex.bibtex.bibd...    finance.quotesp...    ietf.zeroconf/2...    redhat.blinux.g...    suse.db2/2003-0...    php.phpesp/2004...    uml.devel/2003-...    gnome.labyrinth...    qnx.openqnx.dev...    boot-loaders.gr...    db.dataperfect....    audio.audacity....    linux.uclinux.m...    editors.j.devel...    os.openbsd.tech...    kde.users.multi...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation