-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1116 from hpehl/JBEAP-26463
JBEAP-26463: Split runtime ds presenter/view into xa and non-xa version
- Loading branch information
Showing
7 changed files
with
285 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
...rc/main/java/org/jboss/hal/client/runtime/subsystem/datasource/DataSourceXAPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* Copyright 2022 Red Hat | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.hal.client.runtime.subsystem.datasource; | ||
|
||
import javax.inject.Inject; | ||
import org.jboss.hal.core.datasource.DataSource; | ||
import org.jboss.hal.core.finder.Finder; | ||
import org.jboss.hal.core.finder.FinderPath; | ||
import org.jboss.hal.core.finder.FinderPathFactory; | ||
import org.jboss.hal.core.mvp.ApplicationFinderPresenter; | ||
import org.jboss.hal.core.mvp.HalView; | ||
import org.jboss.hal.core.mvp.HasPresenter; | ||
import org.jboss.hal.dmr.Operation; | ||
import org.jboss.hal.dmr.ResourceAddress; | ||
import org.jboss.hal.dmr.dispatch.Dispatcher; | ||
import org.jboss.hal.meta.StatementContext; | ||
import org.jboss.hal.resources.Ids; | ||
import org.jboss.hal.resources.Names; | ||
import org.jboss.hal.resources.Resources; | ||
import org.jboss.hal.spi.Requires; | ||
import com.google.web.bindery.event.shared.EventBus; | ||
import com.gwtplatform.mvp.client.annotations.NameToken; | ||
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit; | ||
import com.gwtplatform.mvp.client.proxy.ProxyPlace; | ||
import com.gwtplatform.mvp.shared.proxy.PlaceRequest; | ||
|
||
import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.DATA_SOURCE_ADDRESS; | ||
import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_ADDRESS; | ||
import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_JDBC_ADDRESS; | ||
import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_POOL_ADDRESS; | ||
import static org.jboss.hal.client.runtime.subsystem.datasource.AddressTemplates.XA_DATA_SOURCE_TEMPLATE; | ||
import static org.jboss.hal.dmr.ModelDescriptionConstants.DATASOURCES; | ||
import static org.jboss.hal.dmr.ModelDescriptionConstants.INCLUDE_RUNTIME; | ||
import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME; | ||
import static org.jboss.hal.dmr.ModelDescriptionConstants.READ_RESOURCE_OPERATION; | ||
import static org.jboss.hal.dmr.ModelDescriptionConstants.RECURSIVE; | ||
import static org.jboss.hal.meta.token.NameTokens.DATA_SOURCE_XA_RUNTIME; | ||
|
||
public class DataSourceXAPresenter | ||
extends ApplicationFinderPresenter<DataSourceXAPresenter.MyView, DataSourceXAPresenter.MyProxy> { | ||
|
||
private final FinderPathFactory finderPathFactory; | ||
private final Dispatcher dispatcher; | ||
private final StatementContext statementContext; | ||
private final Resources resources; | ||
private String name; | ||
|
||
@Inject | ||
public DataSourceXAPresenter(EventBus eventBus, | ||
MyView view, | ||
MyProxy myProxy, | ||
Finder finder, | ||
FinderPathFactory finderPathFactory, | ||
Dispatcher dispatcher, | ||
StatementContext statementContext, | ||
Resources resources) { | ||
super(eventBus, view, myProxy, finder); | ||
this.finderPathFactory = finderPathFactory; | ||
this.dispatcher = dispatcher; | ||
this.statementContext = statementContext; | ||
this.resources = resources; | ||
} | ||
|
||
@Override | ||
protected void onBind() { | ||
super.onBind(); | ||
getView().setPresenter(this); | ||
} | ||
|
||
@Override | ||
public void prepareFromRequest(PlaceRequest request) { | ||
super.prepareFromRequest(request); | ||
name = request.getParameter(NAME, null); | ||
getView().setup(); | ||
} | ||
|
||
@Override | ||
public FinderPath finderPath() { | ||
return finderPathFactory.runtimeServerPath() | ||
.append(Ids.RUNTIME_SUBSYSTEM, DATASOURCES, resources.constants().monitor(), Names.DATASOURCES) | ||
.append(Ids.DATA_SOURCE_RUNTIME, Ids.dataSourceRuntime(name, true), Names.DATASOURCE, name); | ||
} | ||
|
||
@Override | ||
protected void reload() { | ||
ResourceAddress address = XA_DATA_SOURCE_TEMPLATE.resolve(statementContext, name); | ||
Operation operation = new Operation.Builder(address, READ_RESOURCE_OPERATION) | ||
.param(INCLUDE_RUNTIME, true) | ||
.param(RECURSIVE, true) | ||
.build(); | ||
dispatcher.execute(operation, result -> getView().update(new DataSource(name, result, true))); | ||
} | ||
|
||
String getDataSource() { | ||
return name; | ||
} | ||
|
||
// @formatter:off | ||
@ProxyCodeSplit | ||
@NameToken(DATA_SOURCE_XA_RUNTIME) | ||
@Requires({ DATA_SOURCE_ADDRESS, XA_DATA_SOURCE_ADDRESS, | ||
XA_DATA_SOURCE_POOL_ADDRESS, | ||
XA_DATA_SOURCE_JDBC_ADDRESS }) | ||
public interface MyProxy extends ProxyPlace<DataSourceXAPresenter> { | ||
} | ||
|
||
public interface MyView extends HalView, HasPresenter<DataSourceXAPresenter> { | ||
void setup(); | ||
|
||
void update(DataSource dataSource); | ||
} | ||
// @formatter:on | ||
} |
Oops, something went wrong.