Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Impl failsafe methods
Browse files Browse the repository at this point in the history
  • Loading branch information
asoldano committed Dec 17, 2012
1 parent 3df1cec commit f6fc16a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
Expand Down Expand Up @@ -40,6 +40,7 @@

/**
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
* @author <a href="mailto:alessio.soldano@jboss.com">Alessio Soldano</a>
*/
@MessageLogger(projectCode = "JBAS")
public interface WSLogger extends BasicLogger {
Expand Down Expand Up @@ -257,5 +258,8 @@ public interface WSLogger extends BasicLogger {
@LogMessage(level = WARN)
@Message(id = 15596, value = "Multiple EJB3 endpoints in the same deployment with different declared security roles; be aware this might be a security risk if you're not controlling allowed roles (@RolesAllowed) on each ws endpoint method.")
void multipleEndpointsWithDifferentDeclaredSecurityRoles();


@LogMessage(level = TRACE)
@Message(id = 15597, value = "Child '%s' not found for VirtualFile: %s")
void missingChild(String child, VirtualFile file);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static org.jboss.as.webservices.util.DotNames.WEB_SERVICE_ANNOTATION;
import static org.jboss.as.webservices.util.WSAttachmentKeys.JMS_ENDPOINT_METADATA_KEY;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.LinkedList;
Expand Down Expand Up @@ -99,11 +98,12 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
if (!map.isEmpty()) {

for (String wsdlLocation : map.keySet()) {
try {
final ResourceRoot resourceRoot = getWsdlResourceRoot(unit, wsdlLocation);
if (resourceRoot == null) continue;
final UnifiedVirtualFile uvf = new VirtualFileAdaptor(resourceRoot.getRoot());
URL url = uvf.findChild(wsdlLocation).toURL();
final ResourceRoot resourceRoot = getWsdlResourceRoot(unit, wsdlLocation);
if (resourceRoot == null) continue;
final UnifiedVirtualFile uvf = new VirtualFileAdaptor(resourceRoot.getRoot());
UnifiedVirtualFile childUvf = uvf.findChildFailSafe(wsdlLocation);
if (childUvf != null) {
URL url = childUvf.toURL();
SOAPAddressWSDLParser parser = new SOAPAddressWSDLParser(url);
for (AnnotationInstance ai : map.get(wsdlLocation)) {
String port = ai.value(PORT_NAME).asString();
Expand All @@ -127,7 +127,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
endpointsMetaData.addEndpointMetaData(endpointMetaData);
}
}
} catch (Exception ignore) {
} else {
ROOT_LOGGER.cannotReadWsdl(wsdlLocation);
}
}
Expand All @@ -141,7 +141,7 @@ public void undeploy(final DeploymentUnit context) {
// NOOP
}

private static ResourceRoot getWsdlResourceRoot(final DeploymentUnit unit, final String wsdlPath) throws MalformedURLException {
private static ResourceRoot getWsdlResourceRoot(final DeploymentUnit unit, final String wsdlPath) {
final AttachmentList<ResourceRoot> resourceRoots = new AttachmentList<ResourceRoot>(ResourceRoot.class);
final ResourceRoot root = unit.getAttachment(DEPLOYMENT_ROOT);
resourceRoots.add(root);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, JBoss Inc., and individual contributors as indicated
* Copyright 2012, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
Expand All @@ -22,6 +22,7 @@
package org.jboss.as.webservices.util;

import static org.jboss.as.webservices.WSMessages.MESSAGES;
import static org.jboss.as.webservices.WSLogger.ROOT_LOGGER;

import java.io.IOException;
import java.net.URL;
Expand Down Expand Up @@ -52,14 +53,32 @@ private VirtualFile getFile() throws IOException {
return file;
}

public UnifiedVirtualFile findChild(String child) throws IOException {
private UnifiedVirtualFile findChild(String child, boolean throwExceptionIfNotFound) throws IOException {
final VirtualFile virtualFile = getFile();
final VirtualFile childFile = file.getChild(child);
if (!childFile.exists())
throw MESSAGES.missingChild(child, virtualFile);
if (!childFile.exists()) {
if (throwExceptionIfNotFound) {
throw MESSAGES.missingChild(child, virtualFile);
} else {
if (ROOT_LOGGER.isTraceEnabled()) ROOT_LOGGER.missingChild(child, virtualFile);
return null;
}
}
return new VirtualFileAdaptor(childFile);
}

public UnifiedVirtualFile findChild(String child) throws IOException {
return findChild(child, true);
}

public UnifiedVirtualFile findChildFailSafe(String child) {
try {
return findChild(child, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public URL toURL() {
try {
return getFile().toURL();
Expand Down

0 comments on commit f6fc16a

Please sign in to comment.