use of org.glassfish.hk2.api.Filter in project Payara by payara.
the class TransactionalInterceptorBase method getTransactionalAnnotation.
private Transactional getTransactionalAnnotation(InvocationContext invocationContext) {
Optional<Transactional> optionalTransactional;
// Try the Weld bindings first. This gives us the *exact* binding which caused this interceptor being called
@SuppressWarnings("unchecked") Set<Annotation> bindings = (Set<Annotation>) invocationContext.getContextData().get("org.jboss.weld.interceptor.bindings");
if (bindings != null) {
optionalTransactional = bindings.stream().filter(annotation -> annotation.annotationType().equals(Transactional.class)).findAny().map(annotation -> Transactional.class.cast(annotation));
if (optionalTransactional.isPresent()) {
return optionalTransactional.get();
}
}
BeanManager beanManager = CDI.current().getBeanManager();
// Failing the Weld binding, check the method first
optionalTransactional = getAnnotation(beanManager, invocationContext.getMethod(), Transactional.class);
if (optionalTransactional.isPresent()) {
return optionalTransactional.get();
}
// If nothing found on the method, check the the bean class
optionalTransactional = getAnnotation(beanManager, invocationContext.getTarget().getClass(), Transactional.class);
if (optionalTransactional.isPresent()) {
return optionalTransactional.get();
}
// find it signals a critical error.
throw new IllegalStateException("@Transactional not found on " + invocationContext.getTarget().getClass());
}
use of org.glassfish.hk2.api.Filter in project Payara by payara.
the class CreateResourceRef method chooseRefContainer.
private RefContainer chooseRefContainer(final AdminCommandContext context) {
final ActionReport report = context.getActionReport();
Class<?>[] allInterfaces = resourceOfInterest.getClass().getInterfaces();
for (Class<?> resourceInterface : allInterfaces) {
ResourceConfigCreator resourceConfigCreator = resourceInterface.getAnnotation(ResourceConfigCreator.class);
if (resourceConfigCreator != null) {
commandName = resourceConfigCreator.commandName();
}
}
if (commandName != null) {
List<ServiceHandle<?>> serviceHandles = locator.getAllServiceHandles(new Filter() {
@Override
public boolean matches(Descriptor arg0) {
String name = arg0.getName();
return name != null && name.equals(commandName);
}
});
for (ServiceHandle<?> handle : serviceHandles) {
ActiveDescriptor<?> descriptor = handle.getActiveDescriptor();
if (descriptor.getName().equals(commandName)) {
if (!descriptor.isReified()) {
locator.reifyDescriptor(descriptor);
}
AdminCommand service = locator.<AdminCommand>getService(descriptor.getImplementationClass());
if (service != null) {
TargetType targetType = descriptor.getImplementationClass().getAnnotation(TargetType.class);
targets = targetType.value();
break;
}
}
}
if (!(isTargetValid = validateTarget(target, targets))) {
return null;
}
Config config = domain.getConfigs().getConfigByName(target);
if (config != null) {
return config;
}
Server server = configBeansUtilities.getServerNamed(target);
if (server != null) {
return server;
}
DeploymentGroup deploymentGroup = domain.getDeploymentGroupNamed(target);
if (deploymentGroup != null) {
return deploymentGroup;
}
return domain.getClusterNamed(target);
} else {
report.setMessage(LOCAL_STRINGS.getLocalString("create.resource.ref.failed", "Resource ref {0} creation failed", refName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return null;
}
}
use of org.glassfish.hk2.api.Filter in project Payara by payara.
the class GetHttpListener method execute.
@Override
public void execute(AdminCommandContext context) {
ActionReport report = context.getActionReport();
// Check that a configuration can be found
if (targetUtil.getConfig(target) == null) {
report.failure(logger, MessageFormat.format(logger.getResourceBundle().getString(LogFacade.UNKNOWN_CONFIG), target));
return;
}
Config config = targetUtil.getConfig(target);
// Check that a matching listener can be found
List<NetworkListener> listeners = config.getNetworkConfig().getNetworkListeners().getNetworkListener();
Optional<NetworkListener> optionalListener = listeners.stream().filter(listener -> listener.getName().equals(listenerName)).findFirst();
if (!optionalListener.isPresent()) {
report.failure(logger, MessageFormat.format(logger.getResourceBundle().getString(LogFacade.UNKNOWN_NETWORK_LISTENER), listenerName, target));
return;
}
NetworkListener listener = optionalListener.get();
// Write message body
report.appendMessage(String.format("Name: %s\n", listener.getName()));
report.appendMessage(String.format("Enabled: %s\n", listener.getEnabled()));
report.appendMessage(String.format("Port: %s\n", listener.getPort()));
if (listener.getPortRange() != null) {
report.appendMessage(String.format("Port Range: %s\n", listener.getPortRange()));
}
report.appendMessage(String.format("Address: %s\n", listener.getAddress()));
report.appendMessage(String.format("Protocol: %s\n", listener.getProtocol()));
if (verbose) {
report.appendMessage(String.format("Transport: %s\n", listener.getTransport()));
report.appendMessage(String.format("Type: %s\n", listener.getType()));
report.appendMessage(String.format("Thread Pool: %s\n", listener.getThreadPool()));
report.appendMessage(String.format("JK Enabled: %s\n", listener.getJkEnabled()));
report.appendMessage(String.format("JK Configuration File: %s\n", listener.getJkConfigurationFile()));
}
// Write the variables as properties
Properties properties = new Properties();
properties.put("name", listener.getName());
properties.put("enabled", listener.getEnabled());
properties.put("port", listener.getPort());
if (listener.getPortRange() != null) {
properties.put("portRange", listener.getPortRange());
}
properties.put("address", listener.getAddress());
properties.put("protocol", listener.getProtocol());
properties.put("transport", listener.getTransport());
properties.put("type", listener.getType());
properties.put("threadPool", listener.getThreadPool());
properties.put("jkEnabled", listener.getJkEnabled());
properties.put("jkConfigurationFile", listener.getJkConfigurationFile());
report.setExtraProperties(properties);
}
use of org.glassfish.hk2.api.Filter in project Payara by payara.
the class SafeProperties method getPersistentSchedules.
private Map<Method, List<ScheduledTimerDescriptor>> getPersistentSchedules() {
Map<Method, List<ScheduledTimerDescriptor>> persistentSchedules = new HashMap<>();
for (Entry<Method, List<ScheduledTimerDescriptor>> entry : schedules.entrySet()) {
Method method = entry.getKey();
List<ScheduledTimerDescriptor> descriptors = entry.getValue().stream().filter(descriptor -> descriptor.getPersistent()).collect(toList());
if (!descriptors.isEmpty()) {
persistentSchedules.put(method, descriptors);
}
}
return persistentSchedules;
}
use of org.glassfish.hk2.api.Filter in project Payara by payara.
the class SafeProperties method getNonPersistentSchedules.
private Map<Method, List<ScheduledTimerDescriptor>> getNonPersistentSchedules() {
Map<Method, List<ScheduledTimerDescriptor>> nonPersistentSchedules = new HashMap<>();
for (Entry<Method, List<ScheduledTimerDescriptor>> entry : schedules.entrySet()) {
Method method = entry.getKey();
List<ScheduledTimerDescriptor> descriptors = entry.getValue().stream().filter(descriptor -> !descriptor.getPersistent()).collect(toList());
if (!descriptors.isEmpty()) {
nonPersistentSchedules.put(method, descriptors);
}
}
return nonPersistentSchedules;
}
Aggregations