use of org.glassfish.hk2.classmodel.reflect.Type in project Payara by payara.
the class BasicSharedServiceTest method createSharedServices.
private void createSharedServices() {
System.out.println("################### Trying to Create Shared Service #######################");
ServiceLocator habitat = Globals.getDefaultHabitat();
org.glassfish.api.admin.CommandRunner commandRunner = habitat.getService(org.glassfish.api.admin.CommandRunner.class);
ActionReport report = habitat.getService(ActionReport.class);
org.glassfish.api.admin.CommandRunner.CommandInvocation invocation = commandRunner.getCommandInvocation("create-shared-service", report);
ParameterMap parameterMap = new ParameterMap();
parameterMap.add("servicetype", "JavaEE");
parameterMap.add("characteristics", "service-type=JavaEE");
parameterMap.add("configuration", "min.clustersize=2:max.clustersize=4");
parameterMap.add("DEFAULT", "my-shared-gf-service");
invocation.parameters(parameterMap).execute();
System.out.println("Created shared service 'my-shared-gf-service' :" + !report.hasFailures());
Assert.assertFalse(report.hasFailures());
// Create shared service of type Database
// asadmin create-shared-service --characteristics service-type=Database --configuration database.name=my-shared-db-service --servicetype Database my-shared-db-service
parameterMap = new ParameterMap();
parameterMap.add("servicetype", "Database");
parameterMap.add("characteristics", "service-type=Database");
parameterMap.add("configuration", "database.name=my-shared-db-service");
parameterMap.add("DEFAULT", "my-shared-db-service");
invocation.parameters(parameterMap).execute();
System.out.println("Created shared service 'my-shared-db-service' :" + !report.hasFailures());
Assert.assertFalse(report.hasFailures());
// Create shared service of type LB
// asadmin create-shared-service --characteristics service-type=LB --configuration http-port=50080:https-port=50081:ssl-enabled=true --servicetype LB my-shared-lb-service
parameterMap = new ParameterMap();
parameterMap.add("servicetype", "LB");
parameterMap.add("characteristics", "service-type=LB");
parameterMap.add("configuration", "http-port=50080:https-port=50081:ssl-enabled=true");
parameterMap.add("DEFAULT", "my-shared-lb-service");
invocation.parameters(parameterMap).execute();
System.out.println("Created shared service 'my-shared-lb-service' :" + !report.hasFailures());
Assert.assertFalse(report.hasFailures());
// List the services and check the status of both the services - it should be 'RUNNING'
invocation = commandRunner.getCommandInvocation("list-services", report);
parameterMap = new ParameterMap();
parameterMap.add("scope", "shared");
parameterMap.add("output", "service-name,state");
invocation.parameters(parameterMap).execute();
boolean sharedServiceStarted = false;
List<Map<String, String>> list = (List<Map<String, String>>) report.getExtraProperties().get("list");
for (Map<String, String> map : list) {
sharedServiceStarted = false;
String state = map.get("STATE");
if ("RUNNING".equalsIgnoreCase(state)) {
sharedServiceStarted = true;
} else {
break;
}
}
// check if the shared services are started.
Assert.assertTrue(sharedServiceStarted);
// Try starting an uncreated service. Should fail
/* parameterMap=new ParameterMap();
parameterMap.add("DEFAULT","Uncreated-shared-db-service");
invocation.parameters(parameterMap).execute();
System.out.println("Started uncreated db shared service"+!report.hasFailures());
//Assert.assertTrue(report.hasFailures());*/
}
use of org.glassfish.hk2.classmodel.reflect.Type in project Payara by payara.
the class WeldUtils method hasCDIEnablingAnnotations.
/**
* Determine whether there are any beans annotated with annotations that should enable CDI
* processing even in the absence of a beans.xml descriptor.
*
* @param context The DeploymentContext
* @param paths The paths to check for annotated beans
*
* @return true, if there is at least one bean annotated with a qualified annotation in the specified paths
*/
public static boolean hasCDIEnablingAnnotations(DeploymentContext context, Collection<URI> paths) {
List<String> result = new ArrayList<String>();
Types types = getTypes(context);
if (types != null) {
Iterator<Type> typesIter = types.getAllTypes().iterator();
while (typesIter.hasNext()) {
Type type = typesIter.next();
if (!(type instanceof AnnotationType)) {
Iterator<AnnotationModel> annotations = type.getAnnotations().iterator();
while (annotations.hasNext()) {
AnnotationModel am = annotations.next();
AnnotationType at = am.getType();
if (isCDIEnablingAnnotation(at) && type.wasDefinedIn(paths)) {
if (!result.contains(at.getName())) {
result.add(at.getName());
}
}
}
}
}
}
return !(result.isEmpty());
}
use of org.glassfish.hk2.classmodel.reflect.Type in project Payara by payara.
the class WeldUtils method getCDIAnnotatedClassNames.
/**
* Get the names of any classes that are annotated with bean-defining annotations, which should
* enable CDI processing even in the absence of a beans.xml descriptor.
*
* @param context The DeploymentContext
*
* @return A collection of class names; The collection could be empty if none are found.
*/
public static Collection<String> getCDIAnnotatedClassNames(DeploymentContext context) {
Set<String> result = new HashSet<String>();
Types types = getTypes(context);
if (types != null) {
Iterator<Type> typesIter = types.getAllTypes().iterator();
while (typesIter.hasNext()) {
Type type = typesIter.next();
if (!(type instanceof AnnotationType)) {
Iterator<AnnotationModel> annotations = type.getAnnotations().iterator();
while (annotations.hasNext()) {
AnnotationModel am = annotations.next();
AnnotationType at = am.getType();
if (isCDIEnablingAnnotation(at)) {
if (!result.contains(at.getName())) {
result.add(type.getName());
}
}
}
}
}
}
return result;
}
use of org.glassfish.hk2.classmodel.reflect.Type in project Payara by payara.
the class ActiveJmsResourceAdapter method isASRmiRegistryPortAvailable.
private boolean isASRmiRegistryPortAvailable(JmsRaUtil jmsraUtil) {
if (_logger.isLoggable(Level.FINE))
logFine("isASRmiRegistryPortAvailable - JMSService Type:" + jmsraUtil.getJMSServiceType());
// AS RMI Registry. So the check below is not necessary.
if (jmsraUtil.getJMSServiceType().equals(REMOTE) || jmsraUtil.getJMSServiceType().equals(LOCAL)) {
return false;
}
try {
JmxConnector jmxConnector = getJmxConnector();
if (!"true".equals(jmxConnector.getEnabled()))
return false;
if ("true".equals(jmxConnector.getSecurityEnabled()))
return false;
// Attempt to detect JMXStartupService for RMI registry
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Detecting JMXStartupService...");
}
JMXStartupService jmxservice = Globals.get(JMXStartupService.class);
if (jmxservice == null)
return false;
jmxservice.waitUntilJMXConnectorStarted();
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Found JMXStartupService");
}
String name = "rmi://" + getConfiguredRmiRegistryHost() + ":" + getConfiguredRmiRegistryPort() + "/jmxrmi";
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Attempting to list " + name);
}
Naming.list(name);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("List on " + name + " succeeded");
}
// return configured port only if RMI registry is available
return true;
} catch (Exception e) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Failed to detect JMX RMI Registry: " + e.getMessage());
}
return false;
}
}
use of org.glassfish.hk2.classmodel.reflect.Type in project Payara by payara.
the class ExistingDomainTest method Test.
@Test
public void Test() {
ServiceLocator habitat = server.getHabitat();
System.out.println("Process type is " + habitat.<ProcessEnvironment>getService(ProcessEnvironment.class).getProcessType());
for (Sniffer s : habitat.<Sniffer>getAllServices(Sniffer.class)) {
System.out.println("Got sniffer " + s.getModuleType());
}
}
Aggregations