Enterprise JavaBeans Redirection
The Extensibility concept springs up from the continual customers’ needs for specific extensions. It has a long history within SAP, originating from the ABAP world and the so called Business Add-Ins. Now this concept is making its way in the SAP Java world.
At the moment the Extensibility concept is developed in two main directions:
- The idea of Adaptability
As the environment, knowledge and expectations continuously vary, there is always a need for custom changes (e.g. in the UI). But a change leads to a lot of manual adjustments in order to adapt the backend appropriately. Here comes the necessity of a technology to implicitly adapt the whole stack so that to properly fit to the (UI) change without any manual intervention. The requirements and expectations are under research, there are a lot of open topics and discussions and still there is no clear idea for the solution.
- The idea of Redirecting
In general the idea is to provide a way a predefined part of an application to be replaced by a custom implementation. In other words, if component X is using component Y by default, the idea is to redirect X to refer to another (custom provided) component Z. There is an open standard in this direction – the Service Component Architecture (SCA).
In the context of the component redirection, we have recently developed the EJB redirection option, which is the subject of this blog. The EJB redirection is based on administering EJB references at runtime. The solution is using only Java EE standard artifacts, there is no proprietary metadata at all. This is not a global extensibility solution. It just fulfills some specific requirements, using the standard mechanisms.
How to redirect an EJB reference
Each EJB reference is displayed in the SAP NetWeaver Administrator and can be modified to point to another EJB, which fulfills certain requirements. You have to open the SAP NetWeaver Administrator and choose Configuration Management → Infrastructure → Application Modules. An annotated EJB reference is redirected by changing its mappedName string value. An xml-specified EJB reference is redirected by changing its jndi-name string value.
In both cases, an EJB reference will be changed if all of the following requirements are fulfilled:
The custom provided string value is a legal EJB lookup scheme. For more details on the EJB lookup scheme, refer to: EJB Lookup Scheme .
The custom provided EJB lookup scheme contains all appName, jarName, beanName and interfaceName elements.
If any of the requirements is not fulfilled, the EJB reference will not be changed and a warning will be displayed.
When the change is saved, in order for it to be applied, either the whole referencing application or only the runtime of the changed referencing bean is restarted. The latter can be switched by means of the <restart-at-runtime-change> property of the ejb-j2ee-engine.xml.
The default values can be restored by choosing Get Default in the Environment & References tab in the EJB Module Details section.
The EJB redirection is a small step towards the extensibility concept realization, but in the right direction.