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

Provide support for setting the schema in JBatch #39

Merged
merged 1 commit into from
Oct 23, 2014
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 @@ -82,6 +82,8 @@ public class ListBatchRuntimeConfiguration
private static final String DATA_SOURCE_NAME = "dataSourceLookupName";

private static final String EXECUTOR_SERVICE_NAME = "executorServiceLookupName";

private static final String SCHEMA_NAME = "schemaName";

@Inject
protected Target targetUtil;
Expand All @@ -105,6 +107,7 @@ protected void executeCommand(AdminCommandContext context, Properties extraProps

map.put(DATA_SOURCE_NAME, batchRuntimeConfiguration.getDataSourceLookupName());
map.put(EXECUTOR_SERVICE_NAME, batchRuntimeConfiguration.getExecutorServiceLookupName());
map.put(SCHEMA_NAME, batchRuntimeConfiguration.getSchemaName());
extraProps.put("listBatchRuntimeConfiguration", map);

ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
Expand All @@ -119,6 +122,9 @@ protected void executeCommand(AdminCommandContext context, Properties extraProps
case EXECUTOR_SERVICE_NAME:
data[index] = batchRuntimeConfiguration.getExecutorServiceLookupName();
break;
case SCHEMA_NAME:
data[index] = batchRuntimeConfiguration.getSchemaName();
break;
default:
throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
}
Expand All @@ -131,7 +137,7 @@ protected void executeCommand(AdminCommandContext context, Properties extraProps
@Override
protected final String[] getAllHeaders() {
return new String[] {
DATA_SOURCE_NAME, EXECUTOR_SERVICE_NAME
DATA_SOURCE_NAME, EXECUTOR_SERVICE_NAME, SCHEMA_NAME
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public class SetBatchRuntimeConfiguration

@Param(name = "executorServiceLookupName", shortName = "x", optional = true)
private String executorServiceLookupName;

@Param(name = "schemaName", shortName = "n", optional = true)
private String schemaName;

@Override
public void execute(final AdminCommandContext context) {
Expand All @@ -117,7 +120,6 @@ public void execute(final AdminCommandContext context) {

try {
Config config = targetUtil.getConfig(target);
System.out.println("** EXECUTING -d " + dataSourceLookupName + " -x " + executorServiceLookupName);

BatchRuntimeConfiguration batchRuntimeConfiguration = config.getExtensionByType(BatchRuntimeConfiguration.class);
if (batchRuntimeConfiguration != null) {
Expand Down Expand Up @@ -150,6 +152,10 @@ public Object run(final BatchRuntimeConfiguration batchRuntimeConfigurationProxy
throw new GlassFishBatchValidationException("No executor service bound to name = " + executorServiceLookupName);
}
}
if (schemaName != null && !encounteredError) {
batchRuntimeConfigurationProxy.setSchemaName(schemaName);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ public interface BatchRuntimeConfiguration
@Attribute(defaultValue = "concurrent/__defaultManagedExecutorService")
String getExecutorServiceLookupName();

@Attribute(defaultValue = "APP")
String getSchemaName();

public void setDataSourceLookupName(String value);

public void setExecutorServiceLookupName(String value);

public void setSchemaName(String value);

}
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public static String getDefaultDataSourceLookupNameForTarget(String targetName)
}

private String getSchemaName() {
return "APP";
return batchRuntimeConfiguration.getSchemaName();
}

public String getExecutorServiceLookupName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
/>
</sun:dropDown>
</sun:property>
<sun:property id="schemaNameProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18nf.batch.configuration.schemaName}" helpText="$resource{i18nf.batch.configuration.schemaNameHelp}">
<sun:textField id="schemaName" columns="$int{40}" maxLength="30" text="#{pageSession.valueMap['schemaName']}" />
</sun:property>
</sun:propertySheetSection>

<sun:hidden id="helpKey" value="$resource{help_full.batchConfiguration}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ batch.configuration.executorServiceLookupName=Executor Service Lookup Name:
batch.configuration.executorServiceLookupNameHelp=JNDI lookup name of the managed executor service that provides threads to jobs
batch.configuration.dataSourceLookupName=Data Source Lookup Name:
batch.configuration.dataSourceLookupNameHelp=JNDI lookup name of the data source that stores job information
batch.configuration.schemaName=Database Schema Name
batch.configuration.schemaNameHelp=Name of the schema containing the required batch tables