@Override public OfficeManagedObject addHttpObject(Class<?> objectClass, String... acceptedContentTypes) { // Determine if already registered OfficeManagedObject object = this.httpObjects.get(objectClass); if (object == null) { // Not registered, so register OfficeManagedObjectSource mos = this.officeArchitect.addOfficeManagedObjectSource(objectClass.getName(), new HttpObjectManagedObjectSource<>(objectClass, acceptedContentTypes, this.singletonObjectParserList)); object = mos.addOfficeManagedObject(objectClass.getName(), ManagedObjectScope.PROCESS); this.httpObjects.put(objectClass, object); } // Return the object return object; }
@Override public OfficeManagedObject addHttpArgument(String parameterName, HttpValueLocation location) { // Obtain the bind name String bindName = "HTTP_" + (location == null ? "ANY" : location.name()) + "_" + parameterName; OfficeManagedObject object = this.httpArguments.get(bindName); if (object != null) { return object; // return the already register object } // Not registered, so register OfficeManagedObjectSource mos = this.officeArchitect.addOfficeManagedObjectSource(bindName, new HttpArgumentManagedObjectSource(parameterName, location)); object = mos.addOfficeManagedObject(bindName, ManagedObjectScope.PROCESS); this.httpArguments.put(bindName, object); // Return the object return object; }
@Override public OfficeManagedObject addHttpApplicationObject(Class<?> objectClass, String bindName) { // Determine if already registered bindName = getBindName(objectClass, bindName); OfficeManagedObject object = this.httpApplicationObjects.get(bindName); if (object != null) { return object; // return the already registered object } // Not registered, so register OfficeManagedObjectSource mos = this.officeArchitect.addOfficeManagedObjectSource(bindName, HttpApplicationObjectManagedObjectSource.class.getName()); mos.addProperty(HttpApplicationObjectManagedObjectSource.PROPERTY_CLASS_NAME, objectClass.getName()); if ((bindName != null) && (bindName.trim().length() > 0)) { mos.addProperty(HttpApplicationObjectManagedObjectSource.PROPERTY_BIND_NAME, bindName); } object = mos.addOfficeManagedObject(bindName, ManagedObjectScope.PROCESS); this.httpApplicationObjects.put(bindName, object); // Return the object return object; }
@Override public OfficeManagedObject addHttpSessionObject(Class<?> objectClass, String bindName) { // Determine if already registered bindName = getBindName(objectClass, bindName); OfficeManagedObject object = this.httpSessionObjects.get(bindName); if (object != null) { return object; // return the already registered object } // Not registered, so register OfficeManagedObjectSource mos = this.officeArchitect.addOfficeManagedObjectSource(bindName, HttpSessionObjectManagedObjectSource.class.getName()); mos.addProperty(HttpSessionObjectManagedObjectSource.PROPERTY_CLASS_NAME, objectClass.getName()); if ((bindName != null) && (bindName.trim().length() > 0)) { mos.addProperty(HttpSessionObjectManagedObjectSource.PROPERTY_BIND_NAME, bindName); } object = mos.addOfficeManagedObject(bindName, ManagedObjectScope.PROCESS); this.httpSessionObjects.put(bindName, object); // Return the object return object; }
@Override public OfficeManagedObject addHttpRequestObject(Class<?> objectClass, boolean isLoadParameters, String bindName) { // Determine if already registered bindName = getBindName(objectClass, bindName); OfficeManagedObject object = this.httpRequestObjects.get(bindName); if (object == null) { // Not registered, so register OfficeManagedObjectSource mos = this.officeArchitect.addOfficeManagedObjectSource(bindName, HttpRequestObjectManagedObjectSource.class.getName()); mos.addProperty(HttpRequestObjectManagedObjectSource.PROPERTY_CLASS_NAME, objectClass.getName()); if ((bindName != null) && (bindName.trim().length() > 0)) { mos.addProperty(HttpRequestObjectManagedObjectSource.PROPERTY_BIND_NAME, bindName); } object = mos.addOfficeManagedObject(bindName, ManagedObjectScope.PROCESS); this.httpRequestObjects.put(bindName, object); // Determine if load HTTP parameters if (isLoadParameters) { // Add the property to load parameters mos.addProperty(HttpRequestObjectManagedObjectSource.PROPERTY_IS_LOAD_HTTP_PARAMETERS, String.valueOf(true)); } } // Return the object return object; }
OfficeManagedObjectSource mos = architect.addOfficeManagedObjectSource("mo", managedObjectSourceClass.getName()); if (managedObjectSourceClass == this.getDataSourceManagedObjectSourceClass()) {
OfficeManagedObjectSource mos = context.getOfficeArchitect().addOfficeManagedObjectSource("mo", managedObjectSourceClass.getName()); mos.addOfficeManagedObject("mo", ManagedObjectScope.THREAD);
OfficeManagedObjectSource mos = context.getOfficeArchitect().addOfficeManagedObjectSource("mo", managedObjectSourceClass.getName()); mos.addOfficeManagedObject("mo", ManagedObjectScope.THREAD);
OfficeManagedObjectSource mos = architect.addOfficeManagedObjectSource("mo", this.getConnectionManagedObjectSourceClass().getName()); this.loadConnectionProperties(mos);
OfficeManagedObjectSource httpChallengeContextMos = this.officeArchitect.addOfficeManagedObjectSource( HttpChallengeContext.class.getSimpleName(), new HttpChallengeContextManagedObjectSource()); OfficeManagedObject httpChallengeContext = httpChallengeContextMos OfficeManagedObjectSource defaultHttpAuthenticationMos = this.officeArchitect.addOfficeManagedObjectSource( defaultHttpAuthenticationName, new DefaultHttpAuthenticationManagedObjectSource(negotiator, httpSecurityNames)); OfficeManagedObjectSource defaultHttpAccessControlMos = this.officeArchitect.addOfficeManagedObjectSource( defaultHttpAccessControlName, new DefaultHttpAccessControlManagedObjectSource()); defaultHttpAccessControlMos.setTimeout(maxTimeout);
/** * Ensure if {@link EntityManager} is managing the {@link DataSource} that it is * validated on start up. * * @throws Throwable On test failure. */ public void testManagedConnectivity() throws Throwable { // Configure without data source Closure<Throwable> closure = new Closure<>(); CompileOfficeFloor compile = new CompileOfficeFloor(); compile.office((context) -> { OfficeManagedObjectSource jpaMos = context.getOfficeArchitect().addOfficeManagedObjectSource("JPA", this.getJpaManagedObjectSourceClass().getName()); this.loadJpaProperties(jpaMos); }); compile.getOfficeFloorCompiler().setEscalationHandler((escalation) -> { closure.value = escalation; }); OfficeFloor officeFloor = compile.compileAndOpenOfficeFloor(); assertNotNull("No connectivity should not prevent running (data source may be temporarily unavailable)", officeFloor); // Ensure start up failure assertNotNull("Should have start up failure", closure.value); assertEquals("Incorrect start up failure", "Failing to connect EntityManager", closure.value.getMessage()); assertNotNull("Should indicate cause", closure.value.getCause()); // Close officeFloor.closeOfficeFloor(); }
OfficeManagedObjectSource mos = architect.addOfficeManagedObjectSource("mo", this.getConnectionManagedObjectSourceClass().getName()); this.loadConnectionProperties(mos);
OfficeManagedObjectSource authenticationContextMos = office.addOfficeManagedObjectSource( authenticationContextName, new AuthenticationContextManagedObjectSource<>(this.name, this.security)); OfficeManagedObjectSource authenticationMos = office.addOfficeManagedObjectSource(authenticationName, new AuthenticationManagedObjectSource<>(this.name, this.security, this.type)); OfficeManagedObject authentication = authenticationMos.addOfficeManagedObject(authenticationName, } else { String httpAuthenticationName = this.name + "_HttpAuthentication"; OfficeManagedObjectSource httpAuthenticationMos = office.addOfficeManagedObjectSource( httpAuthenticationName, new HttpAuthenticationManagedObjectSource<>(this.type)); this.httpAuthentication = httpAuthenticationMos.addOfficeManagedObject(httpAuthenticationName, OfficeManagedObjectSource accessControlMos = office.addOfficeManagedObjectSource(accessControlName, new AccessControlManagedObjectSource<>(this.name, accessControlType)); accessControlMos.setTimeout(this.timeout); } else { String httpAccessControlName = this.name + "_HttpAccessControl"; OfficeManagedObjectSource httpAccessControlMos = office.addOfficeManagedObjectSource( httpAccessControlName, new HttpAccessControlManagedObjectSource<>(this.type)); this.httpAccessControl = httpAccessControlMos.addOfficeManagedObject(httpAccessControlName,
.addOfficeManagedObjectSource("connection", ConnectionManagedObjectSource.class.getName()); this.loadDatabaseProperties(connectionMos); connectionMos.addOfficeManagedObject("connection", ManagedObjectScope.THREAD); .addOfficeManagedObjectSource("dataSource", DataSourceManagedObjectSource.class.getName()); this.loadDatabaseProperties(dataSourceMos); dataSourceMos.addOfficeManagedObject("dataSource", ManagedObjectScope.THREAD); OfficeManagedObjectSource jpaMos = context.getOfficeArchitect().addOfficeManagedObjectSource("JPA", this.getJpaManagedObjectSourceClass().getName()); this.loadJpaProperties(jpaMos);
OfficeManagedObjectSource mos = context.getOfficeArchitect().addOfficeManagedObjectSource("mo", connectionMosClass.getName()); propertyLoader.accept(mos);
OfficeManagedObjectSource httpSessionMos = this.officeArchitect.addOfficeManagedObjectSource("HTTP_SESSION", HttpSessionManagedObjectSource.class.getName()); httpSessionMos.setTimeout(10 * 1000); // TODO make configurable .addOfficeManagedObjectSource("HTTP_APPLICATION_STATE", new HttpApplicationStateManagedObjectSource(this.contextPath)) .addOfficeManagedObject("HTTP_APPLICATION_STATE", ManagedObjectScope.PROCESS); this.officeArchitect .addOfficeManagedObjectSource("HTTP_REQUEST_STATE", new HttpRequestStateManagedObjectSource(argumentParsers)) .addOfficeManagedObject("HTTP_REQUEST_STATE", ManagedObjectScope.PROCESS); ObjectResponseManagedObjectSource objectResponseMos = new ObjectResponseManagedObjectSource( this.objectResponderFactories); this.officeArchitect.addOfficeManagedObjectSource("OBJECT_RESPONSE", objectResponseMos) .addOfficeManagedObject("OBJECT_RESPONSE", ManagedObjectScope.PROCESS); this.routing.setHttpEscalationHandler(objectResponseMos);
OfficeManagedObjectSource mos = architect.addOfficeManagedObjectSource(managedObjectName, managedObjectSourceClassName);