You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2006/07/31 22:52:13 UTC

svn commit: r427257 - in /beehive/trunk/system-controls/src/ejb: build.xml org/apache/beehive/controls/system/ejb/EJBControlImpl.java

Author: cschoett
Date: Mon Jul 31 13:52:12 2006
New Revision: 427257

URL: http://svn.apache.org/viewvc?rev=427257&view=rev
Log:
A bit of cleanup for the EJBControl.  Added commons logging to lifecycle methods (JIRA-790), additionally cleaned up some minor issues which typically cause ide warnings when viewing the source code.

Modified:
    beehive/trunk/system-controls/src/ejb/build.xml
    beehive/trunk/system-controls/src/ejb/org/apache/beehive/controls/system/ejb/EJBControlImpl.java

Modified: beehive/trunk/system-controls/src/ejb/build.xml
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/ejb/build.xml?rev=427257&r1=427256&r2=427257&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/ejb/build.xml (original)
+++ beehive/trunk/system-controls/src/ejb/build.xml Mon Jul 31 13:52:12 2006
@@ -28,6 +28,7 @@
         <path refid="controls.dependency.path"/>
         <path refid="ejb.dependency.path"/>
         <path refid="velocity.dependency.path"/>
+        <path refid="commons-logging.dependency.path"/>
         <path refid="tools.dependency.path"/>
     </path>
 

Modified: beehive/trunk/system-controls/src/ejb/org/apache/beehive/controls/system/ejb/EJBControlImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/ejb/org/apache/beehive/controls/system/ejb/EJBControlImpl.java?rev=427257&r1=427256&r2=427257&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/ejb/org/apache/beehive/controls/system/ejb/EJBControlImpl.java (original)
+++ beehive/trunk/system-controls/src/ejb/org/apache/beehive/controls/system/ejb/EJBControlImpl.java Mon Jul 31 13:52:12 2006
@@ -43,6 +43,8 @@
 import org.apache.beehive.controls.api.context.ResourceContext;
 import org.apache.beehive.controls.api.context.ResourceContext.ResourceEvents;
 import org.apache.beehive.controls.api.events.EventHandler;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
 
 /**
  * The Enterprise Java Bean Control implementation class
@@ -52,6 +54,7 @@
     implements EJBControl, Extensible, java.io.Serializable {
 
     static final long serialVersionUID = 1L;
+    private static final Log LOGGER = LogFactory.getLog(EJBControlImpl.class);
 
     public static final int SESSION_BEAN = 1;
     public static final int ENTITY_BEAN = 2;
@@ -61,7 +64,10 @@
 
     @EventHandler(field = "context", eventSet = LifeCycle.class, eventName = "onCreate")
     public void onCreate() {
-        // first time initialization
+
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("Enter: onCreate()");
+        }
 
         EJBHome ejbHome = context.getControlPropertySet(EJBHome.class);
         if (ejbHome == null)
@@ -153,17 +159,17 @@
 
         Method[] ejbMethods = ejbInterface.getMethods();
         for (Method m : ejbMethods) {
-	        if (!cbMethodName.equals(m.getName())
+            if (!cbMethodName.equals(m.getName())
                     || !cbMethodReturnType.equals(m.getReturnType())) {
                 continue;
             }
 
-		    Class[] params = m.getParameterTypes();
-		    if (cbMethodParams.length == params.length) {
+            Class[] params = m.getParameterTypes();
+            if (cbMethodParams.length == params.length) {
                 int i;
                 for (i = 0; i < cbMethodParams.length; i++) {
-			        if (cbMethodParams[i] != params[i]) break;
-		        }
+                    if (cbMethodParams[i] != params[i]) break;
+                }
                 if (i == cbMethodParams.length)
                     return m;
             }
@@ -267,10 +273,10 @@
     protected javax.naming.Context getInitialContext() throws NamingException {
         if (_context == null) {
             //If naming context information is provided, then use that to create the initial context
-            JNDIContextEnv env = (JNDIContextEnv) context.getControlPropertySet(JNDIContextEnv.class);
+            JNDIContextEnv env = context.getControlPropertySet(JNDIContextEnv.class);
             String value = env.contextFactory();
             if (value != null && value.length() > 0) {
-                Hashtable ht = new Hashtable();
+                Hashtable<String, String> ht = new Hashtable<String, String>();
                 ht.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, value);
                 value = env.providerURL();
                 if (value != null && value.length() > 0)
@@ -293,6 +299,11 @@
 
     @EventHandler(field = "resourceContext", eventSet = ResourceEvents.class, eventName = "onAcquire")
     public void onAcquire() {
+
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("Enter: onAquire()");
+        }
+
         // Compute the home instance cache lookup key.  The Service URI must
         // be taken into account because different services use different
         // class loaders.  The JNDI home must be taken into account because
@@ -303,10 +314,9 @@
             // If JNDI name is an URL using a JNDI protocol
             if (_jndiName.toLowerCase().startsWith(JNDI_GLOBAL_PREFIX)) {
 
-                URLConnection jndiConn = null;
                 try {
                     URL url = new URL(_jndiName);
-                    jndiConn = url.openConnection();
+                    URLConnection jndiConn = url.openConnection();
                     _homeInstance = jndiConn.getContent();
                 }
                 catch (MalformedURLException mue) {
@@ -334,14 +344,10 @@
 
     @EventHandler(field = "resourceContext", eventSet = ResourceEvents.class, eventName = "onRelease")
     public void onRelease() {
-        //
-        // If conversational, attempt to save the bean reference,
-        // else always release it if stateless or not persistable.
-        //
-        //if (context.getService().getConversationID() == null ||
-        if (!saveBeanInstance()) {
-            releaseBeanInstance(false);
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("Enter: onRelease()");
         }
+        releaseBeanInstance(false);
     }
 
     //@EventHandler(field="context", eventSet=LifeCycle.class, eventName="onReset")