cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject git commit: Update the @FactoryType annotation to remove the spring ref and prepare for possible package changes for 3.1
Date Thu, 01 May 2014 17:47:47 GMT
Repository: cxf
Updated Branches:
  refs/heads/master ffbb46fe6 -> d78f8c657


Update the @FactoryType annotation to remove the spring ref and prepare for possible package
changes for 3.1


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

Branch: refs/heads/master
Commit: d78f8c6576086db2baa5d467ff8c506466ce3859
Parents: ffbb46f
Author: Daniel Kulp <dkulp@apache.org>
Authored: Thu May 1 13:47:10 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu May 1 13:47:10 2014 -0400

----------------------------------------------------------------------
 .../org/apache/cxf/annotations/FactoryType.java | 16 +++--
 .../factory/AnnotationsFactoryBeanListener.java |  4 --
 .../cxf/service/invoker/SpringBeanFactory.java  | 61 ------------------
 .../invoker/spring/SpringBeanFactory.java       | 65 ++++++++++++++++++++
 .../http/SpringAnnotationGreeterImpl.java       |  4 +-
 5 files changed, 79 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d78f8c65/core/src/main/java/org/apache/cxf/annotations/FactoryType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/annotations/FactoryType.java b/core/src/main/java/org/apache/cxf/annotations/FactoryType.java
index e9a83b7..7da7f33 100644
--- a/core/src/main/java/org/apache/cxf/annotations/FactoryType.java
+++ b/core/src/main/java/org/apache/cxf/annotations/FactoryType.java
@@ -24,6 +24,9 @@ import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
+
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.service.invoker.Factory;
 /**
  * Defines the factory used for the service.
  * 
@@ -45,16 +48,21 @@ public @interface FactoryType {
      *    1) The Class for the service
      *    2) String[] of the args from above 
      */
-    Class<?> factoryClass() default DEFAULT.class;
+    Class<? extends Factory> factoryClass() default DEFAULT.class;
     
     enum Type {
         Singleton,
         Session,
         Pooled, //args[0] is the size of the pool
-        PerRequest,
-        Spring, //args[0] is the Spring bean name
+        PerRequest
     };
     
-    static final class DEFAULT { }
+    static final class DEFAULT implements Factory {
+        public Object create(Exchange e) throws Throwable {
+            return null;
+        }
+        public void release(Exchange e, Object o) {
+        }
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/d78f8c65/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
b/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
index 655eb68..5c6a9ee 100644
--- a/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
+++ b/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
@@ -53,7 +53,6 @@ import org.apache.cxf.service.invoker.PerRequestFactory;
 import org.apache.cxf.service.invoker.PooledFactory;
 import org.apache.cxf.service.invoker.SessionFactory;
 import org.apache.cxf.service.invoker.SingletonFactory;
-import org.apache.cxf.service.invoker.SpringBeanFactory;
 import org.apache.cxf.service.model.BindingFaultInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.FaultInfo;
@@ -190,9 +189,6 @@ public class AnnotationsFactoryBeanListener implements FactoryBeanListener
{
                     case Pooled:
                         f = new PooledFactory(cls, Integer.parseInt(scope.args()[0]));
                         break;
-                    case Spring:
-                        f = new SpringBeanFactory(scope.args()[0]);
-                        break;
                     default:
                         f = new SingletonFactory(cls);
                         break;

http://git-wip-us.apache.org/repos/asf/cxf/blob/d78f8c65/core/src/main/java/org/apache/cxf/service/invoker/SpringBeanFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/service/invoker/SpringBeanFactory.java b/core/src/main/java/org/apache/cxf/service/invoker/SpringBeanFactory.java
deleted file mode 100644
index f942019..0000000
--- a/core/src/main/java/org/apache/cxf/service/invoker/SpringBeanFactory.java
+++ /dev/null
@@ -1,61 +0,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.
- */
-
-package org.apache.cxf.service.invoker;
-
-import org.apache.cxf.message.Exchange;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Factory that will query the Spring ApplicationContext for the 
- * appropriate bean for each request.
- * 
- * This can be expensive.  If the bean is "prototype" or similar such that a 
- * new instance is created each time, this could slow things down.  In that 
- * case, it's recommended to use this in conjunction with the PooledFactory
- * to pool the beans or the SessionFactory or similar.
- */
-public class SpringBeanFactory implements Factory, ApplicationContextAware {
-    ApplicationContext ctx;
-    String beanName;
-    
-    public SpringBeanFactory(String name) {
-        beanName = name;
-    }
-    
-    /** {@inheritDoc}*/
-    public Object create(Exchange e) throws Throwable {
-        if (ctx == null) {
-            ctx = e.getBus().getExtension(ApplicationContext.class);
-        }
-        return ctx.getBean(beanName);
-    }
-
-    /** {@inheritDoc}*/
-    public void release(Exchange e, Object o) {
-        //nothing
-    }
-
-    public void setApplicationContext(ApplicationContext arg0) throws BeansException {
-        ctx = arg0;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/d78f8c65/core/src/main/java/org/apache/cxf/service/invoker/spring/SpringBeanFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/service/invoker/spring/SpringBeanFactory.java
b/core/src/main/java/org/apache/cxf/service/invoker/spring/SpringBeanFactory.java
new file mode 100644
index 0000000..ef16680
--- /dev/null
+++ b/core/src/main/java/org/apache/cxf/service/invoker/spring/SpringBeanFactory.java
@@ -0,0 +1,65 @@
+/**
+ * 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.cxf.service.invoker.spring;
+
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.service.invoker.Factory;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Factory that will query the Spring ApplicationContext for the 
+ * appropriate bean for each request.
+ * 
+ * This can be expensive.  If the bean is "prototype" or similar such that a 
+ * new instance is created each time, this could slow things down.  In that 
+ * case, it's recommended to use this in conjunction with the PooledFactory
+ * to pool the beans or the SessionFactory or similar.
+ */
+public class SpringBeanFactory implements Factory, ApplicationContextAware {
+    volatile ApplicationContext ctx;
+    final String beanName;
+    
+    public SpringBeanFactory(String name) {
+        beanName = name;
+    }
+    public SpringBeanFactory(Class<?> c, String[] args) {
+        beanName = args[0];
+    }
+    
+    /** {@inheritDoc}*/
+    public Object create(Exchange e) throws Throwable {
+        if (ctx == null) {
+            ctx = e.getBus().getExtension(ApplicationContext.class);
+        }
+        return ctx.getBean(beanName);
+    }
+
+    /** {@inheritDoc}*/
+    public void release(Exchange e, Object o) {
+        //nothing
+    }
+
+    public void setApplicationContext(ApplicationContext arg0) throws BeansException {
+        ctx = arg0;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/d78f8c65/systests/transports/src/test/java/org/apache/cxf/systest/http/SpringAnnotationGreeterImpl.java
----------------------------------------------------------------------
diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/http/SpringAnnotationGreeterImpl.java
b/systests/transports/src/test/java/org/apache/cxf/systest/http/SpringAnnotationGreeterImpl.java
index c9a9b8b..c7265e7 100644
--- a/systests/transports/src/test/java/org/apache/cxf/systest/http/SpringAnnotationGreeterImpl.java
+++ b/systests/transports/src/test/java/org/apache/cxf/systest/http/SpringAnnotationGreeterImpl.java
@@ -24,18 +24,18 @@ import javax.jws.WebService;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Response;
 
-
 import org.apache.cxf.annotations.FactoryType;
 import org.apache.cxf.greeter_control.Greeter;
 import org.apache.cxf.greeter_control.types.GreetMeResponse;
 import org.apache.cxf.greeter_control.types.PingMeResponse;
 import org.apache.cxf.greeter_control.types.SayHiResponse;
+import org.apache.cxf.service.invoker.spring.SpringBeanFactory;
 
 @WebService(serviceName = "GreeterService",
             portName = "GreeterPort",
             endpointInterface = "org.apache.cxf.greeter_control.Greeter", 
             targetNamespace = "http://cxf.apache.org/greeter_control")
-@FactoryType(value = FactoryType.Type.Spring, args = { "SpringBean" })
+@FactoryType(factoryClass = SpringBeanFactory.class, args = { "SpringBean" })
 public class SpringAnnotationGreeterImpl implements Greeter {
     String name;
     


Mime
View raw message