Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated on command and scheduler #44

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private Constants() {
/**
* the named cron expression for daily execution.
*/
public static final String CRON_EXPRESSION_DAYLY = "@daily";
public static final String CRON_EXPRESSION_DAILY = "@daily";

/**
* the named cron expression for hourly execution.
Expand All @@ -69,12 +69,12 @@ private Constants() {
/**
* the named cron expression for minutely execution.
*/
public static final String CRON_EXPRESSION_MINUTLY = "@minutely";
public static final String CRON_EXPRESSION_MINUTELY = "@minutely";

/**
* the named cron expression for secondly execution.
*/
public static final String CRON_EXPRESSION_SECUNDLY = "@secondly";
public static final String CRON_EXPRESSION_SECONDLY = "@secondly";

/**
* the named cron expression for execution onreboot.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import org.osgi.annotation.bundle.Requirement;
import org.osgi.namespace.implementation.ImplementationNamespace;

/**
* Require an implementation for the this specification
*/
@Requirement(namespace = ImplementationNamespace.IMPLEMENTATION_NAMESPACE, filter = "(&("
+ ImplementationNamespace.IMPLEMENTATION_NAMESPACE + "="
+ Constants.SPECIFICATION_NAME + ")${frange;${version;==;"
+ Constants.SPECIFICATION_VERSION + "}})")

@org.osgi.annotation.bundle.Requirement(
effective = "active",
namespace = ImplementationNamespace.IMPLEMENTATION_NAMESPACE,
name = Constants.SPECIFICATION_NAME,
version = Constants.SPECIFICATION_VERSION
)
@Retention(RetentionPolicy.CLASS)
public @interface RequireSchedulerImplementation {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.felix.service.command.Parameter;
import org.osgi.framework.BundleContext;
import org.osgi.service.http.runtime.HttpServiceRuntime;
import org.osgi.service.http.runtime.dto.DTOConstants;
import org.osgi.service.http.runtime.dto.ErrorPageDTO;
import org.osgi.service.http.runtime.dto.FailedErrorPageDTO;
import org.osgi.service.http.runtime.dto.FailedFilterDTO;
Expand Down Expand Up @@ -56,6 +57,7 @@ void dtos(DTOFormatter formatter) {
.fields("*")
.line()
.fields("*")
.format("failureReason", f -> failedReason(f.failureReason))
.part()
.as(dto -> String.format("[%s] %s", dto.serviceId, dto.name));

Expand All @@ -72,6 +74,7 @@ void dtos(DTOFormatter formatter) {
.fields("*")
.line()
.fields("*")
.format("failureReason", f -> failedReason(f.failureReason))
.part()
.as(dto -> String.format("[%s]", dto.serviceId));

Expand All @@ -88,6 +91,7 @@ void dtos(DTOFormatter formatter) {
.fields("*")
.line()
.fields("*")
.format("failureReason", f -> failedReason(f.failureReason))
.part()
.as(dto -> String.format("[%s] %s", dto.serviceId, dto.name));

Expand All @@ -104,6 +108,7 @@ void dtos(DTOFormatter formatter) {
.fields("*")
.line()
.fields("*")
.format("failureReason", f -> failedReason(f.failureReason))
.part()
.as(dto -> String.format("[%s]", dto.serviceId));

Expand All @@ -120,6 +125,7 @@ void dtos(DTOFormatter formatter) {
.fields("*")
.line()
.fields("*")
.format("failureReason", f -> failedReason(f.failureReason))
.part()
.as(dto -> String.format("[%s]", dto.serviceId));

Expand All @@ -136,6 +142,7 @@ void dtos(DTOFormatter formatter) {
.fields("*")
.line()
.fields("*")
.format("failureReason", f -> failedReason(f.failureReason))
.part()
.as(dto -> String.format("[%s] %s", dto.serviceId, dto.name));

Expand All @@ -152,6 +159,7 @@ void dtos(DTOFormatter formatter) {
.fields("*")
.line()
.fields("*")
.format("failureReason", f -> failedReason(f.failureReason))
.part()
.as(dto -> String.format("[%s]", dto.serviceId));

Expand Down Expand Up @@ -246,4 +254,30 @@ private static String port(RuntimeDTO runtimeDTO) {
return p;
}

private String failedReason(int failureReason) {

switch (failureReason) {
case DTOConstants.FAILURE_REASON_UNKNOWN :
return "UNKNOWN";
case DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE :
return "FAILURE_REASON_UNKNOWN";
case DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE :
return "SERVICE_NOT_GETTABLE";
case DTOConstants.FAILURE_REASON_VALIDATION_FAILED :
return "VALIDATION_FAILED";
case DTOConstants.FAILURE_REASON_SERVICE_IN_USE :
return "SERVICE_IN_USE";
case DTOConstants.FAILURE_REASON_SERVLET_WRITE_TO_LOCATION_DENIED :
return "SERVLET_WRITE_TO_LOCATION_DENIED";
case DTOConstants.FAILURE_REASON_WHITEBOARD_WRITE_TO_DEFAULT_DENIED :
return "WHITEBOARD_WRITE_TO_DEFAULT_DENIED";
case DTOConstants.FAILURE_REASON_SERVLET_READ_FROM_DEFAULT_DENIED :
return "SERVLET_READ_FROM_DEFAULT_DENIED";
case DTOConstants.FAILURE_REASON_WHITEBOARD_WRITE_TO_LOCATION_DENIED :
return "WHITEBOARD_WRITE_TO_LOCATION_DENIED";
default :
return failureReason + "";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.osgi.framework.BundleContext;
import org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime;
import org.osgi.service.jaxrs.runtime.dto.ApplicationDTO;
import org.osgi.service.jaxrs.runtime.dto.DTOConstants;
import org.osgi.service.jaxrs.runtime.dto.ExtensionDTO;
import org.osgi.service.jaxrs.runtime.dto.FailedApplicationDTO;
import org.osgi.service.jaxrs.runtime.dto.FailedExtensionDTO;
Expand Down Expand Up @@ -48,6 +49,7 @@ void dtos(DTOFormatter formatter) {
.fields("*")
.line()
.fields("*")
.format("failureReason", f -> failedReason(f.failureReason))
.part()
.as(dto -> String.format("[%s] %s", dto.serviceId, dto.name));

Expand All @@ -64,6 +66,7 @@ void dtos(DTOFormatter formatter) {
.fields("*")
.line()
.fields("*")
.format("failureReason", f -> failedReason(f.failureReason))
.part()
.as(dto -> String.format("[%s] %s", dto.serviceId, dto.name));

Expand All @@ -80,6 +83,7 @@ void dtos(DTOFormatter formatter) {
.fields("*")
.line()
.fields("*")
.format("failureReason", f -> failedReason(f.failureReason))
.part()
.as(dto -> String.format("[%s] %s", dto.serviceId, dto.name));

Expand Down Expand Up @@ -143,4 +147,26 @@ private static boolean runtimeHasServiceId(JaxrsServiceRuntime runtime, long ser
return service_id == runtime.getRuntimeDTO().serviceDTO.id;
}

private String failedReason(int failureReason) {

switch (failureReason) {
case DTOConstants.FAILURE_REASON_UNKNOWN :
return "UNKNOWN";
case DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE :
return "FAILURE_REASON_UNKNOWN";
case DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE :
return "SERVICE_NOT_GETTABLE";
case DTOConstants.FAILURE_REASON_VALIDATION_FAILED :
return "VALIDATION_FAILED";
case DTOConstants.FAILURE_REASON_REQUIRED_EXTENSIONS_UNAVAILABLE :
return "REQUIRED_EXTENSIONS_UNAVAILABLE";
case DTOConstants.FAILURE_REASON_DUPLICATE_NAME :
return "DUPLICATE_NAME";
case DTOConstants.FAILURE_REASON_REQUIRED_APPLICATION_UNAVAILABLE :
return "REQUIRED_APPLICATION_UNAVAILABLE";
default :
return failureReason + "";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ private String preDeclared(String expression) {
case Constants.CRON_EXPRESSION_WEEKLY :
return "2 0 0 ? * MON";

case Constants.CRON_EXPRESSION_DAYLY :
case Constants.CRON_EXPRESSION_DAILY :
return "3 0 0 * * ?";

case Constants.CRON_EXPRESSION_HOURLY :
return "4 0 * * * ?";

case Constants.CRON_EXPRESSION_MINUTLY :
return "* 0 * * * *";
case Constants.CRON_EXPRESSION_MINUTELY :
return "0 * * * * *";

case Constants.CRON_EXPRESSION_SECUNDLY:
case Constants.CRON_EXPRESSION_SECONDLY:
return "* * * * * *";

case Constants.CRON_EXPRESSION_REBOOT :
Expand Down
Loading