Show TOC

Background documentationCalling Java EE Applications from Portal Applications Locate this document in the navigation structure

 

Portal applications can access Java EE applications, such as EJBs and servlets, as follows:

  1. Specify the reference.

    The reference is defined in portalapp.xml either in PrivateSharingReference or PublicSharingReference using the Java EE application prefix SAPJ2EE::.

    Syntax Syntax

    1. <property name="PrivateSharingReference" value="SAPJ2EE::sap.com/Hello"/>
    End of the code.
  2. Access the application.

    The application is accessed via JNDI. The following is an example of a portal component accessing an EJB.

    Syntax Syntax

    1. public void doContent(
    2.    IPortalComponentRequest request,
    3.    IPortalComponentResponse response) {
    4.    String key = "Hello/Stateless/HelloStatelessBean";
    5.  
    6.    try {
    7.       Context context = new InitialContext();
    8.  
    9.       Object obj = context.lookup(key);
    10.       HelloHome home =
    11.          (HelloHome) P4ObjectBroker.init().narrow(obj, HelloHome.class);
    12.       Hello hello = home.create();
    13.       response.write("Bean message: " + hello.getMessage());
    End of the code.
Referencing Elements

You can reference an application, connector, library, interface or service by specifying the Java EE object in the portalapp.xml, either in the SharingReference or PrivateSharingReference property. Whether you should use SharingReference or PrivateSharingReference depends on your purpose:

  • If the referenced application, library or service has to be used in the API of the portal application, use the SharingReference.

  • If the reference is for the core of the portal application, use PrivateSharingReference.

The format of the Java EE object in the SharingReference or PrivateSharingReference property is as follows:

  • Application: SAPJ2EE::<provider name/application name>

  • Connector: SAPJ2EE::<provider name/connector name>

  • Service: SAPJ2EE::service:<service name>

  • Library: SAPJ2EE::library:<library name>

  • Interface: SAPJ2EE::interface::<interface name>

Note Note

The format includes the provider name for an application or connector, but not for services, libraries and interfaces.

The provider name is separated from the application name by slash (/).

If the provider is not SAP (sap.com), then you must add the provider name to the deployment.supportedProviders property in SAP NetWeaver Administrator, as described in Configuring the Portal Runtime Properties.

End of the note.

For more information on sharing references, see Application Configuration.

Example

This is an example of a portal application referencing the Java EE application sap.com/Hello, the AS Java service P4 and the library TestLibrary. The references are specified in PrivateSharingReference. This means that the references are established between the core of the portal application and the referenced application, service and library.

Syntax Syntax

  1. <application>
  2. 	<application-config>
  3. 		<property name="SharingReference" value=""/>
  4. 		<property name="PrivateSharingReference" value="SAPJ2EE::sap.com/Hello,
  5.                                SAPJ2EE::service:p4,SAPJ2EE::library:TestLibrary"/>
  6. 	</application-config>
  7. </application>
End of the code.