com.speedment.runtime.core.Speedment Maven / Gradle / Ivy
Show all versions of tool-deploy Show documentation
/*
*
* Copyright (c) 2006-2019, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.core;
import com.speedment.runtime.core.exception.SpeedmentException;
import com.speedment.runtime.core.manager.Manager;
import com.speedment.runtime.core.manager.ManagerConfigurator;
import java.util.Optional;
/**
* The {@code Platform} class acts as a generic holder of different system
* Components. Using its pluggable architecture, one can
* replace existing default implementations of existing Components or plug in
* custom made implementation of any type.
*
* Pluggable components must have a default constructor.
*
* @author Per Minborg
* @author Emil Forslund
* @since 2.0.0
*/
public interface Speedment extends AutoCloseable {
/**
* Returns the specified component from the platform, or if it does not
* exist, an empty {@code Optional}.
*
* @param the type to search for
* @param type the interface type
* @return the implementation or empty
*/
Optional get(Class type);
/**
* Returns the specified component from the platform, or if it does not
* exist, throws a {@code SpeedmentException}.
*
* @param the component interface type
* @param type the component interface class
* @return the component
*
* @throws SpeedmentException if it was not installed
*/
T getOrThrow(Class type) throws SpeedmentException;
/**
* Creates and Returns a manager configurator that can be used to configure
* an existing manager. When the manager configurator's build() method is
* called, a new configured manager will be returned.
*
* @param the entity type
* @param manager to configure
* @return a manager configurator
*/
ManagerConfigurator configure(Class> manager);
/**
* Closes the Speedment instance and deallocates any allocated resources.
* After close() has been called, the Speedment instance can not be called
* any more.
*/
@Override
void close();
}