Get a remote session from the pool and initialize it.
If the pool is empty, create a new remote session.
@param strUserID The user name/ID of the user, or null if unknown.
@return The remote Task.
551175
public RemoteTask getNewRemoteTask(Map<String,Object> properties)
    {
        try   {
            if (m_app != null)
            {   // Make sure remote server has same db properties, etc.
                Map<String,Object> appProperties = m_app.getProperties();
                properties = Utility.copyAppProperties(properties, appProperties);
            }
            Application app = new MainApplication(((BaseApplication)m_app).getEnvironment(), properties, null);
            RemoteTask remoteServer = new TaskSession(app);
            ((TaskSession)remoteServer).setProperties(properties);
            return remoteServer;
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }
961915
private AnycastInputHandler createAIHandRCD(SIBUuid8 dmeId, 
                                              SIBUuid12 gatheringTargetDestUuid,
                                              DestinationDefinition definition,
                                              boolean restartFromStaleBackup)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, 
                  "createAIHandRCD",
                  new Object[]{ 
                  dmeId,
                  gatheringTargetDestUuid,
                  definition,
                  Boolean.valueOf(restartFromStaleBackup)});
                  
    AnycastInputHandler aih = null;
    AIContainerItemStream aiContainerItemStream = null;
    PtoPReceiveMsgsItemStream rcdItemStream = null;
    String key = SIMPUtils.getRemoteGetKey(dmeId, gatheringTargetDestUuid);

    try
    {
      // check if either item stream already exists
      aiContainerItemStream = _aiContainerItemStreams.get(key);
      rcdItemStream = _rcdItemStreams.get(key);
      if (aiContainerItemStream == null || rcdItemStream == null)
      {
        LocalTransaction tran = _baseDestinationHandler.getTransactionManager().createLocalTransaction(true);

        // create aiContainerItemStream if necessary
        if (aiContainerItemStream == null)
        {
          aiContainerItemStream = new AIContainerItemStream(dmeId, gatheringTargetDestUuid, null, null, null);
          _baseDestinationHandler.addItemStream(aiContainerItemStream, (Transaction) tran);
        }

        // create rcdItemStream if necessary
        if (rcdItemStream == null)
        {
          rcdItemStream = new PtoPReceiveMsgsItemStream(_baseDestinationHandler, dmeId, null);
          _baseDestinationHandler.addItemStream(rcdItemStream, (Transaction) tran);
          
          // Configure destination depth parameters for the PtoPReceiveMsgsItemStream (defect 559096)
          // Set the default limits on the Itemstream
          rcdItemStream.setDefaultDestLimits();
          // Setup any message depth interval checking in line with 510343
          rcdItemStream.setDestMsgInterval();
        }

        tran.commit();
        
        // If commit succeeded, add streams to map
        _aiContainerItemStreams.put(key, aiContainerItemStream);
        _rcdItemStreams.put(key, rcdItemStream);
      }

      aih =
        new AnycastInputHandler(
          definition.getName(),
          definition.getUUID(),
          definition.isReceiveExclusive(),
          _messageProcessor,
          aiContainerItemStream,
          dmeId,
          gatheringTargetDestUuid,
          _destinationManager.getAsyncUpdateThread(),
          _baseDestinationHandler,
          restartFromStaleBackup);
      RemoteConsumerDispatcher rcd =
        new RemoteConsumerDispatcher(
          _baseDestinationHandler, definition.getName(),
          rcdItemStream,
          new ConsumerDispatcherState(),
          aih,
          _baseDestinationHandler.getTransactionManager(),
          definition.isReceiveExclusive());
      rcd.setReadyForUse();

      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        SibTr.debug(tc, "RCD created " + rcd);

    }
    catch (Exception e)
    {
      // Exception shouldn't occur so FFDC and rethrow as runtime exception
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.impl.destination.AbstractRemoteSupport.createAIHandRCD",
        "1:961:1.25",
        this);

      SIErrorException e2 =
        new SIErrorException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0002",
            new Object[] { "com.ibm.ws.sib.processor.impl.destination.AbstractRemoteSupport.createAIHandRCD", "1:968:1.25", e },
            null),
        e);

      SibTr.exception(tc, e);
      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
        new Object[] {
          "com.ibm.ws.sib.processor.impl.destination.AbstractRemoteSupport.createAIHandRCD",
          "1:976:1.25",
          e });

      // Don't throw exception if destination is being deleted, it is a message store invalid add
      // operation, and we're not being reconstituted with startMode == JsConstants.ME_START_FLUSH
      // Defect 222966
      if (_toBeDeleted && e instanceof InvalidAddOperation && !restartFromStaleBackup)
      {
        // Not throwing exception, make sure we return null
        aih = null;
      }
      else
      {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
          SibTr.exit(tc, "createAIHandRCD", aih);
        
        throw e2;
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "createAIHandRCD", aih);

    return aih;
  }
608520
public Object doRemoteAction(String strCommand, Map<String, Object> properties) throws DBException, RemoteException
    {
        BaseTransport transport = this.createProxyTransport(DO_REMOTE_ACTION);
        transport.addParam(NAME, strCommand);   // Don't use COMMAND
        transport.addParam(PROPERTIES, properties);
        Object strReturn = transport.sendMessageAndGetReply();
        if (strReturn instanceof String)
        {   // Could be returning a session
            BaseSessionProxy session = this.checkForSession((String)strReturn);
            if (session != null)
                return session;
        }
        Object objReturn = transport.convertReturnObject(strReturn);
        return this.checkDBException(objReturn);
    }
1328478
public RemoteTask createRemoteTask(Map<String, Object> properties) throws RemoteException
    {
        try   {
            Application app = this.getApplication();
            RemoteTask remoteServer = new TaskSession(app);
            ((TaskSession)remoteServer).setProperties(properties);
            return remoteServer;
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }
316532
public TaskInfo createTask(ManagedObject obj, String taskTypeId, String initiatedBy, boolean cancelable) throws RuntimeFault, RemoteException {
        return createTask(obj, taskTypeId, initiatedBy, cancelable, null);
    }
1374649
public Object startupService(BundleContext bundleContext)
    {
        Map<String,Object> props = this.getServiceProperties();
        Environment env = (Environment)this.getService(Env.class);
        props = Utility.putAllIfNew(props, env.getProperties());  // Use the same params as environment
        // Note the order that I do this... this is because MainApplication may need access to the remoteapp during initialization
        App app = env.getMessageApplication(true, props);
        Task task = new AutoTask(app, null, props);

        return this.createMessageService(task, null, props);
    }
750118
private SMPPSession getSession() throws IOException {
    if (session == null) {
      LOGGER.info("Initiate session for the first time to {}:{}", remoteIpAddress, remotePort);
      session = newSession();
    }
    else if (!session.getSessionState().isBound()) {
      throw new IOException("We have no valid session yet");
    }
    return session;
  }
394274
private RemoteExecutorServiceAsync asyncScheduledServiceAtFixed(String executorId, String requestId) {
        ScheduledTasksService scheduledRemoteService = new ScheduledTasksService(codec, name, commandExecutor, executorId, responses);
        scheduledRemoteService.setTerminationTopicName(terminationTopicName);
        scheduledRemoteService.setTasksCounterName(tasksCounterName);
        scheduledRemoteService.setStatusName(statusName);
        scheduledRemoteService.setSchedulerQueueName(schedulerQueueName);
        scheduledRemoteService.setSchedulerChannelName(schedulerChannelName);
        scheduledRemoteService.setTasksName(tasksName);
        scheduledRemoteService.setRequestId(new RequestId(requestId));
        scheduledRemoteService.setTasksRetryIntervalName(tasksRetryIntervalName);
        RemoteExecutorServiceAsync asyncScheduledServiceAtFixed = scheduledRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().noResult());
        return asyncScheduledServiceAtFixed;
    }
834547
protected HttpSession getSessionFromTransaction(final HttpServletRequest servletRequest, final String txId) {

        final Principal userPrincipal = servletRequest.getUserPrincipal();
        final String userName = userPrincipal == null ? null : userPrincipal.getName();

        final FedoraSession session = batchService.getSession(txId, userName);
        final HttpSession batchSession = new HttpSession(session);
        batchSession.makeBatchSession();
        LOGGER.debug("Returning a session in the batch {} for user {}", batchSession, userName);
        return batchSession;
    }
886897
private Session getOrCreateSession(SessionId sessionId) {
    Session session = sessions.get(sessionId);
    if (session == null) {
      session = new LocalSession(sessionId, name(), type(), null, service.serializer());
      sessions.put(session.sessionId(), session);
      service.register(session);
    }
    return session;
  }
305847
private RaftServiceContext getOrInitializeService(PrimitiveId primitiveId, PrimitiveType primitiveType, String serviceName, byte[] config) {
    // Get the state machine executor or create one if it doesn't already exist.
    RaftServiceContext service = raft.getServices().getService(serviceName);
    if (service == null) {
      service = initializeService(primitiveId, primitiveType, serviceName, config);
    }
    return service;
  }
339220
public RemoteSendQueue createRemoteSendQueue(String strQueueName, String strQueueType) throws RemoteException
    {
        BaseTransport transport = this.createProxyTransport(CREATE_REMOTE_SEND_QUEUE);
        transport.addParam(MessageConstants.QUEUE_NAME, strQueueName);
        transport.addParam(MessageConstants.QUEUE_TYPE, strQueueType);
        String strID = (String)transport.sendMessageAndGetReply();
        return new SendQueueProxy(this, strID);
    }
9156
public RemoteTask createRemoteTask(Map<String, Object> properties) throws RemoteException
    {   // Note: This new task's parent is MY application!
        BaseTransport transport = this.createProxyTransport(CREATE_REMOTE_TASK); // Don't use my method yet, since I don't have the returned ID
        transport.addParam(PROPERTIES, properties);
        String strID = (String)transport.sendMessageAndGetReply();
        return new TaskProxy((ApplicationProxy)m_parentProxy, strID);   // Note the parent is MY PARENT not ME. (just like the remote hierarchy)
    }
1121294
@Override
	protected final void remoteInit() throws JMSException
    {
        CreateDurableSubscriberQuery query = new CreateDurableSubscriberQuery();
        query.setSessionId(session.getId());
        query.setConsumerId(id);
        query.setTopic((Topic)destination);
        query.setMessageSelector(messageSelector);
        query.setNoLocal(noLocal);
        query.setName(subscriptionName);
        transportEndpoint.blockingRequest(query);
    }
1116355
public PrimaryBackupSession getOrCreateSession(long sessionId, MemberId memberId) {
    PrimaryBackupSession session = sessions.get(sessionId);
    if (session == null) {
      session = createSession(sessionId, memberId);
    }
    return session;
  }
1093178
public TransferState asynchGet(String remoteFileName,
                                   DataSink sink,
                                   MarkerListener mListener)
        throws IOException, ClientException, ServerException {
        checkTransferParamsGet();

        localServer.store(sink);
        controlChannel.write(new Command("RETR", remoteFileName));

        return transferStart(localServer.getControlChannel(), mListener);
    }
225729
public ResumeSessionResponse resumeSession(String sessionId) {
        ResumeSessionRequest request = new ResumeSessionRequest();
        request.setSessionId(sessionId);
        return resumeSession(request);
    }