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/marshalling/protostream/src/main/java/org/wildfly/clustering/marshalling/protostream/net/URLMarshaller.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.marshalling.protostream.net; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import org.wildfly.clustering.marshalling.protostream.FunctionalMarshaller; import org.wildfly.common.function.ExceptionFunction; /** * Marshaller for a {@link URL}. * @author Paul Ferraro */ public class URLMarshaller extends FunctionalMarshaller<URL, URI> { private static final ExceptionFunction<URL, URI, IOException> TO_URI = new ExceptionFunction<>() { @Override public URI apply(URL url) throws IOException { try { return url.toURI(); } catch (URISyntaxException e) { throw new IOException(e); } } }; public URLMarshaller() { super(URL.class, URI.class, TO_URI, URI::toURL); } }
1,900
34.203704
102
java
null
wildfly-main/clustering/marshalling/protostream/src/main/java/org/wildfly/clustering/marshalling/protostream/net/InetAddressMarshaller.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.marshalling.protostream.net; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.PrivilegedActionException; import java.util.Arrays; import org.wildfly.clustering.marshalling.protostream.FieldSetMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader; import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter; import org.wildfly.common.net.Inet; import org.wildfly.security.ParametricPrivilegedExceptionAction; import org.wildfly.security.manager.WildFlySecurityManager; /** * Marshaller for an {@link InetAddress}. * @author Paul Ferraro */ public enum InetAddressMarshaller implements FieldSetMarshaller<InetAddress, InetAddress>, ParametricPrivilegedExceptionAction<InetAddress, String> { INSTANCE; private static final InetAddress DEFAULT = InetAddress.getLoopbackAddress(); private static final int HOST_NAME_INDEX = 0; private static final int ADDRESS_INDEX = 1; private static final int FIELDS = 2; @Override public InetAddress getBuilder() { return DEFAULT; } @Override public int getFields() { return FIELDS; } @Override public InetAddress readField(ProtoStreamReader reader, int index, InetAddress address) throws IOException { switch (index) { case HOST_NAME_INDEX: try { return WildFlySecurityManager.doUnchecked(reader.readString(), this); } catch (PrivilegedActionException e) { Exception exception = e.getException(); if (exception instanceof IOException) { throw (IOException) exception; } throw new IllegalStateException(e); } case ADDRESS_INDEX: return InetAddress.getByAddress(reader.readByteArray()); default: return address; } } @Override public void writeFields(ProtoStreamWriter writer, int startIndex, InetAddress address) throws IOException { // Determine host name without triggering reverse lookup String hostName = Inet.getHostNameIfResolved(address); // Marshal as host name, if possible if (hostName != null) { if (!hostName.equals(DEFAULT.getHostName())) { writer.writeString(startIndex + HOST_NAME_INDEX, hostName); } } else { byte[] bytes = address.getAddress(); if (!Arrays.equals(bytes, DEFAULT.getAddress())) { writer.writeBytes(startIndex + ADDRESS_INDEX, address.getAddress()); } } } @Override public InetAddress run(String host) throws UnknownHostException { return InetAddress.getByName(host); } }
3,913
37
149
java
null
wildfly-main/clustering/marshalling/protostream/src/main/java/org/wildfly/clustering/marshalling/protostream/net/URIMarshaller.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.marshalling.protostream.net; import java.net.URI; import org.wildfly.clustering.marshalling.protostream.FunctionalScalarMarshaller; import org.wildfly.clustering.marshalling.protostream.Scalar; /** * Marshaller for a {@link URI}. * @author Paul Ferraro */ public class URIMarshaller extends FunctionalScalarMarshaller<URI, String> { public URIMarshaller() { super(URI.class, Scalar.STRING.cast(String.class), URI::toString, URI::create); } }
1,520
37.025
87
java
null
wildfly-main/clustering/marshalling/protostream/src/main/java/org/wildfly/clustering/marshalling/protostream/net/InetSocketAddressMarshaller.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.marshalling.protostream.net; import java.io.IOException; import java.net.InetSocketAddress; 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 an {@link InetSocketAddress}. * @author Paul Ferraro */ public class InetSocketAddressMarshaller implements ProtoStreamMarshaller<InetSocketAddress> { private static final InetSocketAddress DEFAULT = new InetSocketAddress(InetAddressMarshaller.INSTANCE.getBuilder(), 0); private static final int RESOLVED_ADDRESS_INDEX = 1; private static final int UNRESOLVED_HOST_INDEX = RESOLVED_ADDRESS_INDEX + InetAddressMarshaller.INSTANCE.getFields(); private static final int PORT_INDEX = UNRESOLVED_HOST_INDEX + 1; @Override public InetSocketAddress readFrom(ProtoStreamReader reader) throws IOException { InetSocketAddress result = DEFAULT; while (!reader.isAtEnd()) { int tag = reader.readTag(); int index = WireType.getTagFieldNumber(tag); if (index >= RESOLVED_ADDRESS_INDEX && index < UNRESOLVED_HOST_INDEX) { result = new InetSocketAddress(InetAddressMarshaller.INSTANCE.readField(reader, index - RESOLVED_ADDRESS_INDEX, result.getAddress()), result.getPort()); } else if (index >= UNRESOLVED_HOST_INDEX && index < PORT_INDEX) { result = InetSocketAddress.createUnresolved(reader.readString(), result.getPort()); } else if (index == PORT_INDEX) { int port = reader.readUInt32(); result = result.isUnresolved() ? InetSocketAddress.createUnresolved(result.getHostName(), port) : new InetSocketAddress(result.getAddress(), port); } else { reader.skipField(tag); } } return result; } @Override public void writeTo(ProtoStreamWriter writer, InetSocketAddress socketAddress) throws IOException { if (socketAddress.isUnresolved()) { writer.writeString(UNRESOLVED_HOST_INDEX, socketAddress.getHostName()); } else { InetAddressMarshaller.INSTANCE.writeFields(writer, RESOLVED_ADDRESS_INDEX, socketAddress.getAddress()); } int port = socketAddress.getPort(); if (port != DEFAULT.getPort()) { writer.writeUInt32(PORT_INDEX, port); } } @Override public Class<? extends InetSocketAddress> getJavaClass() { return InetSocketAddress.class; } }
3,725
43.891566
168
java
null
wildfly-main/clustering/marshalling/protostream/src/main/java/org/wildfly/clustering/marshalling/protostream/net/NetMarshallerProvider.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.marshalling.protostream.net; import java.net.InetAddress; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshallerProvider; import org.wildfly.clustering.marshalling.protostream.SimpleFieldSetMarshaller; /** * Provider for java.net marshallers. * @author Paul Ferraro */ public enum NetMarshallerProvider implements ProtoStreamMarshallerProvider { INET_ADDRESS(new SimpleFieldSetMarshaller<>(InetAddress.class, InetAddressMarshaller.INSTANCE)), INET_SOCKET_ADDRESS(new InetSocketAddressMarshaller()), URI(new URIMarshaller()), URL(new URLMarshaller()), ; private final ProtoStreamMarshaller<?> marshaller; NetMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
2,007
36.886792
100
java
null
wildfly-main/clustering/marshalling/protostream/src/main/java/org/wildfly/clustering/marshalling/protostream/math/BigDecimalMarshaller.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.marshalling.protostream.math; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; 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.common.function.ExceptionPredicate; /** * Marshaller for {@link BigDecimal}. * @author Paul Ferraro */ public enum BigDecimalMarshaller implements ProtoStreamMarshaller<BigDecimal>, ExceptionPredicate<BigInteger, IOException> { INSTANCE; private static final int UNSCALED_VALUE_INDEX = 1; private static final int SCALE_INDEX = 2; private static final int DEFAULT_SCALE = 0; @Override public BigDecimal readFrom(ProtoStreamReader reader) throws IOException { BigInteger unscaledValue = BigInteger.ZERO; int scale = DEFAULT_SCALE; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case UNSCALED_VALUE_INDEX: unscaledValue = new BigInteger(reader.readByteArray()); break; case SCALE_INDEX: scale = reader.readSInt32(); break; default: reader.skipField(tag); } } return new BigDecimal(unscaledValue, scale); } @Override public void writeTo(ProtoStreamWriter writer, BigDecimal value) throws IOException { BigInteger unscaledValue = value.unscaledValue(); if (!this.test(unscaledValue)) { writer.writeBytes(UNSCALED_VALUE_INDEX, unscaledValue.toByteArray()); } int scale = value.scale(); if (scale != DEFAULT_SCALE) { writer.writeSInt32(SCALE_INDEX, scale); } } @Override public Class<? extends BigDecimal> getJavaClass() { return BigDecimal.class; } @Override public boolean test(BigInteger value) { return value.signum() == 0; } }
3,235
35.359551
124
java
null
wildfly-main/clustering/marshalling/protostream/src/main/java/org/wildfly/clustering/marshalling/protostream/math/MathMarshallerProvider.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.marshalling.protostream.math; import java.math.BigInteger; import java.math.RoundingMode; import org.wildfly.clustering.marshalling.protostream.EnumMarshaller; 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.common.function.Functions; /** * Provider for java.math marshallers. * @author Paul Ferraro */ public enum MathMarshallerProvider implements ProtoStreamMarshallerProvider { BIG_DECIMAL(BigDecimalMarshaller.INSTANCE), BIG_INTEGER(new FunctionalScalarMarshaller<>(Scalar.BYTE_ARRAY.cast(byte[].class), Functions.constantSupplier(BigInteger.ZERO), BigDecimalMarshaller.INSTANCE, BigInteger::toByteArray, BigInteger::new)), MATH_CONTEXT(new MathContextMarshaller()), ROUNDING_MODE(new EnumMarshaller<>(RoundingMode.class)), ; private final ProtoStreamMarshaller<?> marshaller; MathMarshallerProvider(ProtoStreamMarshaller<?> marshaller) { this.marshaller = marshaller; } @Override public ProtoStreamMarshaller<?> getMarshaller() { return this.marshaller; } }
2,364
40.491228
206
java
null
wildfly-main/clustering/marshalling/protostream/src/main/java/org/wildfly/clustering/marshalling/protostream/math/MathContextMarshaller.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.marshalling.protostream.math; import java.io.IOException; import java.math.MathContext; import java.math.RoundingMode; 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 {@link MathContext}. * @author Paul Ferraro */ public class MathContextMarshaller implements ProtoStreamMarshaller<MathContext> { private static final int PRECISION_INDEX = 1; private static final int ROUNDING_MODE_INDEX = 2; private static final int DEFAULT_PRECISION = 0; private static final RoundingMode DEFAULT_ROUNDING_MODE = RoundingMode.HALF_UP; @Override public MathContext readFrom(ProtoStreamReader reader) throws IOException { int precision = DEFAULT_PRECISION; RoundingMode mode = DEFAULT_ROUNDING_MODE; while (!reader.isAtEnd()) { int tag = reader.readTag(); switch (WireType.getTagFieldNumber(tag)) { case PRECISION_INDEX: precision = reader.readUInt32(); break; case ROUNDING_MODE_INDEX: mode = reader.readEnum(RoundingMode.class); break; default: reader.skipField(tag); } } return new MathContext(precision, mode); } @Override public void writeTo(ProtoStreamWriter writer, MathContext context) throws IOException { int precision = context.getPrecision(); if (precision != DEFAULT_PRECISION) { writer.writeUInt32(PRECISION_INDEX, precision); } RoundingMode mode = context.getRoundingMode(); if (mode != DEFAULT_ROUNDING_MODE) { writer.writeEnum(ROUNDING_MODE_INDEX, mode); } } @Override public Class<? extends MathContext> getJavaClass() { return MathContext.class; } }
3,127
36.686747
91
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossMarshallingTimeUnitTest.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.wildfly.clustering.marshalling.jboss; import org.wildfly.clustering.marshalling.AbstractTimeTestCase; /** * @author Paul Ferraro */ public class JBossMarshallingTimeUnitTest extends AbstractTimeTestCase { public JBossMarshallingTimeUnitTest() { super(JBossMarshallingTesterFactory.INSTANCE); } }
1,353
36.611111
72
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossByteBufferMarshalledKeyFactoryTestCase.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.marshalling.jboss; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledKeyFactoryTestCase; /** * @author Paul Ferraro */ public class JBossByteBufferMarshalledKeyFactoryTestCase extends ByteBufferMarshalledKeyFactoryTestCase { public JBossByteBufferMarshalledKeyFactoryTestCase() { super(TestJBossByteBufferMarshaller.INSTANCE); } }
1,423
38.555556
105
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossMarshallingTesterFactory.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.wildfly.clustering.marshalling.jboss; import org.wildfly.clustering.marshalling.MarshallingTester; import org.wildfly.clustering.marshalling.MarshallingTesterFactory; import org.wildfly.clustering.marshalling.spi.ByteBufferTestMarshaller; /** * @author Paul Ferraro */ public enum JBossMarshallingTesterFactory implements MarshallingTesterFactory { INSTANCE; @Override public <T> MarshallingTester<T> createTester() { return new MarshallingTester<>(new ByteBufferTestMarshaller<>(TestJBossByteBufferMarshaller.INSTANCE)); } }
1,591
38.8
111
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossMarshallingAtomicTestCase.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.wildfly.clustering.marshalling.jboss; import org.wildfly.clustering.marshalling.AbstractAtomicTestCase; /** * @author Paul Ferraro */ public class JBossMarshallingAtomicTestCase extends AbstractAtomicTestCase { public JBossMarshallingAtomicTestCase() { super(JBossMarshallingTesterFactory.INSTANCE); } }
1,361
36.833333
76
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossByteBufferMarshalledValueFactoryTestCase.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.marshalling.jboss; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshalledValueFactoryTestCase; /** * @author Paul Ferraro */ public class JBossByteBufferMarshalledValueFactoryTestCase extends ByteBufferMarshalledValueFactoryTestCase { public JBossByteBufferMarshalledValueFactoryTestCase() { super(TestJBossByteBufferMarshaller.INSTANCE); } }
1,431
38.777778
109
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossMarshallingNetTestCase.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.wildfly.clustering.marshalling.jboss; import org.wildfly.clustering.marshalling.AbstractNetTestCase; /** * @author Paul Ferraro */ public class JBossMarshallingNetTestCase extends AbstractNetTestCase { public JBossMarshallingNetTestCase() { super(JBossMarshallingTesterFactory.INSTANCE); } }
1,349
36.5
70
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossMarshallingCircularReferenceTestCase.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.marshalling.jboss; import org.wildfly.clustering.marshalling.AbstractCircularReferenceTestCase; /** * @author Paul Ferraro */ public class JBossMarshallingCircularReferenceTestCase extends AbstractCircularReferenceTestCase { public JBossMarshallingCircularReferenceTestCase() { super(JBossMarshallingTesterFactory.INSTANCE); } }
1,405
38.055556
98
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossMarshallingSQLTestCase.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.wildfly.clustering.marshalling.jboss; import org.wildfly.clustering.marshalling.AbstractSQLTestCase; /** * @author Paul Ferraro */ public class JBossMarshallingSQLTestCase extends AbstractSQLTestCase { public JBossMarshallingSQLTestCase() { super(JBossMarshallingTesterFactory.INSTANCE); } }
1,349
36.5
70
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossMarshallingLangTestCase.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.wildfly.clustering.marshalling.jboss; import org.wildfly.clustering.marshalling.AbstractLangTestCase; /** * @author Paul Ferraro */ public class JBossMarshallingLangTestCase extends AbstractLangTestCase { public JBossMarshallingLangTestCase() { super(JBossMarshallingTesterFactory.INSTANCE); } }
1,353
36.611111
72
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/TestJBossByteBufferMarshaller.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.marshalling.jboss; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.OptionalInt; import org.jboss.marshalling.MarshallingConfiguration; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; /** * @author Paul Ferraro */ public enum TestJBossByteBufferMarshaller implements MarshallingConfigurationRepository, ByteBufferMarshaller { INSTANCE; private final MarshallingConfiguration configuration; private final ByteBufferMarshaller marshaller; TestJBossByteBufferMarshaller() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); this.configuration = new MarshallingConfiguration(); this.configuration.setClassTable(new DynamicClassTable(loader)); this.configuration.setObjectTable(new DynamicExternalizerObjectTable(loader)); this.marshaller = new JBossByteBufferMarshaller(this, loader); } @Override public boolean isMarshallable(Object object) { return this.marshaller.isMarshallable(object); } @Override public Object readFrom(InputStream input) throws IOException { return this.marshaller.readFrom(input); } @Override public void writeTo(OutputStream output, Object object) throws IOException { this.marshaller.writeTo(output, object); } @Override public OptionalInt size(Object object) { return this.marshaller.size(object); } @Override public int getCurrentMarshallingVersion() { return 0; } @Override public MarshallingConfiguration getMarshallingConfiguration(int version) { return this.configuration; } }
2,746
33.3375
111
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossMarshallingUtilTestCase.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.wildfly.clustering.marshalling.jboss; import org.wildfly.clustering.marshalling.AbstractUtilTestCase; /** * @author Paul Ferraro */ public class JBossMarshallingUtilTestCase extends AbstractUtilTestCase { public JBossMarshallingUtilTestCase() { super(JBossMarshallingTesterFactory.INSTANCE); } }
1,353
36.611111
72
java
null
wildfly-main/clustering/marshalling/jboss/src/test/java/org/wildfly/clustering/marshalling/jboss/JBossMarshallingConcurrentTestCase.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.wildfly.clustering.marshalling.jboss; import org.wildfly.clustering.marshalling.AbstractConcurrentTestCase; /** * @author Paul Ferraro */ public class JBossMarshallingConcurrentTestCase extends AbstractConcurrentTestCase { public JBossMarshallingConcurrentTestCase() { super(JBossMarshallingTesterFactory.INSTANCE); } }
1,377
37.277778
84
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/DefaultExternalizerProviders.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.wildfly.clustering.marshalling.jboss; import java.util.EnumSet; import java.util.Set; import java.util.function.Supplier; import org.wildfly.clustering.marshalling.spi.ExternalizerProvider; import org.wildfly.clustering.marshalling.spi.MarshallingExternalizerProvider; import org.wildfly.clustering.marshalling.spi.net.NetExternalizerProvider; import org.wildfly.clustering.marshalling.spi.sql.SQLExternalizerProvider; import org.wildfly.clustering.marshalling.spi.time.TimeExternalizerProvider; import org.wildfly.clustering.marshalling.spi.util.UtilExternalizerProvider; import org.wildfly.clustering.marshalling.spi.util.concurrent.ConcurrentExternalizerProvider; import org.wildfly.clustering.marshalling.spi.util.concurrent.atomic.AtomicExternalizerProvider; /** * Default sets of externalizers. * @author Paul Ferraro */ public enum DefaultExternalizerProviders implements Supplier<Set<? extends ExternalizerProvider>> { NET(NetExternalizerProvider.class), SQL(SQLExternalizerProvider.class), TIME(TimeExternalizerProvider.class), UTIL(UtilExternalizerProvider.class), ATOMIC(AtomicExternalizerProvider.class), CONCURRENT(ConcurrentExternalizerProvider.class), MARSHALLING(MarshallingExternalizerProvider.class), ; private final Set<? extends ExternalizerProvider> providers; <E extends Enum<E> & ExternalizerProvider> DefaultExternalizerProviders(Class<E> providerClass) { this.providers = EnumSet.allOf(providerClass); } @Override public Set<? extends ExternalizerProvider> get() { return this.providers; } }
2,633
41.483871
101
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/SimpleClassTable.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.wildfly.clustering.marshalling.jboss; import java.io.IOException; import java.util.Arrays; import java.util.IdentityHashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; import org.jboss.marshalling.ClassTable; import org.jboss.marshalling.Marshaller; import org.jboss.marshalling.Unmarshaller; import org.wildfly.clustering.marshalling.spi.IndexSerializer; import org.wildfly.clustering.marshalling.spi.IntSerializer; /** * Simple {@link ClassTable} implementation based on an array of recognized classes. * @author Paul Ferraro */ public class SimpleClassTable implements ClassTable { private final List<Class<?>> classes; private final Map<Class<?>, Integer> indexes = new IdentityHashMap<>(); private final IntSerializer indexSerializer; public SimpleClassTable(Class<?>... classes) { this(Arrays.asList(classes)); } public SimpleClassTable(List<Class<?>> classes) { this(IndexSerializer.select(classes.size()), classes); } private SimpleClassTable(IntSerializer indexSerializer, List<Class<?>> classes) { this.indexSerializer = indexSerializer; this.classes = classes; ListIterator<Class<?>> iterator = classes.listIterator(); while (iterator.hasNext()) { this.indexes.putIfAbsent(iterator.next(), iterator.previousIndex()); } } @Override public Writer getClassWriter(Class<?> targetClass) { Integer index = this.indexes.get(targetClass); return (index != null) ? new ClassTableWriter(index, this.indexSerializer) : null; } @Override public Class<?> readClass(Unmarshaller input) throws IOException { return this.classes.get(this.indexSerializer.readInt(input)); } private static class ClassTableWriter implements ClassTable.Writer { private final int index; private final IntSerializer serializer; ClassTableWriter(int index, IntSerializer serializer) { this.index = index; this.serializer = serializer; } @Override public void writeClass(Marshaller marshaller, Class<?> clazz) throws IOException { this.serializer.writeInt(marshaller, this.index); } } }
3,294
35.611111
90
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/SimpleSerializabilityChecker.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.marshalling.jboss; import java.util.Set; import org.jboss.marshalling.SerializabilityChecker; /** * A {@link SerializabilityChecker} based on a fixed set of classes. * @author Paul Ferraro */ public class SimpleSerializabilityChecker implements SerializabilityChecker { private final Set<Class<?>> serializableClasses; public SimpleSerializabilityChecker(Set<Class<?>> serializableClasses) { this.serializableClasses = serializableClasses; } @Override public boolean isSerializable(Class<?> targetClass) { return (targetClass != Object.class) && (this.serializableClasses.contains(targetClass) || DEFAULT.isSerializable(targetClass)); } }
1,743
36.913043
136
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/ExternalizerAdapter.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.wildfly.clustering.marshalling.jboss; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import org.wildfly.clustering.marshalling.Externalizer; /** * Adapts a {@link org.wildfly.clustering.marshalling.Externalizer} to a JBoss Marshalling {@link org.jboss.marshalling.Externalizer}. * @author Paul Ferraro */ public class ExternalizerAdapter implements org.jboss.marshalling.Externalizer { private static final long serialVersionUID = 1714120446322944436L; private final Externalizer<Object> externalizer; @SuppressWarnings("unchecked") public ExternalizerAdapter(Externalizer<?> externalizer) { this.externalizer = (Externalizer<Object>) externalizer; } @Override public void writeExternal(Object subject, ObjectOutput output) throws IOException { this.externalizer.writeObject(output, subject); } @Override public Object createExternal(Class<?> subjectType, ObjectInput input) throws IOException, ClassNotFoundException { return this.externalizer.readObject(input); } }
2,120
37.563636
134
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/MarshallingConfigurationRepository.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.wildfly.clustering.marshalling.jboss; import org.jboss.marshalling.MarshallingConfiguration; /** * Repository of versioned {@link MarshallingConfiguration}s. * @author Paul Ferraro */ public interface MarshallingConfigurationRepository { int getCurrentMarshallingVersion(); MarshallingConfiguration getMarshallingConfiguration(int version); }
1,391
39.941176
70
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/ExternalizerObjectTable.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.wildfly.clustering.marshalling.jboss; import java.io.IOException; import java.lang.reflect.Modifier; import java.util.IdentityHashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; import org.jboss.marshalling.Marshaller; import org.jboss.marshalling.ObjectTable; import org.jboss.marshalling.Unmarshaller; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.clustering.marshalling.spi.IndexSerializer; import org.wildfly.clustering.marshalling.spi.IntSerializer; /** * {@link ObjectTable} implementation that dynamically loads {@link Externalizer} instances available from a given {@link ClassLoader}. * @author Paul Ferraro */ public class ExternalizerObjectTable implements ObjectTable { private final List<Externalizer<?>> externalizers; private final Map<Class<?>, Integer> indexes = new IdentityHashMap<>(); private final IntSerializer indexSerializer; public ExternalizerObjectTable(List<Externalizer<?>> externalizers) { this(IndexSerializer.select(externalizers.size()), externalizers); } @SafeVarargs public ExternalizerObjectTable(Externalizer<?>... externalizers) { this(List.of(externalizers)); } private ExternalizerObjectTable(IntSerializer indexSerializer, List<Externalizer<?>> externalizers) { this.indexSerializer = indexSerializer; this.externalizers = externalizers; ListIterator<Externalizer<?>> iterator = externalizers.listIterator(); while (iterator.hasNext()) { this.indexes.putIfAbsent(iterator.next().getTargetClass(), iterator.previousIndex()); } } @Override public Writer getObjectWriter(final Object object) throws IOException { Class<?> targetClass = object.getClass().isEnum() ? ((Enum<?>) object).getDeclaringClass() : object.getClass(); Class<?> superClass = targetClass.getSuperclass(); // If implementation class has no externalizer, search any abstract superclasses while (!this.indexes.containsKey(targetClass) && (superClass != null) && Modifier.isAbstract(superClass.getModifiers())) { targetClass = superClass; superClass = targetClass.getSuperclass(); } Integer index = this.indexes.get(targetClass); return (index != null) ? new ExternalizerWriter(index, this.indexSerializer, this.externalizers.get(index)) : null; } @Override public Object readObject(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException { int index = this.indexSerializer.readInt(unmarshaller); if (index >= this.externalizers.size()) { throw new IllegalStateException(); } return this.externalizers.get(index).readObject(unmarshaller); } private static class ExternalizerWriter implements ObjectTable.Writer { private final int index; private final IntSerializer serializer; private final Externalizer<Object> externalizer; @SuppressWarnings("unchecked") ExternalizerWriter(int index, IntSerializer serializer, Externalizer<?> externalizer) { this.index = index; this.serializer = serializer; this.externalizer = (Externalizer<Object>) externalizer; } @Override public void writeObject(Marshaller marshaller, Object object) throws IOException { this.serializer.writeInt(marshaller, this.index); this.externalizer.writeObject(marshaller, object); } } }
4,583
41.444444
135
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/SimpleMarshallingConfigurationRepository.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.wildfly.clustering.marshalling.jboss; import java.util.Arrays; import java.util.List; import java.util.function.Function; import org.jboss.marshalling.MarshallingConfiguration; /** * Simple {@link MarshallingConfigurationRepository} implementation based on an array of {@link MarshallingConfiguration}s. * Marshalling versions, while arbitrary, are sequential by convention; and start at 1, not 0, for purely historical reasons. * @author Paul Ferraro */ public class SimpleMarshallingConfigurationRepository implements MarshallingConfigurationRepository { private final MarshallingConfiguration[] configurations; private final int currentVersion; /** * Create a marshalling configuration repository using the specified enumeration of marshalling configuration suppliers. * @param enumClass an enum class * @param current the supplier of the current marshalling configuration * @param context the context with which to obtain the marshalling configuration */ public <C, E extends Enum<E> & Function<C, MarshallingConfiguration>> SimpleMarshallingConfigurationRepository(Class<E> enumClass, E current, C context) { this(current.ordinal() + 1, createConfigurations(enumClass, context)); } private static <C, E extends Enum<E> & Function<C, MarshallingConfiguration>> MarshallingConfiguration[] createConfigurations(Class<E> enumClass, C context) { List<Function<C, MarshallingConfiguration>> values = Arrays.asList(enumClass.getEnumConstants()); MarshallingConfiguration[] configurations = new MarshallingConfiguration[values.size()]; for (int i = 0; i < configurations.length; ++i) { configurations[i] = values.get(i).apply(context); } return configurations; } /** * Create a marshalling configuration repository using the specified marshalling configurations. The current version is always the last. * @param configurations */ public SimpleMarshallingConfigurationRepository(MarshallingConfiguration... configurations) { this(configurations.length, configurations); } /** * Create a marshalling configuration repository using the specified marshalling configurations. * @param currentVersion the current version * @param configurations the configurations for this repository */ private SimpleMarshallingConfigurationRepository(int currentVersion, MarshallingConfiguration... configurations) { this.currentVersion = currentVersion; this.configurations = configurations; } @Override public int getCurrentMarshallingVersion() { return this.currentVersion; } @Override public MarshallingConfiguration getMarshallingConfiguration(int version) { return this.configurations[version - 1]; } }
3,872
43.011364
162
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/JBossByteBufferMarshaller.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.wildfly.clustering.marshalling.jboss; import java.io.IOException; import java.io.InputStream; import java.io.InvalidClassException; import java.io.InvalidObjectException; import java.io.OutputStream; import java.lang.ref.WeakReference; import org.jboss.marshalling.ClassExternalizerFactory; import org.jboss.marshalling.Marshaller; import org.jboss.marshalling.MarshallerFactory; import org.jboss.marshalling.Marshalling; import org.jboss.marshalling.MarshallingConfiguration; import org.jboss.marshalling.ObjectTable; import org.jboss.marshalling.SerializabilityChecker; import org.jboss.marshalling.SimpleDataInput; import org.jboss.marshalling.SimpleDataOutput; import org.jboss.marshalling.Unmarshaller; import org.wildfly.clustering.marshalling.spi.IndexSerializer; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.security.manager.WildFlySecurityManager; /** * A {@link ByteBufferMarshaller} based on JBoss Marshalling. * @author Paul Ferraro */ public class JBossByteBufferMarshaller implements ByteBufferMarshaller { private final MarshallerFactory factory = Marshalling.getMarshallerFactory("river", Marshalling.class.getClassLoader()); private final MarshallingConfigurationRepository repository; private final WeakReference<ClassLoader> loader; public JBossByteBufferMarshaller(MarshallingConfigurationRepository repository, ClassLoader loader) { this.repository = repository; this.loader = new WeakReference<>(loader); } private MarshallingConfiguration getMarshallingConfiguration(int version) { return this.repository.getMarshallingConfiguration(version); } @Override public Object readFrom(InputStream input) throws IOException { try (SimpleDataInput data = new SimpleDataInput(Marshalling.createByteInput(input))) { int version = IndexSerializer.UNSIGNED_BYTE.readInt(data); ClassLoader loader = setThreadContextClassLoader(this.loader.get()); try (Unmarshaller unmarshaller = this.factory.createUnmarshaller(this.repository.getMarshallingConfiguration(version))) { unmarshaller.start(data); Object result = unmarshaller.readObject(); unmarshaller.finish(); return result; } catch (ClassNotFoundException e) { InvalidClassException exception = new InvalidClassException(e.getMessage()); exception.initCause(e); throw exception; } catch (RuntimeException e) { // Issues such as invalid lambda deserialization throw runtime exceptions InvalidObjectException exception = new InvalidObjectException(e.getMessage()); exception.initCause(e); throw exception; } finally { setThreadContextClassLoader(loader); } } } @Override public void writeTo(OutputStream output, Object value) throws IOException { int version = this.repository.getCurrentMarshallingVersion(); try (SimpleDataOutput data = new SimpleDataOutput(Marshalling.createByteOutput(output))) { IndexSerializer.UNSIGNED_BYTE.writeInt(data, version); ClassLoader loader = setThreadContextClassLoader(this.loader.get()); try (Marshaller marshaller = this.factory.createMarshaller(this.getMarshallingConfiguration(version))) { marshaller.start(data); marshaller.writeObject(value); marshaller.finish(); } finally { setThreadContextClassLoader(loader); } } } @Override public boolean isMarshallable(Object object) { if (object == null) return true; MarshallingConfiguration configuration = this.repository.getMarshallingConfiguration(this.repository.getCurrentMarshallingVersion()); try { ObjectTable table = configuration.getObjectTable(); if ((table != null) && table.getObjectWriter(object) != null) return true; ClassExternalizerFactory factory = configuration.getClassExternalizerFactory(); if ((factory != null) && (factory.getExternalizer(object.getClass()) != null)) return true; SerializabilityChecker checker = configuration.getSerializabilityChecker(); return ((checker == null) ? SerializabilityChecker.DEFAULT : checker).isSerializable(object.getClass()); } catch (IOException e) { return false; } } private static ClassLoader setThreadContextClassLoader(ClassLoader loader) { return (loader != null) ? WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(loader) : null; } }
5,817
45.174603
141
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/DynamicExternalizerObjectTable.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.marshalling.jboss; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.EnumSet; import java.util.LinkedList; import java.util.List; import java.util.ServiceLoader; import java.util.Set; import org.wildfly.clustering.marshalling.Externalizer; import org.wildfly.security.manager.WildFlySecurityManager; /** * @author Paul Ferraro */ public class DynamicExternalizerObjectTable extends ExternalizerObjectTable { public DynamicExternalizerObjectTable(ClassLoader loader) { this(List.of(loader)); } public DynamicExternalizerObjectTable(List<ClassLoader> loaders) { this(List.of(), loaders); } public DynamicExternalizerObjectTable(List<Externalizer<?>> externalizers, List<ClassLoader> loaders) { super(loadExternalizers(externalizers, loaders)); } private static List<Externalizer<?>> loadExternalizers(List<Externalizer<?>> externalizers, List<ClassLoader> loaders) { List<Externalizer<?>> loadedExternalizers = WildFlySecurityManager.doUnchecked(new PrivilegedAction<>() { @Override public List<Externalizer<?>> run() { List<Externalizer<?>> externalizers = new LinkedList<>(); for (ClassLoader loader : loaders) { for (Externalizer<? super Object> externalizer : ServiceLoader.load(Externalizer.class, loader)) { externalizers.add(externalizer); } } return externalizers; } }); Set<DefaultExternalizerProviders> providers = EnumSet.allOf(DefaultExternalizerProviders.class); int size = loadedExternalizers.size(); for (DefaultExternalizerProviders provider : providers) { size += provider.get().size(); } List<Externalizer<?>> result = new ArrayList<>(size); // Add static externalizers first result.addAll(externalizers); // Then default externalizers for (DefaultExternalizerProviders provider : providers) { result.addAll(provider.get()); } // Then loaded externalizers result.addAll(loadedExternalizers); return result; } }
3,289
38.638554
124
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/ClassTableContributor.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.wildfly.clustering.marshalling.jboss; import java.util.List; /** * Contributes known classes to a {@link org.jboss.marshalling.ClassTable}. * @author Paul Ferraro */ public interface ClassTableContributor { List<Class<?>> getKnownClasses(); }
1,287
38.030303
75
java
null
wildfly-main/clustering/marshalling/jboss/src/main/java/org/wildfly/clustering/marshalling/jboss/DynamicClassTable.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.wildfly.clustering.marshalling.jboss; import java.io.Externalizable; import java.io.Serializable; import java.security.PrivilegedAction; import java.time.Clock; import java.time.ZoneId; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.ServiceLoader; import java.util.TimeZone; import org.wildfly.security.manager.WildFlySecurityManager; /** * {@link org.jboss.marshalling.ClassTable} implementation that dynamically loads {@link ClassTableContributor} instances visible from a given {@link ClassLoader}. * @author Paul Ferraro */ public class DynamicClassTable extends SimpleClassTable { public DynamicClassTable(ClassLoader loader) { this(List.of(loader)); } public DynamicClassTable(List<ClassLoader> loaders) { super(findClasses(loaders)); } private static List<Class<?>> findClasses(List<ClassLoader> loaders) { List<Class<?>> knownClasses = WildFlySecurityManager.doUnchecked(new PrivilegedAction<List<Class<?>>>() { @Override public List<Class<?>> run() { List<Class<?>> classes = new LinkedList<>(); for (ClassLoader loader : loaders) { for (ClassTableContributor contributor : ServiceLoader.load(ClassTableContributor.class, loader)) { classes.addAll(contributor.getKnownClasses()); } } return classes; } }); List<Class<?>> classes = new ArrayList<>(knownClasses.size() + 36); classes.add(Serializable.class); classes.add(Externalizable.class); // Add common-use non-public JDK implementation classes classes.add(Clock.systemDefaultZone().getClass()); classes.add(TimeZone.getDefault().getClass()); classes.add(ZoneId.systemDefault().getClass()); List<Void> randomAccessList = Collections.emptyList(); List<Void> nonRandomAccessList = new LinkedList<>(); // Add collection wrapper types classes.add(Collections.checkedCollection(randomAccessList, Void.class).getClass()); classes.add(Collections.checkedCollection(nonRandomAccessList, Void.class).getClass()); classes.add(Collections.checkedList(randomAccessList, Void.class).getClass()); classes.add(Collections.checkedList(nonRandomAccessList, Void.class).getClass()); classes.add(Collections.checkedMap(Collections.emptyMap(), Void.class, Void.class).getClass()); classes.add(Collections.checkedNavigableMap(Collections.emptyNavigableMap(), Void.class, Void.class).getClass()); classes.add(Collections.checkedNavigableSet(Collections.emptyNavigableSet(), Void.class).getClass()); classes.add(Collections.checkedQueue(new LinkedList<>(), Void.class).getClass()); classes.add(Collections.checkedSet(Collections.emptySet(), Void.class).getClass()); classes.add(Collections.checkedSortedMap(Collections.emptySortedMap(), Void.class, Void.class).getClass()); classes.add(Collections.checkedSortedSet(Collections.emptySortedSet(), Void.class).getClass()); classes.add(Collections.synchronizedCollection(randomAccessList).getClass()); classes.add(Collections.synchronizedCollection(nonRandomAccessList).getClass()); classes.add(Collections.synchronizedList(randomAccessList).getClass()); classes.add(Collections.synchronizedList(nonRandomAccessList).getClass()); classes.add(Collections.synchronizedMap(Collections.emptyMap()).getClass()); classes.add(Collections.synchronizedNavigableMap(Collections.emptyNavigableMap()).getClass()); classes.add(Collections.synchronizedNavigableSet(Collections.emptyNavigableSet()).getClass()); classes.add(Collections.synchronizedSet(Collections.emptySet()).getClass()); classes.add(Collections.synchronizedSortedMap(Collections.emptySortedMap()).getClass()); classes.add(Collections.synchronizedSortedSet(Collections.emptySortedSet()).getClass()); classes.add(Collections.unmodifiableCollection(randomAccessList).getClass()); classes.add(Collections.unmodifiableCollection(nonRandomAccessList).getClass()); classes.add(Collections.unmodifiableList(randomAccessList).getClass()); classes.add(Collections.unmodifiableList(nonRandomAccessList).getClass()); classes.add(Collections.unmodifiableMap(Collections.emptyMap()).getClass()); classes.add(Collections.unmodifiableNavigableMap(Collections.emptyNavigableMap()).getClass()); classes.add(Collections.unmodifiableNavigableSet(Collections.emptyNavigableSet()).getClass()); classes.add(Collections.unmodifiableSet(Collections.emptySet()).getClass()); classes.add(Collections.unmodifiableSortedMap(Collections.emptySortedMap()).getClass()); classes.add(Collections.unmodifiableSortedSet(Collections.emptySortedSet()).getClass()); classes.addAll(knownClasses); return classes; } }
6,110
51.230769
163
java
null
wildfly-main/clustering/ejb/extension/src/test/java/org/wildfly/extension/clustering/ejb/DistributableEjbSubsystemTestCase.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.extension.clustering.ejb; import org.jboss.as.clustering.subsystem.AdditionalInitialization; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.subsystem.test.AbstractSubsystemSchemaTest; import org.jboss.as.subsystem.test.KernelServices; import org.jboss.dmr.ModelNode; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.InfinispanDefaultCacheRequirement; import java.util.EnumSet; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** * Unit test for distributable-ejb subsystem. * @author Paul Ferraro * @author Richard Achmatowicz */ @RunWith(value = Parameterized.class) public class DistributableEjbSubsystemTestCase extends AbstractSubsystemSchemaTest<DistributableEjbSubsystemSchema> { @Parameters public static Iterable<DistributableEjbSubsystemSchema> parameters() { return EnumSet.allOf(DistributableEjbSubsystemSchema.class); } public DistributableEjbSubsystemTestCase(DistributableEjbSubsystemSchema schema) { super(DistributableEjbExtension.SUBSYSTEM_NAME, new DistributableEjbExtension(), schema, DistributableEjbSubsystemSchema.CURRENT); } /** * The distributable-ejb subsystem depends on an infinispan cache-container and cache. */ @Override protected org.jboss.as.subsystem.test.AdditionalInitialization createAdditionalInitialization() { return new AdditionalInitialization() .require(InfinispanDefaultCacheRequirement.CONFIGURATION, "foo") .require(InfinispanCacheRequirement.CONFIGURATION, "foo", "bar") ; } /** * Verifies that we may add and remove additional bean-management providers. * @throws Exception for any test failures */ @Test public void testInfinispanBeanManagement() throws Exception { final String subsystemXml = getSubsystemXml(); final KernelServices ks = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(subsystemXml).build(); assertTrue("Subsystem boot failed!", ks.isSuccessfulBoot()); final PathAddress distributableEjbAddress = PathAddress.pathAddress(DistributableEjbResourceDefinition.PATH); final PathAddress anotherBeanManagementProviderAddress = distributableEjbAddress.append(InfinispanBeanManagementResourceDefinition.pathElement("another-bean-management-provider")); // add a new bean-management instance ModelNode anotherBeanManagementProvider = Util.createAddOperation(anotherBeanManagementProviderAddress); anotherBeanManagementProvider.get(InfinispanBeanManagementResourceDefinition.Attribute.CACHE_CONTAINER.getName()).set("foo"); anotherBeanManagementProvider.get(InfinispanBeanManagementResourceDefinition.Attribute.CACHE.getName()).set("bar"); anotherBeanManagementProvider.get(BeanManagementResourceDefinition.Attribute.MAX_ACTIVE_BEANS.getName()).set(11); ModelNode addResponse = ks.executeOperation(anotherBeanManagementProvider); assertEquals(addResponse.toString(), ModelDescriptionConstants.SUCCESS, addResponse.get(ModelDescriptionConstants.OUTCOME).asString()); // check max-active-beans attribute value ModelNode readMaxActiveBeansAttribute = Util.getReadAttributeOperation(anotherBeanManagementProviderAddress, BeanManagementResourceDefinition.Attribute.MAX_ACTIVE_BEANS.getName()); ModelNode readMaxActiveBeansResult = ks.executeOperation(readMaxActiveBeansAttribute); assertEquals(readMaxActiveBeansResult.toString(), ModelDescriptionConstants.SUCCESS, readMaxActiveBeansResult.get(ModelDescriptionConstants.OUTCOME).asString()); assertEquals(readMaxActiveBeansResult.toString(), 11, readMaxActiveBeansResult.get(ModelDescriptionConstants.RESULT).asInt()); // remove the bean management instance ModelNode removeAnotherBeanManagementProvider = Util.createRemoveOperation(anotherBeanManagementProviderAddress); ModelNode removeResponse = ks.executeOperation(removeAnotherBeanManagementProvider); assertEquals(removeResponse.toString(), ModelDescriptionConstants.SUCCESS, removeResponse.get(ModelDescriptionConstants.OUTCOME).asString()); } /** * Verifies that we may not have client mappings registry providers. * @throws Exception for any test failures */ @Test public void testClientMappingsRegistry() throws Exception { final String subsystemXml = getSubsystemXml(); final KernelServices ks = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(subsystemXml).build(); assertTrue("Subsystem boot failed!", ks.isSuccessfulBoot()); final PathAddress distributableEjbAddress = PathAddress.pathAddress(DistributableEjbResourceDefinition.PATH); final PathAddress infinispanClientMappingsRegistryProviderAddress = distributableEjbAddress.append(ClientMappingsRegistryProviderResourceDefinition.pathElement("infinispan")); // add a new client-mappings-registry instance ModelNode addInfinispanClientMappingsRegistryProvider = Util.createAddOperation(infinispanClientMappingsRegistryProviderAddress); addInfinispanClientMappingsRegistryProvider.get(InfinispanClientMappingsRegistryProviderResourceDefinition.Attribute.CACHE_CONTAINER.getName()).set("foo"); addInfinispanClientMappingsRegistryProvider.get(InfinispanClientMappingsRegistryProviderResourceDefinition.Attribute.CACHE.getName()).set("bar"); ModelNode addResponse = ks.executeOperation(addInfinispanClientMappingsRegistryProvider); assertEquals(addResponse.toString(), ModelDescriptionConstants.SUCCESS, addResponse.get(ModelDescriptionConstants.OUTCOME).asString()); // check that the old registry is no longer present and has been replaced by the new registry final ModelNode distributableEjbSubsystem = ks.readWholeModel().get(DistributableEjbResourceDefinition.PATH.getKeyValuePair()); final ModelNode localClientMappingsRegistryProvider = distributableEjbSubsystem.get(LocalClientMappingsRegistryProviderResourceDefinition.PATH.getKeyValuePair()); final ModelNode infinispanClientMappingsRegistryProvider = distributableEjbSubsystem.get(InfinispanClientMappingsRegistryProviderResourceDefinition.PATH.getKeyValuePair()); assertEquals(localClientMappingsRegistryProvider.toString(), false, localClientMappingsRegistryProvider.isDefined()); assertEquals(infinispanClientMappingsRegistryProvider.toString(), true, infinispanClientMappingsRegistryProvider.isDefined()); } /** * Verifies that attributes with expression are handled properly. * @throws Exception for any test failures */ @Test public void testExpressions() throws Exception { final String subsystemXml = getSubsystemXml(); final KernelServices ks = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(subsystemXml).build(); assertTrue("Subsystem boot failed!", ks.isSuccessfulBoot()); final ModelNode subsystem = ks.readWholeModel().get(DistributableEjbResourceDefinition.PATH.getKeyValuePair()); final ModelNode beanManagement = subsystem.get(InfinispanBeanManagementResourceDefinition.pathElement("default").getKeyValuePair()); // default within the expression should be 10000 final int maxActiveBeans = beanManagement.get(BeanManagementResourceDefinition.Attribute.MAX_ACTIVE_BEANS.getName()).resolve().asInt(); assertEquals(10000, maxActiveBeans); ModelNode persistentTimerManagement = subsystem.get(InfinispanTimerManagementResourceDefinition.pathElement("distributed").getKeyValuePair()); assertEquals(100, persistentTimerManagement.get(InfinispanTimerManagementResourceDefinition.Attribute.MAX_ACTIVE_TIMERS.getName()).resolve().asInt()); ModelNode transientTimerManagement = subsystem.get(InfinispanTimerManagementResourceDefinition.pathElement("transient").getKeyValuePair()); assertEquals(1000, transientTimerManagement.get(InfinispanTimerManagementResourceDefinition.Attribute.MAX_ACTIVE_TIMERS.getName()).resolve().asInt()); } }
9,594
59.727848
188
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/LocalClientMappingsRegistryProvider.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.extension.clustering.ejb; import java.util.List; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.network.ClientMapping; import org.wildfly.clustering.ejb.infinispan.network.ClientMappingsRegistryEntryServiceConfigurator; import org.wildfly.clustering.ejb.remote.ClientMappingsRegistryProvider; import org.wildfly.clustering.server.service.ProvidedCacheServiceConfigurator; import org.wildfly.clustering.server.service.group.LocalCacheGroupServiceConfiguratorProvider; import org.wildfly.clustering.server.service.registry.LocalRegistryServiceConfiguratorProvider; import org.wildfly.clustering.service.SupplierDependency; /** * A local client mappings registry provider implementation. * * @author Paul Ferraro * @author Richard Achmatowicz */ public class LocalClientMappingsRegistryProvider implements ClientMappingsRegistryProvider { static final String NAME = "ejb"; @Override public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String connectorName, SupplierDependency<List<ClientMapping>> clientMappings) { CapabilityServiceConfigurator registryEntryConfigurator = new ClientMappingsRegistryEntryServiceConfigurator(NAME, connectorName, clientMappings); CapabilityServiceConfigurator registryConfigurator = new ProvidedCacheServiceConfigurator<>(LocalRegistryServiceConfiguratorProvider.class, NAME, connectorName); CapabilityServiceConfigurator groupConfigurator = new ProvidedCacheServiceConfigurator<>(LocalCacheGroupServiceConfiguratorProvider.class, NAME, connectorName); return List.of(registryEntryConfigurator, registryConfigurator, groupConfigurator); } }
2,736
50.641509
169
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/InfinispanTimerManagementResourceDefinition.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.extension.clustering.ejb; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.CapabilityReference; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.clustering.controller.UnaryRequirementCapability; import org.jboss.as.clustering.controller.validation.IntRangeValidatorBuilder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.registry.AttributeAccess.Flag; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.wildfly.clustering.ejb.timer.TimerServiceRequirement; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.InfinispanDefaultCacheRequirement; import org.wildfly.clustering.service.UnaryRequirement; /** * @author Paul Ferraro */ public class InfinispanTimerManagementResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { static PathElement pathElement(String name) { return PathElement.pathElement("infinispan-timer-management", name); } static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); enum Capability implements CapabilityProvider { TIMER_MANAGEMENT_PROVIDER(TimerServiceRequirement.TIMER_MANAGEMENT_PROVIDER), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(UnaryRequirement requirement) { this.capability = new UnaryRequirementCapability(requirement); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { CACHE_CONTAINER("cache-container", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setAllowExpression(false) .setRequired(true) .setCapabilityReference(new CapabilityReference(Capability.TIMER_MANAGEMENT_PROVIDER, InfinispanDefaultCacheRequirement.CONFIGURATION)) ; } }, CACHE("cache", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setAllowExpression(false) .setCapabilityReference(new CapabilityReference(Capability.TIMER_MANAGEMENT_PROVIDER, InfinispanCacheRequirement.CONFIGURATION, CACHE_CONTAINER)); } }, MAX_ACTIVE_TIMERS("max-active-timers", ModelType.INT) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setValidator(new IntRangeValidatorBuilder().min(1).configure(builder).build()); } }, MARSHALLER("marshaller", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setDefaultValue(new ModelNode(TimerContextMarshallerFactory.JBOSS.name())) .setValidator(EnumValidator.create(TimerContextMarshallerFactory.class)) ; } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(true) .setRequired(false) .setFlags(Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } InfinispanTimerManagementResourceDefinition() { super(WILDCARD_PATH, DistributableEjbExtension.SUBSYSTEM_RESOLVER.createChildResolver(WILDCARD_PATH)); } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { // create the ManagementResourceRegistration for the infinispan-bean-management resource ManagementResourceRegistration registration = parent.registerSubModel(this); // create the resolver for the infinispan-bean-management resource ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()) .addAttributes(Attribute.class) .addCapabilities(Capability.class) ; // create the service handler for the infinispan-brean-management resource ResourceServiceHandler handler = new SimpleResourceServiceHandler(InfinispanTimerManagementServiceConfigurator::new); // register the resource descriptor and the handler new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
6,776
46.391608
170
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/DistributableEjbSubsystemModel.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.extension.clustering.ejb; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.SubsystemModel; /** * Enumerates the model versions for the distributable-ejb subsystem. * @author Paul Ferraro * @author Richard Achmatowicz */ public enum DistributableEjbSubsystemModel implements SubsystemModel { VERSION_1_0_0(1, 0, 0), // WildFly 27 ; public static final DistributableEjbSubsystemModel CURRENT = VERSION_1_0_0; private final ModelVersion version; DistributableEjbSubsystemModel(int major, int minor, int micro) { this.version = ModelVersion.create(major, minor, micro); } @Override public ModelVersion getVersion() { return this.version; } }
1,770
35.142857
79
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/DistributableEjbResourceDefinition.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.extension.clustering.ejb; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.CapabilityReference; import org.jboss.as.clustering.controller.DefaultSubsystemDescribeHandler; 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.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SubsystemRegistration; import org.jboss.as.clustering.controller.SubsystemResourceDefinition; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.CapabilityReferenceRecorder; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess.Flag; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelType; import org.wildfly.clustering.ejb.bean.BeanProviderRequirement; import org.wildfly.clustering.ejb.bean.DefaultBeanProviderRequirement; import org.wildfly.clustering.service.Requirement; /** * Definition of the /subsystem=distributable-ejb resource. * @author Paul Ferraro * @author Richard Achmatowicz */ public class DistributableEjbResourceDefinition extends SubsystemResourceDefinition { static final PathElement PATH = pathElement(DistributableEjbExtension.SUBSYSTEM_NAME); enum Capability implements CapabilityProvider { DEFAULT_BEAN_MANAGEMENT_PROVIDER(DefaultBeanProviderRequirement.BEAN_MANAGEMENT_PROVIDER), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(Requirement requirement) { this.capability = new RequirementCapability(requirement); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } } enum Attribute implements org.jboss.as.clustering.controller.Attribute { DEFAULT_BEAN_MANAGEMENT("default-bean-management", ModelType.STRING, new CapabilityReference(Capability.DEFAULT_BEAN_MANAGEMENT_PROVIDER, BeanProviderRequirement.BEAN_MANAGEMENT_PROVIDER)), ; private final AttributeDefinition definition; Attribute(String name, ModelType type, CapabilityReferenceRecorder reference) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(false) .setRequired(true) .setCapabilityReference(reference) .setFlags(Flag.RESTART_RESOURCE_SERVICES) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } DistributableEjbResourceDefinition() { super(PATH, DistributableEjbExtension.SUBSYSTEM_RESOLVER); } @Override public void register(SubsystemRegistration parent) { ManagementResourceRegistration registration = parent.registerSubsystemModel(this); new DefaultSubsystemDescribeHandler().register(registration); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()) .addAttributes(Attribute.class) .addCapabilities(Capability.class) .addRequiredSingletonChildren(LocalClientMappingsRegistryProviderResourceDefinition.PATH) ; ResourceServiceHandler handler = new DistributableEjbResourceServiceHandler(); new SimpleResourceRegistrar(descriptor, handler).register(registration); // register the child resource infinispan-bean-management new InfinispanBeanManagementResourceDefinition().register(registration); // register the child resources for client-mappings-registry-provider new LocalClientMappingsRegistryProviderResourceDefinition().register(registration); new InfinispanClientMappingsRegistryProviderResourceDefinition().register(registration); new InfinispanTimerManagementResourceDefinition().register(registration); } }
5,287
44.586207
197
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/DistributableEjbXMLDescriptionFactory.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.extension.clustering.ejb; import static org.jboss.as.controller.PersistentResourceXMLDescription.builder; import java.util.function.Function; import java.util.stream.Stream; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.controller.PersistentResourceXMLDescription; /** * Parser description for the distributable-ejb subsystem. * @author Paul Ferraro * @author Richard Achmatowicz */ public enum DistributableEjbXMLDescriptionFactory implements Function<DistributableEjbSubsystemSchema, PersistentResourceXMLDescription> { INSTANCE; @Override public PersistentResourceXMLDescription apply(DistributableEjbSubsystemSchema schema) { return builder(DistributableEjbResourceDefinition.PATH, schema.getNamespace()).addAttributes(Attribute.stream(DistributableEjbResourceDefinition.Attribute.class)) .addChild(builder(InfinispanBeanManagementResourceDefinition.WILDCARD_PATH).addAttributes(Stream.concat(Attribute.stream(BeanManagementResourceDefinition.Attribute.class), Attribute.stream(InfinispanBeanManagementResourceDefinition.Attribute.class)))) .addChild(builder(LocalClientMappingsRegistryProviderResourceDefinition.PATH).setXmlElementName("local-client-mappings-registry")) .addChild(builder(InfinispanClientMappingsRegistryProviderResourceDefinition.PATH).addAttributes(Attribute.stream(InfinispanClientMappingsRegistryProviderResourceDefinition.Attribute.class)).setXmlElementName("infinispan-client-mappings-registry")) .addChild(builder(InfinispanTimerManagementResourceDefinition.WILDCARD_PATH).addAttributes(Attribute.stream(InfinispanTimerManagementResourceDefinition.Attribute.class)).setXmlElementName("infinispan-timer-management")) .build(); } }
2,842
55.86
267
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/DistributableEjbSubsystemSchema.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.extension.clustering.ejb; import org.jboss.as.controller.PersistentResourceXMLDescription; import org.jboss.as.controller.PersistentSubsystemSchema; import org.jboss.as.controller.SubsystemSchema; import org.jboss.as.controller.xml.VersionedNamespace; import org.jboss.staxmapper.IntVersion; /** * Enumerates the schema versions for the distributable-ejb subsystem. * @author Paul Ferraro * @author Richard Achmatowicz */ public enum DistributableEjbSubsystemSchema implements PersistentSubsystemSchema<DistributableEjbSubsystemSchema> { VERSION_1_0(1, 0), // WildFly 27 ; static final DistributableEjbSubsystemSchema CURRENT = VERSION_1_0; private final VersionedNamespace<IntVersion, DistributableEjbSubsystemSchema> namespace; DistributableEjbSubsystemSchema(int major, int minor) { this.namespace = SubsystemSchema.createLegacySubsystemURN(DistributableEjbExtension.SUBSYSTEM_NAME, new IntVersion(major, minor)); } @Override public VersionedNamespace<IntVersion, DistributableEjbSubsystemSchema> getNamespace() { return this.namespace; } @Override public PersistentResourceXMLDescription getXMLDescription() { return DistributableEjbXMLDescriptionFactory.INSTANCE.apply(this); } }
2,311
39.561404
138
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/InfinispanClientMappingsRegistryProviderResourceDefinition.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.extension.clustering.ejb; import org.jboss.as.clustering.controller.CapabilityReference; 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.registry.AttributeAccess; import org.jboss.dmr.ModelType; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.InfinispanDefaultCacheRequirement; import java.util.function.UnaryOperator; /** * Definition of the /subsystem=distributable-ejb/client-mappings-registry=infinispan resource. * * @author Paul Ferraro * @author Richard Achmatowicz */ public class InfinispanClientMappingsRegistryProviderResourceDefinition extends ClientMappingsRegistryProviderResourceDefinition { static final PathElement PATH = pathElement("infinispan"); enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { CACHE_CONTAINER("cache-container", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setRequired(true) .setCapabilityReference(new CapabilityReference(Capability.CLIENT_MAPPINGS_REGISTRY_PROVIDER, InfinispanDefaultCacheRequirement.CONFIGURATION)) ; } }, CACHE("cache", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setRequired(false) .setCapabilityReference(new CapabilityReference(Capability.CLIENT_MAPPINGS_REGISTRY_PROVIDER, InfinispanCacheRequirement.CONFIGURATION, CACHE_CONTAINER)); } } ; private final AttributeDefinition definition ; Attribute(String name, ModelType type) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } InfinispanClientMappingsRegistryProviderResourceDefinition() { super(PATH, new SimpleResourceDescriptorConfigurator<>(Attribute.class), InfinispanClientMappingsRegistryProviderServiceConfigurator::new); } }
3,746
44.144578
178
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/ClientMappingsRegistryProviderServiceConfigurator.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.extension.clustering.ejb; import org.jboss.as.clustering.controller.CapabilityServiceNameProvider; import org.jboss.as.clustering.controller.ResourceServiceConfigurator; import org.jboss.as.controller.PathAddress; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.ejb.remote.ClientMappingsRegistryProvider; import org.wildfly.clustering.service.FunctionalService; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; /** * Base class service configurator for client mappings registry providers. * * @author Paul Ferraro * @author Richard Achmatowicz */ public abstract class ClientMappingsRegistryProviderServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, Supplier<ClientMappingsRegistryProvider> { public ClientMappingsRegistryProviderServiceConfigurator(PathAddress address) { super(ClientMappingsRegistryProviderResourceDefinition.Capability.CLIENT_MAPPINGS_REGISTRY_PROVIDER, address); } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<ClientMappingsRegistryProvider> provider = builder.provides(name); Service service = new FunctionalService<>(provider, Function.identity(), this); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } }
2,710
44.183333
192
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/InfinispanBeanManagementResourceDefinition.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.extension.clustering.ejb; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityReference; 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.registry.AttributeAccess.Flag; import org.jboss.dmr.ModelType; import org.wildfly.clustering.infinispan.service.InfinispanCacheRequirement; import org.wildfly.clustering.infinispan.service.InfinispanDefaultCacheRequirement; /** * Definition of the /subsystem=distributable-ejb/infinispan-bean-management=* resource. * * @author Paul Ferraro * @author Richard Achmatowicz */ public class InfinispanBeanManagementResourceDefinition extends BeanManagementResourceDefinition { static PathElement pathElement(String name) { return PathElement.pathElement("infinispan-bean-management", name); } static final PathElement WILDCARD_PATH = pathElement(PathElement.WILDCARD_VALUE); enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { CACHE_CONTAINER("cache-container", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setRequired(true).setCapabilityReference(new CapabilityReference(Capability.BEAN_MANAGEMENT_PROVIDER, InfinispanDefaultCacheRequirement.CONFIGURATION)); } }, CACHE("cache", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setCapabilityReference(new CapabilityReference(Capability.BEAN_MANAGEMENT_PROVIDER, InfinispanCacheRequirement.CONFIGURATION, CACHE_CONTAINER)); } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setRequired(false) .setFlags(Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } InfinispanBeanManagementResourceDefinition() { super(WILDCARD_PATH, new SimpleResourceDescriptorConfigurator<>(Attribute.class), InfinispanBeanManagementServiceConfigurator::new); } }
3,704
44.182927
183
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/TimerContextMarshallerFactory.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.extension.clustering.ejb; import java.util.function.Function; import org.jboss.marshalling.MarshallingConfiguration; import org.jboss.marshalling.ModularClassResolver; import org.jboss.modules.Module; import org.wildfly.clustering.marshalling.jboss.DynamicExternalizerObjectTable; import org.wildfly.clustering.marshalling.jboss.JBossByteBufferMarshaller; import org.wildfly.clustering.marshalling.jboss.SimpleMarshallingConfigurationRepository; import org.wildfly.clustering.marshalling.protostream.ModuleClassLoaderMarshaller; import org.wildfly.clustering.marshalling.protostream.ProtoStreamByteBufferMarshaller; import org.wildfly.clustering.marshalling.protostream.SerializationContextBuilder; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; /** * @author Paul Ferraro */ public enum TimerContextMarshallerFactory implements Function<Module, ByteBufferMarshaller> { JBOSS() { @Override public ByteBufferMarshaller apply(Module module) { MarshallingConfiguration config = new MarshallingConfiguration(); config.setClassResolver(ModularClassResolver.getInstance(module.getModuleLoader())); config.setObjectTable(new DynamicExternalizerObjectTable(module.getClassLoader())); return new JBossByteBufferMarshaller(new SimpleMarshallingConfigurationRepository(config), module.getClassLoader()); } }, PROTOSTREAM() { @Override public ByteBufferMarshaller apply(Module module) { SerializationContextBuilder builder = new SerializationContextBuilder(new ModuleClassLoaderMarshaller(module.getModuleLoader())).load(module.getClassLoader()); return new ProtoStreamByteBufferMarshaller(builder.build()); } }, ; }
2,816
45.180328
171
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/DistributableEjbExtension.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.extension.clustering.ejb; import org.jboss.as.clustering.controller.PersistentSubsystemExtension; import org.jboss.as.controller.Extension; import org.jboss.as.controller.descriptions.ParentResourceDescriptionResolver; import org.jboss.as.controller.descriptions.SubsystemResourceDescriptionResolver; import org.kohsuke.MetaInfServices; /** * Defines the extension for the distributable-ejb subsystem. * * @author Paul Ferraro * @author Richard Achmatowicz */ @MetaInfServices(Extension.class) public class DistributableEjbExtension extends PersistentSubsystemExtension<DistributableEjbSubsystemSchema> { static final String SUBSYSTEM_NAME = "distributable-ejb"; static final ParentResourceDescriptionResolver SUBSYSTEM_RESOLVER = new SubsystemResourceDescriptionResolver(SUBSYSTEM_NAME, DistributableEjbExtension.class); public DistributableEjbExtension() { super(SUBSYSTEM_NAME, DistributableEjbSubsystemModel.CURRENT, DistributableEjbResourceDefinition::new, DistributableEjbSubsystemSchema.CURRENT); } }
2,084
44.326087
162
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/LocalClientMappingsRegistryProviderResourceDefinition.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.extension.clustering.ejb; import org.jboss.as.controller.PathElement; import java.util.function.UnaryOperator; /** * Definition of the /subsystem=distributable-ejb/client-mappings-registry=local resource. * * @author Paul Ferraro * @author Richard Achmatowicz */ public class LocalClientMappingsRegistryProviderResourceDefinition extends ClientMappingsRegistryProviderResourceDefinition { static final PathElement PATH = pathElement("local"); LocalClientMappingsRegistryProviderResourceDefinition() { super(PATH, UnaryOperator.identity(), LocalClientMappingsRegistryProviderServiceConfigurator::new); } }
1,678
38.97619
125
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/DistributableEjbResourceServiceHandler.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.extension.clustering.ejb; import static org.wildfly.extension.clustering.ejb.DistributableEjbResourceDefinition.Attribute.DEFAULT_BEAN_MANAGEMENT; import static org.wildfly.extension.clustering.ejb.DistributableEjbResourceDefinition.Capability.DEFAULT_BEAN_MANAGEMENT_PROVIDER; import java.util.EnumSet; import org.jboss.as.clustering.controller.IdentityCapabilityServiceConfigurator; import org.jboss.as.clustering.controller.ResourceServiceHandler; 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.ejb.bean.BeanProviderRequirement; import org.wildfly.extension.clustering.ejb.DistributableEjbResourceDefinition.Capability; /** * {@link ResourceServiceHandler} for the /subsystem=distributable-ejb resource. * @author Paul Ferraro * @author Richard Achmatowicz */ public class DistributableEjbResourceServiceHandler implements ResourceServiceHandler { @Override public void installServices(OperationContext context, ModelNode model) throws OperationFailedException { String name = DEFAULT_BEAN_MANAGEMENT.resolveModelAttribute(context, model).asString(); new IdentityCapabilityServiceConfigurator<>(DEFAULT_BEAN_MANAGEMENT_PROVIDER.getServiceName(context.getCurrentAddress()), BeanProviderRequirement.BEAN_MANAGEMENT_PROVIDER, name) .configure(context) .build(context.getServiceTarget()) .install(); } @Override public void removeServices(OperationContext context, ModelNode model) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); for (Capability capability : EnumSet.allOf(Capability.class)) { context.removeService(capability.getServiceName(address)); } } }
2,937
46.387097
185
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/LocalClientMappingsRegistryProviderServiceConfigurator.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.extension.clustering.ejb; import org.jboss.as.controller.PathAddress; import org.wildfly.clustering.ejb.remote.ClientMappingsRegistryProvider; /** * Service configurator for local client mappings registry provider. * * @author Paul Ferraro * @author Richard Achmatowicz */ public class LocalClientMappingsRegistryProviderServiceConfigurator extends ClientMappingsRegistryProviderServiceConfigurator { public LocalClientMappingsRegistryProviderServiceConfigurator(PathAddress address) { super(address); } @Override public ClientMappingsRegistryProvider get() { return new LocalClientMappingsRegistryProvider(); } }
1,702
37.704545
127
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/BeanManagementServiceConfigurator.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.extension.clustering.ejb; import static org.wildfly.extension.clustering.ejb.BeanManagementResourceDefinition.Attribute.MAX_ACTIVE_BEANS; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.jboss.as.clustering.controller.CapabilityServiceNameProvider; import org.jboss.as.clustering.controller.ResourceServiceConfigurator; 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; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.ejb.bean.BeanManagementConfiguration; import org.wildfly.clustering.ejb.bean.BeanManagementProvider; import org.wildfly.clustering.ejb.bean.BeanDeploymentMarshallingContext; import org.wildfly.clustering.ejb.cache.bean.BeanMarshallerFactory; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceConfigurator; /** * Common service configurator for bean management services. * @author Paul Ferraro */ public abstract class BeanManagementServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, Supplier<BeanManagementProvider>, Function<String, BeanManagementProvider>, BeanManagementConfiguration { private final String name; private volatile Integer maxActiveBeans; public BeanManagementServiceConfigurator(PathAddress address) { super(BeanManagementResourceDefinition.Capability.BEAN_MANAGEMENT_PROVIDER, address); // set the name of this provider this.name = address.getLastElement().getValue(); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.maxActiveBeans = MAX_ACTIVE_BEANS.resolveModelAttribute(context, model).asIntOrNull(); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<BeanManagementProvider> provider = builder.provides(name); Service service = new FunctionalService<>(provider, Function.identity(), this); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } @Override public BeanManagementProvider get() { return this.apply(this.name); } @Override public Integer getMaxActiveBeans() { return this.maxActiveBeans; } @Override public Function<BeanDeploymentMarshallingContext, ByteBufferMarshaller> getMarshallerFactory() { return BeanMarshallerFactory.JBOSS; } }
4,039
41.526316
240
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/ClientMappingsRegistryProviderResourceDefinition.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.extension.clustering.ejb; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.RequirementCapability; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.wildfly.clustering.ejb.remote.RemoteEjbRequirement; import org.wildfly.clustering.service.Requirement; import java.util.function.UnaryOperator; /** * Base class definition of the /subsystem=distributable-ejb/client-mappings-registry=* resource. * * @author Paul Ferraro * @author Richard Achmatowicz */ public class ClientMappingsRegistryProviderResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { static PathElement pathElement(String value) { return PathElement.pathElement("client-mappings-registry", value); } enum Capability implements CapabilityProvider, UnaryOperator<RuntimeCapability.Builder<Void>> { CLIENT_MAPPINGS_REGISTRY_PROVIDER(RemoteEjbRequirement.CLIENT_MAPPINGS_REGISTRY_PROVIDER), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(Requirement requirement) { this.capability = new RequirementCapability(requirement, this); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } @Override public RuntimeCapability.Builder<Void> apply(RuntimeCapability.Builder<Void> builder) { return builder.setAllowMultipleRegistrations(true); } } private final UnaryOperator<ResourceDescriptor> configurator; private final ResourceServiceConfiguratorFactory serviceConfiguratorFactory; ClientMappingsRegistryProviderResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ResourceServiceConfiguratorFactory serviceConfiguratorFactory) { super(path, DistributableEjbExtension.SUBSYSTEM_RESOLVER.createChildResolver(path)); this.configurator = configurator; this.serviceConfiguratorFactory = serviceConfiguratorFactory; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = this.configurator.apply(new ResourceDescriptor(this.getResourceDescriptionResolver())) .addCapabilities(Capability.class) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(this.serviceConfiguratorFactory); new SimpleResourceRegistrar(descriptor, handler).register(registration); return registration; } }
4,288
45.619565
183
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/InfinispanTimerManagementServiceConfigurator.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.extension.clustering.ejb; import static org.wildfly.extension.clustering.ejb.InfinispanTimerManagementResourceDefinition.Attribute.*; import java.util.function.Consumer; import java.util.function.Function; import org.jboss.as.clustering.controller.CapabilityServiceNameProvider; import org.jboss.as.clustering.controller.ResourceServiceConfigurator; 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.modules.Module; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.ejb.infinispan.timer.InfinispanTimerManagementConfiguration; import org.wildfly.clustering.ejb.infinispan.timer.InfinispanTimerManagementProvider; import org.wildfly.clustering.ejb.timer.TimerManagementProvider; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; import org.wildfly.clustering.service.ServiceConfigurator; /** * @author Paul Ferraro */ public class InfinispanTimerManagementServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, InfinispanTimerManagementConfiguration { private volatile String containerName; private volatile String cacheName; private volatile Integer maxActiveTimers; private volatile Function<Module, ByteBufferMarshaller> marshallerFactory; public InfinispanTimerManagementServiceConfigurator(PathAddress address) { super(InfinispanTimerManagementResourceDefinition.Capability.TIMER_MANAGEMENT_PROVIDER, address); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.containerName = CACHE_CONTAINER.resolveModelAttribute(context, model).asString(); this.cacheName = CACHE.resolveModelAttribute(context, model).asStringOrNull(); this.maxActiveTimers = MAX_ACTIVE_TIMERS.resolveModelAttribute(context, model).asIntOrNull(); this.marshallerFactory = TimerContextMarshallerFactory.valueOf(MARSHALLER.resolveModelAttribute(context, model).asString()); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<TimerManagementProvider> provider = builder.provides(name); return builder.setInstance(Service.newInstance(provider, new InfinispanTimerManagementProvider(this))).setInitialMode(ServiceController.Mode.ON_DEMAND); } @Override public Function<Module, ByteBufferMarshaller> getMarshallerFactory() { return this.marshallerFactory; } @Override public Integer getMaxActiveTimers() { return this.maxActiveTimers; } @Override public String getContainerName() { return this.containerName; } @Override public String getCacheName() { return this.cacheName; } }
4,225
41.686869
176
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/InfinispanBeanManagementServiceConfigurator.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.extension.clustering.ejb; 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.ejb.bean.BeanManagementProvider; import org.wildfly.clustering.ejb.infinispan.bean.InfinispanBeanManagementConfiguration; import org.wildfly.clustering.ejb.infinispan.bean.InfinispanBeanManagementProvider; import org.wildfly.clustering.service.ServiceConfigurator; import static org.wildfly.extension.clustering.ejb.InfinispanBeanManagementResourceDefinition.Attribute.CACHE; import static org.wildfly.extension.clustering.ejb.InfinispanBeanManagementResourceDefinition.Attribute.CACHE_CONTAINER; /** * Service configurator for Infinispan bean management providers. * * @author Paul Ferraro * @author Richard Achmatowicz */ public class InfinispanBeanManagementServiceConfigurator extends BeanManagementServiceConfigurator implements InfinispanBeanManagementConfiguration { private volatile String containerName; private volatile String cacheName; public InfinispanBeanManagementServiceConfigurator(PathAddress address) { super(address); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.containerName = CACHE_CONTAINER.resolveModelAttribute(context, model).asString(); this.cacheName = CACHE.resolveModelAttribute(context, model).asStringOrNull(); return super.configure(context, model); } @Override public BeanManagementProvider apply(String name) { return new InfinispanBeanManagementProvider(name, this); } @Override public String getContainerName() { return this.containerName; } @Override public String getCacheName() { return this.cacheName; } }
2,950
38.878378
149
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/BeanManagementResourceDefinition.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.extension.clustering.ejb; import java.util.function.UnaryOperator; import org.jboss.as.clustering.controller.CapabilityProvider; import org.jboss.as.clustering.controller.ChildResourceDefinition; import org.jboss.as.clustering.controller.ResourceDescriptor; import org.jboss.as.clustering.controller.ResourceServiceConfiguratorFactory; import org.jboss.as.clustering.controller.ResourceServiceHandler; import org.jboss.as.clustering.controller.SimpleResourceRegistrar; import org.jboss.as.clustering.controller.SimpleResourceServiceHandler; import org.jboss.as.clustering.controller.UnaryCapabilityNameResolver; import org.jboss.as.clustering.controller.UnaryRequirementCapability; import org.jboss.as.clustering.controller.validation.IntRangeValidatorBuilder; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.AttributeAccess.Flag; import org.jboss.dmr.ModelType; import org.wildfly.clustering.ejb.bean.BeanProviderRequirement; import org.wildfly.clustering.service.UnaryRequirement; /** * Common resource definition for bean management resources. * @author Paul Ferraro */ public class BeanManagementResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { enum Capability implements CapabilityProvider, UnaryOperator<RuntimeCapability.Builder<Void>> { BEAN_MANAGEMENT_PROVIDER(BeanProviderRequirement.BEAN_MANAGEMENT_PROVIDER), ; private final org.jboss.as.clustering.controller.Capability capability; Capability(UnaryRequirement requirement) { this.capability = new UnaryRequirementCapability(requirement, this); } @Override public org.jboss.as.clustering.controller.Capability getCapability() { return this.capability; } @Override public RuntimeCapability.Builder<Void> apply(RuntimeCapability.Builder<Void> builder) { return builder.setDynamicNameMapper(UnaryCapabilityNameResolver.DEFAULT) .addRequirements(ClientMappingsRegistryProviderResourceDefinition.Capability.CLIENT_MAPPINGS_REGISTRY_PROVIDER.getName()); } } enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator<SimpleAttributeDefinitionBuilder> { MAX_ACTIVE_BEANS("max-active-beans", ModelType.INT) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setAllowExpression(true).setValidator(new IntRangeValidatorBuilder().min(1).configure(builder).build()); } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setRequired(false) .setFlags(Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } private final UnaryOperator<ResourceDescriptor> configurator; private final ResourceServiceConfiguratorFactory factory; BeanManagementResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ResourceServiceConfiguratorFactory factory) { super(path, DistributableEjbExtension.SUBSYSTEM_RESOLVER.createChildResolver(path, PathElement.pathElement("bean-management"))); this.configurator = configurator; this.factory = factory; } @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()) .addAttributes(Attribute.class) .addCapabilities(Capability.class) ; ResourceServiceHandler handler = new SimpleResourceServiceHandler(this.factory); new SimpleResourceRegistrar(this.configurator.apply(descriptor), handler).register(registration); return registration; } }
5,525
44.669421
148
java
null
wildfly-main/clustering/ejb/extension/src/main/java/org/wildfly/extension/clustering/ejb/InfinispanClientMappingsRegistryProviderServiceConfigurator.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.extension.clustering.ejb; import static org.wildfly.extension.clustering.ejb.InfinispanClientMappingsRegistryProviderResourceDefinition.Attribute.CACHE_CONTAINER; import static org.wildfly.extension.clustering.ejb.InfinispanClientMappingsRegistryProviderResourceDefinition.Attribute.CACHE; 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.ejb.infinispan.remote.InfinispanClientMappingsRegistryProvider; import org.wildfly.clustering.ejb.remote.ClientMappingsRegistryProvider; import org.wildfly.clustering.service.ServiceConfigurator; /** * Service configurator for Infinispan-based distributed client mappings registry provider. * * @author Paul Ferraro * @author Richard Achmatowicz */ public class InfinispanClientMappingsRegistryProviderServiceConfigurator extends ClientMappingsRegistryProviderServiceConfigurator { private volatile String containerName; private volatile String cacheName; public InfinispanClientMappingsRegistryProviderServiceConfigurator(PathAddress address) { super(address); } @Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.containerName = CACHE_CONTAINER.resolveModelAttribute(context, model).asString(); this.cacheName = CACHE.resolveModelAttribute(context, model).asStringOrNull(); return this; } @Override public ClientMappingsRegistryProvider get() { return new InfinispanClientMappingsRegistryProvider(this.containerName, this.cacheName); } }
2,755
43.451613
136
java
null
wildfly-main/clustering/ejb/spi/src/test/java/org/wildfly/clustering/ejb/bean/BeanExpirationMetaDataTestCase.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.ejb.bean; import java.time.Duration; import java.time.Instant; import org.junit.Assert; import org.junit.Test; /** * Validates BeanExpirationMetaData logic. * @author Paul Ferraro */ public class BeanExpirationMetaDataTestCase { @Test public void nullTimeout() { BeanExpirationMetaData metaData = new BeanExpirationMetaData() { @Override public Duration getTimeout() { return null; } @Override public Instant getLastAccessTime() { return Instant.now().plus(Duration.ofHours(1)); } }; Assert.assertFalse(metaData.isExpired()); Assert.assertTrue(metaData.isImmortal()); } @Test public void negativeTimeout() { BeanExpirationMetaData metaData = new BeanExpirationMetaData() { @Override public Duration getTimeout() { return Duration.ofSeconds(-1); } @Override public Instant getLastAccessTime() { return Instant.now().plus(Duration.ofHours(1)); } }; Assert.assertFalse(metaData.isExpired()); Assert.assertTrue(metaData.isImmortal()); } @Test public void zeroTimeout() { BeanExpirationMetaData metaData = new BeanExpirationMetaData() { @Override public Duration getTimeout() { return Duration.ZERO; } @Override public Instant getLastAccessTime() { return Instant.now().plus(Duration.ofHours(1)); } }; Assert.assertTrue(metaData.isExpired()); Assert.assertFalse(metaData.isImmortal()); } @Test public void expired() { BeanExpirationMetaData metaData = new BeanExpirationMetaData() { @Override public Duration getTimeout() { return Duration.ofMinutes(1); } @Override public Instant getLastAccessTime() { return Instant.now().minus(Duration.ofHours(1)); } }; Assert.assertTrue(metaData.isExpired()); Assert.assertFalse(metaData.isImmortal()); } @Test public void notYetExpired() { BeanExpirationMetaData metaData = new BeanExpirationMetaData() { @Override public Duration getTimeout() { return Duration.ofHours(1); } @Override public Instant getLastAccessTime() { return Instant.now(); } }; Assert.assertFalse(metaData.isExpired()); Assert.assertFalse(metaData.isImmortal()); } }
3,789
28.84252
72
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/DeploymentConfiguration.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.ejb; import org.jboss.modules.Module; import org.jboss.msc.service.ServiceName; /** * @author Paul Ferraro */ public interface DeploymentConfiguration extends org.wildfly.clustering.ee.DeploymentConfiguration { /** * Returns the service name of the deployment containing the EJB. * @return the service name for the deployment */ ServiceName getDeploymentServiceName(); /** * Returns the module of the deployment. * @return a module */ Module getModule(); }
1,564
33.777778
100
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/remote/AffinitySupport.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.wildfly.clustering.ejb.remote; import org.jboss.ejb.client.Affinity; /** * Defines the affinity requirements for remote clients. * * @author Paul Ferraro * * @param <I> the bean type */ public interface AffinitySupport<I> { /** * Returns the strong affinity for all invocations. * Strong affinity indicates a strict load balancing requirement. * @return an affinity */ Affinity getStrongAffinity(); /** * Returns the weak affinity of the specified bean identifier. * Weak affinity indicates a load balancing preference within the confines of the strong affinity. * @param id a bean identifier * @return an affinity */ Affinity getWeakAffinity(I id); }
1,757
34.877551
102
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/remote/ClientMappingsRegistryProvider.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.wildfly.clustering.ejb.remote; import java.util.List; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.network.ClientMapping; import org.wildfly.clustering.service.SupplierDependency; /** * interface defining ClientMappingsRegistryProvider instances, used to install configured ClientMappingsRegistry services. * * @author Paul Ferraro */ public interface ClientMappingsRegistryProvider { Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String connectorName, SupplierDependency<List<ClientMapping>> clientMappings); }
1,626
39.675
146
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/remote/RemoteEjbRequirement.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.ejb.remote; import org.jboss.as.clustering.controller.RequirementServiceNameFactory; import org.jboss.as.clustering.controller.ServiceNameFactory; import org.jboss.as.clustering.controller.ServiceNameFactoryProvider; import org.wildfly.clustering.service.Requirement; public enum RemoteEjbRequirement implements Requirement, ServiceNameFactoryProvider { CLIENT_MAPPINGS_REGISTRY_PROVIDER("org.wildfly.clustering.ejb.client-mappings-registry-provider", ClientMappingsRegistryProvider.class) ; private final String name; private final Class<?> type; private final ServiceNameFactory factory; RemoteEjbRequirement(final String name, final Class<?> type) { this.name = name; this.type = type; this.factory = new RequirementServiceNameFactory(this); } @Override public String getName() { return this.name; } @Override public Class<?> getType() { return this.type; } @Override public ServiceNameFactory getServiceNameFactory() { return this.factory; } }
2,120
36.210526
139
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/remote/LegacyClientMappingsRegistryProviderFactory.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.ejb.remote; /** * interface for obtaining ClientMappingsRegistryProvider instances in the legacy case where no distributable-ejb subsystem is present. * * @author Paul Ferraro * @author Richard Achmatowicz */ @Deprecated public interface LegacyClientMappingsRegistryProviderFactory { ClientMappingsRegistryProvider createClientMappingsRegistryProvider(String clusterName); }
1,439
41.352941
135
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/ScheduleTimerConfiguration.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.ejb.timer; import java.time.Instant; import java.time.temporal.ChronoUnit; /** * Encapsulates the configuration of a schedule timer. * @author Paul Ferraro */ public interface ScheduleTimerConfiguration extends TimerConfiguration { ImmutableScheduleExpression getScheduleExpression(); @Override default Instant getStart() { return Instant.now().truncatedTo(ChronoUnit.MILLIS); } }
1,467
34.804878
72
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimeoutListener.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.ejb.timer; import java.util.concurrent.ExecutionException; import org.wildfly.clustering.ee.Batch; /** * A listener to be invoked on timeout of a timer. * @author Paul Ferraro * @param <I> the timer identifier type * @param <B> the batch type */ public interface TimeoutListener<I, B extends Batch> { void timeout(TimerManager<I, B> manager, Timer<I> timer) throws ExecutionException; }
1,455
36.333333
87
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerManager.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.ejb.timer; import java.lang.reflect.Method; import java.util.function.Supplier; import java.util.stream.Stream; import org.wildfly.clustering.ee.Batch; import org.wildfly.clustering.ee.Batcher; import org.wildfly.clustering.ee.Restartable; /** * Manages creation, retrieval, and scheduling of timers. * @author Paul Ferraro * @param <I> the timer identifier type * @param <B> the batch type */ public interface TimerManager<I, B extends Batch> extends Restartable { Timer<I> createTimer(I id, IntervalTimerConfiguration config, Object context); Timer<I> createTimer(I id, ScheduleTimerConfiguration config, Object context); Timer<I> createTimer(I id, ScheduleTimerConfiguration config, Object context, Method method, int index); Timer<I> getTimer(I id); Stream<I> getActiveTimers(); Batcher<B> getBatcher(); Supplier<I> getIdentifierFactory(); }
1,944
34.363636
108
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/ImmutableScheduleExpression.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.ejb.timer; import java.time.Instant; import java.time.ZoneId; /** * Immutable view of a {@link jakarta.ejb.ScheduleExpression}. * @author Paul Ferraro */ public interface ImmutableScheduleExpression { String getSecond(); String getMinute(); String getHour(); String getDayOfMonth(); String getMonth(); String getDayOfWeek(); String getYear(); ZoneId getZone(); Instant getStart(); Instant getEnd(); }
1,504
31.021277
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/ScheduleTimerOperationProvider.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.ejb.timer; import java.time.Instant; import java.util.function.UnaryOperator; /** * Creates an operator for a given schedule expression, used to determine the next time a scheduled timer should timeout. * @author Paul Ferraro */ public interface ScheduleTimerOperationProvider { UnaryOperator<Instant> createOperator(ImmutableScheduleExpression expression); }
1,425
38.611111
121
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerServiceConfiguration.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.ejb.timer; import org.wildfly.clustering.ejb.DeploymentConfiguration; /** * Encapsulates the configuration of a timer service. * @author Paul Ferraro */ public interface TimerServiceConfiguration extends DeploymentConfiguration { /** * The name of the component containing the timer service. * @return a component name */ String getName(); }
1,426
35.589744
76
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerManagementProvider.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.ejb.timer; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; /** * Provides timer management service installation mechanics for a component. * @author Paul Ferraro */ public interface TimerManagementProvider { <I> CapabilityServiceConfigurator getTimerManagerFactoryServiceConfigurator(TimerManagerFactoryConfiguration<I> config); }
1,420
40.794118
124
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerMetaData.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.ejb.timer; import java.time.Instant; /** * Describes the metadata of a timer. * @author Paul Ferraro */ public interface TimerMetaData extends ImmutableTimerMetaData { void setLastTimout(Instant timeout); }
1,272
35.371429
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/IntervalTimerConfiguration.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.ejb.timer; import java.time.Duration; /** * Encapsulates the configuration of an interval timer. * @author Paul Ferraro */ public interface IntervalTimerConfiguration extends TimerConfiguration { default Duration getInterval() { // A single action timer has no interval return null; } }
1,372
35.131579
72
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerManagerFactory.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.ejb.timer; import org.wildfly.clustering.ee.Batch; /** * Factory for creating a {@link TimerManager}. * @author Paul Ferraro * @param <I> the timer identifier type * @param <B> the batch type */ public interface TimerManagerFactory<I, B extends Batch> { TimerManager<I, B> createTimerManager(TimerManagerConfiguration<I, B> configuration); }
1,409
37.108108
89
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerExpirationMetaData.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.ejb.timer; import java.time.Instant; /** * Describes the expiration-related metadata of a timer. * @author Paul Ferraro */ public interface TimerExpirationMetaData { Instant getNextTimeout(); }
1,259
35
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerManagerConfiguration.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.ejb.timer; import org.wildfly.clustering.ee.Batch; /** * Encapsulates the configuration of a {@link TimerManager}. * @author Paul Ferraro * @param <I> the timer identifier type * @param <B> the batch type */ public interface TimerManagerConfiguration<I, B extends Batch> extends TimerManagerFactoryConfiguration<I> { TimeoutListener<I, B> getListener(); }
1,423
37.486486
108
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerRegistry.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.ejb.timer; /** * Exposes the mechanism for registering arbitrary timers with the system, e.g. management model. * @author Paul Ferraro * @param <I> the timer identifier type */ public interface TimerRegistry<I> { void register(I id); void unregister(I id); }
1,329
35.944444
97
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerType.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.ejb.timer; /** * Enumerates the supported timer types. * @author Paul Ferraro */ public enum TimerType { INTERVAL(false), SCHEDULE(true), ; private final boolean calendar; TimerType(boolean calendar) { this.calendar = calendar; } public boolean isCalendar() { return this.calendar; } }
1,396
30.75
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/ScheduledTimer.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.ejb.timer; /** * A {@link Timer} that executes according to a configured schedule. * @author Paul Ferraro */ public interface ScheduledTimer<I> extends Timer<I> { @Override TimerMetaData getMetaData(); }
1,272
36.441176
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/ImmutableTimerMetaData.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.ejb.timer; import java.lang.reflect.Method; import java.time.Instant; import java.util.function.Predicate; /** * Describes the immutable metadata of a timer. * @author Paul Ferraro */ public interface ImmutableTimerMetaData { TimerType getType(); Object getContext(); Predicate<Method> getTimeoutMatcher(); boolean isPersistent(); <C extends TimerConfiguration> C getConfiguration(Class<C> configurationClass); Instant getNextTimeout(); Instant getLastTimout(); }
1,554
34.340909
83
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerServiceRequirement.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.ejb.timer; import org.jboss.as.clustering.controller.UnaryRequirementServiceNameFactory; import org.jboss.as.clustering.controller.UnaryServiceNameFactory; import org.jboss.as.clustering.controller.UnaryServiceNameFactoryProvider; import org.wildfly.clustering.service.UnaryRequirement; /** * Enumerates the distributed timer service capabilities. * @author Paul Ferraro */ public enum TimerServiceRequirement implements UnaryRequirement, UnaryServiceNameFactoryProvider { TIMER_MANAGEMENT_PROVIDER("org.wildfly.clustering.ejb.timer-management-provider", TimerManagementProvider.class), ; private final String name; private final Class<?> type; private final UnaryServiceNameFactory factory = new UnaryRequirementServiceNameFactory(this); TimerServiceRequirement(String name, Class<?> type) { this.name = name; this.type = type; } @Override public String getName() { return this.name; } @Override public Class<?> getType() { return this.type; } @Override public UnaryServiceNameFactory getServiceNameFactory() { return this.factory; } }
2,205
35.163934
117
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerManagerFactoryConfiguration.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.ejb.timer; import java.util.function.Supplier; /** * Encapsulates the configuration of a {@link TimerManagerFactory}. * @author Paul Ferraro * @param <I> the timer identifier type */ public interface TimerManagerFactoryConfiguration<I> { TimerServiceConfiguration getTimerServiceConfiguration(); Supplier<I> getIdentifierFactory(); TimerRegistry<I> getRegistry(); boolean isPersistent(); }
1,468
36.666667
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerManagementConfiguration.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.ejb.timer; import java.util.function.Function; import org.jboss.modules.Module; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; /** * Encapsulates the configuration of a {@link TimerManagementProvider}. * @author Paul Ferraro */ public interface TimerManagementConfiguration { Function<Module, ByteBufferMarshaller> getMarshallerFactory(); Integer getMaxActiveTimers(); }
1,463
35.6
71
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/Timer.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.ejb.timer; /** * Describes the properties of a timer, and its controlling mechanisms. * @author Paul Ferraro * @param <I> the timer identifier type */ public interface Timer<I> { I getId(); ImmutableTimerMetaData getMetaData(); boolean isActive(); boolean isCanceled(); void cancel(); void invoke() throws Exception; void activate(); void suspend(); }
1,448
31.931818
71
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/timer/TimerConfiguration.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.ejb.timer; import java.time.Instant; /** * Encapsulates the configuration of a timer. * @author Paul Ferraro */ public interface TimerConfiguration { Instant getStart(); }
1,237
34.371429
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanExpiration.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.ejb.bean; import java.time.Duration; import org.wildfly.clustering.ee.expiration.Expiration; /** * Encapsulates the expiration criteria for a bean. * Overrides the inherited semantics for zero timeout behavior. * @author Paul Ferraro */ public interface BeanExpiration extends Expiration { @Override default boolean isImmortal() { // EJB specification does not consider zero timeout to be immortal Duration timeout = this.getTimeout(); return (timeout == null) || timeout.isNegative(); } }
1,589
35.976744
74
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanManager.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.wildfly.clustering.ejb.bean; import java.util.concurrent.TimeoutException; import java.util.function.Supplier; import org.wildfly.clustering.ee.Batch; import org.wildfly.clustering.ee.Batcher; import org.wildfly.clustering.ee.Restartable; import org.wildfly.clustering.ejb.remote.AffinitySupport; /** * A SPI for managing beans. * * @author Paul Ferraro * * @param <K> the bean identifier type * @param <V> the bean instance type * @param <B> the batch type */ public interface BeanManager<K, V extends BeanInstance<K>, B extends Batch> extends Restartable, AffinitySupport<K>, BeanStatistics { Bean<K, V> createBean(V instance, K groupId); Bean<K, V> findBean(K id) throws TimeoutException; Supplier<K> getIdentifierFactory(); Batcher<B> getBatcher(); boolean isRemotable(Throwable throwable); }
1,866
35.607843
133
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanDeploymentConfiguration.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.ejb.bean; import org.wildfly.clustering.ejb.DeploymentConfiguration; /** * Encapsulates configuration of a bean deployment. * @author Paul Ferraro */ public interface BeanDeploymentConfiguration extends DeploymentConfiguration, BeanDeploymentMarshallingContext { }
1,325
39.181818
112
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/DefaultBeanProviderRequirement.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.ejb.bean; import org.jboss.as.clustering.controller.RequirementServiceNameFactory; import org.jboss.as.clustering.controller.ServiceNameFactory; import org.jboss.as.clustering.controller.ServiceNameFactoryProvider; import org.wildfly.clustering.service.Requirement; /** * Requirements representing services names for bean management providers * @author Paul Ferraro * @author Richard Achmatowicz */ public enum DefaultBeanProviderRequirement implements Requirement, ServiceNameFactoryProvider { BEAN_MANAGEMENT_PROVIDER("org.wildfly.clustering.ejb.default-bean-management-provider", BeanManagementProvider.class), ; private final String name; private final Class<?> type; private final ServiceNameFactory factory; DefaultBeanProviderRequirement(String name, Class<?> type) { this.name = name; this.type = type; this.factory = new RequirementServiceNameFactory(this); } @Override public String getName() { return this.name; } @Override public Class<?> getType() { return this.type; } @Override public ServiceNameFactory getServiceNameFactory() { return this.factory; } }
2,246
35.241935
122
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanDeploymentMarshallingContext.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.ejb.bean; import java.util.Set; import org.jboss.modules.Module; /** * The marshalling context for a bean deployment. * @author Paul Ferraro */ public interface BeanDeploymentMarshallingContext { /** * Returns the module of the bean deployment, * @return the module of the bean deployment */ Module getModule(); /** * The set of bean classes contained in the bean deployment. * @return a set of bean classes */ Set<Class<?>> getBeanClasses(); }
1,553
32.782609
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanProviderRequirement.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.ejb.bean; import org.jboss.as.clustering.controller.DefaultableUnaryServiceNameFactoryProvider; import org.jboss.as.clustering.controller.ServiceNameFactory; import org.jboss.as.clustering.controller.UnaryRequirementServiceNameFactory; import org.jboss.as.clustering.controller.UnaryServiceNameFactory; import org.wildfly.clustering.service.DefaultableUnaryRequirement; import org.wildfly.clustering.service.Requirement; /** * Requirement definition for EJB abstractions. * @author Paul Ferraro * @author Richard Achmatowicz */ public enum BeanProviderRequirement implements DefaultableUnaryRequirement, DefaultableUnaryServiceNameFactoryProvider { BEAN_MANAGEMENT_PROVIDER("org.wildfly.clustering.ejb.bean-management-provider", DefaultBeanProviderRequirement.BEAN_MANAGEMENT_PROVIDER), ; private final String name; private final UnaryServiceNameFactory factory; private final DefaultBeanProviderRequirement defaultRequirement; BeanProviderRequirement(String name, DefaultBeanProviderRequirement defaultRequirement) { this.name = name; this.factory = new UnaryRequirementServiceNameFactory(this); this.defaultRequirement = defaultRequirement; } @Override public String getName() { return this.name; } @Override public UnaryServiceNameFactory getServiceNameFactory() { return this.factory; } @Override public ServiceNameFactory getDefaultServiceNameFactory() { return this.defaultRequirement; } @Override public Requirement getDefaultRequirement() { return this.defaultRequirement; } }
2,682
37.884058
141
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanConfiguration.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.ejb.bean; import org.wildfly.clustering.ejb.DeploymentConfiguration; /** * Specifies the configuration of an EJB component. * @author Paul Ferraro */ public interface BeanConfiguration extends DeploymentConfiguration { /** * Returns the name of the EJB component. * @return the component name */ String getName(); }
1,400
34.923077
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanMetaData.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.ejb.bean; import java.time.Instant; /** * Described the mutable and immutable metadata of a cached bean. * @author Paul Ferraro * @param <K> the bean identifier type */ public interface BeanMetaData<K> extends ImmutableBeanMetaData<K> { void setLastAccessTime(Instant lastAccessTime); }
1,353
36.611111
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanManagerConfiguration.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.ejb.bean; import java.util.function.Supplier; /** * Encapsulates the configuration of a bean manager. * @author Paul Ferraro * * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface BeanManagerConfiguration<K, V extends BeanInstance<K>> { Supplier<K> getIdentifierFactory(); String getBeanName(); BeanExpirationConfiguration<K, V> getExpiration(); }
1,464
36.564103
73
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/Bean.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.wildfly.clustering.ejb.bean; import java.util.function.Consumer; /** * Described the mutable and immutable properties of a cached bean. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface Bean<K, V extends BeanInstance<K>> extends ImmutableBean<K, V>, AutoCloseable { /** * Returns the metadata of this bean. * @return */ @Override BeanMetaData<K> getMetaData(); /** * Indicates whether or not this bean is valid, i.e. not closed nor removed. * @return true, if this bean is valid, false otherwise */ boolean isValid(); /** * Removes this bean from the cache, executing the specified task. */ void remove(Consumer<V> removeTask); /** * Closes any resources used by this bean. */ @Override void close(); }
1,906
31.87931
96
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanExpirationConfiguration.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.ejb.bean; import org.wildfly.clustering.ee.expiration.ExpirationConfiguration; /** * Encapsulates the expiration configuration for a bean. * @author Paul Ferraro * * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface BeanExpirationConfiguration<K, V extends BeanInstance<K>> extends BeanExpiration, ExpirationConfiguration<V> { }
1,434
38.861111
127
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/ImmutableBeanMetaData.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.ejb.bean; /** * Describes the immutable metadata of a bean. * @author Paul Ferraro * @param <K> the bean identifier type */ public interface ImmutableBeanMetaData<K> extends BeanExpirationMetaData { /** * Returns the component name of this bean. * @return the component name of this bean. */ String getName(); /** * Returns the identifier of the group to which this bean is associated. * @return a group identifier. */ K getGroupId(); }
1,544
34.930233
76
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanManagementConfiguration.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.ejb.bean; import java.util.function.Function; import org.wildfly.clustering.marshalling.spi.ByteBufferMarshaller; /** * Encapsulates the configuration of a bean management provider. * @author Paul Ferraro */ public interface BeanManagementConfiguration extends BeanPassivationConfiguration { /** * Returns a factory for creating a bean deployment's marshaller. * @return a marshaller factory */ Function<BeanDeploymentMarshallingContext, ByteBufferMarshaller> getMarshallerFactory(); }
1,571
37.341463
92
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanExpirationMetaData.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.ejb.bean; import java.time.Duration; import org.wildfly.clustering.ee.expiration.ExpirationMetaData; /** * Encapsulates the expiration-related meta data of a cached bean. * Overrides the inherited semantics for zero timeout behavior. * @author Paul Ferraro */ public interface BeanExpirationMetaData extends BeanExpiration, ExpirationMetaData { @Override default boolean isExpired() { Duration timeout = this.getTimeout(); // EJB specification considers a zero timeout to be expired. if ((timeout != null) && timeout.isZero()) return true; return ExpirationMetaData.super.isExpired(); } }
1,696
37.568182
84
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/LegacyBeanManagementConfiguration.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.wildfly.clustering.ejb.bean; /** * Configuration for legacy bean management. * @author Paul Ferraro */ @Deprecated public interface LegacyBeanManagementConfiguration extends BeanPassivationConfiguration { String DEFAULT_CONTAINER_NAME = "ejb"; String getContainerName(); String getCacheName(); }
1,348
37.542857
89
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanManagementProvider.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.wildfly.clustering.ejb.bean; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; /** * Provides service installation mechanics for components of bean deployments. * @author Paul Ferraro */ public interface BeanManagementProvider { /** * Returns a name uniquely identifying this provider. * @return the provider name */ String getName(); /** * Installs dependencies for a deployment unit * @param configuration a bean deployment configuration * @return a collection of service configurators */ Iterable<CapabilityServiceConfigurator> getDeploymentServiceConfigurators(BeanDeploymentConfiguration configuration); /** * Builds a bean manager factory for an Jakarta Enterprise Bean within a deployment. * @param configuration a bean configuration * @return a service configurator */ CapabilityServiceConfigurator getBeanManagerFactoryServiceConfigurator(BeanConfiguration configuration); }
2,029
38.038462
121
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanStatistics.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.wildfly.clustering.ejb.bean; /** * Exposes statistics for cached beans. * @author Paul Ferraro */ public interface BeanStatistics { /** * Returns the number of beans that are actively cached. * @return a number of beans */ int getActiveCount(); /** * Returns the number of passivated beans accessible to the cache. * @return a number of beans */ int getPassiveCount(); }
1,457
34.560976
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanInstance.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.ejb.bean; /** * A distributable bean instance. * @author Paul Ferraro * @param <K> the bean identifier type */ public interface BeanInstance<K> { /** * Returns the unique identifier of this bean instance. * @return a unique identifier */ K getId(); /** * Invoked prior to serializing this bean instance for the purpose of replication or persistence. */ void prePassivate(); /** * Invoked after deserializing this bean instance following replication or persistence. */ void postActivate(); }
1,613
32.625
101
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/ImmutableBean.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.ejb.bean; /** * Describes the immutable properties of a cached bean. * @author Paul Ferraro * @param <K> the bean identifier type * @param <V> the bean instance type */ public interface ImmutableBean<K, V extends BeanInstance<K>> { /** * Returns the identifier of this bean. * @return a unique identifier */ K getId(); /** * Returns the instance of this bean. * @return the bean instance */ V getInstance(); /** * Returns the metadata of this bean. * @return */ ImmutableBeanMetaData<K> getMetaData(); }
1,636
31.74
70
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/BeanManagerFactory.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.wildfly.clustering.ejb.bean; import org.wildfly.clustering.ee.Batch; /** * Creates a {@link BeanManager}. * * @author Paul Ferraro * * @param <K> the bean identifier type * @param <V> the bean instance type * @param <B> the batch type */ public interface BeanManagerFactory<K, V extends BeanInstance<K>, B extends Batch> { BeanManager<K, V, B> createBeanManager(BeanManagerConfiguration<K, V> configuration); }
1,460
37.447368
89
java
null
wildfly-main/clustering/ejb/spi/src/main/java/org/wildfly/clustering/ejb/bean/LegacyBeanManagementProviderFactory.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.ejb.bean; /** * interface for obtaining BeanManagementProvider instances in the legacy case where no distributable-ejb subsystem is present. * * @author Paul Ferraro * @author Richard Achmatowicz */ @Deprecated public interface LegacyBeanManagementProviderFactory { BeanManagementProvider createBeanManagementProvider(String name, LegacyBeanManagementConfiguration config); }
1,440
41.382353
127
java