/** * Block until a message is received. * Hangs on the remote receive message call. * @return The next message. */ public Message receiveMessage() { Message message = null; try { message = m_receiveQueue.receiveRemoteMessage(); // Hang until a message comes through } catch (RemoteException ex) { ex.printStackTrace(); return null; // Remote exception = I'm done } if (message != null) ((BaseMessage)message).setProcessedByServer(true); // Don't send the message back down. return message; } }
/** * Free the receiver (and the remote session). */ public void free() { if (m_sendQueue != null) { try { m_sendQueue.freeRemoteSession(); } catch (RemoteException ex) { ex.printStackTrace(); } } m_sendQueue = null; super.free(); } /**
/** * Creates new MessageSender. * @param server The remote server. * @param baseMessageQueue My parent message queue. */ public void init(RemoteTask server, BaseMessageQueue baseMessageQueue) throws RemoteException { super.init(baseMessageQueue); m_sendQueue = server.createRemoteSendQueue(baseMessageQueue.getQueueName(), baseMessageQueue.getQueueType()); } /**
if (CLOSE.equals(strCommand)) ((RemoteDatabase)m_remoteObject).close(); Map<String,Object> propIn = ((RemoteDatabase)m_remoteObject).getDBProperties(); this.setReturnObject(out, propIn); if (propIn != null) properties.putAll(propIn); ((RemoteDatabase)m_remoteObject).setDBProperties(properties); ((RemoteDatabase)m_remoteObject).commit(); ((RemoteDatabase)m_remoteObject).rollback();
RemoteTable bookingDetailSession = (RemoteTable)remoteSession.doRemoteAction(BookingConstants.GET_DETAIL_COMMAND, properties); Object objReturn = bookingDetailSession.doRemoteAction(SearchConstants.ADD_COMMAND, properties); if (strDate != null)
/** * Handle the command send from my client peer. * @param in The (optional) Inputstream to get the params from. * @param out The stream to write the results. */ public void doProcess(InputStream in, PrintWriter out, Map<String, Object> properties) throws RemoteException { String strCommand = this.getProperty(REMOTE_COMMAND, properties); if (GET_REMOTE_TABLE.equals(strCommand)) { String strName = this.getNextStringParam(in, NAME, properties); RemoteTable remoteTable = ((RemoteSession)m_remoteObject).getRemoteTable(strName); // First, see if this is in my list already? String strID = this.find(remoteTable); if (strID == null) strID = this.add(new TableHolder(this, remoteTable)); this.setReturnString(out, strID); } else if (SETUP_REMOTE_SESSION_FILTER.equals(strCommand)) { org.jbundle.thin.base.message.BaseMessageFilter filter = (org.jbundle.thin.base.message.BaseMessageFilter)this.getNextObjectParam(in, FILTER, properties); filter = ((RemoteSession)m_remoteObject).setupRemoteSessionFilter(filter); this.setReturnObject(out, filter); } else super.doProcess(in, out, properties); } }
/** * Handle the command send from my client peer. * @param in The (optional) Inputstream to get the params from. * @param out The stream to write the results. */ public void doProcess(InputStream in, PrintWriter out, Map<String, Object> properties) throws RemoteException { String strCommand = this.getProperty(REMOTE_COMMAND, properties); if (SEND_MESSAGE.equals(strCommand)) { BaseMessage message = (BaseMessage)this.getNextObjectParam(in, MESSAGE, properties); ((RemoteSendQueue)m_remoteObject).sendMessage(message); } else super.doProcess(in, out, properties); } }
/** * Constructor. * @param server The remote server. * @param baseMessageQueue My parent message queue. */ public void init(RemoteTask server, BaseMessageQueue baseMessageQueue) throws RemoteException { super.init(baseMessageQueue); m_receiveQueue = server.createRemoteReceiveQueue(baseMessageQueue.getQueueName(), baseMessageQueue.getQueueType()); } /**
/** * Update this filter with this new information. * Override this to do something if there is a remote version of this filter. * @param messageFilter The message filter I am updating. * @param properties New filter information (ie, bookmark=345). */ public void setNewFilterProperties(BaseMessageFilter messageFilter, Object[][] mxProperties, Map<String, Object> propFilter) { super.setNewFilterProperties(messageFilter, mxProperties, propFilter); // Does nothing. try { if (messageFilter.isUpdateRemoteFilter()) // Almost always true if (messageFilter.getRemoteFilterID() != null) // If the remote filter exists m_receiveQueue.updateRemoteFilterProperties(messageFilter, mxProperties, propFilter); } catch (RemoteException ex) { ex.printStackTrace(); } } /**
/** * Process this action. * @param strAction The action to process. * By default, this method handles RESET, SUBMIT, and DELETE. */ public boolean doAction(String strAction, int iOptions) { if (GET_RATE.equalsIgnoreCase(strAction)) { Map properties = new HashMap(); this.addScreenFieldProperty(properties, "HotelID", "HotelID"); this.addScreenFieldProperty(properties, "HotelRate", "HotelRate"); this.addScreenFieldProperty(properties, "HotelClass", "HotelClass"); this.addScreenFieldProperty(properties, "StartDate", "StartDate"); try { //+ synchronized(m_remoteSession) { m_remoteSession.doRemoteAction(strAction, properties); } } catch (Exception ex) { ex.printStackTrace(); } } return super.doAction(strAction, iOptions); } /**
/** * Remove this message filter from this queue. * Also remove the remote message filter. * @param messageFilter The message filter to remove. * @param bFreeFilter If true, free this filter. * @return True if successful. */ public boolean removeMessageFilter(MessageFilter messageFilter, boolean bFreeFilter) { boolean bSuccess = false; try { if (((BaseMessageFilter)messageFilter).getRemoteFilterID() == null) bSuccess = true; // No remote filter to remove else bSuccess = m_receiveQueue.removeRemoteMessageFilter((BaseMessageFilter)messageFilter, bFreeFilter); } catch (RemoteException ex) { ex.printStackTrace(); } if (!bSuccess) Util.getLogger().warning("Remote listener not removed"); // Never return super.removeMessageFilter(messageFilter, bFreeFilter); } /**
RemoteTable remoteTable = m_remoteSession.getRemoteTable(null); // Main table (BookingMenuLookup)
/** * Start this service. * Override this to do all the startup. * @return true if successful. */ public Application startupThisApp(Environment env, Map<String, Object> props) { Application application = new MessageInfoApplication(env, props, null); if (env.getDefaultApplication() != null) if (env.getDefaultApplication() != application) { RemoteTask server = (RemoteTask)application.getRemoteTask(null); RemoteTask appServer = (RemoteTask)env.getDefaultApplication().getRemoteTask(null, null, false); if ((server != null) && (appServer != null)) { try { // Tell the remote session who my main session is // so it can know where not to send server record // messages (to eliminate echos in the client). appServer.setRemoteMessageTask(server); // Should have done all the apps in this env! } catch (RemoteException ex) { ex.printStackTrace(); } } } return application; } }
/** * Add this message filter to this receive queue. * Also adds a message filter to the remote queue. * @param The message filter to add. * @return The message filter passed in. */ public void addMessageFilter(MessageFilter messageFilter) { super.addMessageFilter(messageFilter); try { // If at all possible, pass the queue's current session, so the filter is in the proper environment if (((BaseMessageFilter)messageFilter).isCreateRemoteFilter()) // Almost always true { // Create the remote version of this filter. RemoteSession remoteSession = (RemoteSession)((BaseMessageFilter)messageFilter).getRemoteSession(); BaseMessageFilter remoteFilter = m_receiveQueue.addRemoteMessageFilter((BaseMessageFilter)messageFilter, remoteSession); ((BaseMessageFilter)messageFilter).setRemoteFilterInfo(remoteFilter.getQueueName(), remoteFilter.getQueueType(), remoteFilter.getFilterID(), remoteFilter.getRegistryID()); } } catch (RemoteException ex) { ex.printStackTrace(); } } /**
/** * Get the remote session. */ public RemoteSession getRemoteSession(FieldList recBookingDetail) { if (m_remoteSession == null) if (recBookingDetail != null) { String strDetailType = recBookingDetail.getClass().getName(); strDetailType = strDetailType.substring(strDetailType.lastIndexOf('.') + 1); TourGeekScreen TourGeekScreen = (TourGeekScreen)this.getTargetScreen(TourGeekScreen.class); RemoteSession parentSessionObject = TourGeekScreen.getRemoteSession(); try { m_remoteSession = (RemoteSession)parentSessionObject.makeRemoteSession("com.tourgeek.tour.booking.remote.booking.detail." + strDetailType + "Session"); } catch (RemoteException ex) { ex.printStackTrace(); } } return m_remoteSession; } /**
/** * Free the receiver (and the remote session). */ public void free() { this.stopThisThread(); // This needs to be called first (even though super.free() calls it). super.free(); // Free all the filters next (This is also tell the remotesessions to clean up). if (m_receiveQueue != null) { try { m_receiveQueue.freeRemoteSession(); } catch (RemoteException ex) { ex.printStackTrace(); } } m_receiveQueue = null; } /**
/** * Block until a message is received. * Hangs on the remote receive message call. * @return The next message. */ public Message receiveMessage() { Message message = null; try { message = m_receiveQueue.receiveRemoteMessage(); // Hang until a message comes through } catch (RemoteException ex) { ex.printStackTrace(); return null; // Remote exception = I'm done! } if (message instanceof BaseMessage) ((BaseMessage)message).setProcessedByServer(true); // Don't send the message back down. return message; } /**
/** * Send this message to the remote send queue (who will pass it on). * @param message The message to send. */ public void sendMessage(Message message) { try { if (((RemoteMessageQueue)this.getMessageQueue()).isSendRemoteMessage((BaseMessage)message) == false) return; if (((BaseMessage)message).isProcessedByServer()) return; // Don't send back down (the server already processed it). if (((BaseMessage)message).isConsumed()) return; // Don't send if already handled. if (MessageConstants.LOCAL_QUEUE.equalsIgnoreCase(((BaseMessage)message).getMessageHeader().getQueueType())) return; // Local queue only synchronized (m_sendQueue) { // In case this is called from another task m_sendQueue.sendMessage(message); } } catch (RemoteException ex) { ex.printStackTrace(); } } }
/** * Make the remote session. */ public RemoteSession createRemoteSession(JBaseScreen parentScreen) { RemoteSession remoteSession = null; if (parentScreen == null) return null; RemoteSession parentSessionObject = ((JMainSearchPane)parentScreen).getTourGeekScreen().getRemoteSession(); String strTableName = this.getRemoteTableName(); if (strTableName != null) { String strRemoteSession = "com.tourgeek.tour.product.remote.search." + strTableName + "SearchSession"; try { remoteSession = (RemoteSession)parentSessionObject.makeRemoteSession(strRemoteSession); // RemoteTable remoteTable = remoteSession.getRemoteTable(strTableName); // this.setFieldList(remoteTable.makeFieldList(null)); // remoteTable = new com.tourgeek.thin.base.db.client.CachedRemoteTable(remoteTable); // new com.tourgeek.thin.base.db.client.RemoteFieldTable(this.getFieldList(), remoteTable, applet); } catch (RemoteException ex) { ex.printStackTrace(); } } return remoteSession; } /**
RemoteSession parentSessionObject = TourGeekScreen.getRemoteSession(); try { m_remoteSession = (RemoteSession)parentSessionObject.makeRemoteSession("com.tourgeek.tour.booking.remote.booking.BookingLineSession");