Entering content frame

Procedure documentation Accessing Portal Applications from J2EE Applications Locate the document in its SAP Library structure

Procedure

J2EE applications can access portal components and/or portal services as follows:

...

       1.      Specify the tag reference.

The reference tag is specified in the application-j2ee-engine.xml. It has the following specifics:

¡        Attribute: reference-type

¡        Attribute value: hard or soft

Note that references to portal applications are treated in a unique way. This means there is no difference if hard or weak is specified

¡        Tag: reference-target

¡        Tag value: The name of the portal application or an alias defined for it

¡        Attribute: target-type. Attribute value: application

The value application identifies the reference target as the portal application

¡        Attribute: provider-name. Attribute value: sap.com.

Currently the only supported provider prefix is sap.com

Example

<reference-target target-type="application" provider-name="sap.com">

PortalTestApp2

</reference-target>

       2.      Access the application.

The application is accessed via JNDI. The lookup is made to the portal registry. There is currently no JNDI schema defined for the portal registry. Therefore, the object factory for the portal registry must be specified in the environment of JNDI through:

¡        the environment variable: Context.INITIAL_CONTEXT_FACTORY. It must have the value: com.sapportals.portal.prt.registry.PortalRegistryFactory.

¡        The lookup is made using the following JNDI path: /broker/services/<service name>:

§         <service name>is the key of the service as defined in its interface.

Alternatively the notation

§         <application name>.<service name> can be used as defined in the portalapp.xml file of the application which provides the service.

Example

This is an example Web Dynpro application, which uses the portal service xsltransform to perform a transformation of an XML file to HTML. The XML file is in the format of RSS, which is a common format for providing news on the Internet. The example shows only the relevant parts. It reads the current news from Yahoo and transforms it to HTML using an XSTL style sheet, which it expects in the local directory "c:\temp".

import com.sapportals.portal.prt.service.xsltransform.IXSLTransformService;

import com.sapportals.portal.prt.service.xsltransform.IWPXSLTransformer;

 

public class HelloWorld {

   public void wdDoInit() {

      String output;

      String line;

      String rssStyleSheetFileName = "c:/temp/rsshtml20.xsl";

      String topStoriesURLName = "http://rss.news.yahoo.com/rss/topstories";

      URL rssStyleSheetURL = null;

      URL topStoriesURL = null;

      StringBuffer news = new StringBuffer();

      StringBuffer styleSheet = new StringBuffer();

 

      Hashtable env = new Hashtable();

 

      env.put(

         Context.INITIAL_CONTEXT_FACTORY,

         "com.sapportals.portal.prt.registry.PortalRegistryFactory");

 

      InitialContext context = new InitialContext(env);

 

      IXSLTransformService xslTransformService =

         (IXSLTransformService) context.lookup(

            "/broker/services/" + IXSLTransformService.KEY);

 

      rssStyleSheetURL = new URL("file://localhost/" + rssStyleSheetFileName);

 

      InputStreamReader iReader =

         new InputStreamReader(rssStyleSheetURL.openStream());

      BufferedReader bReader = new BufferedReader(iReader);

 

      while ((line = bReader.readLine()) != null) {

         styleSheet.append(line);

      }

 

      IWPXSLTransformer rssTransformer =

         xslTransformService.getTransformer(

            new StringReader(styleSheet.toString()));

 

      topStoriesURL = new URL(topStoriesURLName);

 

      iReader = new InputStreamReader(topStoriesURL.openStream());

      bReader = new BufferedReader(iReader);

 

      while ((line = bReader.readLine()) != null) {

         news.append(line);

      }

      output = rssTransformer.transform(news.toString());

   }

}

 

 

Leaving content frame