Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Lifecycle AOP Framework. Enabling describe enhanced State Diagram with Java language,
and processing relational Lifecycle constraints(including: state validations, transitions validations),
concurrency, lifecycle callbacks, lifecycle events implicitely with Lifecycle Engine.
This engine can be used by class load time (Java Instrumentation) or compile time (Lifecycle-StaticWeaver-maven-plugin).
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2013-2020 Madz. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://raw.github.com/zhongdj/Lifecycle/master/License.txt
* . See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package net.imadz.lifecycle;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Constructor;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.imadz.bcel.intercept.DefaultStateMachineRegistry;
import net.imadz.common.Dumper;
import net.imadz.lifecycle.annotations.CompositeState;
import net.imadz.lifecycle.annotations.LifecycleMeta;
import net.imadz.lifecycle.annotations.StateMachine;
import net.imadz.lifecycle.meta.builder.StateMachineMetaBuilder;
import net.imadz.lifecycle.meta.builder.impl.StateMachineMetaBuilderImpl;
import net.imadz.lifecycle.meta.object.StateMachineObject;
import net.imadz.lifecycle.meta.type.LifecycleMetaRegistry;
import net.imadz.lifecycle.meta.type.StateMachineMetadata;
import net.imadz.util.StateAccessible;
import net.imadz.utils.BundleUtils;
import net.imadz.verification.VerificationException;
import net.imadz.verification.VerificationFailure;
import net.imadz.verification.VerificationFailureSet;
public abstract class AbsStateMachineRegistry implements LifecycleMetaRegistry {
private static Logger logger = Logger.getLogger("Lifecycle Framework");
private static volatile LifecycleMetaRegistry instance = null;
public static LifecycleMetaRegistry getInstance() {
if (null != instance) {
return instance;
} else {
final String registryClass = System
.getProperty("net.imadz.lifecycle.StateMachineRegistry");
if (null != registryClass) {
try {
// TODO There are two patterns to use registry:
// 1. using Annotation to register LifecycleMetadata
// classes.
// 2. using
// AbsStateMachineRegistry.registerLifecycleMeta(Class>
// class);
// For now ONLY 1st pattern is supported with extending
// AbsStateMachineRegistry.
Class.forName(registryClass).newInstance();
} catch (Throwable t) {
logger.log(Level.SEVERE,
"Cannot Instantiate State Machine Registry: "
+ registryClass, t);
throw new IllegalStateException(t);
}
} else {
DefaultStateMachineRegistry.getInstance();
}
}
return instance;
}
public static void close() {
instance = null;
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public static @interface LifecycleRegistry {
/**
* @return classes can be the name of life cycle interface itself, which
* has a @StateMachine annotated on it's type. or the name of a
* class/interface that has a @LifecycleMeta annotated on the
* type.
*/
Class>[] value();
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public static @interface StateMachineBuilder {
/**
* @return a concrete StateMachineMetaBuilder implementation class,
* which can build state machines from value of @LifecycleRegisty
*/
Class extends StateMachineMetaBuilder> value() default StateMachineMetaBuilderImpl.class;
}
/**
* The key might be class object as: The life cycle interface itself that
* has a @StateMachine, or a class/interface that has a @LifecycleMeta The
* key might be String as: The full qualified name corresponds to the dotted
* path, or simple name, or class full name
*/
protected final HashMap