Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a metadata class for jaxrs and making WSFServlet suitable for …
…jaxrs too
- Loading branch information
Showing
3 changed files
with
283 additions
and
2 deletions.
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
src/main/java/org/jboss/wsf/spi/classloading/JAXRSClassLoaderProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2016, Red Hat Middleware LLC, and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.wsf.spi.classloading; | ||
|
||
import java.security.AccessController; | ||
import java.security.Permission; | ||
import java.security.PrivilegedAction; | ||
|
||
/** | ||
* SPI for getting AS classloaders | ||
* | ||
* @author alessio.soldano@jboss.com | ||
* @since 18-Jan-2016 | ||
* | ||
*/ | ||
public abstract class JAXRSClassLoaderProvider | ||
{ | ||
private static final RuntimePermission SET_DEFAULT_CLASSLOADER_PROVIDER = new RuntimePermission("org.jboss.wsf.spi.SET_DEFAULT_CLASSLOADER_PROVIDER"); | ||
|
||
private static JAXRSClassLoaderProvider provider = new JAXRSClassLoaderProvider() | ||
{ | ||
@Override | ||
public ClassLoader getJAXRSSubsystemClassLoader() | ||
{ | ||
return getContextClassLoader(); | ||
} | ||
|
||
@Override | ||
public ClassLoader getServerIntegrationClassLoader() | ||
{ | ||
return getContextClassLoader(); | ||
} | ||
|
||
}; | ||
private static volatile boolean set = false; | ||
|
||
public static void setDefaultProvider(JAXRSClassLoaderProvider p) | ||
{ | ||
checkPermission(SET_DEFAULT_CLASSLOADER_PROVIDER); | ||
provider = p; | ||
set = true; | ||
} | ||
|
||
public static JAXRSClassLoaderProvider getDefaultProvider() | ||
{ | ||
return provider; | ||
} | ||
|
||
public static boolean isSet() | ||
{ | ||
return set; | ||
} | ||
|
||
/** | ||
* Return the ClassLoader instance having visibility over the application server ws subsystem only | ||
* | ||
* @return classloader | ||
*/ | ||
public abstract ClassLoader getJAXRSSubsystemClassLoader(); | ||
|
||
/** | ||
* Return the ClassLoader instance having visibility over the all server side ws libraries (for JAXWS usage) | ||
* | ||
* @return classloader | ||
*/ | ||
public abstract ClassLoader getServerIntegrationClassLoader(); | ||
|
||
static ClassLoader getContextClassLoader() | ||
{ | ||
if (System.getSecurityManager() == null) | ||
{ | ||
return Thread.currentThread().getContextClassLoader(); | ||
} | ||
else | ||
{ | ||
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() | ||
{ | ||
public ClassLoader run() | ||
{ | ||
return Thread.currentThread().getContextClassLoader(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
private static void checkPermission(final Permission permission) | ||
{ | ||
SecurityManager securityManager = System.getSecurityManager(); | ||
if (securityManager != null) | ||
{ | ||
AccessController.checkPermission(permission); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
src/main/java/org/jboss/wsf/spi/metadata/JAXRSDeploymentMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2006, Red Hat Middleware LLC, and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.wsf.spi.metadata; | ||
|
||
import java.util.ArrayList; | ||
import java.util.LinkedHashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* JAXRS deployment metadata | ||
* | ||
* @author alessio.soldano@jboss.com | ||
* @since 18-Jan-2016 | ||
* | ||
*/ | ||
public final class JAXRSDeploymentMetadata | ||
{ | ||
private boolean scanAll; | ||
private boolean scanResources; | ||
private boolean scanProviders; | ||
private boolean dispatcherCreated; | ||
private final Set<String> scannedResourceClasses = new LinkedHashSet<String>(); | ||
private final Set<String> scannedProviderClasses = new LinkedHashSet<String>(); | ||
private List<Class<?>> scannedApplicationClasses = new ArrayList<>(); | ||
private boolean bootClasses; | ||
private boolean unwrappedExceptionsParameterSet; | ||
private final Set<String> scannedJndiComponentResources = new LinkedHashSet<String>(); | ||
|
||
/** | ||
* Merges a list of additional JAX-RS deployment data with this lot of deployment data. | ||
* | ||
* @param deploymentData | ||
*/ | ||
public void merge(final List<JAXRSDeploymentMetadata> deploymentData) | ||
{ | ||
for (JAXRSDeploymentMetadata data : deploymentData) | ||
{ | ||
scannedApplicationClasses.addAll(data.getScannedApplicationClasses()); | ||
if (scanResources) | ||
{ | ||
scannedResourceClasses.addAll(data.getScannedResourceClasses()); | ||
scannedJndiComponentResources.addAll(data.getScannedJndiComponentResources()); | ||
} | ||
if (scanProviders) | ||
{ | ||
scannedProviderClasses.addAll(data.getScannedProviderClasses()); | ||
} | ||
} | ||
} | ||
|
||
public Set<String> getScannedJndiComponentResources() | ||
{ | ||
return scannedJndiComponentResources; | ||
} | ||
|
||
public boolean isDispatcherCreated() | ||
{ | ||
return dispatcherCreated; | ||
} | ||
|
||
public void setDispatcherCreated(boolean dispatcherCreated) | ||
{ | ||
this.dispatcherCreated = dispatcherCreated; | ||
} | ||
|
||
public List<Class<?>> getScannedApplicationClasses() | ||
{ | ||
return scannedApplicationClasses; | ||
} | ||
|
||
public boolean hasBootClasses() | ||
{ | ||
return bootClasses; | ||
} | ||
|
||
public void setBootClasses(boolean bootClasses) | ||
{ | ||
this.bootClasses = bootClasses; | ||
} | ||
|
||
public boolean shouldScan() | ||
{ | ||
return scanAll || scanResources || scanProviders; | ||
} | ||
|
||
public boolean isScanAll() | ||
{ | ||
return scanAll; | ||
} | ||
|
||
public void setScanAll(boolean scanAll) | ||
{ | ||
if (scanAll) | ||
{ | ||
scanResources = true; | ||
scanProviders = true; | ||
} | ||
this.scanAll = scanAll; | ||
} | ||
|
||
public boolean isScanResources() | ||
{ | ||
return scanResources; | ||
} | ||
|
||
public void setScanResources(boolean scanResources) | ||
{ | ||
this.scanResources = scanResources; | ||
} | ||
|
||
public boolean isScanProviders() | ||
{ | ||
return scanProviders; | ||
} | ||
|
||
public void setScanProviders(boolean scanProviders) | ||
{ | ||
this.scanProviders = scanProviders; | ||
} | ||
|
||
public Set<String> getScannedResourceClasses() | ||
{ | ||
return scannedResourceClasses; | ||
} | ||
|
||
public Set<String> getScannedProviderClasses() | ||
{ | ||
return scannedProviderClasses; | ||
} | ||
|
||
public boolean isUnwrappedExceptionsParameterSet() | ||
{ | ||
return unwrappedExceptionsParameterSet; | ||
} | ||
|
||
public void setUnwrappedExceptionsParameterSet(boolean unwrappedExceptionsParameterSet) | ||
{ | ||
this.unwrappedExceptionsParameterSet = unwrappedExceptionsParameterSet; | ||
} | ||
} |