本文整理汇总了Java中org.jboss.as.controller.registry.Resource.hasChild方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.hasChild方法的具体用法?Java Resource.hasChild怎么用?Java Resource.hasChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.as.controller.registry.Resource
的用法示例。
在下文中一共展示了Resource.hasChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkNoOtherHandlerWithTheSameName
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
static void checkNoOtherHandlerWithTheSameName(OperationContext context) throws OperationFailedException {
final PathAddress address = context.getCurrentAddress();
final PathAddress parentAddress = address.subAddress(0, address.size() - 1);
final Resource resource = context.readResourceFromRoot(parentAddress);
final PathElement element = address.getLastElement();
final String handlerType = element.getKey();
final String handlerName = element.getValue();
for (String otherHandler: HANDLER_TYPES) {
if (handlerType.equals(otherHandler)) {
// we need to check other handler types for the same name
continue;
}
final PathElement check = PathElement.pathElement(otherHandler, handlerName);
if (resource.hasChild(check)) {
throw DomainManagementLogger.ROOT_LOGGER.handlerAlreadyExists(check.getValue(), parentAddress.append(check));
}
}
}
示例2: checkCanRemove
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
protected void checkCanRemove(OperationContext context, ModelNode operation) throws OperationFailedException {
final String deploymentName = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue();
final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
if(root.hasChild(PathElement.pathElement(SERVER_GROUP))) {
final List<String> badGroups = new ArrayList<String>();
for(final Resource.ResourceEntry entry : root.getChildren(SERVER_GROUP)) {
if(entry.hasChild(PathElement.pathElement(DEPLOYMENT, deploymentName))) {
badGroups.add(entry.getName());
}
}
if (badGroups.size() > 0) {
throw new OperationFailedException(DomainControllerLogger.ROOT_LOGGER.cannotRemoveDeploymentInUse(deploymentName, badGroups));
}
}
}
示例3: processServerGroup
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private static void processServerGroup(final RequiredConfigurationHolder holder, final String group, final Resource domain, ExtensionRegistry extensionRegistry) {
final PathElement groupElement = PathElement.pathElement(SERVER_GROUP, group);
if (!domain.hasChild(groupElement)) {
return;
}
final Resource serverGroup = domain.getChild(groupElement);
final ModelNode model = serverGroup.getModel();
if (model.hasDefined(SOCKET_BINDING_GROUP)) {
final String socketBindingGroup = model.get(SOCKET_BINDING_GROUP).asString();
processSocketBindingGroup(domain, socketBindingGroup, holder);
}
final String profile = model.get(PROFILE).asString();
processProfile(domain, profile, holder, extensionRegistry);
}
示例4: processSocketBindingGroup
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private static void processSocketBindingGroup(final Resource domain, final String socketBindingGroup, final RequiredConfigurationHolder holder) {
final Set<String> socketBindingGroups = holder.socketBindings;
if (socketBindingGroups.contains(socketBindingGroup)) {
return;
}
socketBindingGroups.add(socketBindingGroup);
final PathElement socketBindingGroupElement = PathElement.pathElement(SOCKET_BINDING_GROUP, socketBindingGroup);
if (domain.hasChild(socketBindingGroupElement)) {
final Resource resource = domain.getChild(socketBindingGroupElement);
if (resource.getModel().hasDefined(INCLUDES)) {
for (final ModelNode include : resource.getModel().get(INCLUDES).asList()) {
processSocketBindingGroup(domain, include.asString(), holder);
}
}
}
ControllerLogger.ROOT_LOGGER.tracef("Recorded need for socket-binding-group %s", socketBindingGroup);
}
示例5: execute
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
ModelNode model = resource.getModel();
boolean hasLegacy = false;
if (forDomain) {
for (final AttributeDefinition attribute : RemotingSubsystemRootResource.LEGACY_ATTRIBUTES) {
if (model.hasDefined(attribute.getName())) {
hasLegacy = true;
break;
}
}
}
if (!hasLegacy && !resource.hasChild(RemotingEndpointResource.ENDPOINT_PATH)) {
// User didn't configure either worker-thread-pool or endpoint. Add a default endpoint resource so
// users can read the default config attribute values
context.addResource(PathAddress.pathAddress(RemotingEndpointResource.ENDPOINT_PATH), Resource.Factory.create());
}
}
示例6: hasDeploymentSubModel
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
/**
* Checks to see if a resource has already been registered for the specified address on the subsystem.
*
* @param subsystemName the name of the subsystem
* @param address the address to check
*
* @return {@code true} if the address exists on the subsystem otherwise {@code false}
*/
public boolean hasDeploymentSubModel(final String subsystemName, final PathAddress address) {
final Resource root = deploymentUnit.getAttachment(DEPLOYMENT_RESOURCE);
final PathElement subsystem = PathElement.pathElement(SUBSYSTEM, subsystemName);
boolean found = false;
if (root.hasChild(subsystem)) {
if (address == PathAddress.EMPTY_ADDRESS) {
return true;
}
Resource parent = root.getChild(subsystem);
for (PathElement child : address) {
if (parent.hasChild(child)) {
found = true;
parent = parent.getChild(child);
} else {
found = false;
break;
}
}
}
return found;
}
示例7: processProfiles
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private void processProfiles(final Resource domain, final String profile, final Set<String> profiles) {
if (!profiles.contains(profile)) {
profiles.add(profile);
final PathElement pathElement = PathElement.pathElement(PROFILE, profile);
if (domain.hasChild(pathElement)) {
final Resource resource = domain.getChild(pathElement);
final ModelNode model = resource.getModel();
if (model.hasDefined(INCLUDES)) {
for (final ModelNode include : model.get(INCLUDES).asList()) {
processProfiles(domain, include.asString(), profiles);
}
}
}
}
}
示例8: getOrCreate
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private static Resource getOrCreate(final Resource parent, final PathElement element, final Resource desired) {
synchronized (parent) {
if (parent.hasChild(element)) {
if (desired == null) {
return parent.requireChild(element);
} else {
throw new IllegalStateException();
}
} else {
return register(parent, element, desired);
}
}
}
示例9: processProfile
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
static void processProfile(final Resource domain, String profile, Set<String> profiles) {
if (!profiles.contains(profile)) {
profiles.add(profile);
final PathElement pathElement = PathElement.pathElement(PROFILE, profile);
if (domain.hasChild(pathElement)) {
final Resource resource = domain.getChild(pathElement);
final ModelNode model = resource.getModel();
if (model.hasDefined(INCLUDES)) {
for (final ModelNode include : model.get(INCLUDES).asList()) {
processProfile(domain, include.asString(), profiles);
}
}
}
}
}
示例10: processSocketBindingGroup
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
static void processSocketBindingGroup(final Resource domain, final String name, final Set<String> socketBindings) {
if (!socketBindings.contains(name)) {
socketBindings.add(name);
final PathElement pathElement = PathElement.pathElement(SOCKET_BINDING_GROUP, name);
if (domain.hasChild(pathElement)) {
final Resource resource = domain.getChild(pathElement);
final ModelNode model = resource.getModel();
if (model.hasDefined(INCLUDES)) {
for (final ModelNode include : model.get(INCLUDES).asList()) {
processSocketBindingGroup(domain, include.asString(), socketBindings);
}
}
}
}
}
示例11: processServerConfig
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
/**
* Determine the relevant pieces of configuration which need to be included when processing the domain model.
*
* @param root the resource root
* @param requiredConfigurationHolder the resolution context
* @param serverConfig the server config
* @param extensionRegistry the extension registry
*/
static void processServerConfig(final Resource root, final RequiredConfigurationHolder requiredConfigurationHolder, final IgnoredNonAffectedServerGroupsUtil.ServerConfigInfo serverConfig, final ExtensionRegistry extensionRegistry) {
final Set<String> serverGroups = requiredConfigurationHolder.serverGroups;
final Set<String> socketBindings = requiredConfigurationHolder.socketBindings;
String sbg = serverConfig.getSocketBindingGroup();
if (sbg != null && !socketBindings.contains(sbg)) {
processSocketBindingGroup(root, sbg, requiredConfigurationHolder);
}
final String groupName = serverConfig.getServerGroup();
final PathElement groupElement = PathElement.pathElement(SERVER_GROUP, groupName);
// Also check the root, since this also gets executed on the slave which may not have the server-group configured yet
if (!serverGroups.contains(groupName) && root.hasChild(groupElement)) {
final Resource serverGroup = root.getChild(groupElement);
final ModelNode groupModel = serverGroup.getModel();
serverGroups.add(groupName);
// Include the socket binding groups
if (groupModel.hasDefined(SOCKET_BINDING_GROUP)) {
final String socketBindingGroup = groupModel.get(SOCKET_BINDING_GROUP).asString();
processSocketBindingGroup(root, socketBindingGroup, requiredConfigurationHolder);
}
final String profileName = groupModel.get(PROFILE).asString();
processProfile(root, profileName, requiredConfigurationHolder, extensionRegistry);
}
}
示例12: addResource
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
public void addResource(PathAddress relativeAddress, Resource toAdd) {
Resource model = root;
final Iterator<PathElement> i = operationAddress.append(relativeAddress).iterator();
while (i.hasNext()) {
final PathElement element = i.next();
if (element.isMultiTarget()) {
throw ControllerLogger.ROOT_LOGGER.cannotWriteTo("*");
}
if (!i.hasNext()) {
if (model.hasChild(element)) {
throw ControllerLogger.ROOT_LOGGER.duplicateResourceAddress(relativeAddress);
} else {
model.registerChild(element, toAdd);
model = toAdd;
}
} else {
model = model.getChild(element);
if (model == null) {
PathAddress ancestor = PathAddress.EMPTY_ADDRESS;
for (PathElement pe : relativeAddress) {
ancestor = ancestor.append(pe);
if (element.equals(pe)) {
break;
}
}
throw ControllerLogger.ROOT_LOGGER.resourceNotFound(ancestor, relativeAddress);
}
}
}
}
示例13: executeSingleTargetChild
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
@Override
protected void executeSingleTargetChild(PathAddress base, PathElement currentElement, PathAddress newRemaining, OperationContext context, boolean ignoreMissing) {
final PathAddress next = base.append(currentElement);
// Either require the child or a remote target
final Resource resource = context.readResource(base, false);
final ImmutableManagementResourceRegistration nr = context.getResourceRegistration().getSubModel(next);
if (resource.hasChild(currentElement) || (nr != null && nr.isRemote())) {
safeExecute(next, newRemaining, context, nr, ignoreMissing);
}
//if we are on the wrong host no need to do anything
else if(!resource.hasChild(currentElement)) {
throw new Resource.NoSuchResourceException(currentElement);
}
}
示例14: requireChild
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
private static Resource requireChild(final Resource resource, final PathElement childPath, final PathAddress fullAddress) {
if (resource.hasChild(childPath)) {
return resource.requireChild(childPath);
} else {
PathAddress missing = PathAddress.EMPTY_ADDRESS;
for (PathElement search : fullAddress) {
missing = missing.append(search);
if (search.equals(childPath)) {
break;
}
}
throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(missing);
}
}
示例15: createResourceFromDomainModelOp
import org.jboss.as.controller.registry.Resource; //导入方法依赖的package包/类
/**
* Create a resource based on the result of the {@code ReadMasterDomainModelHandler}.
*
* @param result the operation result
* @param extensions set to track extensions
* @return the resource
*/
static Resource createResourceFromDomainModelOp(final ModelNode result, final Set<String> extensions) {
final Resource root = Resource.Factory.create();
for (ModelNode model : result.asList()) {
final PathAddress resourceAddress = PathAddress.pathAddress(model.require(DOMAIN_RESOURCE_ADDRESS));
if (resourceAddress.size() == 1) {
final PathElement element = resourceAddress.getElement(0);
if (element.getKey().equals(EXTENSION)) {
if (!extensions.contains(element.getValue())) {
extensions.add(element.getValue());
}
}
}
Resource resource = root;
final Iterator<PathElement> i = resourceAddress.iterator();
if (!i.hasNext()) { //Those are root attributes
resource.getModel().set(model.require(DOMAIN_RESOURCE_MODEL));
}
while (i.hasNext()) {
final PathElement e = i.next();
if (resource.hasChild(e)) {
resource = resource.getChild(e);
} else {
/*
{
"domain-resource-address" => [
("profile" => "test"),
("subsystem" => "test")
],
"domain-resource-model" => {},
"domain-resource-properties" => {"ordered-child-types" => ["ordered-child"]}
}*/
final Resource nr;
if (model.hasDefined(DOMAIN_RESOURCE_PROPERTIES, ORDERED_CHILD_TYPES_PROPERTY)) {
List<ModelNode> list = model.get(DOMAIN_RESOURCE_PROPERTIES, ORDERED_CHILD_TYPES_PROPERTY).asList();
Set<String> orderedChildTypes = new HashSet<String>(list.size());
for (ModelNode type : list) {
orderedChildTypes.add(type.asString());
}
nr = Resource.Factory.create(false, orderedChildTypes);
} else {
nr = Resource.Factory.create();
}
resource.registerChild(e, nr);
resource = nr;
}
if (!i.hasNext()) {
resource.getModel().set(model.require(DOMAIN_RESOURCE_MODEL));
}
}
}
return root;
}