geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r634792 [7/9] - in /geronimo/sandbox/concurrent: ./ concurrent-deployer/ concurrent-deployer/src/ concurrent-deployer/src/main/ concurrent-deployer/src/main/plan/ concurrent/ concurrent/src/ concurrent/src/main/ concurrent/src/main/plan/ ge...
Date Fri, 07 Mar 2008 19:56:28 GMT
Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/ContextHandlerUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/ContextHandlerUtils.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/ContextHandlerUtils.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/ContextHandlerUtils.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,55 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.concurrent.ManagedContextHandler;
+
+public class ContextHandlerUtils {
+        
+    private final static Log LOG = LogFactory.getLog(ContextHandlerUtils.class);
+    
+    public static List<ManagedContextHandler> loadHandlers(ClassLoader classLoader,
+                                                           String[] handlerClasses) {
+        List<ManagedContextHandler> handlers = new ArrayList<ManagedContextHandler>();
+        if (handlerClasses != null) {
+            for (String handlerClass : handlerClasses) {
+                try {
+                    handlers.add(loadHandler(classLoader, handlerClass.trim()));
+                } catch (Exception e) {
+                    LOG.warn("Failed to load context handler class " + handlerClass, e);
+                }
+            }
+        }
+        return handlers;
+    }
+    
+    public static ManagedContextHandler loadHandler(ClassLoader classLoader, 
+                                                    String className)
+        throws Exception {
+        Class clazz = classLoader.loadClass(className);
+        if (!ManagedContextHandler.class.isAssignableFrom(clazz)) {
+            throw new Exception("Class " + className + " is not a ManagedContextHandler class");
+        }
+        return (ManagedContextHandler) clazz.newInstance();
+    }
+               
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/ContextHandlerUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/ContextHandlerUtils.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GBeanBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GBeanBuilder.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GBeanBuilder.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GBeanBuilder.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,93 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl;
+
+import java.util.Hashtable;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.management.impl.InvalidObjectNameException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelException;
+import org.apache.geronimo.kernel.ObjectNameUtil;
+import org.apache.geronimo.kernel.management.State;
+
+public class GBeanBuilder {
+    
+    protected Kernel kernel;
+    protected ClassLoader classLoader;
+
+    public GBeanBuilder(Kernel kernel, ClassLoader classLoader) {
+        this.kernel = kernel;
+        this.classLoader = classLoader;        
+    }
+    
+    /* in memory */
+    protected void addGBeanKernel(AbstractName gbeanName, GBeanData threadData) throws KernelException {
+        kernel.loadGBean(threadData, this.classLoader);           
+        kernel.startRecursiveGBean(gbeanName);
+    }
+    
+    /* in memory */
+    protected void removeGBeanKernel(AbstractName gbeanName) {
+        try {
+            if (kernel.getGBeanState(gbeanName) == State.RUNNING_INDEX) {
+                kernel.stopGBean(gbeanName);
+            }
+            kernel.unloadGBean(gbeanName);
+        } catch (GBeanNotFoundException e) {
+            // Bean is no longer loaded
+        }
+    }
+    
+    /**
+     * ObjectName must match this pattern: 
+     * domain:j2eeType=&lt;j2eeType&gt;,name=MyName,J2EEServer=MyServer
+     */
+    public static void verifyObjectName(String objectNameStr, String j2eeType, String name) {
+        ObjectName objectName = ObjectNameUtil.getObjectName(objectNameStr);
+        if (objectName.isPattern()) {
+            throw new InvalidObjectNameException(
+                    "ObjectName can not be a pattern", objectName);
+        }
+        Hashtable keyPropertyList = objectName.getKeyPropertyList();
+        if (!j2eeType.equals(keyPropertyList.get("j2eeType"))) {
+            throw new InvalidObjectNameException(
+                    name + " object name j2eeType property must be '" + j2eeType + "'",
+                    objectName);
+        }
+        if (!keyPropertyList.containsKey(NameFactory.J2EE_NAME)) {
+            throw new InvalidObjectNameException(
+                    name + " object must contain a name property", 
+                    objectName);
+        }
+        if (!keyPropertyList.containsKey(NameFactory.J2EE_SERVER)) {
+            throw new InvalidObjectNameException(
+                    name + " object name must contain a J2EEServer property",
+                    objectName);
+        }
+        if (keyPropertyList.size() != 3) {
+            throw new InvalidObjectNameException(
+                    name + " object name can only have j2eeType, name, and J2EEServer properties",
+                    objectName);
+        }
+    }
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GBeanBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GBeanBuilder.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContext.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContext.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContext.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.concurrent.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.geronimo.concurrent.ManagedContext;
+import org.apache.geronimo.concurrent.ManagedContextHandler;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelRegistry;
+import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
+
+public class GeronimoManagedContext extends ManagedContext {
+
+    private ModuleLifecycleListener moduleLifecyleListener;
+
+    public GeronimoManagedContext(ManagedContextHandler contextHandler,
+                                  Map<String, Object> capturedContext,
+                                  AbstractName moduleName) {
+        super(contextHandler, capturedContext);
+        
+        if (moduleName != null) {
+            this.moduleLifecyleListener = ModuleLifecycleListener.getModuleLifecycleListener(moduleName);
+        }
+    }
+
+    public boolean isValid() {
+        return (this.moduleLifecyleListener == null) ? true : this.moduleLifecyleListener.isRunning();
+    }
+    
+    private static class ModuleLifecycleListener implements LifecycleListener {
+
+        private static Map<AbstractName, ModuleLifecycleListener> listeners = 
+            new HashMap<AbstractName, ModuleLifecycleListener>();
+        
+        private final AbstractName moduleName;
+        private boolean running;
+        
+        public ModuleLifecycleListener(AbstractName moduleName) {
+            this.moduleName = moduleName;
+            this.running = true;
+        }
+                
+        public boolean isRunning() {
+            return this.running;
+        }
+        
+        public AbstractName getModuleName() {
+            return this.moduleName;
+        }
+        
+        public void failed(AbstractName arg0) {
+            this.running = false;
+        }
+
+        public void loaded(AbstractName arg0) {
+            this.running = false;
+        }
+
+        public void running(AbstractName arg0) {
+            this.running = true;
+        }
+
+        public void starting(AbstractName arg0) {
+            this.running = false;
+        }
+
+        public void stopped(AbstractName arg0) {
+            this.running = false;            
+        }
+
+        public void stopping(AbstractName arg0) {
+            this.running = false;
+        }
+
+        public void unloaded(AbstractName arg0) { 
+            this.running = false;
+            removeModuleLifecycleListener(this.moduleName);
+        }
+        
+        public static synchronized ModuleLifecycleListener getModuleLifecycleListener(AbstractName moduleName) {
+            ModuleLifecycleListener listener = listeners.get(moduleName);
+            if (listener == null) {
+                listener = new ModuleLifecycleListener(moduleName);
+                
+                // register listener with Kernel
+                AbstractNameQuery query = new AbstractNameQuery(moduleName);
+                Kernel kernel = KernelRegistry.getSingleKernel();
+                kernel.getLifecycleMonitor().addLifecycleListener(listener, query);
+                
+                listeners.put(moduleName, listener);
+            }
+            return listener;
+        }
+        
+        private static synchronized void removeModuleLifecycleListener(AbstractName moduleName) {
+            listeners.remove(moduleName);
+        }
+        
+    }
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContext.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContextBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContextBuilder.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContextBuilder.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContextBuilder.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.concurrent.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.geronimo.concurrent.ManagedContext;
+import org.apache.geronimo.concurrent.ManagedContextHandler;
+import org.apache.geronimo.concurrent.impl.executor.ManagedExecutorServiceModuleFacade;
+import org.apache.geronimo.concurrent.spi.ManagedContextBuilder;
+import org.apache.geronimo.gbean.AbstractName;
+
+public class GeronimoManagedContextBuilder extends ManagedContextBuilder {
+
+    public ManagedContext buildManagedContext(ManagedContextHandler contextHandler) {        
+        // save context
+        Map<String, Object> capturedContext = new HashMap<String, Object>();
+        contextHandler.saveContext(capturedContext);
+        
+        // determine module name
+        AbstractName moduleID = ManagedExecutorServiceModuleFacade.getCurrentModule();
+        
+        return new GeronimoManagedContext(contextHandler, capturedContext, moduleID);
+    }
+
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContextBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/GeronimoManagedContextBuilder.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/NotificationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/NotificationHelper.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/NotificationHelper.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/NotificationHelper.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,70 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.system.jmx.MBeanServerKernelBridge;
+
+public class NotificationHelper {
+    
+    private final static Log LOG = LogFactory.getLog(NotificationHelper.class);
+    
+    private AtomicInteger notificationSequence = new AtomicInteger(1);
+    private NotificationBroadcasterSupport notificationBroadcasterSupport;
+    private String objectName;
+    
+    public NotificationHelper(Kernel kernel, AbstractName name) {
+        this.notificationBroadcasterSupport = getNotificationBroadcasterSupport(kernel, name);
+        this.objectName = name.getObjectName().getCanonicalName();
+    }
+        
+    private static NotificationBroadcasterSupport getNotificationBroadcasterSupport(Kernel kernel,
+                                                                                    AbstractName name) {
+        try {
+            MBeanServerKernelBridge bridge = 
+                (MBeanServerKernelBridge)kernel.getGBean(MBeanServerKernelBridge.class);
+            return bridge.getNotificationBroadcasterSupport(name);
+        } catch (Exception e) {
+            LOG.debug("Failed to lookup MBeanServerKernelBridge", e);
+            return null;
+        }
+    }
+               
+    public boolean isNotificationSupported() {
+        return (this.notificationBroadcasterSupport != null);        
+    }
+    
+    public void sendNotification(String type, Object userData) {
+        if (!isNotificationSupported()) {
+            return;
+        }
+        Notification notification = new Notification(type,
+                                                     this.objectName, 
+                                                     this.notificationSequence.getAndIncrement());
+        notification.setUserData(userData);
+        
+        this.notificationBroadcasterSupport.sendNotification(notification);
+    }
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/NotificationHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/NotificationHelper.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/context/ContextServiceGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/context/ContextServiceGBean.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/context/ContextServiceGBean.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/context/ContextServiceGBean.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,71 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl.context;
+
+import java.util.List;
+
+import org.apache.geronimo.concurrent.ManagedContextHandler;
+import org.apache.geronimo.concurrent.ManagedContextHandlerChain;
+import org.apache.geronimo.concurrent.context.BasicContextService;
+import org.apache.geronimo.concurrent.impl.ContextHandlerUtils;
+import org.apache.geronimo.concurrent.naming.ModuleAwareResourceSource;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
+
+public class ContextServiceGBean implements ModuleAwareResourceSource {
+
+    public static final GBeanInfo GBEAN_INFO;
+    
+    private ManagedContextHandlerChain mainContextHandler;
+
+    public ContextServiceGBean(Kernel kernel, 
+                               ClassLoader classLoader,
+                               AbstractName name,
+                               String[] contextHandlerClasses) {
+        List<ManagedContextHandler> handlers = 
+            ContextHandlerUtils.loadHandlers(classLoader, contextHandlerClasses);
+        this.mainContextHandler = new ManagedContextHandlerChain(handlers);
+    }
+    
+    public Object $getResource(AbstractName moduleID) {
+        return new BasicContextService(this.mainContextHandler);
+    }
+    
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ContextServiceGBean.class, "ContextService");
+
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false, false);
+        infoFactory.addAttribute("abstractName", AbstractName.class, false, false);
+        infoFactory.addAttribute("kernel", Kernel.class, false, false);
+        
+        infoFactory.addAttribute("contextHandlers", String[].class, true);
+
+        infoFactory.setConstructor(new String[] {"kernel", 
+                                                 "classLoader", 
+                                                 "abstractName",
+                                                 "contextHandlers"} );
+        
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+         
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/context/ContextServiceGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/context/ContextServiceGBean.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedExecutorServiceGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedExecutorServiceGBean.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedExecutorServiceGBean.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedExecutorServiceGBean.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,141 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl.executor;
+
+import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import javax.util.concurrent.ManagedExecutorService;
+import javax.util.concurrent.ManagedThreadFactory;
+
+import org.apache.geronimo.concurrent.ManagedContextHandler;
+import org.apache.geronimo.concurrent.ManagedContextHandlerChain;
+import org.apache.geronimo.concurrent.executor.ComponentManagedExecutorService;
+import org.apache.geronimo.concurrent.executor.ManagedExecutorServiceFacade;
+import org.apache.geronimo.concurrent.impl.ContextHandlerUtils;
+import org.apache.geronimo.concurrent.impl.thread.GeronimoManagedThreadFactorySource;
+import org.apache.geronimo.concurrent.naming.ModuleAwareResourceSource;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.management.ManagedConstants;
+
+public class ComponentManagedExecutorServiceGBean implements GBeanLifecycle, ModuleAwareResourceSource {
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    protected ManagedExecutorService executor;
+
+    protected int minPoolSize;
+    protected int maxPoolSize;
+    protected long keepAliveTime;
+    protected int queueCapacity;
+    protected ManagedThreadFactory threadFactory;    
+    protected ManagedContextHandlerChain contextHandler;
+   
+    public ComponentManagedExecutorServiceGBean(ClassLoader classLoader,
+                                                int minPoolSize,
+                                                int maxPoolSize,
+                                                long keepAliveTime,
+                                                int queueCapacity,
+                                                GeronimoManagedThreadFactorySource threadFactorySource,
+                                                String[] contextHandlerClasses) {
+        this.minPoolSize = minPoolSize;
+        this.maxPoolSize = maxPoolSize;
+        this.keepAliveTime = keepAliveTime;
+        this.queueCapacity = queueCapacity;
+        this.threadFactory = threadFactorySource.getManagedThreadFactory();
+        List<ManagedContextHandler> handlers = 
+            ContextHandlerUtils.loadHandlers(classLoader, contextHandlerClasses);
+        this.contextHandler = new ManagedContextHandlerChain(handlers);
+    }
+
+    protected synchronized ManagedExecutorService getManagedExecutorService() {
+        if (this.executor == null) {
+            BlockingQueue<Runnable> queue = null;
+            if (this.queueCapacity <= 0) {
+                queue = new LinkedBlockingQueue<Runnable>();
+            } else {
+                queue = new ArrayBlockingQueue<Runnable>(this.queueCapacity); 
+            }
+            this.executor = new ComponentManagedExecutorService(this.minPoolSize,
+                                                                this.maxPoolSize,
+                                                                this.keepAliveTime,
+                                                                TimeUnit.MILLISECONDS,
+                                                                queue, 
+                                                                this.threadFactory,
+                                                                this.contextHandler);
+        }
+        return this.executor;        
+    }
+    
+    protected synchronized void shutdownExecutor() {
+        if (this.executor != null) {
+            this.executor.shutdown();
+        }
+    }
+    
+    public Object $getResource(AbstractName moduleID) {
+        return new ManagedExecutorServiceFacade(getManagedExecutorService(), false);
+    }
+
+    public void doStart() throws Exception {
+    }
+
+    public void doFail() {
+        shutdownExecutor();
+    }
+    
+    public void doStop() throws Exception {
+        doFail();
+    }
+
+    static {
+        GBeanInfoBuilder infoFactory = 
+            GBeanInfoBuilder.createStatic(ComponentManagedExecutorServiceGBean.class, 
+                                          ManagedConstants.MANAGED_EXECUTOR_SERVICE);
+
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
+        
+        infoFactory.addAttribute("minPoolSize", int.class, true);
+        infoFactory.addAttribute("maxPoolSize", int.class, true);
+        infoFactory.addAttribute("keepAliveTime", long.class, true);
+        infoFactory.addAttribute("queueCapacity", int.class, true);
+        infoFactory.addAttribute("contextHandlers", String[].class, true);
+
+        infoFactory.addReference("threadFactory", GeronimoManagedThreadFactorySource.class);
+
+        infoFactory.setConstructor(new String[] { "classLoader",
+                                                  "minPoolSize", 
+                                                  "maxPoolSize", 
+                                                  "keepAliveTime", 
+                                                  "queueCapacity",
+                                                  "threadFactory",
+                                                  "contextHandlers" });
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedExecutorServiceGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedExecutorServiceGBean.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedScheduledExecutorServiceGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedScheduledExecutorServiceGBean.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedScheduledExecutorServiceGBean.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedScheduledExecutorServiceGBean.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,112 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl.executor;
+
+import java.util.List;
+
+import javax.util.concurrent.ManagedScheduledExecutorService;
+import javax.util.concurrent.ManagedThreadFactory;
+
+import org.apache.geronimo.concurrent.ManagedContextHandler;
+import org.apache.geronimo.concurrent.ManagedContextHandlerChain;
+import org.apache.geronimo.concurrent.executor.ComponentManagedScheduledExecutorService;
+import org.apache.geronimo.concurrent.executor.ManagedScheduledExecutorServiceFacade;
+import org.apache.geronimo.concurrent.impl.ContextHandlerUtils;
+import org.apache.geronimo.concurrent.impl.thread.GeronimoManagedThreadFactorySource;
+import org.apache.geronimo.concurrent.naming.ModuleAwareResourceSource;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.management.ManagedConstants;
+
+public class ComponentManagedScheduledExecutorServiceGBean implements GBeanLifecycle, ModuleAwareResourceSource {
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    protected ManagedScheduledExecutorService executor;
+
+    protected int corePoolSize;
+    protected ManagedThreadFactory threadFactory;    
+    protected ManagedContextHandlerChain contextHandler;
+   
+    public ComponentManagedScheduledExecutorServiceGBean(ClassLoader classLoader,
+                                                         int corePoolSize,
+                                                         GeronimoManagedThreadFactorySource threadFactorySource,
+                                                         String[] contextHandlerClasses) {
+        this.corePoolSize = corePoolSize;
+        this.threadFactory = threadFactorySource.getManagedThreadFactory();
+        List<ManagedContextHandler> handlers = 
+            ContextHandlerUtils.loadHandlers(classLoader, contextHandlerClasses);
+        this.contextHandler = new ManagedContextHandlerChain(handlers);
+    }
+
+    protected synchronized ManagedScheduledExecutorService getManagedScheduledExecutorService() {
+        if (this.executor == null) {
+            this.executor = new ComponentManagedScheduledExecutorService(this.corePoolSize, 
+                                                                         this.threadFactory,
+                                                                         this.contextHandler);
+        }
+        return this.executor;        
+    }
+    
+    protected synchronized void shutdownExecutor() {
+        if (this.executor != null) {
+            this.executor.shutdown();
+        }
+    }
+    
+    public Object $getResource(AbstractName moduleID) {
+        return new ManagedScheduledExecutorServiceFacade(getManagedScheduledExecutorService(), false);
+    }
+
+    public void doStart() throws Exception {
+    }
+
+    public void doFail() {
+        shutdownExecutor();
+    }
+    
+    public void doStop() throws Exception {
+        doFail();
+    }
+
+    static {
+        GBeanInfoBuilder infoFactory = 
+            GBeanInfoBuilder.createStatic(ComponentManagedScheduledExecutorServiceGBean.class, 
+                                          ManagedConstants.MANAGED_EXECUTOR_SERVICE);
+
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
+        
+        infoFactory.addAttribute("corePoolSize", int.class, true);
+        infoFactory.addAttribute("contextHandlers", String[].class, true);
+
+        infoFactory.addReference("threadFactory", GeronimoManagedThreadFactorySource.class);
+
+        infoFactory.setConstructor(new String[] { "classLoader",
+                                                  "corePoolSize", 
+                                                  "threadFactory",
+                                                  "contextHandlers" });
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedScheduledExecutorServiceGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ComponentManagedScheduledExecutorServiceGBean.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedExecutorServiceModuleFacade.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedExecutorServiceModuleFacade.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedExecutorServiceModuleFacade.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedExecutorServiceModuleFacade.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,219 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl.executor;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import javax.util.concurrent.ManagedExecutorService;
+import javax.util.concurrent.ManagedTaskListener;
+
+import org.apache.geronimo.concurrent.executor.ManagedExecutorServiceFacade;
+import org.apache.geronimo.gbean.AbstractName;
+
+public class ManagedExecutorServiceModuleFacade extends ManagedExecutorServiceFacade {
+    
+    private static ThreadLocal<AbstractName> moduleThreadLocal = new ThreadLocal<AbstractName>();
+    
+    private AbstractName moduleID;
+
+    public ManagedExecutorServiceModuleFacade(ManagedExecutorService executor,
+                                              AbstractName moduleID) {
+        super(executor, true);
+        this.moduleID = moduleID;
+    }
+    
+    protected Object before() {
+        moduleThreadLocal.set(this.moduleID);
+        return null;
+    }
+    
+    protected void after(Object obj) {
+        moduleThreadLocal.remove();
+    }
+    
+    public static AbstractName getCurrentModule() {
+        return moduleThreadLocal.get();
+    }
+    
+    public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks, 
+                                         ManagedTaskListener listener)
+        throws InterruptedException {
+        Object rs = before();
+        try {
+            return this.executor.invokeAll(tasks, listener);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks,
+                                         long timeout,
+                                         TimeUnit unit,
+                                         ManagedTaskListener listener) 
+        throws InterruptedException {
+        Object rs = before();
+        try {
+            return this.executor.invokeAll(tasks, timeout, unit, listener);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public <T> T invokeAny(Collection<Callable<T>> tasks, 
+                           ManagedTaskListener listener)
+        throws InterruptedException, 
+               ExecutionException {
+        Object rs = before();
+        try {
+            return this.executor.invokeAny(tasks, listener);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public <T> T invokeAny(Collection<Callable<T>> tasks,
+                           long timeout,
+                           TimeUnit unit,
+                           ManagedTaskListener listener) 
+        throws InterruptedException,
+               ExecutionException, 
+               TimeoutException {
+        Object rs = before();
+        try {
+            return this.executor.invokeAny(tasks, timeout, unit, listener);
+        } finally {
+            after(rs);
+        }           
+    }
+
+    public Future<?> submit(Runnable command, ManagedTaskListener listener) {
+        Object rs = before();
+        try {            
+            return this.executor.submit(command, listener);
+        } finally {
+            after(rs);
+        }      
+    }
+
+    public <T> Future<T> submit(Callable<T> callable, ManagedTaskListener listener) {
+        Object rs = before();
+        try {
+            return this.executor.submit(callable, listener);
+        } finally {
+            after(rs);
+        } 
+    }
+
+    public <T> Future<T> submit(Runnable command, T result, ManagedTaskListener listener) {            
+        Object rs = before();
+        try {
+            return this.executor.submit(command, result, listener);
+        } finally {
+            after(rs);
+        } 
+    }
+
+    public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks) 
+        throws InterruptedException {
+        Object rs = before();
+        try {
+            return this.executor.invokeAll(tasks);
+        } finally {
+            after(rs);
+        } 
+    }
+
+    public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks, 
+                                         long timeout, 
+                                         TimeUnit unit)
+        throws InterruptedException {        
+        Object rs = before();
+        try {
+            return this.executor.invokeAll(tasks, timeout, unit);
+        } finally {
+            after(rs);
+        } 
+    }
+
+    public <T> T invokeAny(Collection<Callable<T>> tasks) 
+        throws InterruptedException,
+               ExecutionException {
+        Object rs = before();
+        try {
+            return this.executor.invokeAny(tasks);
+        } finally {
+            after(rs);
+        } 
+    }
+
+    public <T> T invokeAny(Collection<Callable<T>> tasks, 
+                           long timeout, 
+                           TimeUnit unit)
+        throws InterruptedException, 
+               ExecutionException, 
+               TimeoutException {
+        Object rs = before();
+        try {
+            return this.executor.invokeAny(tasks, timeout, unit);
+        } finally {
+            after(rs);
+        } 
+    }
+
+    public <T> Future<T> submit(Callable<T> task) {
+        Object rs = before();
+        try {
+            return this.executor.submit(task);
+        } finally {
+            after(rs);
+        } 
+    }
+
+    public Future<?> submit(Runnable task) {
+        Object rs = before();
+        try {
+            return this.executor.submit(task);
+        } finally {
+            after(rs);
+        } 
+    }
+
+    public <T> Future<T> submit(Runnable task, T result) {
+        Object rs = before();
+        try {
+            return this.executor.submit(task, result);
+        } finally {
+            after(rs);
+        } 
+    }
+
+    public void execute(Runnable command) {
+        Object rs = before();
+        try {
+            this.executor.execute(command);
+        } finally {
+            after(rs);
+        } 
+    }
+           
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedExecutorServiceModuleFacade.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedExecutorServiceModuleFacade.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedScheduledExecutorServiceModuleFacade.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedScheduledExecutorServiceModuleFacade.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedScheduledExecutorServiceModuleFacade.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedScheduledExecutorServiceModuleFacade.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,156 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl.executor;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import javax.util.concurrent.ManagedScheduledExecutorService;
+import javax.util.concurrent.ManagedTaskListener;
+import javax.util.concurrent.Trigger;
+
+import org.apache.geronimo.gbean.AbstractName;
+
+public class ManagedScheduledExecutorServiceModuleFacade 
+    extends ManagedExecutorServiceModuleFacade 
+    implements ManagedScheduledExecutorService {
+    
+    public ManagedScheduledExecutorServiceModuleFacade(ManagedScheduledExecutorService executor,
+                                                       AbstractName moduleID) {
+        super(executor, moduleID);
+    }
+
+    private ManagedScheduledExecutorService getExecutor() {
+        return (ManagedScheduledExecutorService)this.executor;
+    }
+    
+    public ScheduledFuture<?> schedule(Runnable command, 
+                                       Trigger trigger, 
+                                       ManagedTaskListener listener) {
+        Object rs = before();
+        try {
+            return getExecutor().schedule(command, trigger, listener);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public <V> ScheduledFuture<V> schedule(Callable<V> callable, 
+                                           Trigger trigger, 
+                                           ManagedTaskListener listener) {
+        Object rs = before();
+        try {
+            return getExecutor().schedule(callable, trigger, listener);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public ScheduledFuture<?> schedule(Runnable command,
+                                       long initialDelay,
+                                       TimeUnit unit,
+                                       ManagedTaskListener listener) {
+        Object rs = before();
+        try {
+            return getExecutor().schedule(command, initialDelay, unit, listener);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public <V> ScheduledFuture<V> schedule(Callable<V> callable,
+                                           long initialDelay,
+                                           TimeUnit unit,
+                                           ManagedTaskListener listener) {
+        Object rs = before();
+        try {
+            return getExecutor().schedule(callable, initialDelay, unit, listener);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
+                                                  long initialDelay,
+                                                  long period,
+                                                  TimeUnit unit,
+                                                  ManagedTaskListener listener) {
+        Object rs = before();
+        try {
+            return getExecutor().scheduleAtFixedRate(command, initialDelay, period, unit, listener);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
+                                                     long initialDelay,
+                                                     long delay,
+                                                     TimeUnit unit,
+                                                     ManagedTaskListener listener) {
+        Object rs = before();
+        try {
+            return getExecutor().scheduleWithFixedDelay(command, initialDelay, delay, unit, listener);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
+        Object rs = before();
+        try {
+            return getExecutor().schedule(command, delay, unit);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
+        Object rs = before();
+        try {
+            return getExecutor().schedule(callable, delay, unit);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public ScheduledFuture<?> scheduleAtFixedRate(Runnable command,
+                                                  long initialDelay,
+                                                  long period,
+                                                  TimeUnit unit) {
+        Object rs = before();
+        try {
+            return getExecutor().scheduleAtFixedRate(command, initialDelay, period, unit);
+        } finally {
+            after(rs);
+        }
+    }
+
+    public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,
+                                                     long initialDelay,
+                                                     long delay,
+                                                     TimeUnit unit) {
+        Object rs = before();
+        try {
+            return getExecutor().scheduleWithFixedDelay(command, initialDelay, delay, unit);
+        } finally {
+            after(rs);
+        }
+    }
+          
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedScheduledExecutorServiceModuleFacade.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ManagedScheduledExecutorServiceModuleFacade.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceGBean.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceGBean.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceGBean.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,159 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl.executor;
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import javax.util.concurrent.ManagedExecutorService;
+
+import org.apache.geronimo.concurrent.executor.ServerManagedExecutorService;
+import org.apache.geronimo.concurrent.impl.GBeanBuilder;
+import org.apache.geronimo.concurrent.impl.NotificationHelper;
+import org.apache.geronimo.concurrent.impl.thread.GeronimoManagedThreadFactorySource;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.management.EventProvider;
+import org.apache.geronimo.management.ManagedConstants;
+
+public class ServerManagedExecutorServiceGBean extends ComponentManagedExecutorServiceGBean implements EventProvider, org.apache.geronimo.management.ManagedExecutorService {
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    private AbstractName name;
+    
+    private ServerManagedThreadFactory threadFactory;
+    
+    public ServerManagedExecutorServiceGBean(Kernel kernel,                                              
+                                             AbstractName name, 
+                                             ClassLoader classLoader, 
+                                             int minPoolSize,
+                                             int maxPoolSize,
+                                             long keepAliveTime,
+                                             int queueCapacity,
+                                             GeronimoManagedThreadFactorySource threadFactorySource,
+                                             String[] contextHandlerClasses) {
+        super(classLoader, minPoolSize, maxPoolSize, keepAliveTime, queueCapacity, threadFactorySource, contextHandlerClasses);               
+        this.name = name;    
+        
+        NotificationHelper notificationHelper = new NotificationHelper(kernel, name);
+        this.threadFactory = new ServerManagedThreadFactory(threadFactorySource.getManagedThreadFactory(), notificationHelper);
+    }
+          
+    protected synchronized ManagedExecutorService getManagedExecutorService() {
+        if (this.executor == null) {
+            BlockingQueue<Runnable> queue = null;
+            if (this.queueCapacity <= 0) {
+                queue = new LinkedBlockingQueue<Runnable>();
+            } else {
+                queue = new ArrayBlockingQueue<Runnable>(this.queueCapacity); 
+            }
+            this.executor = new ServerManagedExecutorService(this.minPoolSize,
+                                                             this.maxPoolSize,
+                                                             this.keepAliveTime,
+                                                             TimeUnit.MILLISECONDS,
+                                                             queue,
+                                                             this.threadFactory,
+                                                             this.contextHandler);
+        }
+        return this.executor;        
+    }
+        
+    @Override
+    public Object $getResource(AbstractName moduleID) {
+        return new ManagedExecutorServiceModuleFacade(getManagedExecutorService(), moduleID);
+    }
+       
+    public AbstractName getName() {
+        return this.name;
+    }
+    
+    public String getObjectName() {
+        return this.name.getObjectName().getCanonicalName();
+    }
+    
+    public String[] getEventTypes() {
+        return this.threadFactory.getEventTypes();
+    }
+
+    public String[] getHungTaskThreads() {
+        return this.threadFactory.getHungTaskThreads();
+    }
+
+    public String[] getThreads() {
+        return this.threadFactory.getThreads();
+    }
+    
+    public boolean isEventProvider() {
+        return true;
+    }
+
+    public boolean isStateManageable() {
+        return true;
+    }
+
+    public boolean isStatisticsProvider() {
+        return false;
+    }
+    
+    protected void verifyObjectName() {
+        GBeanBuilder.verifyObjectName(getObjectName(),  
+                                      ManagedConstants.MANAGED_EXECUTOR_SERVICE,
+                                      ManagedConstants.MANAGED_EXECUTOR_SERVICE);
+    }
+    
+    static {
+        GBeanInfoBuilder infoFactory = 
+            GBeanInfoBuilder.createStatic(ServerManagedExecutorServiceGBean.class, 
+                                          ManagedConstants.MANAGED_EXECUTOR_SERVICE);
+
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
+        infoFactory.addAttribute("abstractName", AbstractName.class, false);
+        infoFactory.addAttribute("kernel", Kernel.class, false);
+
+        infoFactory.addAttribute("minPoolSize", int.class, true);
+        infoFactory.addAttribute("maxPoolSize", int.class, true);
+        infoFactory.addAttribute("keepAliveTime", long.class, true);
+        infoFactory.addAttribute("queueCapacity", int.class, true);
+        infoFactory.addAttribute("contextHandlers", String[].class, true);
+        
+        infoFactory.addReference("threadFactory", GeronimoManagedThreadFactorySource.class);
+        
+        infoFactory.addInterface(org.apache.geronimo.management.ManagedExecutorService.class);
+
+        infoFactory.setConstructor(new String[] { "kernel",  
+                                                  "abstractName", 
+                                                  "classLoader",
+                                                  "minPoolSize",
+                                                  "maxPoolSize",
+                                                  "keepAliveTime",
+                                                  "queueCapacity",
+                                                  "threadFactory",
+                                                  "contextHandlers" });
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+      
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceGBean.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceWrapperGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceWrapperGBean.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceWrapperGBean.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceWrapperGBean.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,140 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl.executor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.concurrent.impl.GBeanBuilder;
+import org.apache.geronimo.concurrent.impl.thread.GeronimoManagedThreadFactorySource;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.management.ManagedConstants;
+
+/**
+ * Deploys ServerManagedExecutorServiceGBean under the right JMX object name. 
+ */
+public class ServerManagedExecutorServiceWrapperGBean 
+    extends GBeanBuilder
+    implements GBeanLifecycle {
+
+    private final static Log LOG = LogFactory.getLog(ServerManagedExecutorServiceWrapperGBean.class);
+    
+    public static final GBeanInfo GBEAN_INFO;
+
+    private AbstractName name;
+      
+    private String[] contextHandlerClasses;
+    private int minPoolSize;
+    private int maxPoolSize;
+    private long keepAliveTime;
+    private int queueCapacity;
+    
+    private AbstractName executorServiceName;
+    private ServerManagedExecutorServiceGBean executorServiceGBean;
+        
+    public ServerManagedExecutorServiceWrapperGBean(Kernel kernel,                                              
+                                                    AbstractName name, 
+                                                    ClassLoader classLoader, 
+                                                    int minPoolSize,
+                                                    int maxPoolSize,
+                                                    long keepAliveTime,
+                                                    int queueCapacity,
+                                                    GeronimoManagedThreadFactorySource threadFactorySource,
+                                                    String[] contextHandlerClasses) {   
+        super(kernel, classLoader);
+        this.name = name;
+                
+        this.contextHandlerClasses = contextHandlerClasses;
+        this.minPoolSize = minPoolSize;
+        this.maxPoolSize = maxPoolSize;
+        this.keepAliveTime = keepAliveTime;
+        this.queueCapacity = queueCapacity;        
+    }
+                    
+    public void doStart() throws Exception {   
+        String threadName =  (String)this.name.getName().get("name");
+        this.executorServiceName = kernel.getNaming().createRootName(name.getArtifact(), threadName, ManagedConstants.MANAGED_EXECUTOR_SERVICE);
+        GBeanData executorServiceData = new GBeanData(this.executorServiceName, ServerManagedExecutorServiceGBean.getGBeanInfo());
+        executorServiceData.setAttribute("contextHandlers", this.contextHandlerClasses);     
+        executorServiceData.setAttribute("minPoolSize", this.minPoolSize);
+        executorServiceData.setAttribute("maxPoolSize", this.maxPoolSize);
+        executorServiceData.setAttribute("keepAliveTime", this.keepAliveTime);
+        executorServiceData.setAttribute("queueCapacity", this.queueCapacity);
+        
+        GBeanData wrapperData = kernel.getGBeanData(this.name);
+        
+        executorServiceData.setReferencePatterns("threadFactory", 
+                wrapperData.getReferencePatterns("threadFactory"));
+        
+        addGBeanKernel(this.executorServiceName, executorServiceData);
+
+        this.executorServiceGBean = (ServerManagedExecutorServiceGBean)kernel.getGBean(this.executorServiceName);
+        this.executorServiceGBean.verifyObjectName();
+    }
+                
+    public void doFail() {
+        try {
+            doStop();
+        } catch (Exception e) {
+            // ignore
+        }
+    }
+    
+    public void doStop() throws Exception {
+        this.executorServiceGBean = null;
+        if (this.executorServiceName != null) {
+            removeGBeanKernel(this.executorServiceName);
+        }
+    }
+    
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ServerManagedExecutorServiceWrapperGBean.class, ManagedConstants.MANAGED_THREAD_FACTORY + "Builder");
+
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false, false);
+        infoFactory.addAttribute("abstractName", AbstractName.class, false, false);
+        infoFactory.addAttribute("kernel", Kernel.class, false, false);
+                
+        infoFactory.addAttribute("minPoolSize", int.class, true);
+        infoFactory.addAttribute("maxPoolSize", int.class, true);
+        infoFactory.addAttribute("keepAliveTime", long.class, true);
+        infoFactory.addAttribute("queueCapacity", int.class, true);
+        infoFactory.addAttribute("contextHandlers", String[].class, true);
+        
+        infoFactory.addReference("threadFactory", GeronimoManagedThreadFactorySource.class);
+        
+        infoFactory.setConstructor(new String[] { "kernel",  
+                                                  "abstractName", 
+                                                  "classLoader",
+                                                  "minPoolSize",
+                                                  "maxPoolSize",
+                                                  "keepAliveTime",
+                                                  "queueCapacity",
+                                                  "threadFactory",
+                                                  "contextHandlers" });
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceWrapperGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedExecutorServiceWrapperGBean.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceGBean.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceGBean.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceGBean.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,135 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl.executor;
+
+import javax.util.concurrent.ManagedScheduledExecutorService;
+
+import org.apache.geronimo.concurrent.executor.ServerManagedScheduledExecutorService;
+import org.apache.geronimo.concurrent.impl.GBeanBuilder;
+import org.apache.geronimo.concurrent.impl.NotificationHelper;
+import org.apache.geronimo.concurrent.impl.thread.GeronimoManagedThreadFactorySource;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.management.EventProvider;
+import org.apache.geronimo.management.ManagedConstants;
+
+public class ServerManagedScheduledExecutorServiceGBean extends ComponentManagedScheduledExecutorServiceGBean implements EventProvider, org.apache.geronimo.management.ManagedExecutorService {
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    private AbstractName name;
+    
+    private ServerManagedThreadFactory threadFactory;
+    
+    public ServerManagedScheduledExecutorServiceGBean(Kernel kernel,                                              
+                                                      AbstractName name, 
+                                                      ClassLoader classLoader, 
+                                                      int corePoolSize,
+                                                      GeronimoManagedThreadFactorySource threadFactorySource,
+                                                      String[] contextHandlerClasses) {
+        super(classLoader, corePoolSize, threadFactorySource, contextHandlerClasses);               
+        this.name = name;      
+        
+        NotificationHelper notificationHelper = new NotificationHelper(kernel, name);
+        this.threadFactory = new ServerManagedThreadFactory(threadFactorySource.getManagedThreadFactory(), notificationHelper);
+    }
+          
+    protected synchronized ManagedScheduledExecutorService getManagedScheduledExecutorService() {
+        if (this.executor == null) {
+            this.executor = new ServerManagedScheduledExecutorService(this.corePoolSize,
+                                                                      this.threadFactory,
+                                                                      this.contextHandler);
+        }
+        return this.executor;        
+    }
+        
+    @Override
+    public Object $getResource(AbstractName moduleID) {
+        return new ManagedScheduledExecutorServiceModuleFacade(getManagedScheduledExecutorService(), moduleID);
+    }
+       
+    public AbstractName getName() {
+        return this.name;
+    }
+    
+    public String getObjectName() {
+        return this.name.getObjectName().getCanonicalName();
+    }
+    
+    public String[] getEventTypes() {
+        return this.threadFactory.getEventTypes();
+    }
+
+    public String[] getHungTaskThreads() {
+        return this.threadFactory.getHungTaskThreads();
+    }
+
+    public String[] getThreads() {
+        return this.threadFactory.getThreads();
+    }
+    
+    public boolean isEventProvider() {
+        return true;
+    }
+
+    public boolean isStateManageable() {
+        return true;
+    }
+
+    public boolean isStatisticsProvider() {
+        return false;
+    }
+    
+    protected void verifyObjectName() {
+        GBeanBuilder.verifyObjectName(getObjectName(),  
+                                      ManagedConstants.MANAGED_EXECUTOR_SERVICE,
+                                      ManagedConstants.MANAGED_EXECUTOR_SERVICE);
+    }
+    
+    static {
+        GBeanInfoBuilder infoFactory = 
+            GBeanInfoBuilder.createStatic(ServerManagedScheduledExecutorServiceGBean.class, 
+                                          ManagedConstants.MANAGED_EXECUTOR_SERVICE);
+
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
+        infoFactory.addAttribute("abstractName", AbstractName.class, false);
+        infoFactory.addAttribute("kernel", Kernel.class, false);
+
+        infoFactory.addAttribute("corePoolSize", int.class, true);
+        infoFactory.addAttribute("contextHandlers", String[].class, true);
+        
+        infoFactory.addReference("threadFactory", GeronimoManagedThreadFactorySource.class);
+        
+        infoFactory.addInterface(org.apache.geronimo.management.ManagedExecutorService.class);
+
+        infoFactory.setConstructor(new String[] { "kernel",  
+                                                  "abstractName", 
+                                                  "classLoader",
+                                                  "corePoolSize",
+                                                  "threadFactory",
+                                                  "contextHandlers" });
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+      
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceGBean.java
------------------------------------------------------------------------------
    svn:executable = 

Added: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceWrapperGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceWrapperGBean.java?rev=634792&view=auto
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceWrapperGBean.java (added)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceWrapperGBean.java Fri Mar  7 11:56:14 2008
@@ -0,0 +1,122 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.concurrent.impl.executor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.concurrent.impl.GBeanBuilder;
+import org.apache.geronimo.concurrent.impl.thread.GeronimoManagedThreadFactorySource;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.management.ManagedConstants;
+
+/**
+ * Deploys ServerManagedScheduledExecutorServiceGBean under the right JMX object name. 
+ */
+public class ServerManagedScheduledExecutorServiceWrapperGBean 
+    extends GBeanBuilder
+    implements GBeanLifecycle {
+
+    private final static Log LOG = LogFactory.getLog(ServerManagedScheduledExecutorServiceWrapperGBean.class);
+    
+    public static final GBeanInfo GBEAN_INFO;
+
+    private AbstractName name;
+      
+    private int corePoolSize;
+    private String[] contextHandlerClasses;
+    
+    private AbstractName executorServiceName;
+    private ServerManagedScheduledExecutorServiceGBean executorServiceGBean;
+        
+    public ServerManagedScheduledExecutorServiceWrapperGBean(Kernel kernel,                                              
+                                                             AbstractName name, 
+                                                             ClassLoader classLoader, 
+                                                             int corePoolSize,
+                                                             GeronimoManagedThreadFactorySource threadFactorySource,
+                                                             String[] contextHandlerClasses) {       
+        super(kernel, classLoader);
+        this.name = name;
+                
+        this.contextHandlerClasses = contextHandlerClasses;
+        this.corePoolSize = corePoolSize;
+    }
+            
+    public void doStart() throws Exception {   
+        String threadName =  (String)this.name.getName().get("name");
+        this.executorServiceName = kernel.getNaming().createRootName(name.getArtifact(), threadName, ManagedConstants.MANAGED_EXECUTOR_SERVICE);
+        GBeanData executorServiceData = new GBeanData(this.executorServiceName, ServerManagedScheduledExecutorServiceGBean.getGBeanInfo());
+        executorServiceData.setAttribute("contextHandlers", this.contextHandlerClasses);     
+        executorServiceData.setAttribute("corePoolSize", this.corePoolSize);
+        
+        GBeanData wrapperData = kernel.getGBeanData(this.name);
+        
+        executorServiceData.setReferencePatterns("threadFactory", 
+                wrapperData.getReferencePatterns("threadFactory"));
+        
+        addGBeanKernel(this.executorServiceName, executorServiceData);
+
+        this.executorServiceGBean = (ServerManagedScheduledExecutorServiceGBean)kernel.getGBean(this.executorServiceName);
+        this.executorServiceGBean.verifyObjectName();
+    }
+                
+    public void doFail() {
+        try {
+            doStop();
+        } catch (Exception e) {
+            // ignore
+        }
+    }
+    
+    public void doStop() throws Exception {
+        this.executorServiceGBean = null;
+        if (this.executorServiceName != null) {
+            removeGBeanKernel(this.executorServiceName);
+        }
+    }
+    
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ServerManagedScheduledExecutorServiceWrapperGBean.class, ManagedConstants.MANAGED_THREAD_FACTORY + "Builder");
+
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false, false);
+        infoFactory.addAttribute("abstractName", AbstractName.class, false, false);
+        infoFactory.addAttribute("kernel", Kernel.class, false, false);
+                
+        infoFactory.addAttribute("corePoolSize", int.class, true);
+        infoFactory.addAttribute("contextHandlers", String[].class, true);
+        
+        infoFactory.addReference("threadFactory", GeronimoManagedThreadFactorySource.class);
+        
+        infoFactory.setConstructor(new String[] { "kernel",  
+                                                  "abstractName", 
+                                                  "classLoader",
+                                                  "corePoolSize",
+                                                  "threadFactory",
+                                                  "contextHandlers" });
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceWrapperGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedScheduledExecutorServiceWrapperGBean.java
------------------------------------------------------------------------------
    svn:executable = 



Mime
View raw message