blob: 857b097bc2087f1648d24078863a9e291373f19e [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
package org.apache.sling.cta.impl;
import java.lang.instrument.ClassFileTransformer;
import java.util.ArrayList;
import java.util.List;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
public class AgentInfo implements AgentInfoMBean {
static final ObjectName NAME;
static {
try {
NAME = new ObjectName(AgentInfo.class.getPackage().getName().replace(".impl", "")+":type=Agent");
} catch (MalformedObjectNameException e) {
throw new ExceptionInInitializerError(e);
}
}
private final long connectTimeoutMillis;
private final long readTimeoutMillis;
private List<String> transformers = new ArrayList<>();
private List<String> transformedClasses = new ArrayList<>();
public AgentInfo(long connectTimeoutMillis, long readTimeoutMillis) {
this.connectTimeoutMillis = connectTimeoutMillis;
this.readTimeoutMillis = readTimeoutMillis;
}
@Override
public long getConnectTimeoutMillis() {
return connectTimeoutMillis;
}
@Override
public long getReadTimeoutMillis() {
return readTimeoutMillis;
}
public String[] getTransformers() {
return transformers.toArray(new String[0]);
}
public String[] getTransformedClasses() {
return transformedClasses.toArray(new String[0]);
}
public void registerTransformedClass(String transformedClassName) {
transformedClasses.add(transformedClassName);
}
public void registerTransformer(Class<? extends ClassFileTransformer> transformerClass) {
transformers.add(transformerClass.getName());
}
}