roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [2/2] roller git commit: So far unsuccessful experiments with CdiWebloggerProvider
Date Sat, 20 Oct 2018 18:48:01 GMT
So far unsuccessful experiments with CdiWebloggerProvider


Project: http://git-wip-us.apache.org/repos/asf/roller/repo
Commit: http://git-wip-us.apache.org/repos/asf/roller/commit/8192321f
Tree: http://git-wip-us.apache.org/repos/asf/roller/tree/8192321f
Diff: http://git-wip-us.apache.org/repos/asf/roller/diff/8192321f

Branch: refs/heads/java10
Commit: 8192321fde942c4d802a4697d3ba9d3119a244ea
Parents: b7f4daa
Author: Dave Johnson <snoopdave@gmail.com>
Authored: Sat Oct 20 14:47:57 2018 -0400
Committer: Dave Johnson <snoopdave@gmail.com>
Committed: Sat Oct 20 14:47:57 2018 -0400

----------------------------------------------------------------------
 app/pom.xml                                     |  6 ++++
 .../business/CdiWebloggerProvider.java          | 15 ++++++----
 .../weblogger/business/WebloggerImpl.java       |  2 ++
 .../business/jpa/JPAWebloggerImpl.java          |  3 ++
 app/src/main/resources/META-INF/beans.xml       | 23 +++++++++++++++
 app/src/main/resources/logback.xml              | 13 +++++++++
 .../roller/weblogger/business/SimpleTest.java   | 30 ++++++++++++++++++++
 app/src/test/resources/roller-custom.properties |  3 ++
 8 files changed, 90 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/roller/blob/8192321f/app/pom.xml
----------------------------------------------------------------------
diff --git a/app/pom.xml b/app/pom.xml
index 843da76..4d6910a 100644
--- a/app/pom.xml
+++ b/app/pom.xml
@@ -371,6 +371,12 @@ limitations under the License.
         </dependency>
 
         <dependency>
+            <groupId>org.jboss.weld.se</groupId>
+            <artifactId>weld-se-core</artifactId>
+            <version>3.0.5.Final</version>
+        </dependency>
+
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
             <version>${slf4j.version}</version>

http://git-wip-us.apache.org/repos/asf/roller/blob/8192321f/app/src/main/java/org/apache/roller/weblogger/business/CdiWebloggerProvider.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/roller/weblogger/business/CdiWebloggerProvider.java
b/app/src/main/java/org/apache/roller/weblogger/business/CdiWebloggerProvider.java
index e879ff5..eaf8c09 100644
--- a/app/src/main/java/org/apache/roller/weblogger/business/CdiWebloggerProvider.java
+++ b/app/src/main/java/org/apache/roller/weblogger/business/CdiWebloggerProvider.java
@@ -18,19 +18,24 @@
 
 package org.apache.roller.weblogger.business;
 
-import org.apache.roller.weblogger.business.BootstrapException;
-import org.apache.roller.weblogger.business.Weblogger;
-import org.apache.roller.weblogger.business.WebloggerProvider;
+import org.apache.roller.weblogger.business.jpa.JPAWebloggerImpl;
+import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
 
 
 public class CdiWebloggerProvider implements WebloggerProvider {
+
+    Weblogger weblogger;
+
     @Override
     public void bootstrap() throws BootstrapException {
-
+        Weld weld = new Weld();
+        WeldContainer container = weld.initialize();
+        weblogger = container.select(JPAWebloggerImpl.class).get();
     }
 
     @Override
     public Weblogger getWeblogger() {
-        return null;
+        return weblogger;
     }
 }

http://git-wip-us.apache.org/repos/asf/roller/blob/8192321f/app/src/main/java/org/apache/roller/weblogger/business/WebloggerImpl.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/roller/weblogger/business/WebloggerImpl.java b/app/src/main/java/org/apache/roller/weblogger/business/WebloggerImpl.java
index 1cf6359..53894fc 100644
--- a/app/src/main/java/org/apache/roller/weblogger/business/WebloggerImpl.java
+++ b/app/src/main/java/org/apache/roller/weblogger/business/WebloggerImpl.java
@@ -34,6 +34,8 @@ import org.apache.roller.weblogger.business.runnable.ThreadManager;
 import org.apache.roller.weblogger.business.themes.ThemeManager;
 import org.apache.roller.weblogger.config.PingConfig;
 
+import javax.enterprise.inject.Alternative;
+
 
 /**
  * The abstract version of the Weblogger implementation.

http://git-wip-us.apache.org/repos/asf/roller/blob/8192321f/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.java
b/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.java
index a06c4da..b612f18 100644
--- a/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.java
+++ b/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.java
@@ -39,10 +39,13 @@ import org.apache.roller.weblogger.business.plugins.PluginManager;
 import org.apache.roller.weblogger.business.search.IndexManager;
 import org.apache.roller.weblogger.business.themes.ThemeManager;
 
+import javax.enterprise.inject.Default;
+
 /**
  * A JPA specific implementation of the Weblogger business layer.
  */
 @com.google.inject.Singleton
+@Default
 public class JPAWebloggerImpl extends WebloggerImpl {
 
     // a persistence utility class

http://git-wip-us.apache.org/repos/asf/roller/blob/8192321f/app/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/app/src/main/resources/META-INF/beans.xml b/app/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..402c564
--- /dev/null
+++ b/app/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+  http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>

http://git-wip-us.apache.org/repos/asf/roller/blob/8192321f/app/src/main/resources/logback.xml
----------------------------------------------------------------------
diff --git a/app/src/main/resources/logback.xml b/app/src/main/resources/logback.xml
new file mode 100644
index 0000000..7d900d8
--- /dev/null
+++ b/app/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+            </pattern>
+        </encoder>
+    </appender>
+
+    <root level="INFO">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/roller/blob/8192321f/app/src/test/java/org/apache/roller/weblogger/business/SimpleTest.java
----------------------------------------------------------------------
diff --git a/app/src/test/java/org/apache/roller/weblogger/business/SimpleTest.java b/app/src/test/java/org/apache/roller/weblogger/business/SimpleTest.java
new file mode 100644
index 0000000..0284a90
--- /dev/null
+++ b/app/src/test/java/org/apache/roller/weblogger/business/SimpleTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.business;
+
+import org.apache.roller.weblogger.TestUtils;
+import org.junit.Test;
+
+public class SimpleTest {
+
+    @Test
+    public void testSetupWeblogger() throws Exception {
+        TestUtils.setupWeblogger();
+    }
+}

http://git-wip-us.apache.org/repos/asf/roller/blob/8192321f/app/src/test/resources/roller-custom.properties
----------------------------------------------------------------------
diff --git a/app/src/test/resources/roller-custom.properties b/app/src/test/resources/roller-custom.properties
index af72133..62da734 100644
--- a/app/src/test/resources/roller-custom.properties
+++ b/app/src/test/resources/roller-custom.properties
@@ -1,3 +1,4 @@
+
 database.configurationType=jdbc
 database.jdbc.driverClass=org.apache.derby.jdbc.ClientDriver
 database.jdbc.connectionURL=jdbc:derby://localhost:4224/memory:rollerdb
@@ -14,6 +15,8 @@ hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFac
 
 # turn off transaction manager during JUnit testing (TODO: find way to activate for JUnit
tests)
 
+weblogger.provider.class=org.apache.roller.weblogger.business.CdiWebloggerProvider
+
 # use plain text passwords in testing
 passwds.encryption.enabled=false
 


Mime
View raw message