Skip to content

Commit

Permalink
0003459: Extension point for registration redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Feb 26, 2018
1 parent 2b49ecf commit b8f7088
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.ext;

import org.jumpmind.extension.IExtensionPoint;

/**
* An {@link IExtensionPoint} to examine an incoming registration request
* and redirect it to another node. For example, all nodes contact the
* root server for registration, but they are redirected to a regional
* server that is closest to them.
* If this extension is unused, the default behavior is to check
* the registration_redirect table for a matching externalId
* and redirect to the configured registration node.
*/
public interface IRegistrationRedirect extends IExtensionPoint {

public String getRedirectionUrlFor(String externalId, String nodeGroupId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.config.INodeIdCreator;
import org.jumpmind.symmetric.ext.INodeRegistrationListener;
import org.jumpmind.symmetric.ext.IRegistrationRedirect;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.NodeGroupLink;
import org.jumpmind.symmetric.model.NodeHost;
Expand Down Expand Up @@ -186,7 +187,15 @@ protected Node processRegistration(Node nodePriorToRegistration, String remoteHo
}
}

String redirectUrl = getRedirectionUrlFor(nodePriorToRegistration.getExternalId());
String redirectUrl = null;
IRegistrationRedirect registrationRedirect = extensionService.getExtensionPoint(IRegistrationRedirect.class);
if (registrationRedirect != null) {
redirectUrl = registrationRedirect.getRedirectionUrlFor(nodePriorToRegistration.getExternalId(),
nodePriorToRegistration.getNodeGroupId());
} else {
redirectUrl = getRedirectionUrlFor(nodePriorToRegistration.getExternalId());
}

if (redirectUrl != null) {
log.info("Redirecting {} to {} for registration.",
nodePriorToRegistration.getExternalId(), redirectUrl);
Expand Down

0 comments on commit b8f7088

Please sign in to comment.