code
stringlengths
73
34.1k
label
stringclasses
1 value
public Class<E> getEventClass() { if (cachedClazz != null) { return cachedClazz; } Class<?> clazz = this.getClass(); while (clazz != Object.class) { try { Type mySuperclass = clazz.getGenericSuperclass(); Type tType = ((Parameterize...
java
protected final String computeId( final ITemplateContext context, final IProcessableElementTag tag, final String name, final boolean sequence) { String id = tag.getAttributeValue(this.idAttributeDefinition.getAttributeName()); if (!org.thymeleaf.util.StringUtils.isEm...
java
public String code(final String code) { if (this.theme == null) { throw new TemplateProcessingException("Theme cannot be resolved because RequestContext was not found. " + "Are you using a Context object without a RequestContext variable?"); } return this.theme.getMes...
java
private static DirectoryGrouping resolveDirectoryGrouping(final ModelNode model, final ExpressionResolver expressionResolver) { try { return DirectoryGrouping.forName(HostResourceDefinition.DIRECTORY_GROUPING.resolveModelAttribute(expressionResolver, model).asString()); } catch (OperationFai...
java
private String addPathProperty(final List<String> command, final String typeName, final String propertyName, final Map<String, String> properties, final DirectoryGrouping directoryGrouping, final File typeDir, File serverDir) { final String result; final String value =...
java
private String findLoggingProfile(final ResourceRoot resourceRoot) { final Manifest manifest = resourceRoot.getAttachment(Attachments.MANIFEST); if (manifest != null) { final String loggingProfile = manifest.getMainAttributes().getValue(LOGGING_PROFILE); if (loggingProfile != nul...
java
public static int getBytesToken(ParsingContext ctx) { String input = ctx.getInput().substring(ctx.getLocation()); int tokenOffset = 0; int i = 0; char[] inputChars = input.toCharArray(); for (; i < input.length(); i += 1) { char c = inputChars[i]; if (c ==...
java
public static void addOperation(final OperationContext context) { RbacSanityCheckOperation added = context.getAttachment(KEY); if (added == null) { // TODO support managed domain if (!context.isNormalServer()) return; context.addStep(createOperation(), INSTANCE, Stage...
java
public static ModelNode getFailureDescription(final ModelNode result) { if (isSuccessfulOutcome(result)) { throw ControllerClientLogger.ROOT_LOGGER.noFailureDescription(); } if (result.hasDefined(FAILURE_DESCRIPTION)) { return result.get(FAILURE_DESCRIPTION); } ...
java
public static ModelNode getOperationAddress(final ModelNode op) { return op.hasDefined(OP_ADDR) ? op.get(OP_ADDR) : new ModelNode(); }
java
public static String getOperationName(final ModelNode op) { if (op.hasDefined(OP)) { return op.get(OP).asString(); } throw ControllerClientLogger.ROOT_LOGGER.operationNameNotFound(); }
java
public static ModelNode createReadResourceOperation(final ModelNode address, final boolean recursive) { final ModelNode op = createOperation(READ_RESOURCE_OPERATION, address); op.get(RECURSIVE).set(recursive); return op; }
java
public ModelNode buildRequest() throws OperationFormatException { ModelNode address = request.get(Util.ADDRESS); if(prefix.isEmpty()) { address.setEmptyList(); } else { Iterator<Node> iterator = prefix.iterator(); while (iterator.hasNext()) { ...
java
private void parseUsersAuthentication(final XMLExtendedStreamReader reader, final ModelNode realmAddress, final List<ModelNode> list) throws XMLStreamException { final ModelNode usersAddress = realmAddress.clone().add(AUTHENTICATION, USERS); list.add...
java
public Set<Action.ActionEffect> getActionEffects() { switch(getImpact()) { case CLASSLOADING: case WRITE: return WRITES; case READ_ONLY: return READS; default: throw new IllegalStateException(); } }
java
private ModelNode addLocalHost(final ModelNode address, final List<ModelNode> operationList, final String hostName) { String resolvedHost = hostName != null ? hostName : defaultHostControllerName; // All further operations should modify the newly added host so the address passed in is updated. ...
java
public static byte[] hashPath(MessageDigest messageDigest, Path path) throws IOException { try (InputStream in = getRecursiveContentStream(path)) { return hashContent(messageDigest, in); } }
java
public synchronized ModelNode doCommand(String command) throws CommandFormatException, IOException { ModelNode request = cmdCtx.buildRequest(command); return execute(request, isSlowCommand(command)).getResponseNode(); }
java
public synchronized Response doCommandFullResponse(String command) throws CommandFormatException, IOException { ModelNode request = cmdCtx.buildRequest(command); boolean replacedBytes = replaceFilePathsWithBytes(request); OperationResponse response = execute(request, isSlowCommand(command) || re...
java
private File[] getFilesFromProperty(final String name, final Properties props) { String sep = WildFlySecurityManager.getPropertyPrivileged("path.separator", null); String value = props.getProperty(name, null); if (value != null) { final String[] paths = value.split(Pattern.quote(sep)...
java
public boolean putAtomic(C instance, K key, V value, Map<K, V> snapshot) { Assert.checkNotNullParam("key", key); final Map<K, V> newMap; final int oldSize = snapshot.size(); if (oldSize == 0) { newMap = Collections.singletonMap(key, value); } else if (oldSize == 1) { ...
java
@Deprecated public void parseAndSetParameter(String value, ModelNode operation, XMLStreamReader reader) throws XMLStreamException { //we use manual parsing here, and not #getParser().. to preserve backward compatibility. if (value != null) { for (String element : value.split(",")) { ...
java
boolean lock(final Integer permit, final long timeout, final TimeUnit unit) { boolean result = false; try { result = lockInterruptibly(permit, timeout, unit); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } return result; }
java
boolean lockShared(final Integer permit, final long timeout, final TimeUnit unit) { boolean result = false; try { result = lockSharedInterruptibly(permit, timeout, unit); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } return resul...
java
void lockInterruptibly(final Integer permit) throws InterruptedException { if (permit == null) { throw new IllegalArgumentException(); } sync.acquireInterruptibly(permit); }
java
void lockSharedInterruptibly(final Integer permit) throws InterruptedException { if (permit == null) { throw new IllegalArgumentException(); } sync.acquireSharedInterruptibly(permit); }
java
boolean lockInterruptibly(final Integer permit, final long timeout, final TimeUnit unit) throws InterruptedException { if (permit == null) { throw new IllegalArgumentException(); } return sync.tryAcquireNanos(permit, unit.toNanos(timeout)); }
java
boolean lockSharedInterruptibly(final Integer permit, final long timeout, final TimeUnit unit) throws InterruptedException { if (permit == null) { throw new IllegalArgumentException(); } return sync.tryAcquireSharedNanos(permit, unit.toNanos(timeout)); }
java
CapabilityRegistry createShadowCopy() { CapabilityRegistry result = new CapabilityRegistry(forServer, this); readLock.lock(); try { try { result.writeLock.lock(); copy(this, result); } finally { result.writeLock.unlock(); ...
java
private void registerRequirement(RuntimeRequirementRegistration requirement) { assert writeLock.isHeldByCurrentThread(); CapabilityId dependentId = requirement.getDependentId(); if (!capabilities.containsKey(dependentId)) { throw ControllerLogger.MGMT_OP_LOGGER.unknownCapabilityInCon...
java
@Override public void removeCapabilityRequirement(RuntimeRequirementRegistration requirementRegistration) { // We don't know if this got registered as an runtime-only requirement or a hard one // so clean it from both maps writeLock.lock(); try { removeRequirement(require...
java
void publish() { assert publishedFullRegistry != null : "Cannot write directly to main registry"; writeLock.lock(); try { if (!modified) { return; } publishedFullRegistry.writeLock.lock(); try { publishedFullRegistr...
java
void rollback() { if (publishedFullRegistry == null) { return; } writeLock.lock(); try { publishedFullRegistry.readLock.lock(); try { clear(true); copy(publishedFullRegistry, this); modified = false; ...
java
static void addOperationAddress(final ModelNode operation, final PathAddress base, final String key, final String value) { operation.get(OP_ADDR).set(base.append(key, value).toModelNode()); }
java
static String findNonProgressingOp(Resource resource, boolean forServer, long timeout) throws OperationFailedException { Resource.ResourceEntry nonProgressing = null; for (Resource.ResourceEntry child : resource.getChildren(ACTIVE_OPERATION)) { ModelNode model = child.getModel(); ...
java
void bootTimeScan(final DeploymentOperations deploymentOperations) { // WFCORE-1579: skip the scan if deployment dir is not available if (!checkDeploymentDir(this.deploymentDir)) { DeploymentScannerLogger.ROOT_LOGGER.bootTimeScanFailed(deploymentDir.getAbsolutePath()); return; ...
java
void scan() { if (acquireScanLock()) { boolean scheduleRescan = false; try { scheduleRescan = scan(false, deploymentOperations); } finally { try { if (scheduleRescan) { synchronized (this) { ...
java
void forcedUndeployScan() { if (acquireScanLock()) { try { ROOT_LOGGER.tracef("Performing a post-boot forced undeploy scan for scan directory %s", deploymentDir.getAbsolutePath()); ScanContext scanContext = new ScanContext(deploymentOperations); // A...
java
private boolean checkDeploymentDir(File directory) { if (!directory.exists()) { if (deploymentDirAccessible) { deploymentDirAccessible = false; ROOT_LOGGER.directoryIsNonexistent(deploymentDir.getAbsolutePath()); } } else if (!directory.isD...
java
private static ModelNode createOperation(final ModelNode operationToValidate) { PathAddress pa = PathAddress.pathAddress(operationToValidate.require(OP_ADDR)); PathAddress validationAddress = pa.subAddress(0, pa.size() - 1); return Util.getEmptyOperation("validate-cache", validationAddress.toMo...
java
public synchronized RegistrationPoint getOldestRegistrationPoint() { return registrationPoints.size() == 0 ? null : registrationPoints.values().iterator().next().get(0); }
java
public synchronized Set<RegistrationPoint> getRegistrationPoints() { Set<RegistrationPoint> result = new HashSet<>(); for (List<RegistrationPoint> registrationPoints : registrationPoints.values()) { result.addAll(registrationPoints); } return Collections.unmodifiableSet(resul...
java
public static boolean hasValidContentAdditionParameterDefined(ModelNode operation) { for (String s : DeploymentAttributes.MANAGED_CONTENT_ATTRIBUTES.keySet()) { if (operation.hasDefined(s)) { return true; } } return false; }
java
static InstalledIdentity load(final InstalledImage image, final ProductConfig productConfig, final List<File> moduleRoots, final List<File> bundleRoots) throws IOException { // build the identity information final String productVersion = productConfig.resolveVersion(); final String productName ...
java
static ProcessedLayers process(final InstalledConfiguration conf, final List<File> moduleRoots, final List<File> bundleRoots) throws IOException { final ProcessedLayers layers = new ProcessedLayers(conf); // Process module roots final LayerPathSetter moduleSetter = new LayerPathSetter() { ...
java
static void processRoot(final File root, final ProcessedLayers layers, final LayerPathSetter setter) throws IOException { final LayersConfig layersConfig = LayersConfig.getLayersConfig(root); // Process layers final File layersDir = new File(root, layersConfig.getLayersPath()); if (!laye...
java
static AbstractLazyPatchableTarget createPatchableTarget(final String name, final LayerPathConfig layer, final File metadata, final InstalledImage image) throws IOException { // patchable target return new AbstractLazyPatchableTarget() { @Override public InstalledImage getInstal...
java
public List<ModelNode> getAllowedValues() { if (allowedValues == null) { return Collections.emptyList(); } return Arrays.asList(this.allowedValues); }
java
protected void addAllowedValuesToDescription(ModelNode result, ParameterValidator validator) { if (allowedValues != null) { for (ModelNode allowedValue : allowedValues) { result.get(ModelDescriptionConstants.ALLOWED).add(allowedValue); } } else if (validator insta...
java
public static ModelNode validateRequest(CommandContext ctx, ModelNode request) throws CommandFormatException { final Set<String> keys = request.keys(); if (keys.size() == 2) { // no props return null; } ModelNode outcome = (ModelNode) ctx.get(Scope.REQUEST, DESCRIPTION_RESPO...
java
public static boolean reconnectContext(RedirectException re, CommandContext ctx) { boolean reconnected = false; try { ConnectionInfo info = ctx.getConnectionInfo(); ControllerAddress address = null; if (info != null) { address = info.getControllerAddre...
java
public static String compactToString(ModelNode node) { Objects.requireNonNull(node); final StringWriter stringWriter = new StringWriter(); final PrintWriter writer = new PrintWriter(stringWriter, true); node.writeString(writer, true); return stringWriter.toString(); }
java
private void init() { validatePreSignedUrls(); try { conn = new AWSAuthConnection(access_key, secret_access_key); // Determine the bucket name if prefix is set or if pre-signed URLs are being used if (prefix != null && prefix.length() > 0) { ListAllMy...
java
private List<DomainControllerData> readFromFile(String directoryName) { List<DomainControllerData> data = new ArrayList<DomainControllerData>(); if (directoryName == null) { return data; } if (conn == null) { init(); } try { if (using...
java
private void writeToFile(List<DomainControllerData> data, String domainName) throws IOException { if(domainName == null || data == null) { return; } if (conn == null) { init(); } try { String key = S3Util.sanitize(domainName) + "/" + S3Util.s...
java
private void remove(String directoryName) { if ((directoryName == null) || (conn == null)) return; String key = S3Util.sanitize(directoryName) + "/" + S3Util.sanitize(DC_FILE_NAME); try { Map headers = new TreeMap(); headers.put("Content-Type", Arrays.asList(...
java
public void mergeSubtree(final OperationTransformerRegistry targetRegistry, final Map<PathAddress, ModelVersion> subTree) { for(Map.Entry<PathAddress, ModelVersion> entry: subTree.entrySet()) { mergeSubtree(targetRegistry, entry.getKey(), entry.getValue()); } }
java
private static boolean isDisabledHandler(final LogContext logContext, final String handlerName) { final Map<String, String> disableHandlers = logContext.getAttachment(CommonAttributes.ROOT_LOGGER_NAME, DISABLED_HANDLERS_KEY); return disableHandlers != null && disableHandlers.containsKey(handlerName); ...
java
static PathAddress toPathAddress(String domain, ImmutableManagementResourceRegistration registry, ObjectName name) { if (!name.getDomain().equals(domain)) { return PathAddress.EMPTY_ADDRESS; } if (name.equals(ModelControllerMBeanHelper.createRootObjectName(domain))) { ret...
java
private void stopDone() { synchronized (stopLock) { final StopContext stopContext = this.stopContext; this.stopContext = null; if (stopContext != null) { stopContext.complete(); } stopLock.notifyAll(); } }
java
public String getRejectionLogMessageId() { String id = logMessageId; if (id == null) { id = getRejectionLogMessage(Collections.<String, ModelNode>emptyMap()); } logMessageId = id; return logMessageId; }
java
@Override public synchronized void stop(final StopContext context) { final boolean shutdownServers = runningModeControl.getRestartMode() == RestartMode.SERVERS; if (shutdownServers) { Runnable task = new Runnable() { @Override public void run() { ...
java
public boolean isResourceExcluded(final PathAddress address) { if (!localHostControllerInfo.isMasterDomainController() && address.size() > 0) { IgnoredDomainResourceRoot root = this.rootResource; PathElement firstElement = address.getElement(0); IgnoreDomainResourceTypeResour...
java
VersionExcludeData getVersionIgnoreData(int major, int minor, int micro) { VersionExcludeData result = registry.get(new VersionKey(major, minor, micro)); if (result == null) { result = registry.get(new VersionKey(major, minor, null)); } return result; }
java
public static void copyRecursively(final Path source, final Path target, boolean overwrite) throws IOException { final CopyOption[] options; if (overwrite) { options = new CopyOption[]{StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING}; } else { opti...
java
public static void deleteSilentlyRecursively(final Path path) { if (path != null) { try { deleteRecursively(path); } catch (IOException ioex) { DeploymentRepositoryLogger.ROOT_LOGGER.cannotDeleteFile(ioex, path); } } }
java
public static void deleteRecursively(final Path path) throws IOException { DeploymentRepositoryLogger.ROOT_LOGGER.debugf("Deleting %s recursively", path); if (Files.exists(path)) { Files.walkFileTree(path, new FileVisitor<Path>() { @Override public FileVisitRe...
java
public static final Path resolveSecurely(Path rootPath, String path) { Path resolvedPath; if(path == null || path.isEmpty()) { resolvedPath = rootPath.normalize(); } else { String relativePath = removeSuperflousSlashes(path); resolvedPath = rootPath.resolve(re...
java
public static List<ContentRepositoryElement> listFiles(final Path rootPath, Path tempDir, final ContentFilter filter) throws IOException { List<ContentRepositoryElement> result = new ArrayList<>(); if (Files.exists(rootPath)) { if(isArchive(rootPath)) { return listZipContent(...
java
public static Path createTempDirectory(Path dir, String prefix) throws IOException { try { return Files.createTempDirectory(dir, prefix); } catch (UnsupportedOperationException ex) { } return Files.createTempDirectory(dir, prefix); }
java
public static void unzip(Path zip, Path target) throws IOException { try (final ZipFile zipFile = new ZipFile(zip.toFile())){ unzip(zipFile, target); } }
java
public static ServiceController<String> addService(final ServiceName name, final String path, boolean possiblyAbsolute, final String relativeTo, final ServiceTarget serviceTarget) { if (possiblyAbsolute && isAbsoluteUnixOrWindowsPath(path)) { r...
java
public List<File> getInactiveHistory() throws PatchingException { if (validHistory == null) { walk(); } final File[] inactiveDirs = installedIdentity.getInstalledImage().getPatchesDir().listFiles(new FileFilter() { @Override public boolean accept(File pathname...
java
public List<File> getInactiveOverlays() throws PatchingException { if (referencedOverlayDirectories == null) { walk(); } List<File> inactiveDirs = null; for (Layer layer : installedIdentity.getLayers()) { final File overlaysDir = new File(layer.getDirectoryStructu...
java
public void deleteInactiveContent() throws PatchingException { List<File> dirs = getInactiveHistory(); if (!dirs.isEmpty()) { for (File dir : dirs) { deleteDir(dir, ALL); } } dirs = getInactiveOverlays(); if (!dirs.isEmpty()) { ...
java
public void bootstrap() throws Exception { final HostRunningModeControl runningModeControl = environment.getRunningModeControl(); final ControlledProcessState processState = new ControlledProcessState(true); shutdownHook.setControlledProcessState(processState); ServiceTarget target = ser...
java
private void persistDecorator(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException { if (shouldWriteDecoratorAndElements(model)) { writer.writeStartElement(decoratorElement); persistChildren(writer, model); writer.writeEndElement(); } }
java
@Deprecated public static PersistentResourceXMLBuilder decorator(final String elementName) { return new PersistentResourceXMLBuilder(PathElement.pathElement(elementName), null).setDecoratorGroup(elementName); }
java
void rejectAttributes(RejectedAttributesLogContext rejectedAttributes, ModelNode attributeValue) { for (RejectAttributeChecker checker : checks) { rejectedAttributes.checkAttribute(checker, name, attributeValue); } }
java
private OperationEntry getInheritableOperationEntryLocked(final String operationName) { final OperationEntry entry = operations == null ? null : operations.get(operationName); if (entry != null && entry.isInherited()) { return entry; } return null; }
java
private void registerChildInternal(IgnoreDomainResourceTypeResource child) { child.setParent(this); children.put(child.getName(), child); }
java
protected Channel awaitChannel() throws IOException { Channel channel = this.channel; if(channel != null) { return channel; } synchronized (lock) { for(;;) { if(state == State.CLOSED) { throw ProtocolLogger.ROOT_LOGGER.channelCl...
java
protected boolean prepareClose() { synchronized (lock) { final State state = this.state; if (state == State.OPEN) { this.state = State.CLOSING; lock.notifyAll(); return true; } } return false; }
java
protected boolean setChannel(final Channel newChannel) { if(newChannel == null) { return false; } synchronized (lock) { if(state != State.OPEN || channel != null) { return false; } this.channel = newChannel; this.channel...
java
private boolean isRedeployAfterRemoval(ModelNode operation) { return operation.hasDefined(DEPLOYMENT_OVERLAY_LINK_REMOVAL) && operation.get(DEPLOYMENT_OVERLAY_LINK_REMOVAL).asBoolean(); }
java
protected void createNewFile(final File file) { try { file.createNewFile(); setFileNotWorldReadablePermissions(file); } catch (IOException e){ throw new RuntimeException(e); } }
java
private void setFileNotWorldReadablePermissions(File file) { file.setReadable(false, false); file.setWritable(false, false); file.setExecutable(false, false); file.setReadable(true, true); file.setWritable(true, true); }
java
protected synchronized ResourceRoot getSeamIntResourceRoot() throws DeploymentUnitProcessingException { try { if (seamIntResourceRoot == null) { final ModuleLoader moduleLoader = Module.getBootModuleLoader(); Module extModule = moduleLoader.loadModule(EXT_CONTENT_MODU...
java
public static PathAddress pathAddress(final ModelNode node) { if (node.isDefined()) { // final List<Property> props = node.asPropertyList(); // Following bit is crap TODO; uncomment above and delete below // when bug is fixed final List<Property> props = new Array...
java
public PathElement getElement(int index) { final List<PathElement> list = pathAddressList; return list.get(index); }
java
public PathElement getLastElement() { final List<PathElement> list = pathAddressList; return list.size() == 0 ? null : list.get(list.size() - 1); }
java
public PathAddress append(List<PathElement> additionalElements) { final ArrayList<PathElement> newList = new ArrayList<PathElement>(pathAddressList.size() + additionalElements.size()); newList.addAll(pathAddressList); newList.addAll(additionalElements); return pathAddress(newList); }
java
@Deprecated public ModelNode navigate(ModelNode model, boolean create) throws NoSuchElementException { final Iterator<PathElement> i = pathAddressList.iterator(); while (i.hasNext()) { final PathElement element = i.next(); if (create && !i.hasNext()) { if (ele...
java
@Deprecated public ModelNode remove(ModelNode model) throws NoSuchElementException { final Iterator<PathElement> i = pathAddressList.iterator(); while (i.hasNext()) { final PathElement element = i.next(); if (i.hasNext()) { model = model.require(element.getKey...
java
public ModelNode toModelNode() { final ModelNode node = new ModelNode().setEmptyList(); for (PathElement element : pathAddressList) { final String value; if (element.isMultiTarget() && !element.isWildcard()) { value = '[' + element.getValue() + ']'; } ...
java
public boolean matches(PathAddress address) { if (address == null) { return false; } if (equals(address)) { return true; } if (size() != address.size()) { return false; } for (int i = 0; i < size(); i++) { PathElemen...
java
public static void indexResourceRoot(final ResourceRoot resourceRoot) throws DeploymentUnitProcessingException { if (resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX) != null) { return; } VirtualFile indexFile = resourceRoot.getRoot().getChild(ModuleIndexBuilder.INDEX_LOCATIO...
java
public static void validateRollbackState(final String patchID, final InstalledIdentity identity) throws PatchingException { final Set<String> validHistory = processRollbackState(patchID, identity); if (patchID != null && !validHistory.contains(patchID)) { throw PatchLogger.ROOT_LOGGER.patchN...
java
public static void mark(DeploymentUnit unit) { unit = DeploymentUtils.getTopDeploymentUnit(unit); unit.putAttachment(MARKER, Boolean.TRUE); }
java
@Override public Map<String, Set<String>> cleanObsoleteContent() { if(!readWrite) { return Collections.emptyMap(); } Map<String, Set<String>> cleanedContents = new HashMap<>(2); cleanedContents.put(MARKED_CONTENT, new HashSet<>()); cleanedContents.put(DELETED_CONT...
java