You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2012/11/07 14:29:49 UTC
svn commit: r1406619 - in /openwebbeans/trunk/webbeans-el22: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/webbeans/ src/main/java/org/apache/webbeans/el22/
src/main/resources/ src/main/resources...
Author: gerdogdu
Date: Wed Nov 7 13:29:48 2012
New Revision: 1406619
URL: http://svn.apache.org/viewvc?rev=1406619&view=rev
Log:
OWB-715 Remove EL22 implementation from Core to Own Project
Added:
openwebbeans/trunk/webbeans-el22/
openwebbeans/trunk/webbeans-el22/pom.xml
openwebbeans/trunk/webbeans-el22/src/
openwebbeans/trunk/webbeans-el22/src/main/
openwebbeans/trunk/webbeans-el22/src/main/java/
openwebbeans/trunk/webbeans-el22/src/main/java/org/
openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/
openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/
openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/
openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/EL22Adaptor.java (with props)
openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java (with props)
openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedExpressionFactory.java (with props)
openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedValueExpression.java (with props)
openwebbeans/trunk/webbeans-el22/src/main/resources/
openwebbeans/trunk/webbeans-el22/src/main/resources/META-INF/
openwebbeans/trunk/webbeans-el22/src/main/resources/META-INF/openwebbeans/
openwebbeans/trunk/webbeans-el22/src/main/resources/META-INF/openwebbeans/openwebbeans.properties (with props)
openwebbeans/trunk/webbeans-el22/src/site/
openwebbeans/trunk/webbeans-el22/src/site/site.xml
openwebbeans/trunk/webbeans-el22/src/test/
openwebbeans/trunk/webbeans-el22/src/test/java/
openwebbeans/trunk/webbeans-el22/src/test/java/org/
openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/
openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/
openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/
openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/
openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/AbstractUnitTest.java (with props)
openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java (with props)
openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/MockELContext.java (with props)
openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/RequestBean.java (with props)
openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/SampleBean.java (with props)
Added: openwebbeans/trunk/webbeans-el22/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/pom.xml?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/pom.xml (added)
+++ openwebbeans/trunk/webbeans-el22/pom.xml Wed Nov 7 13:29:48 2012
@@ -0,0 +1,83 @@
+<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">
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+-->
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans</artifactId>
+ <version>1.1.7-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>openwebbeans-el22</artifactId>
+ <name>EL 2.2 plugin</name>
+ <description>Apache OpenWebBeans EL 2.2 integration</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-el_2.2_spec</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-impl</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-spi</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
+ </dependencies>
+
+</project>
Added: openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/EL22Adaptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/EL22Adaptor.java?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/EL22Adaptor.java (added)
+++ openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/EL22Adaptor.java Wed Nov 7 13:29:48 2012
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.el22;
+
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+
+import org.apache.webbeans.spi.adaptor.ELAdaptor;
+
+public class EL22Adaptor implements ELAdaptor
+{
+ public EL22Adaptor()
+ {
+
+ }
+
+ public ELResolver getOwbELResolver()
+ {
+ return new WebBeansELResolver();
+ }
+
+ public ExpressionFactory getOwbWrappedExpressionFactory(ExpressionFactory expressionFactroy)
+ {
+ return new WrappedExpressionFactory(expressionFactroy);
+ }
+
+}
Propchange: openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/EL22Adaptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java (added)
+++ openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java Wed Nov 7 13:29:48 2012
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.el22;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.el.ELContextStore;
+
+/**
+ * JSF or JSP expression language a.k.a EL resolver.
+ *
+ * <p>
+ * EL is registered with the JSF in faces-config.xml if there exist a faces-config.xml
+ * in the application location <code>WEB-INF/</code>. Otherwise it is registered with
+ * JspApplicationContext at start-up.
+ * </p>
+ *
+ * <p>
+ * All <code>@Dependent</code> scoped contextual instances created during an EL
+ * expression evaluation are destroyed when the evaluation completes.
+ * </p>
+ *
+ * @version $Rev: 1307826 $ $Date: 2012-03-31 18:24:37 +0300 (Sat, 31 Mar 2012) $
+ *
+ */
+public class WebBeansELResolver extends ELResolver
+{
+ private WebBeansContext webBeansContext;
+
+ public WebBeansELResolver()
+ {
+ webBeansContext = WebBeansContext.getInstance();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Class<?> getCommonPropertyType(ELContext arg0, Object arg1)
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext arg0, Object arg1)
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Class<?> getType(ELContext arg0, Object arg1, Object arg2) throws ELException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @SuppressWarnings({"unchecked","deprecation"})
+ public Object getValue(ELContext context, Object obj, Object property) throws ELException
+ {
+ // Check if the OWB actually got used in this application
+ if (!webBeansContext.getBeanManagerImpl().isInUse())
+ {
+ return null;
+ }
+
+ //Bean instance
+ Object contextualInstance = null;
+ ELContextStore elContextStore = null;
+ if (obj == null)
+ {
+ //Name of the bean
+ String name = (String) property;
+ //Local store, create if not exist
+ elContextStore = ELContextStore.getInstance(true);
+
+ contextualInstance = elContextStore.findBeanByName(name);
+
+ if(contextualInstance != null)
+ {
+ context.setPropertyResolved(true);
+
+ return contextualInstance;
+ }
+
+ //Manager instance
+ BeanManagerImpl manager = elContextStore.getBeanManager();
+
+ //Get beans
+ Set<Bean<?>> beans = manager.getBeans(name);
+
+ //Found?
+ if(beans != null && !beans.isEmpty())
+ {
+ //Managed bean
+ Bean<Object> bean = (Bean<Object>)beans.iterator().next();
+
+ if(bean.getScope().equals(Dependent.class))
+ {
+ contextualInstance = getDependentContextualInstance(manager, elContextStore, context, bean);
+ }
+ else
+ {
+ // now we check for NormalScoped beans
+ contextualInstance = getNormalScopedContextualInstance(manager, elContextStore, context, bean, name);
+ }
+ }
+ }
+
+ return contextualInstance;
+ }
+
+ protected Object getNormalScopedContextualInstance(BeanManagerImpl manager, ELContextStore store, ELContext context, Bean<Object> bean, String beanName)
+ {
+ CreationalContext<Object> creationalContext = manager.createCreationalContext(bean);
+ Object contextualInstance = manager.getReference(bean, Object.class, creationalContext);
+ if (contextualInstance != null)
+ {
+ context.setPropertyResolved(true);
+ //Adding into store
+ store.addNormalScoped(beanName, contextualInstance);
+ }
+
+ return contextualInstance;
+ }
+
+
+ protected Object getDependentContextualInstance(BeanManagerImpl manager, ELContextStore store, ELContext context, Bean<Object> bean)
+ {
+ Object contextualInstance = store.getDependent(bean);
+ if(contextualInstance != null)
+ {
+ //Object found on the store
+ context.setPropertyResolved(true);
+ }
+ else
+ {
+ // If no contextualInstance found on the store
+ CreationalContext<Object> creationalContext = manager.createCreationalContext(bean);
+ contextualInstance = manager.getReference(bean, Object.class, creationalContext);
+ if (contextualInstance != null)
+ {
+ context.setPropertyResolved(true);
+ //Adding into store
+ store.addDependent(bean, contextualInstance, creationalContext);
+ }
+ }
+ return contextualInstance;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isReadOnly(ELContext arg0, Object arg1, Object arg2) throws ELException
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setValue(ELContext arg0, Object arg1, Object arg2, Object arg3) throws ELException
+ {
+
+ }
+
+}
Propchange: openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedExpressionFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedExpressionFactory.java?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedExpressionFactory.java (added)
+++ openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedExpressionFactory.java Wed Nov 7 13:29:48 2012
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.el22;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+public class WrappedExpressionFactory extends ExpressionFactory
+{
+ private ExpressionFactory expressionFactory;
+
+ public WrappedExpressionFactory(ExpressionFactory expressionFactory)
+ {
+ this.expressionFactory = expressionFactory;
+ }
+
+ @Override
+ public Object coerceToType(Object arg0, Class<?> arg1) throws ELException
+ {
+ return expressionFactory.coerceToType(arg0, arg1);
+ }
+
+ @Override
+ public MethodExpression createMethodExpression(ELContext arg0, String arg1, Class<?> arg2, Class<?>[] arg3) throws ELException, NullPointerException
+ {
+ return expressionFactory.createMethodExpression(arg0, arg1, arg2, arg3);
+ }
+
+ @Override
+ public ValueExpression createValueExpression(Object arg0, Class<?> arg1)
+ {
+ ValueExpression wrapped = expressionFactory.createValueExpression(arg0, arg1);
+
+ return new WrappedValueExpression(wrapped);
+ }
+
+ @Override
+ public ValueExpression createValueExpression(ELContext arg0, String arg1, Class<?> arg2) throws NullPointerException, ELException
+ {
+ ValueExpression wrapped = expressionFactory.createValueExpression(arg0, arg1, arg2);
+
+ return new WrappedValueExpression(wrapped);
+ }
+}
Propchange: openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedExpressionFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedValueExpression.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedValueExpression.java?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedValueExpression.java (added)
+++ openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedValueExpression.java Wed Nov 7 13:29:48 2012
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.el22;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.el.ValueExpression;
+import javax.el.ValueReference;
+
+import org.apache.webbeans.el.ELContextStore;
+
+public class WrappedValueExpression extends ValueExpression
+{
+ private static final long serialVersionUID = 1L;
+
+ private ValueExpression valueExpression;
+
+ public WrappedValueExpression(ValueExpression valueExpression)
+ {
+ this.valueExpression = valueExpression;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see javax.el.ValueExpression#getValueReference(javax.el.ELContext)
+ */
+ @Override
+ public ValueReference getValueReference(ELContext context)
+ {
+ return valueExpression.getValueReference(context);
+ }
+
+ @Override
+ public Class<?> getExpectedType()
+ {
+ return valueExpression.getExpectedType();
+ }
+
+ @Override
+ public Class<?> getType(ELContext arg0) throws NullPointerException, PropertyNotFoundException, ELException
+ {
+ return valueExpression.getType(arg0);
+ }
+
+ @Override
+ public Object getValue(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException
+ {
+ Object value = null;
+ try
+ {
+ value = valueExpression.getValue(context);
+
+ }
+ finally
+ {
+ //Destroy dependent store
+ ELContextStore store = ELContextStore.getInstance(false);
+ if(store != null)
+ {
+ store.destroyDependents();
+ }
+ }
+
+ return value;
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext arg0) throws NullPointerException, PropertyNotFoundException, ELException
+ {
+ return valueExpression.isReadOnly(arg0);
+ }
+
+ @Override
+ public void setValue(ELContext arg0, Object arg1) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException
+ {
+ valueExpression.setValue(arg0, arg1);
+ }
+
+ @Override
+ public boolean equals(Object arg0)
+ {
+ return valueExpression.equals(arg0);
+ }
+
+ @Override
+ public String getExpressionString()
+ {
+ return valueExpression.getExpressionString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return valueExpression.hashCode();
+ }
+
+ @Override
+ public boolean isLiteralText()
+ {
+ return valueExpression.isLiteralText();
+ }
+
+}
Propchange: openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WrappedValueExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-el22/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/main/resources/META-INF/openwebbeans/openwebbeans.properties (added)
+++ openwebbeans/trunk/webbeans-el22/src/main/resources/META-INF/openwebbeans/openwebbeans.properties Wed Nov 7 13:29:48 2012
@@ -0,0 +1,28 @@
+#Licensed to the Apache Software Foundation (ASF) under one
+#or more contributor license agreements. See the NOTICE file
+#distributed with this work for additional information
+#regarding copyright ownership. The ASF licenses this file
+#to you under the Apache License, Version 2.0 (the
+#"License"); you may not use this file except in compliance
+#with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing,
+#software distributed under the License is distributed on an
+#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#KIND, either express or implied. See the License for the
+#specific language governing permissions and limitations
+#under the License.
+#---------------------------------------------------------------
+# The Unified EL-2.2 configuration for OpenWebBeans
+#
+#---------------------------------------------------------------
+
+
+configuration.ordinal= 15
+
+################################### Default EL Adaptor ####################################
+#Default implementation of org.apache.webbeans.spi.adaptor.ELAdaptor
+org.apache.webbeans.spi.adaptor.ELAdaptor=org.apache.webbeans.el22.EL22Adaptor
+################################################################################################
Propchange: openwebbeans/trunk/webbeans-el22/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-el22/src/site/site.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/site/site.xml?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/site/site.xml (added)
+++ openwebbeans/trunk/webbeans-el22/src/site/site.xml Wed Nov 7 13:29:48 2012
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<project name="OpenWebBeans">
+ <bannerLeft>
+ <name>Apache OpenWebBeans</name>
+ <src>http://openwebbeans.apache.org/owb/images/logos/openwebbeans_hor.png</src>
+ <href>http://openwebbeans.apache.org</href>
+ </bannerLeft>
+
+ <bannerRight>
+ <name>Apache Banner</name>
+ <src>http://www.apache.org/images/asf-logo.gif</src>
+ <href>http://www.apache.org</href>
+ </bannerRight>
+
+ <publishDate format="dd MMM yyyy" />
+ <version position="left"/>
+
+ <body>
+ <breadcrumbs>
+ <item name="Apache" href="http://www.apache.org"/>
+ <item name="OpenWebBeans" href="http://openwebbeans.apache.org"/>
+ <item name="OWB EL-2.2" href="http://openwebbeans.apache.org/${project.version}/openwebbeans-el22"/>
+ </breadcrumbs>
+
+ <menu ref="reports"/>
+ </body>
+</project>
+
Added: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/AbstractUnitTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/AbstractUnitTest.java?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/AbstractUnitTest.java (added)
+++ openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/AbstractUnitTest.java Wed Nov 7 13:29:48 2012
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.el.test;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.config.WebBeansFinder;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.lifecycle.test.OpenWebBeansTestLifeCycle;
+import org.apache.webbeans.lifecycle.test.OpenWebBeansTestMetaDataDiscoveryService;
+import org.apache.webbeans.spi.ContainerLifecycle;
+import org.apache.webbeans.util.WebBeansUtil;
+import org.junit.Assert;
+
+
+public abstract class AbstractUnitTest
+{
+ private OpenWebBeansTestLifeCycle testLifecycle;
+ private List<Extension> extensions = new ArrayList<Extension>();
+ private WebBeansContext webBeansContext;
+
+ protected AbstractUnitTest()
+ {
+
+ }
+
+ protected void startContainer(Collection<Class<?>> beanClasses)
+ {
+ startContainer(beanClasses, null);
+ }
+
+ protected void startContainer(Collection<Class<?>> beanClasses, Collection<String> beanXmls)
+ {
+ WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader());
+ //Creates a new container
+ testLifecycle = new OpenWebBeansTestLifeCycle();
+
+ webBeansContext = WebBeansContext.getInstance();
+ for (Extension ext : extensions)
+ {
+ webBeansContext.getExtensionLoader().addExtension(ext);
+ }
+
+ //Deploy bean classes
+ OpenWebBeansTestMetaDataDiscoveryService discoveryService = (OpenWebBeansTestMetaDataDiscoveryService)webBeansContext.getScannerService();
+ discoveryService.deployClasses(beanClasses);
+ if (beanXmls != null)
+ {
+ discoveryService.deployXMLs(beanXmls);
+ }
+
+ //Start application
+ try
+ {
+ testLifecycle.startApplication(null);
+ }
+ catch (Exception e)
+ {
+ throw new WebBeansConfigurationException(e);
+ }
+
+ }
+
+ protected ContainerLifecycle getLifecycle()
+ {
+ return testLifecycle;
+ }
+
+ protected void shutDownContainer()
+ {
+ //Shwtdown application
+ if(this.testLifecycle != null)
+ {
+ this.testLifecycle.stopApplication(null);
+ }
+ }
+
+ protected WebBeansContext getWebBeansContext()
+ {
+ return this.webBeansContext;
+ }
+
+ protected BeanManager getBeanManager()
+ {
+ return this.webBeansContext.getBeanManagerImpl();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> T getInstance(Class<T> type, Annotation... qualifiers)
+ {
+ Set<Bean<?>> beans = getBeanManager().getBeans(type, qualifiers);
+ Assert.assertNotNull(beans);
+
+ Bean<?> bean = getBeanManager().resolve(beans);
+
+ return (T) getBeanManager().getReference(bean, type, getBeanManager().createCreationalContext(bean));
+ }
+
+ protected String getXmlPath(String packageName, String fileName)
+ {
+ StringBuilder prefix = new StringBuilder(packageName.replace('.', '/'));
+ prefix.append("/");
+ prefix.append(fileName);
+ prefix.append(".xml");
+
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return loader.getResource(prefix.toString()).toExternalForm();
+ }
+
+ /**
+ * Add a CDI Extension which should get used in the test case.
+ * Use this function instead of defining test Extensions via the usual
+ * META-INF/services/javax.enterprise.inject.spi.Extension file!
+ *
+ * @param ext the {@link Extension} which should get loaded
+ */
+ public void addExtension(Extension ext) {
+ this.extensions.add(ext);
+ }
+}
Propchange: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/AbstractUnitTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java (added)
+++ openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java Wed Nov 7 13:29:48 2012
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.el.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.el22.WebBeansELResolver;
+import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.el.ELContext;
+
+public class ELPerformanceTest extends AbstractUnitTest
+{
+ private final static int THREADS = 100;
+ private final static int ITERATIONS = 200;
+
+
+ private static Logger logger = WebBeansLoggerFacade.getLogger(ELPerformanceTest.class);
+
+ /**
+ * Test our bean creation for thread safety.
+ */
+ @Test
+ public void testBeanCreation() throws Exception
+ {
+ Collection<Class<?>> classes = new ArrayList<Class<?>>();
+
+ classes.add(SampleBean.class);
+ classes.add(RequestBean.class);
+
+ // we need this to enable the EL resolver at all!
+
+ startContainer(classes);
+
+ List<ParallelBeanStarter> strarters = new ArrayList<ParallelBeanStarter>();
+ WebBeansELResolver resolver = new WebBeansELResolver();
+
+ long start = System.nanoTime();
+
+ for(int i=0; i<THREADS; i++)
+ {
+ ParallelBeanStarter starter = new ParallelBeanStarter(resolver);
+ strarters.add(starter);
+ starter.start();
+ }
+
+ for(ParallelBeanStarter starter : strarters)
+ {
+ starter.join();
+ }
+
+ long end = System.nanoTime();
+
+ logger.log(Level.INFO, "Executing {0} threads with {1} iterations took {2} ns", WebBeansLoggerFacade.args(THREADS, ITERATIONS, end - start));
+
+ shutDownContainer();
+ }
+
+ private static class ParallelBeanStarter extends Thread
+ {
+ private WebBeansELResolver resolver;
+ private ELContext elctx = new MockELContext();
+ private static AtomicInteger n = new AtomicInteger(0);
+
+ public ParallelBeanStarter(WebBeansELResolver resolver)
+ {
+ this.resolver = resolver;
+ }
+
+ @Override
+ public void run()
+ {
+ WebBeansContext.currentInstance().getContextFactory().initRequestContext(null);
+ WebBeansContext.currentInstance().getContextFactory().initSessionContext(null);
+
+ try
+ {
+ for (int i = 0; i < ITERATIONS; i++)
+ {
+ SampleBean sb = (SampleBean) resolver.getValue(elctx , null, "sampleBean");
+ sb.getRb().getY();
+ sb.getX();
+ }
+ }
+ catch(RuntimeException e)
+ {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ Assert.fail("got an exception: " + e.getMessage());
+ throw e;
+ }
+ finally
+ {
+ WebBeansContext.currentInstance().getContextFactory().destroyRequestContext(null);
+ WebBeansContext.currentInstance().getContextFactory().destroySessionContext(null);
+ }
+ }
+ }
+}
Propchange: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/ELPerformanceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/MockELContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/MockELContext.java?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/MockELContext.java (added)
+++ openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/MockELContext.java Wed Nov 7 13:29:48 2012
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.el.test;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.VariableMapper;
+
+public class MockELContext extends ELContext
+{
+
+ @Override
+ public ELResolver getELResolver()
+ {
+ return null;
+ }
+
+ @Override
+ public FunctionMapper getFunctionMapper()
+ {
+ return null;
+ }
+
+ @Override
+ public VariableMapper getVariableMapper()
+ {
+ return null;
+ }
+
+}
Propchange: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/MockELContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/RequestBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/RequestBean.java?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/RequestBean.java (added)
+++ openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/RequestBean.java Wed Nov 7 13:29:48 2012
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.el.test;
+
+import javax.enterprise.context.RequestScoped;
+import java.io.Serializable;
+
+@RequestScoped
+public class RequestBean implements Serializable
+{
+ private int y = 323;
+
+ public int getY()
+ {
+ return y;
+ }
+
+ public void setY(int y)
+ {
+ this.y = y;
+ }
+}
Propchange: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/RequestBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/SampleBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/SampleBean.java?rev=1406619&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/SampleBean.java (added)
+++ openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/SampleBean.java Wed Nov 7 13:29:48 2012
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.el.test;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@SessionScoped
+@Named
+public class SampleBean implements Serializable
+{
+ private int x=121;
+ private @Inject RequestBean rb;
+
+ public int getX()
+ {
+ return x;
+ }
+
+ public void setX(int x)
+ {
+ this.x = x;
+ }
+
+ public RequestBean getRb()
+ {
+ return rb;
+ }
+
+ public void setRb(RequestBean rb)
+ {
+ this.rb = rb;
+ }
+}
Propchange: openwebbeans/trunk/webbeans-el22/src/test/java/org/apache/webbeans/el/test/SampleBean.java
------------------------------------------------------------------------------
svn:eol-style = native