
|
If you were logged in you would be able to see more operations.
|
|
EJB Cartridge
Created: 27/Oct/04 08:06 AM
Updated: 27/Oct/04 08:06 AM
|
|
| Component/s: |
None
|
| Affects Version/s: |
None
|
| Fix Version/s: |
None
|
|
|
Environment:
|
not of interest
|
|
The creation of env-entries by the SessionBean template has some small errors as it uses variables that are not defined. In the following I am referring to the SessionBean.vls template section beginning at line 94 and ending at line 132 that deals with the code generation for the lookup of environment entries:
problems:
1) $visibility is not set
2) $attribute is not set
3) no closing bracket at the end of the created method
The solution is quite simple:
1) #set ($visibility = $envEntry.visibility) at the very beginning
2) change $attribute to $envEntry
3) add } add the very end of the foreach loop
Here is the complete change I did to this section (I hope that the formatting is readable):
// -- accessors for environment entries --
#foreach($envEntry in $service.getEnvironmentEntries(true))
/**
* Get <em>${envEntry.name}</em> environment entry.
$envEntry.getDocumentation(" * ")
*
## Only expose the method to the component interface if it is public.
#set ($visibility = $envEntry.visibility)
#if($visibility == "public")
* @ejb.interface-method
#end
*/
$visibility $envEntry.type.fullyQualifiedName ${envEntry.getterName}(){
javax.naming.InitialContext initialContext = null;
try {
initialContext = new javax.naming.InitialContext();
return (${envEntry.type.fullyQualifiedName}) initialContext.lookup("java:comp/env/$envEntry.name");
} catch (javax.naming.NamingException cause) {
RuntimeException ex = new IllegalStateException(
"Cannot access environment entry \"$envEntry.name\".");
// In order to set the exception cause on JDK 1.4
// and stay JDK 1.3 compatible nonetheless, we need
// a bit of reflection magic here...
try {
java.lang.reflect.Method initCause =
ex.getClass().getMethod("initCause",
new Class[] {Throwable.class});
initCause.invoke(ex, new Object[] { cause });
} catch (Throwable t) {
// Ignore any errors here - we simply make do without the cause
}
throw ex;
} finally {
try {
if (initialContext != null) { initialContext.close(); }
} catch (javax.naming.NamingException ignore) {
// Silently ignore naming exceptions at cleanup time
}
}
}
#end
|
|
|
There are no comments yet on this issue.
|
| |
|
|