Skip to content

Commit

Permalink
Merge pull request #1742 from sajinieKavindya/master
Browse files Browse the repository at this point in the history
Add Framework to Support Activating and Deactivating File Inbound Endpoints
  • Loading branch information
sajinieKavindya authored Jan 3, 2025
2 parents fda3686 + 0340ccc commit fb25fb4
Show file tree
Hide file tree
Showing 21 changed files with 412 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ public void setId(int i) {
public String getId() {
return null;
}

@Override
public boolean reInitialize() {

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ public void setId(int i) {
public String getId() {
return null;
}
}

@Override
public boolean reInitialize() {

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ public boolean startListener() {

@Override
public void init() {
/*
* The activate/deactivate functionality is not currently implemented
* for this Inbound Endpoint type.
*
* Therefore, the following check has been added to immediately return if the "suspend"
* attribute is set to true in the inbound endpoint configuration due to the fixes done
* in Synapse level - https://github.com/wso2/wso2-synapse/pull/2261.
*
* Note: This implementation is temporary and should be revisited and improved once
* the activate/deactivate capability is implemented.
*/
if (startInPausedMode) {
logger.info("Inbound endpoint [" + name + "] is currently suspended.");
return;
}
startListener();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public abstract class InboundOneTimeTriggerRequestProcessor implements InboundRe
protected SynapseEnvironment synapseEnvironment;
protected String name;
protected boolean coordination;
protected boolean startInPausedMode;

private OneTimeTriggerInboundRunner inboundRunner;
private Thread runningThread;
Expand Down Expand Up @@ -130,4 +131,22 @@ public void destroy() {
}
}
}

@Override
public boolean activate() {

return false;
}

@Override
public boolean deactivate() {

return false;
}

@Override
public boolean isDeactivated() {
// Need to properly implement this logic.
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public abstract class InboundRequestProcessorImpl implements InboundRequestProce
private HashMap<Thread, InboundRunner> inboundRunnersThreadsMap = new HashMap<>();
private static final Log log = LogFactory.getLog(InboundRequestProcessorImpl.class);
private InboundEndpointsDataStore dataStore;

protected boolean startInPausedMode;

protected final static String COMMON_ENDPOINT_POSTFIX = "--SYNAPSE_INBOUND_ENDPOINT";

public InboundRequestProcessorImpl(){
Expand Down Expand Up @@ -263,4 +264,22 @@ private String getServerHost() {

return null;
}

@Override
public boolean activate() {

return false;
}

@Override
public boolean deactivate() {

return false;
}

@Override
public boolean isDeactivated() {
// Need to properly implement this logic.
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,25 @@ public GenericEventBasedListener(InboundProcessorParams params) {
this.onErrorSeq = params.getOnErrorSeq();
this.synapseEnvironment = params.getSynapseEnvironment();
this.classImpl = params.getClassImpl();
this.startInPausedMode = params.startInPausedMode();
}

public void init() {
/*
* The activate/deactivate functionality is not currently implemented
* for this Inbound Endpoint type.
*
* Therefore, the following check has been added to immediately return if the "suspend"
* attribute is set to true in the inbound endpoint configuration due to the fixes done
* in Synapse level - https://github.com/wso2/wso2-synapse/pull/2261.
*
* Note: This implementation is temporary and should be revisited and improved once
* the activate/deactivate capability is implemented.
*/
if (startInPausedMode) {
log.info("Inbound endpoint [" + name + "] is currently suspended.");
return;
}
log.info("Inbound event based listener " + name + " for class " + classImpl +
" starting ...");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ public abstract class GenericInboundListener implements InboundRequestProcessor
protected String onErrorSequence;
protected String name;
protected InboundProcessorParams params;
protected boolean startInPausedMode;


public GenericInboundListener(InboundProcessorParams inboundParams) {
this.injectingSequence = inboundParams.getInjectingSeq();
this.onErrorSequence = inboundParams.getOnErrorSeq();
this.name = inboundParams.getName();
this.params = inboundParams;
this.startInPausedMode = params.startInPausedMode();
}

/**
Expand Down Expand Up @@ -93,4 +95,22 @@ protected static void handleException(String msg, Exception e) {
log.error(msg, e);
throw new SynapseException(msg, e);
}

@Override
public boolean activate() {

return false;
}

@Override
public boolean deactivate() {

return false;
}

@Override
public boolean isDeactivated() {
// Need to properly implement this logic.
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,25 @@ public GenericProcessor(InboundProcessorParams params) {
this.onErrorSeq = params.getOnErrorSeq();
this.synapseEnvironment = params.getSynapseEnvironment();
this.classImpl = params.getClassImpl();
this.startInPausedMode = params.startInPausedMode();
}

public void init() {
/*
* The activate/deactivate functionality is not currently implemented
* for this Inbound Endpoint type.
*
* Therefore, the following check has been added to immediately return if the "suspend"
* attribute is set to true in the inbound endpoint configuration due to the fixes done
* in Synapse level - https://github.com/wso2/wso2-synapse/pull/2261.
*
* Note: This implementation is temporary and should be revisited and improved once
* the activate/deactivate capability is implemented.
*/
if (startInPausedMode) {
log.info("Inbound endpoint [" + name + "] is currently suspended.");
return;
}
log.info("Inbound listener " + name + " for class " + classImpl + " starting ...");
try {
Class c = Class.forName(classImpl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,30 @@ public class InboundHL7Listener implements InboundRequestProcessor {

private int port;
private InboundProcessorParams params;
private final boolean startInPausedMode;

public InboundHL7Listener(InboundProcessorParams params) {
this.params = params;
startInPausedMode = params.startInPausedMode();
}

@Override
public void init() {
/*
* The activate/deactivate functionality is not currently implemented
* for this Inbound Endpoint type.
*
* Therefore, the following check has been added to immediately return if the "suspend"
* attribute is set to true in the inbound endpoint configuration due to the fixes done
* in Synapse level - https://github.com/wso2/wso2-synapse/pull/2261.
*
* Note: This implementation is temporary and should be revisited and improved once
* the activate/deactivate capability is implemented.
*/
if (startInPausedMode) {
log.info("Inbound endpoint [" + params.getName() + "] is currently suspended.");
return;
}
if (!InboundHL7IOReactor.isStarted()) {
log.info("Starting MLLP Transport Reactor");
try {
Expand Down Expand Up @@ -67,4 +84,22 @@ public void destroy() {
HL7EndpointManager.getInstance().closeEndpoint(port);
}

@Override
public boolean activate() {

return false;
}

@Override
public boolean deactivate() {

return false;
}

@Override
public boolean isDeactivated() {
// Need to properly implement this logic.
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class InboundHttpListener implements InboundRequestProcessor {
private String name;
private int port;
private InboundProcessorParams processorParams;
protected boolean startInPausedMode;

public InboundHttpListener(InboundProcessorParams params) {

Expand All @@ -59,11 +60,27 @@ public InboundHttpListener(InboundProcessorParams params) {
handleException("Please provide port number as integer instead of port " + portParam, e);
}
name = params.getName();
startInPausedMode = params.startInPausedMode();
}

@Override
public void init() {

/*
* The activate/deactivate functionality is not currently implemented
* for this Inbound Endpoint type.
*
* Therefore, the following check has been added to immediately return if the "suspend"
* attribute is set to true in the inbound endpoint configuration due to the fixes done
* in Synapse level - https://github.com/wso2/wso2-synapse/pull/2261.
*
* Note: This implementation is temporary and should be revisited and improved once
* the activate/deactivate capability is implemented.
*/
if (startInPausedMode) {
log.info("Inbound endpoint [" + name + "] is currently suspended.");
return;
}
if (isPortUsedByAnotherApplication(port)) {
log.warn("Port " + port + " used by inbound endpoint " + name + " is already used by another application " +
"hence undeploying inbound endpoint");
Expand Down Expand Up @@ -118,4 +135,22 @@ protected void destoryInbound() {
}
}
}

@Override
public boolean activate() {

return false;
}

@Override
public boolean deactivate() {

return false;
}

@Override
public boolean isDeactivated() {
// Need to properly implement this logic.
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ public InboundHttpsListener(InboundProcessorParams params) {
@Override
public void init() {

/*
* The activate/deactivate functionality is not currently implemented
* for this Inbound Endpoint type.
*
* Therefore, the following check has been added to immediately return if the "suspend"
* attribute is set to true in the inbound endpoint configuration due to the fixes done
* in Synapse level - https://github.com/wso2/wso2-synapse/pull/2261.
*
* Note: This implementation is temporary and should be revisited and improved once
* the activate/deactivate capability is implemented.
*/
if (startInPausedMode) {
log.info("Inbound endpoint [" + name + "] is currently suspended.");
return;
}
if (isPortUsedByAnotherApplication(port)) {
log.warn("Port " + port + "used by inbound endpoint " + name + " is already used by another application " +
"hence undeploying inbound endpoint");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
*/
package org.wso2.carbon.inbound.endpoint.protocol.httpssecurewebsocket;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.inbound.InboundProcessorParams;
import org.wso2.carbon.inbound.endpoint.protocol.httpwebsocket.InboundHttpWebsocketListener;
import org.wso2.carbon.inbound.endpoint.protocol.httpwebsocket.management.HttpWebsocketEndpointManager;

public class InboundHttpsSecureWebsocketListener extends InboundHttpWebsocketListener {

private static final Log LOGGER = LogFactory.getLog(InboundHttpsSecureWebsocketListener.class);

public InboundHttpsSecureWebsocketListener(InboundProcessorParams params) {

super(params);
Expand All @@ -31,6 +35,21 @@ public InboundHttpsSecureWebsocketListener(InboundProcessorParams params) {
@Override
public void init() {

/*
* The activate/deactivate functionality is not currently implemented
* for this Inbound Endpoint type.
*
* Therefore, the following check has been added to immediately return if the "suspend"
* attribute is set to true in the inbound endpoint configuration due to the fixes done
* in Synapse level - https://github.com/wso2/wso2-synapse/pull/2261.
*
* Note: This implementation is temporary and should be revisited and improved once
* the activate/deactivate capability is implemented.
*/
if (startInPausedMode) {
LOGGER.info("Inbound endpoint [" + name + "] is currently suspended.");
return;
}
HttpWebsocketEndpointManager.getInstance().startSSLEndpoint(port, name, processorParams);
}
}
Loading

0 comments on commit fb25fb4

Please sign in to comment.