org.tentackle.pdo.OperationFactory Maven / Gradle / Ivy
/*
* Tentackle - https://tentackle.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.tentackle.pdo;
import org.tentackle.common.ServiceFactory;
import org.tentackle.session.Session;
interface OperationFactoryHolder {
OperationFactory INSTANCE = ServiceFactory.createService(
OperationFactory.class, DefaultOperationFactory.class);
}
/**
* A factory for operation objects.
*
* @author harald
*/
public interface OperationFactory {
/**
* The singleton.
*
* @return the singleton
*/
static OperationFactory getInstance() {
return OperationFactoryHolder.INSTANCE;
}
/**
* Creates an operation.
*
* @param the operation type
* @param clazz the class of the operation, usually an interface
* @param context the domain context
* @return the created operation
*/
> T create(Class clazz, DomainContext context);
/**
* Creates an operation.
*
* @param the operation type
* @param clazz the class of the operation, usually an interface
* @param session the session
* @return the created operation
*/
> T create(Class clazz, Session session);
/**
* Creates an operation.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @param context the domain context
* @return the created operation
*/
> T create(String className, DomainContext context);
/**
* Creates an operation for a session only.
*
* Note: the application must set the context.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @param session the session
* @return the created operation
*/
> T create(String className, Session session);
/**
* Creates an operation without any domain context or session.
*
* Note: the application must set the context.
*
* @param the operation type
* @param clazz the class of the operation, usually an interface
* @return the created operation
*/
> T create(Class clazz);
/**
* Creates an operation without any domain context or session.
*
* Note: the application must set the context.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @return the created operation
*/
> T create(String className);
/**
* Creates an operation.
*
* @param the operation type
* @param op the operation
* @return the created operation belonging to the same class as the given {@code op} and in same context.
*/
> T create(T op);
/**
* Creates an operation within a sub context.
* If the current context is already within the given context name, the result is equivalent
* to {@link #create(Operation)}.
*
* @param the operation type
* @param op the operation
* @param contextName the context name
* @return the created operation belonging to the same class as the given {@code op} in a sub context of given name
*/
> T create(T op, String contextName);
/**
* Creates an operation for a given persistence delegate.
*
* @param the operation type
* @param clazz the class of the operation, usually an interface
* @param persistenceDelegate the persistence delegate
* @return the created operation
*/
> T create(Class clazz, PersistentOperation persistenceDelegate);
/**
* Creates an operation for a given persistence delegate.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @param persistenceDelegate the persistence delegate
* @return the created operation
*/
> T create(String className, PersistentOperation persistenceDelegate);
/**
* Creates an operation for a given domain delegate.
*
* @param the operation type
* @param clazz the class of the operation, usually an interface
* @param context the domain context
* @param domainDelegate the domain delegate
* @return the created operation
*/
> T create(Class clazz, DomainContext context, DomainOperation domainDelegate);
/**
* Creates an operation for a given domain delegate.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @param context the domain context
* @param domainDelegate the domain delegate
* @return the created operation
*/
> T create(String className, DomainContext context, DomainOperation domainDelegate);
/**
* Creates an operation for a given domain delegate.
*
* @param the operation type
* @param clazz the class of the operation, usually an interface
* @param session the session
* @param domainDelegate the domain delegate
* @return the created operation
*/
> T create(Class clazz, Session session, DomainOperation domainDelegate);
/**
* Creates an operation for a given domain delegate.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @param session the session
* @param domainDelegate the domain delegate
* @return the created operation
*/
> T create(String className, Session session, DomainOperation domainDelegate);
/**
* Creates an operation for given delegates.
*
* @param the operation type
* @param clazz the class of the operation, usually an interface
* @param persistenceDelegate the persistence delegate
* @param domainDelegate the domain delegate
* @return the created operation
*/
> T create(Class clazz, PersistentOperation persistenceDelegate, DomainOperation domainDelegate);
/**
* Creates an operation for given delegates.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @param persistenceDelegate the persistence delegate
* @param domainDelegate the domain delegate
* @return the created operation
*/
> T create(String className, PersistentOperation persistenceDelegate, DomainOperation domainDelegate);
/**
* Gets the class implementing the persistence layer.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @return the persistence class
*/
> Class> getPersistenceClass(String className);
/**
* Gets the class implementing the domain layer.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @return the domain class
*/
> Class> getDomainClass(String className);
/**
* Creates the delegate implementing the persistence layer.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @return the persistent delegate
*/
> PersistentOperation createPersistenceDelegate(String className);
/**
* Creates the delegate implementing the domain layer.
*
* @param the operation type
* @param className the name of operation-class, usually an interface
* @return the domain delegate
*/
> DomainOperation createDomainDelegate(String className);
}