Entering content frame

Background documentation Calling J2EE Applications from Portal Applications Locate the document in its SAP Library structure

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

 

...

       1.      Specify the reference.

The reference is defined in portalapp.xml either in PrivateSharingReference or PublicSharingReferenceusing the J2EE application prefix SAPJ2EE::.

<property name="PrivateSharingReference" value="SAPJ2EE::sap.com/Hello"/>

       2.      Access the application.

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

public void doContent(

   IPortalComponentRequest request,

   IPortalComponentResponse response) {

   String key = "Hello/Stateless/HelloStatelessBean";

 

   try {

      Context context = new InitialContext();

 

      Object obj = context.lookup(key);

      HelloHome home =

         (HelloHome) P4ObjectBroker.init().narrow(obj, HelloHome.class);

      Hello hello = home.create();

      response.write("Bean message: " + hello.getMessage());

Referencing Elements

You can reference an application, connector, library, interface or service by specifying the the J2EE 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 J2EE object in the SharingReference or PrivateSharingReference property is as follows:

·        Application: SAPJ2EE::<provider prefix/application name>

·        Connector: SAPJ2EE::<provider prefix/connector name>

·        Service: SAPJ2EE::service:<service name>

·        Library: SAPJ2EE::library:<library name>

·        Interface: SAPJ2EE::interface::<interface name>

Note

The format includes the provider prefix for an application or connector, but not for services, libraries and interfaces. The provider prefix is separated from the application name by slash (/).

For more information on sharing references, see Application Configuration.

Example

This is an example of a portal application referencing the J2EE application sap.com/Hello, the J2EE Engine 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.

<application>

   <application-config>

      <property name="SharingReference" value=""/>

      <property name="PrivateSharingReference"

              value="SAPJ2EE::sap.com/Hello,
                     SAPJ2EE::service:p4,SAPJ2EE::library:TestLibrary"
/>

   </application-config>

</application>

 

Leaving content frame