use of org.glassfish.internal.api.ServerContext in project Payara by payara.
the class AbstractRestResourceProvider method getResourceConfig.
@Override
public ResourceConfig getResourceConfig(Set<Class<?>> classes, final ServerContext sc, final ServiceLocator habitat, final Set<? extends Binder> additionalBinders) throws EndpointRegistrationException {
final Reloader r = new Reloader();
ResourceConfig rc = new ResourceConfig(classes);
rc.property(ServerProperties.MEDIA_TYPE_MAPPINGS, getMimeMappings());
rc.register(CsrfProtectionFilter.class);
// TODO - JERSEY2
// RestConfig restConf = ResourceUtil.getRestConfig(habitat);
// if (restConf != null) {
// if (restConf.getLogOutput().equalsIgnoreCase("true")) { //enable output logging
// rc.getContainerResponseFilters().add(LoggingFilter.class);
// }
// if (restConf.getLogInput().equalsIgnoreCase("true")) { //enable input logging
// rc.getContainerRequestFilters().add(LoggingFilter.class);
// }
// if (restConf.getWadlGeneration().equalsIgnoreCase("false")) { //disable WADL
// rc.getFeatures().put(ResourceConfig.FEATURE_DISABLE_WADL, Boolean.TRUE);
// }
// }
// else {
// rc.getFeatures().put(ResourceConfig.FEATURE_DISABLE_WADL, Boolean.TRUE);
// }
//
rc.register(r);
rc.register(ReloadResource.class);
rc.register(new MultiPartFeature());
// rc.register(getJsonFeature());
rc.register(new AbstractBinder() {
@Override
protected void configure() {
AbstractActiveDescriptor<Reloader> descriptor = BuilderHelper.createConstantDescriptor(r);
descriptor.addContractType(Reloader.class);
bind(descriptor);
AbstractActiveDescriptor<ServerContext> scDescriptor = BuilderHelper.createConstantDescriptor(sc);
scDescriptor.addContractType(ServerContext.class);
bind(scDescriptor);
LocatorBridge locatorBridge = new LocatorBridge(habitat);
AbstractActiveDescriptor<LocatorBridge> hDescriptor = BuilderHelper.createConstantDescriptor(locatorBridge);
bind(hDescriptor);
RestSessionManager rsm = habitat.getService(RestSessionManager.class);
AbstractActiveDescriptor<RestSessionManager> rmDescriptor = BuilderHelper.createConstantDescriptor(rsm);
bind(rmDescriptor);
}
});
for (Binder b : additionalBinders) {
rc.register(b);
}
rc.property(MessageProperties.LEGACY_WORKERS_ORDERING, true);
return rc;
}
use of org.glassfish.internal.api.ServerContext in project Payara by payara.
the class ActiveJmsResourceAdapter method isDBEnabled.
private boolean isDBEnabled() {
Domain domain = Globals.get(Domain.class);
ServerContext serverContext = Globals.get(ServerContext.class);
Server server = domain.getServerNamed(serverContext.getInstanceName());
AvailabilityService as = server.getConfig().getAvailabilityService();
if (as != null) {
JmsAvailability jmsAvailability = as.getExtensionByType(JmsAvailability.class);
if (jmsAvailability.getAvailabilityEnabled() != null && Boolean.parseBoolean(jmsAvailability.getAvailabilityEnabled())) {
return true;
} else if (jmsAvailability.getConfigStoreType() != null && !"MASTERBROKER".equalsIgnoreCase(jmsAvailability.getConfigStoreType()))
return true;
}
return false;
}
use of org.glassfish.internal.api.ServerContext in project Payara by payara.
the class ActiveJmsResourceAdapter method getClusterName.
private String getClusterName() {
ServerContext serverctx = Globals.get(ServerContext.class);
String instanceName = serverctx.getInstanceName();
Domain domain = Globals.get(Domain.class);
Server server = domain.getServerNamed(instanceName);
return server.getCluster() != null ? server.getCluster().getName() : null;
/*ClusterHelper.getClusterForInstance(this.serverContxt.
.getConfigContext(),
serverContxt.getInstanceName()).getName();*/
}
use of org.glassfish.internal.api.ServerContext in project Payara by payara.
the class ActiveJmsResourceAdapter method startResourceAdapter.
@Override
protected void startResourceAdapter(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
JmsService jmsService = getJmsService();
if (jmsService != null && jmsService.getType().equals("DISABLED")) {
return;
}
try {
if (this.moduleName_.equals(ConnectorRuntime.DEFAULT_JMS_ADAPTER)) {
if (connectorRuntime.isServer()) {
Domain domain = Globals.get(Domain.class);
ServerContext serverContext = Globals.get(ServerContext.class);
Server server = domain.getServerNamed(serverContext.getInstanceName());
try {
initializeLazyListener(jmsService);
} catch (Throwable ex) {
Logger.getLogger(ActiveJmsResourceAdapter.class.getName()).log(Level.SEVERE, null, ex);
throw new ResourceAdapterInternalException(ex);
}
}
// System.setProperty("imq.jmsra.direct.clustered", "true");
AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {
public Object run() throws ResourceAdapterInternalException {
// set the JMSRA system property to enable XA JOINS
// disabling this due to issue - 8727
// System.setProperty(XA_JOIN_ALLOWED, "true");
// to prevent classloader leaks in new threads clear invocation manager before bootstrapping JMS
resourceadapter_.start(bootStrapContextImpl);
return null;
}
});
// setResourceAdapter(resourceadapter_);
} else {
resourceadapter_.start(bootStrapContextImpl);
}
} catch (PrivilegedActionException ex) {
throw new ResourceAdapterInternalException(ex);
}
}
use of org.glassfish.internal.api.ServerContext in project Payara by payara.
the class OpenAPISupplier method getServerURL.
private List<URL> getServerURL(String contextRoot) {
List<URL> result = new ArrayList<>();
ServerContext context = Globals.get(ServerContext.class);
String hostName;
try {
hostName = InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException ex) {
hostName = "localhost";
}
String instanceType = Globals.get(ServerEnvironment.class).getRuntimeType().toString();
List<Integer> httpPorts = new ArrayList<>();
List<Integer> httpsPorts = new ArrayList<>();
List<NetworkListener> networkListeners = context.getConfigBean().getConfig().getNetworkConfig().getNetworkListeners().getNetworkListener();
String adminListener = context.getConfigBean().getConfig().getAdminListener().getName();
networkListeners.stream().filter(networkListener -> Boolean.parseBoolean(networkListener.getEnabled())).forEach(networkListener -> {
int port;
try {
// get the dynamic config port
port = Globals.get(GrizzlyService.class).getRealPort(networkListener);
} catch (MultiException ex) {
// get the port in the domain xml
port = Integer.parseInt(networkListener.getPort());
}
// Check if this listener is using HTTP or HTTPS
boolean securityEnabled = Boolean.parseBoolean(networkListener.findProtocol().getSecurityEnabled());
List<Integer> ports = securityEnabled ? httpsPorts : httpPorts;
// If this listener isn't the admin listener, it must be an HTTP/HTTPS listener
if (!networkListener.getName().equals(adminListener)) {
ports.add(port);
} else if (instanceType.equals("MICRO")) {
// micro instances can use the admin listener as both an admin and HTTP/HTTPS port
ports.add(port);
}
});
for (Integer httpPort : httpPorts) {
try {
result.add(new URL("http", hostName, httpPort, contextRoot));
} catch (MalformedURLException ex) {
// ignore
}
}
for (Integer httpsPort : httpsPorts) {
try {
result.add(new URL("https", hostName, httpsPort, contextRoot));
} catch (MalformedURLException ex) {
// ignore
}
}
return result;
}
Aggregations