use of org.glassfish.hk2.external.org.objectweb.asm.commons.Method in project Payara by payara.
the class EjbOptionalIntfGenerator method generateNonAccessibleMethod.
private static void generateNonAccessibleMethod(ClassVisitor cv, java.lang.reflect.Method m) throws Exception {
String methodName = m.getName();
Type returnType = Type.getReturnType(m);
Type[] argTypes = Type.getArgumentTypes(m);
Method asmMethod = new Method(methodName, returnType, argTypes);
// Only called for non-static Protected or Package access
int access = ACC_PUBLIC;
GeneratorAdapter mg = new GeneratorAdapter(access, asmMethod, null, getExceptionTypes(m), cv);
mg.throwException(Type.getType(javax.ejb.EJBException.class), "Illegal non-business method access on no-interface view");
mg.returnValue();
mg.endMethod();
}
use of org.glassfish.hk2.external.org.objectweb.asm.commons.Method in project Payara by payara.
the class ActiveJmsResourceAdapter method setClusterBrokerList.
protected void setClusterBrokerList(String brokerList) {
try {
Class c = resourceadapter_.getClass();
Method m = c.getMethod("setClusterBrokerList", String.class);
m.invoke(resourceadapter_, brokerList);
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.CLUSTER_BROKER_SUCCESS, new Object[] { brokerList });
}
} catch (Exception ex) {
// throw new RuntimeException ("Error invoking PortMapperClientHandler.handleRequest. Cause - " + ex.getMessage(), ex);
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, JMSLoggerInfo.CLUSTER_BROKER_FAILURE, new Object[] { brokerList, ex.getMessage() });
}
}
}
use of org.glassfish.hk2.external.org.objectweb.asm.commons.Method in project Payara by payara.
the class ActiveJmsResourceAdapter method createManagedConnectionFactories.
/**
* This is a temporay solution for obtaining all the MCFs
* corresponding to a JMS RA pool, this is to facilitate the
* recovery process where the XA resources of all RMs in the
* broker cluster are required. Should be removed when a permanent
* solutuion is available from the broker.
* @param cpr <code>ConnectorConnectionPool</code> object
* @param loader Class Loader.
* @return
*/
@Override
public ManagedConnectionFactory[] createManagedConnectionFactories(com.sun.enterprise.connectors.ConnectorConnectionPool cpr, ClassLoader loader) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "RECOVERY : Entering createMCFS in AJMSRA");
}
ArrayList mcfs = new ArrayList();
if (getAddressListCount() < 2) {
mcfs.add(createManagedConnectionFactory(cpr, loader));
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Brokers are not clustered,So doing normal recovery");
}
} else {
String addlist = null;
Set s = cpr.getConnectorDescriptorInfo().getMCFConfigProperties();
Iterator tmpit = s.iterator();
while (tmpit.hasNext()) {
ConnectorConfigProperty prop = (ConnectorConfigProperty) tmpit.next();
String propName = prop.getName();
if (propName.equalsIgnoreCase("imqAddressList") || propName.equalsIgnoreCase("Addresslist")) {
addlist = prop.getValue();
}
}
StringTokenizer tokenizer = null;
if ((addlist == null) || (addlist.trim().equalsIgnoreCase("localhost"))) {
tokenizer = new StringTokenizer(addressList, ",");
} else {
tokenizer = new StringTokenizer(addlist, ",");
}
_logger.log(Level.FINE, "No of addresses found " + tokenizer.countTokens());
while (tokenizer.hasMoreTokens()) {
String brokerurl = tokenizer.nextToken();
ManagedConnectionFactory mcf = super.createManagedConnectionFactory(cpr, loader);
Iterator it = s.iterator();
while (it.hasNext()) {
ConnectorConfigProperty prop = (ConnectorConfigProperty) it.next();
String propName = prop.getName();
String propValue = prop.getValue();
if (propName.startsWith("imq") && !"".equals(propValue)) {
try {
Method meth = mcf.getClass().getMethod(SETTER, new Class[] { java.lang.String.class, java.lang.String.class });
if (propName.trim().equalsIgnoreCase("imqAddressList")) {
meth.invoke(mcf, new Object[] { prop.getName(), brokerurl });
} else {
meth.invoke(mcf, new Object[] { prop.getName(), prop.getValueObject() });
}
} catch (NoSuchMethodException ex) {
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, JMSLoggerInfo.NO_SUCH_METHOD, new Object[] { SETTER, mcf.getClass().getName() });
}
} catch (Exception ex) {
LogHelper.log(_logger, Level.SEVERE, JMSLoggerInfo.ERROR_EXECUTE_METHOD, ex, SETTER, mcf.getClass().getName());
}
}
}
ConnectorConfigProperty addressProp3 = new ConnectorConfigProperty(ADDRESSLIST, brokerurl, "Address List", "java.lang.String");
// todo: need to remove log statement
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ADDRESSLIST, new Object[] { brokerurl });
}
HashSet addressProp = new HashSet();
addressProp.add(addressProp3);
SetMethodAction setMethodAction = new SetMethodAction(mcf, addressProp);
try {
setMethodAction.run();
} catch (Exception e) {
;
}
mcfs.add(mcf);
}
}
return (ManagedConnectionFactory[]) mcfs.toArray(new ManagedConnectionFactory[mcfs.size()]);
}
use of org.glassfish.hk2.external.org.objectweb.asm.commons.Method in project Payara by payara.
the class ActiveJmsResourceAdapter method handleRequest.
@Override
public void handleRequest(SelectableChannel selectableChannel) {
SocketChannel socketChannel = null;
if (selectableChannel instanceof SocketChannel) {
socketChannel = (SocketChannel) selectableChannel;
// PortMapperClientHandler handler = null;
try {
Class c = resourceadapter_.getClass();
Method m = c.getMethod("getPortMapperClientHandler", null);
// handler = (PortMapperClientHandler) m.invoke(resourceadapter_, null);
Object handler = m.invoke(resourceadapter_, null);
m = handler.getClass().getMethod("handleRequest", SocketChannel.class);
// ((PortMapperClientHandler)ra_).handleRequest(socketChannel);
m.invoke(handler, socketChannel);
} catch (Exception ex) {
String message = sm.getString("error.invoke.portmapper", ex.getLocalizedMessage());
throw new RuntimeException(message, ex);
}
// handler.handleRequest(socketChannel);
} else {
throw new IllegalArgumentException(sm.getString("invalid.socket.channel"));
}
}
use of org.glassfish.hk2.external.org.objectweb.asm.commons.Method in project Payara by payara.
the class ActiveJmsResourceAdapter method createManagedConnectionFactory.
/**
* Creates ManagedConnection Factory instance. For any property that is
* for supporting AS7 imq properties, resource adapter has a set method
* setProperty(String,String). All as7 properties starts with "imq".
* MQ Adapter supports this only for backward compatibility.
*
* @param cpr <code>ConnectorConnectionPool</code> object
* @param loader Class Loader.
* @return
*/
@Override
public ManagedConnectionFactory createManagedConnectionFactory(com.sun.enterprise.connectors.ConnectorConnectionPool cpr, ClassLoader loader) {
ManagedConnectionFactory mcf = super.createManagedConnectionFactory(cpr, loader);
if (mcf != null) {
Set s = cpr.getConnectorDescriptorInfo().getMCFConfigProperties();
Iterator it = s.iterator();
while (it.hasNext()) {
ConnectorConfigProperty prop = (ConnectorConfigProperty) it.next();
String propName = prop.getName();
// setProperty(String,String) method.
if (propName.startsWith("imq") && !"".equals(prop.getValue())) {
try {
Method meth = mcf.getClass().getMethod(SETTER, new Class[] { java.lang.String.class, java.lang.String.class });
meth.invoke(mcf, new Object[] { prop.getName(), prop.getValueObject() });
} catch (NoSuchMethodException ex) {
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, JMSLoggerInfo.NO_SUCH_METHOD, new Object[] { SETTER, mcf.getClass().getName() });
}
} catch (Exception ex) {
LogHelper.log(_logger, Level.SEVERE, JMSLoggerInfo.ERROR_EXECUTE_METHOD, ex, SETTER, mcf.getClass().getName());
}
}
}
// CR 6591307- Fix for properties getting overridden when setRA is called. Resetting the properties if the RA is the JMS RA
String moduleName = this.getModuleName();
if (ConnectorAdminServiceUtils.isJMSRA(moduleName)) {
try {
Set configProperties = cpr.getConnectorDescriptorInfo().getMCFConfigProperties();
Object[] array = configProperties.toArray();
for (int i = 0; i < array.length; i++) {
if (array[i] instanceof ConnectorConfigProperty) {
ConnectorConfigProperty property = (ConnectorConfigProperty) array[i];
if (ActiveJmsResourceAdapter.ADDRESSLIST.equals(property.getName())) {
if (property.getValue() == null || "".equals(property.getValue()) || "localhost".equals(property.getValue())) {
_logger.log(Level.FINE, "raraddresslist.default.value : " + property.getValue());
configProperties.remove(property);
}
}
}
}
SetMethodAction setMethodAction = new SetMethodAction(mcf, configProperties);
setMethodAction.run();
} catch (Exception Ex) {
final String mcfClass = cpr.getConnectorDescriptorInfo().getManagedConnectionFactoryClass();
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, JMSLoggerInfo.RARDEPLOYMENT_MCF_ERROR, new Object[] { mcfClass, Ex.getMessage() });
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "rardeployment.mcfcreation_error", Ex);
}
}
}
}
return mcf;
}
Aggregations