cancel
Showing results for 
Search instead for 
Did you mean: 

problem with making a bundle file for customer UI Command

Former Member
0 Kudos

Hi everyone, in SAP documentation Importing an Example Project Into SAP NetWeaver Developer Studio at http://help.sap.com/saphelp_nw04/helpdata/en/49/895342d1f43830e10000000a155106/content.htm there is an example project attached in SAP Note 817876.

Following the procedure in this documentation I created a project and got the par file. After I deployed the par file I can not see the service registered under Service Configuration.

When I add the following

<service-profile>

<property name="generic_classloader_registration" value="yes"/>

<property name="generic_service_key" value="com.sap.netweaver.rf.wrapper.RFServiceWrapper"/>

I can see the service has been registered. Does it mean this configuration is missing in the example project?

Thanks for early reply.

Best regards.

Wang

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Yantong

The par file should work with the existing entry in the Portalapp.xml.

<services>

<service name="RFServiceWrapper">

<service-config>

<property name="className" value="com.sap.netweaver.rf.wrapper.RFServiceWrapper"/>

<property name="startup" value="true"/>

</service-config>

</service>

</services>

Did you try changing the label of a UI command after this.

Regards

Pran

Former Member
0 Kudos

Dear Pran:

Thanks a lot for your quick reply. You can see in my post below, the problem is the method getKey() can not be executed. I think the class RFServiceWrapper has not been processed as we want.

I do not think changing the label will help before we make this customer's bundle file registered in this system.

Best regards.

Wang

Former Member
0 Kudos

Hi yantong

I ll give it a try myself , unless someone comes up with an answer before.

Regards

Pran

Former Member
0 Kudos

Hi Pran

In the example project there are two methods IServiceContent getContent() and String getKey() in the class RFServiceWrapper. Can you figure out what are these used for? Is it needed for customer's implementation in this class ?

Best regards.

Wang

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

> IServiceContent getContent() and String getKey()

> in the class RFServiceWrapper

getConte<u>x</u>t, you mean?!

The whole class implements an IService interface which is nothing else than the definition of a portal service.

The key is used to retrieve such a service from outside, i.e. from another portal application.

For service implementation details, see JavaDoc of IService as well as this tutorial: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/ep/component and service creation tutorial.zip

Hope it helps

Detlev

Former Member
0 Kudos

Hi Detlev, thanks for reply. One thing I do not get it. In the code

public interface IRFServiceWrapper extends IService

{

public static final String KEY= "com.customername.km.resource.bundle";

}

there is a key.

and the par file is named as com.customername.km.resource.bundle.ResourceBundleProject.par (recommended)

the bundle file's name is MyBundle.properties under package

com.customername.km.resource.bundle.

How can I how can I check if the class RFServiceWrapper is working ?

How can I specify this bundle file's path for my UI Command ?

Thanks for reply.

Best regards.

Wang

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

all the service does in this case is adding the content of the par (the things to be found under lib or private/lib as well as under classes and private/classes) to the KMC classloader.

In the case discussed, under src.api\com\customer\km\resource\bundle you will find the resource bundles. If deployed, they should be found under the classes dir (or within a jar under the lib dir; I'm not sure if they are packed into a jar or just copied, if they are not java files).

Anyhow, the main task of the service is this line:

CrtClassLoaderRegistry.addClassLoader(this.getKey(), this.getClass().getClassLoader());

What does it? If the application is loaded, it checks the services in it, and this one is set to startup at loading time. This means calling the init-method, and in this, the actual classloader (of this application) is added to the CrtClassLoaderRegistry. And this one is used as the KMC classloader. That means, if you set some resource bundle within KM config, the corresponding propertiy-files are searched, and they are searched by using the KMC classloader (classloader registry, that means looking through different classloaders).

Hope it helps

Detlev

Former Member
0 Kudos

Great explanation

Somemore ideas from my side

I think the class loaders for the different services will be stored in a member HashMap of the CrtClassLoaderRegistry against keys that is specified in the attribute KEY.

The request for a property file by a UI command is serviced by a method that iterates through the HashMap and finds a matching class reference based on the key.Once the reference is obtained an the property file can be streamed and a Property object created. Some probable psuedo code on the internal workings


//obtained from user configuration
String bundleFileinConfig = "com.test.bundle.PropFile";
String keyForSearch = bundleFileinConfig.substring(0,bundleFileinConfig.lastIndexOf("."));
String bundleFile = bundleFileinConfig.substring(bundleFileinConfig.lastIndexOf(".")+1,bundleFileinConfig.length());


//Proccessing to obtain the resource and values
Class bundleClass = CrtClassLoaderRegistry.findClass(keyForSearch);//protected access
Properties prop = null;
if(bundleClass != null){
 prop = new Properties();
 InputStream inStream = CrtClassLoaderRegistry.getSystemResourceAsStream(bundleFileinConfig);
 prop.load(inStream);
 }
 if(prop != null)
 prop.getProperty("<whatever property specified for the command>");

Regards

Pran

Former Member
0 Kudos

Hi Detlev and Pran:

Thank you so much for your help.

Best regards.

Wang

Former Member
0 Kudos

Hi, Pran and Detlev, FYI, unfortunately on our system EP 6.0 SP2 P31 there is no method findClass().

Anyway thanks for your replies and your time.

Best regards.

Wang

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

Pran just wanted to show how it works internally (in more or less pseudo-code). You don't have to use this at all, it was just for understanding the techniques in the background.

Best regards

Detlev

Former Member
0 Kudos

Oh I caused more confusion .. sorry guys

Thanks Detlev

Regards

Pran

Former Member
0 Kudos

Hi Detlev and Pran, thanks, Pran's code is very helpful for me to verify if the CrtClassLoaderRegistry is working or not. Actually I found in bc.crt_api.jar on our system EP 6.0 SP2 P31 there is no implementation for the methods findClass(), findResource() and findResources(), that were supposed to be there. This is not the first time for me to get such problem.

In the documentation there is a method but when you use this method it does not exit or not be implemented.

According to SAP's documentation it can be done. But in real life it can not be done....

Detlev, I got your point and thanks again for your and Pran's reply.

Best regards.

Wang

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

first, CrtClassLoaderRegistry differs between SP2 and NW04 (in NW04 there you have the nice feature to give a name under which a classloader is registered, so that when you redeploy a PAR, also the new Classloader is used; that's not possible under SP2).

In fact, you shouldn't have a problem at all. The line where the service registers the application classloader to the registry also differs between the two PAR's attached to the note you are working with.

Hope it helps

Detlev

detlev_beutner
Active Contributor
0 Kudos

Hi Wang,

generally, under SystemAdmin -- SystemConfig -- ServiceConfig -- Applications -- ... only the services show up which have a service profile. The reason for this behaviour probably is that only for such services it makes sense to restart them after having changed some of the profile parameter values.

In the PAR example mentioned by yours, there is no service profile section (just checked).

Hope it helps

Detlev

Former Member
0 Kudos

Dear Detlev,

Thanks a lot for this very quick reply. .

I have checked the par file if <service-profile .../> is not added in the xml file there will be no in the par file.

I got another problem. I have monitored the process when this class RFServiceWrapper is processed.

If I use my portalapp.xml (with <service-profile .../>)the method init(), release(), afterInit() and destroy() can be executed. But the getKey() can NOT be executed even after the server has been restarted. If I use the original xml file only Init() and AfterInit() can be executed.

Our system is EP 6.0 SP2 P31.

Any hint for solving this problem? Thanks for reply.

Best regards.

Wang