Redirectors
The portal enables you to create redirectors that automatically translate all navigation targets with a specific prefix into different navigation targets.
For example, the roles connector includes a redirector (that is, a class that implementsINavigationRedirector) that translates any navigation target with thepcdprefix into the same navigation target but with aROLESprefix. This enables users or applications to navigate to role-based navigation nodes by specifying a target with apcdprefix.
You do not have to implement a redirector for your navigation connector. However, you can only register a redirector at the same time you register a navigation connector.
Procedure
The following describes how to write and deploy a redirector:
Create a new class that implementsINavigationRedirector
Implement the methodredirect(), which has the following signature:
publicINavigationRedirectorResultredirect( StringatomicName,Hashtablehashtable)throwsNamingException{
}
The original navigation target is passed as a string, without a prefix or separator.
The method provides the logic for translating this string into the new navigation target, including a prefix and separator. The method returns an object of typeINavigationRedirectorResult. You must create a class that implements this interface.
Package this class with the PAR file that contains your navigation connector.
Register the redirector in the same call that registers your navigation connector, as follows
Create an instance of your redirector.
Create aMapfor holding your redirectors.
Register your redirector when registering your connector.
privatemyCo nnectorRedirector my ConnectorRedirector;
// Create instance of redirector.
publicvoidinit(IServiceContextserviceContext){
myConnectorRedirector=new my ConnectorRedirector();
}
// Register redirector.
publicvoidafterInit(){
INavigationConnectorRegistrationservice= (INavigationConnectorRegistration) getContext(). getService(INavigationService.KEY);
if(service!=null){
Mapredirectors=newHashMap();
redirectors.put("myRedirectPrefix",myConnectorRedirector);
service.registerConnector( "myRedirectPrefix",myConnector,null,redirectors);
}
}