use of org.apache.cxf.service.invoker.SessionFactory in project cxf by apache.
the class AnnotationsFactoryBeanListener method setScope.
private void setScope(Server server, Class<?> cls) {
FactoryType scope = cls.getAnnotation(FactoryType.class);
if (scope != null) {
Invoker i = server.getEndpoint().getService().getInvoker();
if (i instanceof FactoryInvoker) {
Factory f;
if (scope.factoryClass() == FactoryType.DEFAULT.class) {
switch(scope.value()) {
case Session:
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);
break;
case Pooled:
f = new PooledFactory(cls, Integer.parseInt(scope.args()[0]));
break;
default:
f = new SingletonFactory(cls);
break;
}
} else {
try {
f = scope.factoryClass().getConstructor(Class.class, String[].class).newInstance(cls, scope.args());
} catch (Throwable t) {
throw new ServiceConstructionException(t);
}
}
((FactoryInvoker) i).setFactory(f);
}
}
}
Aggregations