diff options
Diffstat (limited to 'plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle')
6 files changed, 0 insertions, 429 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycle.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycle.java deleted file mode 100644 index fd44921cca..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycle.java +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.lifecycle; - -/** - * @author Eike Stepper - */ -public interface ILifecycle -{ - public void activate() throws LifecycleException; - - public Exception deactivate(); - - /** - * @author Eike Stepper - */ - public interface Introspection extends ILifecycle - { - public ILifecycleState getLifecycleState(); - - public boolean isActive(); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleEvent.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleEvent.java deleted file mode 100644 index ab3694d2ef..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleEvent.java +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.lifecycle; - -import org.eclipse.net4j.util.event.IEvent; - -/** - * @author Eike Stepper - */ -public interface ILifecycleEvent extends IEvent -{ - public ILifecycle getLifecycle(); - - public Kind getKind(); - - /** - * @author Eike Stepper - */ - public enum Kind - { - ABOUT_TO_ACTIVATE, ACTIVATED, ABOUT_TO_DEACTIVATE, DEACTIVATED - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleState.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleState.java deleted file mode 100644 index a581c1907c..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/ILifecycleState.java +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.lifecycle; - -/** - * @author Eike Stepper - */ -public enum ILifecycleState -{ - ACTIVATING, ACTIVE, DEACTIVATING, INACTIVE -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleException.java deleted file mode 100644 index b00aec53f2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.lifecycle; - -/** - * @author Eike Stepper - */ -public class LifecycleException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public LifecycleException() - { - } - - public LifecycleException(String message) - { - super(message); - } - - public LifecycleException(Throwable cause) - { - super(cause); - } - - public LifecycleException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java deleted file mode 100644 index c50ae42fe5..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/LifecycleUtil.java +++ /dev/null @@ -1,264 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.util.lifecycle; - -import org.eclipse.net4j.internal.util.bundle.OM; -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.internal.util.lifecycle.LifecycleEventAdapter; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.util.WrappedException; - -import java.lang.annotation.Annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Method; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -/** - * @author Eike Stepper - */ -public final class LifecycleUtil -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_LIFECYCLE, LifecycleUtil.class); - - private LifecycleUtil() - { - } - - public static ILifecycleState getLifecycleState(Object object) - { - if (object instanceof ILifecycle.Introspection) - { - return ((ILifecycle.Introspection)object).getLifecycleState(); - } - - return ILifecycleState.ACTIVE; - } - - public static boolean isActive(Object object) - { - if (object instanceof ILifecycle.Introspection) - { - return ((ILifecycle.Introspection)object).isActive(); - } - - return object != null; - } - - public static void activate(Object object) throws LifecycleException - { - activate(object, false); - } - - /** - * @see Activator - */ - public static void activate(Object object, boolean useAnnotation) throws LifecycleException - { - if (object instanceof ILifecycle) - { - ((ILifecycle)object).activate(); - } - else if (object != null && useAnnotation) - { - invokeAnnotation(object, Activator.class); - } - } - - public static Exception activateSilent(Object object) - { - return activateSilent(object, false); - } - - /** - * @see Activator - */ - public static Exception activateSilent(Object object, boolean useAnnotation) - { - try - { - activate(object, useAnnotation); - return null; - } - catch (Exception ex) - { - OM.LOG.error(ex); - return ex; - } - } - - public static boolean waitForActive(Object object, long millis) - { - try - { - if (object instanceof ILifecycle) - { - Lifecycle lifecycle = (Lifecycle)object; - if (lifecycle.isActive()) - { - return true; - } - - final CountDownLatch latch = new CountDownLatch(1); - LifecycleEventAdapter adapter = new LifecycleEventAdapter() - { - @Override - protected void onActivated(ILifecycle lifecycle) - { - latch.countDown(); - } - }; - - try - { - lifecycle.addListener(adapter); - latch.await(millis, TimeUnit.MILLISECONDS); - } - finally - { - lifecycle.removeListener(adapter); - } - - return lifecycle.isActive(); - } - - return true; - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - public static Exception deactivate(Object object) - { - return deactivate(object, false); - } - - /** - * @see Deactivator - */ - public static Exception deactivate(Object object, boolean useAnnotation) - { - if (object instanceof ILifecycle) - { - return ((ILifecycle)object).deactivate(); - } - else if (object != null && useAnnotation) - { - // TODO Handle evtl. return value (exception) - invokeAnnotation(object, Deactivator.class); - } - - return null; - } - - public static void deactivateNoisy(Object object) throws LifecycleException - { - deactivateNoisy(object, false); - } - - public static void deactivateNoisy(Object object, boolean useAnnotation) throws LifecycleException - { - Exception ex = deactivate(object, useAnnotation); - if (ex instanceof RuntimeException) - { - throw (RuntimeException)ex; - } - else if (ex != null) - { - throw new LifecycleException(ex); - } - } - - private static <T extends Annotation> void invokeAnnotation(Object object, Class<T> annotationClass) - { - Class<?> c = object.getClass(); - while (c != Object.class) - { - final Method[] methods = c.getDeclaredMethods(); - for (Method method : methods) - { - if (method.getParameterTypes().length == 0) - { - Annotation annotation = method.getAnnotation(annotationClass); - if (annotation != null) - { - invokeMethod(object, method); - boolean propagate = annotationClass == Activator.class ? ((Activator)annotation).propagate() - : ((Deactivator)annotation).propagate(); - if (!propagate) - { - break; - } - } - } - } - - c = c.getSuperclass(); - } - } - - private static Object invokeMethod(Object object, Method method) - { - try - { - return method.invoke(object, (Object[])null); - } - catch (IllegalAccessException iae) - { - try - { - method.setAccessible(true); - return method.invoke(object, (Object[])null); - } - catch (Exception ex) - { - if (TRACER.isEnabled()) - { - TRACER.trace(ex); - } - } - } - catch (Exception ex) - { - if (TRACER.isEnabled()) - { - TRACER.trace(ex); - } - } - - return null; - } - - /** - * @author Eike Stepper - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface Activator - { - boolean propagate() default true; - } - - /** - * @author Eike Stepper - */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface Deactivator - { - boolean propagate() default true; - } -} diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/package.html b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/package.html deleted file mode 100644 index e7e55a0ba2..0000000000 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/lifecycle/package.html +++ /dev/null @@ -1,46 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - - Copyright (c) 2004 - 2008 Eike Stepper, Germany. - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://www.eclipse.org/legal/epl-v10.html - - Contributors: - Eike Stepper - Initial API and implementation - ---> -</head> -<body bgcolor="white"> - -A framework for components with a simple lifecycle. -Interfaces that describe the behaviour of objects with respect to their lifecycle. -A utility class to interact with such objects and an abstract class that can be -used to implement such objects are provided as well. -<p> - -<!-- - -<h2>Package Specification</h2> - -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT ##### -<ul> - <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a> -</ul> - -<h2>Related Documentation</h2> - -For overviews, tutorials, examples, guides, and tool documentation, please see: -<ul> - <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a> -</ul> - ---> - -<!-- Put @see and @since tags down here. --> - -</body> -</html> |