Skip to content

Commit

Permalink
Cleanups around moduleId
Browse files Browse the repository at this point in the history
- implemented some toStrings
- generics
- simplified moduleId

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Oct 15, 2022
1 parent cba2bde commit 144c42c
Show file tree
Hide file tree
Showing 19 changed files with 277 additions and 398 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ public synchronized ContextServiceImpl getContextService(ConcurrentServiceCfg co
}


/**
* Shut down the runtime service.
*
* @param jndiName
*/
public void shutdownManagedExecutorService(String jndiName) {
ManagedExecutorServiceImpl mes = removeManagedExecutorService(jndiName);
if (mes != null) {
Expand All @@ -284,6 +289,11 @@ public void shutdownManagedExecutorService(String jndiName) {
}


/**
* Shut down the runtime service.
*
* @param jndiName
*/
public void shutdownScheduledManagedExecutorService(String jndiName) {
ManagedScheduledExecutorServiceImpl mses = removeManagedScheduledExecutorService(jndiName);
if (mses != null) {
Expand All @@ -292,6 +302,11 @@ public void shutdownScheduledManagedExecutorService(String jndiName) {
}


/**
* Stop the runtime thread factory.
*
* @param jndiName
*/
public void shutdownManagedThreadFactory(String jndiName) {
ManagedThreadFactoryImpl mtf = removeManagedThreadFactory(jndiName);
if (mtf != null) {
Expand All @@ -300,6 +315,11 @@ public void shutdownManagedThreadFactory(String jndiName) {
}


/**
* Remove the context service from the internal map.
*
* @param jndiName
*/
public synchronized void shutdownContextService(String jndiName) {
contextServiceMap.remove(jndiName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Vector;

Expand Down Expand Up @@ -113,12 +113,12 @@ public BundleDescriptor(String name, String description) {
/**
* Sets the application to which I belong.
*/
public void setApplication(Application a) {
application = a;
public void setApplication(Application application) {
this.application = application;
for (List<? extends RootDeploymentDescriptor> extensionsByType : extensions.values()) {
for (RootDeploymentDescriptor extension : extensionsByType) {
if (extension instanceof BundleDescriptor) {
((BundleDescriptor) extension).setApplication(a);
((BundleDescriptor) extension).setApplication(application);
}
}
}
Expand Down Expand Up @@ -615,9 +615,6 @@ public String getDeploymentDescriptorDir() {
return DEPLOYMENT_DESCRIPTOR_DIR;
}

public String getRawModuleID() {
return moduleID;
}
/**
* @return the wsdl directory location inside the archive file
*/
Expand Down Expand Up @@ -797,9 +794,7 @@ private PersistenceUnitDescriptor findReferencedPU0(String unitName) {
// next look to see if there is unique match in ear scope.
int sameNamedEarScopedPUCount = 0;
Set<Map.Entry<String, PersistenceUnitDescriptor>> entrySet = visiblePUs.entrySet();
Iterator<Map.Entry<String, PersistenceUnitDescriptor>> entryIt = entrySet.iterator();
while (entryIt.hasNext()) {
Map.Entry<String, PersistenceUnitDescriptor> entry = entryIt.next();
for (Entry<String, PersistenceUnitDescriptor> entry : entrySet) {
String s = entry.getKey();
int idx = s.lastIndexOf(PERSISTENCE_UNIT_NAME_SEPARATOR);
if (idx != -1 // ear scoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

Expand All @@ -41,12 +40,6 @@ public class JaxrpcMappingDescriptor extends RootDeploymentDescriptor {

private boolean simpleMapping = true;

@Override
public String getModuleID() {
return "";
}


@Override
public String getDefaultSpecVersion() {
return "1.0";
Expand Down Expand Up @@ -101,9 +94,7 @@ public void addMapping(String javaPackage, String namespaceUri) {
*/
public Collection<Mapping> getMappings() {
Collection<Mapping> mappings = new HashSet<>();
Iterator<Entry<String, String>> nIter = namespaceUriToPackageMap.entrySet().iterator();
while (nIter.hasNext()) {
Entry<String, String> entry = nIter.next();
for (Entry<String, String> entry : namespaceUriToPackageMap.entrySet()) {
String namespaceUri = entry.getKey();
String javaPackage = entry.getValue();
Mapping mapping = new Mapping(namespaceUri, javaPackage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* @author David Matejcek
*/
public class ManagedExecutorDefinitionDescriptor extends ResourceDescriptor implements ContextualResourceDefinition {
public class ManagedExecutorDefinitionDescriptor extends ResourceDescriptor implements ContextualResourceDefinition {

private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ public class PermissionsDescriptor extends RootDeploymentDescriptor {
private RootDeploymentDescriptor parent;
private PermissionCollection declaredPerms;

/** @return canonical name of the class and hash code */
@Override
public String getModuleID() {
return this.getClass().getCanonicalName() + '@' + hashCode();
public PermissionsDescriptor() {
setModuleID(getClass().getCanonicalName() + '@' + hashCode());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ public String getDefaultSpecVersion() {
return JPA_1_0;
}

@Override
public String getModuleID() {
throw new RuntimeException();
}

@Override
public ArchiveType getModuleType() {
throw new RuntimeException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public WebServicesDescriptor() {
*/
@Override
public String getDefaultSpecVersion() {
return "1.3";//TODO fix this WebServicesDescriptorNode.SPEC_VERSION;
// FIXME should be WebServicesDescriptorNode.SPEC_VERSION;
return "2.0";
}

public void setBundleDescriptor(BundleDescriptor module) {
Expand All @@ -73,22 +74,22 @@ public boolean isEmpty() {

public WebService getWebServiceByName(String webServiceName) {
for (WebService webService : webServices) {
if( webService.getName().equals(webServiceName) ) {
if (webService.getDisplayName().equals(webServiceName)) {
return webService;
}
}
return null;
}

public void addWebService(WebService descriptor) {
descriptor.setWebServicesDescriptor(this);
webServices.add(descriptor);
public void addWebService(WebService ws) {
ws.setWebServicesDescriptor(this);
webServices.add(ws);

}

public void removeWebService(WebService descriptor) {
descriptor.setWebServicesDescriptor(null);
webServices.remove(descriptor);
public void removeWebService(WebService ws) {
ws.setWebServicesDescriptor(null);
webServices.remove(ws);

}

Expand Down Expand Up @@ -161,15 +162,6 @@ public ArchiveType getModuleType() {
return null;
}

//
// Dummy RootDeploymentDescriptor implementations for methods that
// do not apply to WebServicesDescriptor.
//
@Override
public String getModuleID() {
return "";
}

@Override
public ClassLoader getClassLoader() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

package com.sun.enterprise.deployment.node;

import org.glassfish.deployment.common.Descriptor;
import com.sun.enterprise.deployment.xml.TagNames;

import org.glassfish.deployment.common.Descriptor;

/**
* This node handles the descriptionType xml fragment
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Set;

import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;

Expand All @@ -30,8 +31,7 @@ public class TestClient {
private static SimpleReporterAdapter stat =
new SimpleReporterAdapter("appserv-tests");

public boolean found1 = false;
public boolean found2 = false;
public int found = 0;

public static void main (String[] args) {
stat.addDescription("wsctx");
Expand Down Expand Up @@ -60,12 +60,13 @@ private int invokeServlet(String url) throws Exception {
InputStream is = c1.getInputStream();
BufferedReader input = new BufferedReader (new InputStreamReader(is));
String line = null;
Set<String> expected = Set.of("So the RESULT OF HELLO SERVICE IS", "[Hello All-HelloWAR]");
log("Expecting lines with the content: " + expected);
while ((line = input.readLine()) != null) {
log(line);
if(line.indexOf("So the RESULT OF HELLO SERVICE IS") != -1)
found1 = true;
if(line.indexOf("[Hello AllHelloWAR]") != -1)
found2 = true;
if(expected.contains(line)) {
found++;
}
}
return code;
}
Expand All @@ -75,10 +76,7 @@ private void report(int code) {
log("Incorrect return code: " + code);
fail();
}
if(!found1) {
fail();
}
if(!found2) {
if(found < 2) {
fail();
}
pass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@
@WebService
public class Hello {

@Resource WebServiceContext wsc;
@Resource
WebServiceContext wsc;

public String sayHello(String param) {
System.out.println("wsctxt-servlet wsc = " + wsc);
if(wsc != null) {
ServletContext sc =
(ServletContext)wsc.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
String a = null;
if (sc!= null ) {
a = sc.getServletContextName();
}
return "Hello " + param +a;
if (wsc != null) {
ServletContext sc = (ServletContext) wsc.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
System.out.println("ServletContext = " + sc);
final String a;
if (sc != null) {
a = sc.getServletContextName();
} else {
a = "null";
}
return "Hello " + param + '-' + a;
}
return "WebService Context injection failed";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp)
out.println("</head>");
out.println("<body>");
out.println("<p>");
out.println("So the RESULT OF HELLO SERVICE IS :");
out.println("So the RESULT OF HELLO SERVICE IS");
out.println("</p>");
out.println("[" + ret + "]");
out.println("</body>");
Expand Down

0 comments on commit 144c42c

Please sign in to comment.