All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.sun.faces.flow.builder.FlowBuilderImpl Maven / Gradle / Ivy
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package com.sun.faces.flow.builder;
import com.sun.faces.flow.FlowImpl;
import com.sun.faces.flow.ParameterImpl;
import com.sun.faces.util.Util;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.faces.context.FacesContext;
import javax.faces.flow.Flow;
import javax.faces.flow.builder.FlowBuilder;
import javax.faces.flow.builder.FlowCallBuilder;
import javax.faces.flow.builder.MethodCallBuilder;
import javax.faces.flow.builder.NavigationCaseBuilder;
import javax.faces.flow.builder.ReturnBuilder;
import javax.faces.flow.builder.SwitchBuilder;
import javax.faces.flow.builder.ViewBuilder;
public class FlowBuilderImpl extends FlowBuilder {
private FlowImpl flow;
private ExpressionFactory expressionFactory;
private ELContext elContext;
private FacesContext context;
private boolean didInit;
private boolean hasId;
public FlowBuilderImpl(FacesContext context) {
flow = new FlowImpl();
this.context = context;
this.expressionFactory = context.getApplication().getExpressionFactory();
this.elContext = context.getELContext();
this.didInit = false;
this.hasId = false;
}
//
@Override
public NavigationCaseBuilder navigationCase() {
return new NavigationCaseBuilderImpl(this);
}
@Override
public ViewBuilder viewNode(String viewNodeId, String vdlDocumentId) {
Util.notNull("viewNodeId", viewNodeId);
Util.notNull("vdlDocumentId", vdlDocumentId);
ViewBuilder result = new ViewBuilderImpl(this, viewNodeId, vdlDocumentId);
return result;
}
@Override
public SwitchBuilder switchNode(String switchNodeId) {
Util.notNull("switchNodeId", switchNodeId);
return new SwitchBuilderImpl(this, switchNodeId);
}
@Override
public ReturnBuilder returnNode(String returnNodeId) {
Util.notNull("returnNodeId", returnNodeId);
return new ReturnBuilderImpl(this, returnNodeId);
}
@Override
public MethodCallBuilder methodCallNode(String methodCallNodeId) {
Util.notNull("methodCallNodeId", methodCallNodeId);
return new MethodCallBuilderImpl(this, methodCallNodeId);
}
@Override
public FlowCallBuilder flowCallNode(String flowCallNodeId) {
return new FlowCallBuilderImpl(this, flowCallNodeId);
}
//
//
@Override
public FlowBuilder id(String definingDocumentId, String flowId) {
Util.notNull("definingDocumentId", definingDocumentId);
Util.notNull("flowId", flowId);
flow.setId(definingDocumentId, flowId);
this.hasId = true;
return this;
}
@Override
public FlowBuilder initializer(MethodExpression methodExpression) {
Util.notNull("methodExpression", methodExpression);
flow.setInitializer(methodExpression);
return this;
}
@Override
public FlowBuilder initializer(String methodExpression) {
Util.notNull("methodExpression", methodExpression);
MethodExpression me = expressionFactory.createMethodExpression(elContext, methodExpression, null, new Class[] {});
flow.setInitializer(me);
return this;
}
@Override
public FlowBuilder finalizer(MethodExpression methodExpression) {
flow.setFinalizer(methodExpression);
return this;
}
@Override
public FlowBuilder finalizer(String methodExpression) {
MethodExpression me = expressionFactory.createMethodExpression(elContext, methodExpression, null, new Class[] {});
flow.setFinalizer(me);
return this;
}
@Override
public FlowBuilder inboundParameter(String name, ValueExpression value) {
ParameterImpl param = new ParameterImpl(name, value);
flow._getInboundParameters().put(name, param);
return this;
}
@Override
public FlowBuilder inboundParameter(String name, String value) {
ValueExpression ve = expressionFactory.createValueExpression(elContext, value, Object.class);
inboundParameter(name, ve);
return this;
}
//
@Override
public Flow getFlow() {
if (!hasId) {
throw new IllegalStateException("Flow must have a defining document id and flow id.");
}
if (!didInit) {
flow.init(context);
String startNodeId = flow.getStartNodeId();
if (null == startNodeId) {
String flowId = flow.getId();
this.viewNode(flowId, "/" + flowId + "/" + flowId + ".xhtml").markAsStartNode();
}
didInit = true;
}
return flow;
}
public FlowImpl _getFlow() {
return flow;
}
//
ExpressionFactory getExpressionFactory() {
return expressionFactory;
}
ELContext getELContext() {
return elContext;
}
//
}