openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1607767 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/container/ webbeans-impl/src/main/resources/META-INF/services/ webbeans-impl/src/test/java/org/apache/webbeans/container/ webbeans-tck/
Date Thu, 03 Jul 2014 23:17:53 GMT
Author: rmannibucau
Date: Thu Jul  3 23:17:53 2014
New Revision: 1607767

URL: http://svn.apache.org/r1607767
Log:
basic CDI implementation, mainly only allows to get the bean manager (Instance contract is
not that respected)

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDI.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDIProvider.java
    openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/services/
    openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.CDIProvider
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/OwbCDIProviderTest.java
Modified:
    openwebbeans/trunk/webbeans-tck/testng-dev.xml

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDI.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDI.java?rev=1607767&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDI.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDI.java
Thu Jul  3 23:17:53 2014
@@ -0,0 +1,108 @@
+/*
+ * 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.container;
+
+import org.apache.webbeans.component.InstanceBean;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
+import org.apache.webbeans.inject.instance.InstanceImpl;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.CDI;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.util.TypeLiteral;
+import javax.inject.Inject;
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
+
+public class OwbCDI extends CDI<Object>
+{
+    @Inject
+    private Instance<Object> injectionPoint;
+
+    private WebBeansContext getWebBeansContext()
+    {
+        return WebBeansContext.currentInstance();
+    }
+
+    protected Instance<Object> instance()
+    {
+        final WebBeansContext webBeansContext = getWebBeansContext();
+        final BeanManagerImpl bm = webBeansContext.getBeanManagerImpl();
+        final CreationalContextImpl<Instance<Object>> creationalContext = bm.createCreationalContext(null);
+        final InjectionPoint injectionPoint1 = bm.createInjectionTarget(bm.createAnnotatedType(OwbCDI.class)).getInjectionPoints().iterator().next();
+        creationalContext.putInjectionPoint(injectionPoint1);
+        return new InstanceBean<Object>(webBeansContext).create(creationalContext);
+    }
+
+    @Override
+    public BeanManager getBeanManager()
+    {
+        return getWebBeansContext().getBeanManagerImpl();
+    }
+
+    @Override
+    public Instance<Object> select(final Annotation... qualifiers)
+    {
+        return instance().select(qualifiers);
+    }
+
+    @Override
+    public boolean isUnsatisfied()
+    {
+        return instance().isUnsatisfied();
+    }
+
+    @Override
+    public boolean isAmbiguous()
+    {
+        return instance().isAmbiguous();
+    }
+
+    @Override
+    public void destroy(final Object instance)
+    {
+        InstanceImpl.class.cast(instance).destroy(instance);
+    }
+
+    @Override
+    public <U extends Object> Instance<U> select(final TypeLiteral<U> subtype,
final Annotation... qualifiers)
+    {
+        return instance().select(subtype, qualifiers);
+    }
+
+    @Override
+    public <U extends Object> Instance<U> select(final Class<U> subtype,
final Annotation... qualifiers)
+    {
+        return instance().select(subtype, qualifiers);
+    }
+
+    @Override
+    public Iterator<Object> iterator()
+    {
+        return instance().iterator();
+    }
+
+    @Override
+    public Object get()
+    {
+        return instance().get();
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDIProvider.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDIProvider.java?rev=1607767&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDIProvider.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDIProvider.java
Thu Jul  3 23:17:53 2014
@@ -0,0 +1,33 @@
+/*
+ * 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.container;
+
+import javax.enterprise.inject.spi.CDI;
+import javax.enterprise.inject.spi.CDIProvider;
+
+public class OwbCDIProvider implements CDIProvider
+{
+    private static final OwbCDI OWB_CDI = new OwbCDI();
+
+    @Override
+    public CDI<Object> getCDI()
+    {
+        return OWB_CDI;
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.CDIProvider
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.CDIProvider?rev=1607767&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.CDIProvider
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.CDIProvider
Thu Jul  3 23:17:53 2014
@@ -0,0 +1,17 @@
+#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.
+org.apache.webbeans.container.OwbCDIProvider

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/OwbCDIProviderTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/OwbCDIProviderTest.java?rev=1607767&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/OwbCDIProviderTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/container/OwbCDIProviderTest.java
Thu Jul  3 23:17:53 2014
@@ -0,0 +1,41 @@
+/*
+ * 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.container;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+import javax.enterprise.inject.spi.CDI;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class OwbCDIProviderTest extends AbstractUnitTest
+{
+    @Test
+    public void run()
+    {
+        startContainer(OwbCDIProviderTest.class);
+        assertNotNull(CDI.current());
+        assertNotNull(CDI.current().getBeanManager());
+        assertFalse(CDI.current().isUnsatisfied());
+        assertTrue(CDI.current().isAmbiguous());
+    }
+}

Modified: openwebbeans/trunk/webbeans-tck/testng-dev.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/testng-dev.xml?rev=1607767&r1=1607766&r2=1607767&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/testng-dev.xml (original)
+++ openwebbeans/trunk/webbeans-tck/testng-dev.xml Thu Jul  3 23:17:53 2014
@@ -18,7 +18,7 @@
 <suite name="JSR-346-TCK" verbose="2" configfailurepolicy="continue">
   <test name="JSR-346 TCK">
     <classes>
-      <class name="org.jboss.cdi.tck.tests.event.resolve.typeWithParameters.CheckTypeParametersWhenResolvingObserversTest"
/>
+      <class name="org.jboss.cdi.tck.tests.decorators.interceptor.DecoratorAndInterceptorTest"
/>
       <!--
       <class name="org.jboss.cdi.tck.tests.event.parameterized.ParameterizedEventTest"
/>
       <class name="org.jboss.cdi.tck.tests.event.fires.FireEventTest" />



Mime
View raw message