You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/10/18 22:04:19 UTC
svn commit: r1023971 - in
/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service:
factory/AnnotationsFactoryBeanListener.java invoker/FactoryInvoker.java
invoker/Messages.properties invoker/SessionFactory.java
Author: dkulp
Date: Mon Oct 18 20:04:18 2010
New Revision: 1023971
URL: http://svn.apache.org/viewvc?rev=1023971&view=rev
Log:
Fix some fault messages
Add ability for SessionFactory to not create if not already in the
session.
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/FactoryInvoker.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/Messages.properties
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionFactory.java
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java?rev=1023971&r1=1023970&r2=1023971&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java Mon Oct 18 20:04:18 2010
@@ -167,7 +167,11 @@ public class AnnotationsFactoryBeanListe
if (scope.factoryClass() == FactoryType.DEFAULT.class) {
switch (scope.value()) {
case Session:
- f = new SessionFactory(cls);
+ if (scope.args().length > 0) {
+ f = new SessionFactory(cls, Boolean.parseBoolean(scope.args()[0]));
+ } else {
+ f = new SessionFactory(cls);
+ }
break;
case PerRequest:
f = new PerRequestFactory(cls);
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/FactoryInvoker.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/FactoryInvoker.java?rev=1023971&r1=1023970&r2=1023971&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/FactoryInvoker.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/FactoryInvoker.java Mon Oct 18 20:04:18 2010
@@ -31,7 +31,7 @@ import org.apache.cxf.message.Exchange;
*
*/
public class FactoryInvoker extends AbstractInvoker {
- private static final ResourceBundle BUNDLE = BundleUtils.getBundle(FactoryInvoker.class);
+ static final ResourceBundle BUNDLE = BundleUtils.getBundle(FactoryInvoker.class);
private Factory factory;
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/Messages.properties?rev=1023971&r1=1023970&r2=1023971&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/Messages.properties (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/Messages.properties Mon Oct 18 20:04:18 2010
@@ -20,9 +20,9 @@
#
SVC_CLASS_IS_INTERFACE=Could not instantiate service class {0} because it is an interface.
SVC_CLASS_IS_ABSTRACT=Could not instantiate service class {0} because it is abstract.
-COULD_NOT_INSTANTIATE=Couldn't instantiate service object.
-ILLEGAL_ACCESS=Couldn't access service object.
-CREATE_SERVICE_OBJECT_EXC=Couldn't instantiate service object.
+COULD_NOT_INSTANTIATE=Could not instantiate service object.
+ILLEGAL_ACCESS=Could not access service object.
+CREATE_SERVICE_OBJECT_EXC=Could not instantiate service object.
EXCEPTION_INVOKING_OBJECT={0} while invoking {1} with params {2}.
SUSPENDED_INVOCATION_EXCEPTION=Invocation of method {1} on object {0} with params {2} has been suspended.
INVOKING_METHOD=Invoking method {1} on object {0} with params {2}.
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionFactory.java?rev=1023971&r1=1023970&r2=1023971&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionFactory.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/invoker/SessionFactory.java Mon Oct 18 20:04:18 2010
@@ -19,6 +19,7 @@
package org.apache.cxf.service.invoker;
+import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.service.Service;
@@ -29,12 +30,22 @@ import org.apache.cxf.service.Service;
* some session implementations require the beans to be Serializable
*/
public class SessionFactory implements Factory {
+
Factory factory;
+ boolean createIfNotExist;
+
public SessionFactory(Class<?> svcClass) {
- this(new PerRequestFactory(svcClass));
+ this(new PerRequestFactory(svcClass), true);
}
public SessionFactory(Factory f) {
+ this(f, true);
+ }
+ public SessionFactory(Class<?> svcClass, boolean createOnDemand) {
+ this(new PerRequestFactory(svcClass), createOnDemand);
+ }
+ public SessionFactory(Factory f, boolean createOnDemand) {
factory = f;
+ createIfNotExist = createOnDemand;
}
/** {@inheritDoc}*/
@@ -44,8 +55,12 @@ public class SessionFactory implements F
synchronized (serv) {
o = e.getSession().get(serv.getName().toString());
if (o == null) {
- o = factory.create(e);
- e.getSession().put(serv.getName().toString(), o);
+ if (createIfNotExist) {
+ o = factory.create(e);
+ e.getSession().put(serv.getName().toString(), o);
+ } else {
+ throw new Fault("COULD_NOT_INSTANTIATE", FactoryInvoker.BUNDLE);
+ }
}
}
return o;