Search in sources :

Example 1 with Method

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();
}
Also used : GeneratorAdapter(org.glassfish.hk2.external.org.objectweb.asm.commons.GeneratorAdapter) Method(org.glassfish.hk2.external.org.objectweb.asm.commons.Method)

Example 2 with Method

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() });
        }
    }
}
Also used : Method(java.lang.reflect.Method) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 3 with Method

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()]);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) StringTokenizer(java.util.StringTokenizer) ManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory) Iterator(java.util.Iterator) HashSet(java.util.HashSet) SetMethodAction(com.sun.enterprise.connectors.util.SetMethodAction)

Example 4 with Method

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"));
    }
}
Also used : SocketChannel(java.nio.channels.SocketChannel) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) Method(java.lang.reflect.Method) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 5 with Method

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Method(java.lang.reflect.Method) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) MultiException(org.glassfish.hk2.api.MultiException) PrivilegedActionException(java.security.PrivilegedActionException) ExecutionException(java.util.concurrent.ExecutionException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException) URISyntaxException(java.net.URISyntaxException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ManagedConnectionFactory(javax.resource.spi.ManagedConnectionFactory) Iterator(java.util.Iterator) SetMethodAction(com.sun.enterprise.connectors.util.SetMethodAction)

Aggregations

MultiException (org.glassfish.hk2.api.MultiException)18 Method (java.lang.reflect.Method)16 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)12 GeneratorAdapter (org.glassfish.hk2.external.org.objectweb.asm.commons.GeneratorAdapter)8 Method (org.glassfish.hk2.external.org.objectweb.asm.commons.Method)8 PrivilegedActionException (java.security.PrivilegedActionException)7 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)6 URISyntaxException (java.net.URISyntaxException)6 ExecutionException (java.util.concurrent.ExecutionException)6 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)6 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)6 File (java.io.File)5 HashMap (java.util.HashMap)5 ConfigModel (org.jvnet.hk2.config.ConfigModel)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Attribute (org.jvnet.hk2.config.Attribute)4 PropertyVetoException (java.beans.PropertyVetoException)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 HashSet (java.util.HashSet)3