use of org.glassfish.hk2.external.org.objectweb.asm.commons.Method in project Payara by payara.
the class CommandResourceMetaData method processConfigBeans.
private static void processConfigBeans(ServiceLocator serviceLocator) {
List<ActiveDescriptor<?>> allDescriptors = serviceLocator.getDescriptors(BuilderHelper.createContractFilter(ConfigInjector.class.getName()));
HashSet<String> alreadyChecked = new HashSet<String>();
for (ActiveDescriptor<?> ad : allDescriptors) {
List<String> targets = ad.getMetadata().get("target");
if (targets == null)
continue;
for (String t : targets) {
if (alreadyChecked.contains(t))
continue;
alreadyChecked.add(t);
try {
Class<?> tclass = Class.forName(t);
if (tclass != null && ConfigBeanProxy.class.isAssignableFrom(tclass)) {
String beanName = tclass.getSimpleName();
for (Method m : tclass.getMethods()) {
if (m.isAnnotationPresent(Create.class)) {
addCreateMethod(beanName, m, m.getAnnotation(Create.class));
} else if (m.isAnnotationPresent(Delete.class)) {
addDeleteMethod(beanName, m, m.getAnnotation(Delete.class));
}
}
}
} catch (ClassNotFoundException cnfe) {
continue;
}
}
}
}
use of org.glassfish.hk2.external.org.objectweb.asm.commons.Method in project Payara by payara.
the class CDIExtension method afterBeanDiscovery.
/**
* This method will ensure that the file which indicates that the
* application has shut down properly has been removed and then
* adds the HK2 service to the system
*
* @param beforeBeanDiscovery
*/
@SuppressWarnings("unused")
private void afterBeanDiscovery(@Observes AfterBeanDiscovery afterBeanDiscovery) {
ServiceLocator locator = getServiceLocator();
if (locator == null)
return;
HK2ExtensionVerifier verifier = locator.getService(HK2ExtensionVerifier.class);
verifier.afterBeanDiscoveryCalled();
}
use of org.glassfish.hk2.external.org.objectweb.asm.commons.Method in project Payara by payara.
the class CDIExtension method beforeBeanDiscovery.
/**
* This method will ensure that the file which indicates that the
* application has shut down properly has been removed and then
* adds the HK2 service to the system
*
* @param beforeBeanDiscovery
*/
@SuppressWarnings("unused")
private void beforeBeanDiscovery(@Observes BeforeBeanDiscovery beforeBeanDiscovery) {
File destructoFile = createDestructionFileObject();
if (destructoFile == null)
return;
if (destructoFile.exists()) {
if (destructoFile.delete() == false)
return;
}
ServiceLocator locator = getServiceLocator();
if (locator == null)
return;
Descriptor d = BuilderHelper.link(HK2ExtensionVerifier.class).in(Singleton.class.getName()).andLoadWith(new HK2LoaderImpl()).build();
// Just having the service present is enough for the first callback
ServiceLocatorUtilities.addOneDescriptor(locator, d);
}
use of org.glassfish.hk2.external.org.objectweb.asm.commons.Method in project Payara by payara.
the class ExistingConfigurationTest method setupServer.
@Test
public void setupServer() throws Exception {
Server server = null;
Port port = null;
File f = EmbeddedServerUtils.getServerLocation();
try {
EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
efsb.installRoot(f);
// find the domain root.
f = EmbeddedServerUtils.getDomainLocation(f);
f = new File(f, "config");
f = new File(f, "domain.xml");
Assert.assertTrue(f.exists());
efsb.configurationFile(f, true);
server = EmbeddedServerUtils.createServer(efsb.build());
ServiceLocator habitat = server.getHabitat();
Collection<ServiceHandle<?>> vss = habitat.getAllServiceHandles(com.sun.enterprise.config.serverbeans.VirtualServer.class);
Assert.assertTrue(vss.size() > 0);
for (ServiceHandle<?> vs : vss) {
Object virtualServer = vs.getService();
Method m = virtualServer.getClass().getMethod("getId");
Assert.assertNotNull("Object returned does not implement getId, is it a virtual server ?", m);
String id = (String) m.invoke(virtualServer);
System.out.println("Virtual Server " + id);
Assert.assertNotNull("Got a null virtual server ID", id);
}
Collection<ServiceHandle<?>> nls = habitat.getAllServiceHandles(org.glassfish.grizzly.config.dom.NetworkListener.class);
Assert.assertTrue(nls.size() > 1);
for (ServiceHandle<?> nl : nls) {
Object networkListener = nl.getService();
Method m = networkListener.getClass().getMethod("getPort");
Assert.assertNotNull("Object returned does not implement getPort, is it a networkListener ?", m);
String p = (String) m.invoke(networkListener);
System.out.println("Network Listener " + p);
Assert.assertNotNull("Got a null networkListener port", p);
}
server.start();
port = server.createPort(8758);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
if (port != null) {
port.close();
}
EmbeddedServerUtils.shutdownServer(server);
}
}
use of org.glassfish.hk2.external.org.objectweb.asm.commons.Method in project Payara by payara.
the class ExistingDomainTest method Test.
@Test
public void Test() throws Exception {
ServiceLocator habitat = server.getHabitat();
System.out.println("Process type is " + habitat.<ProcessEnvironment>getService(ProcessEnvironment.class).getProcessType());
Collection<ServiceHandle<?>> listeners = habitat.getAllServiceHandles(org.glassfish.grizzly.config.dom.NetworkListener.class);
Assert.assertTrue(listeners.size() > 1);
for (ServiceHandle<?> s : listeners) {
Object networkListener = s.getService();
Method m = networkListener.getClass().getMethod("getPort");
Assert.assertNotNull("Object returned does not implement getPort, is it a networkListener ?", m);
String port = (String) m.invoke(networkListener);
System.out.println("Network Listener " + port);
Assert.assertNotNull("Got a null networkListener port", port);
}
}
Aggregations