cancel
Showing results for 
Search instead for 
Did you mean: 

Properties for a seesion bean

Former Member
0 Kudos

Hi all,

I think this migth be a question of beginners: What is the common way / best practise to provide properties to a session bean?

Thanks for each hint,

Christoph

Accepted Solutions (1)

Accepted Solutions (1)

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

That depends very much. For example whether it's a stateful or a stateless session bean. In the first case you could use getters ans setters as with a normal JavaBean. In latter case this is not a good idea, so you would use paramaeters in the call of the Bean.

Maybe you should go more into the details of what you want to do?

Regards,

Benny

Former Member
0 Kudos

Hi Benny,

thanks for this hint. It's a statless session bean. I'm not quite convinced about your suggestion to deliver config-params to the methods of a session bean. E.g. I implement a method to send some data to a subsystem. To do this I have to know the hostname of subsystem's server. I do not think that this hostname is anything the UI should be concerned with. It's part of business logic. So I would like to configure this hostname for ma bean.

Regards,

Christoph

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Christoph,

oops, you asked for properties and I thought about fields.

Your example shows quite clearly the direction to go: In that case you should use the JNDI (Java Naming and Directory Interface) environment. That allows to be independent of name changes afterwards and also allows to reconfigure your landscape afterwards without changing the code. JNDI is part of the EE standard and the right buzzword to search for.

Regards,

Benny

Vlado
Advisor
Advisor
0 Kudos

Hi Christoph,

EJB env-entries is the way to go. These can also be modified at runtime through the NWA without the need to redeploy your application.

HTH!

\-- Vladimir

Former Member
0 Kudos

Hi Vladimir,

yes, I already heard about and did some tests. I generated the file "sap.application.global.properties" in META-INF of my EAR-DC. After deployment of the EAR I can see the defined properties in NW-Administrator.

My problem is that I don't know how to access the props. I tried following source-code:

InitialContext ctx = new InitialContext();

ApplicationConfigHandlerFactory cfgHandler = (ApplicationConfigHandlerFactory)ctx.lookup("ApplicationConfiguration");

java.util.Properties appProps = cfgHandler.getApplicationProperties();

if (appProps==null) {

// some reaction if no application properties are available.

} else {

//extract properties

}

I get an error at compile time that class ApplicationConfigHandlerFactory cannot be found. I already tried to use several public parts but no one seems to be appropriate.

On the other hand side I found a jar-file named "sap.comtcjeconfigurationimpl.jar" in directory "/usr/sap/JAD/J00/j2ee/cluster/bin/services/configuration" in the server's filesystem. This jar-file contains the missing class. I just can't find the public part that delivers access to the jar-file. Do you know anything more?

I'm developping under CE SP03 with NWDI.

Regards,

Christoph

Vlado
Advisor
Advisor
0 Kudos

Hi Christoph,

Actually, I was referring to standard Java EE env-entry references. Please check the ejb-jar.xml schema and/or @Resource annotation.

Regards,

\-- Vladimir

Former Member
0 Kudos

I am using NW 7.0 SP 14 and the public part is called "configuration" under SAP_JEE. You also have to add a reference to this in your EAR.

Answers (0)