com.cbse.jeasy
Class JEHttpClient

java.lang.Object
  extended by com.cbse.jeasy.JEObject
      extended by com.cbse.jeasy.JEHttpClient
All Implemented Interfaces:
java.lang.Runnable

public class JEHttpClient
extends JEObject
implements java.lang.Runnable

A class using for connection between JEasy presentation layer and application layer. The JEHttpClient connects to the JEHttpConnector running as a servlet at an application server. The parameter service and sXml are transfered

Version:
%I%, %G%
Author:
H.Pfohl

Field Summary
 
Fields inherited from class com.cbse.jeasy.JEObject
DEVELOPPING, INPUT_ERROR_DATE, INPUT_ERROR_LENGTH, INPUT_ERROR_MANDATORY, INPUT_ERROR_PARSE, INPUT_ERROR_RANGE, INPUT_ERROR_TIME, INPUT_ERRORS, NO_INPUT_ERROR, RUNNING
 
Constructor Summary
JEHttpClient(java.lang.String s)
          Reads the properties from a string.
 
Method Summary
 java.lang.String callAndWait()
          Use this method to call the server and wait for a return.
 byte[] compress(byte[] ba)
           
 byte[] compress(byte[] ba, javax.crypto.Cipher ec)
           
 byte[] compress(java.lang.String s)
           
 byte[] compress(java.lang.String s, javax.crypto.Cipher ec)
           
 byte[] decompress(byte[] ba)
           
 byte[] decompress(java.io.InputStream in)
           
 byte[] decompress(java.io.InputStream in, javax.crypto.Cipher dc)
           
 byte[] decrypt(byte[] ba, javax.crypto.Cipher decryptCipher)
           
 java.lang.String decrypt(java.io.InputStream in, javax.crypto.Cipher dc)
           
 byte[] encrypt(byte[] ba, javax.crypto.Cipher encryptCipher)
           
 java.lang.String getSessionId()
           
 java.net.URL getURL()
           
 boolean isAlive()
          If b is true the method requests a session id from the JEHttpConnector, who will instantiate a JEDispatcher object at the server.
 void readAttachment()
          Transfers byte from the JEHttpConnector to the clients OütputBuffer
 void run()
          When running as a thread this method is called when the client starts the thread.
 java.lang.String sendAttachment(java.lang.String filePath, java.lang.String fileName, java.io.InputStream attachment)
          Transfers byte out of an InputStream to the server and calls the service Use this method to call the server and wait for a return.
 boolean setCrypt(boolean b, java.lang.String key)
          If b is true the data send to and received from the server are crypted
 void setParameters(JECallBack o, java.lang.String service, java.lang.String sXml)
          Because the JEHttpClient is running as a thread, the parameters are to be set here.
 void setParameters(JECallBack o, java.lang.String service, java.lang.String sXml, java.io.OutputStream os)
          Because the JEHttpClient is running as a thread, the parameters are to be set here.
 boolean setSession(boolean b)
          If b is true the method requests a session id from the JEHttpConnector, who will instantiate a JEDispatcher object at the server.
 void setSimulate(boolean simulate)
          Simulates the connection to JEHttpConnector by instatiating a local JEHttpConnector.
 void setSimulateParams(java.lang.String JEHttpConnectorClass, java.lang.String JEDispatcherClass, java.lang.String property)
           
 void setURL(java.lang.String URL)
           
 
Methods inherited from class com.cbse.jeasy.JEObject
backupEntry, clear, deserializeValue, getApplet, getApplLocale, getCenter, getComponent, getEast, getElementAt, getElementSize, getId, getJCallBack, getJClass, getLabel, getMode, getName, getNorth, getObjLocale, getParentId, getPreview, getProjectDirectory, getProperty, getRegisterText, getSouth, getStarted, getTitle, getType, getWest, getXMLtag, isEditable, isEnabled, isEnterprise, isProfessional, isStandard, isVisible, JEadd, JEadd, JEadd, JEadd, JEadd, JEadd, JEadd, JEadd, JEadd, JEadd, JEadd, JEaddTab, removeProperties, removeProperty, restoreEntry, serializeValue, setApplet, setApplLocale, setEditable, setEditable, setEnabled, setEnabled, setFocus, setJCallBack, setMarkable, setMarkable, setMode, setObjLocale, setParentId, setPreview, setProjectDirectory, setProperty, setStarted, setVisible, setVisible, start, wasEntryChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JEHttpClient

public JEHttpClient(java.lang.String s)
Reads the properties from a string.

Parameters:
s - contains properties and values
See Also:
JE#PropertyString
Method Detail

setURL

public void setURL(java.lang.String URL)

setSimulate

public void setSimulate(boolean simulate)
Simulates the connection to JEHttpConnector by instatiating a local JEHttpConnector.


setSimulateParams

public void setSimulateParams(java.lang.String JEHttpConnectorClass,
                              java.lang.String JEDispatcherClass,
                              java.lang.String property)

getURL

public java.net.URL getURL()

setParameters

public void setParameters(JECallBack o,
                          java.lang.String service,
                          java.lang.String sXml)
Because the JEHttpClient is running as a thread, the parameters are to be set here.

Parameters:
o - the JECallBack object (your JEasy client class) who's callBackInvoke method is called with the return string of the JEDispatcher
service - the service id the JEDispatcher performs. In general it is a method of JEDispatcher.
sXml - an xml string holding all parameters you need for this service. The JEDispatcher has to read xml and has to know about the tagnames

setParameters

public void setParameters(JECallBack o,
                          java.lang.String service,
                          java.lang.String sXml,
                          java.io.OutputStream os)
Because the JEHttpClient is running as a thread, the parameters are to be set here.

Parameters:
o - the JECallBack object (your JEasy client class) who's callBackInvoke method is called with the return string of the JEDispatcher
service - the service id the JEDispatcher performs. In general it is a method of JEDispatcher.
sXml - an xml string holding all parameters you need for this service. The JEDispatcher has to read xml and has to know about the tagnames
os - OutputStream to receive the attachment

setCrypt

public boolean setCrypt(boolean b,
                        java.lang.String key)
If b is true the data send to and received from the server are crypted


isAlive

public boolean isAlive()
If b is true the method requests a session id from the JEHttpConnector, who will instantiate a JEDispatcher object at the server. If b is false the session is released at the client and the server.

Returns:
false if no connection to the server

setSession

public boolean setSession(boolean b)
If b is true the method requests a session id from the JEHttpConnector, who will instantiate a JEDispatcher object at the server. If b is false the session is released at the client and the server.

Returns:
false if no connection to the server

run

public void run()
When running as a thread this method is called when the client starts the thread. The parameter service and xml are send to the JEHttpConnector who transfers them to the JEDispatcher. The response is send to the clients method callBackInvoke.

Specified by:
run in interface java.lang.Runnable

callAndWait

public java.lang.String callAndWait()
                             throws java.lang.Exception
Use this method to call the server and wait for a return. The parameter service and xml are send to the JEHttpConnector who transfers them to the JEDispatcher. The response is returned to the caller.

Throws:
java.lang.Exception

readAttachment

public void readAttachment()
Transfers byte from the JEHttpConnector to the clients OütputBuffer


sendAttachment

public java.lang.String sendAttachment(java.lang.String filePath,
                                       java.lang.String fileName,
                                       java.io.InputStream attachment)
                                throws java.lang.Exception
Transfers byte out of an InputStream to the server and calls the service Use this method to call the server and wait for a return. The parameter service and xml are send to the JEHttpConnector who transfers them to the JEDispatcher. The response is returned to the caller.

Throws:
java.lang.Exception

compress

public byte[] compress(byte[] ba,
                       javax.crypto.Cipher ec)
                throws java.lang.Exception
Throws:
java.lang.Exception

compress

public byte[] compress(java.lang.String s)
                throws java.lang.Exception
Throws:
java.lang.Exception

compress

public byte[] compress(java.lang.String s,
                       javax.crypto.Cipher ec)
                throws java.lang.Exception
Throws:
java.lang.Exception

decompress

public byte[] decompress(java.io.InputStream in)
                  throws java.lang.Exception
Throws:
java.lang.Exception

decompress

public byte[] decompress(java.io.InputStream in,
                         javax.crypto.Cipher dc)
                  throws java.lang.Exception
Throws:
java.lang.Exception

compress

public byte[] compress(byte[] ba)

decompress

public byte[] decompress(byte[] ba)

decrypt

public java.lang.String decrypt(java.io.InputStream in,
                                javax.crypto.Cipher dc)
                         throws java.lang.Exception
Throws:
java.lang.Exception

decrypt

public byte[] decrypt(byte[] ba,
                      javax.crypto.Cipher decryptCipher)
               throws java.lang.Exception
Throws:
java.lang.Exception

encrypt

public byte[] encrypt(byte[] ba,
                      javax.crypto.Cipher encryptCipher)
               throws java.lang.Exception
Throws:
java.lang.Exception

getSessionId

public java.lang.String getSessionId()