Skip to content

Commit

Permalink
Add juddi.properties for registry configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Diesler authored and bstansberry committed Nov 8, 2011
1 parent c54f7bb commit c786c19
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 34 deletions.
12 changes: 6 additions & 6 deletions jaxr/src/main/java/org/jboss/as/jaxr/scout/SaajTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class SaajTransport implements Transport {

public Element send(Element request, URI endpointURL) throws RegistryException {
String requestMessage = DOMWriter.printNode(request, true);
log.debug("Request message:" + requestMessage);
log.debugf("Request message: %s\n%s", endpointURL, requestMessage);

Element response = null;
try {
Expand All @@ -81,11 +81,11 @@ public Element send(Element request, URI endpointURL) throws RegistryException {
}
response = getFirstChildElement(soapBody);
} catch (Exception ex) {
log.error("Exception::", ex);
log.errorf(ex, "Exception::");
throw new RegistryException(ex);
}

log.debug("Response message:" + DOMWriter.printNode(response, true));
log.debugf("Response message: %s", DOMWriter.printNode(response, true));
return response;
}

Expand Down Expand Up @@ -164,8 +164,8 @@ private static Element getElement(String xmlFrag) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(xmlFrag)));
reqElement = doc.getDocumentElement();
} catch (Exception e) {
log.error("Exception:", e);
} catch (Exception ex) {
log.errorf(ex, "Exception:");
}

return reqElement;
Expand All @@ -187,7 +187,7 @@ private Element getFirstChildElement(Element el, String tagName) {
}
}
String responseObtained = DOMWriter.printNode(childEl, true);
log.debug("Response obtained=" + responseObtained);
log.debugf("Response obtained: %s", responseObtained);
return childEl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class JAXRConfiguration {
// Should all tables be created on Start
private boolean createOnStart=true;
// Should all tables be dropped on Stop
private boolean dropOnStop=true;
private boolean dropOnStop=false;
// Should all tables be dropped on Start
private boolean dropOnStart=true;
// Datasource to Database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.ContextConfig;
import org.apache.juddi.registry.RegistryServlet;
import org.apache.naming.resources.ProxyDirContext;
import org.apache.naming.resources.Resource;
import org.apache.tomcat.InstanceManager;
import org.jboss.as.server.mgmt.HttpManagementService;
import org.jboss.as.server.mgmt.domain.HttpManagement;
Expand All @@ -47,10 +49,22 @@
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;

import javax.naming.Binding;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.servlet.http.HttpServlet;
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Hashtable;

/**
* A service starting a welcome web context driven by simple static content.
Expand Down Expand Up @@ -79,7 +93,19 @@ public static ServiceController<?> addService(final ServiceTarget target, final
}

private JUDDIContextService(final JAXRConfiguration config) {
this.context = new StandardContext();
context = new StandardContext() {
private DirContext resources;
// [TODO] AS7-2499 Remove DirContext hack to load juddi.properties
public DirContext getResources() {
if (resources == null) {
DirContext orgdirctx = super.getResources();
if (orgdirctx != null) {
resources = new JAXRDirContext(new Hashtable<String, Object>(), orgdirctx);
}
}
return resources;
}
};
}

@Override
Expand Down Expand Up @@ -111,12 +137,13 @@ public synchronized void start(StartContext startContext) throws StartException
context.addServletMapping("/publish", "JUDDIServlet");
context.addServletMapping("/inquiry", "JUDDIServlet");

// Add the JUDDIServlet
// Add the RegistryServlet
servlet = new RegistryServlet();
wrapper = context.createWrapper();
wrapper.setName("JUDDIRegistryServlet");
wrapper.setServlet(servlet);
wrapper.setServletClass(servlet.getClass().getName());
wrapper.setLoadOnStartup(1);
context.addChild(wrapper);

host.addChild(context);
Expand Down Expand Up @@ -148,10 +175,6 @@ public synchronized void stop(StopContext stopContext) {

@Override
public synchronized Context getValue() throws IllegalStateException {
final Context context = this.context;
if (context == null) {
throw new IllegalStateException();
}
return context;
}

Expand Down Expand Up @@ -190,4 +213,23 @@ public void newInstance(Object o) throws IllegalAccessException, InvocationTarge
public void destroyInstance(Object o) throws IllegalAccessException, InvocationTargetException {
}
}

private static class JAXRDirContext extends ProxyDirContext {
public JAXRDirContext(Hashtable<String, Object> env, DirContext dircontext) {
super(env, dircontext);
}

@Override
// [TODO] AS7-2499 Remove DirContext hack to load juddi.properties
public Object lookup(String name) throws NamingException {
try {
return super.lookup(name);
} catch (NamingException namingExeption) {
InputStream stream = getClass().getClassLoader().getResourceAsStream(name);
if (stream == null)
throw namingExeption;
return new Resource(stream);
}
}
}
}
26 changes: 8 additions & 18 deletions jaxr/src/main/java/org/jboss/as/jaxr/service/JUDDIServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,12 @@ public class JUDDIServlet extends HttpServlet {

private static Logger log = Logger.getLogger(JUDDIServlet.class);

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.setHeader("Allow", "POST");
res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The request " +
"method 'GET' is not allowed by UDDI API.");
res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The request method 'GET' is not allowed by UDDI API.");
}

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.setContentType("text/xml; charset=utf-8");

SOAPMessage soapReq = null;
Expand All @@ -121,27 +118,21 @@ public void doPost(HttpServletRequest req, HttpServletResponse res)
}

if (uddiReq == null)
throw new FatalErrorException("A UDDI request was not " +
"found in the SOAP message.");
throw new FatalErrorException("A UDDI request was not found in the SOAP message.");

String function = uddiReq.getLocalName();
if ((function == null) || (function.trim().length() == 0))
throw new FatalErrorException("The name of the UDDI request " +
"could not be identified.");
throw new FatalErrorException("The name of the UDDI request could not be identified.");
IHandler requestHandler = maker.lookup(function);
if (requestHandler == null)
throw new UnsupportedException("The UDDI request " +
"type specified is unknown: " + function);

String generic = uddiReq.getAttribute("generic");
if (generic == null)
throw new FatalErrorException("A UDDI generic attribute " +
"value was not found for UDDI request: " + function + " (The " +
"'generic' attribute must be present)");
throw new FatalErrorException("A UDDI generic attribute value was not found for UDDI request: " + function + " (The 'generic' attribute must be present)");
else if (!generic.equals(IRegistry.UDDI_V2_GENERIC))
throw new UnsupportedException("Currently only UDDI v2 " +
"requests are supported. The generic attribute value " +
"received was: " + generic);
throw new UnsupportedException("Currently only UDDI v2 requests are supported. The generic attribute value received was: " + generic);

// Unmarshal the raw xml into the appropriate jUDDI
// request object.
Expand All @@ -167,8 +158,7 @@ else if (!generic.equals(IRegistry.UDDI_V2_GENERIC))

IHandler responseHandler = maker.lookup(uddiResObj.getClass().getName());
if (responseHandler == null)
throw new FatalErrorException("The response object " +
"type is unknown: " + uddiResObj.getClass().getName());
throw new FatalErrorException("The response object type is unknown: " + uddiResObj.getClass().getName());

// Create a new 'temp' XML element to use as a container
// in which to marshal the UDDI response data into.
Expand Down
54 changes: 54 additions & 0 deletions jaxr/src/main/resources/WEB-INF/juddi.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# jUDDI Registry Properties (used by RegistryServer)
# see http://www.juddi.org for more information

# The UDDI Operator Name
juddi.operatorName = jUDDI.org

# The maximum name size and maximum number
# of name elements allows in several of the
# FindXxxx and SaveXxxx UDDI functions.
juddi.maxNameLength=255
juddi.maxNameElementsAllowed=5
juddi.maxBusinessEntitiesPerUser=25
juddi.maxBusinessServicesPerBusiness=20
juddi.maxBindingTemplatesPerService=10
juddi.maxTModelsPerUser=100
juddi.maxRowsLimit=10

# jUDDI Authentication module to use
juddi.auth = org.apache.juddi.auth.DefaultAuthenticator

# jUDDI DataStore module currently to use
juddi.dataStore = org.apache.juddi.datastore.jdbc.JDBCDataStore


# jUDDI UUIDGen implementation to use
juddi.uuidgen = org.apache.juddi.uuidgen.DefaultUUIDGen

# jUDDI Monitor implementation to use
#juddi.monitor = org.apache.juddi.monitor.jdbc.JDBCMonitor

# jUDDI Cryptor implementation to use
juddi.cryptor = org.apache.juddi.cryptor.DefaultCryptor

# jUDDI Validator to use
juddi.validator=org.apache.juddi.validator.DefaultValidator

# jUDDI DataSource to use
juddi.dataSource=java:jboss/datasources/ExampleDS


# jUDDI Proxy Properties (used by RegistryProxy)
juddi.proxy.adminURL = http://localhost:8080/juddi/admin
juddi.proxy.inquiryURL = http://localhost:8080/juddi/inquiry
juddi.proxy.publishURL = http://localhost:8080/juddi/publish
juddi.proxy.transportClass = org.apache.juddi.proxy.AxisTransport
juddi.proxy.securityProvider = com.sun.net.ssl.internal.ssl.Provider
juddi.proxy.protocolHandler = com.sun.net.ssl.internal.www.protocol

# jUDDI HTTP Proxy Properties
juddi.httpProxySet = true
juddi.httpProxyHost = proxy.viens.net
juddi.httpProxyPort = 8000
juddi.httpProxyUserName = sviens
juddi.httpProxyPassword = password
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ public void tearDown() throws Exception {
if (connection != null) connection.close();
}

/**
* Does authentication with the uddi registry
*/
protected void login() {
PasswordAuthentication passwdAuth = new PasswordAuthentication(userid, passwd.toCharArray());
Set creds = new HashSet();
Expand Down

0 comments on commit c786c19

Please sign in to comment.