本文整理了Java中org.jboss.as.controller.registry.Resource.getChildren
方法的一些代码示例,展示了Resource.getChildren
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.getChildren
方法的具体详情如下:
包路径:org.jboss.as.controller.registry.Resource
类名称:Resource
方法名:getChildren
[英]Get the children for a given type.
[中]
代码示例来源:origin: wildfly/wildfly
/**
* @param childType
* @return
* @see org.jboss.as.controller.registry.Resource#getChildren(java.lang.String)
*/
public Set<ResourceEntry> getChildren(String childType) {
return delegate.getChildren(childType);
}
代码示例来源:origin: wildfly/wildfly
@Override
public Set<ResourceEntry> getChildren(String childType) {
return delegate.getChildren(childType);
}
代码示例来源:origin: wildfly/wildfly
@Override
public Set<ResourceEntry> getChildren(String childType) {
return delegate.getChildren(childType);
}
代码示例来源:origin: wildfly/wildfly
@Override
public Set<ResourceEntry> getChildren(final String childType) {
if (BALANCER.equals(childType)) {
final Set<String> names = getChildrenNames(childType);
final Set<ResourceEntry> result = new LinkedHashSet<>(names.size());
for (String name : names) {
result.add(new ModClusterBalancerResource(name, this.name));
}
return result;
}
return delegate.getChildren(childType);
}
代码示例来源:origin: wildfly/wildfly
@Override
public Set<ResourceEntry> getChildren(final String childType) {
if (BatchJobExecutionResourceDefinition.EXECUTION.equals(childType)) {
final Set<String> names = getChildrenNames(childType);
final Set<ResourceEntry> result = new LinkedHashSet<>(names.size());
for (String name : names) {
result.add(new PlaceholderResourceEntry(BatchJobExecutionResourceDefinition.EXECUTION, name));
}
return result;
}
return delegate.getChildren(childType);
}
代码示例来源:origin: wildfly/wildfly
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.siteName = SITE.resolveModelAttribute(context, model).asString();
PathAddress address = context.getCurrentAddress();
Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
Set<Resource.ResourceEntry> entries = resource.getChildren(RemoteSiteResourceDefinition.WILDCARD_PATH.getKey());
this.sites = new ArrayList<>(entries.size());
for (Resource.ResourceEntry entry : entries) {
this.sites.add(new ServiceSupplierDependency<>(new RemoteSiteServiceNameProvider(address, entry.getPathElement())));
}
return super.configure(context, model);
}
代码示例来源:origin: wildfly/wildfly
static PathAddress translateProxyPath(OperationContext context, PathAddress address) throws OperationFailedException {
Set<Resource.ResourceEntry> children = context.readResourceFromRoot(address, false).getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey());
if (children.size() != 1) {
throw new OperationFailedException(ModClusterLogger.ROOT_LOGGER.legacyOperationsWithMultipleProxies());
}
PathAddress proxyPath = PathAddress.pathAddress(ProxyConfigurationResourceDefinition.pathElement(children.iterator().next().getName()));
address = address.append(proxyPath);
return address;
}
代码示例来源:origin: wildfly/wildfly
@Override
public DiscardPolicy checkResource(TransformationContext context, PathAddress address) {
Resource resource = context.readResourceFromRoot(address.getParent());
if (resource.hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey()) && resource.getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey()).size() > 1) {
return DiscardPolicy.REJECT_AND_WARN;
}
return DiscardPolicy.NEVER;
}
}
代码示例来源:origin: wildfly/wildfly
private static boolean removeInCurrentStep(Resource resource) {
for (String childType : resource.getChildTypes()) {
for (Resource.ResourceEntry entry : resource.getChildren(childType)) {
if (!entry.isRuntime() && resource.hasChild(entry.getPathElement())) {
return false;
}
}
}
return true;
}
代码示例来源:origin: wildfly/wildfly
@Override
public void convert(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) {
if (value.isDefined()) {
PathAddress rootAddress = address.subAddress(0, address.size() - 4);
PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources"));
Resource subsystem = context.readResourceFromRoot(subsystemAddress);
String poolName = value.asString();
for (String type : Arrays.asList("data-source", "xa-data-source")) {
if (subsystem.hasChildren(type)) {
for (Resource.ResourceEntry entry : subsystem.getChildren(type)) {
if (entry.getName().equals(poolName)) {
value.set(entry.getModel().get("jndi-name"));
return;
}
}
}
}
}
}
};
代码示例来源:origin: wildfly/wildfly
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
// Cache the TransactionManager service name for use by our runtime services
ConnectorServices.registerCapabilityServiceName(LOCAL_TRANSACTION_PROVIDER_CAPABILITY, context.getCapabilityServiceName(LOCAL_TRANSACTION_PROVIDER_CAPABILITY, null));
final Resource subsystemResource = context.readResourceFromRoot(PathAddress.pathAddress(ResourceAdaptersExtension.SUBSYSTEM_PATH));
ResourceAdaptersSubsystemService service = new ResourceAdaptersSubsystemService();
CopyOnWriteArrayListMultiMap<String, ServiceName> value = service.getValue();
for (Resource.ResourceEntry re : subsystemResource.getChildren(RESOURCEADAPTER_NAME)) {
value.putIfAbsent(re.getModel().get(ARCHIVE.getName()).asString(), ConnectorServices.RA_SERVICE.append(re.getName()));
}
final ServiceBuilder<?> builder = context.getServiceTarget().addService(ConnectorServices.RESOURCEADAPTERS_SUBSYSTEM_SERVICE, service);
builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public AttributeValueTranslator getWriteTranslator() {
return (context, value) -> {
String jndiName = value.asString();
PathAddress address = context.getCurrentAddress();
PathAddress rootAddress = address.subAddress(0, address.size() - 4);
PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources"));
Resource subsystem = context.readResourceFromRoot(subsystemAddress);
for (String type : Arrays.asList("data-source", "xa-data-source")) {
if (subsystem.hasChildren(type)) {
for (Resource.ResourceEntry entry : subsystem.getChildren(type)) {
ModelNode model = entry.getModel();
if (model.get("jndi-name").asString().equals(jndiName)) {
return new ModelNode(entry.getName());
}
}
}
}
throw InfinispanLogger.ROOT_LOGGER.dataSourceJndiNameNotFound(jndiName);
};
}
};
代码示例来源:origin: wildfly/wildfly
@Override
public TransformedOperation transformOperation(final TransformationContext context, final PathAddress address, final ModelNode operation) throws OperationFailedException {
Resource original = context.readResourceFromRoot(address);
String defaultDataStore = original.getModel().get(TimerServiceResourceDefinition.DEFAULT_DATA_STORE.getName()).asString();
boolean hasFileDataStore = original.hasChild(PathElement.pathElement(EJB3SubsystemModel.FILE_DATA_STORE_PATH.getKey(), defaultDataStore));
if (original.getChildren(EJB3SubsystemModel.FILE_DATA_STORE).size() > 1 ||
!hasFileDataStore) {
return new TransformedOperation(operation, new OperationRejectionPolicy() {
@Override
public boolean rejectOperation(ModelNode preparedResult) {
return true;
}
@Override
public String getFailureDescription() {
return context.getLogger().getRejectedResourceWarning(address, operation);
}
}, OperationResultTransformer.ORIGINAL_RESULT);
}
operation.get(TimerServiceResourceDefinition.THREAD_POOL_NAME.getName()).set(original.getModel().get(TimerServiceResourceDefinition.THREAD_POOL_NAME.getName()));
return new TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT);
}
代码示例来源:origin: wildfly/wildfly
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
Resource existing = context.readResource(PathAddress.EMPTY_ADDRESS);
OperationStepHandler addHandler = context.getResourceRegistration().getSubModel(PathAddress.EMPTY_ADDRESS.append(newKeyName)).getOperationHandler(PathAddress.EMPTY_ADDRESS, "add");
oldAttribute.validateOperation(operation);
List<ModelNode> modules = new ArrayList<ModelNode>(operation.get(oldAttribute.getName()).asList());
Collections.reverse(modules); //need to reverse it to make sure they are added in proper order
for (ModelNode module : modules) {
ModelNode addModuleOp = module.clone();
String code = addModuleOp.get(Constants.CODE).asString();
PathElement relativePath = PathElement.pathElement(newKeyName, code);
PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(relativePath);
addModuleOp.get(OP_ADDR).set(address.toModelNode());
addModuleOp.get(OP).set(ADD);
context.addStep(new ModelNode(), addModuleOp, addHandler, OperationContext.Stage.MODEL, true);
}
//remove on the end to make sure it is executed first
for (Resource.ResourceEntry entry : existing.getChildren(newKeyName)) {
PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(entry.getPathElement());
ModelNode removeModuleOp = Util.createRemoveOperation(address);
context.addStep(new ModelNode(), removeModuleOp, new SecurityDomainReloadRemoveHandler(), OperationContext.Stage.MODEL, true);
}
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
Resource existing = context.readResource(PathAddress.EMPTY_ADDRESS);
OperationStepHandler addHandler = context.getResourceRegistration().getSubModel(PathAddress.EMPTY_ADDRESS.append(newKeyName)).getOperationHandler(PathAddress.EMPTY_ADDRESS, "add");
ModelNode value = operation.get(VALUE);
if (value.isDefined()) {
List<ModelNode> modules = new ArrayList<ModelNode>(value.asList());
Collections.reverse(modules); //need to reverse it to make sure they are added in proper order
for (ModelNode module : modules) {
ModelNode addModuleOp = module.clone();
String code = addModuleOp.get(Constants.CODE).asString();
PathElement relativePath = PathElement.pathElement(newKeyName, code);
PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(relativePath);
addModuleOp.get(OP_ADDR).set(address.toModelNode());
addModuleOp.get(OP).set(ADD);
context.addStep(new ModelNode(), addModuleOp, addHandler, OperationContext.Stage.MODEL, true);
}
}
//remove on the end to make sure it is executed first
for (Resource.ResourceEntry entry : existing.getChildren(newKeyName)) {
PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(entry.getPathElement());
ModelNode removeModuleOp = Util.createRemoveOperation(address);
context.addStep(new ModelNode(), removeModuleOp, new SecurityDomainReloadRemoveHandler(), OperationContext.Stage.MODEL, true);
}
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.statisticsEnabled = StackResourceDefinition.Attribute.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
Resource resource = context.readResourceFromRoot(this.address, false);
Iterator<Resource.ResourceEntry> transports = resource.getChildren(TransportResourceDefinition.WILDCARD_PATH.getKey()).iterator();
if (!transports.hasNext()) {
throw JGroupsLogger.ROOT_LOGGER.transportNotDefined(this.getName());
}
this.transport = new ServiceSupplierDependency<>(new SingletonProtocolServiceNameProvider(this.address, transports.next().getPathElement()));
Set<Resource.ResourceEntry> entries = resource.getChildren(ProtocolResourceDefinition.WILDCARD_PATH.getKey());
this.protocols = new ArrayList<>(entries.size());
for (Resource.ResourceEntry entry : entries) {
this.protocols.add(new ServiceSupplierDependency<>(new ProtocolServiceNameProvider(this.address, entry.getPathElement())));
}
this.relay = resource.hasChild(RelayResourceDefinition.PATH) ? new ServiceSupplierDependency<>(new SingletonProtocolServiceNameProvider(this.address, RelayResourceDefinition.PATH)) : null;
this.socketBindingManager = new ServiceSupplierDependency<>(CommonRequirement.SOCKET_BINDING_MANAGER.getServiceName(context));
return this;
}
代码示例来源:origin: wildfly/wildfly
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
Resource resource = context.getCurrentAddress().equals(this.address) ? context.readResourceFromRoot(this.address, false) : PlaceholderResource.INSTANCE;
Set<Resource.ResourceEntry> entries = resource.getChildren(ProtocolResourceDefinition.WILDCARD_PATH.getKey());
this.protocols = new ArrayList<>(entries.size());
for (Resource.ResourceEntry entry : entries) {
this.protocols.add(new ServiceSupplierDependency<>(new ProtocolServiceNameProvider(this.address, entry.getPathElement())));
}
String channelName = this.address.getParent().getLastElement().getValue();
this.parentChannel = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL.getServiceName(context, channelName));
this.parentFactory = new ServiceSupplierDependency<>(JGroupsRequirement.CHANNEL_SOURCE.getServiceName(context, channelName));
return this;
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) {
PathAddress rebuiltAddress = PathAddress.EMPTY_ADDRESS;
for (PathElement pathElement : aliasAddress) {
if (pathElement.equals(LEGACY_PATH)) {
try {
if (aliasContext.readResourceFromRoot(rebuiltAddress, false).hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey())) {
Set<Resource.ResourceEntry> children = aliasContext.readResourceFromRoot(rebuiltAddress, false).getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey());
if (children.size() > 1 && !Operations.getOperationName(aliasContext.getOperation()).equals(AliasContext.RECURSIVE_GLOBAL_OP)) {
throw new IllegalStateException(ModClusterLogger.ROOT_LOGGER.legacyOperationsWithMultipleProxies());
}
PathAddress proxyPath = PathAddress.pathAddress(ProxyConfigurationResourceDefinition.pathElement(children.iterator().next().getName()));
rebuiltAddress = rebuiltAddress.append(proxyPath);
} else {
// handle :add
rebuiltAddress = rebuiltAddress.append(ProxyConfigurationResourceDefinition.pathElement("default"));
}
} catch (Resource.NoSuchResourceException ignore) {
// handle recursive-global-op
rebuiltAddress = rebuiltAddress.append(ProxyConfigurationResourceDefinition.WILDCARD_PATH);
}
} else {
rebuiltAddress = rebuiltAddress.append(pathElement);
}
}
return rebuiltAddress;
}
});
代码示例来源:origin: wildfly/wildfly
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.connectionTimeout = Attribute.CONNECTION_TIMEOUT.resolveModelAttribute(context, model).asInt();
this.defaultRemoteCluster = Attribute.DEFAULT_REMOTE_CLUSTER.resolveModelAttribute(context, model).asString();
this.keySizeEstimate = Attribute.KEY_SIZE_ESTIMATE.resolveModelAttribute(context, model).asInt();
this.maxRetries = Attribute.MAX_RETRIES.resolveModelAttribute(context, model).asInt();
this.protocolVersion = Attribute.PROTOCOL_VERSION.resolveModelAttribute(context, model).asString();
this.socketTimeout = Attribute.SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt();
this.tcpNoDelay = Attribute.TCP_NO_DELAY.resolveModelAttribute(context, model).asBoolean();
this.tcpKeepAlive = Attribute.TCP_KEEP_ALIVE.resolveModelAttribute(context, model).asBoolean();
this.valueSizeEstimate = Attribute.VALUE_SIZE_ESTIMATE.resolveModelAttribute(context, model).asInt();
this.clusters.clear();
Resource container = context.readResource(PathAddress.EMPTY_ADDRESS);
for (Resource.ResourceEntry entry : container.getChildren(RemoteClusterResourceDefinition.WILDCARD_PATH.getKey())) {
String clusterName = entry.getName();
ModelNode cluster = entry.getModel();
List<String> bindings = StringListAttributeDefinition.unwrapValue(context, RemoteClusterResourceDefinition.Attribute.SOCKET_BINDINGS.resolveModelAttribute(context, cluster));
List<SupplierDependency<OutboundSocketBinding>> bindingDependencies = new ArrayList<>(bindings.size());
for (String binding : bindings) {
bindingDependencies.add(new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, binding)));
}
this.clusters.put(clusterName, bindingDependencies);
}
return this;
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void describe(OrderedChildTypesAttachment orderedChildTypesAttachment, Resource resource, ModelNode addressModel, ModelNode result, ImmutableManagementResourceRegistration registration) {
if (resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) return;
result.add(createAddOperation(orderedChildTypesAttachment, addressModel, resource, registration.getChildAddresses(PathAddress.EMPTY_ADDRESS)));
PathAddress address = PathAddress.pathAddress(addressModel);
for (String type : resource.getChildTypes()) {
for (Resource.ResourceEntry entry : resource.getChildren(type)) {
PathElement path = entry.getPathElement();
ImmutableManagementResourceRegistration childRegistration = Optional.ofNullable(registration.getSubModel(PathAddress.pathAddress(path))).orElse(registration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(path.getKey()))));
PathAddress childAddress = address.append(path);
this.describe(orderedChildTypesAttachment, entry, childAddress.toModelNode(), result, childRegistration);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!