/*- * ============LICENSE_START======================================================= * SDC * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. 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. * ============LICENSE_END========================================================= */ package org.openecomp.core.factory.api; import org.openecomp.core.factory.impl.AbstractFactoryBase; /** * This class provides generic implementation of an abstract factory. Components exposed as Java interfaces should have their own concrete factories * derived from the given class. This assures code alignment and consistency across all Service Management components. The class actually uses * singleton pattern to instantiate and reuse just one instance of a factory. Therefore, each factory implementation has to be thread-safe. In * a general case, the hierarchy of factory objects for an Java interface IUknown may look as follows: *
 *                     AbstractFactory<IUnknown>
 *                                ^
 *                                |
 *   Application code ----> ConcreteFactory
 *                                ^
 *                                |
 *                      +---------+---------+
 *                      |                   |
 *             BaselineFactoryImpl   CustomFactoryImpl
 * 
* Where the classes responsibility is: The normal concrete factory class may look like: *
 * public abstract class ConcreteFactory extends AbstractFactory<IUnknown> {
 *   static {
 *     registerFactory(ConcreteFactory.class, BaselineFactoryImpl.class);
 *   }
 *   public static ConcreteFactory getInstance() {
 * return AbstractFactory.<IUnknown, ConcreteFactory.class>getInstance(ConcreteFactory.class);
 *   }
 * }
 * 
* * @param Java interface type created by the factory. */ public abstract class AbstractFactory extends AbstractFactoryBase { /** * Returns the interface implementor instance. * Note: It's up to the concrete factory to decide on the actual * implementation of the returned interface. Therefore, the call can get the same instance per each call in case of singleton implementation or * new instance otherwise. However, the API consumer may not assume anything regarding the underlying logic and has always go through the factory * to obtain the reference. * * @return Implementor of the exposed Java interface. */ public abstract I createInterface(); } // End of class