@Override public void sourceSection(SectionDesigner designer, SectionSourceContext context) throws Exception { SectionFunctionNamespace namespace = designer.addSectionFunctionNamespace("secure", new HttpFlowSecurerManagedFunctionSource(this.annotation)); SectionFunction function = namespace.addSectionFunction("secure", HttpFlowSecurerManagedFunctionSource.FUNCTION_NAME); designer.link(designer.addSectionInput(INPUT_NAME, null), function); designer.link(function.getFunctionFlow(Flows.SECURE.name()), designer.addSectionOutput(SECURE_OUTPUT_NAME, null, false), false); designer.link(function.getFunctionFlow(Flows.INSECURE.name()), designer.addSectionOutput(INSECURE_OUTPUT_NAME, null, false), false); } }
SectionObject connection = designer.addSectionObject( ServerGwtRpcConnection.class.getName(), ServerGwtRpcConnection.class.getName()); SectionObject cometService = designer.addSectionObject( CometService.class.getName(), CometService.class.getName()); SectionObject cometRequestServicer = designer.addSectionObject( CometRequestServicer.class.getName(), CometRequestServicer.class.getName()); SectionWork subscribeWork = designer.addSectionWork("SUBSCRIBE", ClassWorkSource.class.getName()); subscribeWork.addProperty(ClassWorkSource.CLASS_NAME_PROPERTY_NAME, designer.link(preSubscription.getTaskObject(CometRequestServicer.class .getName()), cometRequestServicer); designer.link(postSubscription.getTaskObject(CometRequestServicer.class .getName()), cometRequestServicer); designer.link(preSubscription, postSubscription); designer.link(designer.addSectionInput(SUBSCRIBE_INPUT_NAME, null), preSubscription); SectionWork publishWork = designer.addSectionWork("PUBLISH_WORK", PublishWorkSource.class.getName()); SectionTask publishTask = publishWork.addSectionTask("PUBLISH", PublishWorkSource.TASK_NAME); designer.link(publishTask .getTaskObject(Dependencies.SERVER_GWT_RPC_CONNECTION.name()),
throw designer.addIssue("Failed to read in template at location '" + location + "' with charset '" + (locationCharset == null ? "<default>" : locationCharset + ")"), ex);
/** * Links an escalation to an {@link SectionOutput}. * * @param task * {@link SectionTask}. * @param exception * Type of escalation. * @param designer * {@link SectionDesigner}. * @param escalations * Registry of the {@link SectionOutput} by type of escalation. */ static <E extends Throwable> void linkEscalation(SectionTask task, Class<E> exception, SectionDesigner designer, Map<Class<?>, SectionOutput> escalations) { // Obtain the section output SectionOutput output = escalations.get(exception); if (output == null) { output = designer.addSectionOutput(exception.getName(), exception.getName(), true); escalations.put(exception, output); } // Link task escalation to output TaskFlow escalation = task.getTaskEscalation(exception.getName()); designer.link(escalation, output, FlowInstigationStrategyEnum.SEQUENTIAL); }
/** * Links the {@link TaskObject} to the {@link SectionObject}. * * @param task * {@link SectionTask}. * @param objectName * Name of the object. * @param objectType * Type of the object. * @param designer * {@link SectionDesigner}. * @param objects * Registry of the {@link SectionObject} by type of object. */ static void linkObject(SectionTask task, String objectName, Class<?> objectType, SectionDesigner designer, Map<Class<?>, SectionObject> objects) { // Obtain the section object SectionObject sectionObject = objects.get(objectType); if (sectionObject == null) { sectionObject = designer.addSectionObject(objectType.getName(), objectType.getName()); objects.put(objectType, sectionObject); } // Link task object to section object TaskObject taskObject = task.getTaskObject(objectName); designer.link(taskObject, sectionObject); }
SectionInput serviceInput = designer.addSectionInput(SERVICE_INPUT, null); SectionOutput unhandledOutput = designer.addSectionOutput(UNHANDLED_OUTPUT, null, false); SectionOutput servletExceptionOutput = designer.addSectionOutput(ServletException.class.getSimpleName(), ServletException.class.getName(), true); SectionOutput ioExceptionOutput = designer.addSectionOutput(IOException.class.getSimpleName(), IOException.class.getName(), true); SectionObject servletServerMo = designer.addSectionObject("SERVLET_SERVER", ServletServer.class.getName()); SectionObject httpConnectionMo = designer.addSectionObject("HTTP_CONNECTION", ServerHttpConnection.class.getName()); SectionObject requestAttributesMo = designer.addSectionObject("REQUEST_ATTRIBUTES", HttpRequestState.class.getName()); SectionObject httpSessionMo = designer.addSectionObject("HTTP_SESSION", HttpSession.class.getName()); SectionObject httpSecurityMo = designer.addSectionObject("HTTP_SECURITY", HttpServletSecurity.class.getName()); SectionManagedObjectSource officeServletContextMos = designer.addSectionManagedObjectSource( "OfficeServletContext", OfficeServletContextManagedObjectSource.class.getName()); officeServletContextMos.addProperty(OfficeServletContextManagedObjectSource.PROPERTY_SERVLET_CONTEXT_NAME, ManagedObjectDependency contextToServerDependency = officeServletContextMo .getManagedObjectDependency("SERVLET_SERVER"); designer.link(contextToServerDependency, servletServerMo); SectionWork routeWork = designer.addSectionWork("Route", ServletRouteWorkSource.class.getName()); SectionTask routeTask = routeWork.addSectionTask("route", ServletRouteWorkSource.TASK_ROUTE); designer.link(serviceInput, routeTask); designer.link(routeTask.getTaskFlow(FlowKeys.UNHANDLED.name()), unhandledOutput,
/** * Adds handling for a {@link Servlet} resource. * * @param inputName * {@link SectionInput} name. * @param requestDispatcherPath * {@link RequestDispatcher} path. * @param servletBridge * {@link ServletBridge} {@link SectionObject}. * @param designer * {@link SectionDesigner}. */ private void addServletResource(String inputName, String requestDispatcherPath, SectionObject servletBridge, SectionDesigner designer) { // Create the task to indicate Servlet container resource SectionWork work = designer.addSectionWork(inputName, ServletContainerResourceWorkSource.class.getName()); work.addProperty( ServletContainerResourceWorkSource.PROPERTY_SERVLET_CONTAINER_RESOURCE, requestDispatcherPath); SectionTask task = work.addSectionTask(inputName, "RESOURCE"); TaskObject dependency = task .getTaskObject(DependencyKeys.SERVLET_BRIDGE.name()); designer.link(dependency, servletBridge); // Link input for task SectionInput input = designer.addSectionInput(inputName, null); designer.link(input, task); }
SectionWork initialWork = designer.addSectionWork("INITIAL", HttpTemplateInitialWorkSource.class.getName()); PropertiesUtil.copyProperties(context, initialWork, HttpTemplateWorkSource.PROPERTY_TEMPLATE_URI, HttpTemplateWorkSource.PROPERTY_TEMPLATE_URI_SUFFIX, HttpTemplateWorkSource.PROPERTY_TEMPLATE_SECURE, HttpTemplateInitialWorkSource.PROPERTY_CONTENT_TYPE, HttpTemplateInitialWorkSource.PROPERTY_CHARSET); SectionTask initialTask = initialWork.addSectionTask("_INITIAL_TASK_", HttpTemplateInitialWorkSource.TASK_NAME); designer.link(initialTask.getTaskObject("SERVER_HTTP_CONNECTION"), connectionObject); designer.link(initialTask.getTaskObject("HTTP_APPLICATION_LOCATION"), locationObject); designer.link(initialTask.getTaskObject("REQUEST_STATE"), requestStateObject); designer.link(initialTask.getTaskObject("HTTP_SESSION"), sessionObject); designer.link(initialTask.getTaskEscalation(IOException.class.getName()), ioEscalation, FlowInstigationStrategyEnum.SEQUENTIAL); SectionInput sectionInput = designer.addSectionInput(RENDER_TEMPLATE_INPUT_NAME, null); designer.link(sectionInput, initialTask); SectionWork templateWork = designer.addSectionWork(TEMPLATE_WORK_NANE, HttpTemplateWorkSource.class.getName()); templateWork.addProperty(HttpTemplateWorkSource.PROPERTY_TEMPLATE_CONTENT, templateContent); designer.link(templateTask.getTaskObject("SERVER_HTTP_CONNECTION"), connectionObject); designer.link(templateTask.getTaskObject("HTTP_APPLICATION_LOCATION"), locationObject); designer.link(templateTask.getTaskEscalation(IOException.class.getName()), ioEscalation, FlowInstigationStrategyEnum.SEQUENTIAL); designer.addIssue("Must provide template logic class for template " + templateUriPath); } else { designer.addIssue("Missing method '" + beanMethodName + "' on class " + this.sectionClass.getName()
@Override public SectionFlowSinkNode secureFlow(SectionDesigner designer, Class<?> argumentType, SectionFlowSinkNode secureFlowSink, SectionFlowSinkNode insecureFlowSink) { // Create the annotation HttpFlowSecurerAnnotation annotation = new HttpFlowSecurerAnnotation( this.httpSecurerBuilder.getHttpSecurityName(), this.httpSecurerBuilder.getAnyRoles(), this.httpSecurerBuilder.getRequiredRoles(), argumentType); // Configure the function String functionName = HttpSecurityArchitectEmployer.this.nextUniqueName(); SectionFunctionNamespace namespace = designer.addSectionFunctionNamespace(functionName, new HttpFlowSecurerManagedFunctionSource(annotation)); SectionFunction function = namespace.addSectionFunction(functionName, HttpFlowSecurerManagedFunctionSource.FUNCTION_NAME); // Configure the function designer.link(function.getFunctionFlow(Flows.SECURE.name()), secureFlowSink, false); designer.link(function.getFunctionFlow(Flows.INSECURE.name()), insecureFlowSink, false); // Return the decision flow sink return function; } }
.addIssue("Template logic class " + sectionClass.getName() + " is annotated with " + HttpSessionStateful.class.getSimpleName() + " but is not " + Serializable.class.getSimpleName()); .addSectionManagedObjectSource(objectName, HttpSessionObjectManagedObjectSource.class.getName()); managedObjectSource.addProperty(HttpSessionObjectManagedObjectSource.PROPERTY_CLASS_NAME, sectionClass.getName());
@Override public void sourceSection(SectionDesigner designer, SectionSourceContext context) throws Exception { // Create the Servlet Bridge dependency SectionObject servletBridge = designer.addSectionObject( "SERVLET_BRIDGE", ServletBridge.class.getName()); // Create the non-handled task String nonHandledInputName = context.getSectionLocation(); this.addServletResource(nonHandledInputName, null, servletBridge, designer); // Create the Servlet container resource tasks Set<String> registeredResources = new HashSet<String>(); for (String inputName : context.getPropertyNames()) { // Obtain the request dispatcher path String requestDispatcherPath = context.getProperty(inputName); // Ensure only register the resource once if (registeredResources.contains(requestDispatcherPath)) { continue; } // Add Servlet Resource this.addServletResource(inputName, requestDispatcherPath, servletBridge, designer); // Resource registered registeredResources.add(requestDispatcherPath); } }
SectionWork work = designer.addSectionWork( gwtServiceName, GwtServiceWorkSource.class.getName()); .getOrCreateSectionObject(ServerGwtRpcConnection.class .getName()); designer.link(connectionDependency, connectionObject); .addSectionInput(gwtServiceName, null); designer.link(serviceInput, task); designer.link( flow, flowTask,
.addIssue("Template logic class " + sectionClass.getName() + " is annotated with " + HttpSessionStateful.class.getSimpleName() + " but is not " + Serializable.class.getSimpleName()); .addSectionManagedObjectSource(objectName, HttpSessionObjectManagedObjectSource.class.getName()); managedObjectSource.addProperty(HttpSessionObjectManagedObjectSource.PROPERTY_CLASS_NAME, sectionClass.getName());
SectionInput handle = designer.addSectionInput(HANDLE_INPUT, AuthenticationRequiredException.class.getName()); SectionObject serverHttpConnection = designer.addSectionObject(ServerHttpConnection.class.getSimpleName(), ServerHttpConnection.class.getName()); SectionObject httpSession = designer.addSectionObject(HttpSession.class.getSimpleName(), HttpSession.class.getName()); SectionObject requestState = designer.addSectionObject(HttpRequestState.class.getSimpleName(), HttpRequestState.class.getName()); SectionObject httpChallengeContext = designer.addSectionObject(HttpChallengeContext.class.getSimpleName(), HttpChallengeContext.class.getName()); SectionFunctionNamespace namespace = designer.addSectionFunctionNamespace("handle", new HandleAuthenticationRequiredManagedFunctionSource()); SectionFunction handler = namespace.addSectionFunction("handler", "handler"); handler.getFunctionObject(Dependencies.AUTHENTICATION_REQUIRED_EXCEPTION.name()).flagAsParameter(); designer.link(handler.getFunctionObject(Dependencies.SERVER_HTTP_CONNECTION.name()), serverHttpConnection); designer.link(handler.getFunctionObject(Dependencies.HTTP_SESSION.name()), httpSession); designer.link(handler.getFunctionObject(Dependencies.REQUEST_STATE.name()), requestState); for (String httpSecurityName : this.httpSecurityNames) { SectionOutput output = designer.addSectionOutput(httpSecurityName, null, false); FunctionFlow flow = handler.getFunctionFlow(httpSecurityName); designer.link(flow, output, false); designer.link(sender.getFunctionObject( net.officefloor.web.security.impl.SendHttpChallengeFunction.Dependencies.HTTP_CHALLENGE_CONTEXT.name()), httpChallengeContext); designer.link(sender.getFunctionObject( net.officefloor.web.security.impl.SendHttpChallengeFunction.Dependencies.SERVER_HTTP_CONNECTION.name()),
.addSectionObject(ServerHttpConnection.class.getSimpleName(), ServerHttpConnection.class.getName()); SectionOutput ioEscalationOutput = designer.addSectionOutput( IOException.class.getSimpleName(), IOException.class.getName(), true); SectionWork work = designer.addSectionWork(resourcePath, HttpFileWorkSource.class.getName()); SourceHttpResourceFactory.copyProperties(context, work); .getTaskObject(DependencyKeys.SERVER_HTTP_CONNECTION .name()); designer.link(serverHttpConnectionObject, serverHttpConnectionDependency); designer.link(ioEscalationFlow, ioEscalationOutput, FlowInstigationStrategyEnum.SEQUENTIAL); SectionInput input = designer.addSectionInput(resourcePath, null); designer.link(input, task);
@Override protected DependencyMetaData[] extractClassManagedObjectDependencies(String objectName, Class<?> sectionClass) throws Exception { // Extract the dependency meta-data for default behaviour DependencyMetaData[] metaData = super.extractClassManagedObjectDependencies(objectName, sectionClass); // Determine if stateful boolean isStateful = isHttpSessionStateful(sectionClass); // If not stateful, return meta-data for default behaviour if (!isStateful) { return metaData; } // As stateful, must not have any dependencies into object if (metaData.length > 0) { throw this.getDesigner() .addIssue("Template logic class " + sectionClass.getName() + " is annotated with " + HttpSessionStateful.class.getSimpleName() + " and therefore can not have dependencies injected into the object (only its methods)"); } // Return the dependency meta-data for stateful template logic return new DependencyMetaData[] { new StatefulDependencyMetaData() }; }
SectionObject serverHttpConnection = designer.addSectionObject(ServerHttpConnection.class.getSimpleName(), ServerHttpConnection.class.getName()); SectionObject httpSession = designer.addSectionObject(HttpSession.class.getSimpleName(), HttpSession.class.getName()); SectionObject httpRequestState = designer.addSectionObject(HttpRequestState.class.getSimpleName(), HttpRequestState.class.getName()); SectionObject authenticationContext = designer.addSectionObject(AuthenticationContext.class.getSimpleName(), AuthenticationContext.class.getName()); SectionObject accessControl = designer.addSectionObject("AccessControl", accessControlType.getName()); SectionObject httpChallengeContext = designer.addSectionObject(HttpChallengeContext.class.getSimpleName(), HttpChallengeContext.class.getName()); for (int i = 0; i < dependencyObjects.length; i++) { HttpSecurityDependencyType<?> dependencyType = dependencyTypes[i]; dependencyObjects[i] = designer.addSectionObject("Dependency_" + dependencyType.getDependencyName(), dependencyType.getDependencyType().getName()); dependencyObjects[i].setTypeQualifier(dependencyType.getTypeQualifier()); SectionFunctionNamespace namespace = designer.addSectionFunctionNamespace("HttpSecuritySource", new HttpSecurityManagedFunctionSource(security, securityType)); HttpSecurityManagedFunctionSource.FUNCTION_CHALLENGE, HttpSecurityManagedFunctionSource.FUNCTION_CHALLENGE); designer.link(challengeFunction.getFunctionObject(HttpChallengeContext.class.getSimpleName()), httpChallengeContext); designer.link(challengeFunction.getFunctionObject(ServerHttpConnection.class.getSimpleName()), serverHttpConnection); designer.link(challengeFunction.getFunctionObject(HttpSession.class.getSimpleName()), httpSession);
@Override public void sourceSection(SectionDesigner designer, SectionSourceContext context) throws Exception { final Map<Class<?>, SectionObject> objects = new HashMap<Class<?>, SectionObject>(); final Map<Class<?>, SectionOutput> escalations = new HashMap<Class<?>, SectionOutput>(); // Add file sender SectionWork sendFileWork = designer.addSectionWork("FILE", HttpFileSenderWorkSource.class.getName()); SourceHttpResourceFactory.copyProperties(context, sendFileWork); SectionTask sendFileTask = sendFileWork.addSectionTask( HttpFileSenderWorkSource.TASK_NAME, HttpFileSenderWorkSource.TASK_NAME); WebApplicationSectionSource.linkObject(sendFileTask, DependencyKeys.SERVER_HTTP_CONNECTION.name(), ServerHttpConnection.class, designer, objects); WebApplicationSectionSource.linkObject(sendFileTask, DependencyKeys.HTTP_APPLICATION_LOCATION.name(), HttpApplicationLocation.class, designer, objects); WebApplicationSectionSource.linkEscalation(sendFileTask, IOException.class, designer, escalations); WebApplicationSectionSource.linkEscalation(sendFileTask, InvalidHttpRequestUriException.class, designer, escalations); // Provide input to service SectionInput input = designer.addSectionInput(SERVICE_INPUT_NAME, null); designer.link(input, sendFileTask); // Provide output once file written SectionOutput output = designer.addSectionOutput(FILE_SENT_OUTPUT_NAME, null, false); designer.link(sendFileTask, output); }
&& (HttpTemplateParserImpl.DEFAULT_FIRST_SECTION_NAME.equals(sectionName)))) { designer.addIssue("Section '" + sectionName + "' can not be introduced, as no previous override section (section prefixed with '" + OVERRIDE_SECTION_PREFIX + "') to identify where to inherit"); if ((isIntroducedSection) && (parentSectionNames.contains(introducedSectionName))) { designer.addIssue("Section '" + introducedSectionName + "' already exists by inheritance and not flagged for overriding (with '" + OVERRIDE_SECTION_PREFIX + "' prefix)"); designer.addIssue("No inherited section exists for overriding by section '" + notOverrideSectionName + "'");
SectionFunctionNamespace routeNamespace = designer.addSectionFunctionNamespace("ROUTE", new HttpRouteManagedFunctionSource(httpRouter)); SectionFunction route = routeNamespace.addSectionFunction(WebArchitect.HANDLER_INPUT_NAME, ROUTE_FUNCTION_NAME); SectionFunctionNamespace handleRedirectNamespace = designer.addSectionFunctionNamespace("REDIRECT", new HttpHandleRedirectFunctionSource(httpRouter)); SectionFunction handleRedirect = handleRedirectNamespace.addSectionFunction(HANDLE_REDIRECT_FUNCTION_NAME, designer.link(route.getFunctionFlow(HANDLE_REDIRECT_FLOW), handleRedirect, false); SectionInput handleHttpInput = designer.addSectionInput(WebArchitect.HANDLER_INPUT_NAME, null); if (this.interception == null) { designer.link(handleHttpInput, route); SectionFunctionNamespace interceptNamespace = designer.addSectionFunctionNamespace( InterceptManagedFunctionSource.FUNCTION_NAME, new InterceptManagedFunctionSource()); SectionFunction intercept = interceptNamespace.addSectionFunction( InterceptManagedFunctionSource.FUNCTION_NAME, InterceptManagedFunctionSource.FUNCTION_NAME); designer.link(handleHttpInput, intercept); SectionOutput interceptOutput = designer.addSectionOutput(this.interception.outputName, null, false); designer.link(intercept, interceptOutput); SectionInput routeInput = designer.addSectionInput(this.interception.inputName, null); designer.link(routeInput, route); SectionObject serverHttpConnection = designer.addSectionObject(ServerHttpConnection.class.getSimpleName(), ServerHttpConnection.class.getName());