_id
stringlengths 2
7
| title
stringlengths 3
140
| partition
stringclasses 3
values | text
stringlengths 73
34.1k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q177000
|
SpringActionInputParameter.isHidden
|
test
|
@Override
public boolean isHidden(String property) {
Annotation[] paramAnnotations = methodParameter.getParameterAnnotations();
Input inputAnnotation = methodParameter.getParameterAnnotation(Input.class);
return inputAnnotation != null && arrayContains(inputAnnotation.hidden(), property);
}
|
java
|
{
"resource": ""
}
|
q177001
|
SpringActionInputParameter.containsPropertyIncludeValue
|
test
|
private boolean containsPropertyIncludeValue(String property) {
return arrayContains(inputAnnotation.readOnly(), property)
|| arrayContains(inputAnnotation.hidden(), property)
|| arrayContains(inputAnnotation.include(), property);
}
|
java
|
{
"resource": ""
}
|
q177002
|
SpringActionInputParameter.hasExplicitOrImplicitPropertyIncludeValue
|
test
|
private boolean hasExplicitOrImplicitPropertyIncludeValue() {
// TODO maybe not a useful optimization
return inputAnnotation != null && inputAnnotation.readOnly().length > 0
|| inputAnnotation.hidden().length > 0
|| inputAnnotation.include().length > 0;
}
|
java
|
{
"resource": ""
}
|
q177003
|
SpringActionInputParameter.isRequired
|
test
|
public boolean isRequired() {
boolean ret;
if (isRequestBody()) {
ret = requestBody.required();
} else if (isRequestParam()) {
ret = !(isDefined(requestParam.defaultValue()) || !requestParam.required());
} else if (isRequestHeader()) {
ret = !(isDefined(requestHeader.defaultValue()) || !requestHeader.required());
} else {
ret = true;
}
return ret;
}
|
java
|
{
"resource": ""
}
|
q177004
|
SpringActionInputParameter.getDefaultValue
|
test
|
public String getDefaultValue() {
String ret;
if (isRequestParam()) {
ret = isDefined(requestParam.defaultValue()) ?
requestParam.defaultValue() : null;
} else if (isRequestHeader()) {
ret = !(ValueConstants.DEFAULT_NONE.equals(requestHeader.defaultValue())) ?
requestHeader.defaultValue() : null;
} else {
ret = null;
}
return ret;
}
|
java
|
{
"resource": ""
}
|
q177005
|
SpringActionInputParameter.getParameterName
|
test
|
@Override
public String getParameterName() {
String ret = null;
if (requestParam != null) {
String requestParamName = requestParam.value();
if (!requestParamName.isEmpty())
ret = requestParamName;
}
if (pathVariable != null) {
String pathVariableName = pathVariable.value();
if (!pathVariableName.isEmpty())
ret = pathVariableName;
}
if (ret == null) {
String parameterName = methodParameter.getParameterName();
if (parameterName == null) {
methodParameter.initParameterNameDiscovery(new LocalVariableTableParameterNameDiscoverer());
ret = methodParameter.getParameterName();
} else {
ret = parameterName;
}
}
return ret;
}
|
java
|
{
"resource": ""
}
|
q177006
|
LinkListSerializer.getExposedPropertyOrParamName
|
test
|
private String getExposedPropertyOrParamName(ActionInputParameter inputParameter) {
final Expose expose = inputParameter.getAnnotation(Expose.class);
String property;
if (expose != null) {
property = expose.value();
} else {
property = inputParameter.getParameterName();
}
return property;
}
|
java
|
{
"resource": ""
}
|
q177007
|
LdContextFactory.getVocab
|
test
|
public String getVocab(MixinSource mixinSource, Object bean, Class<?> mixInClass) {
if (proxyUnwrapper != null) {
bean = proxyUnwrapper.unwrapProxy(bean);
}
// determine vocab in context
String classVocab = bean == null ? null : vocabFromClassOrPackage(bean.getClass());
final Vocab mixinVocab = findAnnotation(mixInClass, Vocab.class);
Object nestedContextProviderFromMixin = getNestedContextProviderFromMixin(mixinSource, bean, mixInClass);
String contextProviderVocab = null;
if (nestedContextProviderFromMixin != null) {
contextProviderVocab = getVocab(mixinSource, nestedContextProviderFromMixin, null);
}
String vocab;
if (mixinVocab != null) {
vocab = mixinVocab.value(); // wins over class
} else if (classVocab != null) {
vocab = classVocab; // wins over context provider
} else if (contextProviderVocab != null) {
vocab = contextProviderVocab; // wins over last resort
} else {
vocab = HTTP_SCHEMA_ORG;
}
return vocab;
}
|
java
|
{
"resource": ""
}
|
q177008
|
PartialUriTemplateComponents.getQuery
|
test
|
public String getQuery() {
StringBuilder query = new StringBuilder();
if (queryTail.length() > 0) {
if (queryHead.length() == 0) {
query.append("{?")
.append(queryTail)
.append("}");
} else if (queryHead.length() > 0) {
query.append(queryHead)
.append("{&")
.append(queryTail)
.append("}");
}
} else {
query.append(queryHead);
}
return query.toString();
}
|
java
|
{
"resource": ""
}
|
q177009
|
XhtmlWriter.appendForm
|
test
|
private void appendForm(Affordance affordance, ActionDescriptor actionDescriptor) throws IOException {
String formName = actionDescriptor.getActionName();
RequestMethod httpMethod = RequestMethod.valueOf(actionDescriptor.getHttpMethod());
// Link's expand method removes non-required variables from URL
String actionUrl = affordance.expand()
.getHref();
beginForm(OptionalAttributes.attr("action", actionUrl)
.and("method", getHtmlConformingHttpMethod(httpMethod))
.and("name", formName));
write("<h4>");
write("Form " + formName);
write("</h4>");
writeHiddenHttpMethodField(httpMethod);
// build the form
if (actionDescriptor.hasRequestBody()) { // parameter bean
ActionInputParameter requestBody = actionDescriptor.getRequestBody();
Class<?> parameterType = requestBody.getParameterType();
recurseBeanProperties(parameterType, actionDescriptor, requestBody, requestBody.getValue(), "");
} else { // plain parameter list
Collection<String> requestParams = actionDescriptor.getRequestParamNames();
for (String requestParamName : requestParams) {
ActionInputParameter actionInputParameter = actionDescriptor.getActionInputParameter(requestParamName);
Object[] possibleValues = actionInputParameter.getPossibleValues(actionDescriptor);
// TODO duplication with appendInputOrSelect
if (possibleValues.length > 0) {
if (actionInputParameter.isArrayOrCollection()) {
appendSelectMulti(requestParamName, possibleValues, actionInputParameter);
} else {
appendSelectOne(requestParamName, possibleValues, actionInputParameter);
}
} else {
if (actionInputParameter.isArrayOrCollection()) {
// have as many inputs as there are call values, list of 5 nulls gives you five input fields
// TODO support for free list input instead, code on demand?
Object[] callValues = actionInputParameter.getValues();
int items = callValues.length;
for (int i = 0; i < items; i++) {
Object value;
if (i < callValues.length) {
value = callValues[i];
} else {
value = null;
}
appendInput(requestParamName, actionInputParameter, value, actionInputParameter
.isReadOnly(requestParamName)); // not readonly
}
} else {
String callValueFormatted = actionInputParameter.getValueFormatted();
appendInput(requestParamName, actionInputParameter, callValueFormatted, actionInputParameter
.isReadOnly(requestParamName)); // not readonly
}
}
}
}
inputButton(Type.SUBMIT, capitalize(httpMethod.name()
.toLowerCase()));
endForm();
}
|
java
|
{
"resource": ""
}
|
q177010
|
XhtmlWriter.inputButton
|
test
|
private void inputButton(Type type, String value) throws IOException {
write("<input type=\"");
write(type.toString());
write("\" ");
write("value");
write("=");
quote();
write(value);
quote();
write("/>");
}
|
java
|
{
"resource": ""
}
|
q177011
|
XhtmlWriter.appendInputOrSelect
|
test
|
private void appendInputOrSelect(ActionInputParameter parentInputParameter, String paramName, ActionInputParameter
childInputParameter, Object[] possibleValues) throws IOException {
if (possibleValues.length > 0) {
if (childInputParameter.isArrayOrCollection()) {
// TODO multiple formatted callvalues
appendSelectMulti(paramName, possibleValues,
childInputParameter);
} else {
appendSelectOne(paramName, possibleValues,
childInputParameter);
}
} else {
appendInput(paramName, childInputParameter,
childInputParameter.getValue(),
parentInputParameter.isReadOnly(paramName));
}
}
|
java
|
{
"resource": ""
}
|
q177012
|
AffordanceBuilder.and
|
test
|
public AffordanceBuilder and(AffordanceBuilder affordanceBuilder) {
for (ActionDescriptor actionDescriptor : affordanceBuilder.actionDescriptors) {
this.actionDescriptors.add(actionDescriptor);
}
return this;
}
|
java
|
{
"resource": ""
}
|
q177013
|
PartialUriTemplate.asComponents
|
test
|
public PartialUriTemplateComponents asComponents() {
return getUriTemplateComponents(Collections.<String, Object>emptyMap(), Collections.<String>emptyList());
}
|
java
|
{
"resource": ""
}
|
q177014
|
PartialUriTemplate.stripOptionalVariables
|
test
|
public PartialUriTemplateComponents stripOptionalVariables(List<ActionDescriptor> actionDescriptors) {
return getUriTemplateComponents(Collections.<String, Object>emptyMap(), getRequiredArgNames(actionDescriptors));
}
|
java
|
{
"resource": ""
}
|
q177015
|
AbstractUberNode.getFirstByName
|
test
|
public UberNode getFirstByName(String name) {
// TODO consider less naive impl
UberNode ret = null;
for (UberNode node : data) {
if (name.equals(node.getName())) {
ret = node;
break;
}
}
return ret;
}
|
java
|
{
"resource": ""
}
|
q177016
|
AbstractUberNode.getFirstByRel
|
test
|
public UberNode getFirstByRel(String rel) {
// TODO consider less naive impl
for (UberNode node : data) {
List<String> myRels = node.getRel();
if (myRels != null) {
for (String myRel : myRels) {
if (rel.equals(myRel)) {
return node;
}
}
}
}
return null;
}
|
java
|
{
"resource": ""
}
|
q177017
|
AbstractUberNode.iterator
|
test
|
@Override
public Iterator<UberNode> iterator() {
return new Iterator<UberNode>() {
int index = 0;
@Override
public void remove() {
throw new UnsupportedOperationException("removing from uber node is not supported");
}
@Override
public UberNode next() {
index = findNextChildWithData();
return data.get(index++);
}
@Override
public boolean hasNext() {
return findNextChildWithData() != -1;
}
private int findNextChildWithData() {
for (int i = index; i < data.size(); i++) {
if (!data.get(i)
.getData()
.isEmpty()) {
return i;
}
}
return -1;
}
};
}
|
java
|
{
"resource": ""
}
|
q177018
|
PersistentHashMap.ofEq
|
test
|
@SuppressWarnings("WeakerAccess")
public static <K,V> PersistentHashMap<K,V> ofEq(Equator<K> eq, Iterable<Map.Entry<K,V>> es) {
if (es == null) { return empty(eq); }
MutableHashMap<K,V> map = emptyMutable(eq);
for (Map.Entry<K,V> entry : es) {
if (entry != null) {
map.assoc(entry.getKey(), entry.getValue());
}
}
return map.immutable();
}
|
java
|
{
"resource": ""
}
|
q177019
|
PersistentTreeMap.of
|
test
|
public static <K extends Comparable<K>,V> PersistentTreeMap<K,V>
of(Iterable<Map.Entry<K,V>> es) {
if (es == null) { return empty(); }
PersistentTreeMap<K,V> map = new PersistentTreeMap<>(Equator.defaultComparator(), null, 0);
for (Map.Entry<K,V> entry : es) {
if (entry != null) {
map = map.assoc(entry.getKey(), entry.getValue());
}
}
return map;
}
|
java
|
{
"resource": ""
}
|
q177020
|
PersistentTreeMap.empty
|
test
|
public static <K,V> PersistentTreeMap<K,V> empty(Comparator<? super K> c) {
return new PersistentTreeMap<>(c, null, 0);
}
|
java
|
{
"resource": ""
}
|
q177021
|
PersistentTreeMap.entrySet
|
test
|
@Override public ImSortedSet<Entry<K,V>> entrySet() {
// This is the pretty way to do it.
return this.fold(PersistentTreeSet.ofComp(new KeyComparator<>(comp)),
PersistentTreeSet::put);
}
|
java
|
{
"resource": ""
}
|
q177022
|
PersistentTreeMap.lastKey
|
test
|
@Override public K lastKey() {
UnEntry<K,V> max = last();
if (max == null) {
throw new NoSuchElementException("this map is empty");
}
return max.getKey();
}
|
java
|
{
"resource": ""
}
|
q177023
|
Xform.of
|
test
|
public static <T> Xform<T> of(Iterable<? extends T> list) {
if (list == null) { return empty(); }
return new SourceProviderIterableDesc<>(list);
}
|
java
|
{
"resource": ""
}
|
q177024
|
Xform._fold
|
test
|
@SuppressWarnings("unchecked")
private static <H> H _fold(Iterable source, Operation[] ops, int opIdx, H ident, Fn2 reducer) {
Object ret = ident;
// This is a label - the first one I have used in Java in years, or maybe ever.
// I'm assuming this is fast, but will have to test to confirm it.
sourceLoop:
for (Object o : source) {
for (int j = opIdx; j < ops.length; j++) {
Operation op = ops[j];
if ( (op.filter != null) && !op.filter.apply(o) ) {
// stop processing this source item and go to the next one.
continue sourceLoop;
}
if (op.map != null) {
o = op.map.apply(o);
// This is how map can handle takeWhile, take, and other termination marker
// roles. Remember, the fewer functions we have to check for, the faster this
// will execute.
if (o == TERMINATE) {
return (H) ret;
}
} else if (op.flatMap != null) {
ret = _fold(op.flatMap.apply(o), ops, j + 1, (H) ret, reducer);
// stop processing this source item and go to the next one.
continue sourceLoop;
}
// if ( (op.terminate != null) && op.terminate.apply(o) ) {
// return (G) ret;
// }
}
// Here, the item made it through all the operations. Combine it with the result.
ret = reducer.apply(ret, o);
}
return (H) ret;
}
|
java
|
{
"resource": ""
}
|
q177025
|
Xform.dropWhile
|
test
|
@Override public Xform<A> dropWhile(Fn1<? super A,Boolean> predicate) {
if (predicate == null) { throw new IllegalArgumentException("Can't dropWhile without a function."); }
return new DropWhileDesc<>(this, predicate);
}
|
java
|
{
"resource": ""
}
|
q177026
|
Xform.fold
|
test
|
@Override public <B> B fold(B ident, Fn2<? super B,? super A,B> reducer) {
if (reducer == null) {
throw new IllegalArgumentException("Can't fold with a null reduction function.");
}
// Construct an optimized array of OpRuns (mutable operations for this run)
RunList runList = toRunList();
return _fold(runList, runList.opArray(), 0, ident, reducer);
}
|
java
|
{
"resource": ""
}
|
q177027
|
Tuple2.of
|
test
|
public static <K,V> Tuple2<K,V> of(Map.Entry<K,V> entry) {
// Protect against multiple-instantiation
if (entry instanceof Tuple2) {
return (Tuple2<K,V>) entry;
}
return new Tuple2<>(entry.getKey(), entry.getValue());
}
|
java
|
{
"resource": ""
}
|
q177028
|
OneOf3.match
|
test
|
@SuppressWarnings("unchecked")
public <R> R match(Fn1<A, R> fa,
Fn1<B, R> fb,
Fn1<C, R> fc) {
if (sel == 0) {
return fa.apply((A) item);
} else if (sel == 1) {
return fb.apply((B) item);
} else {
return fc.apply((C) item);
}
}
|
java
|
{
"resource": ""
}
|
q177029
|
RuntimeTypes.registerClasses
|
test
|
public static ImList<Class> registerClasses(Class... cs) {
if (cs == null) {
throw new IllegalArgumentException("Can't register a null type array");
}
if (cs.length == 0) {
throw new IllegalArgumentException("Can't register a zero-length type array");
}
for (Class c : cs) {
if (c == null) {
throw new IllegalArgumentException("There shouldn't be any null types in this array!");
}
}
ArrayHolder<Class> ah = new ArrayHolder<>(cs);
ImList<Class> registeredTypes;
synchronized (Lock.INSTANCE) {
registeredTypes = typeMap.get(ah);
if (registeredTypes == null) {
ImList<Class> vecCs = vec(cs);
typeMap.put(ah, vecCs);
registeredTypes = vecCs;
}
}
// We are returning the original array. If we returned our safe copy, it could be modified!
return registeredTypes;
}
|
java
|
{
"resource": ""
}
|
q177030
|
PersistentVector.get
|
test
|
@Override public E get(int i) {
E[] node = leafNodeArrayFor(i);
return node[i & LOW_BITS];
}
|
java
|
{
"resource": ""
}
|
q177031
|
PersistentVector.append
|
test
|
@SuppressWarnings("unchecked")
@Override public PersistentVector<E> append(E val) {
//room in tail?
// if(tail.length < MAX_NODE_LENGTH)
if (size - tailoff() < MAX_NODE_LENGTH) {
E[] newTail = (E[]) new Object[tail.length + 1];
System.arraycopy(tail, 0, newTail, 0, tail.length);
newTail[tail.length] = val;
return new PersistentVector<>(size + 1, shift, root, newTail);
}
//full tail, push into tree
Node newroot;
Node tailnode = new Node(root.edit, tail);
int newshift = shift;
//overflow root?
if ((size >>> NODE_LENGTH_POW_2) > (1 << shift)) {
newroot = new Node(root.edit);
newroot.array[0] = root;
newroot.array[1] = newPath(root.edit, shift, tailnode);
newshift += NODE_LENGTH_POW_2;
} else {
newroot = pushTail(shift, root, tailnode);
}
return new PersistentVector<>(size + 1, newshift, newroot, (E[]) new Object[]{val});
}
|
java
|
{
"resource": ""
}
|
q177032
|
PersistentVector.concat
|
test
|
@Override public PersistentVector<E> concat(Iterable<? extends E> items) {
return (PersistentVector<E>) ImList.super.concat(items);
}
|
java
|
{
"resource": ""
}
|
q177033
|
StaticImports.mutableSet
|
test
|
@SafeVarargs
public static <T> MutableSet<T> mutableSet(T... items) {
MutableSet<T> ret = PersistentHashSet.emptyMutable();
if (items == null) { return ret; }
for (T t : items) {
ret.put(t);
}
return ret;
}
|
java
|
{
"resource": ""
}
|
q177034
|
StaticImports.mutableVec
|
test
|
@SafeVarargs
public static <T> MutableList<T> mutableVec(T... items) {
MutableList<T> ret = PersistentVector.emptyMutable();
if (items == null) { return ret; }
for (T t : items) {
ret.append(t);
}
return ret;
}
|
java
|
{
"resource": ""
}
|
q177035
|
StaticImports.set
|
test
|
@SafeVarargs
public static <T> ImSet<T> set(T... items) {
if ( (items == null) || (items.length < 1) ) { return PersistentHashSet.empty(); }
return PersistentHashSet.of(Arrays.asList(items));
}
|
java
|
{
"resource": ""
}
|
q177036
|
StaticImports.vec
|
test
|
@SafeVarargs
static public <T> ImList<T> vec(T... items) {
if ( (items == null) || (items.length < 1) ) { return PersistentVector.empty(); }
return mutableVec(items).immutable();
}
|
java
|
{
"resource": ""
}
|
q177037
|
StaticImports.xformArray
|
test
|
@SafeVarargs
public static <T> UnmodIterable<T> xformArray(T... items) {
return Xform.of(Arrays.asList(items));
}
|
java
|
{
"resource": ""
}
|
q177038
|
IndentUtils.indentSpace
|
test
|
public static StringBuilder indentSpace(int len) {
StringBuilder sB = new StringBuilder();
if (len < 1) { return sB; }
while (len > SPACES_LENGTH_MINUS_ONE) {
sB.append(SPACES[SPACES_LENGTH_MINUS_ONE]);
len = len - SPACES_LENGTH_MINUS_ONE;
}
return sB.append(SPACES[len]);
}
|
java
|
{
"resource": ""
}
|
q177039
|
IndentUtils.arrayString
|
test
|
public static <T> String arrayString(T[] items) {
StringBuilder sB = new StringBuilder("A[");
boolean isFirst = true;
for (T item : items) {
if (isFirst) {
isFirst = false;
} else {
sB.append(" ");
}
if (item instanceof String) {
sB.append("\"").append(item).append("\"");
} else {
sB.append(item);
}
}
return sB.append("]").toString();
}
|
java
|
{
"resource": ""
}
|
q177040
|
LazyRef.of
|
test
|
public static <T> LazyRef<T> of(Fn0<T> producer) {
if (producer == null) {
throw new IllegalArgumentException("The producer function cannot be null (the value it returns can)");
}
return new LazyRef<>(producer);
}
|
java
|
{
"resource": ""
}
|
q177041
|
LazyRef.applyEx
|
test
|
public synchronized T applyEx() {
// Have we produced our value yet?
if (producer != null) {
// produce our value.
value = producer.apply();
// Delete the producer to 1. mark the work done and 2. free resources.
producer = null;
}
// We're clear to return the lazily computed value.
return value;
}
|
java
|
{
"resource": ""
}
|
q177042
|
Cowry.insertIntoArrayAt
|
test
|
public static <T> T[] insertIntoArrayAt(T item, T[] items, int idx, Class<T> tClass) {
// Make an array that's one bigger. It's too bad that the JVM bothers to
// initialize this with nulls.
@SuppressWarnings("unchecked")
T[] newItems = (T[]) ((tClass == null) ? new Object[items.length + 1]
: Array.newInstance(tClass, items.length + 1) );
// If we aren't inserting at the first item, array-copy the items before the insert
// point.
if (idx > 0) {
System.arraycopy(items, 0, newItems, 0, idx);
}
// Insert the new item.
newItems[idx] = item;
// If we aren't inserting at the last item, array-copy the items after the insert
// point.
if (idx < items.length) {
System.arraycopy(items, idx, newItems, idx + 1, items.length - idx);
}
return newItems;
}
|
java
|
{
"resource": ""
}
|
q177043
|
Cowry.arrayCopy
|
test
|
public static <T> T[] arrayCopy(T[] items, int length, Class<T> tClass) {
// Make an array of the appropriate size. It's too bad that the JVM bothers to
// initialize this with nulls.
@SuppressWarnings("unchecked")
T[] newItems = (T[]) ((tClass == null) ? new Object[length]
: Array.newInstance(tClass, length) );
// array-copy the items up to the new length.
if (length > 0) {
System.arraycopy(items, 0, newItems, 0,
items.length < length ? items.length
: length);
}
return newItems;
}
|
java
|
{
"resource": ""
}
|
q177044
|
SleeTransactionImpl.suspendIfAssoaciatedWithThread
|
test
|
private void suspendIfAssoaciatedWithThread() throws SystemException {
// if there is a tx associated with this thread and it is this one
// then suspend it to dissociate the thread (dumb feature?!?! of jboss ts)
final SleeTransaction currentThreadTransaction = transactionManager
.getSleeTransaction();
if (currentThreadTransaction != null
&& currentThreadTransaction.equals(this)) {
// lets use the real tx manager directly, to avoid any other procedures
transactionManager.getRealTransactionManager().suspend();
}
}
|
java
|
{
"resource": ""
}
|
q177045
|
SleeTransactionImpl.beforeAsyncOperation
|
test
|
private void beforeAsyncOperation() throws IllegalStateException,
SecurityException {
try {
int status = transaction.getStatus();
if (asyncOperationInitiated.getAndSet(true) || (status != Status.STATUS_ACTIVE
&& status != Status.STATUS_MARKED_ROLLBACK)) {
throw new IllegalStateException(
"There is no active tx, tx is in state: " + status);
}
suspendIfAssoaciatedWithThread();
} catch (SystemException e) {
throw new IllegalStateException(e);
}
}
|
java
|
{
"resource": ""
}
|
q177046
|
DeployableUnitServiceComponentBuilder.buildComponents
|
test
|
public List<ServiceComponentImpl> buildComponents(String serviceDescriptorFileName, JarFile deployableUnitJar) throws DeploymentException {
// make component jar entry
JarEntry componentDescriptor = deployableUnitJar.getJarEntry(serviceDescriptorFileName);
InputStream componentDescriptorInputStream = null;
List<ServiceComponentImpl> result = new ArrayList<ServiceComponentImpl>();
try {
componentDescriptorInputStream = deployableUnitJar.getInputStream(componentDescriptor);
ServiceDescriptorFactoryImpl descriptorFactory = componentManagement.getComponentDescriptorFactory().getServiceDescriptorFactory();
for (ServiceDescriptorImpl descriptor : descriptorFactory.parse(componentDescriptorInputStream)) {
result.add(new ServiceComponentImpl(descriptor));
}
} catch (IOException e) {
throw new DeploymentException("failed to parse service descriptor from "+componentDescriptor.getName(),e);
}
finally {
if (componentDescriptorInputStream != null) {
try {
componentDescriptorInputStream.close();
} catch (IOException e) {
logger.error("failed to close inputstream of descriptor for jar "+componentDescriptor.getName());
}
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q177047
|
ConcreteClassGeneratorUtils.validateDirectory
|
test
|
static private void validateDirectory(File aDirectory)
throws FileNotFoundException {
if (aDirectory == null) {
throw new IllegalArgumentException("Directory should not be null.");
}
if (!aDirectory.exists()) {
throw new FileNotFoundException("Directory does not exist: "
+ aDirectory);
}
if (!aDirectory.isDirectory()) {
throw new IllegalArgumentException("Is not a directory: "
+ aDirectory);
}
if (!aDirectory.canRead()) {
throw new IllegalArgumentException("Directory cannot be read: "
+ aDirectory);
}
}
|
java
|
{
"resource": ""
}
|
q177048
|
ConcreteClassGeneratorUtils.createInheritanceLink
|
test
|
public static void createInheritanceLink(CtClass concreteClass,
CtClass superClass) {
if (superClass == null)
return;
try {
concreteClass.setSuperclass(superClass);
logger.trace(concreteClass.getName() + " Inheritance link with "
+ superClass.getName() + " class created");
} catch (CannotCompileException cce) {
cce.printStackTrace();
}
}
|
java
|
{
"resource": ""
}
|
q177049
|
ConcreteClassGeneratorUtils.copyMethods
|
test
|
public static void copyMethods(CtClass source, CtClass destination,
CtClass[] exceptions) {
copyMethods(source.getDeclaredMethods(), destination, exceptions);
}
|
java
|
{
"resource": ""
}
|
q177050
|
ConcreteClassGeneratorUtils.copyMethods
|
test
|
public static void copyMethods(CtMethod[] methods, CtClass destination,
CtClass[] exceptions) {
CtMethod methodCopy = null;
for (CtMethod method : methods) {
try {
methodCopy = new CtMethod(method, destination, null);
if (exceptions != null) {
try {
methodCopy.setExceptionTypes(exceptions);
} catch (NotFoundException e) {
throw new SLEEException(e.getMessage(),e);
}
}
destination.addMethod(methodCopy);
} catch (CannotCompileException e) {
throw new SLEEException(e.getMessage(),e);
}
}
}
|
java
|
{
"resource": ""
}
|
q177051
|
LogStructureTreePanel.doTree
|
test
|
private TreeItem doTree(FQDNNode localRoot) {
TreeItem localLeaf = new TreeItem();
LogTreeNode logTreeNode = new LogTreeNode(browseContainer, localRoot.getShortName(), localRoot.getFqdName(), localRoot.isWasLeaf(), this);
localLeaf.setWidget(logTreeNode);
if (localRoot.getChildren().size() > 0) {
Tree t = new Tree();
ArrayList names = new ArrayList(localRoot.getChildrenNames());
Collections.sort(names);
Iterator it = names.iterator();
while (it.hasNext()) {
t.addItem(doTree(localRoot.getChild((String) it.next())));
}
localLeaf.addItem(t);
}
return localLeaf;
}
|
java
|
{
"resource": ""
}
|
q177052
|
SbbEntityFactoryImpl.removeSbbEntityWithCurrentClassLoader
|
test
|
private void removeSbbEntityWithCurrentClassLoader(
final SbbEntity sbbEntity) {
// remove entity
sbbEntity.remove();
// remove from tx data
final TransactionContext txContext = sleeContainer.getTransactionManager().getTransactionContext();
final SbbEntityID sbbEntityID = sbbEntity.getSbbEntityId();
txContext.getData().remove(sbbEntityID);
// if sbb entity is root add a tx action to ensure lock is removed
if (sbbEntityID.isRootSbbEntity()) {
TransactionalAction txAction = new TransactionalAction() {
@Override
public void execute() {
lockFacility.remove(sbbEntityID);
}
};
txContext.getAfterCommitActions().add(txAction);
}
}
|
java
|
{
"resource": ""
}
|
q177053
|
UsageNotificationManagerMBeanImpl.getNotificationsEnabled
|
test
|
public boolean getNotificationsEnabled(String paramName) {
Boolean areNotificationsEnabled = paramNames.get(paramName);
if(!isSlee11)
{
if (areNotificationsEnabled == null
|| areNotificationsEnabled.booleanValue()) {
// considering that notifications are enabled, by default, for each
// param
return true;
} else {
return false;
}
}else
{
if (areNotificationsEnabled != null
&& areNotificationsEnabled.booleanValue()) {
// considering that notifications are enabled, by default, for each
// param
return true;
} else {
return false;
}
}
}
|
java
|
{
"resource": ""
}
|
q177054
|
ServiceManagementImpl.getReferencedRAEntityLinksWhichNotExists
|
test
|
public Set<String> getReferencedRAEntityLinksWhichNotExists(
ServiceComponent serviceComponent) {
Set<String> result = new HashSet<String>();
Set<String> raLinkNames = sleeContainer.getResourceManagement()
.getLinkNamesSet();
for (String raLink : serviceComponent
.getResourceAdaptorEntityLinks(componentRepositoryImpl)) {
if (!raLinkNames.contains(raLink)) {
result.add(raLink);
}
}
return result;
}
|
java
|
{
"resource": ""
}
|
q177055
|
ServiceManagementImpl.installService
|
test
|
public void installService(final ServiceComponent serviceComponent)
throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Installing Service " + serviceComponent);
}
// creates and registers the service usage mbean
final ServiceUsageMBean serviceUsageMBean = sleeContainer
.getUsageParametersManagement().newServiceUsageMBean(
serviceComponent);
// add rollback action to remove state created
TransactionalAction action = new TransactionalAction() {
public void execute() {
try {
serviceUsageMBean.remove();
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
}
};
final TransactionContext txContext = sleeContainer
.getTransactionManager().getTransactionContext();
txContext.getAfterRollbackActions().add(action);
// register notification sources for all sbbs
//
final TraceManagement traceMBeanImpl = sleeContainer
.getTraceManagement();
for (final SbbID sbbID : serviceComponent
.getSbbIDs(componentRepositoryImpl)) {
// Tracer must be available for both 1.1 and 1.0 sbb components
// SbbComponent sbbComponent =
// componentRepositoryImpl.getComponentByID(sbbID);
// if(sbbComponent.isSlee11())
{
traceMBeanImpl.registerNotificationSource(new SbbNotification(
serviceComponent.getServiceID(), sbbID));
// add rollback action to remove state created
action = new TransactionalAction() {
public void execute() {
// remove notification sources for all sbbs
traceMBeanImpl
.deregisterNotificationSource(new SbbNotification(
serviceComponent.getServiceID(), sbbID));
}
};
txContext.getAfterRollbackActions().add(action);
}
// this might be used not only by 1.1 sbbs...
NotificationSourceWrapperImpl sbbMNotificationSource = new NotificationSourceWrapperImpl(
new SbbNotification(serviceComponent.getServiceID(), sbbID));
serviceComponent.getAlarmNotificationSources().putIfAbsent(sbbID,
sbbMNotificationSource);
}
sleeContainer.getSbbManagement().serviceInstall(serviceComponent);
}
|
java
|
{
"resource": ""
}
|
q177056
|
ServiceManagementImpl.uninstallService
|
test
|
public void uninstallService(final ServiceComponent serviceComponent)
throws SystemException, UnrecognizedServiceException,
InstanceNotFoundException, MBeanRegistrationException,
NullPointerException, UnrecognizedResourceAdaptorEntityException,
ManagementException, InvalidStateException {
if (logger.isDebugEnabled()) {
logger.debug("Uninstalling service with id "
+ serviceComponent.getServiceID());
}
if (serviceComponent.getServiceState().isStopping()) {
// let's be friendly and give it a few secs
for (int i = 0; i < 15; i++) {
try {
Thread.sleep(1000);
logger.info("Waiting for "
+ serviceComponent.getServiceID()
+ " to stop, current state is "
+ serviceComponent.getServiceState());
if (serviceComponent.getServiceState().isInactive()) {
break;
}
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
}
}
if (!serviceComponent.getServiceState().isInactive()) {
throw new InvalidStateException(serviceComponent.toString()
+ " is not inactive");
}
final TransactionContext txContext = sleeContainer
.getTransactionManager().getTransactionContext();
if (logger.isDebugEnabled()) {
logger.debug("Closing Usage MBean of service "
+ serviceComponent.getServiceID());
}
ServiceUsageMBean serviceUsageMBean = serviceComponent.getServiceUsageMBean();
if (serviceUsageMBean != null) {
serviceUsageMBean.remove();
// add rollback action to re-create the mbean
// FIXME this doesn't make sense, this restore looses all old data,
// it shoudl only remove on
// commit but as it is right now, the needed sbb components are
// already removed
TransactionalAction action = new TransactionalAction() {
public void execute() {
try {
sleeContainer.getUsageParametersManagement()
.newServiceUsageMBean(serviceComponent);
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
}
};
txContext.getAfterRollbackActions().add(action);
}
// register notification sources for all sbbs
final TraceManagement traceMBeanImpl = sleeContainer
.getTraceManagement();
for (final SbbID sbbID : serviceComponent
.getSbbIDs(componentRepositoryImpl)) {
// Tracer must be available for both 1.1 and 1.0 sbb components
// SbbComponent sbbComponent =
// componentRepositoryImpl.getComponentByID(sbbID);
// if(sbbComponent.isSlee11())
{
traceMBeanImpl
.deregisterNotificationSource(new SbbNotification(
serviceComponent.getServiceID(), sbbID));
// add rollback action to re-add state removed
TransactionalAction action = new TransactionalAction() {
public void execute() {
// remove notification sources for all sbbs
traceMBeanImpl
.registerNotificationSource(new SbbNotification(
serviceComponent.getServiceID(), sbbID));
}
};
txContext.getAfterRollbackActions().add(action);
}
}
// warn sbb management that the service is being uninstalled, giving it
// the option to clear any related resources
sleeContainer.getSbbManagement().serviceUninstall(serviceComponent);
}
|
java
|
{
"resource": ""
}
|
q177057
|
ServiceManagementImpl.isRAEntityLinkNameReferenced
|
test
|
public boolean isRAEntityLinkNameReferenced(String raLinkName) {
if (raLinkName == null) {
throw new NullPointerException("null ra link name");
}
boolean b = false;
try {
b = transactionManager.requireTransaction();
for (ServiceID serviceID : componentRepositoryImpl.getServiceIDs()) {
ServiceComponent serviceComponent = componentRepositoryImpl
.getComponentByID(serviceID);
if (serviceComponent.getServiceState() != ServiceState.INACTIVE
&& serviceComponent.getResourceAdaptorEntityLinks(
componentRepositoryImpl).contains(raLinkName)) {
return true;
}
}
return false;
} finally {
try {
transactionManager.requireTransactionEnd(b, false);
} catch (Throwable ex) {
throw new SLEEException(ex.getMessage(), ex);
}
}
}
|
java
|
{
"resource": ""
}
|
q177058
|
ServiceUsageMBeanImpl.getUsageParameterSets
|
test
|
public synchronized String[] getUsageParameterSets(SbbID sbbId)
throws NullPointerException, UnrecognizedSbbException,
InvalidArgumentException, ManagementException {
if (sbbId == null)
throw new NullPointerException("Sbb ID is null!");
// get the sbb component
SbbComponent sbbComponent = sleeContainer.getComponentRepository()
.getComponentByID(sbbId);
if (sbbComponent == null) {
throw new UnrecognizedSbbException(sbbId.toString());
} else {
if (sbbComponent.getUsageParametersInterface() == null) {
throw new InvalidArgumentException(
"no usage parameter interface for " + sbbId);
}
}
// get service component and check if the sbb belongs to the service
ServiceComponent serviceComponent = sleeContainer
.getComponentRepository().getComponentByID(getService());
if (!serviceComponent.getSbbIDs(
sleeContainer.getComponentRepository()).contains(sbbId)) {
throw new UnrecognizedSbbException(sbbId.toString()
+ " is not part of " + getService());
}
Set<String> resultSet = new HashSet<String>();
for (UsageMBeanImpl usageMBeanImpl : usageMBeans.values()) {
if (((SbbNotification) usageMBeanImpl.getNotificationSource())
.getSbb().equals(sbbId)) {
String name = usageMBeanImpl.getUsageParameterSet();
if (name != null) {
resultSet.add(name);
}
}
}
return resultSet.toArray(new String[resultSet.size()]);
}
|
java
|
{
"resource": ""
}
|
q177059
|
ServiceUsageMBeanImpl.resetAllUsageParameters
|
test
|
public synchronized void resetAllUsageParameters()
throws ManagementException {
try {
//FIXME: hmm, how to check here for clustered... ghmp
for (UsageMBeanImpl usageMBeanImpl : usageMBeans.values()) {
usageMBeanImpl.resetAllUsageParameters();
}
} catch (Throwable e) {
throw new ManagementException(e.getMessage(), e);
}
}
|
java
|
{
"resource": ""
}
|
q177060
|
ProfileFacilityImpl.getProfiles
|
test
|
public Collection<ProfileID> getProfiles(String profileTableName)
throws NullPointerException, UnrecognizedProfileTableNameException,
TransactionRolledbackLocalException, FacilityException {
if (logger.isTraceEnabled()) {
logger.trace("getProfiles( profileTableName = "
+ profileTableName + " )");
}
profileManagement.getSleeContainer().getTransactionManager().mandateTransaction();
try {
return profileManagement.getProfileTable(
profileTableName).getProfiles();
} catch (NullPointerException e) {
throw e;
} catch (UnrecognizedProfileTableNameException e) {
throw e;
} catch (Throwable e) {
throw new FacilityException(e.getMessage(), e);
}
}
|
java
|
{
"resource": ""
}
|
q177061
|
ProfileFacilityImpl.getProfileTableActivity
|
test
|
public ProfileTableActivity getProfileTableActivity(String profileTableName)
throws NullPointerException, UnrecognizedProfileTableNameException,
TransactionRolledbackLocalException, FacilityException {
if (logger.isTraceEnabled()) {
logger.trace("getProfileTableActivity( profileTableName = "
+ profileTableName + " )");
}
final SleeTransactionManager sleeTransactionManager = profileManagement.getSleeContainer()
.getTransactionManager();
boolean terminateTx = sleeTransactionManager.requireTransaction();
try {
return profileManagement.getProfileTable(profileTableName).getActivity();
} catch (NullPointerException e) {
throw e;
} catch (UnrecognizedProfileTableNameException e) {
throw e;
} catch (Throwable e) {
throw new FacilityException("Failed to obtain profile table.", e);
} finally {
// never rollback
try {
sleeTransactionManager.requireTransactionEnd(terminateTx,false);
} catch (Throwable e) {
throw new FacilityException(e.getMessage(),e);
}
}
}
|
java
|
{
"resource": ""
}
|
q177062
|
ProfileFacilityImpl.getProfileByIndexedAttribute
|
test
|
public ProfileID getProfileByIndexedAttribute(
java.lang.String profileTableName, java.lang.String attributeName,
java.lang.Object attributeValue) throws NullPointerException,
UnrecognizedProfileTableNameException,
UnrecognizedAttributeException, AttributeNotIndexedException,
AttributeTypeMismatchException,
TransactionRolledbackLocalException, FacilityException {
if (logger.isTraceEnabled()) {
logger.trace("getProfileByIndexedAttribute( profileTableName = "
+ profileTableName + " , attributeName = " + attributeName
+ " , attributeValue = " + attributeValue + " )");
}
profileManagement.getSleeContainer().getTransactionManager().mandateTransaction();
try {
ProfileTableImpl profileTable = profileManagement.getProfileTable(
profileTableName);
if (profileTable.getProfileSpecificationComponent().isSlee11()) {
throw new FacilityException(
"JAIN SLEE 1.1 Specs forbidden the usage of this method on SLEE 1.1 Profile Tables");
}
Collection<ProfileID> profileIDs = profileTable.getProfilesByAttribute(attributeName,attributeValue,false);
if (profileIDs.isEmpty()) {
return null;
}
else {
return profileIDs.iterator().next();
}
} catch (NullPointerException e) {
throw e;
} catch (UnrecognizedProfileTableNameException e) {
throw e;
} catch (UnrecognizedAttributeException e) {
throw e;
} catch (AttributeNotIndexedException e) {
throw e;
} catch (AttributeTypeMismatchException e) {
throw e;
} catch (Throwable e) {
throw new FacilityException(e.getMessage(), e);
}
}
|
java
|
{
"resource": ""
}
|
q177063
|
AbstractOperation.displayResult
|
test
|
public void displayResult() {
//default impl of display;
if (!context.isQuiet()) {
// Translate the result to text
String resultText = prepareResultText();
// render results to out
PrintWriter out = context.getWriter();
out.println(resultText);
out.flush();
}
}
|
java
|
{
"resource": ""
}
|
q177064
|
AbstractOperation.unfoldArray
|
test
|
protected String unfoldArray(String prefix, Object[] array, PropertyEditor editor)
{
//StringBuffer sb = new StringBuffer("\n");
StringBuffer sb = new StringBuffer("[");
for (int index = 0; index<array.length; index++) {
if (editor != null) {
editor.setValue(array[index]);
sb.append(editor.getAsText());
} else {
sb.append(array[index].toString());
}
if (index < array.length-1) {
sb.append(CID_SEPARATOR);
//sb.append("\n");
}
}
sb.append("]");
return sb.toString();
}
|
java
|
{
"resource": ""
}
|
q177065
|
SleeEndpointFireEventNotTransactedExecutor.execute
|
test
|
void execute(final ActivityHandle realHandle, final ActivityHandle refHandle,
final FireableEventType eventType, final Object event,
final Address address, final ReceivableService receivableService,
final int eventFlags) throws ActivityIsEndingException,
FireEventException, SLEEException,
UnrecognizedActivityHandleException {
final SleeTransaction tx = super.suspendTransaction();
try {
sleeEndpoint._fireEvent(realHandle, refHandle, eventType, event, address,
receivableService, eventFlags,tx);
} finally {
if (tx != null) {
super.resumeTransaction(tx);
}
}
}
|
java
|
{
"resource": ""
}
|
q177066
|
ActivityContextNamingFacilityCacheData.bindName
|
test
|
public void bindName(Object ach, String name)
throws NameAlreadyBoundException {
final Node node = getNode();
if (node.hasChild(name)) {
throw new NameAlreadyBoundException("name already bound");
} else {
node.addChild(Fqn.fromElements(name)).put(CACHE_NODE_MAP_KEY, ach);
}
}
|
java
|
{
"resource": ""
}
|
q177067
|
ActivityContextNamingFacilityCacheData.unbindName
|
test
|
public Object unbindName(String name) throws NameNotBoundException {
final Node node = getNode();
final Node childNode = node.getChild(name);
if (childNode == null) {
throw new NameNotBoundException("name not bound");
} else {
final Object ach = childNode.get(CACHE_NODE_MAP_KEY);
node.removeChild(name);
return ach;
}
}
|
java
|
{
"resource": ""
}
|
q177068
|
ActivityContextNamingFacilityCacheData.lookupName
|
test
|
public Object lookupName(String name) {
final Node childNode = getNode().getChild(name);
if (childNode == null) {
return null;
} else {
return childNode.get(CACHE_NODE_MAP_KEY);
}
}
|
java
|
{
"resource": ""
}
|
q177069
|
ActivityContextNamingFacilityCacheData.getNameBindings
|
test
|
public Map getNameBindings() {
Map result = new HashMap();
Node childNode = null;
Object name = null;
for (Object obj : getNode().getChildren()) {
childNode = (Node) obj;
name = childNode.getFqn().getLastElement();
result.put(name, childNode.get(CACHE_NODE_MAP_KEY));
}
return result;
}
|
java
|
{
"resource": ""
}
|
q177070
|
NextSbbEntityFinder.next
|
test
|
public Result next(ActivityContext ac,
EventContext sleeEvent, Set<SbbEntityID> sbbEntitiesThatHandledCurrentEvent, SleeContainer sleeContainer) {
SbbEntityID sbbEntityId = null;
SbbEntity sbbEntity = null;
EventEntryDescriptor mEventEntry = null;
// get the highest priority sbb from sbb entities attached to AC
for (Iterator<SbbEntityID> iter = ac.getSortedSbbAttachmentSet(sbbEntitiesThatHandledCurrentEvent).iterator(); iter
.hasNext();) {
sbbEntityId = iter.next();
sbbEntity = sleeContainer.getSbbEntityFactory().getSbbEntity(sbbEntityId,true);
if (sbbEntity == null) {
// ignore, sbb entity has been removed
continue;
}
if (eventRouterConfiguration.isConfirmSbbEntityAttachement() && !sbbEntity.isAttached(ac.getActivityContextHandle())) {
// detached by a concurrent tx, see Issue 2313
continue;
}
if (sleeEvent.getService() != null && !sleeEvent.getService().equals(sbbEntityId.getServiceID())) {
if (!sleeEvent.isActivityEndEvent()) {
continue;
}
else {
return new Result(sbbEntity, false);
}
}
// check event is allowed to be handled by the sbb
mEventEntry = sbbEntity.getSbbComponent().getDescriptor().getEventEntries().get(sleeEvent.getEventTypeId());
if (mEventEntry != null && mEventEntry.isReceived()) {
return new Result(sbbEntity, true);
} else {
if (!sleeEvent.isActivityEndEvent()) {
if (logger.isDebugEnabled()) {
logger
.debug("Event is not received by sbb descriptor of entity "
+ sbbEntityId + ", will not deliver event to sbb entity ...");
}
continue;
}
else {
return new Result(sbbEntity, false);
}
}
}
return null;
}
|
java
|
{
"resource": ""
}
|
q177071
|
TraceLevel.isHigherLevel
|
test
|
public boolean isHigherLevel(TraceLevel other) throws NullPointerException {
if (other == null) throw new NullPointerException("other is null");
return this.level < other.level;
}
|
java
|
{
"resource": ""
}
|
q177072
|
DeployableUnitJarComponentBuilder.extractJar
|
test
|
private void extractJar(JarFile jarFile, File dstDir)
throws DeploymentException {
// Extract jar contents to a classpath location
JarInputStream jarIs = null;
try {
jarIs = new JarInputStream(new BufferedInputStream(
new FileInputStream(jarFile.getName())));
for (JarEntry entry = jarIs.getNextJarEntry(); jarIs.available() > 0
&& entry != null; entry = jarIs.getNextJarEntry()) {
logger.trace("jar entry = " + entry.getName());
if (entry.isDirectory()) {
// Create jar directories.
File dir = new File(dstDir, entry.getName());
if (!dir.exists()) {
if (!dir.mkdirs()) {
logger.debug("Failed to create directory "
+ dir.getAbsolutePath());
throw new IOException("Failed to create directory "
+ dir.getAbsolutePath());
}
} else
logger.trace("Created directory"
+ dir.getAbsolutePath());
} else // unzip files
{
File file = new File(dstDir, entry.getName());
File dir = file.getParentFile();
if (!dir.exists()) {
if (!dir.mkdirs()) {
logger.debug("Failed to create directory "
+ dir.getAbsolutePath());
throw new IOException("Failed to create directory "
+ dir.getAbsolutePath());
} else
logger.trace("Created directory"
+ dir.getAbsolutePath());
}
pipeStream(jarFile.getInputStream(entry),
new FileOutputStream(file));
}
}
} catch (Exception e) {
throw new DeploymentException("failed to extract jar file "
+ jarFile.getName());
} finally {
if (jarIs != null) {
try {
jarIs.close();
} catch (IOException e) {
logger.error("failed to close jar input stream", e);
}
}
}
}
|
java
|
{
"resource": ""
}
|
q177073
|
DeployableUnitJarComponentBuilder.pipeStream
|
test
|
private void pipeStream(InputStream is, OutputStream os) throws IOException {
synchronized (buffer) {
try {
for (int bytesRead = is.read(buffer); bytesRead != -1; bytesRead = is
.read(buffer))
os.write(buffer, 0, bytesRead);
is.close();
os.close();
} catch (IOException ioe) {
try {
is.close();
} catch (Exception ioexc) {/* do sth? */
}
try {
os.close();
} catch (Exception ioexc) {/* do sth? */
}
throw ioe;
}
}
}
|
java
|
{
"resource": ""
}
|
q177074
|
ActivityContextCacheData.putObject
|
test
|
@SuppressWarnings("unchecked")
public Object putObject(Object key, Object value) {
return getNode().put(key, value);
}
|
java
|
{
"resource": ""
}
|
q177075
|
ActivityContextCacheData.attachSbbEntity
|
test
|
public boolean attachSbbEntity(SbbEntityID sbbEntityId) {
final Node node = getAttachedSbbsNode(true);
if (!node.hasChild(sbbEntityId)) {
node.addChild(Fqn.fromElements(sbbEntityId));
return true;
} else {
return false;
}
}
|
java
|
{
"resource": ""
}
|
q177076
|
ActivityContextCacheData.detachSbbEntity
|
test
|
public boolean detachSbbEntity(SbbEntityID sbbEntityId) {
final Node node = getAttachedSbbsNode(false);
return node != null ? node.removeChild(sbbEntityId) : false;
}
|
java
|
{
"resource": ""
}
|
q177077
|
ActivityContextCacheData.noSbbEntitiesAttached
|
test
|
public boolean noSbbEntitiesAttached() {
final Node node = getAttachedSbbsNode(false);
return node != null ? node.getChildrenNames().isEmpty() : true;
}
|
java
|
{
"resource": ""
}
|
q177078
|
ActivityContextCacheData.getSbbEntitiesAttached
|
test
|
@SuppressWarnings("unchecked")
public Set<SbbEntityID> getSbbEntitiesAttached() {
final Node node = getAttachedSbbsNode(false);
return node != null ? node.getChildrenNames() : Collections.emptySet();
}
|
java
|
{
"resource": ""
}
|
q177079
|
ActivityContextCacheData.attachTimer
|
test
|
public boolean attachTimer(TimerID timerID) {
final Node node = getAttachedTimersNode(true);
if (!node.hasChild(timerID)) {
node.addChild(Fqn.fromElements(timerID));
return true;
}
else {
return false;
}
}
|
java
|
{
"resource": ""
}
|
q177080
|
ActivityContextCacheData.detachTimer
|
test
|
public boolean detachTimer(TimerID timerID) {
final Node node = getAttachedTimersNode(false);
return node != null ? node.removeChild(timerID) : false;
}
|
java
|
{
"resource": ""
}
|
q177081
|
ActivityContextCacheData.noTimersAttached
|
test
|
public boolean noTimersAttached() {
final Node node = getAttachedTimersNode(false);
return node != null ? node.getChildrenNames().isEmpty() : true;
}
|
java
|
{
"resource": ""
}
|
q177082
|
ActivityContextCacheData.getAttachedTimers
|
test
|
public Set getAttachedTimers() {
final Node node = getAttachedTimersNode(false);
return node != null ? node.getChildrenNames() : Collections.emptySet();
}
|
java
|
{
"resource": ""
}
|
q177083
|
ActivityContextCacheData.nameBound
|
test
|
public void nameBound(String name) {
final Node node = getNamesBoundNode(true);
if (!node.hasChild(name)) {
node.addChild(Fqn.fromElements(name));
}
}
|
java
|
{
"resource": ""
}
|
q177084
|
ActivityContextCacheData.nameUnbound
|
test
|
public boolean nameUnbound(String name) {
final Node node = getNamesBoundNode(false);
return node != null ? node.removeChild(name) : false;
}
|
java
|
{
"resource": ""
}
|
q177085
|
ActivityContextCacheData.noNamesBound
|
test
|
public boolean noNamesBound() {
final Node node = getNamesBoundNode(false);
return node != null ? node.getChildrenNames().isEmpty() : true;
}
|
java
|
{
"resource": ""
}
|
q177086
|
ActivityContextCacheData.getNamesBoundCopy
|
test
|
public Set getNamesBoundCopy() {
final Node node = getNamesBoundNode(false);
return node != null ? node.getChildrenNames() : Collections.emptySet();
}
|
java
|
{
"resource": ""
}
|
q177087
|
ActivityContextCacheData.setCmpAttribute
|
test
|
@SuppressWarnings("unchecked")
public void setCmpAttribute(String attrName, Object attrValue) {
final Node node = getCmpAttributesNode(true);
Node cmpNode = node.getChild(attrName);
if (cmpNode == null) {
cmpNode = node.addChild(Fqn.fromElements(attrName));
}
cmpNode.put(CMP_ATTRIBUTES_NODE_MAP_KEY, attrValue);
}
|
java
|
{
"resource": ""
}
|
q177088
|
ActivityContextCacheData.getCmpAttribute
|
test
|
@SuppressWarnings("unchecked")
public Object getCmpAttribute(String attrName) {
final Node node = getCmpAttributesNode(false);
if(node == null) {
return null;
}
else {
final Node cmpNode = node.getChild(attrName);
if (cmpNode != null) {
return cmpNode.get(CMP_ATTRIBUTES_NODE_MAP_KEY);
}
else {
return null;
}
}
}
|
java
|
{
"resource": ""
}
|
q177089
|
ActivityContextCacheData.getCmpAttributesCopy
|
test
|
@SuppressWarnings("unchecked")
public Map getCmpAttributesCopy() {
final Node node = getCmpAttributesNode(false);
if(node == null) {
return Collections.emptyMap();
}
else {
Map result = new HashMap();
Node cmpNode = null;
for (Object obj : node.getChildren()) {
cmpNode = (Node) obj;
result.put(cmpNode.getFqn().getLastElement(), cmpNode
.get(CMP_ATTRIBUTES_NODE_MAP_KEY));
}
return result;
}
}
|
java
|
{
"resource": ""
}
|
q177090
|
UsageMBeanImpl.initNotificationInfo
|
test
|
private static MBeanNotificationInfo[] initNotificationInfo() {
String[] notificationTypes = new String[] {
ProfileTableNotification.USAGE_NOTIFICATION_TYPE,
ResourceAdaptorEntityNotification.USAGE_NOTIFICATION_TYPE,
SbbNotification.USAGE_NOTIFICATION_TYPE,
SubsystemNotification.USAGE_NOTIFICATION_TYPE
};
return new MBeanNotificationInfo[] { new MBeanNotificationInfo(
notificationTypes, UsageNotification.class.getName(),
"JAIN SLEE 1.1 Usage MBean Notification") };
}
|
java
|
{
"resource": ""
}
|
q177091
|
UsageMBeanImpl.sendUsageNotification
|
test
|
public void sendUsageNotification(long value, long seqno,
String usageParameterSetName, String usageParameterName,
boolean isCounter) {
UsageNotificationManagerMBeanImpl notificationManager = parent
.getUsageNotificationManagerMBean(notificationSource);
if (notificationManager == null
|| notificationManager
.getNotificationsEnabled(usageParameterName)) {
// if the notification manager is null we consider the notification
// can be sent
UsageNotification notification = createUsageNotification(value,
seqno, usageParameterSetName, usageParameterName, isCounter);
for (ListenerFilterHandbackTriplet triplet : listeners.values()) {
if (triplet.notificationFilter == null
|| triplet.notificationFilter
.isNotificationEnabled(notification)) {
triplet.notificationListener.handleNotification(
notification, triplet.handbackObject);
}
}
}
}
|
java
|
{
"resource": ""
}
|
q177092
|
DeploymentManagerMBeanImpl.downloadRemoteDU
|
test
|
private File downloadRemoteDU(URL duURL, File deploymentRoot) throws Exception {
InputStream in = null;
OutputStream out = null;
try {
// Get the filename out of the URL
String filename = new File(duURL.getPath()).getName();
// Prepare for creating the file at deploy folder
File tempFile = new File(deploymentRoot, filename);
out = new BufferedOutputStream(new FileOutputStream(tempFile));
URLConnection conn = duURL.openConnection();
in = conn.getInputStream();
// Get the data
byte[] buffer = new byte[1024];
int numRead;
while ((numRead = in.read(buffer)) != -1) {
out.write(buffer, 0, numRead);
}
// Done! Successful.
return tempFile;
}
finally {
// Do the clean up.
try {
if (in != null) {
in.close();
in = null;
}
if (out != null) {
out.close();
out = null;
}
}
catch (IOException ioe) {
// Shouldn't happen, let's ignore.
}
}
}
|
java
|
{
"resource": ""
}
|
q177093
|
DeploymentManager.updateDeployedComponents
|
test
|
public void updateDeployedComponents() {
try {
// Get the SLEE Component Repo
ComponentRepository componentRepository = sleeContainerDeployer.getSleeContainer().getComponentRepository();
// First we'll put the components in a temp Collection
ConcurrentLinkedQueue<String> newDeployedComponents = new ConcurrentLinkedQueue<String>();
// Get the deployed Profile Specifications
for (ComponentID componentID: componentRepository.getProfileSpecificationIDs()) {
newDeployedComponents.add(componentID.toString());
}
// Get the deployed Event Types
for (ComponentID componentID: componentRepository.getEventComponentIDs()) {
newDeployedComponents.add(componentID.toString());
}
// Get the deployed Resource Adaptor Types
for (ComponentID componentID: componentRepository.getResourceAdaptorTypeIDs()) {
newDeployedComponents.add(componentID.toString());
}
// Get the deployed Resource Adaptors
for (ComponentID componentID: componentRepository.getResourceAdaptorIDs()) {
newDeployedComponents.add(componentID.toString());
}
// Get the deployed Service Building Blocks (SBBs)
for (ComponentID componentID: componentRepository.getSbbIDs()) {
newDeployedComponents.add(componentID.toString());
}
// Get the deployed Services
for (ComponentID componentID: componentRepository.getServiceIDs()) {
newDeployedComponents.add(componentID.toString());
}
// Get the deployed Libraries
for (ComponentID componentID: componentRepository.getLibraryIDs()) {
newDeployedComponents.add(componentID.toString());
}
ResourceManagement resourceManagement = sleeContainerDeployer.getSleeContainer().getResourceManagement();
// Get the existing Resource Adaptor Entity links
String[] entityNames = resourceManagement.getResourceAdaptorEntities();
for (String entityName : entityNames) {
newDeployedComponents.addAll(Arrays.asList(resourceManagement.getLinkNames(entityName)));
}
// All good.. Make the temp the good one.
deployedComponents = newDeployedComponents;
}
catch (Exception e) {
logger.warn("Failure while updating deployed components.", e);
}
}
|
java
|
{
"resource": ""
}
|
q177094
|
DeploymentManager.installDeployableUnit
|
test
|
public void installDeployableUnit(DeployableUnit du) throws Exception {
// Update the deployed components from SLEE
updateDeployedComponents();
// Check if the DU is ready to be installed
if (du.isReadyToInstall(true)) {
// Get and Run the actions needed for installing this DU
sciAction(du.getInstallActions(), du);
// Set the DU as installed
du.setInstalled(true);
// Add the DU to the installed list
deployedDUs.add(du);
// Update the deployed components from SLEE
updateDeployedComponents();
// Go through the remaining DUs waiting for installation
Iterator<DeployableUnit> duIt = waitingForInstallDUs.iterator();
while (duIt.hasNext()) {
DeployableUnit waitingDU = duIt.next();
// If it is ready for installation, follow the same procedure
if (waitingDU.isReadyToInstall(false)) {
// Get and Run the actions needed for installing this DU
sciAction(waitingDU.getInstallActions(), waitingDU);
// Set the DU as installed
waitingDU.setInstalled(true);
// Add the DU to the installed list
deployedDUs.add(waitingDU);
// Update the deployed components from SLEE
updateDeployedComponents();
// Remove the DU from the waiting list.
waitingForInstallDUs.remove(waitingDU);
// Let's start all over.. :)
duIt = waitingForInstallDUs.iterator();
}
}
}
else {
logger.warn("Unable to INSTALL " + du.getDeploymentInfoShortName() + " right now. Waiting for dependencies to be resolved.");
// The DU can't be installed now, let's wait...
waitingForInstallDUs.add(du);
}
}
|
java
|
{
"resource": ""
}
|
q177095
|
DeploymentManager.uninstallDeployableUnit
|
test
|
public void uninstallDeployableUnit(DeployableUnit du) throws Exception {
// Update the deployed components from SLEE
updateDeployedComponents();
// It isn't installed?
if (!du.isInstalled()) {
// Then it should be in the waiting list... remove and we're done.
if (waitingForInstallDUs.remove(du)) {
logger.info(du.getDeploymentInfoShortName() + " wasn't deployed. Removing from waiting list.");
}
}
// Check if DU components are still present
else if (!du.areComponentsStillPresent()) {
logger.info(du.getDeploymentInfoShortName() + " components already removed. Removing DU info.");
// Process internals of undeployment...
processInternalUndeploy(du);
}
// Check if the DU is ready to be uninstalled
else if (du.isReadyToUninstall()) {
// Get and Run the actions needed for uninstalling this DU
sciAction(du.getUninstallActions(), du);
// Process internals of undeployment...
processInternalUndeploy(du);
}
else {
// Have we been her already? If so, don't flood user with log messages...
if (!waitingForUninstallDUs.contains(du)) {
// Add it to the waiting list.
waitingForUninstallDUs.add(du);
logger.warn("Unable to UNINSTALL " + du.getDeploymentInfoShortName() + " right now. Waiting for dependents to be removed.");
}
throw new DependencyException("Unable to undeploy "+du.getDeploymentInfoShortName());
}
}
|
java
|
{
"resource": ""
}
|
q177096
|
DeploymentManager.processInternalUndeploy
|
test
|
private void processInternalUndeploy(DeployableUnit du) throws Exception {
// Set the DU as not installed
du.setInstalled(false);
// Remove if it was present in waiting list
waitingForUninstallDUs.remove(du);
// Update the deployed components from SLEE
updateDeployedComponents();
// Go through the remaining DUs waiting for uninstallation
Iterator<DeployableUnit> duIt = waitingForUninstallDUs.iterator();
while (duIt.hasNext()) {
DeployableUnit waitingDU = duIt.next();
// If it is ready for being uninstalled, follow the same procedure
if (waitingDU.isReadyToUninstall()) {
// Schedule removal
sleeContainerDeployer.getSleeSubDeployer().stop(waitingDU.getURL(), waitingDU.getDeploymentInfoShortName());
// Remove the DU from the waiting list. If it fails, will go back.
waitingForUninstallDUs.remove(waitingDU);
// Let's start all over.. :)
duIt = waitingForUninstallDUs.iterator();
}
}
}
|
java
|
{
"resource": ""
}
|
q177097
|
DeploymentManager.showStatus
|
test
|
public String showStatus() {
// Update the currently deployed components.
updateDeployedComponents();
String output = "";
output += "<p>Deployable Units Waiting For Install:</p>";
for (DeployableUnit waitingDU : waitingForInstallDUs) {
output += "+-- " + waitingDU.getDeploymentInfoShortName() + "<br>";
for (String dependency : waitingDU.getExternalDependencies()) {
if (!deployedComponents.contains(dependency))
dependency += " <strong>MISSING!</strong>";
output += " +-- depends on " + dependency + "<br>";
}
}
output += "<p>Deployable Units Waiting For Uninstall:</p>";
for (DeployableUnit waitingDU : waitingForUninstallDUs) {
output += "+-- " + waitingDU.getDeploymentInfoShortName() + "<br>";
}
return output;
}
|
java
|
{
"resource": ""
}
|
q177098
|
MobicentsLogFilter.isLoggable
|
test
|
public boolean isLoggable(LogRecord record)
{
Logger logger = getLogger(record);
if (record.getThrown() != null)
{
logWithThrowable(logger, record);
}
else
{
logWithoutThrowable(logger, record);
}
return false;
}
|
java
|
{
"resource": ""
}
|
q177099
|
MobicentsLogFilter.getLogger
|
test
|
private Logger getLogger(LogRecord record)
{
String loggerName = record.getLoggerName();
Logger logger = loggerCache.get(loggerName);
if (logger == null)
{
logger = Logger.getLogger(loggerName);
loggerCache.put(loggerName, logger);
}
return logger;
}
|
java
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.