[webbeans-commits] Webbeans SVN: r3664 - in extensions/trunk/se: src/main/java/org/jboss/webbeans/environment/se and 8 other directories.
by webbeans-commits@lists.jboss.org
Author: peteroyle
Date: 2009-09-14 20:18:59 -0400 (Mon, 14 Sep 2009)
New Revision: 3664
Removed:
extensions/trunk/se/src/main/resources/beans.xml
Modified:
extensions/trunk/se/pom.xml
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/ShutdownManager.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/beans/ParametersFactory.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/bindings/Parameters.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/AbstractScanner.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEBeanDeploymentArchive.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeanDiscovery.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeansDeployment.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/Scanner.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/URLScanner.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Shutdown.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/MainTestBean.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ParametersTestBean.java
extensions/trunk/se/src/test/resources/META-INF/beans.xml
Log:
Updated to latest spec changes and added service registry
Modified: extensions/trunk/se/pom.xml
===================================================================
--- extensions/trunk/se/pom.xml 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/pom.xml 2009-09-15 00:18:59 UTC (rev 3664)
@@ -69,6 +69,11 @@
<artifactId>webbeans-core</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>inject-api</artifactId>
+ </dependency>
+
</dependencies>
<scm>
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/ShutdownManager.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/ShutdownManager.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/ShutdownManager.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,3 +1,19 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se;
import javax.enterprise.context.ApplicationScoped;
@@ -2,5 +18,5 @@
import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Current;
import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
import org.jboss.webbeans.bootstrap.api.Bootstrap;
@@ -16,7 +32,7 @@
{
private static LogProvider log = Logging.getLogProvider(ShutdownManager.class);
- private @Current WebBeansManager manager;
+ private @Inject WebBeansManager manager;
private boolean hasShutdownBeenCalled = false;
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -20,7 +20,7 @@
import org.jboss.webbeans.bootstrap.api.Bootstrap;
import org.jboss.webbeans.bootstrap.api.Environments;
-import org.jboss.webbeans.bootstrap.spi.Deployment;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
import org.jboss.webbeans.environment.se.discovery.SEWebBeansDeployment;
@@ -57,16 +57,16 @@
this.applicationBeanStore = new ConcurrentHashMapBeanStore();
}
- public BeanManager go()
- {
- bootstrap.setEnvironment(Environments.SE);
- bootstrap.getServices().add(Deployment.class, new SEWebBeansDeployment() {});
- bootstrap.setApplicationContext(applicationBeanStore);
- bootstrap.startContainer();
- bootstrap.startInitialization().deployBeans().validateBeans().endInitialization();
- this.manager = bootstrap.getManager();
- WebBeansManagerUtils.getInstanceByType(manager, ShutdownManager.class).
- setBootstrap(bootstrap);
+ public BeanManager go() {
+ SEWebBeansDeployment deployment = new SEWebBeansDeployment() {};
+ bootstrap.startContainer(Environments.SE, deployment, this.applicationBeanStore);
+ final BeanDeploymentArchive mainBeanDepArch = deployment.getBeanDeploymentArchives().get(0);
+ this.manager = bootstrap.getManager(mainBeanDepArch);
+ bootstrap.startInitialization();
+ bootstrap.deployBeans();
+ WebBeansManagerUtils.getInstanceByType(manager, ShutdownManager.class).setBootstrap(bootstrap);
+ bootstrap.validateBeans();
+ bootstrap.endInitialization();
return this.manager;
}
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/beans/ParametersFactory.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/beans/ParametersFactory.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/beans/ParametersFactory.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -22,9 +22,7 @@
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Observes;
import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
import org.jboss.webbeans.environment.se.StartMain;
import org.jboss.webbeans.environment.se.bindings.Parameters;
@@ -41,6 +39,10 @@
{
private String[] args;
private List<String> argsList;
+
+ public ParametersFactory() {
+ this.setArgs(StartMain.PARAMETERS);
+ }
/**
* Producer method for the injectable command line args.
@@ -79,13 +81,4 @@
this.argsList = Collections.unmodifiableList( new ArrayList<String>( Arrays.asList( args ) ) );
}
- /**
- * On WebBeans initialisation, retrieve the command line args that were given
- * to StartMain.
- *
- * @param manager The Manager which has been initialized.
- */
- public void initArgs(@Observes AfterBeanDiscovery after) {
- this.setArgs( StartMain.PARAMETERS );
- }
}
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/bindings/Parameters.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/bindings/Parameters.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/bindings/Parameters.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -20,14 +20,14 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import javax.inject.Qualifier;
-import javax.enterprise.inject.BindingType;
/**
*
* @author Peter Royle
*/
-@BindingType
+@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target( { ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD, ElementType.TYPE })
public @interface Parameters {}
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/AbstractScanner.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/AbstractScanner.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/AbstractScanner.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,8 +1,8 @@
/**
* 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.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEBeanDeploymentArchive.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEBeanDeploymentArchive.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEBeanDeploymentArchive.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,8 +1,8 @@
-/*
+/**
* 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.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
@@ -20,6 +20,8 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
+import org.jboss.webbeans.bootstrap.api.helpers.SimpleServiceRegistry;
import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
@@ -34,10 +36,12 @@
public class SEBeanDeploymentArchive implements BeanDeploymentArchive
{
private final SEWebBeanDiscovery wbDiscovery;
+ private final ServiceRegistry serviceRegistry;
public SEBeanDeploymentArchive()
{
wbDiscovery = new SEWebBeanDiscovery() {};
+ serviceRegistry = new SimpleServiceRegistry();
}
/**
@@ -73,4 +77,8 @@
return Collections.EMPTY_SET;
}
+ public ServiceRegistry getServices() {
+ return this.serviceRegistry;
+ }
+
}
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeanDiscovery.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeanDiscovery.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeanDiscovery.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,8 +1,8 @@
/**
* 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.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
@@ -22,7 +22,6 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.environment.se.util.Reflections;
/**
@@ -33,7 +32,7 @@
* @author Pete Muir
* @author Ales Justin
*/
-public abstract class SEWebBeanDiscovery implements WebBeanDiscovery
+public abstract class SEWebBeanDiscovery
{
private final Set<Class<?>> wbClasses;
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeansDeployment.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeansDeployment.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeansDeployment.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,8 +1,8 @@
/**
* 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.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
@@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.webbeans.bootstrap.spi.Deployment;
@@ -42,7 +43,7 @@
/**
* {@inheritDoc}
* @return A collection containing the singular logical BeanDeploymentArchive
- * consisting of all Bean classes and beans.xml descriptos in the current
+ * consisting of all Bean classes and beans.xml descriptors in the current
* classpath.
*/
public List<BeanDeploymentArchive> getBeanDeploymentArchives()
@@ -59,4 +60,8 @@
{
return this.beanDeploymentArchive;
}
+
+ public ServiceRegistry getServices() {
+ return this.beanDeploymentArchive.getServices();
+ }
}
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/Scanner.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/Scanner.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/Scanner.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,8 +1,8 @@
/**
* 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.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/URLScanner.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/URLScanner.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/URLScanner.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,8 +1,8 @@
/**
* 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.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Shutdown.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Shutdown.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/events/Shutdown.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,8 +1,8 @@
-/*
+/**
* 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.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
@@ -20,8 +20,8 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import javax.inject.Qualifier;
-import javax.enterprise.inject.BindingType;
/**
* Fired by webbeans SE before shutting down. Applications and modules should
@@ -29,7 +29,7 @@
*
* @author Peter Royle
*/
-@BindingType
+@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target( { ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD, ElementType.TYPE })
public @interface Shutdown{}
Deleted: extensions/trunk/se/src/main/resources/beans.xml
===================================================================
--- extensions/trunk/se/src/main/resources/beans.xml 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/main/resources/beans.xml 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,19 +0,0 @@
-<!--
-
- JBoss, Home of Professional Open Source
- Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
-
--->
-<beans></beans>
Modified: extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
===================================================================
--- extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,8 +1,8 @@
/**
* 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.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
Modified: extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/MainTestBean.java
===================================================================
--- extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/MainTestBean.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/MainTestBean.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,8 +1,8 @@
/**
* 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.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
@@ -16,25 +16,28 @@
*/
package org.jboss.webbeans.environment.se.test.beans;
+import java.io.Serializable;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Current;
-import javax.enterprise.inject.Initializer;
import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.inject.Inject;
/**
*
* @author Peter Royle
*/
@ApplicationScoped
-public class MainTestBean
+public class MainTestBean implements Serializable
{
boolean initialised = false;
ParametersTestBean parametersTestBean;
- @Initializer
- public void init(@Current ParametersTestBean paramsTestBean)
+ public MainTestBean() {
+ }
+
+ @Inject
+ public MainTestBean(ParametersTestBean paramsTestBean)
{
this.initialised = true;
this.parametersTestBean = paramsTestBean;
Modified: extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ParametersTestBean.java
===================================================================
--- extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ParametersTestBean.java 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ParametersTestBean.java 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,8 +1,8 @@
/**
* 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.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-
package org.jboss.webbeans.environment.se.test.beans;
+import java.io.Serializable;
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Initializer;
+import javax.inject.Inject;
import org.jboss.webbeans.environment.se.bindings.Parameters;
import org.testng.Assert;
@@ -31,12 +31,15 @@
* @author Peter Royle
*/
@ApplicationScoped
-public class ParametersTestBean {
+public class ParametersTestBean implements Serializable {
List<String> parameters;
- @Initializer
- public void init(@Parameters List<String> params) {
+ public ParametersTestBean() {
+ }
+
+ @Inject
+ public ParametersTestBean(@Parameters List<String> params) {
this.parameters = params;
// even if no args are given, it should will always at least be an empty array
Assert.assertNotNull( params );
Modified: extensions/trunk/se/src/test/resources/META-INF/beans.xml
===================================================================
--- extensions/trunk/se/src/test/resources/META-INF/beans.xml 2009-09-14 17:57:21 UTC (rev 3663)
+++ extensions/trunk/se/src/test/resources/META-INF/beans.xml 2009-09-15 00:18:59 UTC (rev 3664)
@@ -1,9 +1,9 @@
<!--
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.
+ Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.
14 years, 7 months
[webbeans-commits] Webbeans SVN: r3663 - in ri/trunk: impl/src/main/java/org/jboss/webbeans and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-09-14 13:57:21 -0400 (Mon, 14 Sep 2009)
New Revision: 3663
Modified:
ri/trunk/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
Log:
Add wrapExpressionFactory
Modified: ri/trunk/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java
===================================================================
--- ri/trunk/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java 2009-09-14 17:55:44 UTC (rev 3662)
+++ ri/trunk/api/src/main/java/javax/enterprise/inject/spi/BeanManager.java 2009-09-14 17:57:21 UTC (rev 3663)
@@ -23,6 +23,7 @@
import java.util.Set;
import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
import javax.enterprise.context.ContextNotActiveException;
import javax.enterprise.context.spi.Context;
import javax.enterprise.context.spi.Contextual;
@@ -261,6 +262,14 @@
public ELResolver getELResolver();
/**
+ * Returns an ExpressionFactory
+ *
+ * @param expressionFactory
+ * @return
+ */
+ public ExpressionFactory wrapExpressionFactory(ExpressionFactory expressionFactory);
+
+ /**
* Get an {@link AnnotatedType} for the given class
* @param <T> the type
* @param type the type
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-09-14 17:55:44 UTC (rev 3662)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-09-14 17:57:21 UTC (rev 3663)
@@ -38,6 +38,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
import javax.enterprise.context.ContextNotActiveException;
import javax.enterprise.context.spi.Context;
import javax.enterprise.context.spi.Contextual;
@@ -57,8 +58,8 @@
import javax.inject.Qualifier;
import org.jboss.webbeans.bean.DecoratorImpl;
+import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.SessionBean;
-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.CreationalContextImpl;
@@ -67,6 +68,7 @@
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.el.Namespace;
import org.jboss.webbeans.el.WebBeansELResolver;
+import org.jboss.webbeans.el.WebBeansExpressionFactory;
import org.jboss.webbeans.introspector.WBAnnotated;
import org.jboss.webbeans.literal.AnyLiteral;
import org.jboss.webbeans.literal.DefaultLiteral;
@@ -1324,6 +1326,11 @@
return webbeansELResolver;
}
+ public ExpressionFactory wrapExpressionFactory(ExpressionFactory expressionFactory)
+ {
+ return new WebBeansExpressionFactory(expressionFactory);
+ }
+
public <T> WBCreationalContext<T> createCreationalContext(Contextual<T> contextual)
{
return new CreationalContextImpl<T>(contextual);
14 years, 7 months
[webbeans-commits] Webbeans SVN: r3662 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests: context/dependent and 14 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-09-14 13:55:44 -0400 (Mon, 14 Sep 2009)
New Revision: 3662
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/AbstractConversationTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/InteriorRoom.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/UnderwaterCity.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/UnderwaterCity.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInitializerMethod/UnderwaterCity.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInjectedField/UnderwaterCity.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DataAccessImpl.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/NotAuthorizedException.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/exceptionInAfterBeanDiscoveryObserver/FooException.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/useBeforeValidationFails/UseBeforeValidationTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/MockLoginModule.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/producer/method/broken/twoBeansSpecializeTheSameBean/PictureShop_Broken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/builtin/BuiltinInstanceTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/reference/ambiguous/AnnotatedInjectionField.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/reference/unresolved/AnnotatedInjectionField.java
Log:
cleanup todos
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/AbstractConversationTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/AbstractConversationTest.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/AbstractConversationTest.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -12,7 +12,7 @@
public abstract class AbstractConversationTest extends AbstractJSR299Test
{
- // TODO this should be part of the JSR-299 API
+
public static final String CID_REQUEST_PARAMETER_NAME = "cid";
public static final String CID_HEADER_NAME = "org.jboss.jsr299.tck.cid";
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/InteriorRoom.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/InteriorRoom.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/InteriorRoom.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -5,7 +5,6 @@
{
public void foo()
{
- // TODO Auto-generated method stub
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/UnderwaterCity.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/UnderwaterCity.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/UnderwaterCity.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -5,7 +5,6 @@
public void foo()
{
- // TODO Auto-generated method stub
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/UnderwaterCity.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/UnderwaterCity.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/UnderwaterCity.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -7,7 +7,6 @@
public void foo()
{
- // TODO Auto-generated method stub
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInitializerMethod/UnderwaterCity.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInitializerMethod/UnderwaterCity.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInitializerMethod/UnderwaterCity.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -10,7 +10,6 @@
public void foo()
{
- // TODO Auto-generated method stub
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInjectedField/UnderwaterCity.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInjectedField/UnderwaterCity.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInjectedField/UnderwaterCity.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -7,7 +7,6 @@
public void foo()
{
- // TODO Auto-generated method stub
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DataAccessImpl.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DataAccessImpl.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/DataAccessImpl.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -23,49 +23,29 @@
public class DataAccessImpl implements DataAccess
{
- /* (non-Javadoc)
- * @see org.jboss.jsr299.tck.tests.deployment.lifecycle.DataAccess#delete()
- */
public void delete()
{
- // TODO Auto-generated method stub
}
- /* (non-Javadoc)
- * @see org.jboss.jsr299.tck.tests.deployment.lifecycle.DataAccess#getDataType()
- */
public Class<?> getDataType()
{
- // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.jboss.jsr299.tck.tests.deployment.lifecycle.DataAccess#getId()
- */
public Object getId()
{
- // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.jboss.jsr299.tck.tests.deployment.lifecycle.DataAccess#load(java.lang.Object)
- */
public Object load(Object id)
{
- // TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see org.jboss.jsr299.tck.tests.deployment.lifecycle.DataAccess#save()
- */
public void save()
{
- // TODO Auto-generated method stub
-
+
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/NotAuthorizedException.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/NotAuthorizedException.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/NotAuthorizedException.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -7,13 +7,11 @@
public NotAuthorizedException(String message, Throwable cause)
{
super(message, cause);
- // TODO Auto-generated constructor stub
}
public NotAuthorizedException(String message)
{
super(message);
- // TODO Auto-generated constructor stub
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/exceptionInAfterBeanDiscoveryObserver/FooException.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/exceptionInAfterBeanDiscoveryObserver/FooException.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/exceptionInAfterBeanDiscoveryObserver/FooException.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -28,28 +28,24 @@
*/
private static final long serialVersionUID = 4441409975741605270L;
-public FooException()
+ public FooException()
{
super();
- // TODO Auto-generated constructor stub
}
public FooException(String arg0, Throwable arg1)
{
super(arg0, arg1);
- // TODO Auto-generated constructor stub
}
public FooException(String arg0)
{
super(arg0);
- // TODO Auto-generated constructor stub
}
public FooException(Throwable arg0)
{
super(arg0);
- // TODO Auto-generated constructor stub
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/useBeforeValidationFails/UseBeforeValidationTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/useBeforeValidationFails/UseBeforeValidationTest.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/lifecycle/broken/useBeforeValidationFails/UseBeforeValidationTest.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -38,7 +38,7 @@
@Test(groups = {"ri-broken", "rewrite"})
//Still not clear how the container should now allow this, but the RI is clearly not implementing this assertion
// TODO Needs Extension stuff adding
- // TODO This isn't what this assertion means, it really means external requests, very hard to test
+ // TODO very hard to test
// WBRI-300
@SpecAssertions({
@SpecAssertion(section = "11.5.3", id = "d"),
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/MockLoginModule.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/MockLoginModule.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/builtin/MockLoginModule.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -37,7 +37,6 @@
public MockLoginModule()
{
- // TODO Auto-generated constructor stub
}
public boolean abort() throws LoginException
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Cod.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -14,7 +14,6 @@
public void ping()
{
- // TODO Auto-generated method stub
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/producer/method/broken/twoBeansSpecializeTheSameBean/PictureShop_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/producer/method/broken/twoBeansSpecializeTheSameBean/PictureShop_Broken.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/inheritance/specialization/producer/method/broken/twoBeansSpecializeTheSameBean/PictureShop_Broken.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -8,7 +8,6 @@
@Override @Produces @Specializes
public Product getExpensiveGift()
{
- // TODO Auto-generated method stub
return super.getExpensiveGift();
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/clientProxy/ClientProxyTest.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -81,7 +81,7 @@
assert false;
}
- // TODO need to set request scope active again, some other tests will fail otherwise
+ // need to set request scope active again, some other tests will fail otherwise
setContextActive(getCurrentConfiguration().getContexts().getRequestContext());
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/builtin/BuiltinInstanceTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/builtin/BuiltinInstanceTest.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/builtin/BuiltinInstanceTest.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -37,14 +37,16 @@
@Test
@SpecAssertion(section = "5.7.2", id = "d")
- public void testScopeOfBuiltinInstance() {
+ public void testScopeOfBuiltinInstance()
+ {
Bean<Instance<Cow>> bean = getBeans(new TypeLiteral<Instance<Cow>>() {}).iterator().next();
assert Dependent.class.equals(bean.getScope());
}
@Test
@SpecAssertion(section = "5.7.2", id = "e")
- public void testNameOfBuiltinInstance() {
+ public void testNameOfBuiltinInstance()
+ {
Bean<Instance<Cow>> bean = getBeans(new TypeLiteral<Instance<Cow>>() {}).iterator().next();
assert bean.getName() == null;
}
@@ -52,18 +54,20 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "5.7.2", id = "a"),
- @SpecAssertion(section = "5.7.2", id = "f")})
- public void testInstanceProvidedForEveryLegalBeanType() {
+ @SpecAssertion(section = "5.7.2", id = "f")
+ })
+ public void testInstanceProvidedForEveryLegalBeanType()
+ {
Farm farm = getInstanceByType(Farm.class);
assert farm.getAnimal() != null;
assert farm.getAbstractAnimal() != null;
assert farm.getCow() != null;
}
- @Test
+ @Test(groups = "broken")
@SpecAssertion(section = "5.7.2", id = "g")
public void testInstanceIsPassivationCapable() {
Bean<Instance> instance = getBeans(Instance.class).iterator().next();
- // TODO assert instance.isSerializable();
+ // assert instance.isSerializable();
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/reference/ambiguous/AnnotatedInjectionField.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/reference/ambiguous/AnnotatedInjectionField.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/reference/ambiguous/AnnotatedInjectionField.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -33,7 +33,6 @@
public AnnotatedType<InjectedBean> getDeclaringType()
{
- // TODO Auto-generated method stub
return null;
}
@@ -44,31 +43,26 @@
public <T extends Annotation> T getAnnotation(Class<T> annotationType)
{
- // TODO Auto-generated method stub
return null;
}
public Set<Annotation> getAnnotations()
{
- // TODO Auto-generated method stub
return null;
}
public Type getBaseType()
{
- // TODO Auto-generated method stub
return InjectedBean.class;
}
public Set<Type> getTypeClosure()
{
- // TODO Auto-generated method stub
return null;
}
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
{
- // TODO Auto-generated method stub
return false;
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/reference/unresolved/AnnotatedInjectionField.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/reference/unresolved/AnnotatedInjectionField.java 2009-09-14 15:46:43 UTC (rev 3661)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/broken/reference/unresolved/AnnotatedInjectionField.java 2009-09-14 17:55:44 UTC (rev 3662)
@@ -33,7 +33,6 @@
public AnnotatedType<InjectedBean> getDeclaringType()
{
- // TODO Auto-generated method stub
return null;
}
@@ -44,31 +43,26 @@
public <T extends Annotation> T getAnnotation(Class<T> annotationType)
{
- // TODO Auto-generated method stub
return null;
}
public Set<Annotation> getAnnotations()
{
- // TODO Auto-generated method stub
return null;
}
public Type getBaseType()
{
- // TODO Auto-generated method stub
return InjectedBean.class;
}
public Set<Type> getTypeClosure()
{
- // TODO Auto-generated method stub
return null;
}
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
{
- // TODO Auto-generated method stub
return false;
}
14 years, 7 months
[webbeans-commits] Webbeans SVN: r3661 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bean and 5 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-09-14 11:46:43 -0400 (Mon, 14 Sep 2009)
New Revision: 3661
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ws/
ri/trunk/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java
tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
Log:
WBRI-377
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java 2009-09-14 15:42:41 UTC (rev 3660)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java 2009-09-14 15:46:43 UTC (rev 3661)
@@ -29,7 +29,7 @@
import org.jboss.webbeans.util.Names;
/**
- * Represents a producer field bean
+ * Represents a producer field
*
* @author Pete Muir
*
@@ -42,12 +42,12 @@
private final String id;
/**
- * Creates a producer field Web Bean
+ * Creates a producer field
*
* @param field The underlying method abstraction
* @param declaringBean The declaring bean abstraction
* @param manager the current manager
- * @return A producer Web Bean
+ * @return A producer field
*/
public static <T> ProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
{
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java 2009-09-14 15:46:43 UTC (rev 3661)
@@ -0,0 +1,74 @@
+/*
+ * 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.bean.ee;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bean.ProducerField;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.ejb.EJBApiAbstraction;
+import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
+import org.jboss.webbeans.ws.WSApiAbstraction;
+
+/**
+ * @author pmuir
+ *
+ */
+public class EEResourceProducerField<T> extends ProducerField<T>
+{
+
+ /**
+ * Creates an EE resource producer field
+ *
+ * @param field The underlying method abstraction
+ * @param declaringBean The declaring bean abstraction
+ * @param manager the current manager
+ * @return A producer field
+ */
+ public static <T> EEResourceProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ return new EEResourceProducerField<T>(field, declaringBean, manager);
+ }
+
+ protected EEResourceProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ super(field, declaringBean, manager);
+ }
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ super.initialize(environment);
+ checkEEResource();
+ }
+ }
+
+ protected void checkEEResource()
+ {
+ EJBApiAbstraction ejbApiAbstraction = manager.getServices().get(EJBApiAbstraction.class);
+ PersistenceApiAbstraction persistenceApiAbstraction = manager.getServices().get(PersistenceApiAbstraction.class);
+ WSApiAbstraction wsApiAbstraction = manager.getServices().get(WSApiAbstraction.class);
+ if (!(getAnnotatedItem().isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS)) || getAnnotatedItem().isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS))
+ {
+ throw new IllegalStateException("Tried to create an EEResourceProducerField, but no @Resource, @PersistenceContext, @PersistenceUnit, @WebServiceRef or @EJB is present " + getAnnotatedItem());
+ }
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java 2009-09-14 15:46:43 UTC (rev 3661)
@@ -0,0 +1,60 @@
+/*
+ * 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.bean.ee;
+
+import javax.persistence.EntityManager;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.introspector.WBField;
+
+/**
+ * @author pmuir
+ *
+ */
+public class PersistenceContextProducerField<T extends EntityManager> extends EEResourceProducerField<T>
+{
+
+ /**
+ * Creates an EE resource producer field
+ *
+ * @param field The underlying method abstraction
+ * @param declaringBean The declaring bean abstraction
+ * @param manager the current manager
+ * @return A producer field
+ */
+ public static <T extends EntityManager> EEResourceProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ return new PersistenceContextProducerField<T>(field, declaringBean, manager);
+ }
+
+ /**
+ * @param field
+ * @param declaringBean
+ * @param manager
+ */
+ protected PersistenceContextProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ super(field, declaringBean, manager);
+ }
+
+ public void dispose(T instance)
+ {
+ instance.close();
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-09-14 15:42:41 UTC (rev 3660)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-09-14 15:46:43 UTC (rev 3661)
@@ -32,13 +32,15 @@
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.DecoratorImpl;
import org.jboss.webbeans.bean.DisposalMethod;
-import org.jboss.webbeans.bean.SessionBean;
+import org.jboss.webbeans.bean.ManagedBean;
+import org.jboss.webbeans.bean.NewManagedBean;
import org.jboss.webbeans.bean.NewSessionBean;
-import org.jboss.webbeans.bean.NewManagedBean;
import org.jboss.webbeans.bean.ProducerField;
import org.jboss.webbeans.bean.ProducerMethod;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.ManagedBean;
+import org.jboss.webbeans.bean.SessionBean;
+import org.jboss.webbeans.bean.ee.EEResourceProducerField;
+import org.jboss.webbeans.bean.ee.PersistenceContextProducerField;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.event.ObserverFactory;
@@ -49,8 +51,10 @@
import org.jboss.webbeans.jsf.JsfApiAbstraction;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
import org.jboss.webbeans.servlet.ServletApiAbstraction;
import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.ws.WSApiAbstraction;
public class AbstractBeanDeployer
{
@@ -147,7 +151,19 @@
protected <T> void createProducerField(AbstractClassBean<?> declaringBean, WBField<T, ?> field)
{
- ProducerField<T> bean = ProducerField.of(field, declaringBean, manager);
+ ProducerField<T> bean;
+ if (isPersistenceContextProducerField(field))
+ {
+ bean = PersistenceContextProducerField.of(field, declaringBean, manager);
+ }
+ else if (isEEResourceProducerField(field))
+ {
+ bean = EEResourceProducerField.of(field, declaringBean, manager);
+ }
+ else
+ {
+ bean = ProducerField.of(field, declaringBean, manager);
+ }
getEnvironment().addBean(bean);
}
@@ -228,6 +244,20 @@
hasSimpleWebBeanConstructor(clazz);
}
+ protected boolean isEEResourceProducerField(WBField<?, ?> field)
+ {
+ EJBApiAbstraction ejbApiAbstraction = manager.getServices().get(EJBApiAbstraction.class);
+ PersistenceApiAbstraction persistenceApiAbstraction = manager.getServices().get(PersistenceApiAbstraction.class);
+ WSApiAbstraction wsApiAbstraction = manager.getServices().get(WSApiAbstraction.class);
+ return field.isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS) || field.isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) || field.isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) || field.isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS);
+ }
+
+ protected boolean isPersistenceContextProducerField(WBField<?, ?> field)
+ {
+ PersistenceApiAbstraction persistenceApiAbstraction = manager.getServices().get(PersistenceApiAbstraction.class);
+ return field.isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS);
+ }
+
private static boolean hasSimpleWebBeanConstructor(WBClass<?> type)
{
return type.getNoArgsWBConstructor() != null || type.getAnnotatedWBConstructors(Inject.class).size() > 0;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-09-14 15:42:41 UTC (rev 3660)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-09-14 15:46:43 UTC (rev 3661)
@@ -62,6 +62,7 @@
import org.jboss.webbeans.servlet.ServletApiAbstraction;
import org.jboss.webbeans.transaction.spi.TransactionServices;
import org.jboss.webbeans.util.serviceProvider.ServiceLoader;
+import org.jboss.webbeans.ws.WSApiAbstraction;
/**
* Common bootstrapping functionality that is run at application startup and
@@ -212,6 +213,7 @@
services.add(EJBApiAbstraction.class, new EJBApiAbstraction(resourceLoader));
services.add(JsfApiAbstraction.class, new JsfApiAbstraction(resourceLoader));
services.add(PersistenceApiAbstraction.class, new PersistenceApiAbstraction(resourceLoader));
+ services.add(WSApiAbstraction.class, new WSApiAbstraction(resourceLoader));
services.add(ServletApiAbstraction.class, new ServletApiAbstraction(resourceLoader));
// Temporary workaround to provide context for building annotated class
// TODO expose AnnotatedClass on SPI and allow container to provide impl of this via ResourceLoader
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java 2009-09-14 15:46:43 UTC (rev 3661)
@@ -0,0 +1,41 @@
+/*
+ * 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.ws;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.util.ApiAbstraction;
+
+public class WSApiAbstraction extends ApiAbstraction implements Service
+{
+
+ public final Class<? extends Annotation> WEB_SERVICE_REF_ANNOTATION_CLASS;
+
+ /**
+ * @param resourceLoader
+ */
+ public WSApiAbstraction(ResourceLoader resourceLoader)
+ {
+ super(resourceLoader);
+ WEB_SERVICE_REF_ANNOTATION_CLASS = annotationTypeForName("javax.xml.ws.WebServiceRef");
+ }
+
+ public void cleanup() {}
+
+}
\ No newline at end of file
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/ws/WSApiAbstraction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java 2009-09-14 15:42:41 UTC (rev 3660)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java 2009-09-14 15:46:43 UTC (rev 3661)
@@ -78,6 +78,21 @@
@Test(groups = { "beanLifecycle", "commonAnnotations", "integration" })
@SpecAssertions( {
+ @SpecAssertion(section="7.3.6", id="nb")
+ })
+ public void testDestructionOfPersistenceContext() throws Exception
+ {
+ Bean<ManagedBean> managedBean = getBeans(ManagedBean.class).iterator().next();
+ CreationalContext<ManagedBean> creationalContext = getCurrentManager().createCreationalContext(managedBean);
+ ManagedBean instance = managedBean.create(creationalContext);
+ EntityManager em = instance.getPersistenceContext();
+ assert em.isOpen();
+ managedBean.destroy(instance, creationalContext);
+ assert !em.isOpen();
+ }
+
+ @Test(groups = { "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertions( {
@SpecAssertion(section="7.3.6", id="lc"),
@SpecAssertion(section="7.3.6", id="mf")
})
Modified: tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-09-14 15:42:41 UTC (rev 3660)
+++ tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-09-14 15:46:43 UTC (rev 3661)
@@ -3703,24 +3703,28 @@
<group>
<text>When the |destroy()| method is called, the container discards this internal reference. For certain kinds of resource, for example persistence contexts, the container eventually performs additional cleanup to destroy state associated with the client or transaction, as required by the Java EE platform specification.</text>
- <assertion id="na">
- <text>Check Java EE component environment resource</text>
+ <assertion id="na" testable="false">
+ <text>Check Java EE component environment resource</text>
+ <note>No behavior specified by platform spec</note>
</assertion>
<assertion id="nb">
<text>Check Entity Manager</text>
</assertion>
- <assertion id="nc">
- <text>Check Entity Manager Factory</text>
+ <assertion id="nc" testable="false">
+ <text>Check Entity Manager Factory</text>
+ <note>No behavior specified by platform spec</note>
</assertion>
- <assertion id="nd">
- <text>Check Remote EJB instance</text>
+ <assertion id="nd" testable="false">
+ <text>Check Remote EJB instance</text>
+ <note>No behavior specified by platform spec</note>
</assertion>
- <assertion id="ne">
- <text>Check Web Service Reference</text>
+ <assertion id="ne" testable="false">
+ <text>Check Web Service Reference</text>
+ <note>No behavior specified by platform spec</note>
</assertion>
</group>
14 years, 7 months
[webbeans-commits] Webbeans SVN: r3660 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-09-14 11:42:41 -0400 (Mon, 14 Sep 2009)
New Revision: 3660
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/Horse.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/BeanDefinitionTest.java
Log:
Fix test that was incorrect and only passing due to a specific ordering in the RI.
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/BeanDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/BeanDefinitionTest.java 2009-09-14 11:39:54 UTC (rev 3659)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/BeanDefinitionTest.java 2009-09-14 15:42:41 UTC (rev 3660)
@@ -1,6 +1,7 @@
package org.jboss.jsr299.tck.tests.definition.bean;
import java.lang.annotation.Annotation;
+import java.util.Set;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.AnnotationLiteral;
@@ -159,6 +160,8 @@
@SpecAssertion(section = "11.1", id = "bb")
public void testBeanClassOnSimpleBean()
{
- assert getBeans(Spider.class).iterator().next().getBeanClass().equals(Spider.class);
+ Set<Bean<Horse>> beans = getBeans(Horse.class);
+ assert beans.size() == 1;
+ assert beans.iterator().next().getBeanClass().equals(Horse.class);
}
}
\ No newline at end of file
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/Horse.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/Horse.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/Horse.java 2009-09-14 15:42:41 UTC (rev 3660)
@@ -0,0 +1,26 @@
+/*
+ * 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.jsr299.tck.tests.definition.bean;
+
+/**
+ * @author pmuir
+ *
+ */
+public class Horse
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/Horse.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 7 months
[webbeans-commits] Webbeans SVN: r3659 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/bean and 13 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-09-14 07:39:54 -0400 (Mon, 14 Sep 2009)
New Revision: 3659
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDecoratorResolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDisposerResolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterprise/BootstrapTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterpriseAndSimple/BootstrapTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleSimple/BootstrapTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/newsimple/NewSimpleBeanTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java
Log:
Rename classes to reflect new spec names
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -56,8 +56,8 @@
import javax.enterprise.inject.spi.ObserverMethod;
import javax.inject.Qualifier;
-import org.jboss.webbeans.bean.DecoratorBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
+import org.jboss.webbeans.bean.SessionBean;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.proxy.ClientProxyProvider;
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
@@ -185,7 +185,7 @@
private transient final Map<String, RIBean<?>> riBeans;
// TODO review this structure
- private transient final Map<EjbDescriptor<?>, EnterpriseBean<?>> enterpriseBeans;
+ private transient final Map<EjbDescriptor<?>, SessionBean<?>> enterpriseBeans;
// TODO This isn't right, specialization should follow accessibility rules, but I think we can enforce these in resolve()
private transient final Map<Contextual<?>, Contextual<?>> specializedBeans;
@@ -215,7 +215,7 @@
* archives
*/
private transient final TypeSafeBeanResolver<Bean<?>> beanResolver;
- private transient final TypeSafeResolver<DecoratorBean<?>> decoratorResolver;
+ private transient final TypeSafeResolver<DecoratorImpl<?>> decoratorResolver;
private transient final TypeSafeResolver<ObserverMethod<?,?>> observerResolver;
private transient final NameBasedResolver nameBasedResolver;
private transient final ELResolver webbeansELResolver;
@@ -231,7 +231,7 @@
* observers deployed in this bean deployment archive activity
*/
private transient final List<Bean<?>> beans;
- private transient final List<DecoratorBean<?>> decorators;
+ private transient final List<DecoratorImpl<?>> decorators;
private transient final List<String> namespaces;
private transient final List<ObserverMethod<?,?>> observers;
@@ -276,10 +276,10 @@
return new BeanManagerImpl(
serviceRegistry,
new CopyOnWriteArrayList<Bean<?>>(),
- new CopyOnWriteArrayList<DecoratorBean<?>>(),
+ new CopyOnWriteArrayList<DecoratorImpl<?>>(),
new CopyOnWriteArrayList<ObserverMethod<?,?>>(),
new CopyOnWriteArrayList<String>(),
- new ConcurrentHashMap<EjbDescriptor<?>, EnterpriseBean<?>>(),
+ new ConcurrentHashMap<EjbDescriptor<?>, SessionBean<?>>(),
new ConcurrentHashMap<String, RIBean<?>>(),
new ClientProxyProvider(),
contexts,
@@ -302,7 +302,7 @@
return new BeanManagerImpl(
services,
new CopyOnWriteArrayList<Bean<?>>(),
- new CopyOnWriteArrayList<DecoratorBean<?>>(),
+ new CopyOnWriteArrayList<DecoratorImpl<?>>(),
new CopyOnWriteArrayList<ObserverMethod<?,?>>(),
new CopyOnWriteArrayList<String>(),
rootManager.getEnterpriseBeans(),
@@ -360,10 +360,10 @@
private BeanManagerImpl(
ServiceRegistry serviceRegistry,
List<Bean<?>> beans,
- List<DecoratorBean<?>> decorators,
+ List<DecoratorImpl<?>> decorators,
List<ObserverMethod<?,?>> observers,
List<String> namespaces,
- Map<EjbDescriptor<?>, EnterpriseBean<?>> enterpriseBeans,
+ Map<EjbDescriptor<?>, SessionBean<?>> enterpriseBeans,
Map<String, RIBean<?>> riBeans,
ClientProxyProvider clientProxyProvider,
ListMultimap<Class<? extends Annotation>, Context> contexts,
@@ -473,10 +473,10 @@
};
- public static Transform<DecoratorBean<?>> DECORATOR_BEAN = new Transform<DecoratorBean<?>>()
+ public static Transform<DecoratorImpl<?>> DECORATOR_BEAN = new Transform<DecoratorImpl<?>>()
{
- public Iterable<DecoratorBean<?>> transform(BeanManagerImpl beanManager)
+ public Iterable<DecoratorImpl<?>> transform(BeanManagerImpl beanManager)
{
return beanManager.getDecorators();
}
@@ -524,9 +524,9 @@
{
return;
}
- if (bean.getClass().equals(EnterpriseBean.class))
+ if (bean.getClass().equals(SessionBean.class))
{
- EnterpriseBean<?> enterpriseBean = (EnterpriseBean<?>) bean;
+ SessionBean<?> enterpriseBean = (SessionBean<?>) bean;
enterpriseBeans.put(enterpriseBean.getEjbDescriptor(), enterpriseBean);
}
if (bean instanceof RIBean<?>)
@@ -543,7 +543,7 @@
beanResolver.clear();
}
- public void addDecorator(DecoratorBean<?> bean)
+ public void addDecorator(DecoratorImpl<?> bean)
{
decorators.add(bean);
riBeans.put(bean.getId(), bean);
@@ -748,7 +748,7 @@
*
* @return The bean map
*/
- public Map<EjbDescriptor<?>, EnterpriseBean<?>> getEnterpriseBeans()
+ public Map<EjbDescriptor<?>, SessionBean<?>> getEnterpriseBeans()
{
return enterpriseBeans;
}
@@ -764,7 +764,7 @@
return Collections.unmodifiableList(beans);
}
- public List<DecoratorBean<?>> getDecorators()
+ public List<DecoratorImpl<?>> getDecorators()
{
return Collections.unmodifiableList(decorators);
}
@@ -1356,9 +1356,9 @@
return getServices().get(EjbDescriptors.class).get(beanName);
}
- public <T> EnterpriseBean<T> getBean(EjbDescriptor<T> descriptor)
+ public <T> SessionBean<T> getBean(EjbDescriptor<T> descriptor)
{
- return (EnterpriseBean<T>) getEnterpriseBeans().get(descriptor);
+ return (SessionBean<T>) getEnterpriseBeans().get(descriptor);
}
public void cleanup()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/Validator.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -41,10 +41,10 @@
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.AbstractProducerBean;
-import org.jboss.webbeans.bean.DecoratorBean;
-import org.jboss.webbeans.bean.DisposalMethodBean;
-import org.jboss.webbeans.bean.NewEnterpriseBean;
-import org.jboss.webbeans.bean.NewSimpleBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
+import org.jboss.webbeans.bean.DisposalMethod;
+import org.jboss.webbeans.bean.NewSessionBean;
+import org.jboss.webbeans.bean.NewManagedBean;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.bootstrap.api.Service;
@@ -94,7 +94,7 @@
private void validateRIBean(RIBean<?> bean, BeanManagerImpl beanManager, Collection<RIBean<?>> specializedBeans)
{
validateBean(bean, beanManager);
- if (!(bean instanceof NewSimpleBean<?>) && !(bean instanceof NewEnterpriseBean<?>))
+ if (!(bean instanceof NewManagedBean<?>) && !(bean instanceof NewSessionBean<?>))
{
RIBean<?> abstractBean = bean;
if (abstractBean.isSpecializing())
@@ -276,7 +276,7 @@
{
// TODO Move building this list to the boot or sth
Set<Class<?>> decoratorBeanClasses = new HashSet<Class<?>>();
- for (DecoratorBean<?> bean : beanManager.getDecorators())
+ for (DecoratorImpl<?> bean : beanManager.getDecorators())
{
decoratorBeanClasses.add(bean.getType());
}
@@ -324,7 +324,7 @@
private void validateDisposalMethods(BeanDeployerEnvironment environment)
{
- Set<DisposalMethodBean<?>> beans = environment.getUnresolvedDisposalBeans();
+ Set<DisposalMethod<?>> beans = environment.getUnresolvedDisposalBeans();
if (!beans.isEmpty())
{
throw new DefinitionException("The following Disposal methods where not declared but not resolved to a producer method" + beans);
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -150,7 +150,7 @@
protected T applyDecorators(T instance, CreationalContext<T> creationalContext, InjectionPoint originalInjectionPoint)
{
- List<SerializableBeanInstance<DecoratorBean<Object>, Object>> decoratorInstances = new ArrayList<SerializableBeanInstance<DecoratorBean<Object>,Object>>();
+ List<SerializableBeanInstance<DecoratorImpl<Object>, Object>> decoratorInstances = new ArrayList<SerializableBeanInstance<DecoratorImpl<Object>,Object>>();
InjectionPoint ip = originalInjectionPoint;
boolean outside = decoratorStackPosition.get().intValue() == 0;
try
@@ -159,15 +159,15 @@
while (i < decorators.size())
{
Decorator<?> decorator = decorators.get(i);
- if (decorator instanceof DecoratorBean<?>)
+ if (decorator instanceof DecoratorImpl<?>)
{
decoratorStackPosition.set(++i);
@SuppressWarnings("unchecked")
- DecoratorBean<Object> decoratorBean = (DecoratorBean<Object>) decorator;
+ DecoratorImpl<Object> decoratorBean = (DecoratorImpl<Object>) decorator;
Object decoratorInstance = getManager().getReference(ip, decorator, creationalContext);
- decoratorInstances.add(new SerializableBeanInstance<DecoratorBean<Object>, Object>(decoratorBean, decoratorInstance));
+ decoratorInstances.add(new SerializableBeanInstance<DecoratorImpl<Object>, Object>(decoratorBean, decoratorInstance));
ip = decoratorBean.getDelegateInjectionPoint();
}
else
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -1,228 +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.bean;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.Decorator;
-import javax.inject.Inject;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.injection.MethodInjectionPoint;
-import org.jboss.webbeans.injection.WBInjectionPoint;
-import org.jboss.webbeans.introspector.WBClass;
-
-public class DecoratorBean<T> extends SimpleBean<T> implements Decorator<T>
-{
-
- public static <T> Decorator<T> wrapForResolver(final Decorator<T> decorator)
- {
- return new ForwardingDecorator<T>()
- {
-
- @Override
- public Set<Annotation> getQualifiers()
- {
- return delegate().getDelegateQualifiers();
- }
-
- @Override
- public Set<Type> getTypes()
- {
- return delegate().getTypes();
- }
-
- @Override
- protected Decorator<T> delegate()
- {
- return decorator;
- }
-
- };
- }
-
- /**
- * Creates a decorator bean
- *
- * @param <T> The type
- * @param clazz The class
- * @param manager the current manager
- * @return a Bean
- */
- public static <T> DecoratorBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
- {
- return new DecoratorBean<T>(clazz, manager);
- }
-
- private WBInjectionPoint<?, ?> delegateInjectionPoint;
- private Set<Annotation> delegateBindings;
- private Type delegateType;
- private Set<Type> delegateTypes;
- private Set<Type> decoratedTypes;
-
- protected DecoratorBean(WBClass<T> type, BeanManagerImpl manager)
- {
- super(type, manager);
- }
-
- @Override
- public void initialize(BeanDeployerEnvironment environment)
- {
- if (!isInitialized())
- {
- super.initialize(environment);
- initDelegateInjectionPoint();
- initDecoratedTypes();
- initDelegateBindings();
- initDelegateType();
- checkDelegateType();
- }
- }
-
- protected void initDecoratedTypes()
- {
- this.decoratedTypes = new HashSet<Type>();
- this.decoratedTypes.addAll(getAnnotatedItem().getInterfaceOnlyFlattenedTypeHierarchy());
- this.decoratedTypes.remove(Serializable.class);
- }
-
- protected void initDelegateInjectionPoint()
- {
- this.delegateInjectionPoint = getDelegateInjectionPoints().iterator().next();
- }
-
- @Override
- protected void checkDelegateInjectionPoints()
- {
- for (WBInjectionPoint<?, ?> injectionPoint : getDelegateInjectionPoints())
- {
- if (injectionPoint instanceof MethodInjectionPoint<?, ?> && !injectionPoint.isAnnotationPresent(Inject.class))
- {
- throw new DefinitionException("Method with @Decorates parameter must be an initializer method " + injectionPoint);
- }
- }
- if (getDelegateInjectionPoints().size() == 0)
- {
- throw new DefinitionException("No delegate injection points defined " + this);
- }
- else if (getDelegateInjectionPoints().size() > 1)
- {
- throw new DefinitionException("Too many delegate injection point defined " + this);
- }
- }
-
- protected void initDelegateBindings()
- {
- this.delegateBindings = new HashSet<Annotation>();
- this.delegateBindings.addAll(this.delegateInjectionPoint.getQualifiers());
- }
-
- protected void initDelegateType()
- {
- this.delegateType = this.delegateInjectionPoint.getBaseType();
- this.delegateTypes = new HashSet<Type>();
- delegateTypes.add(delegateType);
- }
-
- protected void checkDelegateType()
- {
- for (Type decoratedType : getDecoratedTypes())
- {
- if (decoratedType instanceof Class)
- {
- if (!((Class<?>) decoratedType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
- {
- throw new DefinitionException("The delegate type must extend or implement every decorated type. Decorated type " + decoratedType + "." + this );
- }
- }
- else if (decoratedType instanceof ParameterizedType)
- {
- ParameterizedType parameterizedType = (ParameterizedType) decoratedType;
- if (!delegateInjectionPoint.isParameterizedType())
- {
- throw new DefinitionException("The decorated type is parameterized, but the delegate type isn't. Delegate type " + delegateType + "." + this);
- }
- if (!Arrays.equals(delegateInjectionPoint.getActualTypeArguments(), parameterizedType.getActualTypeArguments()));
- Type rawType = ((ParameterizedType) decoratedType).getRawType();
- if (rawType instanceof Class && !((Class<?>) rawType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
- {
- throw new DefinitionException("The delegate type must extend or implement every decorated type. Decorated type " + decoratedType + "." + this );
- }
- else
- {
- throw new IllegalStateException("Unable to process " + decoratedType);
- }
-
- }
- }
- }
-
- public Set<Annotation> getDelegateQualifiers()
- {
- return delegateBindings;
- }
-
- public Type getDelegateType()
- {
- return delegateType;
- }
-
- public Set<Type> getDecoratedTypes()
- {
- return decoratedTypes;
- }
-
- public WBInjectionPoint<?, ?> getDelegateInjectionPoint()
- {
- return delegateInjectionPoint;
- }
-
- /**
- * The type closure of the delegate type
- *
- * @return the delegateTypes
- */
- public Set<Type> getDelegateTypes()
- {
- return delegateTypes;
- }
-
- @Override
- protected void initDecorators()
- {
- // No-op, decorators can't have decorators
- }
-
- /* (non-Javadoc)
- * @see org.jboss.webbeans.bean.SimpleBean#toString()
- */
- @Override
- public String toString()
- {
- // TODO Auto-generated method stub
- return super.toString("decorator");
- }
-
-}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java (from rev 3653, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -0,0 +1,228 @@
+/*
+ * 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.bean;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Decorator;
+import javax.inject.Inject;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.injection.WBInjectionPoint;
+import org.jboss.webbeans.introspector.WBClass;
+
+public class DecoratorImpl<T> extends ManagedBean<T> implements Decorator<T>
+{
+
+ public static <T> Decorator<T> wrapForResolver(final Decorator<T> decorator)
+ {
+ return new ForwardingDecorator<T>()
+ {
+
+ @Override
+ public Set<Annotation> getQualifiers()
+ {
+ return delegate().getDelegateQualifiers();
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+ return delegate().getTypes();
+ }
+
+ @Override
+ protected Decorator<T> delegate()
+ {
+ return decorator;
+ }
+
+ };
+ }
+
+ /**
+ * Creates a decorator bean
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param manager the current manager
+ * @return a Bean
+ */
+ public static <T> DecoratorImpl<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ {
+ return new DecoratorImpl<T>(clazz, manager);
+ }
+
+ private WBInjectionPoint<?, ?> delegateInjectionPoint;
+ private Set<Annotation> delegateBindings;
+ private Type delegateType;
+ private Set<Type> delegateTypes;
+ private Set<Type> decoratedTypes;
+
+ protected DecoratorImpl(WBClass<T> type, BeanManagerImpl manager)
+ {
+ super(type, manager);
+ }
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ super.initialize(environment);
+ initDelegateInjectionPoint();
+ initDecoratedTypes();
+ initDelegateBindings();
+ initDelegateType();
+ checkDelegateType();
+ }
+ }
+
+ protected void initDecoratedTypes()
+ {
+ this.decoratedTypes = new HashSet<Type>();
+ this.decoratedTypes.addAll(getAnnotatedItem().getInterfaceOnlyFlattenedTypeHierarchy());
+ this.decoratedTypes.remove(Serializable.class);
+ }
+
+ protected void initDelegateInjectionPoint()
+ {
+ this.delegateInjectionPoint = getDelegateInjectionPoints().iterator().next();
+ }
+
+ @Override
+ protected void checkDelegateInjectionPoints()
+ {
+ for (WBInjectionPoint<?, ?> injectionPoint : getDelegateInjectionPoints())
+ {
+ if (injectionPoint instanceof MethodInjectionPoint<?, ?> && !injectionPoint.isAnnotationPresent(Inject.class))
+ {
+ throw new DefinitionException("Method with @Decorates parameter must be an initializer method " + injectionPoint);
+ }
+ }
+ if (getDelegateInjectionPoints().size() == 0)
+ {
+ throw new DefinitionException("No delegate injection points defined " + this);
+ }
+ else if (getDelegateInjectionPoints().size() > 1)
+ {
+ throw new DefinitionException("Too many delegate injection point defined " + this);
+ }
+ }
+
+ protected void initDelegateBindings()
+ {
+ this.delegateBindings = new HashSet<Annotation>();
+ this.delegateBindings.addAll(this.delegateInjectionPoint.getQualifiers());
+ }
+
+ protected void initDelegateType()
+ {
+ this.delegateType = this.delegateInjectionPoint.getBaseType();
+ this.delegateTypes = new HashSet<Type>();
+ delegateTypes.add(delegateType);
+ }
+
+ protected void checkDelegateType()
+ {
+ for (Type decoratedType : getDecoratedTypes())
+ {
+ if (decoratedType instanceof Class)
+ {
+ if (!((Class<?>) decoratedType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
+ {
+ throw new DefinitionException("The delegate type must extend or implement every decorated type. Decorated type " + decoratedType + "." + this );
+ }
+ }
+ else if (decoratedType instanceof ParameterizedType)
+ {
+ ParameterizedType parameterizedType = (ParameterizedType) decoratedType;
+ if (!delegateInjectionPoint.isParameterizedType())
+ {
+ throw new DefinitionException("The decorated type is parameterized, but the delegate type isn't. Delegate type " + delegateType + "." + this);
+ }
+ if (!Arrays.equals(delegateInjectionPoint.getActualTypeArguments(), parameterizedType.getActualTypeArguments()));
+ Type rawType = ((ParameterizedType) decoratedType).getRawType();
+ if (rawType instanceof Class && !((Class<?>) rawType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
+ {
+ throw new DefinitionException("The delegate type must extend or implement every decorated type. Decorated type " + decoratedType + "." + this );
+ }
+ else
+ {
+ throw new IllegalStateException("Unable to process " + decoratedType);
+ }
+
+ }
+ }
+ }
+
+ public Set<Annotation> getDelegateQualifiers()
+ {
+ return delegateBindings;
+ }
+
+ public Type getDelegateType()
+ {
+ return delegateType;
+ }
+
+ public Set<Type> getDecoratedTypes()
+ {
+ return decoratedTypes;
+ }
+
+ public WBInjectionPoint<?, ?> getDelegateInjectionPoint()
+ {
+ return delegateInjectionPoint;
+ }
+
+ /**
+ * The type closure of the delegate type
+ *
+ * @return the delegateTypes
+ */
+ public Set<Type> getDelegateTypes()
+ {
+ return delegateTypes;
+ }
+
+ @Override
+ protected void initDecorators()
+ {
+ // No-op, decorators can't have decorators
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.bean.SimpleBean#toString()
+ */
+ @Override
+ public String toString()
+ {
+ // TODO Auto-generated method stub
+ return super.toString("decorator");
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java (from rev 3653, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -0,0 +1,258 @@
+/*
+ * 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.bean;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.introspector.WBMethod;
+
+public class DisposalMethod<T> extends AbstractReceiverBean<T, Method>
+{
+
+ protected MethodInjectionPoint<T, ?> disposalMethodInjectionPoint;
+ private final String id;
+
+ protected DisposalMethod(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
+ {
+ super(declaringBean, manager);
+ this.disposalMethodInjectionPoint = MethodInjectionPoint.of(this, disposalMethod);
+ this.id = createId("DisposalMethod-" + declaringBean.getName() + "-" + disposalMethod.getSignature().toString());
+ initBindings();
+ initType();
+ initTypes();
+ initStereotypes();
+ initPolicy();
+ }
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ addInjectionPoint(disposalMethodInjectionPoint);
+ super.initialize(environment);
+ checkDisposalMethod();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void initType()
+ {
+ this.type = (Class<T>) disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getJavaClass();
+ }
+
+ @Override
+ public WBMethod<T, ?> getAnnotatedItem()
+ {
+ return disposalMethodInjectionPoint;
+ }
+
+ public static <T> DisposalMethod<T> of(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
+ {
+ return new DisposalMethod<T>(manager, disposalMethod, declaringBean);
+ }
+
+ @Override
+ protected void initBindings()
+ {
+ // At least 1 parameter exists, already checked in constructor
+ this.bindings = new HashSet<Annotation>();
+ this.bindings.addAll(disposalMethodInjectionPoint.getWBParameters().get(0).getQualifiers());
+ initDefaultBindings();
+ }
+
+ /**
+ * Initializes the API types
+ */
+ @Override
+ protected void initTypes()
+ {
+ Set<Type> types = new HashSet<Type>();
+ types = new HashSet<Type>();
+ types.addAll(disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getTypeClosure());
+ types.add(Object.class);
+ super.types = types;
+ }
+
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ @Override
+ public Class<? extends Annotation> getScope()
+ {
+ return null;
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+ return types;
+ }
+
+ @Override
+ public String toString()
+ {
+ return disposalMethodInjectionPoint.toString();
+ }
+
+ @Override
+ public boolean isNullable()
+ {
+ // Not relevant
+ return false;
+ }
+
+ @Override
+ public boolean isSerializable()
+ {
+ // Not relevant
+ return false;
+ }
+
+ @Override
+ public boolean isProxyable()
+ {
+ return true;
+ }
+
+ public T create(CreationalContext<T> creationalContext)
+ {
+ // Not Relevant
+ return null;
+ }
+
+ public void invokeDisposeMethod(Object instance)
+ {
+ CreationalContext<T> creationalContext = manager.createCreationalContext(this);
+ Object receiverInstance = getReceiver(creationalContext);
+ if (receiverInstance == null)
+ {
+ disposalMethodInjectionPoint.invokeWithSpecialValue(null, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
+ }
+ else
+ {
+ disposalMethodInjectionPoint.invokeOnInstanceWithSpecialValue(receiverInstance, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
+ }
+ creationalContext.release();
+ }
+
+ private void checkDisposalMethod()
+ {
+ if (!disposalMethodInjectionPoint.getWBParameters().get(0).isAnnotationPresent(Disposes.class))
+ {
+ throw new DefinitionException(disposalMethodInjectionPoint.toString() + " doesn't have @Dispose as first parameter");
+ }
+ if (disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).size() > 1)
+ {
+ throw new DefinitionException(disposalMethodInjectionPoint.toString() + " has more than one @Dispose parameters");
+ }
+ if (disposalMethodInjectionPoint.getAnnotatedParameters(Observes.class).size() > 0)
+ {
+ throw new DefinitionException("@Observes is not allowed on disposal method, see " + disposalMethodInjectionPoint.toString());
+ }
+ if (disposalMethodInjectionPoint.getAnnotation(Inject.class) != null)
+ {
+ throw new DefinitionException("@Intitializer is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
+ }
+ if (disposalMethodInjectionPoint.getAnnotation(Produces.class) != null)
+ {
+ throw new DefinitionException("@Produces is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
+ }
+ if (getDeclaringBean() instanceof SessionBean<?>)
+ {
+ boolean methodDeclaredOnTypes = false;
+ // TODO use annotated item?
+ for (Type type : getDeclaringBean().getTypes())
+ {
+ if (type instanceof Class<?>)
+ {
+ Class<?> clazz = (Class<?>) type;
+ try
+ {
+ clazz.getDeclaredMethod(disposalMethodInjectionPoint.getName(), disposalMethodInjectionPoint.getParameterTypesAsArray());
+ methodDeclaredOnTypes = true;
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ // No - op
+ }
+ }
+ }
+ if (!methodDeclaredOnTypes)
+ {
+ throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
+ }
+ }
+ }
+
+ @Override
+ public Class<T> getType()
+ {
+ return type;
+ }
+
+ @Override
+ protected String getDefaultName()
+ {
+ return disposalMethodInjectionPoint.getPropertyName();
+ }
+
+ public void destroy(T instance, CreationalContext<T> creationalContext)
+ {
+ // No-op. Producer method dependent objects are destroyed in producer method bean
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ // Doesn't support specialization
+ return null;
+ }
+
+ @Override
+ protected void initScopeType()
+ {
+ // Disposal methods aren't scoped
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -1,258 +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.bean;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Disposes;
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.injection.MethodInjectionPoint;
-import org.jboss.webbeans.introspector.WBMethod;
-
-public class DisposalMethodBean<T> extends AbstractReceiverBean<T, Method>
-{
-
- protected MethodInjectionPoint<T, ?> disposalMethodInjectionPoint;
- private final String id;
-
- protected DisposalMethodBean(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
- {
- super(declaringBean, manager);
- this.disposalMethodInjectionPoint = MethodInjectionPoint.of(this, disposalMethod);
- this.id = createId("DisposalMethod-" + declaringBean.getName() + "-" + disposalMethod.getSignature().toString());
- initBindings();
- initType();
- initTypes();
- initStereotypes();
- initPolicy();
- }
-
- @Override
- public void initialize(BeanDeployerEnvironment environment)
- {
- addInjectionPoint(disposalMethodInjectionPoint);
- super.initialize(environment);
- checkDisposalMethod();
- }
-
- @SuppressWarnings("unchecked")
- protected void initType()
- {
- this.type = (Class<T>) disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getJavaClass();
- }
-
- @Override
- public WBMethod<T, ?> getAnnotatedItem()
- {
- return disposalMethodInjectionPoint;
- }
-
- public static <T> DisposalMethodBean<T> of(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
- {
- return new DisposalMethodBean<T>(manager, disposalMethod, declaringBean);
- }
-
- @Override
- protected void initBindings()
- {
- // At least 1 parameter exists, already checked in constructor
- this.bindings = new HashSet<Annotation>();
- this.bindings.addAll(disposalMethodInjectionPoint.getWBParameters().get(0).getQualifiers());
- initDefaultBindings();
- }
-
- /**
- * Initializes the API types
- */
- @Override
- protected void initTypes()
- {
- Set<Type> types = new HashSet<Type>();
- types = new HashSet<Type>();
- types.addAll(disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getTypeClosure());
- types.add(Object.class);
- super.types = types;
- }
-
- @Override
- public String getName()
- {
- return null;
- }
-
- @Override
- public Class<? extends Annotation> getScope()
- {
- return null;
- }
-
- @Override
- public Set<Type> getTypes()
- {
- return types;
- }
-
- @Override
- public String toString()
- {
- return disposalMethodInjectionPoint.toString();
- }
-
- @Override
- public boolean isNullable()
- {
- // Not relevant
- return false;
- }
-
- @Override
- public boolean isSerializable()
- {
- // Not relevant
- return false;
- }
-
- @Override
- public boolean isProxyable()
- {
- return true;
- }
-
- public T create(CreationalContext<T> creationalContext)
- {
- // Not Relevant
- return null;
- }
-
- public void invokeDisposeMethod(Object instance)
- {
- CreationalContext<T> creationalContext = manager.createCreationalContext(this);
- Object receiverInstance = getReceiver(creationalContext);
- if (receiverInstance == null)
- {
- disposalMethodInjectionPoint.invokeWithSpecialValue(null, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
- }
- else
- {
- disposalMethodInjectionPoint.invokeOnInstanceWithSpecialValue(receiverInstance, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
- }
- creationalContext.release();
- }
-
- private void checkDisposalMethod()
- {
- if (!disposalMethodInjectionPoint.getWBParameters().get(0).isAnnotationPresent(Disposes.class))
- {
- throw new DefinitionException(disposalMethodInjectionPoint.toString() + " doesn't have @Dispose as first parameter");
- }
- if (disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).size() > 1)
- {
- throw new DefinitionException(disposalMethodInjectionPoint.toString() + " has more than one @Dispose parameters");
- }
- if (disposalMethodInjectionPoint.getAnnotatedParameters(Observes.class).size() > 0)
- {
- throw new DefinitionException("@Observes is not allowed on disposal method, see " + disposalMethodInjectionPoint.toString());
- }
- if (disposalMethodInjectionPoint.getAnnotation(Inject.class) != null)
- {
- throw new DefinitionException("@Intitializer is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
- }
- if (disposalMethodInjectionPoint.getAnnotation(Produces.class) != null)
- {
- throw new DefinitionException("@Produces is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
- }
- if (getDeclaringBean() instanceof EnterpriseBean<?>)
- {
- boolean methodDeclaredOnTypes = false;
- // TODO use annotated item?
- for (Type type : getDeclaringBean().getTypes())
- {
- if (type instanceof Class<?>)
- {
- Class<?> clazz = (Class<?>) type;
- try
- {
- clazz.getDeclaredMethod(disposalMethodInjectionPoint.getName(), disposalMethodInjectionPoint.getParameterTypesAsArray());
- methodDeclaredOnTypes = true;
- }
- catch (NoSuchMethodException nsme)
- {
- // No - op
- }
- }
- }
- if (!methodDeclaredOnTypes)
- {
- throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
- }
- }
- }
-
- @Override
- public Class<T> getType()
- {
- return type;
- }
-
- @Override
- protected String getDefaultName()
- {
- return disposalMethodInjectionPoint.getPropertyName();
- }
-
- public void destroy(T instance, CreationalContext<T> creationalContext)
- {
- // No-op. Producer method dependent objects are destroyed in producer method bean
- }
-
- @Override
- public String getId()
- {
- return id;
- }
-
- @Override
- public AbstractBean<?, ?> getSpecializedBean()
- {
- // Doesn't support specialization
- return null;
- }
-
- @Override
- protected void initScopeType()
- {
- // Disposal methods aren't scoped
- }
-
- public Set<Class<? extends Annotation>> getStereotypes()
- {
- return Collections.emptySet();
- }
-
-}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -1,402 +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.bean;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import javassist.util.proxy.ProxyFactory;
-import javassist.util.proxy.ProxyObject;
-
-import javax.decorator.Decorator;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.CreationException;
-import javax.interceptor.Interceptor;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
-import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
-import org.jboss.webbeans.bean.proxy.Marker;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.ejb.InternalEjbDescriptor;
-import org.jboss.webbeans.ejb.api.SessionObjectReference;
-import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
-import org.jboss.webbeans.ejb.spi.EjbServices;
-import org.jboss.webbeans.injection.InjectionContextImpl;
-import org.jboss.webbeans.introspector.WBClass;
-import org.jboss.webbeans.introspector.WBMethod;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.resources.ClassTransformer;
-import org.jboss.webbeans.util.Beans;
-import org.jboss.webbeans.util.Proxies;
-
-/**
- * An enterprise bean representation
- *
- * @author Pete Muir
- *
- * @param <T> The type (class) of the bean
- */
-public class EnterpriseBean<T> extends AbstractClassBean<T>
-{
- private final Log log = Logging.getLog(EnterpriseBean.class);
-
- // The EJB descriptor
- private InternalEjbDescriptor<T> ejbDescriptor;
-
- private Class<T> proxyClass;
-
- private EnterpriseBean<?> specializedBean;
-
- /**
- * Creates a simple, annotation defined Enterprise Web Bean
- *
- * @param <T> The type
- * @param clazz The class
- * @param manager the current manager
- * @return An Enterprise Web Bean
- */
- public static <T> EnterpriseBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
- {
- WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
- return new EnterpriseBean<T>(type, ejbDescriptor, manager);
- }
-
- /**
- * Constructor
- *
- * @param type The type of the bean
- * @param manager The Web Beans manager
- */
- protected EnterpriseBean(WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
- {
- super(type, manager);
- initType();
- this.ejbDescriptor = ejbDescriptor;
- initTypes();
- initBindings();
- }
-
- /**
- * Initializes the bean and its metadata
- */
- @Override
- public void initialize(BeanDeployerEnvironment environment)
- {
- if (!isInitialized())
- {
- super.initialize(environment);
- initProxyClass();
- checkEJBTypeAllowed();
- checkConflictingRoles();
- checkObserverMethods();
- checkScopeAllowed();
- }
- }
-
- @Override
- protected void initTypes()
- {
- Set<Type> types = new HashSet<Type>();
- types = new LinkedHashSet<Type>();
- types.add(Object.class);
- for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces())
- {
- types.add(businessInterfaceDescriptor.getInterface());
- }
- super.types = types;
- }
-
- protected void initProxyClass()
- {
- Set<Type> types = new LinkedHashSet<Type>(getTypes());
- types.add(EnterpriseBeanInstance.class);
- types.add(Serializable.class);
- ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
-
- @SuppressWarnings("unchecked")
- Class<T> proxyClass = proxyFactory.createClass();
-
- this.proxyClass = proxyClass;
- }
-
- /**
- * Validates for non-conflicting roles
- */
- protected void checkConflictingRoles()
- {
- if (getType().isAnnotationPresent(Interceptor.class))
- {
- throw new DefinitionException("Enterprise beans cannot be interceptors");
- }
- if (getType().isAnnotationPresent(Decorator.class))
- {
- throw new DefinitionException("Enterprise beans cannot be decorators");
- }
- }
-
- /**
- * Check that the scope type is allowed by the stereotypes on the bean and
- * the bean type
- */
- protected void checkScopeAllowed()
- {
- if (ejbDescriptor.isStateless() && !isDependent())
- {
- throw new DefinitionException("Scope " + getScope() + " is not allowed on stateless enterpise beans for " + getType() + ". Only @Dependent is allowed on stateless enterprise beans");
- }
- if (ejbDescriptor.isSingleton() && !(isDependent() || getScope().equals(ApplicationScoped.class)))
- {
- throw new DefinitionException("Scope " + getScope() + " is not allowed on singleton enterpise beans for " + getType() + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise beans");
- }
- }
-
- /**
- * Validates specialization
- */
- @Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
- {
- super.preSpecialize(environment);
- // We appear to check this twice?
- if (!environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
- {
- throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
- }
- }
-
- @Override
- protected void specialize(BeanDeployerEnvironment environment)
- {
- if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
- {
- throw new IllegalStateException(toString() + " does not specialize a bean");
- }
- AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
- if (!(specializedBean instanceof EnterpriseBean<?>))
- {
- throw new IllegalStateException(toString() + " doesn't have a session bean as a superclass " + specializedBean);
- }
- else
- {
- this.specializedBean = (EnterpriseBean<?>) specializedBean;
- }
- }
-
- /**
- * Creates an instance of the bean
- *
- * @return The instance
- */
- public T create(final CreationalContext<T> creationalContext)
- {
- T instance = produce(creationalContext);
- if (hasDecorators())
- {
- instance = applyDecorators(instance, creationalContext, null);
- }
- return instance;
- }
-
- public void inject(final T instance, final CreationalContext<T> ctx)
- {
- new InjectionContextImpl<T>(getManager(), this, instance)
- {
-
- public void proceed()
- {
- Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
- Beans.callInitializers(instance, ctx, getManager(), getInitializerMethods());
- }
-
- }.run();
-
- }
-
- public T produce(CreationalContext<T> ctx)
- {
- try
- {
- T instance = proxyClass.newInstance();
- ctx.push(instance);
- ((ProxyObject) instance).setHandler(new EnterpriseBeanProxyMethodHandler<T>(this, ctx));
- log.trace("Enterprise bean instance created for bean {0}", this);
- return instance;
- }
- catch (InstantiationException e)
- {
- throw new RuntimeException("Could not instantiate enterprise proxy for " + toString(), e);
- }
- catch (IllegalAccessException e)
- {
- throw new RuntimeException("Could not access bean correctly when creating enterprise proxy for " + toString(), e);
- }
- catch (Exception e)
- {
- throw new CreationException("could not find the EJB in JNDI " + proxyClass, e);
- }
- }
-
- public void destroy(T instance, CreationalContext<T> creationalContext)
- {
- if (instance == null)
- {
- throw new IllegalArgumentException("instance to destroy cannot be null");
- }
- if (!(instance instanceof EnterpriseBeanInstance))
- {
- throw new IllegalArgumentException("Cannot destroy session bean instance not created by the container");
- }
- EnterpriseBeanInstance enterpiseBeanInstance = (EnterpriseBeanInstance) instance;
- enterpiseBeanInstance.destroy(Marker.INSTANCE, this, creationalContext);
- creationalContext.release();
- }
-
- /**
- * Validates the bean type
- */
- private void checkEJBTypeAllowed()
- {
- if (ejbDescriptor.isMessageDriven())
- {
- throw new DefinitionException("Message Driven Beans can't be Web Beans");
- }
- }
-
- /**
- * Gets a string representation
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder();
- // buffer.append("Annotated " + Names.scopeTypeToString(getScopeType()) +
- // Names.ejbTypeFromMetaData(getEjbMetaData()));
- if (getName() == null)
- {
- buffer.append(" unnamed enterprise bean");
- }
- else
- {
- buffer.append(" enterprise bean '" + getName() + "'");
- }
- buffer.append(" [" + getType().getName() + "] ");
- buffer.append("API types " + getTypes() + ", binding types " + getQualifiers());
- return buffer.toString();
- }
-
- public void postConstruct(T instance, CreationalContext<T> creationalContext)
- {
- Beans.injectBoundFields(instance, creationalContext, getManager(), getInjectableFields());
- Beans.callInitializers(instance, creationalContext, getManager(), getInitializerMethods());
- }
-
- public void preDestroy(CreationalContext<T> creationalContext)
- {
- creationalContext.release();
- }
-
- @Override
- protected void initSerializable()
- {
- // No-op
- }
-
- @Override
- public boolean isSerializable()
- {
- return true;
- }
-
- public InternalEjbDescriptor<T> getEjbDescriptor()
- {
- return ejbDescriptor;
- }
-
- public boolean isClientCanCallRemoveMethods()
- {
- return getEjbDescriptor().isStateful() && isDependent();
- }
-
- @Override
- public AbstractBean<?, ?> getSpecializedBean()
- {
- return specializedBean;
- }
-
- /**
- * If there are any observer methods, they must be static or business
- * methods.
- */
- protected void checkObserverMethods()
- {
- for (WBMethod<?, ?> method : this.annotatedItem.getWBDeclaredMethodsWithAnnotatedParameters(Observes.class))
- {
- if (!method.isStatic())
- {
- if (!isMethodExistsOnTypes(method))
- {
- throw new DefinitionException("Observer method must be static or business method: " + method + " on " + getAnnotatedItem());
- }
- }
- }
- }
-
- // TODO must be a nicer way to do this!
- public boolean isMethodExistsOnTypes(WBMethod<?, ?> method)
- {
- for (Type type : getTypes())
- {
- if (type instanceof Class)
- {
- for (Method m : ((Class<?>) type).getMethods())
- {
- if (method.getName().equals(m.getName()) && Arrays.equals(method.getParameterTypesAsArray(), m.getParameterTypes()))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- public SessionObjectReference createReference()
- {
- return manager.getServices().get(EjbServices.class).resolveEjb(getEjbDescriptor().delegate());
- }
-
- public Set<Class<? extends Annotation>> getStereotypes()
- {
- return Collections.emptySet();
- }
-
-}
-
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java (from rev 3653, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -0,0 +1,359 @@
+/*
+ * 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.bean;
+
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.ConstructorInjectionPoint;
+import org.jboss.webbeans.injection.InjectionContextImpl;
+import org.jboss.webbeans.injection.WBInjectionPoint;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBConstructor;
+import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ * Represents a simple bean
+ *
+ * @author Pete Muir
+ *
+ * @param <T> The type (class) of the bean
+ */
+public class ManagedBean<T> extends AbstractClassBean<T>
+{
+ // Logger
+ private static LogProvider log = Logging.getLogProvider(ManagedBean.class);
+
+ // The constructor
+ private ConstructorInjectionPoint<T> constructor;
+ private Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
+ private Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
+ private Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
+ private Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
+
+ private ManagedBean<?> specializedBean;
+
+
+
+ /**
+ * Creates a simple, annotation defined Web Bean
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param manager the current manager
+ * @return A Web Bean
+ */
+ public static <T> ManagedBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ {
+ return new ManagedBean<T>(clazz, manager);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param type The type of the bean
+ * @param manager The Web Beans manager
+ */
+ protected ManagedBean(WBClass<T> type, BeanManagerImpl manager)
+ {
+ super(type, manager);
+ initType();
+ initTypes();
+ initBindings();
+ }
+
+ /**
+ * Creates an instance of the bean
+ *
+ * @return The instance
+ */
+ public T create(CreationalContext<T> creationalContext)
+ {
+ InjectionPoint originalInjectionPoint = null;
+ if (hasDecorators())
+ {
+ originalInjectionPoint = attachCorrectInjectionPoint();
+ }
+ T instance = produce(creationalContext);
+ inject(instance, creationalContext);
+ postConstruct(instance);
+ if (hasDecorators())
+ {
+ instance = applyDecorators(instance, creationalContext, originalInjectionPoint);
+ }
+ return instance;
+ }
+
+ public T produce(CreationalContext<T> ctx)
+ {
+ T instance = constructor.newInstance(manager, ctx);
+ if (!hasDecorators())
+ {
+ // This should be safe, but needs verification PLM
+ // Without this, the chaining of decorators will fail as the incomplete instance will be resolved
+ ctx.push(instance);
+ }
+ return instance;
+ }
+
+ public void inject(final T instance, final CreationalContext<T> ctx)
+ {
+ new InjectionContextImpl<T>(getManager(), this, instance)
+ {
+
+ public void proceed()
+ {
+ Beans.injectEEFields(instance, getManager(), ejbInjectionPoints, persistenceContextInjectionPoints, persistenceUnitInjectionPoints, resourceInjectionPoints);
+ Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
+ Beans.callInitializers(instance, ctx, getManager(), getInitializerMethods());
+ }
+
+ }.run();
+
+ }
+
+ protected InjectionPoint attachCorrectInjectionPoint()
+ {
+ Decorator<?> decorator = getDecorators().get(getDecorators().size() - 1);
+ if (decorator instanceof DecoratorImpl<?>)
+ {
+ DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator;
+ InjectionPoint outerDelegateInjectionPoint = decoratorBean.getDelegateInjectionPoint();
+ return getManager().replaceOrPushCurrentInjectionPoint(outerDelegateInjectionPoint);
+ }
+ else
+ {
+ throw new IllegalStateException("Cannot operate on user defined decorator");
+ }
+ }
+
+ /**
+ * Destroys an instance of the bean
+ *
+ * @param instance The instance
+ */
+ public void destroy(T instance, CreationalContext<T> creationalContext)
+ {
+ try
+ {
+ preDestroy(instance);
+ creationalContext.release();
+ }
+ catch (Exception e)
+ {
+ log.error("Error destroying " + toString(), e);
+ }
+ }
+
+ /**
+ * Initializes the bean and its metadata
+ */
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ initConstructor();
+ checkConstructor();
+ super.initialize(environment);
+ initPostConstruct();
+ initPreDestroy();
+ initEEInjectionPoints();
+ }
+ }
+
+ private void initEEInjectionPoints()
+ {
+ this.ejbInjectionPoints = Beans.getEjbInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.resourceInjectionPoints = Beans.getResourceInjectionPoints(this, getAnnotatedItem(), manager);
+ }
+
+ /**
+ * Validates the type
+ */
+ protected void checkType()
+ {
+ if (getAnnotatedItem().isNonStaticMemberClass())
+ {
+ 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()))
+ {
+ throw new DefinitionException("Simple bean declaring a passivating scope must have a serializable implementation class " + toString());
+ }
+ if (hasDecorators())
+ {
+ if (getAnnotatedItem().isFinal())
+ {
+ throw new DefinitionException("Bean class which has decorators cannot be declared final " + this);
+ }
+ for (Decorator<?> decorator : getDecorators())
+ {
+ if (decorator instanceof DecoratorImpl<?>)
+ {
+ DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator;
+ for (WBMethod<?, ?> decoratorMethod : decoratorBean.getAnnotatedItem().getWBMethods())
+ {
+ WBMethod<?, ?> method = getAnnotatedItem().getWBMethod(decoratorMethod.getSignature());
+ if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal())
+ {
+ throw new DefinitionException("Decorated bean method " + method + " (decorated by "+ decoratorMethod + ") cannot be declarted final");
+ }
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Can only operate on container provided decorators " + decorator);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void checkBeanImplementation()
+ {
+ super.checkBeanImplementation();
+ if (!isDependent())
+ {
+ for (WBField<?, ?> field : getAnnotatedItem().getWBFields())
+ {
+ if (field.isPublic() && !field.isStatic())
+ {
+ throw new DefinitionException("Normal scoped Web Bean implementation class has a public field " + getAnnotatedItem());
+ }
+ }
+ }
+ }
+
+ protected void checkConstructor()
+ {
+ if (!constructor.getAnnotatedWBParameters(Disposes.class).isEmpty())
+ {
+ throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Disposes " + constructor);
+ }
+ if (!constructor.getAnnotatedWBParameters(Observes.class).isEmpty())
+ {
+ throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Observes " + constructor);
+ }
+ }
+
+ @Override
+ protected void preSpecialize(BeanDeployerEnvironment environment)
+ {
+ super.preSpecialize(environment);
+ if (environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
+ {
+ throw new DefinitionException("Simple bean must specialize a simple bean");
+ }
+ }
+
+ @Override
+ protected void specialize(BeanDeployerEnvironment environment)
+ {
+ if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
+ {
+ throw new DefinitionException(toString() + " does not specialize a bean");
+ }
+ AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
+ if (!(specializedBean instanceof ManagedBean))
+ {
+ throw new DefinitionException(toString() + " doesn't have a simple bean as a superclass " + specializedBean);
+ }
+ else
+ {
+ this.specializedBean = (ManagedBean<?>) specializedBean;
+ }
+ }
+
+
+ /**
+ * Initializes the constructor
+ */
+ protected void initConstructor()
+ {
+ this.constructor = Beans.getBeanConstructor(this, getAnnotatedItem());
+ // TODO We loop unecessarily many times here, I want to probably introduce some callback mechanism. PLM.
+ addInjectionPoints(Beans.getParameterInjectionPoints(this, constructor));
+ }
+
+ /**
+ * Returns the constructor
+ *
+ * @return The constructor
+ */
+ public WBConstructor<T> getConstructor()
+ {
+ return constructor;
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ return toString("simple bean");
+ }
+
+ protected String toString(String beanType)
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(Names.scopeTypeToString(getScope()));
+ if (getName() == null)
+ {
+ buffer.append("unnamed ").append(beanType);
+ }
+ else
+ {
+ buffer.append(beanType).append(" '" + getName() + "'");
+ }
+ buffer.append(" ").append(getType().getName()).append(", ");
+ buffer.append(" API types = ").append(Names.typesToString(getTypes())).append(", binding types = " + Names.annotationsToString(getQualifiers()));
+ return buffer.toString();
+ }
+
+ @Override
+ public ManagedBean<?> getSpecializedBean()
+ {
+ return specializedBean;
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -1,126 +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.bean;
-
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.context.Dependent;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.ejb.InternalEjbDescriptor;
-import org.jboss.webbeans.introspector.WBClass;
-import org.jboss.webbeans.literal.NewLiteral;
-import org.jboss.webbeans.resources.ClassTransformer;
-
-/**
- * Represents a @New enterprise bean
- *
- * @author Nicklas Karlsson
- */
-public class NewEnterpriseBean<T> extends EnterpriseBean<T> implements NewBean
-{
-
- /**
- * Creates an instance of a NewEnterpriseBean from an annotated class
- *
- * @param clazz The annotated class
- * @param manager The Web Beans manager
- * @return a new NewEnterpriseBean instance
- */
- public static <T> NewEnterpriseBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
- {
- WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
- return new NewEnterpriseBean<T>(type, ejbDescriptor, manager);
- }
-
- private Set<Annotation> bindings;
-
- /**
- * Protected constructor
- *
- * @param type An annotated class
- * @param manager The Web Beans manager
- */
- protected NewEnterpriseBean(final WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
- {
- super(type, ejbDescriptor, manager);
- this.bindings = new HashSet<Annotation>();
- this.bindings.add(new NewLiteral()
- {
-
- public Class<?> value()
- {
- return type.getJavaClass();
- }
-
- });
- }
-
- /**
- * Gets the scope type
- *
- * @return @Dependent
- */
- @Override
- public Class<? extends Annotation> getScope()
- {
- return Dependent.class;
- }
-
- @Override
- public boolean isAlternative()
- {
- return false;
- }
-
- /**
- * Gets the name of the bean
- *
- * @return null
- */
- @Override
- public String getName()
- {
- return null;
- }
-
- /**
- * Gets the bindings
- *
- * @returns @New
- */
- @Override
- public Set<Annotation> getQualifiers()
- {
- return bindings;
- }
-
- @Override
- public boolean isSpecializing()
- {
- return false;
- }
-
- @Override
- protected void checkScopeAllowed()
- {
- // No-op
- }
-
-}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java (from rev 3653, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -0,0 +1,117 @@
+/*
+ * 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.bean;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.literal.NewLiteral;
+
+/**
+ * Represents a @New simple bean
+ *
+ * @author Nicklas Karlsson
+ */
+public class NewManagedBean<T> extends ManagedBean<T> implements NewBean
+{
+
+ /**
+ * Creates an instance of a NewSimpleBean from an annotated class
+ *
+ * @param clazz The annotated class
+ * @param manager The Web Beans manager
+ * @return a new NewSimpleBean instance
+ */
+ public static <T> NewManagedBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ {
+ return new NewManagedBean<T>(clazz, manager);
+ }
+
+ private Set<Annotation> bindings;
+
+ /**
+ * Protected constructor
+ *
+ * @param type An annotated class
+ * @param manager The Web Beans manager
+ */
+ protected NewManagedBean(final WBClass<T> type, BeanManagerImpl manager)
+ {
+ super(type, manager);
+ this.bindings = new HashSet<Annotation>();
+ this.bindings.add(new NewLiteral()
+ {
+
+ public Class<?> value()
+ {
+ return type.getJavaClass();
+ }
+
+ });
+ }
+
+ /**
+ * Gets the scope type
+ *
+ * @return @Dependent
+ */
+ @Override
+ public Class<? extends Annotation> getScope()
+ {
+ return Dependent.class;
+ }
+
+ @Override
+ public boolean isAlternative()
+ {
+ return false;
+ }
+
+ /**
+ * Gets the name of the bean
+ *
+ * @return null
+ */
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ /**
+ * Gets the bindings
+ *
+ * @returns @New
+ */
+ @Override
+ public Set<Annotation> getQualifiers()
+ {
+ return bindings;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return false;
+ }
+
+}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java (from rev 3653, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -0,0 +1,126 @@
+/*
+ * 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.bean;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.ejb.InternalEjbDescriptor;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.literal.NewLiteral;
+import org.jboss.webbeans.resources.ClassTransformer;
+
+/**
+ * Represents a @New enterprise bean
+ *
+ * @author Nicklas Karlsson
+ */
+public class NewSessionBean<T> extends SessionBean<T> implements NewBean
+{
+
+ /**
+ * Creates an instance of a NewEnterpriseBean from an annotated class
+ *
+ * @param clazz The annotated class
+ * @param manager The Web Beans manager
+ * @return a new NewEnterpriseBean instance
+ */
+ public static <T> NewSessionBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ {
+ WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
+ return new NewSessionBean<T>(type, ejbDescriptor, manager);
+ }
+
+ private Set<Annotation> bindings;
+
+ /**
+ * Protected constructor
+ *
+ * @param type An annotated class
+ * @param manager The Web Beans manager
+ */
+ protected NewSessionBean(final WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ {
+ super(type, ejbDescriptor, manager);
+ this.bindings = new HashSet<Annotation>();
+ this.bindings.add(new NewLiteral()
+ {
+
+ public Class<?> value()
+ {
+ return type.getJavaClass();
+ }
+
+ });
+ }
+
+ /**
+ * Gets the scope type
+ *
+ * @return @Dependent
+ */
+ @Override
+ public Class<? extends Annotation> getScope()
+ {
+ return Dependent.class;
+ }
+
+ @Override
+ public boolean isAlternative()
+ {
+ return false;
+ }
+
+ /**
+ * Gets the name of the bean
+ *
+ * @return null
+ */
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ /**
+ * Gets the bindings
+ *
+ * @returns @New
+ */
+ @Override
+ public Set<Annotation> getQualifiers()
+ {
+ return bindings;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return false;
+ }
+
+ @Override
+ protected void checkScopeAllowed()
+ {
+ // No-op
+ }
+
+}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -1,117 +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.bean;
-
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.context.Dependent;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.introspector.WBClass;
-import org.jboss.webbeans.literal.NewLiteral;
-
-/**
- * Represents a @New simple bean
- *
- * @author Nicklas Karlsson
- */
-public class NewSimpleBean<T> extends SimpleBean<T> implements NewBean
-{
-
- /**
- * Creates an instance of a NewSimpleBean from an annotated class
- *
- * @param clazz The annotated class
- * @param manager The Web Beans manager
- * @return a new NewSimpleBean instance
- */
- public static <T> NewSimpleBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
- {
- return new NewSimpleBean<T>(clazz, manager);
- }
-
- private Set<Annotation> bindings;
-
- /**
- * Protected constructor
- *
- * @param type An annotated class
- * @param manager The Web Beans manager
- */
- protected NewSimpleBean(final WBClass<T> type, BeanManagerImpl manager)
- {
- super(type, manager);
- this.bindings = new HashSet<Annotation>();
- this.bindings.add(new NewLiteral()
- {
-
- public Class<?> value()
- {
- return type.getJavaClass();
- }
-
- });
- }
-
- /**
- * Gets the scope type
- *
- * @return @Dependent
- */
- @Override
- public Class<? extends Annotation> getScope()
- {
- return Dependent.class;
- }
-
- @Override
- public boolean isAlternative()
- {
- return false;
- }
-
- /**
- * Gets the name of the bean
- *
- * @return null
- */
- @Override
- public String getName()
- {
- return null;
- }
-
- /**
- * Gets the bindings
- *
- * @returns @New
- */
- @Override
- public Set<Annotation> getQualifiers()
- {
- return bindings;
- }
-
- @Override
- public boolean isSpecializing()
- {
- return false;
- }
-
-}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java (from rev 3653, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -0,0 +1,168 @@
+/*
+ * 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.bean;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.util.Names;
+
+/**
+ * Represents a producer field bean
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
+public class ProducerField<T> extends AbstractProducerBean<T, Field>
+{
+ // The underlying field
+ private WBField<T, ?> field;
+ private final String id;
+
+ /**
+ * Creates a producer field Web Bean
+ *
+ * @param field The underlying method abstraction
+ * @param declaringBean The declaring bean abstraction
+ * @param manager the current manager
+ * @return A producer Web Bean
+ */
+ public static <T> ProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ return new ProducerField<T>(field, declaringBean, manager);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param method The producer field abstraction
+ * @param declaringBean The declaring bean
+ * @param manager The Web Beans manager
+ */
+ protected ProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ super(declaringBean, manager);
+ this.field = field;
+ initType();
+ initTypes();
+ initBindings();
+ this.id = createId("ProducerField-" + declaringBean.getType().getName() + "-"+ field.getName());
+ initStereotypes();
+ initPolicy();
+ }
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ super.initialize(environment);
+ }
+ }
+
+ public void destroy(T instance, CreationalContext<T> creationalContext)
+ {
+ dispose(instance);
+ }
+
+ public void dispose(T instance)
+ {
+ // No clean up required
+ }
+
+ public T produce(CreationalContext<T> ctx)
+ {
+ return field.get(getReceiver(ctx));
+ }
+
+
+ /**
+ * Gets the annotated item representing the field
+ *
+ * @return The annotated item
+ */
+ @Override
+ protected WBField<T, ?> getAnnotatedItem()
+ {
+ return field;
+ }
+
+ /**
+ * Returns the default name
+ *
+ * @return The default name
+ */
+ @Override
+ protected String getDefaultName()
+ {
+ return field.getPropertyName();
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Annotated " + Names.scopeTypeToString(getScope()));
+ if (getName() == null)
+ {
+ buffer.append("unnamed producer field bean");
+ }
+ else
+ {
+ buffer.append("simple producer field bean '" + getName() + "'");
+ }
+ buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
+ return buffer.toString();
+ }
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return false;
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -1,168 +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.bean;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.util.Collections;
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.introspector.WBField;
-import org.jboss.webbeans.util.Names;
-
-/**
- * Represents a producer field bean
- *
- * @author Pete Muir
- *
- * @param <T>
- */
-public class ProducerFieldBean<T> extends AbstractProducerBean<T, Field>
-{
- // The underlying field
- private WBField<T, ?> field;
- private final String id;
-
- /**
- * Creates a producer field Web Bean
- *
- * @param field The underlying method abstraction
- * @param declaringBean The declaring bean abstraction
- * @param manager the current manager
- * @return A producer Web Bean
- */
- public static <T> ProducerFieldBean<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
- {
- return new ProducerFieldBean<T>(field, declaringBean, manager);
- }
-
- /**
- * Constructor
- *
- * @param method The producer field abstraction
- * @param declaringBean The declaring bean
- * @param manager The Web Beans manager
- */
- protected ProducerFieldBean(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
- {
- super(declaringBean, manager);
- this.field = field;
- initType();
- initTypes();
- initBindings();
- this.id = createId("ProducerField-" + declaringBean.getType().getName() + "-"+ field.getName());
- initStereotypes();
- initPolicy();
- }
-
- @Override
- public void initialize(BeanDeployerEnvironment environment)
- {
- if (!isInitialized())
- {
- super.initialize(environment);
- }
- }
-
- public void destroy(T instance, CreationalContext<T> creationalContext)
- {
- dispose(instance);
- }
-
- public void dispose(T instance)
- {
- // No clean up required
- }
-
- public T produce(CreationalContext<T> ctx)
- {
- return field.get(getReceiver(ctx));
- }
-
-
- /**
- * Gets the annotated item representing the field
- *
- * @return The annotated item
- */
- @Override
- protected WBField<T, ?> getAnnotatedItem()
- {
- return field;
- }
-
- /**
- * Returns the default name
- *
- * @return The default name
- */
- @Override
- protected String getDefaultName()
- {
- return field.getPropertyName();
- }
-
- /**
- * Gets a string representation
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder();
- buffer.append("Annotated " + Names.scopeTypeToString(getScope()));
- if (getName() == null)
- {
- buffer.append("unnamed producer field bean");
- }
- else
- {
- buffer.append("simple producer field bean '" + getName() + "'");
- }
- buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
- return buffer.toString();
- }
-
- @Override
- public AbstractBean<?, ?> getSpecializedBean()
- {
- return null;
- }
-
- @Override
- public boolean isSpecializing()
- {
- return false;
- }
-
- @Override
- public String getId()
- {
- return id;
- }
-
- public Set<Class<? extends Annotation>> getStereotypes()
- {
- return Collections.emptySet();
- }
-
-}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java (from rev 3653, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -0,0 +1,293 @@
+/*
+ * 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.bean;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.CreationException;
+import javax.enterprise.inject.Disposes;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.injection.ParameterInjectionPoint;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.introspector.WBParameter;
+import org.jboss.webbeans.util.Names;
+
+/**
+ * Represents a producer method bean
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
+public class ProducerMethod<T> extends AbstractProducerBean<T, Method>
+{
+ // The underlying method
+ private MethodInjectionPoint<T, ?> method;
+
+ private DisposalMethod<?> disposalMethodBean;
+
+ private ProducerMethod<?> specializedBean;
+
+ private final String id;
+
+ /**
+ * Creates a producer method Web Bean
+ *
+ * @param method The underlying method abstraction
+ * @param declaringBean The declaring bean abstraction
+ * @param manager the current manager
+ * @return A producer Web Bean
+ */
+ public static <T> ProducerMethod<T> of(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ return new ProducerMethod<T>(method, declaringBean, manager);
+ }
+
+ protected ProducerMethod(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ super(declaringBean, manager);
+ this.method = MethodInjectionPoint.of(this, method);
+ initType();
+ initTypes();
+ initBindings();
+ this.id = createId("ProducerMethod-" + declaringBean.getType().getName() + "-" + method.getSignature().toString());
+ initStereotypes();
+ initPolicy();
+ }
+
+ public T produce(CreationalContext<T> creationalContext)
+ {
+ Object receiver = getReceiver(creationalContext);
+ if (receiver != null)
+ {
+ return method.invokeOnInstance(receiver, manager, creationalContext, CreationException.class);
+ }
+ else
+ {
+ return method.invoke(receiver, manager, creationalContext, CreationException.class);
+ }
+ }
+
+ /**
+ * Initializes the bean and its metadata
+ */
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ initProducerMethodInjectableParameters();
+ super.initialize(environment);
+ checkProducerMethod();
+ initDisposalMethod(environment);
+ }
+ }
+
+ /**
+ * Initializes the injection points
+ */
+ protected void initProducerMethodInjectableParameters()
+ {
+ for (WBParameter<?, ?> parameter : method.getWBParameters())
+ {
+ addInjectionPoint(ParameterInjectionPoint.of(this, parameter));
+ }
+ }
+
+ /**
+ * Validates the producer method
+ */
+ protected void checkProducerMethod()
+ {
+ if (getAnnotatedItem().getAnnotatedWBParameters(Observes.class).size() > 0)
+ {
+ throw new DefinitionException("Producer method cannot have parameter annotated @Observes");
+ }
+ else if (getAnnotatedItem().getAnnotatedWBParameters(Disposes.class).size() > 0)
+ {
+ throw new DefinitionException("Producer method cannot have parameter annotated @Disposes");
+ }
+ else if (getDeclaringBean() instanceof SessionBean<?>)
+ {
+ boolean methodDeclaredOnTypes = false;
+ // TODO use annotated item?
+ for (Type type : getDeclaringBean().getTypes())
+ {
+ if (type instanceof Class)
+ {
+ Class<?> clazz = (Class<?>) type;
+ try
+ {
+ clazz.getDeclaredMethod(getAnnotatedItem().getName(), getAnnotatedItem().getParameterTypesAsArray());
+ methodDeclaredOnTypes = true;
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ // No - op
+ }
+ }
+ }
+ if (!methodDeclaredOnTypes)
+ {
+ throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
+ }
+ }
+ }
+
+ /**
+ * Initializes the remove method
+ */
+ protected void initDisposalMethod(BeanDeployerEnvironment environment)
+ {
+ Set<DisposalMethod<?>> disposalBeans = environment.resolveDisposalBeans(getTypes(), getQualifiers(), getDeclaringBean());
+
+ if (disposalBeans.size() == 1)
+ {
+ this.disposalMethodBean = disposalBeans.iterator().next();
+ }
+ else if (disposalBeans.size() > 1)
+ {
+ // TODO List out found disposal methods
+ throw new DefinitionException("Cannot declare multiple disposal methods for this producer method. Producer method: " + this + ". Disposal methods: " + disposalBeans);
+ }
+ }
+
+ public void destroy(T instance, CreationalContext<T> creationalContext)
+ {
+ try
+ {
+ dispose(instance);
+ }
+ finally
+ {
+ if (getDeclaringBean().isDependent())
+ {
+ creationalContext.release();
+ }
+ }
+ }
+
+ public void dispose(T instance)
+ {
+ if (disposalMethodBean != null)
+ {
+ disposalMethodBean.invokeDisposeMethod(instance);
+ }
+ }
+
+ /**
+ * Gets the annotated item representing the method
+ *
+ * @return The annotated item
+ */
+ @Override
+ public WBMethod<T, ?> getAnnotatedItem()
+ {
+ return method;
+ }
+
+ /**
+ * Returns the default name
+ *
+ * @return The default name
+ */
+ @Override
+ protected String getDefaultName()
+ {
+ return method.getPropertyName();
+ }
+
+ /**
+ * Returns the disposal method
+ *
+ * @return The method representation
+ */
+ public DisposalMethod<?> getDisposalMethod()
+ {
+ return disposalMethodBean;
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(Names.scopeTypeToString(getScope()));
+ if (getName() == null)
+ {
+ buffer.append("unnamed producer method bean");
+ }
+ else
+ {
+ buffer.append("simple producer method bean '" + getName() + "'");
+ }
+ buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
+ return buffer.toString();
+ }
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ return specializedBean;
+ }
+
+ @Override
+ protected void preSpecialize(BeanDeployerEnvironment environment)
+ {
+ if (getDeclaringBean().getAnnotatedItem().getWBSuperclass().getDeclaredWBMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
+ {
+ throw new DefinitionException("Specialized producer method does not override a method on the direct superclass");
+ }
+ }
+
+ @Override
+ protected void specialize(BeanDeployerEnvironment environment)
+ {
+ WBMethod<?, ?> superClassMethod = getDeclaringBean().getAnnotatedItem().getWBSuperclass().getWBMethod(getAnnotatedItem().getAnnotatedMethod());
+ if (environment.getProducerMethod(superClassMethod) == null)
+ {
+ throw new IllegalStateException(toString() + " does not specialize a bean");
+ }
+ this.specializedBean = environment.getProducerMethod(superClassMethod);
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -1,293 +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.bean;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.CreationException;
-import javax.enterprise.inject.Disposes;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.injection.MethodInjectionPoint;
-import org.jboss.webbeans.injection.ParameterInjectionPoint;
-import org.jboss.webbeans.introspector.WBMethod;
-import org.jboss.webbeans.introspector.WBParameter;
-import org.jboss.webbeans.util.Names;
-
-/**
- * Represents a producer method bean
- *
- * @author Pete Muir
- *
- * @param <T>
- */
-public class ProducerMethodBean<T> extends AbstractProducerBean<T, Method>
-{
- // The underlying method
- private MethodInjectionPoint<T, ?> method;
-
- private DisposalMethodBean<?> disposalMethodBean;
-
- private ProducerMethodBean<?> specializedBean;
-
- private final String id;
-
- /**
- * Creates a producer method Web Bean
- *
- * @param method The underlying method abstraction
- * @param declaringBean The declaring bean abstraction
- * @param manager the current manager
- * @return A producer Web Bean
- */
- public static <T> ProducerMethodBean<T> of(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
- {
- return new ProducerMethodBean<T>(method, declaringBean, manager);
- }
-
- protected ProducerMethodBean(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
- {
- super(declaringBean, manager);
- this.method = MethodInjectionPoint.of(this, method);
- initType();
- initTypes();
- initBindings();
- this.id = createId("ProducerMethod-" + declaringBean.getType().getName() + "-" + method.getSignature().toString());
- initStereotypes();
- initPolicy();
- }
-
- public T produce(CreationalContext<T> creationalContext)
- {
- Object receiver = getReceiver(creationalContext);
- if (receiver != null)
- {
- return method.invokeOnInstance(receiver, manager, creationalContext, CreationException.class);
- }
- else
- {
- return method.invoke(receiver, manager, creationalContext, CreationException.class);
- }
- }
-
- /**
- * Initializes the bean and its metadata
- */
- @Override
- public void initialize(BeanDeployerEnvironment environment)
- {
- if (!isInitialized())
- {
- initProducerMethodInjectableParameters();
- super.initialize(environment);
- checkProducerMethod();
- initDisposalMethod(environment);
- }
- }
-
- /**
- * Initializes the injection points
- */
- protected void initProducerMethodInjectableParameters()
- {
- for (WBParameter<?, ?> parameter : method.getWBParameters())
- {
- addInjectionPoint(ParameterInjectionPoint.of(this, parameter));
- }
- }
-
- /**
- * Validates the producer method
- */
- protected void checkProducerMethod()
- {
- if (getAnnotatedItem().getAnnotatedWBParameters(Observes.class).size() > 0)
- {
- throw new DefinitionException("Producer method cannot have parameter annotated @Observes");
- }
- else if (getAnnotatedItem().getAnnotatedWBParameters(Disposes.class).size() > 0)
- {
- throw new DefinitionException("Producer method cannot have parameter annotated @Disposes");
- }
- else if (getDeclaringBean() instanceof EnterpriseBean<?>)
- {
- boolean methodDeclaredOnTypes = false;
- // TODO use annotated item?
- for (Type type : getDeclaringBean().getTypes())
- {
- if (type instanceof Class)
- {
- Class<?> clazz = (Class<?>) type;
- try
- {
- clazz.getDeclaredMethod(getAnnotatedItem().getName(), getAnnotatedItem().getParameterTypesAsArray());
- methodDeclaredOnTypes = true;
- }
- catch (NoSuchMethodException nsme)
- {
- // No - op
- }
- }
- }
- if (!methodDeclaredOnTypes)
- {
- throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
- }
- }
- }
-
- /**
- * Initializes the remove method
- */
- protected void initDisposalMethod(BeanDeployerEnvironment environment)
- {
- Set<DisposalMethodBean<?>> disposalBeans = environment.resolveDisposalBeans(getTypes(), getQualifiers(), getDeclaringBean());
-
- if (disposalBeans.size() == 1)
- {
- this.disposalMethodBean = disposalBeans.iterator().next();
- }
- else if (disposalBeans.size() > 1)
- {
- // TODO List out found disposal methods
- throw new DefinitionException("Cannot declare multiple disposal methods for this producer method. Producer method: " + this + ". Disposal methods: " + disposalBeans);
- }
- }
-
- public void destroy(T instance, CreationalContext<T> creationalContext)
- {
- try
- {
- dispose(instance);
- }
- finally
- {
- if (getDeclaringBean().isDependent())
- {
- creationalContext.release();
- }
- }
- }
-
- public void dispose(T instance)
- {
- if (disposalMethodBean != null)
- {
- disposalMethodBean.invokeDisposeMethod(instance);
- }
- }
-
- /**
- * Gets the annotated item representing the method
- *
- * @return The annotated item
- */
- @Override
- public WBMethod<T, ?> getAnnotatedItem()
- {
- return method;
- }
-
- /**
- * Returns the default name
- *
- * @return The default name
- */
- @Override
- protected String getDefaultName()
- {
- return method.getPropertyName();
- }
-
- /**
- * Returns the disposal method
- *
- * @return The method representation
- */
- public DisposalMethodBean<?> getDisposalMethod()
- {
- return disposalMethodBean;
- }
-
- /**
- * Gets a string representation
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder();
- buffer.append(Names.scopeTypeToString(getScope()));
- if (getName() == null)
- {
- buffer.append("unnamed producer method bean");
- }
- else
- {
- buffer.append("simple producer method bean '" + getName() + "'");
- }
- buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
- return buffer.toString();
- }
-
- @Override
- public AbstractBean<?, ?> getSpecializedBean()
- {
- return specializedBean;
- }
-
- @Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
- {
- if (getDeclaringBean().getAnnotatedItem().getWBSuperclass().getDeclaredWBMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
- {
- throw new DefinitionException("Specialized producer method does not override a method on the direct superclass");
- }
- }
-
- @Override
- protected void specialize(BeanDeployerEnvironment environment)
- {
- WBMethod<?, ?> superClassMethod = getDeclaringBean().getAnnotatedItem().getWBSuperclass().getWBMethod(getAnnotatedItem().getAnnotatedMethod());
- if (environment.getProducerMethod(superClassMethod) == null)
- {
- throw new IllegalStateException(toString() + " does not specialize a bean");
- }
- this.specializedBean = environment.getProducerMethod(superClassMethod);
- }
-
- @Override
- public String getId()
- {
- return id;
- }
-
- public Set<Class<? extends Annotation>> getStereotypes()
- {
- return Collections.emptySet();
- }
-
-}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java (from rev 3653, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -0,0 +1,402 @@
+/*
+ * 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.bean;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javassist.util.proxy.ProxyFactory;
+import javassist.util.proxy.ProxyObject;
+
+import javax.decorator.Decorator;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.CreationException;
+import javax.interceptor.Interceptor;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
+import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
+import org.jboss.webbeans.bean.proxy.Marker;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.ejb.InternalEjbDescriptor;
+import org.jboss.webbeans.ejb.api.SessionObjectReference;
+import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
+import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.injection.InjectionContextImpl;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.resources.ClassTransformer;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Proxies;
+
+/**
+ * An enterprise bean representation
+ *
+ * @author Pete Muir
+ *
+ * @param <T> The type (class) of the bean
+ */
+public class SessionBean<T> extends AbstractClassBean<T>
+{
+ private final Log log = Logging.getLog(SessionBean.class);
+
+ // The EJB descriptor
+ private InternalEjbDescriptor<T> ejbDescriptor;
+
+ private Class<T> proxyClass;
+
+ private SessionBean<?> specializedBean;
+
+ /**
+ * Creates a simple, annotation defined Enterprise Web Bean
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param manager the current manager
+ * @return An Enterprise Web Bean
+ */
+ public static <T> SessionBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ {
+ WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
+ return new SessionBean<T>(type, ejbDescriptor, manager);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param type The type of the bean
+ * @param manager The Web Beans manager
+ */
+ protected SessionBean(WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ {
+ super(type, manager);
+ initType();
+ this.ejbDescriptor = ejbDescriptor;
+ initTypes();
+ initBindings();
+ }
+
+ /**
+ * Initializes the bean and its metadata
+ */
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ super.initialize(environment);
+ initProxyClass();
+ checkEJBTypeAllowed();
+ checkConflictingRoles();
+ checkObserverMethods();
+ checkScopeAllowed();
+ }
+ }
+
+ @Override
+ protected void initTypes()
+ {
+ Set<Type> types = new HashSet<Type>();
+ types = new LinkedHashSet<Type>();
+ types.add(Object.class);
+ for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces())
+ {
+ types.add(businessInterfaceDescriptor.getInterface());
+ }
+ super.types = types;
+ }
+
+ protected void initProxyClass()
+ {
+ Set<Type> types = new LinkedHashSet<Type>(getTypes());
+ types.add(EnterpriseBeanInstance.class);
+ types.add(Serializable.class);
+ ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
+
+ @SuppressWarnings("unchecked")
+ Class<T> proxyClass = proxyFactory.createClass();
+
+ this.proxyClass = proxyClass;
+ }
+
+ /**
+ * Validates for non-conflicting roles
+ */
+ protected void checkConflictingRoles()
+ {
+ if (getType().isAnnotationPresent(Interceptor.class))
+ {
+ throw new DefinitionException("Enterprise beans cannot be interceptors");
+ }
+ if (getType().isAnnotationPresent(Decorator.class))
+ {
+ throw new DefinitionException("Enterprise beans cannot be decorators");
+ }
+ }
+
+ /**
+ * Check that the scope type is allowed by the stereotypes on the bean and
+ * the bean type
+ */
+ protected void checkScopeAllowed()
+ {
+ if (ejbDescriptor.isStateless() && !isDependent())
+ {
+ throw new DefinitionException("Scope " + getScope() + " is not allowed on stateless enterpise beans for " + getType() + ". Only @Dependent is allowed on stateless enterprise beans");
+ }
+ if (ejbDescriptor.isSingleton() && !(isDependent() || getScope().equals(ApplicationScoped.class)))
+ {
+ throw new DefinitionException("Scope " + getScope() + " is not allowed on singleton enterpise beans for " + getType() + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise beans");
+ }
+ }
+
+ /**
+ * Validates specialization
+ */
+ @Override
+ protected void preSpecialize(BeanDeployerEnvironment environment)
+ {
+ super.preSpecialize(environment);
+ // We appear to check this twice?
+ if (!environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
+ {
+ throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
+ }
+ }
+
+ @Override
+ protected void specialize(BeanDeployerEnvironment environment)
+ {
+ if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
+ {
+ throw new IllegalStateException(toString() + " does not specialize a bean");
+ }
+ AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
+ if (!(specializedBean instanceof SessionBean<?>))
+ {
+ throw new IllegalStateException(toString() + " doesn't have a session bean as a superclass " + specializedBean);
+ }
+ else
+ {
+ this.specializedBean = (SessionBean<?>) specializedBean;
+ }
+ }
+
+ /**
+ * Creates an instance of the bean
+ *
+ * @return The instance
+ */
+ public T create(final CreationalContext<T> creationalContext)
+ {
+ T instance = produce(creationalContext);
+ if (hasDecorators())
+ {
+ instance = applyDecorators(instance, creationalContext, null);
+ }
+ return instance;
+ }
+
+ public void inject(final T instance, final CreationalContext<T> ctx)
+ {
+ new InjectionContextImpl<T>(getManager(), this, instance)
+ {
+
+ public void proceed()
+ {
+ Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
+ Beans.callInitializers(instance, ctx, getManager(), getInitializerMethods());
+ }
+
+ }.run();
+
+ }
+
+ public T produce(CreationalContext<T> ctx)
+ {
+ try
+ {
+ T instance = proxyClass.newInstance();
+ ctx.push(instance);
+ ((ProxyObject) instance).setHandler(new EnterpriseBeanProxyMethodHandler<T>(this, ctx));
+ log.trace("Enterprise bean instance created for bean {0}", this);
+ return instance;
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException("Could not instantiate enterprise proxy for " + toString(), e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException("Could not access bean correctly when creating enterprise proxy for " + toString(), e);
+ }
+ catch (Exception e)
+ {
+ throw new CreationException("could not find the EJB in JNDI " + proxyClass, e);
+ }
+ }
+
+ public void destroy(T instance, CreationalContext<T> creationalContext)
+ {
+ if (instance == null)
+ {
+ throw new IllegalArgumentException("instance to destroy cannot be null");
+ }
+ if (!(instance instanceof EnterpriseBeanInstance))
+ {
+ throw new IllegalArgumentException("Cannot destroy session bean instance not created by the container");
+ }
+ EnterpriseBeanInstance enterpiseBeanInstance = (EnterpriseBeanInstance) instance;
+ enterpiseBeanInstance.destroy(Marker.INSTANCE, this, creationalContext);
+ creationalContext.release();
+ }
+
+ /**
+ * Validates the bean type
+ */
+ private void checkEJBTypeAllowed()
+ {
+ if (ejbDescriptor.isMessageDriven())
+ {
+ throw new DefinitionException("Message Driven Beans can't be Web Beans");
+ }
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ // buffer.append("Annotated " + Names.scopeTypeToString(getScopeType()) +
+ // Names.ejbTypeFromMetaData(getEjbMetaData()));
+ if (getName() == null)
+ {
+ buffer.append(" unnamed enterprise bean");
+ }
+ else
+ {
+ buffer.append(" enterprise bean '" + getName() + "'");
+ }
+ buffer.append(" [" + getType().getName() + "] ");
+ buffer.append("API types " + getTypes() + ", binding types " + getQualifiers());
+ return buffer.toString();
+ }
+
+ public void postConstruct(T instance, CreationalContext<T> creationalContext)
+ {
+ Beans.injectBoundFields(instance, creationalContext, getManager(), getInjectableFields());
+ Beans.callInitializers(instance, creationalContext, getManager(), getInitializerMethods());
+ }
+
+ public void preDestroy(CreationalContext<T> creationalContext)
+ {
+ creationalContext.release();
+ }
+
+ @Override
+ protected void initSerializable()
+ {
+ // No-op
+ }
+
+ @Override
+ public boolean isSerializable()
+ {
+ return true;
+ }
+
+ public InternalEjbDescriptor<T> getEjbDescriptor()
+ {
+ return ejbDescriptor;
+ }
+
+ public boolean isClientCanCallRemoveMethods()
+ {
+ return getEjbDescriptor().isStateful() && isDependent();
+ }
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ return specializedBean;
+ }
+
+ /**
+ * If there are any observer methods, they must be static or business
+ * methods.
+ */
+ protected void checkObserverMethods()
+ {
+ for (WBMethod<?, ?> method : this.annotatedItem.getWBDeclaredMethodsWithAnnotatedParameters(Observes.class))
+ {
+ if (!method.isStatic())
+ {
+ if (!isMethodExistsOnTypes(method))
+ {
+ throw new DefinitionException("Observer method must be static or business method: " + method + " on " + getAnnotatedItem());
+ }
+ }
+ }
+ }
+
+ // TODO must be a nicer way to do this!
+ public boolean isMethodExistsOnTypes(WBMethod<?, ?> method)
+ {
+ for (Type type : getTypes())
+ {
+ if (type instanceof Class)
+ {
+ for (Method m : ((Class<?>) type).getMethods())
+ {
+ if (method.getName().equals(m.getName()) && Arrays.equals(method.getParameterTypesAsArray(), m.getParameterTypes()))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public SessionObjectReference createReference()
+ {
+ return manager.getServices().get(EjbServices.class).resolveEjb(getEjbDescriptor().delegate());
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+}
+
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -1,359 +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.bean;
-
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Disposes;
-import javax.enterprise.inject.spi.Decorator;
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.injection.ConstructorInjectionPoint;
-import org.jboss.webbeans.injection.InjectionContextImpl;
-import org.jboss.webbeans.injection.WBInjectionPoint;
-import org.jboss.webbeans.introspector.WBClass;
-import org.jboss.webbeans.introspector.WBConstructor;
-import org.jboss.webbeans.introspector.WBField;
-import org.jboss.webbeans.introspector.WBMethod;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
-import org.jboss.webbeans.util.Beans;
-import org.jboss.webbeans.util.Names;
-import org.jboss.webbeans.util.Reflections;
-
-/**
- * Represents a simple bean
- *
- * @author Pete Muir
- *
- * @param <T> The type (class) of the bean
- */
-public class SimpleBean<T> extends AbstractClassBean<T>
-{
- // Logger
- private static LogProvider log = Logging.getLogProvider(SimpleBean.class);
-
- // The constructor
- private ConstructorInjectionPoint<T> constructor;
- private Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
- private Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
- private Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
- private Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
-
- private SimpleBean<?> specializedBean;
-
-
-
- /**
- * Creates a simple, annotation defined Web Bean
- *
- * @param <T> The type
- * @param clazz The class
- * @param manager the current manager
- * @return A Web Bean
- */
- public static <T> SimpleBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
- {
- return new SimpleBean<T>(clazz, manager);
- }
-
- /**
- * Constructor
- *
- * @param type The type of the bean
- * @param manager The Web Beans manager
- */
- protected SimpleBean(WBClass<T> type, BeanManagerImpl manager)
- {
- super(type, manager);
- initType();
- initTypes();
- initBindings();
- }
-
- /**
- * Creates an instance of the bean
- *
- * @return The instance
- */
- public T create(CreationalContext<T> creationalContext)
- {
- InjectionPoint originalInjectionPoint = null;
- if (hasDecorators())
- {
- originalInjectionPoint = attachCorrectInjectionPoint();
- }
- T instance = produce(creationalContext);
- inject(instance, creationalContext);
- postConstruct(instance);
- if (hasDecorators())
- {
- instance = applyDecorators(instance, creationalContext, originalInjectionPoint);
- }
- return instance;
- }
-
- public T produce(CreationalContext<T> ctx)
- {
- T instance = constructor.newInstance(manager, ctx);
- if (!hasDecorators())
- {
- // This should be safe, but needs verification PLM
- // Without this, the chaining of decorators will fail as the incomplete instance will be resolved
- ctx.push(instance);
- }
- return instance;
- }
-
- public void inject(final T instance, final CreationalContext<T> ctx)
- {
- new InjectionContextImpl<T>(getManager(), this, instance)
- {
-
- public void proceed()
- {
- Beans.injectEEFields(instance, getManager(), ejbInjectionPoints, persistenceContextInjectionPoints, persistenceUnitInjectionPoints, resourceInjectionPoints);
- Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
- Beans.callInitializers(instance, ctx, getManager(), getInitializerMethods());
- }
-
- }.run();
-
- }
-
- protected InjectionPoint attachCorrectInjectionPoint()
- {
- Decorator<?> decorator = getDecorators().get(getDecorators().size() - 1);
- if (decorator instanceof DecoratorBean<?>)
- {
- DecoratorBean<?> decoratorBean = (DecoratorBean<?>) decorator;
- InjectionPoint outerDelegateInjectionPoint = decoratorBean.getDelegateInjectionPoint();
- return getManager().replaceOrPushCurrentInjectionPoint(outerDelegateInjectionPoint);
- }
- else
- {
- throw new IllegalStateException("Cannot operate on user defined decorator");
- }
- }
-
- /**
- * Destroys an instance of the bean
- *
- * @param instance The instance
- */
- public void destroy(T instance, CreationalContext<T> creationalContext)
- {
- try
- {
- preDestroy(instance);
- creationalContext.release();
- }
- catch (Exception e)
- {
- log.error("Error destroying " + toString(), e);
- }
- }
-
- /**
- * Initializes the bean and its metadata
- */
- @Override
- public void initialize(BeanDeployerEnvironment environment)
- {
- if (!isInitialized())
- {
- initConstructor();
- checkConstructor();
- super.initialize(environment);
- initPostConstruct();
- initPreDestroy();
- initEEInjectionPoints();
- }
- }
-
- private void initEEInjectionPoints()
- {
- this.ejbInjectionPoints = Beans.getEjbInjectionPoints(this, getAnnotatedItem(), getManager());
- this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(this, getAnnotatedItem(), getManager());
- this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(this, getAnnotatedItem(), getManager());
- this.resourceInjectionPoints = Beans.getResourceInjectionPoints(this, getAnnotatedItem(), manager);
- }
-
- /**
- * Validates the type
- */
- protected void checkType()
- {
- if (getAnnotatedItem().isNonStaticMemberClass())
- {
- 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()))
- {
- throw new DefinitionException("Simple bean declaring a passivating scope must have a serializable implementation class " + toString());
- }
- if (hasDecorators())
- {
- if (getAnnotatedItem().isFinal())
- {
- throw new DefinitionException("Bean class which has decorators cannot be declared final " + this);
- }
- for (Decorator<?> decorator : getDecorators())
- {
- if (decorator instanceof DecoratorBean<?>)
- {
- DecoratorBean<?> decoratorBean = (DecoratorBean<?>) decorator;
- for (WBMethod<?, ?> decoratorMethod : decoratorBean.getAnnotatedItem().getWBMethods())
- {
- WBMethod<?, ?> method = getAnnotatedItem().getWBMethod(decoratorMethod.getSignature());
- if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal())
- {
- throw new DefinitionException("Decorated bean method " + method + " (decorated by "+ decoratorMethod + ") cannot be declarted final");
- }
- }
- }
- else
- {
- throw new IllegalStateException("Can only operate on container provided decorators " + decorator);
- }
- }
- }
- }
-
- @Override
- protected void checkBeanImplementation()
- {
- super.checkBeanImplementation();
- if (!isDependent())
- {
- for (WBField<?, ?> field : getAnnotatedItem().getWBFields())
- {
- if (field.isPublic() && !field.isStatic())
- {
- throw new DefinitionException("Normal scoped Web Bean implementation class has a public field " + getAnnotatedItem());
- }
- }
- }
- }
-
- protected void checkConstructor()
- {
- if (!constructor.getAnnotatedWBParameters(Disposes.class).isEmpty())
- {
- throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Disposes " + constructor);
- }
- if (!constructor.getAnnotatedWBParameters(Observes.class).isEmpty())
- {
- throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Observes " + constructor);
- }
- }
-
- @Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
- {
- super.preSpecialize(environment);
- if (environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
- {
- throw new DefinitionException("Simple bean must specialize a simple bean");
- }
- }
-
- @Override
- protected void specialize(BeanDeployerEnvironment environment)
- {
- if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
- {
- throw new DefinitionException(toString() + " does not specialize a bean");
- }
- AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
- if (!(specializedBean instanceof SimpleBean))
- {
- throw new DefinitionException(toString() + " doesn't have a simple bean as a superclass " + specializedBean);
- }
- else
- {
- this.specializedBean = (SimpleBean<?>) specializedBean;
- }
- }
-
-
- /**
- * Initializes the constructor
- */
- protected void initConstructor()
- {
- this.constructor = Beans.getBeanConstructor(this, getAnnotatedItem());
- // TODO We loop unecessarily many times here, I want to probably introduce some callback mechanism. PLM.
- addInjectionPoints(Beans.getParameterInjectionPoints(this, constructor));
- }
-
- /**
- * Returns the constructor
- *
- * @return The constructor
- */
- public WBConstructor<T> getConstructor()
- {
- return constructor;
- }
-
- /**
- * Gets a string representation
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- return toString("simple bean");
- }
-
- protected String toString(String beanType)
- {
- StringBuilder buffer = new StringBuilder();
- buffer.append(Names.scopeTypeToString(getScope()));
- if (getName() == null)
- {
- buffer.append("unnamed ").append(beanType);
- }
- else
- {
- buffer.append(beanType).append(" '" + getName() + "'");
- }
- buffer.append(" ").append(getType().getName()).append(", ");
- buffer.append(" API types = ").append(Names.typesToString(getTypes())).append(", binding types = " + Names.annotationsToString(getQualifiers()));
- return buffer.toString();
- }
-
- @Override
- public SimpleBean<?> getSpecializedBean()
- {
- return specializedBean;
- }
-
-}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -24,7 +24,7 @@
import javassist.util.proxy.MethodHandler;
-import org.jboss.webbeans.bean.DecoratorBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
import org.jboss.webbeans.bean.SerializableBeanInstance;
import org.jboss.webbeans.introspector.MethodSignature;
import org.jboss.webbeans.introspector.WBMethod;
@@ -40,7 +40,7 @@
{
private static final long serialVersionUID = 4577632640130385060L;
- private final List<SerializableBeanInstance<DecoratorBean<Object>, Object>> decoratorInstances;
+ private final List<SerializableBeanInstance<DecoratorImpl<Object>, Object>> decoratorInstances;
private final Object instance;
@@ -51,7 +51,7 @@
*
* @param proxy The generic proxy
*/
- public DecoratorProxyMethodHandler(List<SerializableBeanInstance<DecoratorBean<Object>, Object>> decoratorInstances, Object instance)
+ public DecoratorProxyMethodHandler(List<SerializableBeanInstance<DecoratorImpl<Object>, Object>> decoratorInstances, Object instance)
{
this.decoratorInstances = decoratorInstances;
this.instance = instance;
@@ -77,7 +77,7 @@
public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
{
MethodSignature methodSignature = new MethodSignatureImpl(method);
- for (SerializableBeanInstance<DecoratorBean<Object>, Object> beanInstance : decoratorInstances)
+ for (SerializableBeanInstance<DecoratorImpl<Object>, Object> beanInstance : decoratorInstances)
{
WBMethod<?, ?> decoratorMethod = beanInstance.getBean().getAnnotatedItem().getWBMethod(methodSignature);
if (decoratorMethod != null)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -18,7 +18,7 @@
import javax.enterprise.context.spi.CreationalContext;
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
/**
* Interface implemented by all enterprise bean proxies to query/control the proxy
@@ -29,6 +29,6 @@
public interface EnterpriseBeanInstance
{
- public void destroy(Marker marker, EnterpriseBean<?> enterpriseBean, CreationalContext<?> creationalContext);
+ public void destroy(Marker marker, SessionBean<?> enterpriseBean, CreationalContext<?> creationalContext);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -24,7 +24,7 @@
import javax.enterprise.context.spi.CreationalContext;
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
import org.jboss.webbeans.introspector.MethodSignature;
import org.jboss.webbeans.introspector.jlr.MethodSignatureImpl;
@@ -59,7 +59,7 @@
*
* @param proxy The generic proxy
*/
- public EnterpriseBeanProxyMethodHandler(EnterpriseBean<T> bean, CreationalContext<T> creationalContext)
+ public EnterpriseBeanProxyMethodHandler(SessionBean<T> bean, CreationalContext<T> creationalContext)
{
this.objectInterface = bean.getEjbDescriptor().getObjectInterface();
this.removeMethodSignatures = bean.getEjbDescriptor().getRemoveMethodSignatures();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -30,15 +30,15 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bean.AbstractClassBean;
-import org.jboss.webbeans.bean.DecoratorBean;
-import org.jboss.webbeans.bean.DisposalMethodBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
-import org.jboss.webbeans.bean.NewEnterpriseBean;
-import org.jboss.webbeans.bean.NewSimpleBean;
-import org.jboss.webbeans.bean.ProducerFieldBean;
-import org.jboss.webbeans.bean.ProducerMethodBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
+import org.jboss.webbeans.bean.DisposalMethod;
+import org.jboss.webbeans.bean.SessionBean;
+import org.jboss.webbeans.bean.NewSessionBean;
+import org.jboss.webbeans.bean.NewManagedBean;
+import org.jboss.webbeans.bean.ProducerField;
+import org.jboss.webbeans.bean.ProducerMethod;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.event.ObserverFactory;
@@ -77,7 +77,7 @@
Set<RIBean<?>> beans = getEnvironment().getBeans();
// ensure that all decorators are initialized before initializing
// the rest of the beans
- for (DecoratorBean<?> bean : getEnvironment().getDecorators())
+ for (DecoratorImpl<?> bean : getEnvironment().getDecorators())
{
bean.initialize(getEnvironment());
manager.addDecorator(bean);
@@ -133,7 +133,7 @@
{
for (WBMethod<?, ?> method : annotatedClass.getWBDeclaredMethodsWithAnnotatedParameters(Disposes.class))
{
- DisposalMethodBean<?> disposalBean = DisposalMethodBean.of(manager, method, declaringBean);
+ DisposalMethod<?> disposalBean = DisposalMethod.of(manager, method, declaringBean);
disposalBean.initialize(getEnvironment());
getEnvironment().addBean(disposalBean);
}
@@ -141,13 +141,13 @@
protected <T> void createProducerMethod(AbstractClassBean<?> declaringBean, WBMethod<T, ?> annotatedMethod)
{
- ProducerMethodBean<T> bean = ProducerMethodBean.of(annotatedMethod, declaringBean, manager);
+ ProducerMethod<T> bean = ProducerMethod.of(annotatedMethod, declaringBean, manager);
getEnvironment().addBean(bean);
}
protected <T> void createProducerField(AbstractClassBean<?> declaringBean, WBField<T, ?> field)
{
- ProducerFieldBean<T> bean = ProducerFieldBean.of(field, declaringBean, manager);
+ ProducerField<T> bean = ProducerField.of(field, declaringBean, manager);
getEnvironment().addBean(bean);
}
@@ -182,25 +182,25 @@
protected <T> void createSimpleBean(WBClass<T> annotatedClass)
{
- SimpleBean<T> bean = SimpleBean.of(annotatedClass, manager);
+ ManagedBean<T> bean = ManagedBean.of(annotatedClass, manager);
getEnvironment().addBean(bean);
createSubBeans(bean);
- getEnvironment().addBean(NewSimpleBean.of(annotatedClass, manager));
+ getEnvironment().addBean(NewManagedBean.of(annotatedClass, manager));
}
protected <T> void createDecorator(WBClass<T> annotatedClass)
{
- DecoratorBean<T> bean = DecoratorBean.of(annotatedClass, manager);
+ DecoratorImpl<T> bean = DecoratorImpl.of(annotatedClass, manager);
getEnvironment().addBean(bean);
}
protected <T> void createEnterpriseBean(InternalEjbDescriptor<T> ejbDescriptor)
{
// TODO Don't create enterprise bean if it has no local interfaces!
- EnterpriseBean<T> bean = EnterpriseBean.of(ejbDescriptor, manager);
+ SessionBean<T> bean = SessionBean.of(ejbDescriptor, manager);
getEnvironment().addBean(bean);
createSubBeans(bean);
- getEnvironment().addBean(NewEnterpriseBean.of(ejbDescriptor, manager));
+ getEnvironment().addBean(NewSessionBean.of(ejbDescriptor, manager));
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -28,11 +28,11 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bean.AbstractClassBean;
-import org.jboss.webbeans.bean.DecoratorBean;
-import org.jboss.webbeans.bean.DisposalMethodBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
+import org.jboss.webbeans.bean.DisposalMethod;
import org.jboss.webbeans.bean.NewBean;
-import org.jboss.webbeans.bean.ProducerFieldBean;
-import org.jboss.webbeans.bean.ProducerMethodBean;
+import org.jboss.webbeans.bean.ProducerField;
+import org.jboss.webbeans.bean.ProducerMethod;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.builtin.AbstractBuiltInBean;
import org.jboss.webbeans.bean.builtin.ExtensionBean;
@@ -47,29 +47,29 @@
{
private final Map<WBClass<?>, AbstractClassBean<?>> classBeanMap;
- private final Map<WBMethod<?, ?>, ProducerMethodBean<?>> producerMethodBeanMap;
+ private final Map<WBMethod<?, ?>, ProducerMethod<?>> producerMethodBeanMap;
private final Set<RIBean<?>> beans;
private final Set<ObserverMethodImpl<?, ?>> observers;
- private final List<DisposalMethodBean<?>> allDisposalBeans;
- private final Set<DisposalMethodBean<?>> resolvedDisposalBeans;
- private final Set<DecoratorBean<?>> decorators;
+ private final List<DisposalMethod<?>> allDisposalBeans;
+ private final Set<DisposalMethod<?>> resolvedDisposalBeans;
+ private final Set<DecoratorImpl<?>> decorators;
private final EjbDescriptors ejbDescriptors;
private final TypeSafeDisposerResolver disposalMethodResolver;
public BeanDeployerEnvironment(EjbDescriptors ejbDescriptors, BeanManagerImpl manager)
{
this.classBeanMap = new HashMap<WBClass<?>, AbstractClassBean<?>>();
- this.producerMethodBeanMap = new HashMap<WBMethod<?, ?>, ProducerMethodBean<?>>();
- this.allDisposalBeans = new ArrayList<DisposalMethodBean<?>>();
- this.resolvedDisposalBeans = new HashSet<DisposalMethodBean<?>>();
+ this.producerMethodBeanMap = new HashMap<WBMethod<?, ?>, ProducerMethod<?>>();
+ this.allDisposalBeans = new ArrayList<DisposalMethod<?>>();
+ this.resolvedDisposalBeans = new HashSet<DisposalMethod<?>>();
this.beans = new HashSet<RIBean<?>>();
- this.decorators = new HashSet<DecoratorBean<?>>();
+ this.decorators = new HashSet<DecoratorImpl<?>>();
this.observers = new HashSet<ObserverMethodImpl<?, ?>>();
this.ejbDescriptors = ejbDescriptors;
this.disposalMethodResolver = new TypeSafeDisposerResolver(manager, allDisposalBeans);
}
- public ProducerMethodBean<?> getProducerMethod(WBMethod<?, ?> method)
+ public ProducerMethod<?> getProducerMethod(WBMethod<?, ?> method)
{
if (!producerMethodBeanMap.containsKey(method))
{
@@ -77,7 +77,7 @@
}
else
{
- ProducerMethodBean<?> bean = producerMethodBeanMap.get(method);
+ ProducerMethod<?> bean = producerMethodBeanMap.get(method);
bean.initialize(this);
return bean;
}
@@ -97,13 +97,13 @@
}
}
- public void addBean(ProducerMethodBean<?> bean)
+ public void addBean(ProducerMethod<?> bean)
{
producerMethodBeanMap.put(bean.getAnnotatedItem(), bean);
beans.add(bean);
}
- public void addBean(ProducerFieldBean<?> bean)
+ public void addBean(ProducerField<?> bean)
{
beans.add(bean);
}
@@ -127,12 +127,12 @@
beans.add(bean);
}
- public void addBean(DecoratorBean<?> bean)
+ public void addBean(DecoratorImpl<?> bean)
{
decorators.add(bean);
}
- public void addBean(DisposalMethodBean<?> bean)
+ public void addBean(DisposalMethod<?> bean)
{
allDisposalBeans.add(bean);
}
@@ -147,7 +147,7 @@
return Collections.unmodifiableSet(beans);
}
- public Set<DecoratorBean<?>> getDecorators()
+ public Set<DecoratorImpl<?>> getDecorators()
{
return Collections.unmodifiableSet(decorators);
}
@@ -158,9 +158,9 @@
}
- public Set<DisposalMethodBean<?>> getUnresolvedDisposalBeans()
+ public Set<DisposalMethod<?>> getUnresolvedDisposalBeans()
{
- Set<DisposalMethodBean<?>> beans = new HashSet<DisposalMethodBean<?>>(allDisposalBeans);
+ Set<DisposalMethod<?>> beans = new HashSet<DisposalMethod<?>>(allDisposalBeans);
beans.removeAll(resolvedDisposalBeans);
return Collections.unmodifiableSet(beans);
}
@@ -179,9 +179,9 @@
* @param bindings The binding types to match
* @return The set of matching disposal methods
*/
- public Set<DisposalMethodBean<?>> resolveDisposalBeans(Set<Type> types, Set<Annotation> bindings, AbstractClassBean<?> declaringBean)
+ public Set<DisposalMethod<?>> resolveDisposalBeans(Set<Type> types, Set<Annotation> bindings, AbstractClassBean<?> declaringBean)
{
- Set<DisposalMethodBean<?>> beans = disposalMethodResolver.resolve(ResolvableFactory.of(types, bindings, declaringBean));
+ Set<DisposalMethod<?>> beans = disposalMethodResolver.resolve(ResolvableFactory.of(types, bindings, declaringBean));
resolvedDisposalBeans.addAll(beans);
return Collections.unmodifiableSet(beans);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDecoratorResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDecoratorResolver.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDecoratorResolver.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -22,7 +22,7 @@
import java.util.TreeSet;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bean.DecoratorBean;
+import org.jboss.webbeans.bean.DecoratorImpl;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Reflections;
@@ -30,31 +30,31 @@
* @author pmuir
*
*/
-public class TypeSafeDecoratorResolver extends TypeSafeBeanResolver<DecoratorBean<?>>
+public class TypeSafeDecoratorResolver extends TypeSafeBeanResolver<DecoratorImpl<?>>
{
- public TypeSafeDecoratorResolver(BeanManagerImpl manager, Iterable<DecoratorBean<?>> decorators)
+ public TypeSafeDecoratorResolver(BeanManagerImpl manager, Iterable<DecoratorImpl<?>> decorators)
{
super(manager, decorators);
}
@Override
- protected boolean matches(Resolvable resolvable, DecoratorBean<?> bean)
+ protected boolean matches(Resolvable resolvable, DecoratorImpl<?> bean)
{
return Reflections.isAssignableFrom(bean.getDelegateTypes(), resolvable.getTypeClosure()) && Beans.containsAllBindings(bean.getDelegateQualifiers(), resolvable.getQualifiers(), getManager()) && getManager().getEnabledDecoratorClasses().contains(bean.getType());
}
@Override
- protected Set<DecoratorBean<?>> sortResult(Set<DecoratorBean<?>> matchedDecorators)
+ protected Set<DecoratorImpl<?>> sortResult(Set<DecoratorImpl<?>> matchedDecorators)
{
- Set<DecoratorBean<?>> sortedBeans = new TreeSet<DecoratorBean<?>>(new Comparator<DecoratorBean<?>>()
+ Set<DecoratorImpl<?>> sortedBeans = new TreeSet<DecoratorImpl<?>>(new Comparator<DecoratorImpl<?>>()
{
- public int compare(DecoratorBean<?> o1, DecoratorBean<?> o2)
+ public int compare(DecoratorImpl<?> o1, DecoratorImpl<?> o2)
{
List<Class<?>> enabledDecorators = getManager().getEnabledDecoratorClasses();
- int p1 = enabledDecorators.indexOf(((DecoratorBean<?>) o1).getType());
- int p2 = enabledDecorators.indexOf(((DecoratorBean<?>) o2).getType());
+ int p1 = enabledDecorators.indexOf(((DecoratorImpl<?>) o1).getType());
+ int p2 = enabledDecorators.indexOf(((DecoratorImpl<?>) o2).getType());
return p1 - p2;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDisposerResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDisposerResolver.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/TypeSafeDisposerResolver.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -20,7 +20,7 @@
import java.util.Set;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bean.DisposalMethodBean;
+import org.jboss.webbeans.bean.DisposalMethod;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Reflections;
@@ -28,19 +28,19 @@
* @author pmuir
*
*/
-public class TypeSafeDisposerResolver extends TypeSafeResolver<DisposalMethodBean<?>>
+public class TypeSafeDisposerResolver extends TypeSafeResolver<DisposalMethod<?>>
{
private final BeanManagerImpl manager;
- public TypeSafeDisposerResolver(BeanManagerImpl manager, Iterable<DisposalMethodBean<?>> disposers)
+ public TypeSafeDisposerResolver(BeanManagerImpl manager, Iterable<DisposalMethod<?>> disposers)
{
super(disposers);
this.manager = manager;
}
@Override
- protected boolean matches(Resolvable resolvable, DisposalMethodBean<?> disposer)
+ protected boolean matches(Resolvable resolvable, DisposalMethod<?> disposer)
{
return resolvable.getDeclaringBean().equals(disposer.getDeclaringBean()) && Reflections.isAssignableFrom(disposer.getType(), resolvable.getTypeClosure()) && Beans.containsAllBindings(disposer.getQualifiers(), resolvable.getQualifiers(), manager);
}
@@ -54,7 +54,7 @@
}
@Override
- protected Set<DisposalMethodBean<?>> filterResult(Set<DisposalMethodBean<?>> matched)
+ protected Set<DisposalMethod<?>> filterResult(Set<DisposalMethod<?>> matched)
{
return matched;
}
@@ -66,7 +66,7 @@
}
@Override
- protected Set<DisposalMethodBean<?>> sortResult(Set<DisposalMethodBean<?>> matched)
+ protected Set<DisposalMethod<?>> sortResult(Set<DisposalMethod<?>> matched)
{
return matched;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -38,7 +38,7 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bean.AbstractProducerBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
@@ -80,9 +80,9 @@
*/
public static boolean isPassivatingScope(Bean<?> bean, BeanManagerImpl manager)
{
- if (bean instanceof EnterpriseBean<?>)
+ if (bean instanceof SessionBean<?>)
{
- return ((EnterpriseBean<?>) bean).getEjbDescriptor().isStateful();
+ return ((SessionBean<?>) bean).getEjbDescriptor().isStateful();
}
else
{
@@ -99,9 +99,9 @@
*/
public static boolean isPassivationCapableBean(Bean<?> bean)
{
- if (bean instanceof EnterpriseBean<?>)
+ if (bean instanceof SessionBean<?>)
{
- return ((EnterpriseBean<?>) bean).getEjbDescriptor().isStateful();
+ return ((SessionBean<?>) bean).getEjbDescriptor().isStateful();
}
else if (bean instanceof AbstractProducerBean<?, ?>)
{
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterprise/BootstrapTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterprise/BootstrapTest.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterprise/BootstrapTest.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -9,7 +9,7 @@
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.bean.SessionBean;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -36,10 +36,10 @@
assert classes.containsKey(Panther.class);
assert classes.containsKey(Tiger.class);
- assert classes.get(Hound.class) instanceof EnterpriseBean;
- assert classes.get(Elephant.class) instanceof EnterpriseBean;
- assert classes.get(Panther.class) instanceof EnterpriseBean;
- assert classes.get(Tiger.class) instanceof EnterpriseBean;
+ assert classes.get(Hound.class) instanceof SessionBean;
+ assert classes.get(Elephant.class) instanceof SessionBean;
+ assert classes.get(Panther.class) instanceof SessionBean;
+ assert classes.get(Tiger.class) instanceof SessionBean;
}
}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterpriseAndSimple/BootstrapTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterpriseAndSimple/BootstrapTest.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleEnterpriseAndSimple/BootstrapTest.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -9,9 +9,9 @@
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.bean.SessionBean;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -41,14 +41,14 @@
assert classes.containsKey(SeaBass.class);
assert classes.containsKey(Sole.class);
- assert classes.get(Hound.class) instanceof EnterpriseBean;
- assert classes.get(Elephant.class) instanceof EnterpriseBean;
- assert classes.get(Panther.class) instanceof EnterpriseBean;
- assert classes.get(Tiger.class) instanceof EnterpriseBean;
- assert classes.get(Tuna.class) instanceof SimpleBean;
- assert classes.get(Salmon.class) instanceof SimpleBean;
- assert classes.get(SeaBass.class) instanceof SimpleBean;
- assert classes.get(Sole.class) instanceof SimpleBean;
+ assert classes.get(Hound.class) instanceof SessionBean;
+ assert classes.get(Elephant.class) instanceof SessionBean;
+ assert classes.get(Panther.class) instanceof SessionBean;
+ assert classes.get(Tiger.class) instanceof SessionBean;
+ assert classes.get(Tuna.class) instanceof ManagedBean;
+ assert classes.get(Salmon.class) instanceof ManagedBean;
+ assert classes.get(SeaBass.class) instanceof ManagedBean;
+ assert classes.get(Sole.class) instanceof ManagedBean;
}
}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleSimple/BootstrapTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleSimple/BootstrapTest.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/multipleSimple/BootstrapTest.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -8,7 +8,7 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -33,10 +33,10 @@
assert classes.containsKey(SeaBass.class);
assert classes.containsKey(Sole.class);
- assert classes.get(Tuna.class) instanceof SimpleBean;
- assert classes.get(Salmon.class) instanceof SimpleBean;
- assert classes.get(SeaBass.class) instanceof SimpleBean;
- assert classes.get(Sole.class) instanceof SimpleBean;
+ assert classes.get(Tuna.class) instanceof ManagedBean;
+ assert classes.get(Salmon.class) instanceof ManagedBean;
+ assert classes.get(SeaBass.class) instanceof ManagedBean;
+ assert classes.get(Sole.class) instanceof ManagedBean;
}
}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/singleProducerMethod/BootstrapTest.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -9,9 +9,9 @@
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.ProducerMethodBean;
+import org.jboss.webbeans.bean.ProducerMethod;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.test.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -36,8 +36,8 @@
assert classes.containsKey(TarantulaProducer.class);
assert classes.containsKey(Tarantula.class);
- assert classes.get(TarantulaProducer.class) instanceof SimpleBean;
- assert classes.get(Tarantula.class) instanceof ProducerMethodBean;
+ assert classes.get(TarantulaProducer.class) instanceof ManagedBean;
+ assert classes.get(Tarantula.class) instanceof ProducerMethod;
}
}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -7,7 +7,7 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.ContextualIdStore;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.bootstrap.api.helpers.SimpleServiceRegistry;
@@ -38,7 +38,7 @@
private void addBean(BeanManagerImpl manager, Class<?> c)
{
WBClass<?> clazz = WBClassImpl.of(c, classTransformer);
- RIBean<?> bean = SimpleBean.of(clazz, manager);
+ RIBean<?> bean = ManagedBean.of(clazz, manager);
manager.addBean(bean);
BeanDeployerEnvironment environment = new BeanDeployerEnvironment(new EjbDescriptors(), manager);
bean.initialize(environment);
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -11,7 +11,7 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.Container;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.mock.MockBeanDeploymentArchive;
import org.jboss.webbeans.mock.MockServletLifecycle;
import org.testng.annotations.AfterClass;
@@ -60,10 +60,10 @@
assert beans.containsKey(SeaBass.class);
assert beans.containsKey(Sole.class);
- assert beans.get(Tuna.class) instanceof SimpleBean;
- assert beans.get(Salmon.class) instanceof SimpleBean;
- assert beans.get(SeaBass.class) instanceof SimpleBean;
- assert beans.get(Sole.class) instanceof SimpleBean;
+ assert beans.get(Tuna.class) instanceof ManagedBean;
+ assert beans.get(Salmon.class) instanceof ManagedBean;
+ assert beans.get(SeaBass.class) instanceof ManagedBean;
+ assert beans.get(Sole.class) instanceof ManagedBean;
manager.getInstanceByType(Sole.class, new AnnotationLiteral<Whitefish>() {}).ping();
}
@@ -82,7 +82,7 @@
Bean<?> bean = beans.get(TarantulaProducer.class);
- assert beans.get(TarantulaProducer.class) instanceof SimpleBean;
+ assert beans.get(TarantulaProducer.class) instanceof ManagedBean;
manager.getInstanceByType(Tarantula.class, new AnnotationLiteral<Tame>() {}).ping();
}
@@ -98,7 +98,7 @@
}
}
assert classes.containsKey(Hound.class);
- assert classes.get(Hound.class) instanceof SimpleBean;
+ assert classes.get(Hound.class) instanceof ManagedBean;
manager.getInstanceByType(HoundLocal.class, new AnnotationLiteral<Tame>() {}).ping();
}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -8,8 +8,8 @@
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.bean.NewEnterpriseBean;
+import org.jboss.webbeans.bean.SessionBean;
+import org.jboss.webbeans.bean.NewSessionBean;
import org.jboss.webbeans.introspector.WBAnnotated;
import org.jboss.webbeans.literal.NewLiteral;
import org.jboss.webbeans.test.AbstractWebBeansTest;
@@ -30,19 +30,19 @@
};
- private EnterpriseBean<WrappedEnterpriseBeanLocal> wrappedEnterpriseBean;
- private NewEnterpriseBean<WrappedEnterpriseBeanLocal> newEnterpriseBean;
+ private SessionBean<WrappedEnterpriseBeanLocal> wrappedEnterpriseBean;
+ private NewSessionBean<WrappedEnterpriseBeanLocal> newEnterpriseBean;
public void initNewBean()
{
Set<Bean<?>> beans = getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class);
assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class).size() == 1;
- assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class).iterator().next() instanceof EnterpriseBean;
- wrappedEnterpriseBean = (EnterpriseBean<WrappedEnterpriseBeanLocal>) getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class).iterator().next();
+ assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class).iterator().next() instanceof SessionBean;
+ wrappedEnterpriseBean = (SessionBean<WrappedEnterpriseBeanLocal>) getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class).iterator().next();
assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class, NEW_LITERAL).size() == 1;
- assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class, NEW_LITERAL).iterator().next() instanceof NewEnterpriseBean;
- newEnterpriseBean = (NewEnterpriseBean<WrappedEnterpriseBeanLocal>) getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class, NEW_LITERAL).iterator().next();
+ assert getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class, NEW_LITERAL).iterator().next() instanceof NewSessionBean;
+ newEnterpriseBean = (NewSessionBean<WrappedEnterpriseBeanLocal>) getCurrentManager().getBeans(WrappedEnterpriseBeanLocal.class, NEW_LITERAL).iterator().next();
}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/newsimple/NewSimpleBeanTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/newsimple/NewSimpleBeanTest.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/newsimple/NewSimpleBeanTest.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -5,8 +5,8 @@
import javax.enterprise.inject.New;
import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.webbeans.bean.NewSimpleBean;
-import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bean.NewManagedBean;
+import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.introspector.WBAnnotated;
import org.jboss.webbeans.literal.NewLiteral;
import org.jboss.webbeans.test.AbstractWebBeansTest;
@@ -15,20 +15,20 @@
@Artifact
public class NewSimpleBeanTest extends AbstractWebBeansTest
{
- private SimpleBean<WrappedSimpleBean> wrappedSimpleBean;
- private NewSimpleBean<WrappedSimpleBean> newSimpleBean;
+ private ManagedBean<WrappedSimpleBean> wrappedSimpleBean;
+ private NewManagedBean<WrappedSimpleBean> newSimpleBean;
private static final New NEW_LITERAL = new NewLiteral();
public void initNewBean() {
assert getCurrentManager().getBeans(WrappedSimpleBean.class).size() == 1;
- assert getCurrentManager().getBeans(WrappedSimpleBean.class).iterator().next() instanceof SimpleBean;
- wrappedSimpleBean = (SimpleBean<WrappedSimpleBean>) getCurrentManager().getBeans(WrappedSimpleBean.class).iterator().next();
+ assert getCurrentManager().getBeans(WrappedSimpleBean.class).iterator().next() instanceof ManagedBean;
+ wrappedSimpleBean = (ManagedBean<WrappedSimpleBean>) getCurrentManager().getBeans(WrappedSimpleBean.class).iterator().next();
assert getCurrentManager().getBeans(WrappedSimpleBean.class, NEW_LITERAL).size() == 1;
- assert getCurrentManager().getBeans(WrappedSimpleBean.class, NEW_LITERAL).iterator().next() instanceof NewSimpleBean;
- newSimpleBean = (NewSimpleBean<WrappedSimpleBean>) getCurrentManager().getBeans(WrappedSimpleBean.class, NEW_LITERAL).iterator().next();
+ assert getCurrentManager().getBeans(WrappedSimpleBean.class, NEW_LITERAL).iterator().next() instanceof NewManagedBean;
+ newSimpleBean = (NewManagedBean<WrappedSimpleBean>) getCurrentManager().getBeans(WrappedSimpleBean.class, NEW_LITERAL).iterator().next();
}
@Test(groups = { "new" })
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java 2009-09-14 11:34:26 UTC (rev 3658)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java 2009-09-14 11:39:54 UTC (rev 3659)
@@ -22,7 +22,7 @@
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.bean.SessionBean;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.test.AbstractWebBeansTest;
@@ -44,11 +44,11 @@
assert descriptor.getClass().equals(InternalEjbDescriptor.class);
Bean<CatLocal> bean = getCurrentManager().getBean(descriptor);
assert bean != null;
- assert bean instanceof EnterpriseBean;
+ assert bean instanceof SessionBean;
assert bean.getBeanClass().equals(Cat.class);
InjectionTarget<CatLocal> it = getCurrentManager().createInjectionTarget(descriptor);
assert it != null;
- assert it instanceof EnterpriseBean;
+ assert it instanceof SessionBean;
assert it == bean;
}
14 years, 7 months
[webbeans-commits] Webbeans SVN: r3658 - doc/trunk/reference/en-US.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-09-14 07:34:26 -0400 (Mon, 14 Sep 2009)
New Revision: 3658
Modified:
doc/trunk/reference/en-US/ri-spi.xml
Log:
Require EE resources to be serializable
Modified: doc/trunk/reference/en-US/ri-spi.xml
===================================================================
--- doc/trunk/reference/en-US/ri-spi.xml 2009-09-14 11:10:40 UTC (rev 3657)
+++ doc/trunk/reference/en-US/ri-spi.xml 2009-09-14 11:34:26 UTC (rev 3658)
@@ -239,6 +239,12 @@
<xref linkend="injection.services"/>.
</para>
</important>
+
+ <para>
+ If the container performs EE resource injection, the injected
+ resources must be serializable. If EE resource injection is provided
+ by Web Beans, the resolved resource must be serializable.
+ </para>
<tip>
<para>
14 years, 7 months
[webbeans-commits] Webbeans SVN: r3657 - in ri/branches/kabir-builder: impl/src/main/java/org/jboss/webbeans and 33 other directories.
by webbeans-commits@lists.jboss.org
Author: kabir.khan(a)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(a)jboss.org | 2009-09-06 14:18:10 +0100 (Sun, 06 Sep 2009) | 1 line
javadoc
.......
r3647 | pete.muir(a)jboss.org | 2009-09-06 15:25:02 +0100 (Sun, 06 Sep 2009) | 1 line
Remove deprecated class
.......
r3648 | pete.muir(a)jboss.org | 2009-09-06 15:35:30 +0100 (Sun, 06 Sep 2009) | 1 line
WBRI-378
.......
r3650 | pete.muir(a)jboss.org | 2009-09-06 18:45:30 +0100 (Sun, 06 Sep 2009) | 1 line
WBRI-376
.......
r3652 | pete.muir(a)jboss.org | 2009-09-07 23:53:39 +0100 (Mon, 07 Sep 2009) | 1 line
update service layer
.......
r3655 | pete.muir(a)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(a)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}
- *
- */
-@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
- *
- */
-@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
+ *
+ */
+@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
+ *
+ */
+@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
+ *
+ */
+@Artifact
+(a)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;
+ }
+
+}
14 years, 7 months
[webbeans-commits] Webbeans SVN: r3655 - ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-09-13 17:17:19 -0400 (Sun, 13 Sep 2009)
New Revision: 3655
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Cat.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/CatLocal.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java
Log:
Test EjbDescriptor
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Cat.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Cat.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Cat.java 2009-09-13 21:17:19 UTC (rev 3655)
@@ -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
+ *
+ */
+@Stateful
+public class Cat implements CatLocal
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Cat.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/CatLocal.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/CatLocal.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/CatLocal.java 2009-09-13 21:17:19 UTC (rev 3655)
@@ -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
+ *
+ */
+@Local
+public interface CatLocal
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/CatLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java 2009-09-13 21:17:19 UTC (rev 3655)
@@ -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
+ *
+ */
+@Artifact
+(a)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;
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/EjbDescriptorLookupTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 7 months