Commits

Anonymous committed 804268b

Issue number: QUARTZ-303
Obtained from:
Submitted by:
Reviewed by:
CVS: ----------------------------------------------------------------------
CVS: Issue number:
CVS: If this change addresses one or more issues,
CVS: then enter the issue number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to the project by someone else; i.e.,
CVS: they sent us a patch or a set of diffs, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.

git-svn-id: http://svn.opensymphony.com/svn/quartz/branches/b_quartz_1-5-x@31069f7d36a-ea1c-0410-88ea-9fd03e4c9665

  • Participants
  • Parent commits 8526254
  • Branches b_quartz_1-5-x

Comments (0)

Files changed (1)

File src/jboss/org/quartz/ee/jmx/jboss/QuartzService.java

 import java.io.StringWriter;
 import java.util.Properties;
 
-import javax.naming.CompositeName;
-import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.Name;
 import javax.naming.NamingException;
         this.jndiName = jndiName;
 
         if (super.getState() == STARTED) {
-            try {
-                unbind(oldName);
-            } catch (NamingException ne) {
-                log.error(captureStackTrace(ne));
-
-                throw new SchedulerConfigException(
-                        "Failed to unbind Scheduler - ", ne);
-            }
+            unbind(oldName);
 
             try {
                 rebind();
                     "Failed to shutdown Scheduler - ");
         }
 
-        try {
-            unbind(jndiName);
-        } catch (NamingException ne) {
-            log.error(captureStackTrace(ne));
-
-            throw new SchedulerConfigException("Failed to unbind Scheduler - ");
-        }
+        unbind(jndiName);
 
         log.info("QuartzService(" + jndiName + ") stopped.");
     }
         return sw.toString();
     }
 
-    private static Context createContext(Context rootCtx, Name name)
-            throws NamingException {
-        Context subctx = rootCtx;
-
-        for (int n = 0; n < name.size(); n++) {
-            String atom = name.get(n);
-
-            try {
-                Object obj = subctx.lookup(atom);
-                subctx = (Context) obj;
-            } catch (NamingException e) {
-                // No binding exists, create a subcontext
-                subctx = subctx.createSubcontext(atom);
-            }
-        }
-
-        return subctx;
-    }
-
-    private void rebind() throws Exception {
-        
-        InitialContext rootCtx = null;
-        
-        try {
-            rootCtx = new InitialContext();
-    
-            // Get the parent context into which we are to bind
-            Name fullName = rootCtx.getNameParser("").parse(jndiName);
-    
-            Name parentName = fullName;
-    
-            if (fullName.size() > 1) {
-                parentName = fullName.getPrefix(fullName.size() - 1);
-            } else {
-                parentName = new CompositeName();
-            }
+     private void rebind() throws Exception
+     {
+         InitialContext rootCtx = new InitialContext();
+         Name fullName = rootCtx.getNameParser("").parse(jndiName);
+         Scheduler scheduler = schedulerFactory.getScheduler();
+         NonSerializableFactory.rebind(fullName, scheduler, true);
+     }
     
-            Context parentCtx = createContext(rootCtx, parentName);
-            Name atomName = fullName.getSuffix(fullName.size() - 1);
-            String atom = atomName.get(0);
-    
-            Scheduler scheduler = schedulerFactory.getScheduler();
-    
-            NonSerializableFactory.rebind(parentCtx, atom, scheduler);
-        }
-        finally {
-            if(rootCtx != null) try { rootCtx.close(); } catch(Exception ignore) {} 
-        }
-    }
-
-    private void unbind(String jndiName) throws NamingException {
-        InitialContext rootCtx = null;
-        
-        try {
-            rootCtx = new InitialContext();
-
-            Name fullName = rootCtx.getNameParser("").parse(jndiName);
-            Name atomName = fullName.getSuffix(fullName.size() - 1);
-            String atom = atomName.get(0);
-    
-            rootCtx.unbind(jndiName);
-            NonSerializableFactory.unbind(atom);
-        }
-        finally {
-            if(rootCtx != null) try { rootCtx.close(); } catch(Exception ignore) {} 
-        }
-    }
-
+     private void unbind(String jndiName)
+     {
+         try
+         {
+             InitialContext rootCtx = new InitialContext();
+             rootCtx.unbind(jndiName);
+             NonSerializableFactory.unbind(jndiName);
+         }
+         catch (NamingException e)
+         {
+             e.printStackTrace();
+         }
+     }
 }