import java.util.Hashtable;
import java.util.Map;
import com.sap.conn.jco.JCo;
import com.sap.conn.jco.JCoCustomRepository;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoFunctionTemplate;
import com.sap.conn.jco.JCoListMetaData;
import com.sap.conn.jco.JCoMetaData;
import com.sap.conn.jco.server.DefaultServerHandlerFactory;
import com.sap.conn.jco.server.JCoServer;
import com.sap.conn.jco.server.JCoServerContext;
import com.sap.conn.jco.server.JCoServerContextInfo;
import com.sap.conn.jco.server.JCoServerErrorListener;
import com.sap.conn.jco.server.JCoServerExceptionListener;
import com.sap.conn.jco.server.JCoServerFactory;
import com.sap.conn.jco.server.JCoServerFunctionHandler;
import com.sap.conn.jco.server.JCoServerState;
import com.sap.conn.jco.server.JCoServerStateChangedListener;
import com.sap.conn.jco.server.JCoServerTIDHandler;
public class StepByStepServer
{
static String SERVER_NAME1 = "SERVER";
static String DESTINATION_NAME1 = "ABAP_AS_WITHOUT_POOL";
static String DESTINATION_NAME2 = "ABAP_AS_WITH_POOL";
static MyTIDHandler myTIDHandler = null;
/**
* This class provides the implementation for the function STFC_CONNECTION. You will
* find the RFC-enabled function STFC_CONNECTION in almost any ABAP system. The
* function is pretty simple - it has 1 input parameter and 2 output parameter. The content
* of the input parameter REQUTEXT is copied to the output parameter ECHOTEXT. The
* output parameter RESPTEXT is set to "Hello World".
*/
static class StfcConnectionHandler implements JCoServerFunctionHandler
{
public void handleRequest(JCoServerContext serverCtx, JCoFunction function)
{
System.out.println("----------------------------------------------------------------");
System.out.println("call : " + function.getName());
System.out.println("ConnectionId : " + serverCtx.getConnectionID());
System.out.println("SessionId : " + serverCtx.getSessionID());
System.out.println("TID : " + serverCtx.getTID());
System.out.println("repository name : " + serverCtx.getRepository().getName());
System.out.println("is in transaction : " + serverCtx.isInTransaction());
System.out.println("is stateful : " + serverCtx.isStatefulSession());
System.out.println("----------------------------------------------------------------");
System.out.println("gwhost: " + serverCtx.getServer().getGatewayHost());
System.out.println("gwserv: " + serverCtx.getServer().getGatewayService());
System.out.println("progid: " + serverCtx.getServer().getProgramID());
System.out.println("----------------------------------------------------------------");
System.out.println("attributes : ");
System.out.println(serverCtx.getConnectionAttributes().toString());
System.out.println("----------------------------------------------------------------");
System.out.println("CPIC conversation ID: " + serverCtx.getConnectionAttributes().getCPICConversationID());
System.out.println("----------------------------------------------------------------");
System.out.println("req text: " + function.getImportParameterList().getString("REQUTEXT"));
function.getExportParameterList().setValue("ECHOTEXT", function.getImportParameterList().getString("REQUTEXT"));
function.getExportParameterList().setValue("RESPTEXT", "Hello World");
// In sample 3 (tRFC Server) we also set the status to executed:
if(myTIDHandler != null)
myTIDHandler.execute(serverCtx);
}
}
/**
* First server example. At first we get an instance of the JCoServer through JCoServerFactory. The requested instance
* will be created, or an existing one will be returned if the instance was created before. It is not possible to
* run more then one instance with a particular configuration. Then we register the implementation for the
* function STFC_CONNECTION provided by class StfcConnectionHandler through FunctionHandlerFactory
* provided by JCo. You are free to write your own implementation JCoServerFunctionHandlerFactory, if you need more
* than simple mapping between function name and java class implementing the function.
* Now we can start the server instance. After a while the JCo runtime opens the server connections. You may
* check the server connections via sm59 or invoke STFC_CONNECTION via se37.
*/
static void step1SimpleServer()
{
JCoServer server;
try
{
server = JCoServerFactory.getServer(SERVER_NAME1);
}
catch(JCoException ex)
{
throw new RuntimeException("Unable to create the server " + SERVER_NAME1 + " because of " + ex.getMessage(), ex);
}
JCoServerFunctionHandler stfcConnectionHandler = new StfcConnectionHandler();
DefaultServerHandlerFactory.FunctionHandlerFactory factory = new DefaultServerHandlerFactory.FunctionHandlerFactory();
factory.registerHandler("STFC_CONNECTION", stfcConnectionHandler);
server.setCallHandlerFactory(factory);
server.start();
System.out.println("The program can be stoped using <ctrl>+<c>");
}
static class MyThrowableListener implements JCoServerErrorListener, JCoServerExceptionListener
{
public void serverErrorOccurred(JCoServer jcoServer, String connectionId, JCoServerContextInfo serverCtx, Error error)
{
System.out.println(">>> Error occured on " + jcoServer.getProgramID() + " connection " + connectionId);
error.printStackTrace();
}
public void serverExceptionOccurred(JCoServer jcoServer, String connectionId, JCoServerContextInfo serverCtx, Exception error)
{
System.out.println(">>> Error occured on " + jcoServer.getProgramID() + " connection " + connectionId);
error.printStackTrace();
}
}
static class MyStateChangedListener implements JCoServerStateChangedListener
{
public void serverStateChangeOccurred(JCoServer server, JCoServerState oldState, JCoServerState newState)
{
// Defined states are: STARTED, DEAD, ALIVE, STOPPED;
// see JCoServerState class for details.
// Details for connections managed by a server instance
// are available via JCoServerMonitor.
System.out.println("Server state changed from " + oldState.toString() + " to " + newState.toString() + " on server with program id "
+ server.getProgramID());
}
}
static void step2SimpleServer()
{
JCoServer server;
try
{
server = JCoServerFactory.getServer(SERVER_NAME1);
}
catch(JCoException ex)
{
throw new RuntimeException("Unable to create the server " + SERVER_NAME1 + " because of " + ex.getMessage(), ex);
}
JCoServerFunctionHandler stfcConnectionHandler = new StfcConnectionHandler();
DefaultServerHandlerFactory.FunctionHandlerFactory factory = new DefaultServerHandlerFactory.FunctionHandlerFactory();
factory.registerHandler("STFC_CONNECTION", stfcConnectionHandler);
server.setCallHandlerFactory(factory);
// additionally to step 1
MyThrowableListener eListener = new MyThrowableListener();
server.addServerErrorListener(eListener);
没有合适的资源?快使用搜索试试~ 我知道了~
sapjco3-3.0.19和dll版本721.1120及619和913
共245个文件
html:222个
java:6个
jar:4个
需积分: 15 10 下载量 127 浏览量
2022-09-15
16:39:20
上传
评论
收藏 16.04MB ZIP 举报
温馨提示
sapjco3-3.0.19和dll版本721.1120及619和913
资源详情
资源评论
资源推荐
收起资源包目录
sapjco3-3.0.19和dll版本721.1120及619和913 (245个子文件)
sap.css 4KB
sapjco3.dll 4.74MB
sapjco3.dll 4.67MB
sapjco3.dll 4.55MB
inherit.gif 57B
index-all.html 375KB
JCoRecord.html 135KB
releasenotes.html 96KB
JCo.html 87KB
DestinationDataProvider.html 80KB
JCoException.html 78KB
constant-values.html 73KB
JCoMetaData.html 67KB
JCoDestination.html 60KB
JCoServer.html 59KB
JCoField.html 49KB
JCoListMetaData.html 43KB
Environment.html 38KB
ServerDataProvider.html 36KB
JCoTable.html 34KB
JCoClassMetaData.html 33KB
JCoRecordMetaData.html 32KB
overview-tree.html 30KB
JCoRepository.html 30KB
JCoAttributes.html 30KB
JCoException.html 30KB
JCoConnectionData.html 29KB
package-use.html 28KB
AbapClassException.html 27KB
JCoRequest.html 25KB
JCoFunction.html 24KB
package-summary.html 24KB
JCoCustomDestination.html 24KB
JCoParameterList.html 24KB
JCoDestinationManager.html 24KB
JCoServerContext.html 23KB
DefaultServerHandlerFactory.html 23KB
JCoRuntimeException.html 22KB
JCoDestination.html 22KB
AbapException.html 21KB
JCoDestinationMonitor.html 21KB
JCoCustomRepository.html 21KB
DefaultSessionReferenceProvider.html 20KB
JCoBackgroundUnitAttributes.html 20KB
JCoStructure.html 19KB
JCoCustomDestination.UserData.html 18KB
JCoRecordMetaData.html 18KB
package-summary.html 18KB
JCoAbapObject.html 18KB
JCoFunctionTemplate.html 18KB
package-tree.html 18KB
SessionReferenceProvider.html 18KB
JCoResponse.html 18KB
SessionException.Type.html 18KB
JCoServerUnitIDHandler.html 18KB
JCoListMetaData.html 18KB
JCoServerFactory.html 17KB
JCoUnitIdentifier.html 17KB
DefaultServerHandlerFactory.FunctionHandlerFactory.html 17KB
DefaultServerHandlerFactory.RequestHandlerFactory.html 17KB
package-summary.html 17KB
AbapException.html 17KB
JCoRuntimeException.html 17KB
JCoServerContextInfo.html 17KB
JCoFunctionUnit.html 17KB
JCoRequestUnit.html 17KB
JCoParameterField.html 16KB
JCoRepositoryQueryResult.html 16KB
DataProviderException.Reason.html 16KB
DataProviderException.html 16KB
JCoTraceListener.html 16KB
JCoServerState.html 16KB
JCoRemoteContext.html 16KB
JCoCustomRepository.QueryMode.html 15KB
JCoRepository.html 15KB
package-use.html 15KB
JCoFunctionUnitState.html 15KB
JCoServerMonitor.html 15KB
JCoClassMetaData.JCoAttributeKind.html 15KB
JCoRepositoryMonitor.html 15KB
JCoServerCallType.html 15KB
JCoContext.html 15KB
JCoServerAuthorizationData.html 15KB
SessionException.html 15KB
AbapClassException.Mode.html 15KB
allclasses-frame.html 15KB
serialized-form.html 14KB
JCoThroughput.html 14KB
JCoServerTIDHandler.html 14KB
JCoUnitIdentifier.Type.html 14KB
JCoDestinationMonitor.html 14KB
JCoExtendedFieldMetaData.html 14KB
JCoAbapObject.html 14KB
JCoFunction.html 14KB
JCoApplicationAuthorizationException.html 14KB
JCoRecordField.html 14KB
JCoCustomDestination.SncConfigurationData.html 13KB
JCoRequest.html 13KB
JCoClassMetaData.html 13KB
JCoServer.html 13KB
共 245 条
- 1
- 2
- 3
顽玉
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0