Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.jolokia.service.jmx.handler;
/*
* Copyright 2009-2013 Roland Huss
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.management.*;
import javax.management.openmbean.OpenMBeanParameterInfo;
import javax.management.openmbean.OpenType;
import org.jolokia.server.core.request.JolokiaExecRequest;
import org.jolokia.server.core.service.serializer.Serializer;
import org.jolokia.server.core.util.RequestType;
/**
* Handler for dealing with execute requests.
*
* @author roland
* @since Jun 12, 2009
*/
public class ExecHandler extends AbstractCommandHandler {
/** {@inheritDoc} */
public RequestType getType() {
return RequestType.EXEC;
}
/** {@inheritDoc} */
@Override
protected void checkForRestriction(JolokiaExecRequest pRequest) {
if (!context.isOperationAllowed(pRequest.getObjectName(),pRequest.getOperation())) {
throw new SecurityException("Operation " + pRequest.getOperation() +
" forbidden for MBean " + pRequest.getObjectNameAsString());
}
}
/**
* Execute an JMX operation. The operation name is taken from the request, as well as the
* arguments to use. If the operation is given in the format "op(type1,type2,...)"
* (e.g "getText(java.lang.String,int)" then the argument types are taken into account
* as well. This way, overloaded JMX operation can be used. If an overloaded JMX operation
* is called without specifying the argument types, then an exception is raised.
*
*
* @param server server to try
* @param request request to process from where the operation and its arguments are extracted.
* @return the return value of the operation call
*/
@Override
public Object doHandleSingleServerRequest(MBeanServerConnection server, JolokiaExecRequest request)
throws InstanceNotFoundException, ReflectionException, MBeanException, IOException {
OperationAndParamType types = extractOperationTypes(server,request);
int nrParams = types.paramClasses.length;
Object[] params = new Object[nrParams];
@SuppressWarnings("unchecked")
List