repo
stringlengths
1
191
file
stringlengths
23
351
code
stringlengths
0
5.32M
file_length
int64
0
5.32M
avg_line_length
float64
0
2.9k
max_line_length
int64
0
288k
extension_type
stringclasses
1 value
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/annotated/slim/backed/BackedAnnotatedTypeMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.annotated.slim.backed; import org.jboss.weld.annotated.slim.AnnotatedTypeIdentifier; import org.jboss.weld.annotated.slim.backed.BackedAnnotatedType; import org.jboss.weld.manager.BeanManagerImpl; import org.jboss.weld.resources.ClassTransformer; import org.jboss.weld.resources.spi.ResourceLoader; import org.wildfly.clustering.weld.annotated.slim.AnnotatedTypeMarshaller; /** * Validates marshalling of {@link BackedAnnotatedType}. * @author Paul Ferraro */ public class BackedAnnotatedTypeMarshaller<X> extends AnnotatedTypeMarshaller<X, BackedAnnotatedType<X>> { @SuppressWarnings("unchecked") public BackedAnnotatedTypeMarshaller() { super((Class<BackedAnnotatedType<X>>) (Class<?>) BackedAnnotatedType.class); } @Override protected BackedAnnotatedType<X> getAnnotatedType(AnnotatedTypeIdentifier identifier, BeanManagerImpl manager) { BackedAnnotatedType<X> result = super.getAnnotatedType(identifier, manager); // If type is not yet know, attempt to load it if (result == null) { @SuppressWarnings("unchecked") Class<X> targetClass = (Class<X>) manager.getServices().get(ResourceLoader.class).classForName(identifier.getClassName()); result = manager.getServices().get(ClassTransformer.class).getBackedAnnotatedType(targetClass, identifier.getBdaId()); } return result; } }
2,456
43.672727
134
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/annotated/slim/unbacked/UnbackedMemberIdentifierMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.annotated.slim.unbacked; import java.io.IOException; import org.infinispan.protostream.descriptors.WireType; import org.jboss.weld.annotated.slim.unbacked.UnbackedAnnotatedType; import org.jboss.weld.annotated.slim.unbacked.UnbackedMemberIdentifier; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; /** * Marshaller for a {@link UnbackedMemberIdentifier}. * @author Paul Ferraro */ public class UnbackedMemberIdentifierMarshaller<X> implements ProtoStreamMarshaller<UnbackedMemberIdentifier<X>> { private static final int TYPE_INDEX = 1; private static final int MEMBER_ID_INDEX = 2; @SuppressWarnings("unchecked") @Override public Class<? extends UnbackedMemberIdentifier<X>> getJavaClass() { return (Class<UnbackedMemberIdentifier<X>>) (Class<?>) UnbackedMemberIdentifier.class; } @Override public UnbackedMemberIdentifier<X> readFrom(ProtoStreamReader reader) throws IOException { String memberId = null; UnbackedAnnotatedType<X> type = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case TYPE_INDEX: type = reader.readObject(UnbackedAnnotatedType.class); break; case MEMBER_ID_INDEX: memberId = reader.readString(); break; default: reader.skipField(tag); } } return new UnbackedMemberIdentifier<>(type, memberId); } @Override public void writeTo(ProtoStreamWriter writer, UnbackedMemberIdentifier<X> identifier) throws IOException { UnbackedAnnotatedType<X> type = identifier.getType(); if (type != null) { writer.writeObject(TYPE_INDEX, type); } String memberId = identifier.getMemberId(); if (memberId != null) { writer.writeString(MEMBER_ID_INDEX, memberId); } } }
3,225
39.325
114
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/annotated/slim/unbacked/UnbackedSlimAnnotatedMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.annotated.slim.unbacked; import org.jboss.weld.annotated.slim.unbacked.UnbackedAnnotatedConstructor; import org.jboss.weld.annotated.slim.unbacked.UnbackedAnnotatedField; import org.jboss.weld.annotated.slim.unbacked.UnbackedAnnotatedMethod; import org.jboss.weld.annotated.slim.unbacked.UnbackedAnnotatedParameter; import org.jboss.weld.annotated.slim.unbacked.UnbackedAnnotatedType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; import org.wildfly.clustering.weld.annotated.slim.AnnotatedConstructorMarshaller; import org.wildfly.clustering.weld.annotated.slim.AnnotatedFieldMarshaller; import org.wildfly.clustering.weld.annotated.slim.AnnotatedMethodMarshaller; import org.wildfly.clustering.weld.annotated.slim.AnnotatedParameterMarshaller; import org.wildfly.clustering.weld.annotated.slim.AnnotatedTypeMarshaller; /** * @author Paul Ferraro */ public enum UnbackedSlimAnnotatedMarshallerProvider implements ProtoStreamMarshallerProvider { CONSTRUCTOR(new AnnotatedConstructorMarshaller<>(UnbackedAnnotatedConstructor.class, UnbackedAnnotatedType.class)), FIELD(new AnnotatedFieldMarshaller<>(UnbackedAnnotatedField.class, UnbackedAnnotatedType.class)), METHOD(new AnnotatedMethodMarshaller<>(UnbackedAnnotatedMethod.class, UnbackedAnnotatedType.class)), PARAMETER(new AnnotatedParameterMarshaller<>(UnbackedAnnotatedParameter.class, UnbackedAnnotatedConstructor.class, UnbackedAnnotatedMethod.class)), TYPE(new AnnotatedTypeMarshaller<>(UnbackedAnnotatedType.class)), IDENTIFIER(new UnbackedMemberIdentifierMarshaller<>()), ; private final ProtoStreamMarshaller<?> marshaller; UnbackedSlimAnnotatedMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
3,034
48.754098
151
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/bean/BeanMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.bean; import org.jboss.weld.annotated.slim.AnnotatedTypeIdentifier; import org.jboss.weld.bean.ManagedBeanIdentifier; import org.jboss.weld.bean.StringBeanIdentifier; import org.wildfly.clustering.marshalling.protostream.FunctionalScalarMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; import org.wildfly.clustering.marshalling.protostream.Scalar; import org.wildfly.clustering.marshalling.protostream.reflect.UnaryFieldMarshaller; /** * @author Paul Ferraro */ public enum BeanMarshallerProvider implements ProtoStreamMarshallerProvider { MANAGED_BEAN_IDENTIFIER(new UnaryFieldMarshaller<>(ManagedBeanIdentifier.class, AnnotatedTypeIdentifier.class, ManagedBeanIdentifier::new)), STRING_BEAN_IDENTIFIER(new FunctionalScalarMarshaller<>(StringBeanIdentifier.class, Scalar.STRING.cast(String.class), StringBeanIdentifier::asString, StringBeanIdentifier::new)), ; private final ProtoStreamMarshaller<?> marshaller; BeanMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
2,339
43.150943
182
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/bean/builtin/BuiltinBeanMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.bean.builtin; import jakarta.enterprise.context.spi.CreationalContext; import jakarta.enterprise.inject.spi.InjectionPoint; import org.jboss.weld.bean.builtin.InstanceImpl; import org.jboss.weld.manager.BeanManagerImpl; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; import org.wildfly.clustering.marshalling.protostream.reflect.TernaryMethodMarshaller; /** * @author Paul Ferraro */ public enum BuiltinBeanMarshallerProvider implements ProtoStreamMarshallerProvider { @SuppressWarnings("unchecked") INSTANCE_IMPL(new TernaryMethodMarshaller<>(InstanceImpl.class, InjectionPoint.class, CreationalContext.class, BeanManagerImpl.class, (injectionPoint, context, manager) -> InstanceImpl.of(injectionPoint, context, manager))), ; private final ProtoStreamMarshaller<?> marshaller; BuiltinBeanMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
2,202
40.566038
228
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/bean/proxy/ProxyBeanMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.bean.proxy; import jakarta.enterprise.inject.spi.Bean; import org.jboss.weld.Container; import org.jboss.weld.bean.proxy.BeanInstance; import org.jboss.weld.bean.proxy.ContextBeanInstance; import org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance; import org.jboss.weld.bean.proxy.MethodHandler; import org.jboss.weld.bean.proxy.ProxyMethodHandler; import org.jboss.weld.serialization.spi.BeanIdentifier; import org.jboss.weld.serialization.spi.ContextualStore; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; import org.wildfly.clustering.marshalling.protostream.reflect.BinaryFieldMarshaller; import org.wildfly.clustering.marshalling.protostream.reflect.TernaryFieldMarshaller; /** * @author Paul Ferraro */ public enum ProxyBeanMarshallerProvider implements ProtoStreamMarshallerProvider { COMBINED_INTERCEPTOR_DECORATOR_STACK_METHOD_HANDLER(new CombinedInterceptorAndDecoratorStackMethodHandlerMarshaller()), CONTEXT_BEAN_INSTANCE(new BinaryFieldMarshaller<>(ContextBeanInstance.class, String.class, BeanIdentifier.class, (contextId, id) -> new ContextBeanInstance<>(Container.instance(contextId).services().get(ContextualStore.class).<Bean<Object>, Object>getContextual(id), id, contextId))), DECORATOR_PROXY_METHOD_HANDLER(new DecoratorProxyMethodHandlerMarshaller()), ENTERPRISE_TARGET_BEAN_INSTANCE(new BinaryFieldMarshaller<>(EnterpriseTargetBeanInstance.class, Class.class, MethodHandler.class, EnterpriseTargetBeanInstance::new)), PROXY_METHOD_HANDLER(new TernaryFieldMarshaller<>(ProxyMethodHandler.class, String.class, BeanInstance.class, BeanIdentifier.class, (contextId, instance, beanId) -> new ProxyMethodHandler(contextId, instance, Container.instance(contextId).services().get(ContextualStore.class).<Bean<Object>, Object>getContextual(beanId)))), TARGET_BEAN_INSTANCE(new TargetBeanInstanceMarshaller()), ; private final ProtoStreamMarshaller<?> marshaller; ProxyBeanMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
3,320
51.714286
328
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/bean/proxy/MockBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.bean.proxy; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.Set; import jakarta.enterprise.context.spi.CreationalContext; import jakarta.enterprise.inject.spi.Bean; import jakarta.enterprise.inject.spi.InjectionPoint; /** * {@link Bean} instance for use with {@link org.jboss.weld.bean.proxy.TargetBeanInstance#TargetBeanInstance(Bean, Object)} constructor. * @author Paul Ferraro */ public class MockBean<T> implements Bean<T> { private final Type type; public MockBean(Type type) { this.type = type; } @Override public T create(CreationalContext<T> creationalContext) { return null; } @Override public void destroy(T instance, CreationalContext<T> creationalContext) { } @Override public Set<Type> getTypes() { return Set.of(this.type); } @Override public Set<Annotation> getQualifiers() { return null; } @Override public Class<? extends Annotation> getScope() { return null; } @Override public String getName() { return null; } @Override public Set<Class<? extends Annotation>> getStereotypes() { return null; } @Override public boolean isAlternative() { return false; } @Override public Class<?> getBeanClass() { return null; } @Override public Set<InjectionPoint> getInjectionPoints() { return null; } public boolean isNullable() { return false; } }
2,601
25.824742
136
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/bean/proxy/DecoratorProxyMethodHandlerMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.bean.proxy; import java.io.IOException; import java.lang.reflect.Field; import java.security.PrivilegedAction; import jakarta.enterprise.inject.spi.Decorator; import org.infinispan.protostream.descriptors.WireType; import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler; import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.security.manager.WildFlySecurityManager; /** * @author Paul Ferraro */ public class DecoratorProxyMethodHandlerMarshaller implements ProtoStreamMarshaller<DecoratorProxyMethodHandler> { static final Field DECORATOR_FIELD = WildFlySecurityManager.doUnchecked(new PrivilegedAction<>() { @Override public Field run() { for (Field field : DecoratorProxyMethodHandler.class.getDeclaredFields()) { if (field.getType() == SerializableContextualInstance.class) { field.setAccessible(true); return field; } } throw new IllegalArgumentException(SerializableContextualInstance.class.getName()); } }); private static final int DECORATOR_INDEX = 1; private static final int DELEGATE_INDEX = 2; @Override public Class<? extends DecoratorProxyMethodHandler> getJavaClass() { return DecoratorProxyMethodHandler.class; } @Override public DecoratorProxyMethodHandler readFrom(ProtoStreamReader reader) throws IOException { SerializableContextualInstance<Decorator<Object>, Object> decorator = null; Object delegate = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case DECORATOR_INDEX: decorator = reader.readAny(SerializableContextualInstance.class); break; case DELEGATE_INDEX: delegate = reader.readAny(); break; default: reader.skipField(tag); } } return new DecoratorProxyMethodHandler(decorator, delegate); } @Override public void writeTo(ProtoStreamWriter writer, DecoratorProxyMethodHandler handler) throws IOException { SerializableContextualInstance<Decorator<Object>, Object> decorator = WildFlySecurityManager.doUnchecked(new PrivilegedAction<>() { @SuppressWarnings("unchecked") @Override public SerializableContextualInstance<Decorator<Object>, Object> run() { try { return (SerializableContextualInstance<Decorator<Object>, Object>) DECORATOR_FIELD.get(handler); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } } }); if (decorator != null) { writer.writeAny(DECORATOR_INDEX, decorator); } Object delegate = handler.getTargetInstance(); if (delegate != null) { writer.writeAny(DELEGATE_INDEX, delegate); } } }
4,391
40.828571
139
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/bean/proxy/TargetBeanInstanceMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.bean.proxy; import java.io.IOException; import org.infinispan.protostream.descriptors.WireType; import org.jboss.weld.bean.proxy.MethodHandler; import org.jboss.weld.bean.proxy.TargetBeanInstance; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; /** * @author Paul Ferraro */ public class TargetBeanInstanceMarshaller implements ProtoStreamMarshaller<TargetBeanInstance> { private static final int INSTANCE_INDEX = 1; private static final int TYPE_INDEX = 2; private static final int HANDLER_INDEX = 3; @Override public Class<? extends TargetBeanInstance> getJavaClass() { return TargetBeanInstance.class; } @Override public TargetBeanInstance readFrom(ProtoStreamReader reader) throws IOException { Object instance = null; Class<?> type = null; MethodHandler handler = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case INSTANCE_INDEX: instance = reader.readAny(); break; case TYPE_INDEX: type = reader.readObject(Class.class); break; case HANDLER_INDEX: handler = reader.readAny(MethodHandler.class); break; default: reader.skipField(tag); } } TargetBeanInstance result = (type != null) ? new TargetBeanInstance(new MockBean<>(type), instance) : new TargetBeanInstance(instance); result.setInterceptorsHandler(handler); return result; } @Override public void writeTo(ProtoStreamWriter writer, TargetBeanInstance source) throws IOException { Object instance = source.getInstance(); if (instance != null) { writer.writeAny(INSTANCE_INDEX, instance); } Class<?> type = source.getInstanceType(); if ((type != null) && (type != instance.getClass())) { writer.writeObject(TYPE_INDEX, type); } MethodHandler handler = source.getInterceptorsHandler(); if (handler != null) { writer.writeAny(HANDLER_INDEX, handler); } } }
3,487
37.755556
144
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/bean/proxy/CombinedInterceptorAndDecoratorStackMethodHandlerMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.bean.proxy; import java.io.IOException; import org.infinispan.protostream.descriptors.WireType; import org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler; import org.jboss.weld.interceptor.proxy.InterceptorMethodHandler; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; /** * @author Paul Ferraro */ public class CombinedInterceptorAndDecoratorStackMethodHandlerMarshaller implements ProtoStreamMarshaller<CombinedInterceptorAndDecoratorStackMethodHandler> { private static final int INTERCEPTOR_METHOD_HANDLER_INDEX = 1; private static final int OUTER_DECORATOR_INDEX = 2; @Override public Class<? extends CombinedInterceptorAndDecoratorStackMethodHandler> getJavaClass() { return CombinedInterceptorAndDecoratorStackMethodHandler.class; } @Override public CombinedInterceptorAndDecoratorStackMethodHandler readFrom(ProtoStreamReader reader) throws IOException { CombinedInterceptorAndDecoratorStackMethodHandler handler = new CombinedInterceptorAndDecoratorStackMethodHandler(); while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case INTERCEPTOR_METHOD_HANDLER_INDEX: handler.setInterceptorMethodHandler(reader.readObject(InterceptorMethodHandler.class)); break; case OUTER_DECORATOR_INDEX: handler.setOuterDecorator(reader.readAny()); break; default: reader.skipField(tag); } } return handler; } @Override public void writeTo(ProtoStreamWriter writer, CombinedInterceptorAndDecoratorStackMethodHandler handler) throws IOException { InterceptorMethodHandler interceptorHandler = handler.getInterceptorMethodHandler(); if (interceptorHandler != null) { writer.writeObject(INTERCEPTOR_METHOD_HANDLER_INDEX, interceptorHandler); } Object decorator = handler.getOuterDecorator(); if (decorator != null) { writer.writeAny(OUTER_DECORATOR_INDEX, decorator); } } }
3,417
42.820513
158
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/bean/proxy/util/UtilProxyBeanMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.bean.proxy.util; import org.jboss.weld.bean.proxy.util.SerializableClientProxy; import org.jboss.weld.serialization.spi.BeanIdentifier; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; import org.wildfly.clustering.marshalling.protostream.reflect.BinaryFieldMarshaller; /** * @author Paul Ferraro */ public enum UtilProxyBeanMarshallerProvider implements ProtoStreamMarshallerProvider { SERIALIZABLE_CLIENT_PROXY(new BinaryFieldMarshaller<>(SerializableClientProxy.class, BeanIdentifier.class, String.class, SerializableClientProxy::new)), ; private final ProtoStreamMarshaller<?> marshaller; UtilProxyBeanMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
2,012
40.081633
156
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/serialization/DistributedModuleServicesProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.serialization; import java.util.Collection; import java.util.Collections; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.module.ResourceRoot; import org.jboss.as.weld.spi.ModuleServicesProvider; import org.jboss.modules.Module; import org.jboss.weld.bootstrap.api.Service; import org.kohsuke.MetaInfServices; /** * @author Paul Ferraro */ @MetaInfServices(ModuleServicesProvider.class) public class DistributedModuleServicesProvider implements ModuleServicesProvider { @Override public Collection<Service> getServices(DeploymentUnit rootDeploymentUnit, DeploymentUnit deploymentUnit, Module module, ResourceRoot resourceRoot) { return Collections.singleton(new DistributedContextualStore(deploymentUnit.getName())); } }
1,851
39.26087
152
java
null
wildfly-main/clustering/weld/core/src/main/java/org/wildfly/clustering/weld/serialization/DistributedContextualStore.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.serialization; import jakarta.enterprise.context.spi.Contextual; import jakarta.enterprise.inject.spi.Bean; import jakarta.enterprise.inject.spi.PassivationCapable; import org.jboss.weld.serialization.ContextualStoreImpl; import org.jboss.weld.serialization.spi.helpers.SerializableContextual; import org.jboss.weld.util.reflection.Reflections; import org.wildfly.clustering.weld.contexts.PassivationCapableSerializableBean; import org.wildfly.clustering.weld.contexts.PassivationCapableSerializableContextual; /** * {@link org.jboss.weld.serialization.spi.ContextualStore} implementation for distributed applications. * @author Paul Ferraro */ public class DistributedContextualStore extends ContextualStoreImpl { private final String contextId; public DistributedContextualStore(String contextId) { super(contextId, null); this.contextId = contextId; } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public <C extends Contextual<I>, I> SerializableContextual<C, I> getSerializableContextual(Contextual<I> contextual) { if (contextual instanceof SerializableContextual<?, ?>) { return Reflections.cast(contextual); } if (contextual instanceof PassivationCapable) { return (contextual instanceof Bean) ? new PassivationCapableSerializableBean(this.contextId, Reflections.<Bean<I>>cast(contextual)) : new PassivationCapableSerializableContextual(this.contextId, contextual); } return super.getSerializableContextual(contextual); } }
2,619
42.666667
219
java
null
wildfly-main/clustering/weld/web/src/test/java/org/wildfly/clustering/weld/web/el/WeldMethodExpressionMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.web.el; import java.io.IOException; import java.util.ServiceLoader; import org.jboss.weld.module.web.el.WeldMethodExpression; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.el.MethodExpressionFactory; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Validates marshalling of a {@link WeldMethodExpression}. * @author Paul Ferraro */ public class WeldMethodExpressionMarshallerTestCase { private final MethodExpressionFactory factory = ServiceLoader.load(MethodExpressionFactory.class, MethodExpressionFactory.class.getClassLoader()).iterator().next(); @Test public void test() throws IOException { Tester<WeldMethodExpression> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new WeldMethodExpression(this.factory.createMethodExpression("foo", WeldMethodExpressionMarshallerTestCase.class, new Class<?>[0])), WeldMethodExpressionMarshallerTestCase::assertEquals); } static void assertEquals(WeldMethodExpression expression1, WeldMethodExpression expression2) { Assert.assertEquals(expression1.getExpressionString(), expression2.getExpressionString()); } }
2,313
42.660377
207
java
null
wildfly-main/clustering/weld/web/src/test/java/org/wildfly/clustering/weld/web/el/WeldValueExpressionMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.web.el; import java.io.IOException; import java.util.ServiceLoader; import org.jboss.weld.module.web.el.WeldValueExpression; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.el.ValueExpressionFactory; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Validates marshalling of a {@WeldValueExpression}. * @author Paul Ferraro */ public class WeldValueExpressionMarshallerTestCase { private final ValueExpressionFactory factory = ServiceLoader.load(ValueExpressionFactory.class, ValueExpressionFactory.class.getClassLoader()).iterator().next(); @Test public void test() throws IOException { Tester<WeldValueExpression> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new WeldValueExpression(this.factory.createValueExpression("foo", WeldValueExpressionMarshallerTestCase.class)), WeldValueExpressionMarshallerTestCase::assertEquals); } static void assertEquals(WeldValueExpression expression1, WeldValueExpression expression2) { Assert.assertEquals(expression1.getExpectedType(), expression2.getExpectedType()); Assert.assertEquals(expression1.getExpressionString(), expression2.getExpressionString()); } }
2,368
42.87037
186
java
null
wildfly-main/clustering/weld/web/src/main/java/org/wildfly/clustering/weld/web/WeldWebSerializationContextInitializerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.web; import org.infinispan.protostream.SerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.ProviderSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.SerializationContextInitializerProvider; import org.wildfly.clustering.weld.web.el.WebELMarshallerProvider; /** * @author Paul Ferraro */ public enum WeldWebSerializationContextInitializerProvider implements SerializationContextInitializerProvider { WEB_EL(new ProviderSerializationContextInitializer<>("org.jboss.weld.module.web.el.proto", WebELMarshallerProvider.class)) ; private final SerializationContextInitializer initializer; WeldWebSerializationContextInitializerProvider(SerializationContextInitializer initializer) { this.initializer = initializer; } @Override public SerializationContextInitializer getInitializer() { return this.initializer; } }
1,995
40.583333
126
java
null
wildfly-main/clustering/weld/web/src/main/java/org/wildfly/clustering/weld/web/WeldWebSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.web; import org.infinispan.protostream.SerializationContextInitializer; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.protostream.CompositeSerializationContextInitializer; /** * @author Paul Ferraro */ @MetaInfServices(SerializationContextInitializer.class) public class WeldWebSerializationContextInitializer extends CompositeSerializationContextInitializer { public WeldWebSerializationContextInitializer() { super(WeldWebSerializationContextInitializerProvider.class); } }
1,589
39.769231
102
java
null
wildfly-main/clustering/weld/web/src/main/java/org/wildfly/clustering/weld/web/el/WebELMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.web.el; import jakarta.el.MethodExpression; import jakarta.el.ValueExpression; import org.jboss.weld.module.web.el.WeldMethodExpression; import org.jboss.weld.module.web.el.WeldValueExpression; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; import org.wildfly.clustering.marshalling.protostream.reflect.DecoratorMarshaller; /** * @author Paul Ferraro */ public enum WebELMarshallerProvider implements ProtoStreamMarshallerProvider { METHOD_EXPRESSION(new DecoratorMarshaller<>(MethodExpression.class, WeldMethodExpression::new, null)), VALUE_EXPRESSION(new DecoratorMarshaller<>(ValueExpression.class, WeldValueExpression::new, null)), ; private final ProtoStreamMarshaller<?> marshaller; WebELMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
2,107
38.773585
106
java
null
wildfly-main/clustering/weld/ejb/src/test/java/org/wildfly/clustering/weld/ejb/SerializedStatefulSessionObjectMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb; import java.io.IOException; import java.util.Map; import java.util.UUID; import org.jboss.as.weld.ejb.SerializedStatefulSessionObject; import org.jboss.ejb.client.UUIDSessionID; import org.jboss.msc.service.ServiceName; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * @author Paul Ferraro */ public class SerializedStatefulSessionObjectMarshallerTestCase { @Test public void test() throws IOException { Tester<SerializedStatefulSessionObject> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new SerializedStatefulSessionObject(ServiceName.JBOSS.append("foo", "bar"), new UUIDSessionID(UUID.randomUUID()), Map.of(SerializedStatefulSessionObjectMarshallerTestCase.class, ServiceName.of("foo", "bar"))), SerializedStatefulSessionObjectMarshallerTestCase::assertEquals); } static void assertEquals(SerializedStatefulSessionObject object1, SerializedStatefulSessionObject object2) { Assert.assertEquals(object1.getComponentServiceName(), object2.getComponentServiceName()); Assert.assertEquals(object1.getServiceNames(), object2.getServiceNames()); Assert.assertEquals(object1.getSessionID(), object2.getSessionID()); } }
2,407
44.433962
295
java
null
wildfly-main/clustering/weld/ejb/src/test/java/org/wildfly/clustering/weld/ejb/component/stateful/StatefulSerializedProxyMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb.component.stateful; import java.io.IOException; import java.util.UUID; import org.jboss.as.ejb3.component.stateful.StatefulSerializedProxy; import org.jboss.ejb.client.UUIDSessionID; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * @author Paul Ferraro */ public class StatefulSerializedProxyMarshallerTestCase { @Test public void test() throws IOException { Tester<StatefulSerializedProxy> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new StatefulSerializedProxy("foo", new UUIDSessionID(UUID.randomUUID())), StatefulSerializedProxyMarshallerTestCase::assertEquals); } static void assertEquals(StatefulSerializedProxy proxy1, StatefulSerializedProxy proxy2) { Assert.assertEquals(proxy1.getSessionID(), proxy2.getSessionID()); Assert.assertEquals(proxy1.getViewName(), proxy2.getViewName()); } }
2,080
40.62
151
java
null
wildfly-main/clustering/weld/ejb/src/test/java/org/wildfly/clustering/weld/ejb/component/session/StatelessSerializedProxyMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb.component.session; import java.io.IOException; import org.jboss.as.ejb3.component.session.StatelessSerializedProxy; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * @author Paul Ferraro */ public class StatelessSerializedProxyMarshallerTestCase { @Test public void test() throws IOException { Tester<StatelessSerializedProxy> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new StatelessSerializedProxy("foo"), StatelessSerializedProxyMarshallerTestCase::assertEquals); } static void assertEquals(StatelessSerializedProxy proxy1, StatelessSerializedProxy proxy2) { Assert.assertEquals(proxy1.getViewName(), proxy2.getViewName()); } }
1,906
39.574468
115
java
null
wildfly-main/clustering/weld/ejb/src/main/java/org/wildfly/clustering/weld/ejb/SerializedStatefulSessionObjectMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.infinispan.protostream.descriptors.WireType; import org.jboss.as.weld.ejb.SerializedStatefulSessionObject; import org.jboss.ejb.client.SessionID; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; /** * @author Paul Ferraro */ public class SerializedStatefulSessionObjectMarshaller implements ProtoStreamMarshaller<SerializedStatefulSessionObject> { private static final int COMPONENT_SERVICE_NAME_INDEX = 1; private static final int SESSION_ID_INDEX = 2; private static final int VIEW_CLASS_INDEX = 3; private static final int VIEW_SERVICE_NAME_INDEX = 4; @Override public Class<? extends SerializedStatefulSessionObject> getJavaClass() { return SerializedStatefulSessionObject.class; } @Override public SerializedStatefulSessionObject readFrom(ProtoStreamReader reader) throws IOException { String componentServiceName = null; SessionID id = null; List<Class<?>> viewClasses = new LinkedList<>(); List<String> viewServiceNames = new LinkedList<>(); while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case COMPONENT_SERVICE_NAME_INDEX: componentServiceName = reader.readString(); break; case SESSION_ID_INDEX: id = reader.readObject(SessionID.class); break; case VIEW_CLASS_INDEX: viewClasses.add(reader.readObject(Class.class)); break; case VIEW_SERVICE_NAME_INDEX: viewServiceNames.add(reader.readString()); break; default: reader.skipField(tag); } } Map<Class<?>, String> views = new HashMap<>(); Iterator<Class<?>> classes = viewClasses.iterator(); Iterator<String> names = viewServiceNames.iterator(); while (classes.hasNext() && names.hasNext()) { views.put(classes.next(), names.next()); } return new SerializedStatefulSessionObject(componentServiceName, id, views); } @Override public void writeTo(ProtoStreamWriter writer, SerializedStatefulSessionObject object) throws IOException { String componentServiceName = object.getComponentServiceName(); if (componentServiceName != null) { writer.writeString(COMPONENT_SERVICE_NAME_INDEX, componentServiceName); } SessionID id = object.getSessionID(); if (id != null) { writer.writeObject(SESSION_ID_INDEX, id); } Map<Class<?>, String> views = object.getServiceNames(); for (Map.Entry<Class<?>, String> entry : views.entrySet()) { writer.writeObject(VIEW_CLASS_INDEX, entry.getKey()); writer.writeString(VIEW_SERVICE_NAME_INDEX, entry.getValue()); } } }
4,352
40.457143
122
java
null
wildfly-main/clustering/weld/ejb/src/main/java/org/wildfly/clustering/weld/ejb/WildFlyWeldEJBSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb; import org.infinispan.protostream.SerializationContext; import org.jboss.as.weld.ejb.StatefulSessionObjectReferenceImpl; import org.wildfly.clustering.marshalling.protostream.AbstractSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.reflect.ProxyMarshaller; /** * @author Paul Ferraro */ public class WildFlyWeldEJBSerializationContextInitializer extends AbstractSerializationContextInitializer { public WildFlyWeldEJBSerializationContextInitializer() { super("org.jboss.as.weld.ejb.proto"); } @Override public void registerMarshallers(SerializationContext context) { context.registerMarshaller(new ProxyMarshaller<>(StatefulSessionObjectReferenceImpl.class)); context.registerMarshaller(new SerializedStatefulSessionObjectMarshaller()); } }
1,894
41.111111
108
java
null
wildfly-main/clustering/weld/ejb/src/main/java/org/wildfly/clustering/weld/ejb/WeldEJBSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb; import org.infinispan.protostream.SerializationContextInitializer; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.protostream.CompositeSerializationContextInitializer; /** * @author Paul Ferraro */ @MetaInfServices(SerializationContextInitializer.class) public class WeldEJBSerializationContextInitializer extends CompositeSerializationContextInitializer { public WeldEJBSerializationContextInitializer() { super(WeldEJBSerializationContextInitializerProvider.class); } }
1,588
40.815789
102
java
null
wildfly-main/clustering/weld/ejb/src/main/java/org/wildfly/clustering/weld/ejb/WeldEJBSerializationContextInitializerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb; import org.infinispan.protostream.SerializationContextInitializer; import org.wildfly.clustering.ejb.client.EJBClientSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.SerializationContextInitializerProvider; import org.wildfly.clustering.weld.ejb.component.session.SessionComponentSerializationContextInitializer; import org.wildfly.clustering.weld.ejb.component.stateful.StatefulComponentSerializationContextInitializer; /** * @author Paul Ferraro */ public enum WeldEJBSerializationContextInitializerProvider implements SerializationContextInitializerProvider { CLIENT(new EJBClientSerializationContextInitializer()), WELD(new WeldModuleEJBSerializationContextInitializer()), WILDFLY(new WildFlyWeldEJBSerializationContextInitializer()), SESSION(new SessionComponentSerializationContextInitializer()), STATEFUL(new StatefulComponentSerializationContextInitializer()), ; private final SerializationContextInitializer initializer; WeldEJBSerializationContextInitializerProvider(SerializationContextInitializer initializer) { this.initializer = initializer; } @Override public SerializationContextInitializer getInitializer() { return this.initializer; } }
2,328
43.788462
111
java
null
wildfly-main/clustering/weld/ejb/src/main/java/org/wildfly/clustering/weld/ejb/WeldModuleEJBSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.security.PrivilegedAction; import org.infinispan.protostream.SerializationContext; import org.jboss.weld.ejb.api.SessionObjectReference; import org.jboss.weld.manager.BeanManagerImpl; import org.jboss.weld.module.ejb.EnterpriseBeanInstance; import org.jboss.weld.serialization.spi.BeanIdentifier; import org.wildfly.clustering.marshalling.protostream.AbstractSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.reflect.TernaryFieldMarshaller; import org.wildfly.clustering.marshalling.protostream.reflect.TriFunction; import org.wildfly.security.ParametricPrivilegedAction; import org.wildfly.security.manager.WildFlySecurityManager; /** * @author Paul Ferraro */ public class WeldModuleEJBSerializationContextInitializer extends AbstractSerializationContextInitializer implements ParametricPrivilegedAction<Class<?>, String> { public WeldModuleEJBSerializationContextInitializer() { super("org.jboss.weld.module.ejb.proto"); } @Override public Class<?> run(String className) { try { return EnterpriseBeanInstance.class.getClassLoader().loadClass(className); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(className); } } @Override public void registerMarshallers(SerializationContext context) { // Gotta love overly restrictive modifiers... Class<?> methodHandlerClass = WildFlySecurityManager.doUnchecked("org.jboss.weld.module.ejb.EnterpriseBeanProxyMethodHandler", this); Class<?> sessionBeanImplClass = WildFlySecurityManager.doUnchecked("org.jboss.weld.module.ejb.SessionBeanImpl", this); TriFunction<BeanManagerImpl, BeanIdentifier, SessionObjectReference, Object> function = new TriFunction<>() { @Override public Object apply(BeanManagerImpl manager, BeanIdentifier identifier, SessionObjectReference reference) { return WildFlySecurityManager.doUnchecked(new PrivilegedAction<Object>() { @Override public Object run() { try { Constructor<?> constructor = methodHandlerClass.getDeclaredConstructor(sessionBeanImplClass, SessionObjectReference.class); constructor.setAccessible(true); return constructor.newInstance(manager.getPassivationCapableBean(identifier), reference); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { throw new IllegalStateException(e); } } }); } }; context.registerMarshaller(new TernaryFieldMarshaller<>(methodHandlerClass, BeanManagerImpl.class, BeanIdentifier.class, SessionObjectReference.class, function)); } }
4,096
48.361446
170
java
null
wildfly-main/clustering/weld/ejb/src/main/java/org/wildfly/clustering/weld/ejb/component/stateful/StatefulSerializedProxyMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb.component.stateful; import java.io.IOException; import org.infinispan.protostream.descriptors.WireType; import org.jboss.as.ejb3.component.stateful.StatefulSerializedProxy; import org.jboss.ejb.client.SessionID; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; /** * @author Paul Ferraro */ public class StatefulSerializedProxyMarshaller implements ProtoStreamMarshaller<StatefulSerializedProxy> { private static final int VIEW_NAME_INDEX = 1; private static final int SESSION_ID_INDEX = 2; @Override public Class<? extends StatefulSerializedProxy> getJavaClass() { return StatefulSerializedProxy.class; } @Override public StatefulSerializedProxy readFrom(ProtoStreamReader reader) throws IOException { String viewName = null; SessionID id = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case VIEW_NAME_INDEX: viewName = reader.readString(); break; case SESSION_ID_INDEX: id = reader.readObject(SessionID.class); break; default: reader.skipField(tag); } } return new StatefulSerializedProxy(viewName, id); } @Override public void writeTo(ProtoStreamWriter writer, StatefulSerializedProxy proxy) throws IOException { String viewName = proxy.getViewName(); if (viewName != null) { writer.writeString(VIEW_NAME_INDEX, viewName); } SessionID id = proxy.getSessionID(); if (id != null) { writer.writeObject(SESSION_ID_INDEX, id); } } }
2,985
36.797468
106
java
null
wildfly-main/clustering/weld/ejb/src/main/java/org/wildfly/clustering/weld/ejb/component/stateful/StatefulComponentSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb.component.stateful; import org.infinispan.protostream.SerializationContext; import org.wildfly.clustering.marshalling.protostream.AbstractSerializationContextInitializer; /** * @author Paul Ferraro */ public class StatefulComponentSerializationContextInitializer extends AbstractSerializationContextInitializer { public StatefulComponentSerializationContextInitializer() { super("org.jboss.as.ejb3.component.stateful.proto"); } @Override public void registerMarshallers(SerializationContext context) { context.registerMarshaller(new StatefulSerializedProxyMarshaller()); } }
1,681
39.047619
111
java
null
wildfly-main/clustering/weld/ejb/src/main/java/org/wildfly/clustering/weld/ejb/component/session/SessionComponentSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.weld.ejb.component.session; import org.infinispan.protostream.SerializationContext; import org.jboss.as.ejb3.component.session.StatelessSerializedProxy; import org.wildfly.clustering.marshalling.protostream.AbstractSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.FunctionalScalarMarshaller; import org.wildfly.clustering.marshalling.protostream.Scalar; /** * @author Paul Ferraro */ public class SessionComponentSerializationContextInitializer extends AbstractSerializationContextInitializer { public SessionComponentSerializationContextInitializer() { super("org.jboss.as.ejb3.component.session.proto"); } @Override public void registerMarshallers(SerializationContext context) { context.registerMarshaller(new FunctionalScalarMarshaller<>(StatelessSerializedProxy.class, Scalar.STRING.cast(String.class), StatelessSerializedProxy::getViewName, StatelessSerializedProxy::new)); } }
2,019
43.888889
205
java
null
wildfly-main/clustering/faces/api/src/test/java/org/wildfly/clustering/faces/FacesSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces; import org.infinispan.protostream.SerializationContextInitializer; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.protostream.CompositeSerializationContextInitializer; /** * @author Paul Ferraro */ @MetaInfServices(SerializationContextInitializer.class) public class FacesSerializationContextInitializer extends CompositeSerializationContextInitializer { public FacesSerializationContextInitializer() { super(FacesSerializationContextInitializerProvider.class); } }
1,580
39.538462
100
java
null
wildfly-main/clustering/faces/api/src/test/java/org/wildfly/clustering/faces/view/LocationMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.view; import java.io.IOException; import jakarta.faces.view.Location; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; import org.junit.Assert; /** * Validates marshalling of a {@link Location}. * @author Paul Ferraro */ public class LocationMarshallerTestCase { @Test public void test() throws IOException { Tester<Location> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new Location("/foo", -1, -1), LocationMarshallerTestCase::assertEquals); tester.test(new Location("/var", 11, 12), LocationMarshallerTestCase::assertEquals); } static void assertEquals(Location location1, Location location2) { Assert.assertEquals(location1.getPath(), location2.getPath()); Assert.assertEquals(location1.getLine(), location2.getLine()); Assert.assertEquals(location1.getColumn(), location2.getColumn()); } }
2,063
37.943396
92
java
null
wildfly-main/clustering/faces/api/src/main/java/org/wildfly/clustering/faces/FacesSerializationContextInitializerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces; import org.infinispan.protostream.SerializationContextInitializer; import org.wildfly.clustering.faces.component.ComponentMarshallerProvider; import org.wildfly.clustering.faces.view.ViewMarshallerProvider; import org.wildfly.clustering.marshalling.protostream.ProviderSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.SerializationContextInitializerProvider; /** * @author Paul Ferraro */ public enum FacesSerializationContextInitializerProvider implements SerializationContextInitializerProvider { COMPONENT(new ProviderSerializationContextInitializer<>("jakarta.faces.component.proto", ComponentMarshallerProvider.class)), VIEW(new ProviderSerializationContextInitializer<>("jakarta.faces.view.proto", ViewMarshallerProvider.class)), ; private final SerializationContextInitializer initializer; FacesSerializationContextInitializerProvider(SerializationContextInitializer initializer) { this.initializer = initializer; } @Override public SerializationContextInitializer getInitializer() { return this.initializer; } }
2,179
42.6
129
java
null
wildfly-main/clustering/faces/api/src/main/java/org/wildfly/clustering/faces/view/ViewMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.view; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; /** * @author Paul Ferraro */ public enum ViewMarshallerProvider implements ProtoStreamMarshallerProvider { LOCATION(new LocationMarshaller()), ; private final ProtoStreamMarshaller<?> marshaller; ViewMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
1,661
36.772727
84
java
null
wildfly-main/clustering/faces/api/src/main/java/org/wildfly/clustering/faces/view/LocationMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.view; import java.io.IOException; import jakarta.faces.view.Location; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; /** * Marshaller for a {@link Location}. * @author Paul Ferraro */ public class LocationMarshaller implements ProtoStreamMarshaller<Location> { private static final int PATH_INDEX = 1; private static final int LINE_INDEX = 2; private static final int COLUMN_INDEX = 3; @Override public Class<? extends Location> getJavaClass() { return Location.class; } @Override public Location readFrom(ProtoStreamReader reader) throws IOException { String path = null; int line = -1; int column = -1; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case PATH_INDEX: path = reader.readString(); break; case LINE_INDEX: line = reader.readUInt32(); break; case COLUMN_INDEX: column = reader.readUInt32(); break; default: reader.skipField(tag); } } return new Location(path, line, column); } @Override public void writeTo(ProtoStreamWriter writer, Location location) throws IOException { String path = location.getPath(); if (path != null) { writer.writeString(PATH_INDEX, path); } int line = location.getLine(); if (line >= 0) { writer.writeUInt32(LINE_INDEX, line); } int column = location.getColumn(); if (column >= 0) { writer.writeUInt32(COLUMN_INDEX, column); } } }
3,078
33.988636
89
java
null
wildfly-main/clustering/faces/api/src/main/java/org/wildfly/clustering/faces/view/facelets/MockTagAttribute.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.view.facelets; import jakarta.el.MethodExpression; import jakarta.el.ValueExpression; import jakarta.faces.view.Location; import jakarta.faces.view.facelets.FaceletContext; import jakarta.faces.view.facelets.TagAttribute; /** * Mock {@link TagAttribute} that implements a fixed {@link #toString()}. * @author Paul Ferraro */ public class MockTagAttribute extends TagAttribute { private final String value; public MockTagAttribute(String value) { this.value = value; } @Override public boolean getBoolean(FaceletContext ctx) { return false; } @Override public int getInt(FaceletContext ctx) { return 0; } @Override public String getLocalName() { return null; } @Override public Location getLocation() { return null; } @Override public MethodExpression getMethodExpression(FaceletContext ctx, Class type, Class[] paramTypes) { return null; } @Override public String getNamespace() { return null; } @Override public Object getObject(FaceletContext ctx) { return null; } @Override public String getQName() { return null; } @Override public String getValue() { return null; } @Override public String getValue(FaceletContext ctx) { return null; } @Override public Object getObject(FaceletContext ctx, Class type) { return null; } @Override public ValueExpression getValueExpression(FaceletContext ctx, Class type) { return null; } @Override public boolean isLiteral() { return false; } @Override public String toString() { return this.value; } }
2,822
23.982301
101
java
null
wildfly-main/clustering/faces/api/src/main/java/org/wildfly/clustering/faces/component/ComponentMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.component; import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.security.PrivilegedAction; import jakarta.faces.component.StateHolder; import jakarta.faces.component.UIComponent; import jakarta.faces.context.FacesContext; import org.wildfly.clustering.marshalling.protostream.EnumMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; import org.wildfly.clustering.marshalling.protostream.reflect.FieldMarshaller; import org.wildfly.security.manager.WildFlySecurityManager; /** * @author Paul Ferraro */ public enum ComponentMarshallerProvider implements ProtoStreamMarshallerProvider { PROPERTY_KEYS(UIComponent.class, "PropertyKeys"), PROPERTY_KEYS_PRIVATE(UIComponent.class, "PropertyKeysPrivate"), STATE_HOLDER_SAVER("jakarta.faces.component.StateHolderSaver"), ; private final ProtoStreamMarshaller<?> marshaller; ComponentMarshallerProvider(Class<?> parentClass, String enumName) { // Package protected enums!!! try { this.marshaller = new EnumMarshaller<>(WildFlySecurityManager.getClassLoaderPrivileged(parentClass).loadClass(parentClass.getName() + "$" + enumName).asSubclass(Enum.class)); } catch (ClassNotFoundException e) { throw new IllegalStateException(e); } } ComponentMarshallerProvider(String className) { // Package protected class with inaccessible fields!!! try { Class<? extends Object> targetClass = WildFlySecurityManager.getClassLoaderPrivileged(StateHolder.class).loadClass(className); PrivilegedAction<Object> action = () -> { try { Constructor<? extends Object> constructor = targetClass.getDeclaredConstructor(FacesContext.class, Object.class); constructor.setAccessible(true); return constructor.newInstance(null, null); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { throw new IllegalStateException(e); } }; this.marshaller = new FieldMarshaller<>(targetClass, () -> WildFlySecurityManager.doUnchecked(action), String.class, Serializable.class); } catch (ClassNotFoundException e) { throw new IllegalStateException(e); } } ComponentMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
3,824
42.965517
186
java
null
wildfly-main/clustering/faces/mojarra/src/test/java/org/wildfly/clustering/faces/mojarra/util/LRUMapMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.util; import java.io.IOException; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; import com.sun.faces.util.LRUMap; /** * @author Paul Ferraro */ public class LRUMapMarshallerTestCase { @Test public void test() throws IOException { Tester<LRUMap<Object, Object>> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); LRUMap<Object, Object> map = new LRUMap<>(10); tester.test(map); map.put(1, "1"); map.put(2, "2"); tester.test(map); } }
1,683
34.829787
97
java
null
wildfly-main/clustering/faces/mojarra/src/test/java/org/wildfly/clustering/faces/mojarra/facelets/el/ContextualCompositeValueExpressionMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.facelets.el; import java.io.IOException; import java.util.ServiceLoader; import jakarta.faces.view.Location; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.el.ValueExpressionFactory; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; import com.sun.faces.facelets.el.ContextualCompositeValueExpression; /** * Validates marshalling of a {@link ContextualCompositeValueExpression}. * @author Paul Ferraro */ public class ContextualCompositeValueExpressionMarshallerTestCase { private final ValueExpressionFactory factory = ServiceLoader.load(ValueExpressionFactory.class, ValueExpressionFactory.class.getClassLoader()).iterator().next(); @Test public void test() throws IOException { Tester<ContextualCompositeValueExpression> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new ContextualCompositeValueExpression(new Location("/path", 1, 2), this.factory.createValueExpression("foo", String.class)), ContextualCompositeValueExpressionMarshallerTestCase::assertEquals); } // ContextualCompositeValueExpression.equals(...) impl is screwy static void assertEquals(ContextualCompositeValueExpression expression1, ContextualCompositeValueExpression expression2) { Assert.assertEquals(expression1.getExpressionString(), expression2.getExpressionString()); Assert.assertEquals(expression1.isLiteralText(), expression2.isLiteralText()); } }
2,604
44.701754
214
java
null
wildfly-main/clustering/faces/mojarra/src/test/java/org/wildfly/clustering/faces/mojarra/facelets/el/TagValueExpressionMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.facelets.el; import java.io.IOException; import java.util.ServiceLoader; import org.junit.Test; import org.wildfly.clustering.el.ValueExpressionFactory; import org.wildfly.clustering.faces.view.facelets.MockTagAttribute; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; import com.sun.faces.facelets.el.TagValueExpression; /** * Validates marshalling of a {@link TagValueExpression}. * @author Paul Ferraro */ public class TagValueExpressionMarshallerTestCase { private final ValueExpressionFactory factory = ServiceLoader.load(ValueExpressionFactory.class, ValueExpressionFactory.class.getClassLoader()).iterator().next(); @Test public void test() throws IOException { Tester<TagValueExpression> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new TagValueExpression(new MockTagAttribute("foo"), this.factory.createValueExpression("foo", String.class))); } }
2,073
41.326531
165
java
null
wildfly-main/clustering/faces/mojarra/src/test/java/org/wildfly/clustering/faces/mojarra/facelets/el/TagMethodExpressionMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.facelets.el; import java.io.IOException; import java.util.ServiceLoader; import org.junit.Test; import org.wildfly.clustering.el.MethodExpressionFactory; import org.wildfly.clustering.faces.view.facelets.MockTagAttribute; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; import com.sun.faces.facelets.el.TagMethodExpression; /** * Validates marshalling of a {@link TagMethodExpression}. * @author Paul Ferraro */ public class TagMethodExpressionMarshallerTestCase { private final MethodExpressionFactory factory = ServiceLoader.load(MethodExpressionFactory.class, MethodExpressionFactory.class.getClassLoader()).iterator().next(); @Test public void test() throws IOException { Tester<TagMethodExpression> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new TagMethodExpression(new MockTagAttribute("foo"), this.factory.createMethodExpression("foo", String.class, new Class[0]))); } }
2,098
40.98
168
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/MojarraSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra; import org.infinispan.protostream.SerializationContextInitializer; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.faces.FacesSerializationContextInitializerProvider; import org.wildfly.clustering.marshalling.protostream.CompositeSerializationContextInitializer; /** * @author Paul Ferraro */ @MetaInfServices(SerializationContextInitializer.class) public class MojarraSerializationContextInitializer extends CompositeSerializationContextInitializer { public MojarraSerializationContextInitializer() { super(new CompositeSerializationContextInitializer(FacesSerializationContextInitializerProvider.class), new CompositeSerializationContextInitializer(MojarraSerializationContextInitializerProvider.class)); } }
1,820
44.525
212
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/MojarraSerializationContextInitializerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra; import org.infinispan.protostream.SerializationContextInitializer; import org.wildfly.clustering.faces.mojarra.context.flash.ContextFlashMarshallerProvider; import org.wildfly.clustering.faces.mojarra.facelets.el.FaceletsELMarshallerProvider; import org.wildfly.clustering.faces.mojarra.util.UtilMarshallerProvider; import org.wildfly.clustering.marshalling.protostream.ProviderSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.SerializationContextInitializerProvider; /** * @author Paul Ferraro */ public enum MojarraSerializationContextInitializerProvider implements SerializationContextInitializerProvider { CONTEXT_FLASH(new ProviderSerializationContextInitializer<>("com.sun.faces.context.flash.proto", ContextFlashMarshallerProvider.class)), FACELETS_EL(new ProviderSerializationContextInitializer<>("com.sun.faces.facelets.el.proto", FaceletsELMarshallerProvider.class)), UTIL(new ProviderSerializationContextInitializer<>("com.sun.faces.util.proto", UtilMarshallerProvider.class)), ; private final SerializationContextInitializer initializer; MojarraSerializationContextInitializerProvider(SerializationContextInitializer initializer) { this.initializer = initializer; } @Override public SerializationContextInitializer getInitializer() { return this.initializer; } }
2,446
46.057692
140
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/util/LRUMapMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.util; import java.io.IOException; import java.lang.reflect.Field; import java.security.PrivilegedAction; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.clustering.marshalling.protostream.util.AbstractMapMarshaller; import org.wildfly.security.manager.WildFlySecurityManager; import com.sun.faces.util.LRUMap; /** * @author Paul Ferraro */ public class LRUMapMarshaller extends AbstractMapMarshaller<LRUMap<Object, Object>> { private static final int MAX_CAPACITY_INDEX = VALUE_INDEX + 1; private static final int DEFAULT_MAX_CAPACITY = 15; private static final Field MAX_CAPACITY_FIELD = WildFlySecurityManager.doUnchecked(new PrivilegedAction<Field>() { @Override public Field run() { for (Field field : LRUMap.class.getDeclaredFields()) { if (field.getType() == Integer.TYPE) { field.setAccessible(true); return field; } } throw new IllegalStateException(); } }); @SuppressWarnings("unchecked") public LRUMapMarshaller() { super((Class<LRUMap<Object, Object>>) (Class<?>) LRUMap.class); } @Override public LRUMap<Object, Object> readFrom(ProtoStreamReader reader) throws IOException { int maxCapacity = DEFAULT_MAX_CAPACITY; List<Object> keys = new LinkedList<>(); List<Object> values = new LinkedList<>(); while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case KEY_INDEX: keys.add(reader.readAny()); break; case VALUE_INDEX: values.add(reader.readAny()); break; case MAX_CAPACITY_INDEX: maxCapacity = reader.readUInt32(); break; default: reader.skipField(tag); } } LRUMap<Object, Object> map = new LRUMap<>(maxCapacity); Iterator<Object> keyIterator = keys.iterator(); Iterator<Object> valueIterator = values.iterator(); while (keyIterator.hasNext() || valueIterator.hasNext()) { map.put(keyIterator.next(), valueIterator.next()); } return map; } @Override public void writeTo(ProtoStreamWriter writer, LRUMap<Object, Object> map) throws IOException { super.writeTo(writer, map); try { int maxCapacity = MAX_CAPACITY_FIELD.getInt(map); if (maxCapacity != DEFAULT_MAX_CAPACITY) { writer.writeUInt32(MAX_CAPACITY_INDEX, maxCapacity); } } catch (IllegalAccessException e) { throw new IllegalStateException(e); } } }
4,125
37.203704
118
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/util/UtilMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.util; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; /** * @author Paul Ferraro */ public enum UtilMarshallerProvider implements ProtoStreamMarshallerProvider { LRU_MAP(new LRUMapMarshaller()), ; private final ProtoStreamMarshaller<?> marshaller; UtilMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
1,668
35.282609
84
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/context/flash/ContextFlashMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.context.flash; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; /** * @author Paul Ferraro */ public enum ContextFlashMarshallerProvider implements ProtoStreamMarshallerProvider { SESSION_HELPER(new SessionHelperMarshaller()), ; private final ProtoStreamMarshaller<?> marshaller; ContextFlashMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
1,707
36.130435
85
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/context/flash/SessionHelperMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.context.flash; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.security.PrivilegedAction; import jakarta.servlet.http.HttpSessionActivationListener; import org.wildfly.clustering.marshalling.protostream.ValueMarshaller; import org.wildfly.security.manager.WildFlySecurityManager; /** * @author Paul Ferraro */ public class SessionHelperMarshaller extends ValueMarshaller<HttpSessionActivationListener> { public SessionHelperMarshaller() { super(WildFlySecurityManager.doUnchecked(new PrivilegedAction<HttpSessionActivationListener>() { @Override public HttpSessionActivationListener run() { try { // *sigh* SessionHelper is package protected Class<? extends HttpSessionActivationListener> targetClass = Reflect.getSessionHelperClass(); Constructor<? extends HttpSessionActivationListener> constructor = targetClass.getDeclaredConstructor(); constructor.setAccessible(true); HttpSessionActivationListener listener = constructor.newInstance(); // Set passivated flag listener.sessionWillPassivate(null); return listener; } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException(e); } } })); } }
2,600
43.084746
129
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/context/flash/Reflect.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.context.flash; import java.security.PrivilegedAction; import jakarta.servlet.http.HttpSessionActivationListener; import org.wildfly.security.manager.WildFlySecurityManager; import com.sun.faces.context.flash.ELFlash; /** * Utility methods requiring privileged actions. * Do not change class/method visibility to avoid being called from other {@link java.security.CodeSource}s, thus granting privilege escalation to external code. * @author Paul Ferraro */ class Reflect { /** * Returns a reference to the package protected {@link com.sun.faces.context.flash.SessionHelper} class. * @param loader a class loader * @param className the name of the class to load * @return the loaded class */ static Class<? extends HttpSessionActivationListener> getSessionHelperClass() { return loadClass(WildFlySecurityManager.getClassLoaderPrivileged(ELFlash.class), "com.sun.faces.context.flash.SessionHelper").asSubclass(HttpSessionActivationListener.class); } /** * Loads a class with the specified name from the specified class loader. * @param loader a class loader * @param className the name of the class to load * @return the loaded class */ static Class<?> loadClass(ClassLoader loader, String className) { return WildFlySecurityManager.doUnchecked(new PrivilegedAction<>() { @Override public Class<?> run() { try { return loader.loadClass(className); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(e); } } }); } }
2,734
39.220588
182
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/context/flash/FlashImmutability.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.context.flash; import java.util.Set; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.ee.Immutability; import org.wildfly.clustering.ee.immutable.InstanceOfImmutability; /** * @author Paul Ferraro */ @MetaInfServices(Immutability.class) public class FlashImmutability extends InstanceOfImmutability { public FlashImmutability() { super(Set.of(Reflect.getSessionHelperClass())); } }
1,490
35.365854
70
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/facelets/el/FaceletsELMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.facelets.el; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; /** * @author Paul Ferraro */ public enum FaceletsELMarshallerProvider implements ProtoStreamMarshallerProvider { CONTEXTUAL_COMPOSITE_VALUE_EXPRESSION(new ContextualCompositeValueExpressionMarshaller()), TAG_METHOD_EXPRESSION(new TagMethodExpressionMarshaller()), TAG_VALUE_EXPRESSION(new TagValueExpressionMarshaller()), ; private final ProtoStreamMarshaller<?> marshaller; FaceletsELMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
1,871
38
94
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/facelets/el/ContextualCompositeValueExpressionMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.facelets.el; import java.io.IOException; import java.lang.reflect.Field; import java.security.PrivilegedAction; import jakarta.el.ValueExpression; import jakarta.faces.view.Location; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.security.manager.WildFlySecurityManager; import com.sun.faces.facelets.el.ContextualCompositeValueExpression; /** * @author Paul Ferraro */ public class ContextualCompositeValueExpressionMarshaller implements ProtoStreamMarshaller<ContextualCompositeValueExpression> { private static final int LOCATION_INDEX = 1; private static final int EXPRESSION_INDEX = 2; static final Field VALUE_EXPRESSION_FIELD = WildFlySecurityManager.doUnchecked(new PrivilegedAction<>() { @Override public Field run() { for (Field field : ContextualCompositeValueExpression.class.getDeclaredFields()) { if (field.getType() == ValueExpression.class) { field.setAccessible(true); return field; } } throw new IllegalArgumentException(ValueExpression.class.getName()); } }); @Override public Class<? extends ContextualCompositeValueExpression> getJavaClass() { return ContextualCompositeValueExpression.class; } @Override public ContextualCompositeValueExpression readFrom(ProtoStreamReader reader) throws IOException { ValueExpression expression = null; Location location = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case LOCATION_INDEX: location = reader.readObject(Location.class); break; case EXPRESSION_INDEX: expression = reader.readAny(ValueExpression.class); break; default: reader.skipField(tag); } } return new ContextualCompositeValueExpression(location, expression); } @Override public void writeTo(ProtoStreamWriter writer, ContextualCompositeValueExpression value) throws IOException { Location location = value.getLocation(); if (location != null) { writer.writeObject(LOCATION_INDEX, location); } ValueExpression expression = WildFlySecurityManager.doUnchecked(new PrivilegedAction<>() { @Override public ValueExpression run() { try { return (ValueExpression) VALUE_EXPRESSION_FIELD.get(value); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } } }); if (expression != null) { writer.writeAny(EXPRESSION_INDEX, expression); } } }
4,232
38.933962
128
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/facelets/el/TagValueExpressionMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.facelets.el; import java.io.IOException; import jakarta.el.ValueExpression; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.faces.view.facelets.MockTagAttribute; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.clustering.marshalling.protostream.SimpleObjectOutput; import com.sun.faces.facelets.el.TagValueExpression; /** * @author Paul Ferraro */ public class TagValueExpressionMarshaller implements ProtoStreamMarshaller<TagValueExpression> { private static final int ATTRIBUTE_INDEX = 1; private static final int EXPRESSION_INDEX = 2; @Override public Class<? extends TagValueExpression> getJavaClass() { return TagValueExpression.class; } @Override public TagValueExpression readFrom(ProtoStreamReader reader) throws IOException { String attribute = null; ValueExpression expression = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case ATTRIBUTE_INDEX: attribute = reader.readString(); break; case EXPRESSION_INDEX: expression = reader.readAny(ValueExpression.class); break; default: reader.skipField(tag); } } return new TagValueExpression(new MockTagAttribute(attribute), expression); } @Override public void writeTo(ProtoStreamWriter writer, TagValueExpression value) throws IOException { String[] strings = new String[1]; Object[] objects = new Object[1]; value.writeExternal(new SimpleObjectOutput.Builder().with(strings).with(objects).build()); String attribute = strings[0]; if (attribute != null) { writer.writeString(ATTRIBUTE_INDEX, attribute); } Object expression = objects[0]; if (expression != null) { writer.writeAny(EXPRESSION_INDEX, expression); } } }
3,317
36.704545
98
java
null
wildfly-main/clustering/faces/mojarra/src/main/java/org/wildfly/clustering/faces/mojarra/facelets/el/TagMethodExpressionMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.faces.mojarra.facelets.el; import java.io.IOException; import jakarta.el.MethodExpression; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.SimpleObjectOutput; import org.wildfly.clustering.faces.view.facelets.MockTagAttribute; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import com.sun.faces.facelets.el.TagMethodExpression; /** * @author Paul Ferraro */ public class TagMethodExpressionMarshaller implements ProtoStreamMarshaller<TagMethodExpression> { private static final int ATTRIBUTE_INDEX = 1; private static final int EXPRESSION_INDEX = 2; @Override public Class<? extends TagMethodExpression> getJavaClass() { return TagMethodExpression.class; } @Override public TagMethodExpression readFrom(ProtoStreamReader reader) throws IOException { String attribute = null; MethodExpression expression = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case ATTRIBUTE_INDEX: attribute = reader.readString(); break; case EXPRESSION_INDEX: expression = reader.readAny(MethodExpression.class); break; default: reader.skipField(tag); } } return new TagMethodExpression(new MockTagAttribute(attribute), expression); } @Override public void writeTo(ProtoStreamWriter writer, TagMethodExpression value) throws IOException { String[] strings = new String[1]; Object[] objects = new Object[1]; value.writeExternal(new SimpleObjectOutput.Builder().with(strings).with(objects).build()); String attribute = strings[0]; if (attribute != null) { writer.writeString(ATTRIBUTE_INDEX, attribute); } Object expression = objects[0]; if (expression != null) { writer.writeAny(EXPRESSION_INDEX, expression); } } }
3,328
36.829545
98
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/ValueExpressionFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el; import jakarta.el.ValueExpression; /** * @author Paul Ferraro */ public interface ValueExpressionFactory { ValueExpression createValueExpression(String name, Class<?> type); }
1,243
36.69697
70
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/MethodExpressionFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el; import jakarta.el.MethodExpression; /** * @author Paul Ferraro */ public interface MethodExpressionFactory { MethodExpression createMethodExpression(String name, Class<?> type, Class<?>[] parameters); }
1,270
37.515152
95
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/expressly/ExpresslyValueExpressionFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import jakarta.el.ValueExpression; import org.glassfish.expressly.ValueExpressionLiteral; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.el.ValueExpressionFactory; /** * @author Paul Ferraro */ @MetaInfServices(ValueExpressionFactory.class) public class ExpresslyValueExpressionFactory implements ValueExpressionFactory { @Override public ValueExpression createValueExpression(String name, Class<?> type) { return new ValueExpressionLiteral(name, type); } }
1,571
37.341463
80
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/expressly/MethodExpressionImplMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import java.io.IOException; import org.glassfish.expressly.MethodExpressionImpl; import org.glassfish.expressly.lang.FunctionMapperImpl; import org.glassfish.expressly.lang.VariableMapperImpl; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Validates marshalling of a {@link MethodExpressionImpl}. * @author Paul Ferraro */ public class MethodExpressionImplMarshallerTestCase { @Test public void test() throws IOException { Tester<MethodExpressionImpl> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new MethodExpressionImpl("foo", null, new FunctionMapperImpl(), new VariableMapperImpl(), String.class, new Class[0])); tester.test(new MethodExpressionImpl("bar", null, new FunctionMapperImpl(), new VariableMapperImpl(), String.class, new Class[] { Boolean.class, Integer.class })); } }
2,035
42.319149
171
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/expressly/ValueExpressionImplMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import java.io.IOException; import org.glassfish.expressly.ValueExpressionImpl; import org.glassfish.expressly.lang.FunctionMapperImpl; import org.glassfish.expressly.lang.VariableMapperImpl; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Validates marshalling of a {@link ValueExpressionImpl}. * @author Paul Ferraro */ public class ValueExpressionImplMarshallerTestCase { @Test public void test() throws IOException { Tester<ValueExpressionImpl> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new ValueExpressionImpl("foo", null, new FunctionMapperImpl(), new VariableMapperImpl(), String.class)); } }
1,844
39.108696
124
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/expressly/ExpresslyMethodExpressionFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import jakarta.el.MethodExpression; import org.glassfish.expressly.MethodExpressionLiteral; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.el.MethodExpressionFactory; /** * @author Paul Ferraro */ @MetaInfServices(MethodExpressionFactory.class) public class ExpresslyMethodExpressionFactory implements MethodExpressionFactory { @Override public MethodExpression createMethodExpression(String name, Class<?> type, Class<?>[] parameters) { return new MethodExpressionLiteral(name, type, parameters); } }
1,615
38.414634
103
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/expressly/MethodExpressionLiteralMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import java.io.IOException; import org.glassfish.expressly.MethodExpressionLiteral; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Validates marshalling of a {@link MethodExpressionLiteral}. * @author Paul Ferraro */ public class MethodExpressionLiteralMarshallerTestCase { @Test public void test() throws IOException { Tester<MethodExpressionLiteral> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new MethodExpressionLiteral("foo", String.class, new Class[0])); tester.test(new MethodExpressionLiteral("bar", String.class, new Class[] { Boolean.class, Integer.class})); } }
1,824
39.555556
115
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/expressly/ValueExpressionLiteralMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import java.io.IOException; import org.glassfish.expressly.ValueExpressionLiteral; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Validates marshalling of a {@link ValueExpressionLiteral}. * @author Paul Ferraro */ public class ValueExpressionLiteralMarshallerTestCase { @Test public void test() throws IOException { Tester<ValueExpressionLiteral> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new ValueExpressionLiteral(Boolean.TRUE, Boolean.class)); } }
1,697
37.590909
97
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/expressly/lang/FunctionMapperImplMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly.lang; import java.io.IOException; import java.lang.reflect.Method; import org.glassfish.expressly.lang.FunctionMapperImpl; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Validates marshalling of a {@link FunctionMapperImpl}. * @author Paul Ferraro */ public class FunctionMapperImplMarshallerTestCase { @Test public void test() throws NoSuchMethodException, IOException { Tester<FunctionMapperImpl> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); FunctionMapperImpl mapper = new FunctionMapperImpl(); tester.test(mapper, Assert::assertNotSame); mapper.addFunction(null, "foo", this.getClass().getMethod("test")); mapper.addFunction("foo", "bar", this.getClass().getMethod("test")); tester.test(mapper, FunctionMapperImplMarshallerTestCase::assertEquals); } static void assertEquals(FunctionMapperImpl mapper1, FunctionMapperImpl mapper2) { assertEquals(mapper1, mapper2, null, "foo"); assertEquals(mapper1, mapper2, "foo", "bar"); } static void assertEquals(FunctionMapperImpl mapper1, FunctionMapperImpl mapper2, String prefix, String localName) { Method method1 = mapper1.resolveFunction(prefix, localName); Method method2 = mapper2.resolveFunction(prefix, localName); Assert.assertNotNull(method1); Assert.assertNotNull(method2); Assert.assertEquals(method1, method2); } }
2,633
40.809524
119
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/expressly/lang/VariableMapperImplMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly.lang; import java.io.IOException; import org.glassfish.expressly.ValueExpressionLiteral; import org.glassfish.expressly.lang.VariableMapperImpl; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; import jakarta.el.ValueExpression; /** * Validates marshalling of a {@link VariableMapperImpl}. * @author Paul Ferraro */ public class VariableMapperImplMarshallerTestCase { @Test public void test() throws IOException { Tester<VariableMapperImpl> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); VariableMapperImpl mapper = new VariableMapperImpl(); tester.test(mapper, Assert::assertNotSame); mapper.setVariable("foo", new ValueExpressionLiteral(Boolean.TRUE, Boolean.class)); mapper.setVariable("bar", new ValueExpressionLiteral(Integer.valueOf(1), Integer.class)); tester.test(mapper, VariableMapperImplMarshallerTestCase::assertEquals); } static void assertEquals(VariableMapperImpl mapper1, VariableMapperImpl mapper2) { assertEquals(mapper1, mapper2, "foo"); assertEquals(mapper1, mapper2, "bar"); } static void assertEquals(VariableMapperImpl mapper1, VariableMapperImpl mapper2, String variable) { ValueExpression expression1 = mapper1.resolveVariable(variable); ValueExpression expression2 = mapper2.resolveVariable(variable); Assert.assertNotNull(expression1); Assert.assertNotNull(expression2); Assert.assertEquals(expression1, expression2); } }
2,700
40.553846
103
java
null
wildfly-main/clustering/el/expressly/src/test/java/org/wildfly/clustering/el/expressly/lang/FunctionMarshallerTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly.lang; import java.io.IOException; import org.glassfish.expressly.lang.FunctionMapperImpl.Function; import org.junit.Test; import org.wildfly.clustering.marshalling.Tester; import org.wildfly.clustering.marshalling.protostream.ProtoStreamTesterFactory; /** * Validates marshalling of a {@link Function}. * @author Paul Ferraro */ public class FunctionMarshallerTestCase { @Test public void test() throws NoSuchMethodException, IOException { Tester<Function> tester = ProtoStreamTesterFactory.INSTANCE.createTester(); tester.test(new Function(null, "foo", this.getClass().getMethod("test"))); tester.test(new Function("foo", "bar", this.getClass().getMethod("test"))); } }
1,782
38.622222
83
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/ELSerializationContextInitializer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import org.infinispan.protostream.SerializationContextInitializer; import org.kohsuke.MetaInfServices; import org.wildfly.clustering.marshalling.protostream.CompositeSerializationContextInitializer; /** * @author Paul Ferraro */ @MetaInfServices(SerializationContextInitializer.class) public class ELSerializationContextInitializer extends CompositeSerializationContextInitializer { public ELSerializationContextInitializer() { super(ELSerializationContextInitializerProvider.class); } }
1,578
39.487179
97
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/ELMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; /** * @author Paul Ferraro */ public enum ELMarshallerProvider implements ProtoStreamMarshallerProvider { METHOD_EXPRESSION_IMPL(new MethodExpressionImplMarshaller()), METHOD_EXPRESSION_LITERAL(new MethodExpressionLiteralMarshaller()), VALUE_EXPRESSION_IMPL(new ValueExpressionImplMarshaller()), VALUE_EXPRESSION_LITERAL(new ValueExpressionLiteralMarshaller()), ; private final ProtoStreamMarshaller<?> marshaller; ELMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
1,893
37.653061
84
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/MethodExpressionImplMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import java.io.IOException; import java.lang.reflect.Field; import java.security.PrivilegedAction; import java.util.LinkedList; import java.util.List; import org.glassfish.expressly.MethodExpressionImpl; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.clustering.marshalling.protostream.SimpleObjectOutput; import org.wildfly.security.manager.WildFlySecurityManager; import jakarta.el.FunctionMapper; import jakarta.el.VariableMapper; /** * {@link ProtoStreamMarshaller} for a {@link MethodExpressionImpl}. * @author Paul Ferraro */ public class MethodExpressionImplMarshaller implements ProtoStreamMarshaller<MethodExpressionImpl> { private static final int EXPRESSION_INDEX = 1; private static final int EXPECTED_TYPE_INDEX = 2; private static final int FUNCTION_MAPPER_INDEX = 3; private static final int VARIABLE_MAPPER_INDEX = 4; private static final int PARAMETER_TYPE_INDEX = 5; private static final Field EXPECTED_TYPE_FIELD = getField(Class.class); private static final Field PARAMETER_TYPES_FIELD = getField(Class[].class); private static Field getField(Class<?> targetType) { return WildFlySecurityManager.doUnchecked(new PrivilegedAction<Field>() { @Override public Field run() { for (Field field : MethodExpressionImpl.class.getDeclaredFields()) { if (field.getType() == targetType) { field.setAccessible(true); return field; } } throw new IllegalStateException(); } }); } @Override public Class<? extends MethodExpressionImpl> getJavaClass() { return MethodExpressionImpl.class; } @Override public MethodExpressionImpl readFrom(ProtoStreamReader reader) throws IOException { String expression = null; Class<?> expectedType = null; FunctionMapper functionMapper = null; VariableMapper variableMapper = null; List<Class<?>> parameterTypes = new LinkedList<>(); while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case EXPRESSION_INDEX: expression = reader.readString(); break; case EXPECTED_TYPE_INDEX: expectedType = reader.readAny(Class.class); break; case FUNCTION_MAPPER_INDEX: functionMapper = reader.readAny(FunctionMapper.class); break; case VARIABLE_MAPPER_INDEX: variableMapper = reader.readAny(VariableMapper.class); break; case PARAMETER_TYPE_INDEX: parameterTypes.add(reader.readAny(Class.class)); break; default: reader.skipField(tag); } } return new MethodExpressionImpl(expression, null, functionMapper, variableMapper, expectedType, parameterTypes.toArray(new Class<?>[0])); } @Override public void writeTo(ProtoStreamWriter writer, MethodExpressionImpl value) throws IOException { String[] strings = new String[2]; Object[] objects = new Object[3]; value.writeExternal(new SimpleObjectOutput.Builder().with(strings).with(objects).build()); String expression = value.getExpressionString(); if (expression != null) { writer.writeString(EXPRESSION_INDEX, expression); } Class<?> expectedType = getValue(value, EXPECTED_TYPE_FIELD, Class.class); if (expectedType != null) { writer.writeAny(EXPECTED_TYPE_INDEX, expectedType); } Class<?>[] parameterTypes = getValue(value, PARAMETER_TYPES_FIELD, Class[].class); for (Class<?> parameterType : parameterTypes) { writer.writeAny(PARAMETER_TYPE_INDEX, parameterType); } Object functionMapper = objects[1]; if (functionMapper != null) { writer.writeAny(FUNCTION_MAPPER_INDEX, functionMapper); } Object variableMapper = objects[2]; if (variableMapper != null) { writer.writeAny(VARIABLE_MAPPER_INDEX, variableMapper); } } private static <T> T getValue(MethodExpressionImpl value, Field field, Class<T> targetClass) { return WildFlySecurityManager.doUnchecked(new PrivilegedAction<T>() { @Override public T run() { try { return targetClass.cast(field.get(value)); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } } }); } }
6,133
39.893333
145
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/ELSerializationContextInitializerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import org.infinispan.protostream.SerializationContextInitializer; import org.wildfly.clustering.el.expressly.lang.ELLangMarshallerProvider; import org.wildfly.clustering.marshalling.protostream.ProviderSerializationContextInitializer; import org.wildfly.clustering.marshalling.protostream.SerializationContextInitializerProvider; /** * @author Paul Ferraro */ public enum ELSerializationContextInitializerProvider implements SerializationContextInitializerProvider { EL(new ProviderSerializationContextInitializer<>("org.glassfish.expressly.proto", ELMarshallerProvider.class)), EL_LANG(new ProviderSerializationContextInitializer<>("org.glassfish.expressly.lang.proto", ELLangMarshallerProvider.class)), ; private final SerializationContextInitializer initializer; ELSerializationContextInitializerProvider(SerializationContextInitializer initializer) { this.initializer = initializer; } @Override public SerializationContextInitializer getInitializer() { return this.initializer; } }
2,116
41.34
129
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/MethodExpressionLiteralMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import java.io.IOException; import java.lang.reflect.Field; import java.security.PrivilegedAction; import java.util.LinkedList; import java.util.List; import org.glassfish.expressly.MethodExpressionLiteral; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.security.manager.WildFlySecurityManager; /** * {@link ProtoStreamMarshaller} for a {@link MethodExpressionLiteral}. * @author Paul Ferraro */ public class MethodExpressionLiteralMarshaller implements ProtoStreamMarshaller<MethodExpressionLiteral> { private static final int EXPRESSION_INDEX = 1; private static final int EXPECTED_TYPE_INDEX = 2; private static final int PARAMETER_TYPE_INDEX = 3; private static final Field EXPECTED_TYPE_FIELD = getField(Class.class); private static final Field PARAMETER_TYPES_FIELD = getField(Class[].class); private static Field getField(Class<?> targetType) { return WildFlySecurityManager.doUnchecked(new PrivilegedAction<Field>() { @Override public Field run() { for (Field field : MethodExpressionLiteral.class.getDeclaredFields()) { if (field.getType() == targetType) { field.setAccessible(true); return field; } } throw new IllegalStateException(); } }); } @Override public Class<? extends MethodExpressionLiteral> getJavaClass() { return MethodExpressionLiteral.class; } @Override public MethodExpressionLiteral readFrom(ProtoStreamReader reader) throws IOException { String expression = null; Class<?> expectedType = null; List<Class<?>> parameterTypes = new LinkedList<>(); while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case EXPRESSION_INDEX: expression = reader.readString(); break; case EXPECTED_TYPE_INDEX: expectedType = reader.readAny(Class.class); break; case PARAMETER_TYPE_INDEX: parameterTypes.add(reader.readAny(Class.class)); break; default: reader.skipField(tag); } } return new MethodExpressionLiteral(expression, expectedType, parameterTypes.toArray(new Class<?>[0])); } @Override public void writeTo(ProtoStreamWriter writer, MethodExpressionLiteral value) throws IOException { String expression = value.getExpressionString(); if (expression != null) { writer.writeString(EXPRESSION_INDEX, expression); } Class<?> expectedType = getValue(value, EXPECTED_TYPE_FIELD, Class.class); if (expectedType != null) { writer.writeAny(EXPECTED_TYPE_INDEX, expectedType); } Class<?>[] parameterTypes = getValue(value, PARAMETER_TYPES_FIELD, Class[].class); if (parameterTypes.length > 0) { for (Class<?> parameterType : parameterTypes) { writer.writeAny(PARAMETER_TYPE_INDEX, parameterType); } } } private static <T> T getValue(MethodExpressionLiteral value, Field field, Class<T> targetClass) { return WildFlySecurityManager.doUnchecked(new PrivilegedAction<T>() { @Override public T run() { try { return targetClass.cast(field.get(value)); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } } }); } }
5,048
39.071429
110
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/ValueExpressionImplMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import java.io.IOException; import org.glassfish.expressly.ValueExpressionImpl; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.clustering.marshalling.protostream.SimpleObjectOutput; import jakarta.el.FunctionMapper; import jakarta.el.VariableMapper; /** * {@link ProtoStreamMarshaller} for a {@link ValueExpressionImpl}. * @author Paul Ferraro */ public class ValueExpressionImplMarshaller implements ProtoStreamMarshaller<ValueExpressionImpl> { private static final int EXPRESSION_INDEX = 1; private static final int EXPECTED_TYPE_INDEX = 2; private static final int FUNCTION_MAPPER_INDEX = 3; private static final int VARIABLE_MAPPER_INDEX = 4; @Override public Class<? extends ValueExpressionImpl> getJavaClass() { return ValueExpressionImpl.class; } @Override public ValueExpressionImpl readFrom(ProtoStreamReader reader) throws IOException { String expression = null; Class<?> expectedType = null; FunctionMapper functionMapper = null; VariableMapper variableMapper = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case EXPRESSION_INDEX: expression = reader.readString(); break; case EXPECTED_TYPE_INDEX: expectedType = reader.readAny(Class.class); break; case FUNCTION_MAPPER_INDEX: functionMapper = reader.readAny(FunctionMapper.class); break; case VARIABLE_MAPPER_INDEX: variableMapper = reader.readAny(VariableMapper.class); break; default: reader.skipField(tag); } } return new ValueExpressionImpl(expression, null, functionMapper, variableMapper, expectedType); } @Override public void writeTo(ProtoStreamWriter writer, ValueExpressionImpl value) throws IOException { String[] strings = new String[2]; Object[] objects = new Object[2]; value.writeExternal(new SimpleObjectOutput.Builder().with(strings).with(objects).build()); String expression = strings[0]; if (expression != null) { writer.writeString(EXPRESSION_INDEX, expression); } Class<?> expectedType = value.getExpectedType(); if (expectedType != null) { writer.writeAny(EXPECTED_TYPE_INDEX, expectedType); } Object functionMapper = objects[0]; if (functionMapper != null) { writer.writeAny(FUNCTION_MAPPER_INDEX, functionMapper); } Object variableMapper = objects[1]; if (variableMapper != null) { writer.writeAny(VARIABLE_MAPPER_INDEX, variableMapper); } } }
4,201
39.019048
103
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/ValueExpressionLiteralMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly; import java.io.IOException; import org.glassfish.expressly.ValueExpressionLiteral; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.clustering.marshalling.protostream.SimpleObjectOutput; /** * {@link ProtoStreamMarshaller} for a {@link ValueExpressionLiteral}. * @author Paul Ferraro */ public class ValueExpressionLiteralMarshaller implements ProtoStreamMarshaller<ValueExpressionLiteral> { private static final int VALUE_INDEX = 1; private static final int EXPECTED_TYPE_INDEX = 2; @Override public Class<? extends ValueExpressionLiteral> getJavaClass() { return ValueExpressionLiteral.class; } @Override public ValueExpressionLiteral readFrom(ProtoStreamReader reader) throws IOException { Object value = null; Class<?> expectedType = null; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case VALUE_INDEX: value = reader.readAny(); break; case EXPECTED_TYPE_INDEX: expectedType = reader.readAny(Class.class); break; default: reader.skipField(tag); } } return new ValueExpressionLiteral(value, expectedType); } @Override public void writeTo(ProtoStreamWriter writer, ValueExpressionLiteral literal) throws IOException { Object value = getValue(literal); if (value != null) { writer.writeAny(VALUE_INDEX, value); } Class<?> expectedType = literal.getExpectedType(); if (expectedType != null) { writer.writeAny(EXPECTED_TYPE_INDEX, expectedType); } } private static Object getValue(ValueExpressionLiteral literal) throws IOException { if (literal.getExpectedType() == null) { return literal.getValue(null); } Object[] objects = new Object[1]; literal.writeExternal(new SimpleObjectOutput.Builder().with(objects).build()); return objects[0]; } }
3,434
37.595506
104
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/lang/FunctionMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly.lang; import java.io.IOException; import java.lang.reflect.Method; import java.util.LinkedList; import java.util.List; import org.glassfish.expressly.lang.FunctionMapperImpl.Function; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.clustering.marshalling.protostream.SimpleObjectOutput; /** * @author Paul Ferraro */ public class FunctionMarshaller implements ProtoStreamMarshaller<Function> { private static final int PREFIX_INDEX = 1; private static final int LOCAL_NAME_INDEX = 2; private static final int DECLARING_CLASS_INDEX = 3; private static final int METHOD_NAME_INDEX = 4; private static final int PARAMETER_TYPE_INDEX = 5; @Override public Class<? extends Function> getJavaClass() { return Function.class; } @Override public Function readFrom(ProtoStreamReader reader) throws IOException { String prefix = null; String localName = null; Class<?> declaringClass = null; String methodName = null; List<Class<?>> parameterTypes = new LinkedList<>(); while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case PREFIX_INDEX: prefix = reader.readString(); break; case LOCAL_NAME_INDEX: localName = reader.readString(); break; case DECLARING_CLASS_INDEX: declaringClass = reader.readAny(Class.class); break; case METHOD_NAME_INDEX: methodName = reader.readString(); break; case PARAMETER_TYPE_INDEX: parameterTypes.add(reader.readAny(Class.class)); break; default: reader.skipField(tag); } } try { Method method = (declaringClass != null) ? declaringClass.getDeclaredMethod(methodName, parameterTypes.toArray(new Class<?>[0])) : null; return new Function(prefix, localName, method); } catch (NoSuchMethodException e) { throw new IllegalStateException(e); } } @Override public void writeTo(ProtoStreamWriter writer, Function function) throws IOException { String[] strings = new String[4]; function.writeExternal(new SimpleObjectOutput.Builder().with(strings).build()); String prefix = strings[0]; if (!prefix.isEmpty()) { writer.writeString(PREFIX_INDEX, prefix); } String localName = strings[1]; if (localName != null) { writer.writeString(LOCAL_NAME_INDEX, localName); } Method method = function.getMethod(); if (method != null) { writer.writeAny(DECLARING_CLASS_INDEX, method.getDeclaringClass()); writer.writeString(METHOD_NAME_INDEX, method.getName()); for (Class<?> parameterType : method.getParameterTypes()) { writer.writeAny(PARAMETER_TYPE_INDEX, parameterType); } } } }
4,466
38.530973
148
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/lang/FunctionMapperImplMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly.lang; import java.io.IOException; import java.lang.reflect.Method; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.glassfish.expressly.lang.FunctionMapperImpl; import org.glassfish.expressly.lang.FunctionMapperImpl.Function; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.clustering.marshalling.protostream.SimpleObjectOutput; /** * @author Paul Ferraro */ public class FunctionMapperImplMarshaller implements ProtoStreamMarshaller<FunctionMapperImpl> { private static final int FUNCTION_INDEX = 1; @Override public Class<? extends FunctionMapperImpl> getJavaClass() { return FunctionMapperImpl.class; } @Override public FunctionMapperImpl readFrom(ProtoStreamReader reader) throws IOException { List<Function> functions = new LinkedList<>(); while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case FUNCTION_INDEX: functions.add(reader.readObject(Function.class)); break; default: reader.skipField(tag); } } FunctionMapperImpl mapper = new FunctionMapperImpl(); for (Function function : functions) { String[] strings = new String[4]; function.writeExternal(new SimpleObjectOutput.Builder().with(strings).build()); String prefix = strings[0]; String localName = strings[1]; Method method = function.getMethod(); mapper.addFunction(!prefix.isEmpty() ? prefix : null, localName, method); } return mapper; } @Override public void writeTo(ProtoStreamWriter writer, FunctionMapperImpl value) throws IOException { Object[] objects = new Object[1]; value.writeExternal(new SimpleObjectOutput.Builder().with(objects).build()); @SuppressWarnings("unchecked") Map<String, Function> functions = (Map<String, Function>) objects[0]; if (functions != null) { for (Function function : functions.values()) { writer.writeObject(FUNCTION_INDEX, function); } } } }
3,553
37.630435
96
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/lang/VariableMapperImplMarshaller.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly.lang; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.glassfish.expressly.lang.VariableMapperImpl; import org.infinispan.protostream.descriptors.WireType; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.clustering.marshalling.protostream.SimpleObjectOutput; import jakarta.el.ValueExpression; /** * @author Paul Ferraro */ public class VariableMapperImplMarshaller implements ProtoStreamMarshaller<VariableMapperImpl> { private static final int VARIABLE_INDEX = 1; private static final int EXPRESSION_INDEX = 2; @Override public Class<? extends VariableMapperImpl> getJavaClass() { return VariableMapperImpl.class; } @Override public VariableMapperImpl readFrom(ProtoStreamReader reader) throws IOException { List<String> variables = new LinkedList<>(); List<ValueExpression> expressions = new LinkedList<>(); while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case VARIABLE_INDEX: variables.add(reader.readString()); break; case EXPRESSION_INDEX: expressions.add(reader.readAny(ValueExpression.class)); break; default: reader.skipField(tag); } } VariableMapperImpl mapper = new VariableMapperImpl(); Iterator<String> variableIterator = variables.iterator(); Iterator<ValueExpression> expressionIterator = expressions.iterator(); while (variableIterator.hasNext() && expressionIterator.hasNext()) { String variable = variableIterator.next(); ValueExpression expression = expressionIterator.next(); mapper.setVariable(variable, expression); } return mapper; } @Override public void writeTo(ProtoStreamWriter writer, VariableMapperImpl value) throws IOException { Object[] objects = new Object[1]; value.writeExternal(new SimpleObjectOutput.Builder().with(objects).build()); @SuppressWarnings("unchecked") Map<String, ValueExpression> expressions = (Map<String, ValueExpression>) objects[0]; if (expressions != null) { for (Map.Entry<String, ValueExpression> entry : expressions.entrySet()) { writer.writeString(VARIABLE_INDEX, entry.getKey()); writer.writeAny(EXPRESSION_INDEX, entry.getValue()); } } } }
3,873
39.354167
96
java
null
wildfly-main/clustering/el/expressly/src/main/java/org/wildfly/clustering/el/expressly/lang/ELLangMarshallerProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.wildfly.clustering.el.expressly.lang; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; /** * @author Paul Ferraro */ public enum ELLangMarshallerProvider implements ProtoStreamMarshallerProvider { FUNCTION(new FunctionMarshaller()), FUNCTION_MAPPER_IMPL(new FunctionMapperImplMarshaller()), VARIABLE_MAPPER_IMPL(new VariableMapperImplMarshaller()), ; private final ProtoStreamMarshaller<?> marshaller; ELLangMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
1,798
36.479167
84
java
null
wildfly-main/clustering/infinispan/extension/src/test/java/org/jboss/as/clustering/infinispan/subsystem/OperationSequencesTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILED; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILURE_DESCRIPTION; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.dmr.ModelNode; import org.junit.Assert; import org.junit.Test; /** * Test case for testing sequences of management operations. * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class OperationSequencesTestCase extends OperationTestCaseBase { @Test public void testCacheContainerAddRemoveAddSequence() throws Exception { // Parse and install the XML into the controller String subsystemXml = getSubsystemXml() ; KernelServices servicesA = this.createKernelServicesBuilder().setSubsystemXml(subsystemXml).build(); ModelNode addContainerOp = getCacheContainerAddOperation("maximal2"); ModelNode removeContainerOp = getCacheContainerRemoveOperation("maximal2"); ModelNode addCacheOp = getCacheAddOperation("maximal2", LocalCacheResourceDefinition.WILDCARD_PATH.getKey(), "fred"); // add a cache container ModelNode result = servicesA.executeOperation(addContainerOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // add a local cache result = servicesA.executeOperation(addCacheOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // remove the cache container result = servicesA.executeOperation(removeContainerOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // add the same cache container result = servicesA.executeOperation(addContainerOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // add the same local cache result = servicesA.executeOperation(addCacheOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); } @Test public void testCacheContainerRemoveRemoveSequence() throws Exception { // Parse and install the XML into the controller String subsystemXml = getSubsystemXml() ; KernelServices servicesA = this.createKernelServicesBuilder().setSubsystemXml(subsystemXml).build(); ModelNode addContainerOp = getCacheContainerAddOperation("maximal2"); ModelNode removeContainerOp = getCacheContainerRemoveOperation("maximal2"); ModelNode addCacheOp = getCacheAddOperation("maximal2", LocalCacheResourceDefinition.WILDCARD_PATH.getKey(), "fred"); // add a cache container ModelNode result = servicesA.executeOperation(addContainerOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // add a local cache result = servicesA.executeOperation(addCacheOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // remove the cache container result = servicesA.executeOperation(removeContainerOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // remove the cache container again result = servicesA.executeOperation(removeContainerOp); Assert.assertEquals(result.toString(), FAILED, result.get(OUTCOME).asString()); } @Test public void testLocalCacheAddRemoveAddSequence() throws Exception { // Parse and install the XML into the controller String subsystemXml = getSubsystemXml() ; KernelServices servicesA = this.createKernelServicesBuilder().setSubsystemXml(subsystemXml).build(); ModelNode addOp = getCacheAddOperation("maximal", LocalCacheResourceDefinition.WILDCARD_PATH.getKey(), "fred"); ModelNode removeOp = getCacheRemoveOperation("maximal", LocalCacheResourceDefinition.WILDCARD_PATH.getKey(), "fred"); // add a local cache ModelNode result = servicesA.executeOperation(addOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // remove the local cache result = servicesA.executeOperation(removeOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // add the same local cache result = servicesA.executeOperation(addOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); } @Test public void testLocalCacheRemoveRemoveSequence() throws Exception { // Parse and install the XML into the controller String subsystemXml = getSubsystemXml() ; KernelServices servicesA = this.createKernelServicesBuilder().setSubsystemXml(subsystemXml).build(); ModelNode addOp = getCacheAddOperation("maximal", LocalCacheResourceDefinition.WILDCARD_PATH.getKey(), "fred"); ModelNode removeOp = getCacheRemoveOperation("maximal", LocalCacheResourceDefinition.WILDCARD_PATH.getKey(), "fred"); // add a local cache ModelNode result = servicesA.executeOperation(addOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // remove the local cache result = servicesA.executeOperation(removeOp); Assert.assertEquals(result.get(FAILURE_DESCRIPTION).asString(), SUCCESS, result.get(OUTCOME).asString()); // remove the same local cache result = servicesA.executeOperation(removeOp); Assert.assertEquals(result.toString(), FAILED, result.get(OUTCOME).asString()); } }
7,167
47.432432
125
java
null
wildfly-main/clustering/infinispan/extension/src/test/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanSubsystemInitialization.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import org.jboss.as.clustering.jgroups.subsystem.JGroupsSubsystemInitialization; import org.jboss.as.connector.subsystems.datasources.DataSourcesExtension; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.RunningMode; import org.jboss.as.controller.capability.registry.RuntimeCapabilityRegistry; import org.jboss.as.controller.extension.ExtensionRegistry; import org.jboss.as.controller.extension.ExtensionRegistryType; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.Resource; /** * @author Paul Ferraro */ public class InfinispanSubsystemInitialization extends JGroupsSubsystemInitialization { private static final long serialVersionUID = -8991959025968193007L; public InfinispanSubsystemInitialization() { super(); } public InfinispanSubsystemInitialization(RunningMode mode) { super(mode); } @Override protected void initializeExtraSubystemsAndModel(ExtensionRegistry registry, Resource root, ManagementResourceRegistration registration, RuntimeCapabilityRegistry capabilityRegistry) { new DataSourcesExtension().initialize(registry.getExtensionContext("datasources", registration, ExtensionRegistryType.MASTER)); Resource subsystem = Resource.Factory.create(); root.registerChild(PathElement.pathElement(SUBSYSTEM, DataSourcesExtension.SUBSYSTEM_NAME), subsystem); Resource dataSource = Resource.Factory.create(); subsystem.registerChild(PathElement.pathElement("data-source", "ExampleDS"), dataSource); dataSource.getModel().get("jndi-name").set("java:jboss/jdbc/store"); super.initializeExtraSubystemsAndModel(registry, root, registration, capabilityRegistry); } }
2,943
44.292308
187
java
null
wildfly-main/clustering/infinispan/extension/src/test/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanTransformersTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.EnumSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.jboss.as.clustering.controller.CommonRequirement; import org.jboss.as.clustering.controller.CommonUnaryRequirement; import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition; import org.jboss.as.clustering.jgroups.subsystem.JGroupsSubsystemInitialization; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.as.model.test.FailedOperationTransformationConfig; import org.jboss.as.model.test.ModelFixer; import org.jboss.as.model.test.ModelTestControllerVersion; import org.jboss.as.model.test.ModelTestUtils; import org.jboss.as.server.ServerEnvironment; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.as.subsystem.test.KernelServicesBuilder; import org.jboss.dmr.ModelNode; import org.jgroups.conf.ClassConfigurator; import org.junit.Assert; import org.junit.Test; import org.wildfly.clustering.jgroups.spi.JGroupsDefaultRequirement; import org.wildfly.clustering.jgroups.spi.JGroupsRequirement; /** * Test cases for transformers used in the Infinispan subsystem * * Here we perform two types of tests: * - testing transformation between the current model and legacy models, in the case * where no rejections are expected, but certain discards/conversions/renames are expected * - testing transformation between the current model and legacy models, in the case * where specific rejections are expected * * @author <a href="tomaz.cerar@redhat.com">Tomaz Cerar</a> * @author Richard Achmatowicz (c) 2011 Red Hat Inc. * @author Radoslav Husar */ public class InfinispanTransformersTestCase extends OperationTestCaseBase { private static String formatArtifact(String pattern, ModelTestControllerVersion version) { return String.format(pattern, version.getMavenGavVersion()); } private static InfinispanSubsystemModel getModelVersion(ModelTestControllerVersion controllerVersion) { switch (controllerVersion) { case EAP_7_4_0: return InfinispanSubsystemModel.VERSION_14_0_0; default: throw new IllegalArgumentException(); } } private static String[] getDependencies(ModelTestControllerVersion version) { switch (version) { case EAP_7_4_0: return new String[] { "org.jboss.spec.javax.transaction:jboss-transaction-api_1.3_spec:2.0.0.Final", "org.jboss.spec.javax.resource:jboss-connector-api_1.7_spec:2.0.0.Final", formatArtifact("org.jboss.eap:wildfly-clustering-infinispan-extension:%s", version), "org.infinispan:infinispan-commons:11.0.9.Final-redhat-00001", "org.infinispan:infinispan-core:11.0.9.Final-redhat-00001", "org.infinispan:infinispan-cachestore-jdbc:11.0.9.Final-redhat-00001", "org.infinispan:infinispan-client-hotrod:11.0.9.Final-redhat-00001", "org.jboss.spec.javax.resource:jboss-connector-api_1.7_spec:2.0.0.Final-redhat-00001", // Following are needed for InfinispanSubsystemInitialization formatArtifact("org.jboss.eap:wildfly-clustering-api:%s", version), formatArtifact("org.jboss.eap:wildfly-clustering-common:%s", version), formatArtifact("org.jboss.eap:wildfly-clustering-infinispan-client:%s", version), formatArtifact("org.jboss.eap:wildfly-clustering-infinispan-spi:%s", version), formatArtifact("org.jboss.eap:wildfly-clustering-jgroups-extension:%s", version), formatArtifact("org.jboss.eap:wildfly-clustering-jgroups-spi:%s", version), formatArtifact("org.jboss.eap:wildfly-clustering-server:%s", version), formatArtifact("org.jboss.eap:wildfly-clustering-service:%s", version), formatArtifact("org.jboss.eap:wildfly-clustering-singleton-api:%s", version), formatArtifact("org.jboss.eap:wildfly-clustering-spi:%s", version), formatArtifact("org.jboss.eap:wildfly-connector:%s", version), }; default: { throw new IllegalArgumentException(); } } } @Override AdditionalInitialization createAdditionalInitialization() { return new InfinispanSubsystemInitialization() .require(CommonRequirement.PATH_MANAGER) .require(CommonUnaryRequirement.PATH, ServerEnvironment.SERVER_TEMP_DIR) .require(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING, "hotrod-server-1", "hotrod-server-2", "jdg1", "jdg2", "jdg3", "jdg4", "jdg5", "jdg6") .require(CommonUnaryRequirement.DATA_SOURCE, "ExampleDS") .require(CommonUnaryRequirement.SSL_CONTEXT, "hotrod-elytron") .require(JGroupsRequirement.CHANNEL_FACTORY, "maximal-channel") .require(JGroupsDefaultRequirement.CHANNEL_FACTORY) .require(CommonRequirement.LOCAL_TRANSACTION_PROVIDER) .require(TransactionResourceDefinition.TransactionRequirement.XA_RESOURCE_RECOVERY_REGISTRY) ; } @Test public void testTransformerEAP740() throws Exception { testTransformation(ModelTestControllerVersion.EAP_7_4_0); } private KernelServices buildKernelServices(String xml, ModelTestControllerVersion controllerVersion, ModelVersion version, String... mavenResourceURLs) throws Exception { KernelServicesBuilder builder = this.createKernelServicesBuilder().setSubsystemXml(xml); builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controllerVersion, version) .addMavenResourceURL(mavenResourceURLs) .addSingleChildFirstClass(InfinispanSubsystemInitialization.class) .addSingleChildFirstClass(JGroupsSubsystemInitialization.class) .addSingleChildFirstClass(org.jboss.as.clustering.subsystem.AdditionalInitialization.class) .addSingleChildFirstClass(ClassConfigurator.class) .skipReverseControllerCheck() .dontPersistXml(); KernelServices services = builder.build(); Assert.assertTrue(ModelTestControllerVersion.MASTER + " boot failed", services.isSuccessfulBoot()); Assert.assertTrue(controllerVersion.getMavenGavVersion() + " boot failed", services.getLegacyServices(version).isSuccessfulBoot()); return services; } private void testTransformation(final ModelTestControllerVersion controller) throws Exception { final ModelVersion version = getModelVersion(controller).getVersion(); final String[] dependencies = getDependencies(controller); final String subsystemXmlResource = String.format("subsystem-infinispan-transform-%d_%d_%d.xml", version.getMajor(), version.getMinor(), version.getMicro()); KernelServices services = this.buildKernelServices(readResource(subsystemXmlResource), controller, version, dependencies); // check that both versions of the legacy model are the same and valid checkSubsystemModelTransformation(services, version, createModelFixer(version), false); } private static ModelFixer createModelFixer(ModelVersion version) { return model -> { if (InfinispanSubsystemModel.VERSION_16_0_0.requiresTransformation(version)) { @SuppressWarnings("deprecation") Map<String, List<PathElement>> containers = Map.ofEntries(Map.entry("minimal", List.of(DistributedCacheResourceDefinition.pathElement("dist"))), Map.entry("maximal", List.of(DistributedCacheResourceDefinition.pathElement("dist"), LocalCacheResourceDefinition.pathElement("local"), ReplicatedCacheResourceDefinition.pathElement("cache-with-jdbc-store"), ScatteredCacheResourceDefinition.pathElement("scattered")))); for (Map.Entry<String, List<PathElement>> entry : containers.entrySet()) { PathElement containerPath = CacheContainerResourceDefinition.pathElement(entry.getKey()); ModelNode containerModel = model.get(containerPath.getKeyValuePair()); containerModel.get("module").set(new ModelNode()); for (PathElement cachePath : entry.getValue()) { ModelNode cacheModel = containerModel.get(cachePath.getKey()).get(cachePath.getValue()); cacheModel.get("module").set(new ModelNode()); if (cacheModel.hasDefined(HeapMemoryResourceDefinition.PATH.getKeyValuePair())) { ModelNode memoryModel = cacheModel.get(HeapMemoryResourceDefinition.PATH.getKeyValuePair()); memoryModel.get("max-entries").set(new ModelNode()); } if (cacheModel.hasDefined(JDBCStoreResourceDefinition.PATH.getKeyValuePair())) { ModelNode storeModel = cacheModel.get(JDBCStoreResourceDefinition.PATH.getKeyValuePair()); storeModel.get("datasource").set(new ModelNode()); if (storeModel.hasDefined(StringTableResourceDefinition.PATH.getKeyValuePair())) { ModelNode tableModel = storeModel.get(StringTableResourceDefinition.PATH.getKeyValuePair()); tableModel.get("batch-size").set(new ModelNode()); } } } for (ScheduledThreadPoolResourceDefinition pool : EnumSet.allOf(ScheduledThreadPoolResourceDefinition.class)) { if (containerModel.hasDefined(pool.getPathElement().getKeyValuePair())) { ModelNode poolModel = containerModel.get(pool.getPathElement().getKeyValuePair()); poolModel.get("max-threads").set(new ModelNode()); } } } } return model; }; } @Test public void testRejectionsEAP740() throws Exception { testRejections(ModelTestControllerVersion.EAP_7_4_0); } private void testRejections(final ModelTestControllerVersion controller) throws Exception { final ModelVersion version = getModelVersion(controller).getVersion(); final String[] dependencies = getDependencies(controller); // create builder for current subsystem version KernelServicesBuilder builder = this.createKernelServicesBuilder(); // initialize the legacy services builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controller, version) .addSingleChildFirstClass(InfinispanSubsystemInitialization.class) .addSingleChildFirstClass(JGroupsSubsystemInitialization.class) .addSingleChildFirstClass(org.jboss.as.clustering.subsystem.AdditionalInitialization.class) .addSingleChildFirstClass(ClassConfigurator.class) .addMavenResourceURL(dependencies) //TODO storing the model triggers the weirdness mentioned in SubsystemTestDelegate.LegacyKernelServiceInitializerImpl.install() //which is strange since it should be loading it all from the current jboss modules //Also this works in several other tests .dontPersistXml(); KernelServices services = builder.build(); KernelServices legacyServices = services.getLegacyServices(version); Assert.assertNotNull(legacyServices); Assert.assertTrue("main services did not boot", services.isSuccessfulBoot()); Assert.assertTrue(legacyServices.isSuccessfulBoot()); // test failed operations involving backups List<ModelNode> operations = builder.parseXmlResource("subsystem-infinispan-transformer-reject.xml"); ModelTestUtils.checkFailedTransformedBootOperations(services, version, operations, createFailedOperationConfig(version)); } private static FailedOperationTransformationConfig createFailedOperationConfig(ModelVersion version) { FailedOperationTransformationConfig config = new FailedOperationTransformationConfig(); PathAddress subsystemAddress = PathAddress.pathAddress(InfinispanSubsystemResourceDefinition.PATH); PathAddress containerAddress = subsystemAddress.append(CacheContainerResourceDefinition.WILDCARD_PATH); PathAddress remoteContainerAddress = subsystemAddress.append(RemoteCacheContainerResourceDefinition.WILDCARD_PATH); List<String> rejectedRemoteContainerAttributes = new LinkedList<>(); if (InfinispanSubsystemModel.VERSION_16_0_0.requiresTransformation(version)) { config.addFailedAttribute(containerAddress.append(ReplicatedCacheResourceDefinition.pathElement("repl"), PartitionHandlingResourceDefinition.PATH), new FailedOperationTransformationConfig.NewAttributesConfig(PartitionHandlingResourceDefinition.Attribute.MERGE_POLICY.getDefinition())); config.addFailedAttribute(containerAddress.append(DistributedCacheResourceDefinition.pathElement("dist"), PartitionHandlingResourceDefinition.PATH), new FailedOperationTransformationConfig.NewAttributesConfig(PartitionHandlingResourceDefinition.Attribute.WHEN_SPLIT.getDefinition())); } if (InfinispanSubsystemModel.VERSION_15_0_0.requiresTransformation(version)) { config.addFailedAttribute(containerAddress, new FailedOperationTransformationConfig.NewAttributesConfig(CacheContainerResourceDefinition.Attribute.MARSHALLER.getDefinition())); rejectedRemoteContainerAttributes.add(RemoteCacheContainerResourceDefinition.Attribute.MARSHALLER.getName()); } if (InfinispanSubsystemModel.VERSION_14_0_0.requiresTransformation(version)) { rejectedRemoteContainerAttributes.add(RemoteCacheContainerResourceDefinition.ListAttribute.MODULES.getName()); } if (!rejectedRemoteContainerAttributes.isEmpty()) { config.addFailedAttribute(remoteContainerAddress, new FailedOperationTransformationConfig.NewAttributesConfig(rejectedRemoteContainerAttributes.toArray(new String[rejectedRemoteContainerAttributes.size()]))); } return config; } }
15,864
60.019231
297
java
null
wildfly-main/clustering/infinispan/extension/src/test/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanSubsystemTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.EnumSet; import java.util.Properties; import org.jboss.as.clustering.controller.CommonRequirement; import org.jboss.as.clustering.controller.CommonUnaryRequirement; import org.jboss.as.clustering.jgroups.subsystem.JGroupsSubsystemResourceDefinition; import org.jboss.as.subsystem.test.AbstractSubsystemSchemaTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.dmr.ModelNode; import org.jboss.dmr.Property; import org.junit.Assert; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.wildfly.clustering.jgroups.spi.JGroupsDefaultRequirement; /** * Tests parsing / booting / marshalling of Infinispan configurations. * * The current XML configuration is tested, along with supported legacy configurations. * * @author <a href="kabir.khan@jboss.com">Kabir Khan</a> * @author Richard Achmatowicz (c) 2013 Red Hat Inc. */ @RunWith(value = Parameterized.class) public class InfinispanSubsystemTestCase extends AbstractSubsystemSchemaTest<InfinispanSubsystemSchema> { @Parameters public static Iterable<InfinispanSubsystemSchema> parameters() { return EnumSet.allOf(InfinispanSubsystemSchema.class); } private final InfinispanSubsystemSchema schema; public InfinispanSubsystemTestCase(InfinispanSubsystemSchema schema) { super(InfinispanExtension.SUBSYSTEM_NAME, new InfinispanExtension(), schema, InfinispanSubsystemSchema.CURRENT); this.schema = schema; } @Override protected String getSubsystemXsdPathPattern() { return "schema/jboss-as-%s_%d_%d.xsd"; } @Override protected AdditionalInitialization createAdditionalInitialization() { return new InfinispanSubsystemInitialization() .require(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING, "hotrod-server-1", "hotrod-server-2") .require(CommonUnaryRequirement.DATA_SOURCE, "ExampleDS") .require(CommonUnaryRequirement.PATH, "jboss.server.temp.dir") .require(JGroupsDefaultRequirement.CHANNEL_FACTORY) .require(CommonRequirement.LOCAL_TRANSACTION_PROVIDER) .require(TransactionResourceDefinition.TransactionRequirement.XA_RESOURCE_RECOVERY_REGISTRY) ; } @Override protected void compare(ModelNode model1, ModelNode model2) { purgeJGroupsModel(model1); purgeJGroupsModel(model2); super.compare(model1, model2); } private static void purgeJGroupsModel(ModelNode model) { model.get(JGroupsSubsystemResourceDefinition.PATH.getKey()).remove(JGroupsSubsystemResourceDefinition.PATH.getValue()); } @Override protected Properties getResolvedProperties() { Properties properties = new Properties(); properties.put("java.io.tmpdir", "/tmp"); return properties; } @Override protected KernelServices standardSubsystemTest(String configId, String configIdResolvedModel, boolean compareXml, AdditionalInitialization additionalInit) throws Exception { KernelServices services = super.standardSubsystemTest(configId, configIdResolvedModel, compareXml, additionalInit); if (!this.schema.since(InfinispanSubsystemSchema.VERSION_1_5)) { ModelNode model = services.readWholeModel(); Assert.assertTrue(model.get(InfinispanSubsystemResourceDefinition.PATH.getKey()).hasDefined(InfinispanSubsystemResourceDefinition.PATH.getValue())); ModelNode subsystem = model.get(InfinispanSubsystemResourceDefinition.PATH.getKeyValuePair()); for (Property containerProp : subsystem.get(CacheContainerResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) { Assert.assertTrue("cache-container=" + containerProp.getName(), containerProp.getValue().get(CacheContainerResourceDefinition.Attribute.STATISTICS_ENABLED.getName()).asBoolean()); for (String key : containerProp.getValue().keys()) { if (key.endsWith("-cache") && !key.equals("default-cache")) { ModelNode caches = containerProp.getValue().get(key); if (caches.isDefined()) { for (Property cacheProp : caches.asPropertyList()) { Assert.assertTrue("cache-container=" + containerProp.getName() + "," + key + "=" + cacheProp.getName(), containerProp.getValue().get(CacheResourceDefinition.Attribute.STATISTICS_ENABLED.getName()).asBoolean()); } } } } } } return services; } }
5,920
44.546154
177
java
null
wildfly-main/clustering/infinispan/extension/src/test/java/org/jboss/as/clustering/infinispan/subsystem/OperationTestCaseBase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.io.IOException; import java.util.Map; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.clustering.controller.CommonUnaryRequirement; import org.jboss.as.clustering.jgroups.subsystem.JGroupsSubsystemInitialization; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.subsystem.test.AbstractSubsystemTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServicesBuilder; import org.jboss.dmr.ModelNode; /** * Base test case for testing management operations. * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. * @author Radoslav Husar */ public class OperationTestCaseBase extends AbstractSubsystemTest { static final String SUBSYSTEM_XML_FILE = String.format("infinispan-%d.%d.xml", InfinispanSubsystemSchema.CURRENT.getVersion().major(), InfinispanSubsystemSchema.CURRENT.getVersion().minor()); public OperationTestCaseBase() { super(InfinispanExtension.SUBSYSTEM_NAME, new InfinispanExtension()); } KernelServicesBuilder createKernelServicesBuilder() { return this.createKernelServicesBuilder(this.createAdditionalInitialization()); } AdditionalInitialization createAdditionalInitialization() { return new JGroupsSubsystemInitialization() .require(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING, "hotrod-server-1", "hotrod-server-2") .require(CommonUnaryRequirement.DATA_SOURCE, "ExampleDS", "new-datasource") ; } // cache container access protected static ModelNode getCacheContainerAddOperation(String containerName) { PathAddress address = getCacheContainerAddress(containerName); return Util.createAddOperation(address, Map.of(CacheContainerResourceDefinition.Attribute.DEFAULT_CACHE.getName(), new ModelNode("default"))); } protected static ModelNode getCacheContainerReadOperation(String containerName, Attribute attribute) { return Util.getReadAttributeOperation(getCacheContainerAddress(containerName), attribute.getName()); } protected static ModelNode getCacheContainerWriteOperation(String containerName, Attribute attribute, String value) { PathAddress cacheAddress = getCacheContainerAddress(containerName); return Util.getWriteAttributeOperation(cacheAddress, attribute.getName(), new ModelNode(value)); } protected static ModelNode getCacheContainerRemoveOperation(String containerName) { PathAddress containerAddr = getCacheContainerAddress(containerName); return Util.createRemoveOperation(containerAddr); } // cache access protected static ModelNode getCacheAddOperation(String containerName, String cacheType, String cacheName) { PathAddress address = getCacheAddress(containerName, cacheType, cacheName); return Util.createAddOperation(address, Map.of()); } protected static ModelNode getCacheReadOperation(String containerName, String cacheType, String cacheName, Attribute attribute) { return Util.getReadAttributeOperation(getCacheAddress(containerName, cacheType, cacheName), attribute.getName()); } protected static ModelNode getCacheWriteOperation(String containerName, String cacheType, String cacheName, Attribute attribute, String value) { return Util.getWriteAttributeOperation(getCacheAddress(containerName, cacheType, cacheName), attribute.getName(), new ModelNode(value)); } protected static ModelNode getCacheRemoveOperation(String containerName, String cacheType, String cacheName) { return Util.createRemoveOperation(getCacheAddress(containerName, cacheType, cacheName)); } // cache store access protected static ModelNode getCacheStoreReadOperation(String containerName, String cacheType, String cacheName, Attribute attribute) { return Util.getReadAttributeOperation(getCustomCacheStoreAddress(containerName, cacheType, cacheName), attribute.getName()); } protected static ModelNode getCacheStoreWriteOperation(String containerName, String cacheName, String cacheType, Attribute attribute, String value) { return Util.getWriteAttributeOperation(getCustomCacheStoreAddress(containerName, cacheType, cacheName), attribute.getName(), new ModelNode(value)); } protected static ModelNode getJDBCCacheStoreReadOperation(String containerName, String cacheType, String cacheName, Attribute attribute) { return Util.getReadAttributeOperation(getJDBCCacheStoreAddress(containerName, cacheType, cacheName), attribute.getName()); } protected static ModelNode getJDBCCacheStoreWriteOperation(String containerName, String cacheType, String cacheName, Attribute attribute, String value) { return Util.getWriteAttributeOperation(getJDBCCacheStoreAddress(containerName, cacheType, cacheName), attribute.getName(), new ModelNode(value)); } // cache store property access protected static ModelNode getCacheStoreGetPropertyOperation(PathAddress cacheStoreAddress, String propertyName) { return Util.createMapGetOperation(cacheStoreAddress, StoreResourceDefinition.Attribute.PROPERTIES.getName(), propertyName); } protected static ModelNode getCacheStorePutPropertyOperation(PathAddress cacheStoreAddress, String propertyName, String propertyValue) { return Util.createMapPutOperation(cacheStoreAddress, StoreResourceDefinition.Attribute.PROPERTIES.getName(), propertyName, propertyValue); } protected static ModelNode getCacheStoreRemovePropertyOperation(PathAddress cacheStoreAddress, String propertyName) { return Util.createMapRemoveOperation(cacheStoreAddress, StoreResourceDefinition.Attribute.PROPERTIES.getName(), propertyName); } protected static ModelNode getCacheStoreClearPropertiesOperation(PathAddress cacheStoreAddress) { return Util.createMapClearOperation(cacheStoreAddress, StoreResourceDefinition.Attribute.PROPERTIES.getName()); } protected static ModelNode getCacheStoreUndefinePropertiesOperation(PathAddress cacheStoreAddress) { return Util.getUndefineAttributeOperation(cacheStoreAddress, StoreResourceDefinition.Attribute.PROPERTIES.getName()); } protected static PathAddress getJDBCCacheStoreAddress(String containerName, String cacheType, String cacheName) { return getCacheAddress(containerName, cacheType, cacheName).append(JDBCStoreResourceDefinition.PATH); } @SuppressWarnings("deprecation") protected static PathAddress getRemoteCacheStoreAddress(String containerName, String cacheType, String cacheName) { return getCacheAddress(containerName, cacheType, cacheName).append(RemoteStoreResourceDefinition.PATH); } protected static PathAddress getFileCacheStoreAddress(String containerName, String cacheType, String cacheName) { return getCacheAddress(containerName, cacheType, cacheName).append(FileStoreResourceDefinition.PATH); } protected static PathAddress getCustomCacheStoreAddress(String containerName, String cacheType, String cacheName) { return getCacheAddress(containerName, cacheType, cacheName).append(CustomStoreResourceDefinition.PATH); } protected static PathAddress getCacheContainerAddress(String containerName) { return PathAddress.pathAddress(InfinispanSubsystemResourceDefinition.PATH).append(CacheContainerResourceDefinition.pathElement(containerName)); } protected static PathAddress getCacheAddress(String containerName, String cacheType, String cacheName) { return getCacheContainerAddress(containerName).append(cacheType, cacheName); } protected String getSubsystemXml() throws IOException { return readResource(SUBSYSTEM_XML_FILE) ; } }
8,923
52.437126
195
java
null
wildfly-main/clustering/infinispan/extension/src/test/java/org/jboss/as/clustering/infinispan/subsystem/OperationsTestCase.java
package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.dmr.ModelNode; import org.junit.Assert; import org.junit.Test; /** * Test case for testing individual management operations. * * These test cases are based on the XML config in subsystem-infinispan-test, * a non-exhaustive subsystem configuration. * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class OperationsTestCase extends OperationTestCaseBase { /* * Tests access to cache container attributes */ @Test public void testCacheContainerReadWriteOperation() throws Exception { // Parse and install the XML into the controller String subsystemXml = getSubsystemXml(); KernelServices servicesA = this.createKernelServicesBuilder().setSubsystemXml(subsystemXml).build(); // read the cache container default cache attribute ModelNode result = servicesA.executeOperation(getCacheContainerReadOperation("maximal", CacheContainerResourceDefinition.Attribute.DEFAULT_CACHE)); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertEquals("local", result.get(RESULT).asString()); // write the default cache attribute result = servicesA.executeOperation(getCacheContainerWriteOperation("maximal", CacheContainerResourceDefinition.Attribute.DEFAULT_CACHE, "new-default-cache")); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); // re-read the default cache attribute result = servicesA.executeOperation(getCacheContainerReadOperation("maximal", CacheContainerResourceDefinition.Attribute.DEFAULT_CACHE)); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertEquals("new-default-cache", result.get(RESULT).asString()); } /* * Tests access to local cache attributes */ @Test public void testLocalCacheReadWriteOperation() throws Exception { // Parse and install the XML into the controller String subsystemXml = getSubsystemXml(); KernelServices servicesA = this.createKernelServicesBuilder().setSubsystemXml(subsystemXml).build(); ModelNode readOperation = getCacheReadOperation("maximal", LocalCacheResourceDefinition.WILDCARD_PATH.getKey(), "local", CacheResourceDefinition.Attribute.STATISTICS_ENABLED); // read the cache container batching attribute ModelNode result = servicesA.executeOperation(readOperation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertTrue(result.get(RESULT).asBoolean()); ModelNode writeOperation = getCacheWriteOperation("maximal", LocalCacheResourceDefinition.WILDCARD_PATH.getKey(), "local", CacheResourceDefinition.Attribute.STATISTICS_ENABLED, "false"); // write the batching attribute result = servicesA.executeOperation(writeOperation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); // re-read the batching attribute result = servicesA.executeOperation(readOperation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertFalse(result.get(RESULT).asBoolean()); } /* * Tests access to local cache attributes */ @Test public void testDistributedCacheJDBCStoreReadWriteOperation() throws Exception { // Parse and install the XML into the controller String subsystemXml = getSubsystemXml(); KernelServices servicesA = this.createKernelServicesBuilder().setSubsystemXml(subsystemXml).build(); // read the distributed cache mixed-keyed-jdbc-store datasource attribute ModelNode result = servicesA.executeOperation(getJDBCCacheStoreReadOperation("maximal", DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(), "dist", JDBCStoreResourceDefinition.Attribute.DATA_SOURCE)); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertEquals("ExampleDS", result.get(RESULT).asString()); // write the batching attribute result = servicesA.executeOperation(getJDBCCacheStoreWriteOperation("maximal", DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(), "dist", JDBCStoreResourceDefinition.Attribute.DATA_SOURCE, "new-datasource")); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); // re-read the batching attribute result = servicesA.executeOperation(getJDBCCacheStoreReadOperation("maximal", DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(), "dist", JDBCStoreResourceDefinition.Attribute.DATA_SOURCE)); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertEquals("new-datasource", result.get(RESULT).asString()); } @Test public void testStoreProperties() throws Exception { KernelServices services = this.createKernelServicesBuilder().setSubsystemXml(this.getSubsystemXml()).build(); PathAddress address = getRemoteCacheStoreAddress("maximal", InvalidationCacheResourceDefinition.WILDCARD_PATH.getKey(), "invalid"); String key = "infinispan.client.hotrod.ping_on_startup"; String value = "true"; ModelNode operation = Util.createMapPutOperation(address, StoreResourceDefinition.Attribute.PROPERTIES.getName(), key, value); ModelNode result = services.executeOperation(operation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertFalse(result.get(RESULT).isDefined()); operation = Util.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES.getName(), key); result = services.executeOperation(operation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertEquals(value, result.get(RESULT).asString()); operation = Util.createMapRemoveOperation(address, StoreResourceDefinition.Attribute.PROPERTIES.getName(), key); result = services.executeOperation(operation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertFalse(result.get(RESULT).isDefined()); operation = Util.createMapGetOperation(address, StoreResourceDefinition.Attribute.PROPERTIES.getName(), key); result = services.executeOperation(operation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertFalse(result.get(RESULT).isDefined()); } @Test public void testAliases() throws Exception { KernelServices services = this.createKernelServicesBuilder().setSubsystemXml(this.getSubsystemXml()).build(); PathAddress address = getCacheContainerAddress("minimal"); String alias = "alias0"; ModelNode operation = Util.createListAddOperation(address, CacheContainerResourceDefinition.ListAttribute.ALIASES.getName(), alias); ModelNode result = services.executeOperation(operation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertFalse(result.get(RESULT).isDefined()); operation = Util.createListGetOperation(address, CacheContainerResourceDefinition.ListAttribute.ALIASES.getName(), 0); result = services.executeOperation(operation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertEquals(new ModelNode(alias), result.get(RESULT)); operation = Util.createListRemoveOperation(address, CacheContainerResourceDefinition.ListAttribute.ALIASES.getName(), 0); result = services.executeOperation(operation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertFalse(result.get(RESULT).isDefined()); operation = Util.createListGetOperation(address, CacheContainerResourceDefinition.ListAttribute.ALIASES.getName(), 0); result = services.executeOperation(operation); Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString()); Assert.assertFalse(result.get(RESULT).isDefined()); } }
8,756
54.075472
224
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/manager/DefaultCacheContainerAdmin.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.manager; import java.util.EnumSet; import javax.security.auth.Subject; import org.infinispan.Cache; import org.infinispan.configuration.cache.Configuration; import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.manager.EmbeddedCacheManagerAdmin; /** * Custom {@link EmbeddedCacheManagerAdmin} that does not use on a GlobalConfigurationManager. * @author Paul Ferraro */ public class DefaultCacheContainerAdmin implements EmbeddedCacheManagerAdmin { private final EmbeddedCacheManager manager; public DefaultCacheContainerAdmin(EmbeddedCacheManager manager) { this.manager = manager; } @Override public void createTemplate(String name, Configuration configuration) { this.manager.defineConfiguration(name, configuration); } @Override public Configuration getOrCreateTemplate(String name, Configuration configuration) { Configuration existing = this.manager.getCacheConfiguration(name); return (existing != null) ? existing : this.manager.defineConfiguration(name, configuration); } @Override public void removeTemplate(String name) { this.manager.undefineConfiguration(name); } @Override public <K, V> Cache<K, V> createCache(String name, String template) { return this.createCache(name, this.manager.getCacheConfiguration(template)); } @Override public <K, V> Cache<K, V> getOrCreateCache(String name, String template) { return this.getOrCreateCache(name, this.manager.getCacheConfiguration(template)); } @Override public synchronized <K, V> Cache<K, V> createCache(String name, Configuration configuration) { this.createTemplate(name, configuration); return this.manager.getCache(name); } @Override public synchronized <K, V> Cache<K, V> getOrCreateCache(String name, Configuration configuration) { return (this.manager.getCacheConfiguration(name) != null) ? this.createCache(name, configuration) : this.manager.getCache(name); } @Override public void removeCache(String name) { this.manager.undefineConfiguration(name); } @Override public EmbeddedCacheManagerAdmin withFlags(AdminFlag... flags) { return this; } @Override public EmbeddedCacheManagerAdmin withFlags(EnumSet<AdminFlag> flags) { return this; } @Override public EmbeddedCacheManagerAdmin withSubject(Subject subject) { return this; } }
3,564
33.61165
136
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/manager/DefaultCacheContainer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.manager; import static org.infinispan.util.logging.Log.CONFIG; import java.security.PrivilegedAction; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.function.Function; import javax.security.auth.Subject; import org.infinispan.AdvancedCache; import org.infinispan.Cache; import org.infinispan.cache.impl.AbstractDelegatingAdvancedCache; import org.infinispan.commons.dataconversion.MediaType; import org.infinispan.commons.util.AggregatedClassLoader; import org.infinispan.configuration.cache.CacheMode; import org.infinispan.configuration.cache.Configuration; import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.manager.EmbeddedCacheManagerAdmin; import org.infinispan.manager.impl.AbstractDelegatingEmbeddedCacheManager; import org.infinispan.remoting.transport.Address; import org.infinispan.remoting.transport.LocalModeAddress; import org.jboss.as.clustering.infinispan.dataconversion.MediaTypeFactory; import org.jboss.modules.ModuleLoader; import org.wildfly.clustering.infinispan.marshall.EncoderRegistry; import org.wildfly.clustering.infinispan.marshalling.ByteBufferMarshallerFactory; import org.wildfly.clustering.infinispan.marshalling.MarshalledValueTranscoder; import org.wildfly.clustering.infinispan.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledKeyFactory; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledValueFactory; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.marshalling.spi.MarshalledValueFactory; import org.wildfly.security.manager.WildFlySecurityManager; /** * EmbeddedCacheManager decorator that overrides the default cache semantics of a cache manager. * @author Paul Ferraro */ public class DefaultCacheContainer extends AbstractDelegatingEmbeddedCacheManager { private final EmbeddedCacheManagerAdmin administrator; private final Function<ClassLoader, ByteBufferMarshaller> marshallerFactory; public DefaultCacheContainer(EmbeddedCacheManager container, ModuleLoader loader) { this(container, new ByteBufferMarshallerFactory(container.getCacheManagerConfiguration().serialization().marshaller().mediaType(), loader)); } private DefaultCacheContainer(EmbeddedCacheManager container, Function<ClassLoader, ByteBufferMarshaller> marshallerFactory) { super(container); this.administrator = new DefaultCacheContainerAdmin(this); this.marshallerFactory = marshallerFactory; } @Override public Address getAddress() { Address address = super.getAddress(); return (address != null) ? address : LocalModeAddress.INSTANCE; } @Override public Address getCoordinator() { Address coordinator = super.getCoordinator(); return (coordinator != null) ? coordinator : LocalModeAddress.INSTANCE; } @Override public List<Address> getMembers() { List<Address> members = super.getMembers(); return (members != null) ? members : Collections.singletonList(LocalModeAddress.INSTANCE); } @Override public void start() { // No-op. Lifecycle is managed by container } @Override public void stop() { // No-op. Lifecycle is managed by container } @Override public <K, V> Cache<K, V> getCache() { return this.getCache(this.cm.getCacheManagerConfiguration().defaultCacheName().orElseThrow(CONFIG::noDefaultCache)); } @Override public <K, V> Cache<K, V> getCache(String cacheName) { return this.getCache(cacheName, true); } @Override public <K, V> Cache<K, V> getCache(String cacheName, boolean createIfAbsent) { Cache<K, V> cache = this.cm.getCache(cacheName, createIfAbsent); if (cache == null) return null; Configuration configuration = cache.getCacheConfiguration(); CacheMode mode = configuration.clustering().cacheMode(); boolean hasStore = configuration.persistence().usingStores(); // Bypass deployment-specific media types for local cache w/out a store or if using a non-ProtoStream marshaller if ((!mode.isClustered() && !hasStore) || !this.cm.getCacheManagerConfiguration().serialization().marshaller().mediaType().equals(ProtoStreamMarshaller.MEDIA_TYPE)) { return new DefaultCache<>(this, cache); } ClassLoader loader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); Map.Entry<MediaType, MediaType> types = MediaTypeFactory.INSTANCE.apply(loader); MediaType keyType = types.getKey(); MediaType valueType = (!mode.isInvalidation() || hasStore) ? types.getValue() : MediaType.APPLICATION_OBJECT; @SuppressWarnings("deprecation") EncoderRegistry registry = (EncoderRegistry) this.cm.getGlobalComponentRegistry().getComponent(org.infinispan.marshall.core.EncoderRegistry.class); synchronized (registry) { boolean registerKeyMediaType = !registry.isConversionSupported(keyType, MediaType.APPLICATION_OBJECT); boolean registerValueMediaType = !registry.isConversionSupported(valueType, MediaType.APPLICATION_OBJECT); if (registerKeyMediaType || registerValueMediaType) { ClassLoader managerLoader = this.cm.getCacheManagerConfiguration().classLoader(); PrivilegedAction<ClassLoader> action = new PrivilegedAction<>() { @Override public ClassLoader run() { return new AggregatedClassLoader(List.of(loader, managerLoader)); } }; ByteBufferMarshaller marshaller = this.marshallerFactory.apply(WildFlySecurityManager.doUnchecked(action)); if (registerKeyMediaType) { MarshalledValueFactory<ByteBufferMarshaller> keyFactory = new ByteBufferMarshalledKeyFactory(marshaller); registry.registerTranscoder(new MarshalledValueTranscoder<>(keyType, keyFactory)); } if (registerValueMediaType) { MarshalledValueFactory<ByteBufferMarshaller> valueFactory = new ByteBufferMarshalledValueFactory(marshaller); registry.registerTranscoder(new MarshalledValueTranscoder<>(valueType, valueFactory)); } } return new DefaultCache<>(this, cache.getAdvancedCache().withMediaType(keyType, valueType)) { @Override public void stop() { super.stop(); if (registerKeyMediaType) { registry.unregisterTranscoder(keyType); } if (registerValueMediaType) { registry.unregisterTranscoder(valueType); } } }; } } @Override public Configuration defineConfiguration(String cacheName, Configuration configuration) { EmbeddedCacheManager manager = this.cm; PrivilegedAction<Configuration> action = new PrivilegedAction<>() { @Override public Configuration run() { return manager.defineConfiguration(cacheName, configuration); } }; return WildFlySecurityManager.doUnchecked(action); } @Override public Configuration defineConfiguration(String cacheName, String templateCacheName, Configuration configurationOverride) { EmbeddedCacheManager manager = this.cm; PrivilegedAction<Configuration> action = new PrivilegedAction<>() { @Override public Configuration run() { return manager.defineConfiguration(cacheName, templateCacheName, configurationOverride); } }; return WildFlySecurityManager.doUnchecked(action); } @Override public EmbeddedCacheManager startCaches(String... cacheNames) { super.startCaches(cacheNames); return this; } @Override public EmbeddedCacheManagerAdmin administration() { return this.administrator; } @Override public synchronized <K, V> Cache<K, V> createCache(String name, Configuration configuration) { return this.administrator.createCache(name, configuration); } @Override public EmbeddedCacheManager withSubject(Subject subject) { return new DefaultCacheContainer(this.cm.withSubject(subject), this.marshallerFactory); } @Override public boolean equals(Object object) { if (!(object instanceof EmbeddedCacheManager)) return false; return this.toString().equals(object.toString()); } @Override public int hashCode() { return this.toString().hashCode(); } @Override public String toString() { return this.getCacheManagerConfiguration().cacheManagerName(); } private static class DefaultCache<K, V> extends AbstractDelegatingAdvancedCache<K, V> { private final EmbeddedCacheManager manager; DefaultCache(EmbeddedCacheManager manager, Cache<K, V> cache) { this(manager, cache.getAdvancedCache()); } DefaultCache(EmbeddedCacheManager manager, AdvancedCache<K, V> cache) { super(cache); this.manager = manager; } @Override public EmbeddedCacheManager getCacheManager() { return this.manager; } @Override public boolean equals(Object object) { if (!(object instanceof Cache)) return false; Cache<?, ?> cache = (Cache<?, ?>) object; return this.manager.equals(cache.getCacheManager()) && this.getName().equals(cache.getName()); } @Override public int hashCode() { return this.cache.hashCode(); } @SuppressWarnings("unchecked") @Override public AdvancedCache rewrap(AdvancedCache delegate) { return new DefaultCache<>(this.manager, delegate); } } }
11,197
41.097744
174
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/logging/InfinispanLogger.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.logging; import static org.jboss.logging.Logger.Level.INFO; import static org.jboss.logging.Logger.Level.WARN; import java.util.Set; import org.infinispan.client.hotrod.exceptions.HotRodClientException; import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.LogMessage; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageLogger; /** * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> * @author Tristan Tarrant * @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a> */ @MessageLogger(projectCode = "WFLYCLINF", length = 4) public interface InfinispanLogger extends BasicLogger { String ROOT_LOGGER_CATEGORY = "org.jboss.as.clustering.infinispan"; /** * The root logger. */ InfinispanLogger ROOT_LOGGER = Logger.getMessageLogger(InfinispanLogger.class, ROOT_LOGGER_CATEGORY); /** * Logs an informational message indicating the Infinispan subsystem is being activated. */ @LogMessage(level = INFO) @Message(id = 1, value = "Activating Infinispan subsystem.") void activatingSubsystem(); /** * Logs an informational message indicating that a cache is being started. * * @param cacheName the name of the cache. * @param containerName the name of the cache container. */ @LogMessage(level = INFO) @Message(id = 2, value = "Started %s cache from %s container") void cacheStarted(String cacheName, String containerName); /** * Logs an informational message indicating that a cache is being stopped. * * @param cacheName the name of the cache. * @param containerName the name of the cache container. */ @LogMessage(level = INFO) @Message(id = 3, value = "Stopped %s cache from %s container") void cacheStopped(String cacheName, String containerName); /** * Logs a warning message indicating that the specified attribute of the specified element is no longer valid and will be ignored. */ // @LogMessage(level = WARN) // @Message(id = 4, value = "The '%s' attribute of the '%s' element is no longer supported and will be ignored") // void attributeDeprecated(String attribute, String element); /** * Logs a warning message indicating that the specified topology attribute of the transport element * is no longer valid */ // @LogMessage(level = WARN) // @Message(id = 5, value = "The '%s' attribute specified on the 'transport' element of a cache container is no longer valid" + // "; use the same attribute specified on the 'transport' element of corresponding JGroups stack instead") // void topologyAttributeDeprecated(String attribute); // @Message(id = 6, value = "Failed to locate a data source bound to %s") // OperationFailedException dataSourceJndiNameNotFound(String jndiName); // @Message(id = 7, value = "Failed to locate data source %s") // OperationFailedException dataSourceNotFound(String name); // /** // * Creates an exception indicating a failure to resolve the outbound socket binding represented by the // * {@code binding} parameter. // * // * @param cause the cause of the error. // * @param binding the outbound socket binding. // * // * @return a {@link org.jboss.as.controller.persistence.ConfigurationPersistenceException} for the error. // */ // @Message(id = 8, value = "Could not resolve destination address for outbound socket binding named '%s'") // InjectionException failedToInjectSocketBinding(@Cause UnknownHostException cause, OutboundSocketBinding binding); /** * Creates an exception indicating an invalid cache store. * * @param cause the cause of the error. * @param cacheStoreName the name of the cache store. * * @return an {@link IllegalArgumentException} for the error. */ @Message(id = 10, value = "%s is not a valid cache store") IllegalArgumentException invalidCacheStore(@Cause Throwable cause, String cacheStoreName); // @Message(id = 27, value = "Could not determine 'stack' attribute from JGroups subsystem") // String indeterminiteStack(); // @LogMessage(level = WARN) // @Message(id = 28, value = "Executor configuration '%s' was deprecated and will only be used to support legacy secondary hosts in the domain.") // void executorIgnored(String executorName); @LogMessage(level = INFO) @Message(id = 29, value = "Started remote cache container '%s'.") void remoteCacheContainerStarted(String remoteCacheContainer); @LogMessage(level = INFO) @Message(id = 30, value = "Stopped remote cache container '%s'.") void remoteCacheContainerStopped(String remoteCacheContainer); @Message(id = 31, value = "Specified HotRod protocol version %s does not support creating caches automatically. Cache named '%s' must be already created on the Infinispan Server!") HotRodClientException remoteCacheMustBeDefined(String protocolVersion, String remoteCacheName); // @LogMessage(level = INFO) // @Message(id = 32, value = "Getting remote cache named '%s'. If it does not exist a new cache will be created from configuration template named '%s'; null value uses default cache configuration on the Infinispan Server.") // void remoteCacheCreated(String remoteCacheName, String cacheConfiguration); @LogMessage(level = WARN) @Message(id = 33, value = "Attribute '%s' is configured to use a deprecated value: %s; use one of the following values instead: %s") void marshallerEnumValueDeprecated(String attributeName, Object attributeValue, Set<?> supportedValues); }
6,828
44.526667
226
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/client/ManagedRemoteCache.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.client; import java.net.SocketAddress; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.UnaryOperator; import javax.management.ObjectName; import jakarta.transaction.TransactionManager; import org.infinispan.client.hotrod.CacheTopologyInfo; import org.infinispan.client.hotrod.DataFormat; import org.infinispan.client.hotrod.Flag; import org.infinispan.client.hotrod.MetadataValue; import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCacheManager; import org.infinispan.client.hotrod.ServerStatistics; import org.infinispan.client.hotrod.StreamingRemoteCache; import org.infinispan.client.hotrod.configuration.Configuration; import org.infinispan.client.hotrod.impl.ClientStatistics; import org.infinispan.client.hotrod.impl.InternalRemoteCache; import org.infinispan.client.hotrod.impl.RemoteCacheSupport; import org.infinispan.client.hotrod.impl.operations.OperationsFactory; import org.infinispan.client.hotrod.impl.operations.PingResponse; import org.infinispan.client.hotrod.impl.operations.RetryAwareCompletionStage; import org.infinispan.commons.util.CloseableIterator; import org.infinispan.commons.util.CloseableIteratorCollection; import org.infinispan.commons.util.CloseableIteratorSet; import org.infinispan.commons.util.IntSet; import org.infinispan.query.dsl.Query; import org.reactivestreams.Publisher; import org.wildfly.clustering.Registrar; import org.wildfly.clustering.Registration; import org.wildfly.clustering.infinispan.client.RemoteCacheContainer; /** * {@link RemoteCache} decorator that handles registration on {@link #start()} and deregistration on {@link #stop()}. * @author Paul Ferraro */ public class ManagedRemoteCache<K, V> extends RemoteCacheSupport<K, V> implements InternalRemoteCache<K, V>, UnaryOperator<Registration> { private final Registrar<String> registrar; private final AtomicReference<Registration> registration; private final RemoteCacheContainer container; private final RemoteCacheManager manager; private final InternalRemoteCache<K, V> cache; public ManagedRemoteCache(RemoteCacheContainer container, RemoteCacheManager manager, RemoteCache<K, V> cache, Registrar<String> registrar) { this(container, manager, (InternalRemoteCache<K, V>) cache, registrar, new AtomicReference<>()); } private ManagedRemoteCache(RemoteCacheContainer container, RemoteCacheManager manager, InternalRemoteCache<K, V> cache, Registrar<String> registrar, AtomicReference<Registration> registration) { this.container = container; this.manager = manager; this.cache = cache; this.registrar = registrar; this.registration = registration; } @Override public boolean isTransactional() { return this.cache.isTransactional(); } @Override public TransactionManager getTransactionManager() { return this.cache.getTransactionManager(); } @Override public void start() { if (this.registration.getAndUpdate(this) == null) { this.cache.start(); } } @Override public Registration apply(Registration registration) { return (registration == null) ? this.registrar.register(this.getName()) : registration; } @Override public void stop() { try (Registration registration = this.registration.getAndSet(null)) { if (registration != null) { this.cache.stop(); } } } @Override public RemoteCacheContainer getRemoteCacheContainer() { return this.container; } @Deprecated @Override public RemoteCacheManager getRemoteCacheManager() { return this.manager; } @Override public void addClientListener(Object listener) { this.cache.addClientListener(listener); } @Override public void addClientListener(Object listener, Object[] filterFactoryParams, Object[] converterFactoryParams) { this.cache.addClientListener(listener, filterFactoryParams, converterFactoryParams); } @Override public ClientStatistics clientStatistics() { return this.cache.clientStatistics(); } @Override public CloseableIteratorSet<Entry<K, V>> entrySet(IntSet segments) { return this.cache.entrySet(segments); } @Override public <T> T execute(String taskName, Map<String, ?> params) { return this.cache.execute(taskName, params); } @Override public CacheTopologyInfo getCacheTopologyInfo() { return this.cache.getCacheTopologyInfo(); } @Override public DataFormat getDataFormat() { return this.cache.getDataFormat(); } @Deprecated @Override public Set<Object> getListeners() { return this.cache.getListeners(); } @Override public String getProtocolVersion() { return this.cache.getProtocolVersion(); } @Override public CloseableIteratorSet<K> keySet(IntSet segments) { return this.cache.keySet(segments); } @Override public void removeClientListener(Object listener) { this.cache.removeClientListener(listener); } @Override public CompletableFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version, long lifespanSeconds, TimeUnit lifespanTimeUnit, long maxIdle, TimeUnit maxIdleTimeUnit) { return this.cache.replaceWithVersionAsync(key, newValue, version, lifespanSeconds, lifespanTimeUnit, maxIdle, maxIdleTimeUnit); } @Override public CloseableIterator<Map.Entry<Object, Object>> retrieveEntries(String filterConverterFactory, Object[] filterConverterParams, Set<Integer> segments, int batchSize) { return this.cache.retrieveEntries(filterConverterFactory, filterConverterParams, segments, batchSize); } @Override public CloseableIterator<Map.Entry<Object, Object>> retrieveEntriesByQuery(Query<?> filterQuery, Set<Integer> segments, int batchSize) { return this.cache.retrieveEntriesByQuery(filterQuery, segments, batchSize); } @Override public CloseableIterator<Map.Entry<Object, MetadataValue<Object>>> retrieveEntriesWithMetadata(Set<Integer> segments, int batchSize) { return this.cache.retrieveEntriesWithMetadata(segments, batchSize); } @Override public <E> Publisher<Map.Entry<K, E>> publishEntries(String filterConverterFactory, Object[] filterConverterParams, Set<Integer> segments, int batchSize) { return this.cache.publishEntries(filterConverterFactory, filterConverterParams, segments, batchSize); } @Override public <E> Publisher<Map.Entry<K, E>> publishEntriesByQuery(Query<?> filterQuery, Set<Integer> segments, int batchSize) { return this.cache.publishEntriesByQuery(filterQuery, segments, batchSize); } @Override public Publisher<Map.Entry<K, MetadataValue<V>>> publishEntriesWithMetadata(Set<Integer> segments, int batchSize) { return this.cache.publishEntriesWithMetadata(segments, batchSize); } @Override public ServerStatistics serverStatistics() { return this.cache.serverStatistics(); } @Override public StreamingRemoteCache<K> streaming() { return this.cache.streaming(); } @Override public CloseableIteratorCollection<V> values(IntSet segments) { return this.cache.values(segments); } @Override public <T, U> InternalRemoteCache<T, U> withDataFormat(DataFormat dataFormat) { return new ManagedRemoteCache<>(this.container, this.manager, this.cache.withDataFormat(dataFormat), this.registrar, this.registration); } @Override public InternalRemoteCache<K, V> withFlags(Flag... flags) { return new ManagedRemoteCache<>(this.container, this.manager, this.cache.withFlags(flags), this.registrar, this.registration); } @Override public String getName() { return this.cache.getName(); } @Override public String getVersion() { return this.cache.getVersion(); } @Override public CompletableFuture<Void> clearAsync() { return this.cache.clearAsync(); } @Override public boolean isEmpty() { return this.cache.isEmpty(); } @Override public boolean containsValue(Object value) { return this.cache.containsValue(value); } @Override public CompletableFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.cache.computeAsync(key, remappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.cache.computeIfAbsentAsync(key, mappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.cache.computeIfPresentAsync(key, remappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<Boolean> containsKeyAsync(K key) { return this.cache.containsKeyAsync(key); } @Override public CompletableFuture<Map<K, V>> getAllAsync(Set<?> keys) { return this.cache.getAllAsync(keys); } @Override public CompletableFuture<V> getAsync(K key) { return this.cache.getAsync(key); } @Override public CompletableFuture<MetadataValue<V>> getWithMetadataAsync(K key) { return this.cache.getWithMetadataAsync(key); } @Override public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) { return this.cache.mergeAsync(key, value, remappingFunction, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit); } @Override public CompletableFuture<Void> putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.cache.putAllAsync(data, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.cache.putAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.cache.putIfAbsentAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> removeAsync(Object key) { return this.cache.removeAsync(key); } @Override public CompletableFuture<Boolean> removeAsync(Object key, Object value) { return this.cache.removeAsync(key, value); } @Override public CompletableFuture<Boolean> removeWithVersionAsync(K key, long version) { return this.cache.removeWithVersionAsync(key, version); } @Override public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { this.cache.replaceAll(function); } @Override public CompletableFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.cache.replaceAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.cache.replaceAsync(key, oldValue, newValue, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<Long> sizeAsync() { return this.cache.sizeAsync(); } @Override public CompletionStage<ServerStatistics> serverStatisticsAsync() { return this.cache.serverStatisticsAsync(); } @Override public CloseableIterator<K> keyIterator(IntSet segments) { return this.cache.keyIterator(segments); } @Override public CloseableIterator<Entry<K, V>> entryIterator(IntSet segments) { return this.cache.entryIterator(segments); } @Override public RetryAwareCompletionStage<MetadataValue<V>> getWithMetadataAsync(K key, SocketAddress preferredAddress) { return this.cache.getWithMetadataAsync(key, preferredAddress); } @Override public boolean hasForceReturnFlag() { return this.cache.hasForceReturnFlag(); } @Override public void resolveStorage(boolean objectStorage) { this.cache.resolveStorage(objectStorage); } @Override public void init(OperationsFactory operationsFactory, Configuration configuration, ObjectName jmxParent) { this.cache.init(operationsFactory, configuration, jmxParent); } @Override public void init(OperationsFactory operationsFactory, Configuration configuration) { this.cache.init(operationsFactory, configuration); } @Override public OperationsFactory getOperationsFactory() { return this.cache.getOperationsFactory(); } @Override public boolean isObjectStorage() { return this.cache.isObjectStorage(); } @Override public K keyAsObjectIfNeeded(Object key) { return this.cache.keyAsObjectIfNeeded(key); } @Override public byte[] keyToBytes(Object object) { return this.cache.keyToBytes(object); } @Override public CompletionStage<PingResponse> ping() { return this.cache.ping(); } @Override public SocketAddress addNearCacheListener(Object listener, int bloomBits) { return this.cache.addNearCacheListener(listener, bloomBits); } @Override public CompletionStage<Void> updateBloomFilter() { return this.cache.updateBloomFilter(); } }
15,720
34.974828
207
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/client/ManagedRemoteCacheContainer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.client; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletionStage; import java.util.function.Function; import org.infinispan.client.hotrod.DataFormat; import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCacheManager; import org.infinispan.client.hotrod.RemoteCacheManagerAdmin; import org.infinispan.client.hotrod.configuration.Configuration; import org.infinispan.client.hotrod.impl.operations.OperationsFactory; import org.infinispan.client.hotrod.impl.operations.PingResponse; import org.infinispan.commons.dataconversion.MediaType; import org.infinispan.commons.marshall.Marshaller; import org.jboss.as.clustering.infinispan.dataconversion.MediaTypeFactory; import org.jboss.modules.ModuleLoader; import org.wildfly.clustering.Registrar; import org.wildfly.clustering.infinispan.client.RemoteCacheContainer; import org.wildfly.clustering.infinispan.marshalling.ByteBufferMarshallerFactory; import org.wildfly.clustering.infinispan.marshalling.UserMarshaller; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.security.manager.WildFlySecurityManager; /** * Container managed {@link RemoteCacheManager} decorator, whose lifecycle methods are no-ops. * * @author Radoslav Husar * @author Paul Ferraro * */ public class ManagedRemoteCacheContainer implements RemoteCacheContainer { private final RemoteCacheManager container; private final OperationsFactory factory; private final String name; private final Function<ClassLoader, ByteBufferMarshaller> marshallerFactory; private final Registrar<String> registrar; public ManagedRemoteCacheContainer(RemoteCacheManager container, String name, ModuleLoader loader, Registrar<String> registrar) { this.container = container; this.name = name; this.registrar = registrar; this.marshallerFactory = new ByteBufferMarshallerFactory(container.getConfiguration().marshaller().mediaType(), loader); this.factory = new OperationsFactory(container.getChannelFactory(), null, container.getConfiguration()); } @Override public String getName() { return this.name; } @Override public RemoteCacheManagerAdmin administration() { return this.container.administration(); } @Override public CompletionStage<Boolean> isAvailable() { return this.factory.newFaultTolerantPingOperation().execute().thenApply(PingResponse::isSuccess); } @Override public <K, V> RemoteCache<K, V> getCache() { return this.getCache(""); } @Override public <K, V> RemoteCache<K, V> getCache(String cacheName) { RemoteCache<K, V> cache = this.container.getCache(cacheName); if (cache == null) return null; Marshaller defaultMarshaller = this.container.getMarshaller(); DataFormat.Builder builder = DataFormat.builder().from(cache.getDataFormat()) .keyType(defaultMarshaller.mediaType()) .valueType(defaultMarshaller.mediaType()) ; ClassLoader loader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); Map.Entry<MediaType, MediaType> types = MediaTypeFactory.INSTANCE.apply(loader); boolean overrideKeyMarshaller = !types.getKey().equals(MediaType.APPLICATION_OBJECT); boolean overrideValueMarshaller = !types.getValue().equals(MediaType.APPLICATION_OBJECT); if (overrideKeyMarshaller || overrideValueMarshaller) { Marshaller marshaller = new UserMarshaller(defaultMarshaller.mediaType(), this.marshallerFactory.apply(loader)); if (overrideKeyMarshaller) { builder.keyType(marshaller.mediaType()); builder.keyMarshaller(marshaller); } if (overrideValueMarshaller) { builder.valueType(marshaller.mediaType()); builder.valueMarshaller(marshaller); } } return new ManagedRemoteCache<>(this, this.container, cache.withDataFormat(builder.build()), this.registrar); } @Override public Configuration getConfiguration() { return this.container.getConfiguration(); } @Override public boolean isStarted() { return this.container.isStarted(); } @Override public boolean switchToCluster(String clusterName) { return this.container.switchToCluster(clusterName); } @Override public boolean switchToDefaultCluster() { return this.container.switchToDefaultCluster(); } @Override public Marshaller getMarshaller() { return this.container.getMarshaller(); } @Override public boolean isTransactional(String cacheName) { return this.container.isTransactional(cacheName); } @Override public Set<String> getCacheNames() { return this.container.getCacheNames(); } @Override public void start() { // Do nothing } @Override public void stop() { // Do nothing } @Override public String[] getServers() { return this.container.getServers(); } @Override public int getActiveConnectionCount() { return this.container.getActiveConnectionCount(); } @Override public int getConnectionCount() { return this.container.getConnectionCount(); } @Override public int getIdleConnectionCount() { return this.container.getIdleConnectionCount(); } @Override public long getRetries() { return this.container.getRetries(); } @Override public int hashCode() { return this.name.hashCode(); } @Override public boolean equals(Object object) { if (!(object instanceof RemoteCacheContainer)) return false; RemoteCacheContainer container = (RemoteCacheContainer) object; return this.name.equals(container.getName()); } @Override public String toString() { return this.name; } }
7,127
33.770732
133
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/cache/LazyCache.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.cache; import java.lang.annotation.Annotation; import java.util.Set; import java.util.concurrent.CompletionStage; import java.util.concurrent.TimeUnit; import org.infinispan.AdvancedCache; import org.infinispan.Cache; import org.infinispan.CacheCollection; import org.infinispan.CacheSet; import org.infinispan.configuration.cache.Configuration; import org.infinispan.lifecycle.ComponentStatus; import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.notifications.cachelistener.filter.CacheEventConverter; import org.infinispan.notifications.cachelistener.filter.CacheEventFilter; /** * An embedded cache that resolves itself from its cache container lazily. * @author Paul Ferraro */ public class LazyCache<K, V> extends LazyBasicCache<K, V, Cache<K, V>> implements Cache<K, V> { private final EmbeddedCacheManager container; private final String name; public LazyCache(EmbeddedCacheManager container, String name) { super(name); this.container = container; this.name = name; } @Override public Cache<K, V> run() { return this.container.getCache(this.name); } @Override public EmbeddedCacheManager getCacheManager() { return this.container; } @Override public AdvancedCache<K, V> getAdvancedCache() { return this.get().getAdvancedCache(); } @Override public Configuration getCacheConfiguration() { return this.get().getCacheConfiguration(); } @Deprecated @Override public Set<Object> getListeners() { return this.get().getListeners(); } @Override public ComponentStatus getStatus() { return this.get().getStatus(); } @Override public boolean startBatch() { return this.get().startBatch(); } @Override public void endBatch(boolean successful) { this.get().endBatch(successful); } @Override public CacheSet<Entry<K, V>> entrySet() { return this.get().entrySet(); } @Override public CacheSet<K> keySet() { return this.get().keySet(); } @Override public CacheCollection<V> values() { return this.get().values(); } @Override public void evict(K key) { this.get().evict(key); } @Override public void putForExternalRead(K key, V value) { this.get().putForExternalRead(key, value); } @Override public void putForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit) { this.get().putForExternalRead(key, value, lifespan, lifespanUnit); } @Override public void putForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { this.get().putForExternalRead(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletionStage<Void> addListenerAsync(Object listener) { return this.get().addListenerAsync(listener); } @Override public <C> CompletionStage<Void> addListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter) { return this.get().addListenerAsync(listener, filter, converter); } @Override public <C> CompletionStage<Void> addFilteredListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) { return this.get().addFilteredListenerAsync(listener, filter, converter, filterAnnotations); } @Override public <C> CompletionStage<Void> addStorageFormatFilteredListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) { return this.get().addStorageFormatFilteredListenerAsync(listener, filter, converter, filterAnnotations); } @Override public CompletionStage<Void> removeListenerAsync(Object listener) { return this.get().removeListenerAsync(listener); } }
5,226
32.50641
248
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/cache/LazyBasicCache.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.cache; import java.security.PrivilegedAction; import java.util.Collection; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; import org.infinispan.commons.api.BasicCache; import org.wildfly.security.manager.WildFlySecurityManager; /** * A cache that resolves itself from its cache container lazily. * @author Paul Ferraro */ public abstract class LazyBasicCache<K, V, C extends BasicCache<K, V>> implements BasicCache<K, V>, Supplier<C>, PrivilegedAction<C> { private final String name; protected LazyBasicCache(String name) { this.name = name; } @Override public C get() { return WildFlySecurityManager.doUnchecked(this); } @Override public String getName() { return this.name; } @Override public void start() { this.get().start(); } @Override public void stop() { this.get().stop(); } @Override public String getVersion() { return this.get().getVersion(); } @Override public boolean containsKey(Object key) { return this.get().containsKey(key); } @Override public boolean containsValue(Object value) { return this.get().containsValue(value); } @Override public boolean isEmpty() { return this.get().isEmpty(); } @Override public Set<Entry<K, V>> entrySet() { return this.get().entrySet(); } @Override public Set<K> keySet() { return this.get().keySet(); } @Override public Collection<V> values() { return this.get().values(); } @Override public void clear() { this.get().clear(); } @Override public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { return this.get().compute(key, remappingFunction); } @Override public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) { return this.get().compute(key, remappingFunction, lifespan, lifespanUnit); } @Override public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().compute(key, remappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) { return this.get().computeIfAbsent(key, mappingFunction); } @Override public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) { return this.get().computeIfAbsent(key, mappingFunction, lifespan, lifespanUnit); } @Override public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().computeIfAbsent(key, mappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { return this.get().computeIfPresent(key, remappingFunction); } @Override public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) { return this.get().computeIfPresent(key, remappingFunction, lifespan, lifespanUnit); } @Override public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().computeIfPresent(key, remappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public V get(Object key) { return this.get().get(key); } @Override public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) { return this.get().merge(key, value, remappingFunction); } @Override public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) { return this.get().merge(key, value, remappingFunction, lifespan, lifespanUnit); } @Override public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().merge(key, value, remappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public V put(K key, V value) { return this.get().put(key, value); } @Override public V put(K key, V value, long lifespan, TimeUnit lifespanUnit) { return this.get().put(key, value, lifespan, lifespanUnit); } @Override public V put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().put(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public void putAll(Map<? extends K, ? extends V> map) { this.get().putAll(map); } @Override public void putAll(Map<? extends K, ? extends V> map, long lifespan, TimeUnit lifespanUnit) { this.get().putAll(map, lifespan, lifespanUnit); } @Override public void putAll(Map<? extends K, ? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { this.get().putAll(map, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public V putIfAbsent(K key, V value) { return this.get().putIfAbsent(key, value); } @Override public V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit) { return this.get().putIfAbsent(key, value, lifespan, lifespanUnit); } @Override public V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().putIfAbsent(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public V remove(Object key) { return this.get().remove(key); } @Override public boolean remove(Object key, Object value) { return this.get().remove(key, value); } @Override public V replace(K key, V value) { return this.get().replace(key, value); } @Override public V replace(K key, V value, long lifespan, TimeUnit lifespanUnit) { return this.get().replace(key, value, lifespan, lifespanUnit); } @Override public V replace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().replace(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public boolean replace(K key, V oldValue, V newValue) { return this.get().replace(key, oldValue, newValue); } @Override public boolean replace(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit) { return this.get().replace(key, oldValue, newValue, lifespan, lifespanUnit); } @Override public boolean replace(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().replace(key, oldValue, newValue, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public int size() { return this.get().size(); } @Override public CompletableFuture<Void> clearAsync() { return this.get().clearAsync(); } @Override public CompletableFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { return this.get().computeAsync(key, remappingFunction); } @Override public CompletableFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) { return this.get().computeAsync(key, remappingFunction, lifespan, lifespanUnit); } @Override public CompletableFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().computeAsync(key, remappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction) { return this.get().computeIfAbsentAsync(key, mappingFunction); } @Override public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) { return this.get().computeIfAbsentAsync(key, mappingFunction, lifespan, lifespanUnit); } @Override public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().computeIfAbsentAsync(key, mappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { return this.get().computeIfPresentAsync(key, remappingFunction); } @Override public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) { return this.get().computeIfPresentAsync(key, remappingFunction, lifespan, lifespanUnit); } @Override public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().computeIfPresentAsync(key, remappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> getAsync(K key) { return this.get().getAsync(key); } @Override public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) { return this.get().mergeAsync(key, value, remappingFunction); } @Override public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) { return this.get().mergeAsync(key, value, remappingFunction, lifespan, lifespanUnit); } @Override public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().mergeAsync(key, value, remappingFunction, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> putAsync(K key, V value) { return this.get().putAsync(key, value); } @Override public CompletableFuture<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit) { return this.get().putAsync(key, value, lifespan, lifespanUnit); } @Override public CompletableFuture<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().putAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<Void> putAllAsync(Map<? extends K, ? extends V> entries) { return this.get().putAllAsync(entries); } @Override public CompletableFuture<Void> putAllAsync(Map<? extends K, ? extends V> entries, long lifespan, TimeUnit lifespanUnit) { return this.get().putAllAsync(entries, lifespan, lifespanUnit); } @Override public CompletableFuture<Void> putAllAsync(Map<? extends K, ? extends V> entries, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().putAllAsync(entries, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> putIfAbsentAsync(K key, V value) { return this.get().putIfAbsentAsync(key, value); } @Override public CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit) { return this.get().putIfAbsentAsync(key, value, lifespan, lifespanUnit); } @Override public CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().putIfAbsentAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<V> removeAsync(Object key) { return this.get().removeAsync(key); } @Override public CompletableFuture<Boolean> removeAsync(Object key, Object value) { return this.get().removeAsync(key, value); } @Override public CompletableFuture<V> replaceAsync(K key, V value) { return this.get().replaceAsync(key, value); } @Override public CompletableFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit) { return this.get().replaceAsync(key, value, lifespan, lifespanUnit); } @Override public CompletableFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().replaceAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue) { return this.get().replaceAsync(key, oldValue, newValue); } @Override public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit) { return this.get().replaceAsync(key, oldValue, newValue, lifespan, lifespanUnit); } @Override public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) { return this.get().replaceAsync(key, oldValue, newValue, lifespan, lifespanUnit, maxIdle, maxIdleUnit); } @Override public CompletableFuture<Long> sizeAsync() { return this.get().sizeAsync(); } }
15,837
36.265882
201
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/deployment/ClusteringDependencyProcessor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.deployment; import org.jboss.as.server.deployment.Attachments; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessor; import org.jboss.as.server.deployment.module.ModuleDependency; import org.jboss.as.server.deployment.module.ModuleSpecification; import org.jboss.modules.Module; import org.jboss.modules.ModuleLoader; /** * {@link DeploymentUnitProcessor} that adds the clustering api to the deployment classpath. * @author Paul Ferraro */ public class ClusteringDependencyProcessor implements DeploymentUnitProcessor { private static final String API = "org.wildfly.clustering.server.api"; private static final String MARSHALLING_API = "org.wildfly.clustering.marshalling.api"; private static final String SINGLETON_API = "org.wildfly.clustering.singleton.api"; @Override public void deploy(DeploymentPhaseContext phaseContext) { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, API, true, false, false, false)); moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, MARSHALLING_API, true, false, false, false)); moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, SINGLETON_API, true, false, false, false)); } }
2,703
49.074074
128
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/RemoteStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.concurrent.TimeUnit; import org.jboss.as.clustering.controller.CapabilityReference; import org.jboss.as.clustering.controller.CommonUnaryRequirement; import org.jboss.as.clustering.controller.SimpleResourceDescriptorConfigurator; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.StringListAttributeDefinition; import org.jboss.as.controller.client.helpers.MeasurementUnit; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Resource description for the addressable resource and its alias * * /subsystem=infinispan/cache-container=X/cache=Y/store=remote * /subsystem=infinispan/cache-container=X/cache=Y/remote-store=REMOTE_STORE * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. * @deprecated Use {@link org.jboss.as.clustering.infinispan.subsystem.HotRodStoreResourceDefinition} instead. */ @Deprecated public class RemoteStoreResourceDefinition extends StoreResourceDefinition { static final PathElement PATH = pathElement("remote"); enum Attribute implements org.jboss.as.clustering.controller.Attribute { CACHE("cache", ModelType.STRING, null), SOCKET_TIMEOUT("socket-timeout", ModelType.LONG, new ModelNode(TimeUnit.MINUTES.toMillis(1))), TCP_NO_DELAY("tcp-no-delay", ModelType.BOOLEAN, ModelNode.TRUE), SOCKET_BINDINGS("remote-servers") ; private final AttributeDefinition definition; Attribute(String name, ModelType type, ModelNode defaultValue) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(defaultValue == null) .setDefaultValue(defaultValue) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null) .build(); } Attribute(String name) { this.definition = new StringListAttributeDefinition.Builder(name) .setCapabilityReference(new CapabilityReference(Capability.PERSISTENCE, CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING)) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .setMinSize(1) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } RemoteStoreResourceDefinition() { super(PATH, InfinispanExtension.SUBSYSTEM_RESOLVER.createChildResolver(PATH, WILDCARD_PATH), new SimpleResourceDescriptorConfigurator<>(Attribute.class), RemoteStoreServiceConfigurator::new); this.setDeprecated(InfinispanSubsystemModel.VERSION_7_0_0.getVersion()); } }
4,063
44.155556
199
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/SharedStateCacheServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.configuration.cache.CacheMode; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.PartitionHandlingConfiguration; import org.infinispan.configuration.cache.SitesConfiguration; import org.infinispan.configuration.cache.SitesConfigurationBuilder; import org.infinispan.configuration.cache.StateTransferConfiguration; import org.jboss.as.controller.PathAddress; import org.jboss.msc.service.ServiceBuilder; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; /** * @author Paul Ferraro */ public class SharedStateCacheServiceConfigurator extends ClusteredCacheServiceConfigurator { private final SupplierDependency<PartitionHandlingConfiguration> partitionHandling; private final SupplierDependency<StateTransferConfiguration> stateTransfer; private final SupplierDependency<SitesConfiguration> backups; SharedStateCacheServiceConfigurator(PathAddress address, CacheMode mode) { super(address, mode); this.partitionHandling = new ServiceSupplierDependency<>(CacheComponent.PARTITION_HANDLING.getServiceName(address)); this.stateTransfer = new ServiceSupplierDependency<>(CacheComponent.STATE_TRANSFER.getServiceName(address)); this.backups = new ServiceSupplierDependency<>(CacheComponent.BACKUPS.getServiceName(address)); } @Override public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { return super.register(new CompositeDependency(this.partitionHandling, this.stateTransfer, this.backups).register(builder)); } @Override public void accept(ConfigurationBuilder builder) { super.accept(builder); builder.clustering().partitionHandling().read(this.partitionHandling.get()); builder.clustering().stateTransfer().read(this.stateTransfer.get()); SitesConfigurationBuilder sitesBuilder = builder.sites(); sitesBuilder.read(this.backups.get()); } }
3,175
45.028986
131
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheContainerResource.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.Collections; import java.util.Map; import org.jboss.as.clustering.controller.ChildResourceProvider; import org.jboss.as.clustering.controller.ComplexResource; import org.jboss.as.controller.registry.Resource; import org.wildfly.clustering.Registrar; import org.wildfly.clustering.Registration; /** * @author Paul Ferraro */ public class CacheContainerResource extends ComplexResource implements Registrar<String> { private static final String CHILD_TYPE = CacheRuntimeResourceDefinition.WILDCARD_PATH.getKey(); public CacheContainerResource(Resource resource) { this(resource, Collections.singletonMap(CHILD_TYPE, new CacheRuntimeResourceProvider())); } private CacheContainerResource(Resource resource, Map<String, ChildResourceProvider> providers) { super(resource, providers, CacheContainerResource::new); } @Override public Registration register(String cache) { ChildResourceProvider provider = this.apply(CHILD_TYPE); provider.getChildren().add(cache); return new Registration() { @Override public void close() { provider.getChildren().remove(cache); } }; } }
2,301
36.737705
101
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ScheduledThreadPoolServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import org.infinispan.commons.executors.ThreadPoolExecutorFactory; import org.infinispan.configuration.global.ThreadPoolConfiguration; import org.infinispan.configuration.global.ThreadPoolConfigurationBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.context.DefaultThreadFactory; import org.wildfly.clustering.service.ServiceConfigurator; /** * @author Radoslav Husar */ public class ScheduledThreadPoolServiceConfigurator extends GlobalComponentServiceConfigurator<ThreadPoolConfiguration> { private final ThreadPoolConfigurationBuilder builder = new ThreadPoolConfigurationBuilder(null); private final ScheduledThreadPoolDefinition definition; ScheduledThreadPoolServiceConfigurator(ScheduledThreadPoolDefinition definition, PathAddress address) { super(definition, address); this.definition = definition; } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { int minThreads = this.definition.getMinThreads().resolveModelAttribute(context, model).asInt(); long keepAliveTime = this.definition.getKeepAliveTime().resolveModelAttribute(context, model).asLong(); ThreadPoolExecutorFactory<?> factory = new ThreadPoolExecutorFactory<ScheduledExecutorService>() { @Override public ScheduledExecutorService createExecutor(ThreadFactory factory) { // Use fixed size, based on maxThreads ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(minThreads, new DefaultThreadFactory(factory)); executor.setKeepAliveTime(keepAliveTime, TimeUnit.MILLISECONDS); executor.setRemoveOnCancelPolicy(true); executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); return executor; } @Override public void validate() { // Do nothing } }; this.builder.threadPoolFactory(factory); return this; } @Override public ThreadPoolConfiguration get() { return this.builder.create(); } }
3,609
40.976744
134
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TransactionResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.function.Consumer; import org.jboss.as.clustering.infinispan.subsystem.TransactionResourceDefinition.Attribute; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; /** * @author Paul Ferraro */ public class TransactionResourceTransformer implements Consumer<ModelVersion> { private final ResourceTransformationDescriptionBuilder builder; TransactionResourceTransformer(ResourceTransformationDescriptionBuilder parent) { this.builder = parent.addChildResource(TransactionResourceDefinition.PATH); } @Override public void accept(ModelVersion version) { if (InfinispanSubsystemModel.VERSION_15_0_0.requiresTransformation(version)) { this.builder.getAttributeBuilder() .setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, Attribute.COMPLETE_TIMEOUT.getName()) .addRejectCheck(RejectAttributeChecker.DEFINED, Attribute.COMPLETE_TIMEOUT.getDefinition()) .end(); } } }
2,323
42.037037
110
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/TransactionRuntimeResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.infinispan.Cache; import org.infinispan.interceptors.impl.TxInterceptor; import org.jboss.as.clustering.controller.BinaryCapabilityNameResolver; import org.jboss.as.clustering.controller.FunctionExecutorRegistry; import org.jboss.as.clustering.controller.MetricHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.registry.ManagementResourceRegistration; /** * @author Paul Ferraro */ public class TransactionRuntimeResourceDefinition extends CacheComponentRuntimeResourceDefinition { static final PathElement PATH = pathElement("transaction"); private final FunctionExecutorRegistry<Cache<?, ?>> executors; TransactionRuntimeResourceDefinition(FunctionExecutorRegistry<Cache<?, ?>> executors) { super(PATH); this.executors = executors; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = super.register(parent); new MetricHandler<>(new CacheInterceptorMetricExecutor<>(this.executors, TxInterceptor.class, BinaryCapabilityNameResolver.GRANDPARENT_PARENT), TransactionMetric.class).register(registration); return registration; } }
2,321
42
200
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/CacheComponent.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.stream.Stream; import org.jboss.as.clustering.controller.ResourceServiceNameFactory; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.msc.service.ServiceName; /** * Enumerates the configurable cache components * @author Paul Ferraro */ public enum CacheComponent implements ResourceServiceNameFactory { MODULES("modules"), EXPIRATION(ExpirationResourceDefinition.PATH), LOCKING(LockingResourceDefinition.PATH), MEMORY(MemoryResourceDefinition.WILDCARD_PATH), PERSISTENCE() { @Override public ServiceName getServiceName(PathAddress cacheAddress) { return StoreResourceDefinition.Capability.PERSISTENCE.getServiceName(cacheAddress.append(StoreResourceDefinition.WILDCARD_PATH)); } }, STATE_TRANSFER(StateTransferResourceDefinition.PATH), PARTITION_HANDLING(PartitionHandlingResourceDefinition.PATH), STORE_WRITE(StoreWriteResourceDefinition.WILDCARD_PATH), TRANSACTION(TransactionResourceDefinition.PATH), STRING_TABLE(StoreResourceDefinition.WILDCARD_PATH, StringTableResourceDefinition.PATH), BACKUPS(BackupResourceDefinition.WILDCARD_PATH), ; private final String[] components; CacheComponent() { this(Stream.empty()); } CacheComponent(PathElement... paths) { this(Stream.of(paths).map(path -> path.isWildcard() ? path.getKey() : path.getValue())); } CacheComponent(Stream<String> components) { this(components.toArray(String[]::new)); } CacheComponent(String... components) { this.components = components; } @Override public ServiceName getServiceName(PathAddress cacheAddress) { return CacheResourceDefinition.Capability.CONFIGURATION.getServiceName(cacheAddress).append(this.components); } }
2,936
36.177215
141
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/ScatteredCacheServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.ScatteredCacheResourceDefinition.Attribute.BIAS_LIFESPAN; import static org.jboss.as.clustering.infinispan.subsystem.ScatteredCacheResourceDefinition.Attribute.INVALIDATION_BATCH_SIZE; import java.util.concurrent.TimeUnit; import org.infinispan.configuration.cache.BiasAcquisition; import org.infinispan.configuration.cache.CacheMode; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.wildfly.clustering.service.ServiceConfigurator; /** * @author Paul Ferraro */ @Deprecated public class ScatteredCacheServiceConfigurator extends SegmentedCacheServiceConfigurator { private volatile int invalidationBatchSize; private volatile long biasLifespan; ScatteredCacheServiceConfigurator(PathAddress address) { super(address, CacheMode.SCATTERED_SYNC); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.invalidationBatchSize = INVALIDATION_BATCH_SIZE.resolveModelAttribute(context, model).asInt(); this.biasLifespan = BIAS_LIFESPAN.resolveModelAttribute(context, model).asLong(); return super.configure(context, model); } @Override public void accept(ConfigurationBuilder builder) { super.accept(builder); builder.clustering() .biasAcquisition((this.biasLifespan > 0) ? BiasAcquisition.ON_WRITE : BiasAcquisition.NEVER) .biasLifespan(this.biasLifespan, TimeUnit.MILLISECONDS) .invalidationBatchSize(this.invalidationBatchSize) ; } }
2,914
40.056338
126
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/InfinispanSubsystemResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; import java.util.Set; import java.util.function.Consumer; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.Capability; import org.jboss.as.clustering.controller.DeploymentChainContributingResourceRegistrar; import org.jboss.as.clustering.controller.ManagementResourceRegistration; import org.jboss.as.clustering.controller.RequirementCapability; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SubsystemRegistration; import org.jboss.as.clustering.controller.SubsystemResourceDefinition; import org.jboss.as.clustering.controller.UnaryCapabilityNameResolver; import org.jboss.as.clustering.controller.UnaryRequirementCapability; import org.jboss.as.clustering.infinispan.deployment.ClusteringDependencyProcessor; import org.jboss.as.clustering.infinispan.subsystem.remote.RemoteCacheContainerResourceDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler; import org.jboss.as.server.DeploymentProcessorTarget; import org.jboss.as.server.deployment.Phase; import org.wildfly.clustering.server.service.ClusteringRequirement; /** * The root resource of the Infinispan subsystem. * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class InfinispanSubsystemResourceDefinition extends SubsystemResourceDefinition implements Consumer<DeploymentProcessorTarget> { static final PathElement PATH = pathElement(InfinispanExtension.SUBSYSTEM_NAME); InfinispanSubsystemResourceDefinition() { super(PATH, InfinispanExtension.SUBSYSTEM_RESOLVER); } @Override public void register(SubsystemRegistration parentRegistration) { ManagementResourceRegistration registration = parentRegistration.registerSubsystemModel(this); registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE); Set<ClusteringRequirement> requirements = EnumSet.allOf(ClusteringRequirement.class); List<Capability> capabilities = new ArrayList<>(requirements.size()); List<Capability> localCapabilities = new ArrayList<>(requirements.size()); UnaryOperator<RuntimeCapability.Builder<Void>> configurator = builder -> builder.setAllowMultipleRegistrations(true); for (ClusteringRequirement requirement : requirements) { capabilities.add(new RequirementCapability(requirement.getDefaultRequirement(), configurator)); localCapabilities.add(new UnaryRequirementCapability(requirement, UnaryCapabilityNameResolver.LOCAL)); } ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()) .addCapabilities(capabilities) .addCapabilities(localCapabilities) ; ResourceServiceHandler handler = new InfinispanSubsystemServiceHandler(); new DeploymentChainContributingResourceRegistrar(descriptor, handler, this).register(registration); new CacheContainerResourceDefinition().register(registration); new RemoteCacheContainerResourceDefinition().register(registration); } @Override public void accept(DeploymentProcessorTarget target) { target.addDeploymentProcessor(InfinispanExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_CLUSTERING, new ClusteringDependencyProcessor()); } }
4,741
48.915789
162
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/LocalCacheServiceHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import org.wildfly.clustering.server.service.LocalCacheServiceConfiguratorProvider; /** * @author Paul Ferraro */ public class LocalCacheServiceHandler extends CacheServiceHandler<LocalCacheServiceConfiguratorProvider> { LocalCacheServiceHandler() { super(LocalCacheServiceConfigurator::new, LocalCacheServiceConfiguratorProvider.class); } }
1,442
38
106
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/HotRodStoreServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.HotRodStoreResourceDefinition.Attribute.CACHE_CONFIGURATION; import static org.jboss.as.clustering.infinispan.subsystem.HotRodStoreResourceDefinition.Attribute.REMOTE_CACHE_CONTAINER; import org.jboss.as.clustering.infinispan.persistence.hotrod.HotRodStoreConfiguration; import org.jboss.as.clustering.infinispan.persistence.hotrod.HotRodStoreConfigurationBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceBuilder; import org.wildfly.clustering.infinispan.client.RemoteCacheContainer; import org.wildfly.clustering.infinispan.client.service.InfinispanClientRequirement; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SupplierDependency; /** * @author Radoslav Husar */ public class HotRodStoreServiceConfigurator extends StoreServiceConfigurator<HotRodStoreConfiguration, HotRodStoreConfigurationBuilder> { private volatile SupplierDependency<RemoteCacheContainer> remoteCacheContainer; private volatile String cacheConfiguration; HotRodStoreServiceConfigurator(PathAddress address) { super(address, HotRodStoreConfigurationBuilder.class); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.cacheConfiguration = CACHE_CONFIGURATION.resolveModelAttribute(context, model).asStringOrNull(); String remoteCacheContainerName = REMOTE_CACHE_CONTAINER.resolveModelAttribute(context, model).asString(); this.remoteCacheContainer = new ServiceSupplierDependency<>(InfinispanClientRequirement.REMOTE_CONTAINER.getServiceName(context, remoteCacheContainerName)); return super.configure(context, model); } @Override public <T> ServiceBuilder<T> register(ServiceBuilder<T> builder) { return super.register(this.remoteCacheContainer.register(builder)); } @Override public void accept(HotRodStoreConfigurationBuilder builder) { builder.segmented(false) .cacheConfiguration(this.cacheConfiguration) .remoteCacheContainer(this.remoteCacheContainer.get()) ; } }
3,512
45.84
164
java
null
wildfly-main/clustering/infinispan/extension/src/main/java/org/jboss/as/clustering/infinispan/subsystem/PartitionHandlingResourceTransformer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.clustering.infinispan.subsystem; import static org.jboss.as.clustering.infinispan.subsystem.PartitionHandlingResourceDefinition.Attribute.MERGE_POLICY; import static org.jboss.as.clustering.infinispan.subsystem.PartitionHandlingResourceDefinition.Attribute.WHEN_SPLIT; import static org.jboss.as.clustering.infinispan.subsystem.PartitionHandlingResourceDefinition.DeprecatedAttribute.ENABLED; import java.util.function.Consumer; import org.infinispan.partitionhandling.PartitionHandling; import org.jboss.as.clustering.controller.transform.SimpleAttributeConverter; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.transform.TransformationContext; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker.SimpleRejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; import org.jboss.dmr.ModelNode; /** * @author Paul Ferraro */ public class PartitionHandlingResourceTransformer implements Consumer<ModelVersion> { private final ResourceTransformationDescriptionBuilder builder; PartitionHandlingResourceTransformer(ResourceTransformationDescriptionBuilder parent) { this.builder = parent.addChildResource(PartitionHandlingResourceDefinition.PATH); } @Override public void accept(ModelVersion version) { if (InfinispanSubsystemModel.VERSION_16_0_0.requiresTransformation(version)) { this.builder.getAttributeBuilder() .setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, MERGE_POLICY.getDefinition(), WHEN_SPLIT.getDefinition()) .addRejectCheck(RejectAttributeChecker.DEFINED, MERGE_POLICY.getDefinition()) .addRejectCheck(new SimpleRejectAttributeChecker(new ModelNode(PartitionHandling.ALLOW_READS.name())), WHEN_SPLIT.getDefinition()) .setValueConverter(new SimpleAttributeConverter(new SimpleAttributeConverter.Converter() { @Override public void convert(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) { if (value.asString(PartitionHandling.ALLOW_READ_WRITES.name()).equals(PartitionHandling.DENY_READ_WRITES.name())) { value.set(ModelNode.TRUE); } } }), WHEN_SPLIT.getDefinition()) .addRename(WHEN_SPLIT.getDefinition(), ENABLED.getName()) .end(); } } }
3,831
51.493151
150
java