Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split porting impl into separate project, move mock to main
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1435 1c488680-804c-0410-94cd-c6b725194a0e
- Loading branch information
Showing
25 changed files
with
321 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<parent> | ||
<artifactId>parent</artifactId> | ||
<groupId>org.jboss.webbeans</groupId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.jboss.webbeans</groupId> | ||
<artifactId>porting-package</artifactId> | ||
<name>Web Beans Porting Package for JSR-299 TCK</name> | ||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.jboss.webbeans</groupId> | ||
<artifactId>webbeans-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.webbeans</groupId> | ||
<artifactId>webbeans-ri</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.webbeans.tck</groupId> | ||
<artifactId>webbeans-tck-api</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
121 changes: 121 additions & 0 deletions
121
porting-package/src/main/java/org/jboss/webbeans/porting/BeansImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package org.jboss.webbeans.porting; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Method; | ||
|
||
import javax.inject.manager.Bean; | ||
|
||
import org.jboss.webbeans.CurrentManager; | ||
import org.jboss.webbeans.bean.AbstractClassBean; | ||
import org.jboss.webbeans.bean.EnterpriseBean; | ||
import org.jboss.webbeans.bean.ProducerFieldBean; | ||
import org.jboss.webbeans.bean.ProducerMethodBean; | ||
import org.jboss.webbeans.bean.SimpleBean; | ||
import org.jboss.webbeans.ejb.spi.EjbDescriptor; | ||
import org.jboss.webbeans.mock.MockEjbDescriptor; | ||
import org.jboss.webbeans.tck.spi.Beans; | ||
import org.jboss.webbeans.util.Reflections; | ||
|
||
/** | ||
* Implements the Beans SPI for the TCK specifically for the JBoss RI. | ||
* | ||
* @author Shane Bryzak | ||
* @author Pete Muir | ||
* @author David Allen | ||
* | ||
*/ | ||
@Deprecated | ||
public class BeansImpl implements Beans | ||
{ | ||
|
||
public <T> Bean<T> createSimpleBean(Class<T> clazz) | ||
{ | ||
return SimpleBean.of(clazz, CurrentManager.rootManager()); | ||
} | ||
|
||
public <T> Bean<T> createProducerMethodBean(Method method, Bean<?> declaringBean) | ||
{ | ||
if (declaringBean instanceof AbstractClassBean) | ||
{ | ||
return ProducerMethodBean.of(method, (AbstractClassBean<?>) declaringBean, CurrentManager.rootManager()); | ||
} | ||
else | ||
{ | ||
throw new IllegalStateException("Cannot create a producer method from a bean that wasn't created by the RI " + declaringBean); | ||
} | ||
} | ||
|
||
public <T> Bean<T> createProducerFieldBean(Field field, Bean<?> declaringBean) | ||
{ | ||
if (declaringBean instanceof AbstractClassBean) | ||
{ | ||
return ProducerFieldBean.of(field, (AbstractClassBean<?>) declaringBean, CurrentManager.rootManager()); | ||
} | ||
else | ||
{ | ||
throw new IllegalStateException("Cannot create a producer field from a bean that wasn't created by the RI " + declaringBean); | ||
} | ||
} | ||
|
||
public <T> Bean<T> createEnterpriseBean(Class<T> clazz) | ||
{ | ||
CurrentManager.rootManager().getEjbDescriptorCache().add(MockEjbDescriptor.of(clazz)); | ||
return EnterpriseBean.of(clazz, CurrentManager.rootManager()); | ||
} | ||
|
||
public boolean isEnterpriseBean(Class<?> clazz) | ||
{ | ||
return CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz); | ||
} | ||
|
||
public boolean isEntityBean(Class<?> clazz) | ||
{ | ||
if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz)) | ||
{ | ||
for (EjbDescriptor<?> ejbDescriptor : CurrentManager.rootManager().getEjbDescriptorCache().get(clazz)) | ||
{ | ||
if (!ejbDescriptor.isMessageDriven() && !ejbDescriptor.isSingleton() && !ejbDescriptor.isStateful() && !ejbDescriptor.isStateless()) | ||
{ | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public boolean isStatefulBean(Class<?> clazz) | ||
{ | ||
if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz)) | ||
{ | ||
for (EjbDescriptor<?> ejbDescriptor : CurrentManager.rootManager().getEjbDescriptorCache().get(clazz)) | ||
{ | ||
if (ejbDescriptor.isStateful()) | ||
{ | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public boolean isStatelessBean(Class<?> clazz) | ||
{ | ||
if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz)) | ||
{ | ||
for (EjbDescriptor<?> ejbDescriptor : CurrentManager.rootManager().getEjbDescriptorCache().get(clazz)) | ||
{ | ||
if (ejbDescriptor.isStateless()) | ||
{ | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public boolean isProxy(Object instance) | ||
{ | ||
return Reflections.isProxy(instance); | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
porting-package/src/main/java/org/jboss/webbeans/porting/ContainersImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.jboss.webbeans.porting; | ||
|
||
import java.io.InputStream; | ||
import java.lang.annotation.Annotation; | ||
import java.util.List; | ||
|
||
import javax.el.ELContext; | ||
import javax.inject.manager.Manager; | ||
|
||
import org.jboss.webbeans.ManagerImpl; | ||
import org.jboss.webbeans.mock.MockBootstrap; | ||
import org.jboss.webbeans.mock.MockWebBeanDiscovery; | ||
import org.jboss.webbeans.mock.el.EL; | ||
import org.jboss.webbeans.tck.spi.StandaloneContainers; | ||
|
||
public class ContainersImpl implements StandaloneContainers | ||
{ | ||
|
||
public Manager deploy(List<Class<? extends Annotation>> enabledDeploymentTypes, Class<?>... classes) | ||
{ | ||
MockBootstrap bootstrap = new MockBootstrap(); | ||
ManagerImpl manager = bootstrap.getManager(); | ||
if (enabledDeploymentTypes != null) | ||
{ | ||
manager.setEnabledDeploymentTypes(enabledDeploymentTypes); | ||
} | ||
bootstrap.setWebBeanDiscovery(new MockWebBeanDiscovery(classes)); | ||
bootstrap.boot(); | ||
return manager; | ||
} | ||
|
||
public Manager deploy(java.lang.Class<?>... classes) | ||
{ | ||
return deploy(null, classes); | ||
} | ||
|
||
public Manager deploy(InputStream archive) | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public Manager deploy(List<Class<? extends Annotation>> enabledDeploymentTypes, InputStream archive) | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public <T> T evaluateValueExpression(String expression, Class<T> expectedType) | ||
{ | ||
ELContext elContext = EL.createELContext(); | ||
return (T) EL.EXPRESSION_FACTORY.createValueExpression(elContext, expression, expectedType).getValue(elContext); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public <T> T evaluateMethodExpression(String expression, Class<T> expectedType, Class<?>[] expectedParamTypes, Object[] expectedParams) | ||
{ | ||
ELContext elContext = EL.createELContext(); | ||
return (T) EL.EXPRESSION_FACTORY.createMethodExpression(elContext, expression, expectedType, expectedParamTypes).invoke(elContext, expectedParams); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
porting-package/src/main/java/org/jboss/webbeans/porting/ContextsImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.jboss.webbeans.porting; | ||
|
||
import org.jboss.webbeans.context.AbstractBeanMapContext; | ||
import org.jboss.webbeans.context.AbstractContext; | ||
import org.jboss.webbeans.context.DependentContext; | ||
import org.jboss.webbeans.context.RequestContext; | ||
import org.jboss.webbeans.tck.spi.Contexts; | ||
|
||
public class ContextsImpl implements Contexts<AbstractContext> | ||
{ | ||
|
||
public RequestContext getRequestContext() | ||
{ | ||
return RequestContext.INSTANCE; | ||
} | ||
|
||
public void setActive(AbstractContext context) | ||
{ | ||
context.setActive(true); | ||
} | ||
|
||
public void setInactive(AbstractContext context) | ||
{ | ||
context.setActive(false); | ||
} | ||
|
||
public AbstractContext getDependentContext() | ||
{ | ||
return DependentContext.INSTANCE; | ||
} | ||
|
||
public void destroyContext(AbstractContext context) | ||
{ | ||
if (context instanceof AbstractBeanMapContext) | ||
{ | ||
((AbstractBeanMapContext) context).destroy(); | ||
} | ||
else | ||
{ | ||
throw new UnsupportedOperationException(); | ||
} | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
porting-package/src/main/java/org/jboss/webbeans/porting/ManagersImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.jboss.webbeans.porting; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.List; | ||
|
||
import javax.inject.manager.Manager; | ||
|
||
import org.jboss.webbeans.CurrentManager; | ||
import org.jboss.webbeans.tck.spi.Managers; | ||
|
||
public class ManagersImpl implements Managers | ||
{ | ||
|
||
public Manager getManager() | ||
{ | ||
return CurrentManager.rootManager(); | ||
} | ||
|
||
public void setEnabledDeploymentTypes(List<Class<? extends Annotation>> enabledDeploymentTypes) | ||
{ | ||
CurrentManager.rootManager().setEnabledDeploymentTypes(enabledDeploymentTypes); | ||
} | ||
|
||
public List<Class<? extends Annotation>> getEnabledDeploymentTypes() | ||
{ | ||
return CurrentManager.rootManager().getEnabledDeploymentTypes(); | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
porting-package/src/main/resources/META-INF/web-beans-tck.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
org.jboss.webbeans.tck.spi.Managers=org.jboss.webbeans.porting.ManagersImpl | ||
org.jboss.webbeans.tck.spi.Beans=org.jboss.webbeans.porting.BeansImpl | ||
org.jboss.webbeans.tck.spi.Contexts=org.jboss.webbeans.porting.ContextsImpl | ||
org.jboss.webbeans.tck.spi.Containers=org.jboss.webbeans.porting.ContainersImpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...webbeans/test/mock/MockEjbDescriptor.java → ...boss/webbeans/mock/MockEjbDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../webbeans/test/mock/MockEjbDiscovery.java → ...jboss/webbeans/mock/MockEjbDiscovery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ebbeans/test/mock/MockResourceLoader.java → ...oss/webbeans/mock/MockResourceLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...beans/test/mock/MockWebBeanDiscovery.java → ...s/webbeans/mock/MockWebBeanDiscovery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../mock/context/MockApplicationContext.java → .../mock/context/MockApplicationContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...st/mock/context/MockDependentContext.java → ...ns/mock/context/MockDependentContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.