Skip to content

Commit 89471e1

Browse files
Kasper Nielsenkaspernielsen
authored andcommitted
er
wer e wer er wer wer wer wer
1 parent eb93821 commit 89471e1

File tree

174 files changed

+2055
-1917
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+2055
-1917
lines changed

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/SchedulingContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package app.packed.concurrent;
22

3-
import app.packed.bean.scanning.BeanTrigger.OnContextServiceVariable;
3+
import app.packed.bean.scanning.BeanTrigger.AutoInject;
44
import app.packed.concurrent.job2.JobExtension;
55
import app.packed.context.Context;
66

77
/**
88
* A context object available for scheduling.
99
*/
10-
@OnContextServiceVariable(introspector = JobExtension.MyI.class, requiresContext = SchedulingContext.class)
10+
@AutoInject(introspector = JobExtension.MyI.class, requiresContext = SchedulingContext.class)
1111
public interface SchedulingContext extends Context<JobExtension> {
1212

1313
/** {@return cancel future invocation of the scheduled operations. In progress operations will be allowed to finish} */

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/annotations/ScheduledJobContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package app.packed.concurrent.annotations;
22

3-
import app.packed.bean.scanning.BeanTrigger.OnContextServiceVariable;
3+
import app.packed.bean.scanning.BeanTrigger.AutoInject;
44
import app.packed.concurrent.other.ScheduledJobExtension;
55
import app.packed.context.Context;
66

7-
@OnContextServiceVariable(introspector = ScheduledJobExtension.ScheduledJobBeanIntrospector.class, requiresContext = ScheduledJobContext.class)
7+
@AutoInject(introspector = ScheduledJobExtension.ScheduledJobBeanIntrospector.class, requiresContext = ScheduledJobContext.class)
88
public interface ScheduledJobContext extends Context<ScheduledJobExtension> {
99

1010
void pause();

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/DaemonJob.java

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@
1515
*/
1616
package app.packed.concurrent.job;
1717

18+
import java.lang.annotation.Annotation;
1819
import java.lang.annotation.ElementType;
1920
import java.lang.annotation.Retention;
2021
import java.lang.annotation.RetentionPolicy;
2122
import java.lang.annotation.Target;
23+
import java.util.concurrent.TimeUnit;
2224

25+
import app.packed.bean.scanning.BeanIntrospector;
2326
import app.packed.bean.scanning.BeanTrigger.OnAnnotatedMethod;
27+
import app.packed.binding.Key;
2428
import app.packed.concurrent.ThreadKind;
25-
import internal.app.packed.concurrent.daemon.JobBeanintrospector;
29+
import app.packed.concurrent.job.DaemonJob.Daemonintrospector;
30+
import app.packed.extension.BaseExtension;
31+
import internal.app.packed.concurrent.daemon.DaemonOperationHandle;
2632

2733
/**
2834
* Will have a dedicated thread.
@@ -46,7 +52,7 @@
4652
// SupportJob
4753
@Target(ElementType.METHOD)
4854
@Retention(RetentionPolicy.RUNTIME)
49-
@OnAnnotatedMethod(allowInvoke = true, introspector = JobBeanintrospector.class)
55+
@OnAnnotatedMethod(allowInvoke = true, introspector = Daemonintrospector.class)
5056
public @interface DaemonJob {
5157

5258
String startup() default "When-exactly-are we starting";
@@ -71,4 +77,39 @@
7177
* @see DaemonMirror#threadKind()
7278
*/
7379
ThreadKind threadKind() default ThreadKind.DAEMON_THREAD;
80+
81+
final class Daemonintrospector extends BeanIntrospector<BaseExtension> {
82+
83+
/** {@inheritDoc} */
84+
@Override
85+
public void onAnnotatedMethod(Annotation annotation, BeanIntrospector.OnMethod method) {
86+
if (annotation instanceof DaemonJob daemon) {
87+
DaemonOperationHandle.installFromAnnotation(this, method, daemon);
88+
} else {
89+
super.onAnnotatedMethod(annotation, method);
90+
}
91+
}
92+
93+
/** {@inheritDoc} */
94+
@Override
95+
public void onExtensionService(Key<?> key, OnContextService service) {
96+
if (service.matchNoQualifiers(DaemonJobContext.class)) {
97+
service.binder().bindInvocationArgument(1);
98+
} else {
99+
super.onExtensionService(key, service);
100+
}
101+
}
102+
}
74103
}
104+
//Could return, RESTART, EXIT, SLEEP, CONTINUE
105+
106+
//Tror det er noget den annoterede metode kan returnere
107+
108+
interface DaemonJobAction {
109+
110+
// The one problem here is cleanup...
111+
// Do we want a stop method? Probably not
112+
static DaemonJobAction sleep(long duration, TimeUnit timeUnit) {
113+
throw new UnsupportedOperationException();
114+
}
115+
}

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/DaemonJobContext.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@
1717

1818
import java.util.concurrent.TimeUnit;
1919

20-
import app.packed.bean.scanning.BeanTrigger.OnContextServiceVariable;
20+
import app.packed.bean.scanning.BeanTrigger.AutoInject;
2121
import app.packed.context.Context;
2222
import app.packed.extension.BaseExtension;
23-
import internal.app.packed.concurrent.daemon.DaemonRuntimeOperationRunner.PackedDaemonContext;
24-
import internal.app.packed.concurrent.daemon.JobBeanintrospector;
23+
import internal.app.packed.concurrent.daemon.DaemonSideBean;
2524

2625
/**
2726
* A context object that can be injected into daemon methods.
2827
*
2928
*/
3029
// I think we need a bit understand about where we are in the shutdown process, early, vs late
31-
@OnContextServiceVariable(introspector = JobBeanintrospector.class, requiresContext = DaemonJobContext.class)
32-
public sealed interface DaemonJobContext extends Context<BaseExtension> permits PackedDaemonContext {
30+
@AutoInject(introspector = DaemonJob.Daemonintrospector.class, requiresContext = DaemonJobContext.class)
31+
public sealed interface DaemonJobContext extends Context<BaseExtension> permits DaemonSideBean {
3332

3433
/**
3534
* @return

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/DaemonJobMirror.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
public final class DaemonJobMirror extends JobMirror {
2828

29-
final DaemonOperationHandle handle;
29+
private final DaemonOperationHandle handle;
3030

3131
/**
3232
* @param handle

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/JobMirror.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
public abstract class JobMirror extends OperationMirror {
2626

2727
OperationHandle<?> handle;
28+
2829
/**
2930
* @param handle
3031
*/

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
==== A job is typically adds a bit more overhead to the task, than simply using a ExecutorService ====
22
* A job has a unique name within a namespace
33
* A job can have a context injected
4-
* The status of a job can be tracked in JobTracker
5-
* A job can be tagged
4+
* The status of a job can be tracked in a JobTracker
5+
* A job can be tagged (operations)
66

77

88

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/ScTest2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static void main(String[] args) throws Exception {
3737
// });
3838

3939
App.run(new ScTest2());
40-
Thread.sleep(1000);
40+
Thread.sleep(10000);
4141
}
4242

4343
/** {@inheritDoc} */

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/JobApp.java renamed to modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/app/JobApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package app.packed.concurrent.job;
16+
package app.packed.concurrent.job.app;
1717

1818
import java.util.concurrent.Future;
1919

modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/PackedJobApp.java renamed to modules/packed-incubator/packed-incubator-concurrent/src/main/java/app/packed/concurrent/job/app/PackedJobApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package app.packed.concurrent.job;
16+
package app.packed.concurrent.job.app;
1717

1818
import java.util.concurrent.Future;
1919
import java.util.concurrent.TimeUnit;

0 commit comments

Comments
 (0)