[jboss-cvs] JBossAS SVN: r88648 - projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 11 11:28:32 EDT 2009


Author: alesj
Date: 2009-05-11 11:28:32 -0400 (Mon, 11 May 2009)
New Revision: 88648

Added:
   projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/AbstractJNDIModeLifecycleCallback.java
Modified:
   projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/JNDIInstallLifecycleCallback.java
   projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/JNDIOnDemandLifecycleCallback.java
Log:
Add more exact abstract class.

Copied: projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/AbstractJNDIModeLifecycleCallback.java (from rev 88344, projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/JNDIInstallLifecycleCallback.java)
===================================================================
--- projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/AbstractJNDIModeLifecycleCallback.java	                        (rev 0)
+++ projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/AbstractJNDIModeLifecycleCallback.java	2009-05-11 15:28:32 UTC (rev 88648)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.naming.microcontainer;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerMode;
+
+/**
+ * JNDIModeLifecycleCallback.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractJNDIModeLifecycleCallback extends AbstractJNDILifecycleCallback
+{
+   /**
+    * Do we bind contexts with this mode.
+    *
+    * @param mode the context's controller mode
+    * @return true if mode is accepted, false otherwise
+    */
+   protected abstract boolean acceptsMode(ControllerMode mode);
+
+   public void install(ControllerContext context) throws Exception
+   {
+      if (acceptsMode(context.getMode()))
+         bind(context, null);
+   }
+
+   public void uninstall(ControllerContext context) throws Exception
+   {
+      if (acceptsMode(context.getMode()))
+         unbind(context, null);
+   }
+}
\ No newline at end of file

Modified: projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/JNDIInstallLifecycleCallback.java
===================================================================
--- projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/JNDIInstallLifecycleCallback.java	2009-05-11 15:19:12 UTC (rev 88647)
+++ projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/JNDIInstallLifecycleCallback.java	2009-05-11 15:28:32 UTC (rev 88648)
@@ -21,26 +21,19 @@
 */
 package org.jboss.naming.microcontainer;
 
-import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.dependency.spi.ControllerMode;
 
 /**
  * JNDIInstallLifecycleCallback.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  * @version $Revision: 1.1 $
  */
-public class JNDIInstallLifecycleCallback extends AbstractJNDILifecycleCallback
+public class JNDIInstallLifecycleCallback extends AbstractJNDIModeLifecycleCallback
 {
-   public void install(ControllerContext context) throws Exception
+   protected boolean acceptsMode(ControllerMode mode)
    {
-      if (ControllerMode.ON_DEMAND.equals(context.getMode()) == false)
-         bind(context, null);
+      return ControllerMode.ON_DEMAND.equals(mode) == false;
    }
-
-   public void uninstall(ControllerContext context) throws Exception
-   {
-      if (ControllerMode.ON_DEMAND.equals(context.getMode()) == false)
-         unbind(context, null);
-   }
 }

Modified: projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/JNDIOnDemandLifecycleCallback.java
===================================================================
--- projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/JNDIOnDemandLifecycleCallback.java	2009-05-11 15:19:12 UTC (rev 88647)
+++ projects/naming/trunk/naming-mc-int/src/main/java/org/jboss/naming/microcontainer/JNDIOnDemandLifecycleCallback.java	2009-05-11 15:28:32 UTC (rev 88648)
@@ -21,26 +21,19 @@
 */
 package org.jboss.naming.microcontainer;
 
-import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.dependency.spi.ControllerMode;
 
 /**
  * JNDIOnDemandLifecycleCallback.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  * @version $Revision: 1.1 $
  */
-public class JNDIOnDemandLifecycleCallback extends AbstractJNDILifecycleCallback
+public class JNDIOnDemandLifecycleCallback extends AbstractJNDIModeLifecycleCallback
 {
-   public void install(ControllerContext context) throws Exception
+   protected boolean acceptsMode(ControllerMode mode)
    {
-      if (ControllerMode.ON_DEMAND.equals(context.getMode()))
-         bind(context, null);
+      return ControllerMode.ON_DEMAND.equals(mode);
    }
-
-   public void uninstall(ControllerContext context) throws Exception
-   {
-      if (ControllerMode.ON_DEMAND.equals(context.getMode()))
-         unbind(context, null);
-   }
 }




More information about the jboss-cvs-commits mailing list