[webbeans-commits] Webbeans SVN: r3657 - in ri/branches/kabir-builder: impl/src/main/java/org/jboss/webbeans and 33 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Mon Sep 14 07:10:41 EDT 2009
Author: kabir.khan at jboss.com
Date: 2009-09-14 07:10:40 -0400 (Mon, 14 Sep 2009)
New Revision: 3657
Added:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Container.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/SingleThreadExecutorServices.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingLifecycle.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/manager/api/ExecutorServices.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockService.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Cat.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/CatLocal.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java
Removed:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/CurrentManager.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/helpers/ForwardingWebBeanDiscovery.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebBeanDiscovery.java
Modified:
ri/branches/kabir-builder/
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ContextualIdStore.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Validator.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDiscoveryEvent.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployment.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/ExtensionBeanDeployer.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ApplicationContext.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ContextLifecycle.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ConversationContext.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/RequestContext.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/SessionContext.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/conversation/AbstractConversationManager.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/EJBApiAbstraction.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptors.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansMethodExpression.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansValueExpression.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/event/ObserverMethodImpl.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/JsfApiAbstraction.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/metadata/TypeStore.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/metadata/cache/MetaAnnotationStore.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/persistence/PersistenceApiAbstraction.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/ManagerObjectFactory.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletHelper.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java
ri/branches/kabir-builder/porting-package/src/main/java/org/jboss/webbeans/tck/ContextsImpl.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Lifecycle.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Service.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/ServiceRegistry.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingServiceRegistry.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/SimpleServiceRegistry.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/manager/api/WebBeansManager.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoader.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/security/spi/SecurityServices.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/servlet/api/ServletServices.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/transaction/spi/TransactionServices.java
ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/validation/spi/ValidationServices.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceLoader.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockSecurityServices.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockServletServices.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockTransactionServices.java
ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockValidationServices.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockResourceLoader.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockSecurityServices.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletServices.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockTransactionServices.java
ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockValidationServices.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
Log:
Merged revisions 3646-3648,3650,3652,3655 via svnmerge from
https://svn.jboss.org/repos/webbeans/ri/trunk
.......
r3646 | pete.muir at jboss.org | 2009-09-06 14:18:10 +0100 (Sun, 06 Sep 2009) | 1 line
javadoc
.......
r3647 | pete.muir at jboss.org | 2009-09-06 15:25:02 +0100 (Sun, 06 Sep 2009) | 1 line
Remove deprecated class
.......
r3648 | pete.muir at jboss.org | 2009-09-06 15:35:30 +0100 (Sun, 06 Sep 2009) | 1 line
WBRI-378
.......
r3650 | pete.muir at jboss.org | 2009-09-06 18:45:30 +0100 (Sun, 06 Sep 2009) | 1 line
WBRI-376
.......
r3652 | pete.muir at jboss.org | 2009-09-07 23:53:39 +0100 (Mon, 07 Sep 2009) | 1 line
update service layer
.......
r3655 | pete.muir at jboss.org | 2009-09-13 22:17:19 +0100 (Sun, 13 Sep 2009) | 1 line
Test EjbDescriptor
.......
Property changes on: ri/branches/kabir-builder
___________________________________________________________________
Name: svnmerge-integrated
- /ri/trunk:1-3636
+ /ri/trunk:1-3656
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -35,9 +35,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import javax.el.ELResolver;
@@ -64,7 +61,6 @@
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.proxy.ClientProxyProvider;
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
-import org.jboss.webbeans.context.ApplicationContext;
import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.context.WBCreationalContext;
import org.jboss.webbeans.ejb.EjbDescriptors;
@@ -169,7 +165,6 @@
* Application scoped services
* ***************************
*/
- private transient final ExecutorService taskExecutor = Executors.newSingleThreadExecutor();
private transient final ServiceRegistry services;
/*
@@ -1083,7 +1078,7 @@
{
BeanManagerImpl childActivity = newChildActivityManager(this);
childActivities.add(childActivity);
- CurrentManager.add(childActivity);
+ Container.instance().addActivity(childActivity);
return childActivity;
}
@@ -1177,57 +1172,8 @@
protected Object readResolve()
{
- return CurrentManager.get(id);
+ return Container.instance().activityManager(id);
}
-
- /**
- * Provides access to the executor service used for asynchronous tasks.
- *
- * @return the ExecutorService for this manager
- */
- public ExecutorService getTaskExecutor()
- {
- return taskExecutor;
- }
-
- public void shutdown()
- {
- log.trace("Ending application");
- shutdownExecutors();
- ApplicationContext applicationContext = getServices().get(ApplicationContext.class);
- applicationContext.destroy();
- applicationContext.setActive(false);
- applicationContext.setBeanStore(null);
- CurrentManager.clear();
- }
-
- /**
- * Shuts down any executor services in the manager.
- */
- protected void shutdownExecutors()
- {
- taskExecutor.shutdown();
- try
- {
- // Wait a while for existing tasks to terminate
- if (!taskExecutor.awaitTermination(60, TimeUnit.SECONDS))
- {
- taskExecutor.shutdownNow(); // Cancel currently executing tasks
- // Wait a while for tasks to respond to being cancelled
- if (!taskExecutor.awaitTermination(60, TimeUnit.SECONDS))
- {
- // Log the error here
- }
- }
- }
- catch (InterruptedException ie)
- {
- // (Re-)Cancel if current thread also interrupted
- taskExecutor.shutdownNow();
- // Preserve interrupt status
- Thread.currentThread().interrupt();
- }
- }
protected ClientProxyProvider getClientProxyProvider()
{
@@ -1414,5 +1360,10 @@
{
return (EnterpriseBean<T>) getEnterpriseBeans().get(descriptor);
}
+
+ public void cleanup()
+ {
+ services.cleanup();
+ }
}
Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Container.java (from rev 3655, ri/trunk/impl/src/main/java/org/jboss/webbeans/Container.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Container.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Container.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -0,0 +1,190 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.webbeans.bootstrap.BeanDeployment;
+import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
+import org.jboss.webbeans.bootstrap.api.Singleton;
+import org.jboss.webbeans.bootstrap.api.SingletonProvider;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+
+/**
+ * A Web Beans application container
+ *
+ * @author pmuir
+ *
+ */
+public class Container
+{
+
+ private final static Singleton<Container> instance;
+
+ static
+ {
+ instance = SingletonProvider.instance().create(Container.class);
+ }
+
+ /**
+ * Get the container for the current application deployment
+ *
+ * @return
+ */
+ public static Container instance()
+ {
+ return instance.get();
+ }
+
+
+ /**
+ * Initialize the container for the current application deployment
+ *
+ * @param deploymentManager
+ * @param deploymentServices
+ */
+ public static void initialize(BeanManagerImpl deploymentManager, ServiceRegistry deploymentServices)
+ {
+ Container instance = new Container(deploymentManager, deploymentServices);
+ Container.instance.set(instance);
+ }
+
+ // The deployment bean manager
+ private final BeanManagerImpl deploymentManager;
+
+ // A map of managers keyed by ID, used for activities
+ private final Map<Integer, BeanManagerImpl> activities;
+
+ // A map of BDA -> bean managers
+ private final Map<BeanDeploymentArchive, BeanManagerImpl> beanDeploymentArchives;
+
+ private final ServiceRegistry deploymentServices;
+
+ private boolean initialized = false;
+
+ public Container(BeanManagerImpl deploymentManager, ServiceRegistry deploymentServices)
+ {
+ this.deploymentManager = deploymentManager;
+ this.activities = new ConcurrentHashMap<Integer, BeanManagerImpl>();
+ this.activities.put(deploymentManager.getId(), deploymentManager);
+ this.beanDeploymentArchives = new ConcurrentHashMap<BeanDeploymentArchive, BeanManagerImpl>();
+ this.deploymentServices = deploymentServices;
+ }
+
+ /**
+ * Cause the container to be cleaned up, including all registered bean
+ * managers, and all deployment services
+ */
+ public void cleanup()
+ {
+ // TODO We should probably cleanup the bean managers for activities?
+ activities.clear();
+
+ for (BeanManagerImpl beanManager : beanDeploymentArchives.values())
+ {
+ beanManager.cleanup();
+ }
+ beanDeploymentArchives.clear();
+
+ deploymentServices.cleanup();
+ deploymentManager.cleanup();
+ }
+
+ /**
+ * Gets the manager for this application deployment
+ *
+ */
+ public BeanManagerImpl deploymentManager()
+ {
+ return deploymentManager;
+ }
+ public Map<BeanDeploymentArchive, BeanManagerImpl> beanDeploymentArchives()
+ {
+ return beanDeploymentArchives;
+ }
+
+ /**
+ * Get the activity manager for a given key
+ *
+ * @param key
+ * @return
+ */
+ public BeanManagerImpl activityManager(Integer key)
+ {
+ return activities.get(key);
+ }
+
+ /**
+ * Add an activity
+ *
+ * @param manager
+ * @return
+ */
+ public Integer addActivity(BeanManagerImpl manager)
+ {
+ Integer id = manager.getId();
+ activities.put(id, manager);
+ return id;
+ }
+
+ /**
+ * Get the services for this application deployment
+ *
+ * @return the deploymentServices
+ */
+ public ServiceRegistry deploymentServices()
+ {
+ return deploymentServices;
+ }
+
+ /**
+ * Add sub-deployment units to the container
+ *
+ * @param beanDeployments
+ */
+ public void putBeanDeployments(Map<BeanDeploymentArchive, BeanDeployment> beanDeployments)
+ {
+ for (Entry<BeanDeploymentArchive, BeanDeployment> entry : beanDeployments.entrySet())
+ {
+ beanDeploymentArchives.put(entry.getKey(), entry.getValue().getBeanManager());
+ addActivity(entry.getValue().getBeanManager());
+ }
+ }
+
+ /**
+ * Check if the application container is fully initialized
+ *
+ * @return the initialized
+ */
+ public boolean isInitialized()
+ {
+ return initialized;
+ }
+
+ /**
+ * Put the application container into an initialized state
+ *
+ * @param initialized the initialized to set
+ */
+ public void setInitialized(boolean initialized)
+ {
+ this.initialized = initialized;
+ }
+
+}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ContextualIdStore.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ContextualIdStore.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ContextualIdStore.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -69,4 +69,9 @@
return id;
}
}
+
+ public void cleanup()
+ {
+ contextuals.clear();
+ }
}
Deleted: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/CurrentManager.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/CurrentManager.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/CurrentManager.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -1,123 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- *
- * Use is subject to license terms.
- *
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.enterprise.inject.TypeLiteral;
-
-import org.jboss.webbeans.bootstrap.BeanDeployment;
-import org.jboss.webbeans.bootstrap.api.Singleton;
-import org.jboss.webbeans.bootstrap.api.SingletonProvider;
-import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
-
-
-/**
- * Access point for getting/setting current Manager
- *
- * @author Gavin King
- * @author Sanjeeb.Sahoo at Sun.COM
- * @author Pete Muir
- */
-public class CurrentManager
-{
-
- private static class IntegerMangerImplMap extends TypeLiteral<Map<Integer, BeanManagerImpl>> {}
-
- private static class BeanDeploymentArchiveManagerImplMap extends TypeLiteral<Map<BeanDeploymentArchive, BeanManagerImpl>> {}
-
- // The root manager instance
- private static Singleton<BeanManagerImpl> rootManager = SingletonProvider.instance().create(BeanManagerImpl.class);
- // A map of managers keyed by ID, used for activities
- private final static Singleton<Map<Integer, BeanManagerImpl>> keyedManagers = SingletonProvider.instance().create(new IntegerMangerImplMap().getRawType());
-
- private final static Singleton<Map<BeanDeploymentArchive, BeanManagerImpl>> beanDeploymentArchives = SingletonProvider.instance().create(new BeanDeploymentArchiveManagerImplMap().getRawType());
-
- public static void clear()
- {
- keyedManagers.get().clear();
- rootManager.clear();
- keyedManagers.clear();
- beanDeploymentArchives.clear();
- }
-
- public static boolean isAvailable()
- {
- return rootManager.isSet() && beanDeploymentArchives.isSet();
- }
-
- /**
- * Gets the root manager
- *
- * @return The root manager
- */
- public static BeanManagerImpl rootManager()
- {
- return rootManager.get();
- }
-
- /**
- * Sets the root manager
- *
- * @param managerImpl The root manager
- */
- public static void setRootManager(BeanManagerImpl managerImpl)
- {
- rootManager.set(managerImpl);
- if (!keyedManagers.isSet())
- {
- keyedManagers.set(new ConcurrentHashMap<Integer, BeanManagerImpl>());
- }
- keyedManagers.get().put(managerImpl.getId(), managerImpl);
- }
-
- public static void setBeanDeploymentArchives(Map<BeanDeploymentArchive, BeanDeployment> beanDeployments)
- {
- beanDeploymentArchives.set(new ConcurrentHashMap<BeanDeploymentArchive, BeanManagerImpl>());
- for (Entry<BeanDeploymentArchive, BeanDeployment> entry : beanDeployments.entrySet())
- {
- beanDeploymentArchives.get().put(entry.getKey(), entry.getValue().getBeanManager());
- add(entry.getValue().getBeanManager());
- }
- }
-
- public static Map<BeanDeploymentArchive, BeanManagerImpl> getBeanDeploymentArchives()
- {
- return beanDeploymentArchives.get();
- }
-
- public static BeanManagerImpl get(Integer key)
- {
- return keyedManagers.get().get(key);
- }
-
- public static Integer add(BeanManagerImpl manager)
- {
- Integer id = manager.getId();
- keyedManagers.get().put(id, manager);
- return id;
- }
-
-}
Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/SingleThreadExecutorServices.java (from rev 3655, ri/trunk/impl/src/main/java/org/jboss/webbeans/SingleThreadExecutorServices.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/SingleThreadExecutorServices.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/SingleThreadExecutorServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.webbeans.manager.api.ExecutorServices;
+
+/**
+ * @author pmuir
+ *
+ */
+public class SingleThreadExecutorServices implements ExecutorServices
+{
+
+ private transient final ExecutorService taskExecutor = Executors.newSingleThreadExecutor();
+
+
+ /**
+ * Provides access to the executor service used for asynchronous tasks.
+ *
+ * @return the ExecutorService for this manager
+ */
+ public ExecutorService getTaskExecutor()
+ {
+ return taskExecutor;
+ }
+
+ public void cleanup()
+ {
+ taskExecutor.shutdown();
+ try
+ {
+ // Wait a while for existing tasks to terminate
+ if (!taskExecutor.awaitTermination(60, TimeUnit.SECONDS))
+ {
+ taskExecutor.shutdownNow(); // Cancel currently executing tasks
+ // Wait a while for tasks to respond to being cancelled
+ if (!taskExecutor.awaitTermination(60, TimeUnit.SECONDS))
+ {
+ // Log the error here
+ }
+ }
+ }
+ catch (InterruptedException ie)
+ {
+ // (Re-)Cancel if current thread also interrupted
+ taskExecutor.shutdownNow();
+ // Preserve interrupt status
+ Thread.currentThread().interrupt();
+ }
+ }
+
+}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Validator.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Validator.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/Validator.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -30,10 +30,10 @@
import javax.enterprise.context.Dependent;
import javax.enterprise.event.Event;
+import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.IllegalProductException;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.New;
-import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.UnproxyableResolutionException;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.Decorator;
@@ -355,4 +355,6 @@
}
+ public void cleanup() {}
+
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -208,6 +208,10 @@
{
throw new DefinitionException("Simple bean " + type + " cannot be a non-static inner class");
}
+ if (!isDependent() && getAnnotatedItem().isParameterizedType())
+ {
+ throw new DefinitionException("Managed bean " + type + " must be @Dependent");
+ }
boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(scopeType).isPassivating();
if (passivating && !Reflections.isSerializable(getBeanClass()))
{
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDiscoveryEvent.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDiscoveryEvent.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDiscoveryEvent.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -85,7 +85,7 @@
}
else
{
- BeanDeployment beanDeployment = new BeanDeployment(beanDeploymentArchive, getDeploymentManager());
+ BeanDeployment beanDeployment = new BeanDeployment(beanDeploymentArchive, getDeploymentManager(), deployment.getServices());
getBeanDeployments().put(beanDeploymentArchive, beanDeployment);
return beanDeployment;
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,6 +24,7 @@
import javax.interceptor.Interceptor;
import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.ejb.EjbDescriptors;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.introspector.WBClass;
@@ -53,7 +54,7 @@
public AbstractBeanDeployer addClass(Class<?> clazz)
{
- ClassTransformer classTransformer = getManager().getServices().get(ClassTransformer.class);
+ ClassTransformer classTransformer = Container.instance().deploymentServices().get(ClassTransformer.class);
if (!clazz.isAnnotation() && !clazz.isEnum())
{
ProcessAnnotatedTypeImpl<?> event = createProcessAnnotatedTypeEvent(clazz, classTransformer);
@@ -82,7 +83,7 @@
// TODO Do we need to fire PAT for annotated types added via BBD? Probably not PLM.
public AbstractBeanDeployer addClass(AnnotatedType<?> clazz)
{
- ClassTransformer classTransformer = getManager().getServices().get(ClassTransformer.class);
+ ClassTransformer classTransformer = Container.instance().deploymentServices().get(ClassTransformer.class);
classes.add(classTransformer.loadClass(clazz));
return this;
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployment.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployment.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployment.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -58,13 +58,13 @@
private final BeanManagerImpl beanManager;
private final BeanDeployer beanDeployer;
- public BeanDeployment(BeanDeploymentArchive beanDeploymentArchive, BeanManagerImpl deploymentManager)
+ public BeanDeployment(BeanDeploymentArchive beanDeploymentArchive, BeanManagerImpl deploymentManager, ServiceRegistry deploymentServices)
{
this.beanDeploymentArchive = beanDeploymentArchive;
EjbDescriptors ejbDescriptors = new EjbDescriptors();
beanDeploymentArchive.getServices().add(EjbDescriptors.class, ejbDescriptors);
ServiceRegistry services = new SimpleServiceRegistry();
- services.addAll(deploymentManager.getServices().entrySet());
+ services.addAll(deploymentServices.entrySet());
services.addAll(beanDeploymentArchive.getServices().entrySet());
this.beanManager = BeanManagerImpl.newManager(deploymentManager, services);
if (beanManager.getServices().contains(EjbServices.class))
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/ExtensionBeanDeployer.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/ExtensionBeanDeployer.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/ExtensionBeanDeployer.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -23,6 +23,7 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bean.builder.InternalObserverMethodBuilder;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.bean.builtin.ExtensionBean;
import org.jboss.webbeans.ejb.EjbDescriptors;
import org.jboss.webbeans.introspector.WBClass;
@@ -45,7 +46,7 @@
public AbstractBeanDeployer createBeans()
{
- ClassTransformer classTransformer = getManager().getServices().get(ClassTransformer.class);
+ ClassTransformer classTransformer = Container.instance().deploymentServices().get(ClassTransformer.class);
for (Extension extension : extensions)
{
@SuppressWarnings("unchecked")
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -27,17 +27,19 @@
import javax.enterprise.inject.spi.Extension;
import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.ContextualIdStore;
-import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.DeploymentException;
import org.jboss.webbeans.Validator;
import org.jboss.webbeans.bean.builtin.ManagerBean;
import org.jboss.webbeans.bootstrap.api.Bootstrap;
import org.jboss.webbeans.bootstrap.api.Environment;
+import org.jboss.webbeans.bootstrap.api.Lifecycle;
import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.bootstrap.api.helpers.ServiceRegistries;
+import org.jboss.webbeans.bootstrap.api.helpers.SimpleServiceRegistry;
import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.bootstrap.spi.Deployment;
import org.jboss.webbeans.context.ApplicationContext;
@@ -109,7 +111,7 @@
verifyServices(beanDeploymentArchive.getServices(), environment.getRequiredBeanDeploymentArchiveServices());
// Create the BeanDeployment and attach
- BeanDeployment parent = new BeanDeployment(beanDeploymentArchive, deploymentManager);
+ BeanDeployment parent = new BeanDeployment(beanDeploymentArchive, deploymentManager, deployment.getServices());
managerAwareBeanDeploymentArchives.put(beanDeploymentArchive, parent);
seenBeanDeploymentArchives.add(beanDeploymentArchive);
for (BeanDeploymentArchive archive : beanDeploymentArchive.getBeanDeploymentArchives())
@@ -178,17 +180,24 @@
}
this.deployment = deployment;
- addImplementationServices(deployment.getServices());
+ ServiceRegistry implementationServices = getImplementationServices(deployment.getServices().get(ResourceLoader.class));
+ deployment.getServices().addAll(implementationServices.entrySet());
+ ServiceRegistry deploymentServices = new SimpleServiceRegistry();
+ deploymentServices.add(ClassTransformer.class, implementationServices.get(ClassTransformer.class));
+ deploymentServices.add(MetaAnnotationStore.class, implementationServices.get(MetaAnnotationStore.class));
+ deploymentServices.add(TypeStore.class, implementationServices.get(TypeStore.class));
+
this.environment = environment;
- this.deploymentManager = BeanManagerImpl.newRootManager(ServiceRegistries.unmodifiableServiceRegistry(deployment.getServices()));
- CurrentManager.setRootManager(deploymentManager);
+ this.deploymentManager = BeanManagerImpl.newRootManager(deploymentServices);
+ Container.initialize(deploymentManager, ServiceRegistries.unmodifiableServiceRegistry(deployment.getServices()));
+
createContexts();
initializeContexts();
// Start the application context
- beginApplication(applicationBeanStore);
+ Container.instance().deploymentServices().get(ContextLifecycle.class).beginApplication(applicationBeanStore);
DeploymentVisitor deploymentVisitor = new DeploymentVisitor(deploymentManager, environment, deployment);
beanDeployments = deploymentVisitor.visit();
@@ -197,9 +206,9 @@
}
}
- private void addImplementationServices(ServiceRegistry services)
+ private ServiceRegistry getImplementationServices(ResourceLoader resourceLoader)
{
- ResourceLoader resourceLoader = services.get(ResourceLoader.class);
+ ServiceRegistry services = new SimpleServiceRegistry();
services.add(EJBApiAbstraction.class, new EJBApiAbstraction(resourceLoader));
services.add(JsfApiAbstraction.class, new JsfApiAbstraction(resourceLoader));
services.add(PersistenceApiAbstraction.class, new PersistenceApiAbstraction(resourceLoader));
@@ -211,6 +220,7 @@
services.add(ClassTransformer.class, new ClassTransformer(services.get(TypeStore.class)));
services.add(MetaAnnotationStore.class, new MetaAnnotationStore(services.get(ClassTransformer.class)));
services.add(ContextualIdStore.class, new ContextualIdStore());
+ return services;
}
public BeanManagerImpl getManager(BeanDeploymentArchive beanDeploymentArchive)
@@ -266,7 +276,7 @@
{
for (Entry<BeanDeploymentArchive, BeanDeployment> entry : beanDeployments.entrySet())
{
- deploymentManager.getServices().get(Validator.class).validateDeployment(entry.getValue().getBeanManager(), entry.getValue().getBeanDeployer().getEnvironment());
+ deployment.getServices().get(Validator.class).validateDeployment(entry.getValue().getBeanManager(), entry.getValue().getBeanDeployer().getEnvironment());
}
fireAfterDeploymentValidationEvent();
}
@@ -278,7 +288,8 @@
synchronized (this)
{
// Register the managers so external requests can handle them
- CurrentManager.setBeanDeploymentArchives(beanDeployments);
+ Container.instance().putBeanDeployments(beanDeployments);
+ Container.instance().setInitialized(true);
}
return this;
}
@@ -361,31 +372,24 @@
protected void initializeContexts()
{
- deploymentManager.addContext(deploymentManager.getServices().get(DependentContext.class));
- deploymentManager.addContext(deploymentManager.getServices().get(RequestContext.class));
- deploymentManager.addContext(deploymentManager.getServices().get(ConversationContext.class));
- deploymentManager.addContext(deploymentManager.getServices().get(SessionContext.class));
- deploymentManager.addContext(deploymentManager.getServices().get(ApplicationContext.class));
+ Lifecycle lifecycle = deployment.getServices().get(ContextLifecycle.class);
+ deploymentManager.addContext(lifecycle.getDependentContext());
+ deploymentManager.addContext(lifecycle.getRequestContext());
+ deploymentManager.addContext(lifecycle.getConversationContext());
+ deploymentManager.addContext(lifecycle.getSessionContext());
+ deploymentManager.addContext(lifecycle.getApplicationContext());
}
protected void createContexts()
{
- deployment.getServices().add(ContextLifecycle.class, new ContextLifecycle());
- deployment.getServices().add(DependentContext.class, new DependentContext());
- deployment.getServices().add(RequestContext.class, new RequestContext());
- deployment.getServices().add(ConversationContext.class, new ConversationContext());
- deployment.getServices().add(SessionContext.class, new SessionContext());
- deployment.getServices().add(ApplicationContext.class, new ApplicationContext());
+ ApplicationContext applicationContext = new ApplicationContext();
+ SessionContext sessionContext = new SessionContext();
+ ConversationContext conversationContext = new ConversationContext();
+ RequestContext requestContext = new RequestContext();
+ DependentContext dependentContext = new DependentContext();
+
+ deployment.getServices().add(ContextLifecycle.class, new ContextLifecycle(applicationContext, sessionContext, conversationContext, requestContext, dependentContext));
}
-
- protected void beginApplication(BeanStore applicationBeanStore)
- {
- log.trace("Starting application");
- ApplicationContext applicationContext = deploymentManager.getServices().get(ApplicationContext.class);
- applicationContext.setBeanStore(applicationBeanStore);
- applicationContext.setActive(true);
-
- }
public void shutdown()
{
@@ -395,7 +399,7 @@
}
finally
{
- deploymentManager.shutdown();
+ Container.instance().deploymentServices().get(ContextLifecycle.class).endApplication();
}
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractContext.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -85,5 +85,7 @@
{
this.active.set(Boolean.valueOf(active));
}
+
+ public abstract void cleanup();
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/AbstractMapContext.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -23,8 +23,8 @@
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
+import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.ContexutalInstance;
-import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -163,4 +163,14 @@
*/
protected abstract boolean isCreationLockRequired();
+
+ @Override
+ public void cleanup()
+ {
+ if (getBeanStore() != null)
+ {
+ getBeanStore().clear();
+ }
+ }
+
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ApplicationContext.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ApplicationContext.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ApplicationContext.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -26,7 +26,6 @@
import javax.enterprise.context.ApplicationScoped;
-import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.context.api.BeanStore;
/**
@@ -36,7 +35,7 @@
*
* @see org.jboss.webbeans.context.ApplicationContext
*/
-public class ApplicationContext extends AbstractMapContext implements Service
+public class ApplicationContext extends AbstractMapContext
{
// The beans
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ContextLifecycle.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ContextLifecycle.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ContextLifecycle.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -22,10 +22,10 @@
*/
package org.jboss.webbeans.context;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.bootstrap.api.Lifecycle;
+import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.conversation.ConversationManager;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -36,25 +36,37 @@
* @author Pete Muir
*
*/
-public class ContextLifecycle implements Lifecycle
+public class ContextLifecycle implements Lifecycle, Service
{
+
+ public static LogProvider log = Logging.getLogProvider(ContextLifecycle.class);
- private static LogProvider log = Logging.getLogProvider(ContextLifecycle.class);
+ public final ApplicationContext applicationContext;
+ public final SessionContext sessionContext;
+ public final ConversationContext conversationContext;
+ public final RequestContext requestContext;
+ public final DependentContext dependentContext;
+
+ public ContextLifecycle(ApplicationContext applicationContext, SessionContext sessionContext, ConversationContext conversationContext, RequestContext requestContext, DependentContext dependentContext)
+ {
+ this.applicationContext = applicationContext;
+ this.sessionContext = sessionContext;
+ this.conversationContext = conversationContext;
+ this.requestContext = requestContext;
+ this.dependentContext = dependentContext;
+ }
public void restoreSession(String id, BeanStore sessionBeanStore)
{
log.trace("Restoring session " + id);
- SessionContext sessionContext = CurrentManager.rootManager().getServices().get(SessionContext.class);
sessionContext.setBeanStore(sessionBeanStore);
sessionContext.setActive(true);
}
- public void endSession(String id, BeanStore sessionBeanStore, ConversationManager conversationManager)
+ public void endSession(String id, BeanStore sessionBeanStore)
{
log.trace("Ending session " + id);
- SessionContext sessionContext = CurrentManager.rootManager().getServices().get(SessionContext.class);
sessionContext.setActive(true);
- conversationManager.destroyAllConversations();
sessionContext.destroy();
sessionContext.setBeanStore(null);
sessionContext.setActive(false);
@@ -63,8 +75,6 @@
public void beginRequest(String id, BeanStore requestBeanStore)
{
log.trace("Starting request " + id);
- RequestContext requestContext = CurrentManager.rootManager().getServices().get(RequestContext.class);
- DependentContext dependentContext = CurrentManager.rootManager().getServices().get(DependentContext.class);
requestContext.setBeanStore(requestBeanStore);
requestContext.setActive(true);
dependentContext.setActive(true);
@@ -73,12 +83,69 @@
public void endRequest(String id, BeanStore requestBeanStore)
{
log.trace("Ending request " + id);
- RequestContext requestContext = CurrentManager.rootManager().getServices().get(RequestContext.class);
- DependentContext dependentContext = CurrentManager.rootManager().getServices().get(DependentContext.class);
requestContext.setBeanStore(requestBeanStore);
dependentContext.setActive(false);
requestContext.destroy();
requestContext.setActive(false);
+ requestContext.setBeanStore(null);
}
+
+ public boolean isRequestActive()
+ {
+ return requestContext.isActive() && dependentContext.isActive();
+ }
+
+ public void beginApplication(BeanStore applicationBeanStore)
+ {
+ log.trace("Starting application");
+ applicationContext.setBeanStore(applicationBeanStore);
+ applicationContext.setActive(true);
+
+ }
+
+ public void endApplication()
+ {
+ log.trace("Ending application");
+ applicationContext.destroy();
+ applicationContext.setActive(false);
+ applicationContext.setBeanStore(null);
+
+ Container.instance().cleanup();
+ }
+
+ public void cleanup()
+ {
+ applicationContext.cleanup();
+ sessionContext.cleanup();
+ conversationContext.cleanup();
+ requestContext.cleanup();
+ dependentContext.cleanup();
+ }
+
+ public ApplicationContext getApplicationContext()
+ {
+ return applicationContext;
+ }
+
+ public SessionContext getSessionContext()
+ {
+ return sessionContext;
+ }
+
+ public ConversationContext getConversationContext()
+ {
+ return conversationContext;
+ }
+
+ public RequestContext getRequestContext()
+ {
+ return requestContext;
+ }
+
+ public DependentContext getDependentContext()
+ {
+ return dependentContext;
+ }
+
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ConversationContext.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ConversationContext.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/ConversationContext.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,7 +24,6 @@
import javax.enterprise.context.ConversationScoped;
-import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -33,7 +32,7 @@
*
* @author Nicklas Karlsson
*/
-public class ConversationContext extends AbstractThreadLocalMapContext implements Service
+public class ConversationContext extends AbstractThreadLocalMapContext
{
private static LogProvider log = Logging.getLogProvider(ConversationContext.class);
@@ -53,4 +52,5 @@
String beanStoreInfo = getBeanStore() == null ? "" : getBeanStore().toString();
return active + "conversation context " + beanStoreInfo;
}
+
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/DependentContext.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -27,7 +27,6 @@
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
-import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.context.api.ContexutalInstance;
/**
@@ -35,7 +34,7 @@
*
* @author Nicklas Karlsson
*/
-public class DependentContext extends AbstractContext implements Service
+public class DependentContext extends AbstractContext
{
/**
@@ -92,4 +91,6 @@
return true;
}
+ public void cleanup() {}
+
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/RequestContext.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/RequestContext.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/RequestContext.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,14 +24,12 @@
import javax.enterprise.context.RequestScoped;
-import org.jboss.webbeans.bootstrap.api.Service;
-
/**
* The request context
*
* @author Nicklas Karlsson
*/
-public class RequestContext extends AbstractThreadLocalMapContext implements Service
+public class RequestContext extends AbstractThreadLocalMapContext
{
/**
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/SessionContext.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/SessionContext.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/SessionContext.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,7 +24,6 @@
import javax.enterprise.context.SessionScoped;
-import org.jboss.webbeans.bootstrap.api.Service;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -34,7 +33,7 @@
*
* @author Nicklas Karlsson
*/
-public class SessionContext extends AbstractThreadLocalMapContext implements Service
+public class SessionContext extends AbstractThreadLocalMapContext
{
private static LogProvider log = Logging.getLogProvider(SessionContext.class);
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -23,8 +23,8 @@
import javax.enterprise.context.spi.Contextual;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.ContextualIdStore;
-import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.ContexutalInstance;
import org.jboss.webbeans.log.LogProvider;
@@ -52,7 +52,7 @@
@SuppressWarnings("unchecked")
public <T> ContexutalInstance<T> get(Contextual<? extends T> contextual)
{
- Integer contextualId = CurrentManager.rootManager().getServices().get(ContextualIdStore.class).getId(contextual);
+ Integer contextualId = Container.instance().deploymentServices().get(ContextualIdStore.class).getId(contextual);
String key = getNamingScheme().getKeyFromId(contextualId);
ContexutalInstance<T> instance = (ContexutalInstance<T>) getAttribute(key);
log.trace("Looked for " + key + " and got " + instance);
@@ -67,7 +67,7 @@
*/
public <T> T remove(Contextual<? extends T> contextual)
{
- Integer contextualId = CurrentManager.rootManager().getServices().get(ContextualIdStore.class).getId(contextual);
+ Integer contextualId = Container.instance().deploymentServices().get(ContextualIdStore.class).getId(contextual);
T instance = get(contextual).getInstance();
String key = getNamingScheme().getKeyFromId(contextualId);
removeAttribute(key);
@@ -99,7 +99,7 @@
for (String attributeName : getFilteredAttributeNames())
{
Integer id = namingScheme.getIdFromKey(attributeName);
- Contextual<?> contextual = CurrentManager.rootManager().getServices().get(ContextualIdStore.class).getContextual(id);
+ Contextual<?> contextual = Container.instance().deploymentServices().get(ContextualIdStore.class).getContextual(id);
contextuals.add(contextual);
}
return contextuals;
@@ -133,7 +133,7 @@
*/
public <T> void put(ContexutalInstance<T> beanInstance)
{
- Integer contextualId = CurrentManager.rootManager().getServices().get(ContextualIdStore.class).getId(beanInstance.getContextual());
+ Integer contextualId = Container.instance().deploymentServices().get(ContextualIdStore.class).getId(beanInstance.getContextual());
String key = getNamingScheme().getKeyFromId(contextualId);
setAttribute(key, beanInstance);
log.trace("Added Contextual type " + beanInstance.getContextual() + " under key " + key);
Copied: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java (from rev 3655, ri/trunk/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java)
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/context/beanstore/HashMapBeanStore.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.context.beanstore;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.enterprise.context.spi.Contextual;
+
+import org.jboss.webbeans.context.api.ContexutalInstance;
+import org.jboss.webbeans.context.api.helpers.AbstractMapBackedBeanStore;
+
+/**
+ * A BeanStore that uses a HashMap as backing storage
+ *
+ * @author Nicklas Karlsson
+ */
+public class HashMapBeanStore extends AbstractMapBackedBeanStore implements Serializable
+{
+
+ private static final long serialVersionUID = 4770689245633688471L;
+
+ // The backing map
+ protected Map<Contextual<? extends Object>, ContexutalInstance<? extends Object>> delegate;
+
+ /**
+ * Constructor
+ */
+ public HashMapBeanStore()
+ {
+ delegate = new HashMap<Contextual<? extends Object>, ContexutalInstance<? extends Object>>();
+ }
+
+ /**
+ * Gets the delegate for the store
+ *
+ * @return The delegate
+ */
+ @Override
+ public Map<Contextual<? extends Object>, ContexutalInstance<? extends Object>> delegate()
+ {
+ return delegate;
+ }
+
+}
\ No newline at end of file
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/conversation/AbstractConversationManager.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/conversation/AbstractConversationManager.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/conversation/AbstractConversationManager.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -33,7 +33,8 @@
import javax.enterprise.inject.Any;
import javax.inject.Inject;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
+import org.jboss.webbeans.context.ContextLifecycle;
import org.jboss.webbeans.context.ConversationContext;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.log.LogProvider;
@@ -163,7 +164,7 @@
longRunningConversation.cancelTermination();
longRunningConversation.unlock();
}
- ConversationContext conversationContext = CurrentManager.rootManager().getServices().get(ConversationContext.class);
+ ConversationContext conversationContext = Container.instance().deploymentServices().get(ContextLifecycle.class).getConversationContext();
conversationContext.destroy();
}
// If the conversation has been switched from one long
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/EJBApiAbstraction.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/EJBApiAbstraction.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/EJBApiAbstraction.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -43,4 +43,6 @@
public final Class<? extends Annotation> EJB_ANNOTATION_CLASS;
public final Class<? extends Annotation> RESOURCE_ANNOTATION_CLASS;
+ public void cleanup() {}
+
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptors.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptors.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptors.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -120,5 +120,7 @@
{
return ejbs.values().iterator();
}
+
+ public void cleanup() {}
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -18,15 +18,53 @@
import java.io.Serializable;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.webbeans.Container;
+import org.jboss.webbeans.bootstrap.api.Lifecycle;
+import org.jboss.webbeans.context.ContextLifecycle;
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.context.beanstore.HashMapBeanStore;
+
/**
- * Interceptor for handling EJB post-construct tasks
+ * Interceptor for ensuring the request context is active during requests to EJBs.
*
+ * Normally, a servlet will start the request context, however in non-servlet
+ * requests (e.g. MDB, async, timeout) the contexts may need starting.
+ *
+ * The Application context is active for duration of the deployment
+ *
* @author Pete Muir
*/
public class SessionBeanInterceptor implements Serializable
{
private static final long serialVersionUID = 7327757031821596782L;
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext invocation) throws Exception
+ {
+ if (Container.instance().deploymentServices().get(ContextLifecycle.class).isRequestActive())
+ {
+ return invocation.proceed();
+ }
+ else
+ {
+ Lifecycle lifecycle = Container.instance().deploymentServices().get(ContextLifecycle.class);
+ BeanStore beanStore = new HashMapBeanStore();
+ String id = invocation.getTarget().getClass().getName() + "." + invocation.getMethod().getName() + "()";
+ lifecycle.beginRequest(id, beanStore);
+ try
+ {
+ return invocation.proceed();
+ }
+ finally
+ {
+ lifecycle.endRequest(id, beanStore);
+ }
+ }
+ }
+
}
\ No newline at end of file
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/AbstractWebBeansELResolver.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -27,7 +27,7 @@
import javax.enterprise.inject.spi.Bean;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
/**
* An EL-resolver against the named beans
@@ -165,7 +165,7 @@
if (store.isEmpty())
{
// TODO need to use correct manager for module
- ELCreationalContext<?> creationalContext = ELCreationalContext.of(CurrentManager.rootManager().createCreationalContext(CONTEXTUAL));
+ ELCreationalContext<?> creationalContext = ELCreationalContext.of(Container.instance().deploymentManager().createCreationalContext(CONTEXTUAL));
store.push(creationalContext);
}
return (ELCreationalContextStack) o;
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansMethodExpression.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansMethodExpression.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansMethodExpression.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -22,7 +22,7 @@
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.util.el.ForwardingMethodExpression;
/**
@@ -63,7 +63,7 @@
public Object invoke(ELContext context, Object[] params)
{
// TODO need to use correct manager for module
- ELCreationalContext<?> creationalContext = ELCreationalContext.of(CurrentManager.rootManager().createCreationalContext(CONTEXTUAL));
+ ELCreationalContext<?> creationalContext = ELCreationalContext.of(Container.instance().deploymentManager().createCreationalContext(CONTEXTUAL));
try
{
getCreationalContextStore(context).push(creationalContext);
@@ -80,7 +80,7 @@
public MethodInfo getMethodInfo(ELContext context)
{
// TODO need to use correct manager for module
- ELCreationalContext<?> creationalContext = ELCreationalContext.of(CurrentManager.rootManager().createCreationalContext(CONTEXTUAL));
+ ELCreationalContext<?> creationalContext = ELCreationalContext.of(Container.instance().deploymentManager().createCreationalContext(CONTEXTUAL));
try
{
getCreationalContextStore(context).push(creationalContext);
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansValueExpression.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansValueExpression.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/el/WebBeansValueExpression.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -21,7 +21,7 @@
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.util.el.ForwardingValueExpression;
/**
@@ -62,7 +62,7 @@
public Object getValue(final ELContext context)
{
// TODO need to use correct manager for module
- ELCreationalContext<?> creationalContext = ELCreationalContext.of(CurrentManager.rootManager().createCreationalContext(CONTEXTUAL));
+ ELCreationalContext<?> creationalContext = ELCreationalContext.of(Container.instance().deploymentManager().createCreationalContext(CONTEXTUAL));
try
{
getCreationalContextStore(context).push(creationalContext);
@@ -79,7 +79,7 @@
public void setValue(ELContext context, Object value)
{
// TODO need to use correct manager for module
- ELCreationalContext<?> creationalContext = ELCreationalContext.of(CurrentManager.rootManager().createCreationalContext(CONTEXTUAL));
+ ELCreationalContext<?> creationalContext = ELCreationalContext.of(Container.instance().deploymentManager().createCreationalContext(CONTEXTUAL));
try
{
getCreationalContextStore(context).push(creationalContext);
@@ -97,7 +97,7 @@
public Class getType(ELContext context)
{
// TODO need to use correct manager for module
- ELCreationalContext<?> creationalContext = ELCreationalContext.of(CurrentManager.rootManager().createCreationalContext(CONTEXTUAL));
+ ELCreationalContext<?> creationalContext = ELCreationalContext.of(Container.instance().deploymentManager().createCreationalContext(CONTEXTUAL));
try
{
getCreationalContextStore(context).push(creationalContext);
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/event/DeferredEventNotification.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -16,7 +16,8 @@
*/
package org.jboss.webbeans.event;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
+import org.jboss.webbeans.bootstrap.api.Lifecycle;
import org.jboss.webbeans.context.ContextLifecycle;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
@@ -51,7 +52,7 @@
public void run()
{
- ContextLifecycle lifecycle = CurrentManager.rootManager().getServices().get(ContextLifecycle.class);
+ Lifecycle lifecycle = Container.instance().deploymentServices().get(ContextLifecycle.class);
BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
lifecycle.beginRequest("async invocation", requestBeanStore);
try
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/event/ObserverMethodImpl.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/event/ObserverMethodImpl.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/event/ObserverMethodImpl.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -37,11 +37,13 @@
import javax.inject.Inject;
import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.introspector.WBParameter;
+import org.jboss.webbeans.manager.api.ExecutorServices;
/**
* <p>
@@ -239,7 +241,7 @@
protected void sendEventAsynchronously(final T event)
{
DeferredEventNotification<T> deferredEvent = new DeferredEventNotification<T>(event, this);
- manager.getTaskExecutor().execute(deferredEvent);
+ Container.instance().deploymentServices().get(ExecutorServices.class).getTaskExecutor().execute(deferredEvent);
}
@Override
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/JsfApiAbstraction.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/JsfApiAbstraction.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/JsfApiAbstraction.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -61,5 +61,7 @@
{
return MINIMUM_API_VERSION >= version;
}
+
+ public void cleanup() {}
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/JsfHelper.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -22,7 +22,7 @@
import javax.servlet.http.HttpSession;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.conversation.ConversationIdName;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -50,7 +50,7 @@
*/
public static boolean isPostback(FacesContext facesContext)
{
- if (CurrentManager.rootManager().getServices().get(JsfApiAbstraction.class).isApiVersionCompatibleWith(2.0))
+ if (Container.instance().deploymentServices().get(JsfApiAbstraction.class).isApiVersionCompatibleWith(2.0))
{
return (Boolean) Reflections.invokeAndWrap("isPostback", facesContext);
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -23,8 +23,8 @@
package org.jboss.webbeans.jsf;
import static org.jboss.webbeans.jsf.JsfHelper.getConversationId;
+import static org.jboss.webbeans.jsf.JsfHelper.getHttpSession;
import static org.jboss.webbeans.jsf.JsfHelper.getModuleBeanManager;
-import static org.jboss.webbeans.jsf.JsfHelper.getHttpSession;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
@@ -33,6 +33,8 @@
import javax.servlet.http.HttpSession;
import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.Container;
+import org.jboss.webbeans.context.ContextLifecycle;
import org.jboss.webbeans.context.ConversationContext;
import org.jboss.webbeans.context.SessionContext;
import org.jboss.webbeans.conversation.ConversationImpl;
@@ -118,8 +120,8 @@
private void afterRenderResponse(FacesContext facesContext)
{
BeanManagerImpl moduleBeanManager = getModuleBeanManager(facesContext);
- SessionContext sessionContext = moduleBeanManager.getServices().get(SessionContext.class);
- ConversationContext conversationContext = moduleBeanManager.getServices().get(ConversationContext.class);
+ SessionContext sessionContext = Container.instance().deploymentServices().get(ContextLifecycle.class).getSessionContext();
+ ConversationContext conversationContext = Container.instance().deploymentServices().get(ContextLifecycle.class).getConversationContext();
if (sessionContext.isActive())
{
log.trace("Cleaning up the conversation after the Render Response phase");
@@ -138,7 +140,7 @@
private void afterResponseComplete(FacesContext facesContext, PhaseId phaseId)
{
BeanManagerImpl moduleBeanManager = getModuleBeanManager(facesContext);
- SessionContext sessionContext = moduleBeanManager.getServices().get(SessionContext.class);
+ SessionContext sessionContext = Container.instance().deploymentServices().get(ContextLifecycle.class).getSessionContext();
if (sessionContext.isActive())
{
log.trace("Cleaning up the conversation after the " + phaseId + " phase as the response has been marked complete");
@@ -164,7 +166,7 @@
moduleBeanManager.getInstanceByType(ConversationManager.class).beginOrRestoreConversation(getConversationId(facesContext));
String cid = moduleBeanManager.getInstanceByType(ConversationImpl.class).getUnderlyingId();
- ConversationContext conversationContext = moduleBeanManager.getServices().get(ConversationContext.class);
+ ConversationContext conversationContext = Container.instance().deploymentServices().get(ContextLifecycle.class).getConversationContext();
conversationContext.setBeanStore(new ConversationBeanStore(session, cid));
conversationContext.setActive(true);
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/metadata/TypeStore.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/metadata/TypeStore.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/metadata/TypeStore.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -64,4 +64,7 @@
{
this.extraAnnotations.get(annotationType).addAll(annotations);
}
+
+ public void cleanup() {}
+
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/metadata/cache/MetaAnnotationStore.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/metadata/cache/MetaAnnotationStore.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/metadata/cache/MetaAnnotationStore.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -126,5 +126,12 @@
buffer.append("Registered stereotype models: " + stereotypes.size() + "\n");
return buffer.toString();
}
+
+ public void cleanup()
+ {
+ bindingTypes.clear();
+ scopes.clear();
+ stereotypes.clear();
+ }
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/persistence/PersistenceApiAbstraction.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/persistence/PersistenceApiAbstraction.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/persistence/PersistenceApiAbstraction.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -55,4 +55,6 @@
EMBEDDABLE_CLASS = annotationTypeForName("javax.persistence.Embeddable");
}
+ public void cleanup() {}
+
}
\ No newline at end of file
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -91,5 +91,12 @@
{
return typeStore;
}
+
+ public void cleanup()
+ {
+ annotatedTypes.clear();
+ annotations.clear();
+ classes.clear();
+ }
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -91,4 +91,6 @@
}
}
+ public void cleanup() {}
+
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/ManagerObjectFactory.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/ManagerObjectFactory.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/resources/ManagerObjectFactory.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -22,7 +22,7 @@
import javax.naming.Name;
import javax.naming.spi.ObjectFactory;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
public class ManagerObjectFactory implements ObjectFactory
{
@@ -30,9 +30,9 @@
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
{
// Temp hack for JBoss Flat Deployment
- if (CurrentManager.getBeanDeploymentArchives().size() == 1)
+ if (Container.instance().beanDeploymentArchives().size() == 1)
{
- return CurrentManager.getBeanDeploymentArchives().entrySet().iterator().next().getValue().getCurrent();
+ return Container.instance().beanDeploymentArchives().entrySet().iterator().next().getValue().getCurrent();
}
else
{
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletApiAbstraction.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -49,5 +49,7 @@
SERVLET_REQUEST_LISTENER_CLASS = classForName("javax.servlet.ServletRequestListener");
}
+ public void cleanup() {}
+
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletHelper.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletHelper.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletHelper.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -19,7 +19,7 @@
import javax.servlet.ServletContext;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.servlet.api.ServletServices;
@@ -36,8 +36,8 @@
{
throw new IllegalArgumentException("Must provide the Servlet Context");
}
- BeanDeploymentArchive beanDeploymentArchive = CurrentManager.rootManager().getServices().get(ServletServices.class).getBeanDeploymentArchive(ctx);
- return CurrentManager.getBeanDeploymentArchives().get(beanDeploymentArchive).getCurrent();
+ BeanDeploymentArchive beanDeploymentArchive = Container.instance().deploymentServices().get(ServletServices.class).getBeanDeploymentArchive(ctx);
+ return Container.instance().beanDeploymentArchives().get(beanDeploymentArchive).getCurrent();
}
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -27,10 +27,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
-import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.context.ContextLifecycle;
-import org.jboss.webbeans.context.RequestContext;
-import org.jboss.webbeans.context.SessionContext;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
import org.jboss.webbeans.conversation.ConversationManager;
@@ -78,24 +75,28 @@
*/
public void endSession(HttpSession session)
{
- SessionContext sessionContext = CurrentManager.rootManager().getServices().get(SessionContext.class);
- RequestContext requestContext = CurrentManager.rootManager().getServices().get(RequestContext.class);
ConversationManager conversationManager = getModuleBeanManager(session.getServletContext()).getInstanceByType(ConversationManager.class);
- if (sessionContext.isActive())
+ if (lifecycle.getSessionContext().isActive())
{
- lifecycle.endSession(session.getId(), sessionContext.getBeanStore(), conversationManager);
+ conversationManager.destroyAllConversations();
+ lifecycle.endSession(session.getId(), lifecycle.getSessionContext().getBeanStore());
}
- else if (requestContext.isActive())
+ else if (lifecycle.getRequestContext().isActive())
{
- lifecycle.endSession(session.getId(), restoreSessionContext(session), conversationManager);
+ conversationManager.destroyAllConversations();
+ lifecycle.endSession(session.getId(), restoreSessionContext(session));
}
else
{
BeanStore mockRequest = new ConcurrentHashMapBeanStore();
+
lifecycle.beginRequest("endSession-" + session.getId(), mockRequest);
- lifecycle.endSession(session.getId(), restoreSessionContext(session), conversationManager);
+ BeanStore sessionBeanStore = restoreSessionContext(session);
+ conversationManager.destroyAllConversations();
+ lifecycle.endSession(session.getId(), sessionBeanStore);
lifecycle.endRequest("endSession-" + session.getId(), mockRequest);
}
+
}
/**
@@ -159,9 +160,8 @@
}
lifecycle.endRequest(request.getRequestURI(), beanStore);
request.removeAttribute(REQUEST_ATTRIBUTE_NAME);
- SessionContext sessionContext = CurrentManager.rootManager().getServices().get(SessionContext.class);
- sessionContext.setActive(false);
- sessionContext.setBeanStore(null);
+ lifecycle.getSessionContext().setActive(false);
+ lifecycle.getSessionContext().setBeanStore(null);
}
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -27,7 +27,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSessionEvent;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.context.ContextLifecycle;
import org.jboss.webbeans.jsp.JspInitialization;
import org.jboss.webbeans.servlet.api.helpers.AbstractServletListener;
@@ -51,7 +51,7 @@
{
if (lifecycle == null)
{
- this.lifecycle = new ServletLifecycle(CurrentManager.rootManager().getServices().get(ContextLifecycle.class));
+ this.lifecycle = new ServletLifecycle(Container.instance().deploymentServices().get(ContextLifecycle.class));
}
return lifecycle;
}
@@ -60,7 +60,7 @@
public void contextInitialized(ServletContextEvent sce)
{
// JBoss AS will still start the deployment even if WB fails
- if (CurrentManager.isAvailable())
+ if (Container.instance() != null && Container.instance().isInitialized())
{
new JspInitialization().init(sce.getServletContext());
}
@@ -75,7 +75,7 @@
public void sessionCreated(HttpSessionEvent event)
{
// JBoss AS will still start the deployment even if WB fails
- if (CurrentManager.isAvailable())
+ if (Container.instance() != null && Container.instance().isInitialized())
{
getLifecycle().beginSession(event.getSession());
}
@@ -90,7 +90,7 @@
public void sessionDestroyed(HttpSessionEvent event)
{
// JBoss AS will still start the deployment even if WB fails
- if (CurrentManager.isAvailable())
+ if (Container.instance() != null && Container.instance().isInitialized())
{
getLifecycle().endSession(event.getSession());
}
@@ -105,7 +105,7 @@
public void requestDestroyed(ServletRequestEvent event)
{
// JBoss AS will still start the deployment even if WB fails
- if (CurrentManager.isAvailable())
+ if (Container.instance() != null && Container.instance().isInitialized())
{
if (event.getServletRequest() instanceof HttpServletRequest)
{
@@ -127,7 +127,7 @@
public void requestInitialized(ServletRequestEvent event)
{
// JBoss AS will still start the deployment even if WB fails
- if (CurrentManager.isAvailable())
+ if (Container.instance() != null && Container.instance().isInitialized())
{
if (event.getServletRequest() instanceof HttpServletRequest)
{
Modified: ri/branches/kabir-builder/porting-package/src/main/java/org/jboss/webbeans/tck/ContextsImpl.java
===================================================================
--- ri/branches/kabir-builder/porting-package/src/main/java/org/jboss/webbeans/tck/ContextsImpl.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/porting-package/src/main/java/org/jboss/webbeans/tck/ContextsImpl.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -1,10 +1,10 @@
package org.jboss.webbeans.tck;
import org.jboss.jsr299.tck.spi.Contexts;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.context.AbstractContext;
import org.jboss.webbeans.context.AbstractMapContext;
-import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.context.ContextLifecycle;
import org.jboss.webbeans.context.RequestContext;
public class ContextsImpl implements Contexts<AbstractContext>
@@ -12,7 +12,7 @@
public RequestContext getRequestContext()
{
- return CurrentManager.rootManager().getServices().get(RequestContext.class);
+ return Container.instance().deploymentServices().get(ContextLifecycle.class).getRequestContext();
}
public void setActive(AbstractContext context)
@@ -27,7 +27,7 @@
public AbstractContext getDependentContext()
{
- return CurrentManager.rootManager().getServices().get(DependentContext.class);
+ return Container.instance().deploymentServices().get(ContextLifecycle.class).getDependentContext();
}
public void destroyContext(AbstractContext context)
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Lifecycle.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Lifecycle.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Lifecycle.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -1,12 +1,42 @@
package org.jboss.webbeans.bootstrap.api;
+import javax.enterprise.context.spi.Context;
+
+import org.jboss.webbeans.context.api.BeanStore;
+
/**
- * Note Lifecycle is not complete, and the API may change
+ * Note Lifecycle is not complete, and the API may change.
*
+ * {@link Lifecycle} is a per-deployment service.
+ *
* @author pmuir
*
*/
-public interface Lifecycle extends Service
+public interface Lifecycle
{
+ public void restoreSession(String id, BeanStore sessionBeanStore);
+
+ public void endSession(String id, BeanStore sessionBeanStore);
+
+ public void beginRequest(String id, BeanStore requestBeanStore);
+
+ public void endRequest(String id, BeanStore requestBeanStore);
+
+ public boolean isRequestActive();
+
+ public void beginApplication(BeanStore applicationBeanStore);
+
+ public void endApplication();
+
+ public Context getApplicationContext();
+
+ public Context getSessionContext();
+
+ public Context getConversationContext();
+
+ public Context getRequestContext();
+
+ public Context getDependentContext();
+
}
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Service.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Service.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Service.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,4 +24,10 @@
public interface Service
{
+ /**
+ * Called by Web beans when it is shutting down, allowing the service to
+ * perform any cleanup needed.
+ */
+ public void cleanup();
+
}
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/ServiceRegistry.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/ServiceRegistry.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/ServiceRegistry.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -51,6 +51,12 @@
*/
public <S extends Service> boolean contains(Class<S> type);
+ /**
+ * Clear up the services registered, by calling {@link Service#cleanup()} on
+ * each registered service
+ */
+ public void cleanup();
+
}
\ No newline at end of file
Copied: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingLifecycle.java (from rev 3655, ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingLifecycle.java)
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingLifecycle.java (rev 0)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingLifecycle.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.bootstrap.api.helpers;
+
+import javax.enterprise.context.spi.Context;
+
+import org.jboss.webbeans.bootstrap.api.Lifecycle;
+import org.jboss.webbeans.context.api.BeanStore;
+
+/**
+ * @author pmuir
+ *
+ */
+public abstract class ForwardingLifecycle implements Lifecycle
+{
+
+ protected abstract Lifecycle delegate();
+
+ public void beginApplication(BeanStore applicationBeanStore)
+ {
+ delegate().beginApplication(applicationBeanStore);
+ }
+
+ public void beginRequest(String id, BeanStore requestBeanStore)
+ {
+ delegate().beginRequest(id, requestBeanStore);
+ }
+
+ public void endApplication()
+ {
+ delegate().endApplication();
+ }
+
+ public void endRequest(String id, BeanStore requestBeanStore)
+ {
+ delegate().endRequest(id, requestBeanStore);
+ }
+
+ public void endSession(String id, BeanStore sessionBeanStore)
+ {
+ delegate().endSession(id, sessionBeanStore);
+ }
+
+ public Context getApplicationContext()
+ {
+ return delegate().getApplicationContext();
+ }
+
+ public Context getConversationContext()
+ {
+ return delegate().getConversationContext();
+ }
+
+ public Context getDependentContext()
+ {
+ return delegate().getDependentContext();
+ }
+
+ public Context getRequestContext()
+ {
+ return delegate().getRequestContext();
+ }
+
+ public Context getSessionContext()
+ {
+ return delegate().getSessionContext();
+ }
+
+ public boolean isRequestActive()
+ {
+ return delegate().isRequestActive();
+ }
+
+ public void restoreSession(String id, BeanStore sessionBeanStore)
+ {
+ delegate().restoreSession(id, sessionBeanStore);
+ }
+
+ @Override
+ public String toString()
+ {
+ return delegate().toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return delegate().equals(obj);
+ }
+
+}
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingServiceRegistry.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingServiceRegistry.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingServiceRegistry.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -43,4 +43,9 @@
return delegate().entrySet();
}
+ public void cleanup()
+ {
+ delegate().cleanup();
+ }
+
}
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/SimpleServiceRegistry.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/SimpleServiceRegistry.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/SimpleServiceRegistry.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -76,6 +76,14 @@
return services.containsKey(type);
}
+ public void cleanup()
+ {
+ for (Service service : services.values())
+ {
+ service.cleanup();
+ }
+ }
+
@Override
public String toString()
{
Deleted: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/WebBeanDiscovery.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.bootstrap.spi;
-
-import java.net.URL;
-
-import org.jboss.webbeans.bootstrap.api.Service;
-
-/**
- * A container should implement this interface to allow Web Beans to
- * discover the beans to deploy
- *
- * @author Pete Muir
- * @deprecated now encapsulated by {@link BeanDeploymentArchive}
- *
- */
- at Deprecated
-public interface WebBeanDiscovery extends Service
-{
-
- /**
- * Gets list of all classes in classpath archives with META-INF/beans.xml (or
- * for WARs WEB-INF/beans.xml) files
- *
- * @return An iterable over the classes
- */
- public Iterable<Class<?>> discoverWebBeanClasses();
-
- /**
- * Gets a list of all deployment descriptors in the app classpath
- *
- * @return An iterable over the beans.xml files
- */
- public Iterable<URL> discoverWebBeansXml();
-
-}
Deleted: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/helpers/ForwardingWebBeanDiscovery.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/helpers/ForwardingWebBeanDiscovery.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/helpers/ForwardingWebBeanDiscovery.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -1,51 +0,0 @@
-package org.jboss.webbeans.bootstrap.spi.helpers;
-
-import java.net.URL;
-
-import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
-
-/**
- * An implementation of {@link WebBeanDiscovery} which forwards all its method
- * calls to another {@link WebBeanDiscovery}}. Subclasses should override one or
- * more methods to modify the behavior of the backing {@link WebBeanDiscovery}
- * as desired per the <a
- * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
- *
- * @author Pete Muir
- *
- */
- at Deprecated
-public abstract class ForwardingWebBeanDiscovery implements WebBeanDiscovery
-{
-
- protected abstract WebBeanDiscovery delegate();
-
- public Iterable<Class<?>> discoverWebBeanClasses()
- {
- return delegate().discoverWebBeanClasses();
- }
-
- public Iterable<URL> discoverWebBeansXml()
- {
- return delegate().discoverWebBeansXml();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- return delegate().equals(obj);
- }
-
- @Override
- public String toString()
- {
- return delegate().toString();
- }
-
- @Override
- public int hashCode()
- {
- return delegate().hashCode();
- }
-
-}
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,6 +24,8 @@
* A container should implement this interface to allow Web Beans to
* resolve EJB and discover EJBs
*
+ * {@link EjbServices} is a per-deployment service.
+ *
* @author Pete Muir
*
*/
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/EjbInjectionServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -23,8 +23,10 @@
/**
* A container should implement this interface to allow Web Beans to
- * resolve EJB
+ * resolve EJB.
*
+ * {@link EjbInjectionServices} is a per-module service.
+ *
* @author Pete Muir
*
*/
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/InjectionServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,6 +24,8 @@
*
* This service may be used to provide EE-style injection.
*
+ * {@link InjectionServices} is a per-BeanDeploymentArchive service.
+ *
* @author pmuir
*
*/
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/JpaInjectionServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -26,6 +26,8 @@
* A container should implement this interface to allow the Web Beans RI to
* resolve JPA persistence units and discover entities
*
+ * {@link JpaInjectionServices} is a per-module service.
+ *
* @author Pete Muir
*
*/
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/ResourceInjectionServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,6 +24,8 @@
* A container should implement this interface to allow the Web Beans RI to
* resolve Resources
*
+ * {@link ResourceInjectionServices} is per-module service.
+ *
* @author Pete Muir
*
*/
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/injection/spi/helpers/AbstractResourceServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -9,7 +9,9 @@
import javax.naming.Context;
import javax.naming.NamingException;
-public abstract class AbstractResourceServices
+import org.jboss.webbeans.bootstrap.api.Service;
+
+public abstract class AbstractResourceServices implements Service
{
private static final String RESOURCE_LOOKUP_PREFIX = "java:/comp/env";
@@ -121,4 +123,9 @@
}
+ public void cleanup()
+ {
+
+ }
+
}
Copied: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/manager/api/ExecutorServices.java (from rev 3655, ri/trunk/spi/src/main/java/org/jboss/webbeans/manager/api/ExecutorServices.java)
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/manager/api/ExecutorServices.java (rev 0)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/manager/api/ExecutorServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.manager.api;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * Allows a custom TaskExecutor to be provided by the container. By default,
+ * {@link Executors#newSingleThreadExecutor()} is used.
+ *
+ * This is a per-deployment service.
+ *
+ * @author pmuir
+ *
+ */
+public interface ExecutorServices extends Service
+{
+
+ public ExecutorService getTaskExecutor();
+
+}
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/manager/api/WebBeansManager.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/manager/api/WebBeansManager.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/manager/api/WebBeansManager.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -37,8 +37,6 @@
public interface WebBeansManager extends BeanManager, Serializable
{
- public void shutdown();
-
/**
* Create a new child activity. A child activity inherits all beans,
* interceptors, decorators, observers, and contexts defined by its direct
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoader.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoader.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceLoader.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -25,8 +25,10 @@
/**
* Resource loading/class creation services for Web Beans. By default an
* implementation which uses the Thread Context ClassLoader if available,
- * otherwise the classloading of the implementation is used
+ * otherwise the classloading of the implementation is used.
*
+ * The {@link ResourceLoader} is a per-deployment service.
+ *
* @author Pete Muir
*
*/
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/security/spi/SecurityServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/security/spi/SecurityServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/security/spi/SecurityServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -26,6 +26,8 @@
*
* Required in a Java EE environment.
*
+ * {@link SecurityServices} is a per-deployment service.
+ *
* @author pmuir
*
*/
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/servlet/api/ServletServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/servlet/api/ServletServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/servlet/api/ServletServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -26,6 +26,8 @@
* be called, in the same thread as the request, every time Web Beans needs to
* identify a request.
*
+ * {@link ServletServices} is a per-deployment service.
+ *
* @author pmuir
*
*/
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/transaction/spi/TransactionServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/transaction/spi/TransactionServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/transaction/spi/TransactionServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -21,6 +21,8 @@
*
* <p>Required in a Java EE environment</p>
*
+ * <p> {@link TransactionServices} is a per-deployment service.</p>
+ *
* @author David Allen
*
*/
Modified: ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/validation/spi/ValidationServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/validation/spi/ValidationServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/main/java/org/jboss/webbeans/validation/spi/ValidationServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -30,6 +30,8 @@
* Required in a Java EE environment.
* </p>
*
+ * <p> {@link ValidationServices} is a per-deployment service</p>
+ *
* @author pmuir
*
*/
Modified: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbInjectionServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,7 +24,7 @@
* @author pmuir
*
*/
-public class MockEjbInjectionServices implements EjbInjectionServices
+public class MockEjbInjectionServices extends MockService implements EjbInjectionServices
{
public Object resolveEjb(InjectionPoint injectionPoint)
Modified: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -6,7 +6,7 @@
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.ejb.spi.EjbServices;
-public class MockEjbServices implements EjbServices
+public class MockEjbServices extends MockService implements EjbServices
{
public Iterable<EjbDescriptor<?>> discoverEjbs()
Modified: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -8,7 +8,7 @@
import org.jboss.webbeans.injection.spi.JpaInjectionServices;
-public class MockJpaServices implements JpaInjectionServices
+public class MockJpaServices extends MockService implements JpaInjectionServices
{
public Collection<Class<?>> discoverEntities()
Modified: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceLoader.java
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceLoader.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceLoader.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -5,7 +5,7 @@
import org.jboss.webbeans.resources.spi.ResourceLoader;
-public class MockResourceLoader implements ResourceLoader
+public class MockResourceLoader extends MockService implements ResourceLoader
{
public Class<?> classForName(String name)
Modified: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -4,7 +4,7 @@
import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
-public class MockResourceServices implements ResourceInjectionServices
+public class MockResourceServices extends MockService implements ResourceInjectionServices
{
public Object resolveResource(InjectionPoint injectionPoint)
Modified: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockSecurityServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockSecurityServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockSecurityServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,7 +24,7 @@
* @author pmuir
*
*/
-public class MockSecurityServices implements SecurityServices
+public class MockSecurityServices extends MockService implements SecurityServices
{
/* (non-Javadoc)
Copied: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockService.java (from rev 3655, ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockService.java)
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockService.java (rev 0)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockService.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.bootstrap.api.test;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * @author pmuir
+ *
+ */
+public abstract class MockService implements Service
+{
+
+ public void cleanup()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Modified: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockServletServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockServletServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockServletServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -25,7 +25,7 @@
* @author pmuir
*
*/
-public class MockServletServices implements ServletServices
+public class MockServletServices extends MockService implements ServletServices
{
public BeanDeploymentArchive getBeanDeploymentArchive(ServletContext ctx)
Modified: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockTransactionServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockTransactionServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockTransactionServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -5,7 +5,7 @@
import org.jboss.webbeans.transaction.spi.TransactionServices;
-public class MockTransactionServices implements TransactionServices
+public class MockTransactionServices extends MockService implements TransactionServices
{
public boolean isTransactionActive()
Modified: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockValidationServices.java
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockValidationServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockValidationServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -24,7 +24,7 @@
* @author pmuir
*
*/
-public class MockValidationServices implements ValidationServices
+public class MockValidationServices extends MockService implements ValidationServices
{
public ValidatorFactory getDefaultValidatorFactory()
Deleted: ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebBeanDiscovery.java
===================================================================
--- ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebBeanDiscovery.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebBeanDiscovery.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -1,20 +0,0 @@
-package org.jboss.webbeans.bootstrap.api.test;
-
-import java.net.URL;
-
-import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
-
-public class MockWebBeanDiscovery implements WebBeanDiscovery
-{
-
- public Iterable<Class<?>> discoverWebBeanClasses()
- {
- return null;
- }
-
- public Iterable<URL> discoverWebBeansXml()
- {
- return null;
- }
-
-}
Modified: ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
===================================================================
--- ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -39,4 +39,7 @@
};
}
-}
\ No newline at end of file
+
+ public void cleanup() {}
+
+}
Modified: ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java
===================================================================
--- ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockEjbInjectionServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -31,5 +31,7 @@
{
return null;
}
+
+ public void cleanup() {}
}
Modified: ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
===================================================================
--- ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -60,5 +60,7 @@
discoverEntities(child, classes);
}
}
+
+ public void cleanup() {}
}
\ No newline at end of file
Modified: ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockResourceLoader.java
===================================================================
--- ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockResourceLoader.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockResourceLoader.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -56,4 +56,6 @@
}
}
+ public void cleanup() {}
+
}
Modified: ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
===================================================================
--- ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -37,4 +37,6 @@
return null;
}
+ public void cleanup() {}
+
}
Modified: ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockSecurityServices.java
===================================================================
--- ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockSecurityServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockSecurityServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -35,5 +35,7 @@
// TODO Auto-generated method stub
return null;
}
+
+ public void cleanup() {}
}
Modified: ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java
===================================================================
--- ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletLifecycle.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -3,13 +3,15 @@
import org.jboss.webbeans.bootstrap.WebBeansBootstrap;
import org.jboss.webbeans.bootstrap.api.Environment;
import org.jboss.webbeans.bootstrap.api.Environments;
+import org.jboss.webbeans.bootstrap.api.Lifecycle;
+import org.jboss.webbeans.bootstrap.api.helpers.ForwardingLifecycle;
import org.jboss.webbeans.context.ContextLifecycle;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.servlet.api.ServletServices;
-public class MockServletLifecycle extends ContextLifecycle
+public class MockServletLifecycle extends ForwardingLifecycle
{
private static final ResourceLoader MOCK_RESOURCE_LOADER = new MockResourceLoader();
@@ -19,6 +21,8 @@
private final BeanStore sessionBeanStore = new ConcurrentHashMapBeanStore();
private final BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
+ private Lifecycle lifecycle;
+
public MockServletLifecycle()
{
this.deployment = new MockDeployment();
@@ -33,9 +37,22 @@
public void initialize()
{
- bootstrap.startContainer(getEnvironment(), getDeployment(), getApplicationBeanStore());
+ try
+ {
+ bootstrap.startContainer(getEnvironment(), getDeployment(), getApplicationBeanStore());
+ }
+ finally
+ {
+ lifecycle = deployment.getServices().get(ContextLifecycle.class);
+ }
}
+ @Override
+ protected Lifecycle delegate()
+ {
+ return lifecycle;
+ }
+
public MockDeployment getDeployment()
{
return deployment;
Modified: ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletServices.java
===================================================================
--- ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockServletServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -46,5 +46,7 @@
return null;
}
}
+
+ public void cleanup() {}
}
Modified: ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockTransactionServices.java
===================================================================
--- ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockTransactionServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockTransactionServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -46,5 +46,7 @@
{
return null;
}
+
+ public void cleanup() {}
}
Modified: ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockValidationServices.java
===================================================================
--- ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockValidationServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/main/java/org/jboss/webbeans/mock/MockValidationServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -31,5 +31,7 @@
{
return null;
}
+
+ public void cleanup() {}
}
Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/CheckableInjectionServices.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -79,4 +79,6 @@
return injectionTargetCorrect;
}
+ public void cleanup() {}
+
}
Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java 2009-09-14 09:34:25 UTC (rev 3656)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -9,7 +9,7 @@
import javax.enterprise.inject.spi.Bean;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.Container;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.mock.MockBeanDeploymentArchive;
@@ -33,7 +33,7 @@
lifecycle.beginApplication();
lifecycle.beginSession();
lifecycle.beginRequest();
- manager = CurrentManager.rootManager();
+ manager = Container.instance().deploymentManager();
}
@AfterClass(alwaysRun=true)
Copied: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Cat.java (from rev 3655, ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Cat.java)
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Cat.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Cat.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.test.unit.manager;
+
+import javax.ejb.Stateful;
+
+/**
+ * @author pmuir
+ *
+ */
+ at Stateful
+public class Cat implements CatLocal
+{
+
+}
Copied: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/CatLocal.java (from rev 3655, ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/CatLocal.java)
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/CatLocal.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/CatLocal.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.test.unit.manager;
+
+import javax.ejb.Local;
+
+/**
+ * @author pmuir
+ *
+ */
+ at Local
+public interface CatLocal
+{
+
+}
Copied: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java (from rev 3655, ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java)
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java 2009-09-14 11:10:40 UTC (rev 3657)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.test.unit.manager;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.ejb.InternalEjbDescriptor;
+import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+import org.jboss.webbeans.test.AbstractWebBeansTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author pmuir
+ *
+ */
+ at Artifact
+ at Packaging(PackagingType.EAR)
+public class EjbDescriptorLookupTest extends AbstractWebBeansTest
+{
+
+ @Test
+ public void testCorrectSubType()
+ {
+ EjbDescriptor<CatLocal> descriptor = getCurrentManager().getEjbDescriptor("Cat");
+ assert descriptor.getClass().equals(InternalEjbDescriptor.class);
+ Bean<CatLocal> bean = getCurrentManager().getBean(descriptor);
+ assert bean != null;
+ assert bean instanceof EnterpriseBean;
+ assert bean.getBeanClass().equals(Cat.class);
+ InjectionTarget<CatLocal> it = getCurrentManager().createInjectionTarget(descriptor);
+ assert it != null;
+ assert it instanceof EnterpriseBean;
+ assert it == bean;
+ }
+
+}
More information about the weld-commits
mailing list