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/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/DeliveryActiveAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.ejb3.annotation.DeliveryActive; import org.jboss.jandex.AnnotationInstance; import org.jboss.metadata.property.PropertyReplacer; /** * Processes the {@link org.jboss.ejb3.annotation.DeliveryActive} annotation * * @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc. */ public class DeliveryActiveAnnotationInformationFactory extends ClassAnnotationInformationFactory<DeliveryActive, Boolean> { protected DeliveryActiveAnnotationInformationFactory() { super(DeliveryActive.class, null); } @Override protected Boolean fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { return annotationInstance.value().asBoolean(); } }
1,897
41.177778
124
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/DeliveryGroupAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2015, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.ejb3.annotation.DeliveryGroup; import org.jboss.ejb3.annotation.DeliveryGroups; import org.jboss.jandex.AnnotationInstance; import org.jboss.metadata.property.PropertyReplacer; /** * Processes the {@link DeliveryGroup} annotation * * @author Flavia Rainone */ public class DeliveryGroupAnnotationInformationFactory extends ClassAnnotationInformationFactory<DeliveryGroup, String> { protected DeliveryGroupAnnotationInformationFactory() { super(DeliveryGroup.class, DeliveryGroups.class); } @Override protected String fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { return annotationInstance.value().asString(); } }
1,874
39.76087
123
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/ClusteredAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2011, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.ejb3.annotation.Clustered; import org.jboss.jandex.AnnotationInstance; import org.jboss.metadata.property.PropertyReplacer; /** * @author Paul Ferraro */ @Deprecated public class ClusteredAnnotationInformationFactory extends ClassAnnotationInformationFactory<Clustered, Void> { protected ClusteredAnnotationInformationFactory() { super(Clustered.class, null); } @Override protected Void fromAnnotation(AnnotationInstance annotationInstance, PropertyReplacer propertyReplacer) { EjbLogger.DEPLOYMENT_LOGGER.deprecatedAnnotation(Clustered.class.getSimpleName()); return null; } }
1,832
38.847826
111
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/RunAsPrincipalAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.ejb3.annotation.RunAsPrincipal; import org.jboss.jandex.AnnotationInstance; import org.jboss.metadata.property.PropertyReplacer; /** * Processes the {@link org.jboss.ejb3.annotation.RunAsPrincipal} annotation on a session bean * * @author Guillaume Grossetie * @author Anil Saldhana */ public class RunAsPrincipalAnnotationInformationFactory extends ClassAnnotationInformationFactory<RunAsPrincipal, String> { protected RunAsPrincipalAnnotationInformationFactory() { super(RunAsPrincipal.class, null); } @Override protected String fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { return propertyReplacer.replaceProperties(annotationInstance.value().asString()); } }
1,925
40.869565
123
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/PoolAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import org.jboss.as.ee.logging.EeLogger; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.ejb3.annotation.Pool; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationValue; import org.jboss.metadata.property.PropertyReplacer; /** * Processes {@link Pool} annotation on EJB classes * * @author Jaikiran Pai */ public class PoolAnnotationInformationFactory extends ClassAnnotationInformationFactory<Pool, String> { public PoolAnnotationInformationFactory() { super(Pool.class, null); } @Override protected String fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { AnnotationValue value = annotationInstance.value(); if (value == null || value.asString().isEmpty()) { throw EeLogger.ROOT_LOGGER.annotationAttributeMissing("@Pool", "value"); } return propertyReplacer.replaceProperties(value.asString()); } }
2,081
38.283019
123
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/AccessTimeoutAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.as.ejb3.concurrency.AccessTimeoutDetails; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationValue; import org.jboss.metadata.property.PropertyReplacer; import jakarta.ejb.AccessTimeout; import java.util.concurrent.TimeUnit; /** * Processes the {@link jakarta.ejb.AccessTimeout} annotation on a session bean * * @author Stuart Douglas */ public class AccessTimeoutAnnotationInformationFactory extends ClassAnnotationInformationFactory<AccessTimeout, AccessTimeoutDetails> { protected AccessTimeoutAnnotationInformationFactory() { super(AccessTimeout.class, null); } @Override protected AccessTimeoutDetails fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { final long timeout = annotationInstance.value().asLong(); AnnotationValue unitAnnVal = annotationInstance.value("unit"); final TimeUnit unit = unitAnnVal != null ? TimeUnit.valueOf(unitAnnVal.asEnum()) : TimeUnit.MILLISECONDS; return new AccessTimeoutDetails(timeout, unit); } }
2,245
42.192308
137
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/RemoteHomeAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import jakarta.ejb.RemoteHome; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationValue; import org.jboss.metadata.property.PropertyReplacer; /** * Processes the {@link jakarta.ejb.RemoteHome} annotation on a session bean * * @author Stuart Douglas */ public class RemoteHomeAnnotationInformationFactory extends ClassAnnotationInformationFactory<RemoteHome, String> { protected RemoteHomeAnnotationInformationFactory() { super(RemoteHome.class, null); } @Override protected String fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { AnnotationValue value = annotationInstance.value(); return value.asClass().toString(); } }
1,898
38.5625
123
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/LockAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationValue; import org.jboss.metadata.property.PropertyReplacer; import jakarta.ejb.Lock; import jakarta.ejb.LockType; /** * Processes the {@link jakarta.ejb.Lock} annotation on a session bean, which allows concurrent access (like @Singleton and @Stateful beans), * and its methods and updates the {@link org.jboss.as.ejb3.component.session.SessionBeanComponentDescription} accordingly. * * @author Stuart Douglas */ public class LockAnnotationInformationFactory extends ClassAnnotationInformationFactory<Lock, LockType> { protected LockAnnotationInformationFactory() { super(Lock.class, null); } @Override protected LockType fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { AnnotationValue value = annotationInstance.value(); if(value == null) { return LockType.WRITE; } return LockType.valueOf(annotationInstance.value().asEnum()); } }
2,190
40.339623
141
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/RolesAllowedAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.jandex.AnnotationInstance; import org.jboss.metadata.property.PropertyReplacer; import jakarta.annotation.security.RolesAllowed; /** * @author Stuart Douglas */ public class RolesAllowedAnnotationInformationFactory extends ClassAnnotationInformationFactory<RolesAllowed, String[]> { protected RolesAllowedAnnotationInformationFactory() { super(RolesAllowed.class, null); } @Override protected String[] fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { String[] values = annotationInstance.value().asStringArray(); for (int i = 0; i < values.length; i++) { values[i] = propertyReplacer.replaceProperties(values[i]); } return values; } }
1,928
39.1875
125
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/RunAsAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import jakarta.annotation.security.RunAs; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.jandex.AnnotationInstance; import org.jboss.metadata.property.PropertyReplacer; /** * Processes the {@link jakarta.annotation.security.RunAs} annotation on a session bean * * @author Stuart Douglas */ public class RunAsAnnotationInformationFactory extends ClassAnnotationInformationFactory<RunAs, String> { protected RunAsAnnotationInformationFactory() { super(RunAs.class, null); } @Override protected String fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { return propertyReplacer.replaceProperties(annotationInstance.value().asString()); } }
1,846
39.152174
123
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/DependsOnAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.jandex.AnnotationInstance; import org.jboss.metadata.property.PropertyReplacer; import jakarta.ejb.DependsOn; /** * @author Stuart Douglas */ public class DependsOnAnnotationInformationFactory extends ClassAnnotationInformationFactory<DependsOn, String[]> { protected DependsOnAnnotationInformationFactory() { super(DependsOn.class, null); } @Override protected String[] fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { String[] values = annotationInstance.value().asStringArray(); for (int i = 0; i < values.length; i++) { values[i] = propertyReplacer.replaceProperties(values[i]); } return values; } }
1,897
38.541667
125
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/deployment/processors/annotation/TransactionAttributeAnnotationInformationFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.deployment.processors.annotation; import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationValue; import org.jboss.metadata.property.PropertyReplacer; import jakarta.ejb.TransactionAttribute; import jakarta.ejb.TransactionAttributeType; /** * Processes the {@link jakarta.ejb.TransactionAttribute} annotation on a session bean * @author Stuart Douglas */ public class TransactionAttributeAnnotationInformationFactory extends ClassAnnotationInformationFactory<TransactionAttribute, TransactionAttributeType> { protected TransactionAttributeAnnotationInformationFactory() { super(TransactionAttribute.class, null); } @Override protected TransactionAttributeType fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { final AnnotationValue value = annotationInstance.value(); if(value == null) { return TransactionAttributeType.REQUIRED; } return TransactionAttributeType.valueOf(value.asEnum()); } }
2,157
40.5
153
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/EJBRemoteConnectorService.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.jboss.ejb.protocol.remote.RemoteEJBService; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; import org.jboss.remoting3.Endpoint; import org.jboss.remoting3.OpenListener; import org.jboss.remoting3.Registration; import org.jboss.remoting3.ServiceRegistrationException; import org.wildfly.transaction.client.provider.remoting.RemotingTransactionService; import org.xnio.OptionMap; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ public class EJBRemoteConnectorService implements Service { // TODO: Should this be exposed via the management APIs? private static final String EJB_CHANNEL_NAME = "jboss.ejb"; public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "connector"); private final Consumer<EJBRemoteConnectorService> serviceConsumer; private final Supplier<Endpoint> endpointSupplier; private final Supplier<ExecutorService> executorServiceSupplier; private final Supplier<AssociationService> associationServiceSupplier; private final Supplier<RemotingTransactionService> remotingTransactionServiceSupplier; private volatile Registration registration; private final OptionMap channelCreationOptions; private final Function<String, Boolean> classResolverFilter; public EJBRemoteConnectorService( final Consumer<EJBRemoteConnectorService> serviceConsumer, final Supplier<Endpoint> endpointSupplier, final Supplier<ExecutorService> executorServiceSupplier, final Supplier<AssociationService> associationServiceSupplier, final Supplier<RemotingTransactionService> remotingTransactionServiceSupplier, final OptionMap channelCreationOptions, final Function<String, Boolean> classResolverFilter) { this.serviceConsumer = serviceConsumer; this.endpointSupplier = endpointSupplier; this.executorServiceSupplier = executorServiceSupplier; this.associationServiceSupplier = associationServiceSupplier; this.remotingTransactionServiceSupplier = remotingTransactionServiceSupplier; this.channelCreationOptions = channelCreationOptions; this.classResolverFilter = classResolverFilter; } @Override public void start(StartContext context) throws StartException { final AssociationService associationService = associationServiceSupplier.get(); final Endpoint endpoint = endpointSupplier.get(); Executor executor = executorServiceSupplier != null ? executorServiceSupplier.get() : null; if (executor != null) { associationService.setExecutor(executor); } RemoteEJBService remoteEJBService = RemoteEJBService.create( associationService.getAssociation(), remotingTransactionServiceSupplier.get(), classResolverFilter ); remoteEJBService.serverUp(); // Register an EJB channel open listener OpenListener channelOpenListener = remoteEJBService.getOpenListener(); try { registration = endpoint.registerService(EJB_CHANNEL_NAME, channelOpenListener, this.channelCreationOptions); } catch (ServiceRegistrationException e) { throw new StartException(e); } serviceConsumer.accept(this); } @Override public void stop(StopContext context) { serviceConsumer.accept(null); final AssociationService associationService = associationServiceSupplier.get(); associationService.sendTopologyUpdateIfLastNodeToLeave(); associationService.setExecutor(null); registration.close(); } }
5,020
44.645455
170
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/RemotingProfileService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import java.net.URI; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.as.network.OutboundConnection; import org.jboss.ejb.client.EJBTransportProvider; import org.jboss.msc.Service; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; import org.wildfly.discovery.ServiceURL; import org.xnio.OptionMap; /** * Service which contains the static configuration data found in an Jakarta Enterprise Beans Remoting profile, either in the subsystem or in a * deployment descriptor. * * @author <a href="mailto:[email protected]">Tomasz Adamski</a> * @author <a href="mailto:[email protected]">David M. Lloyd</a> */ public class RemotingProfileService implements Service { /** * There URLs are used to allow discovery to find these connections. */ private final List<ServiceURL> serviceUrls; private final Map<String, RemotingConnectionSpec> remotingConnectionSpecMap; private final List<HttpConnectionSpec> httpConnectionSpecs; private final Consumer<RemotingProfileService> consumer; private final Supplier<EJBTransportProvider> localTransportProviderSupplier; public RemotingProfileService(final Consumer<RemotingProfileService> consumer, final Supplier<EJBTransportProvider> localTransportProviderSupplier, final List<ServiceURL> serviceUrls, final Map<String, RemotingConnectionSpec> remotingConnectionSpecMap, final List<HttpConnectionSpec> httpConnectionSpecs) { this.consumer = consumer; this.localTransportProviderSupplier = localTransportProviderSupplier; this.serviceUrls = serviceUrls; this.remotingConnectionSpecMap = remotingConnectionSpecMap; this.httpConnectionSpecs = httpConnectionSpecs; } @Override public void start(StartContext context) throws StartException { consumer.accept(this); } @Override public void stop(StopContext context) { consumer.accept(null); } public Supplier<EJBTransportProvider> getLocalTransportProviderSupplier() { return localTransportProviderSupplier; } public Collection<RemotingConnectionSpec> getConnectionSpecs() { return remotingConnectionSpecMap.values(); } public Collection<HttpConnectionSpec> getHttpConnectionSpecs() { return httpConnectionSpecs; } public List<ServiceURL> getServiceUrls() { return serviceUrls; } public static final class RemotingConnectionSpec { private final String connectionName; private final Supplier<OutboundConnection> supplier; private final OptionMap connectOptions; private final long connectTimeout; public RemotingConnectionSpec(final String connectionName, final Supplier<OutboundConnection> supplier, final OptionMap connectOptions, final long connectTimeout) { this.connectionName = connectionName; this.supplier = supplier; this.connectOptions = connectOptions; this.connectTimeout = connectTimeout; } public String getConnectionName() { return connectionName; } public Supplier<OutboundConnection> getSupplier() { return supplier; } public OptionMap getConnectOptions() { return connectOptions; } public long getConnectTimeout() { return connectTimeout; } } public static final class HttpConnectionSpec { private final String uri; public HttpConnectionSpec(final String uri) { this.uri = uri; } public URI getUri() { try { return new URI(uri); } catch(Exception e) { return null; } } } }
5,049
34.815603
172
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/LocalEjbReceiver.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import static org.jboss.as.ejb3.util.MethodInfoHelper.EMPTY_STRING_ARRAY; import java.io.Serializable; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import org.jboss.as.ee.component.Component; import org.jboss.as.ee.component.ComponentView; import org.jboss.as.ee.component.deployers.StartupCountdown; import org.jboss.as.ee.utils.DescriptorUtils; import org.jboss.as.ejb3.component.EJBComponent; import org.jboss.as.ejb3.component.interceptors.CancellationFlag; import org.jboss.as.ejb3.component.session.SessionBeanComponent; import org.jboss.as.ejb3.component.stateful.StatefulSessionComponent; import org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier; import org.jboss.as.ejb3.deployment.DeploymentRepository; import org.jboss.as.ejb3.deployment.EjbDeploymentInformation; import org.jboss.as.ejb3.deployment.ModuleDeployment; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.ejb.client.AttachmentKey; import org.jboss.ejb.client.AttachmentKeys; import org.jboss.ejb.client.EJBClientInvocationContext; import org.jboss.ejb.client.EJBLocator; import org.jboss.ejb.client.EJBReceiver; import org.jboss.ejb.client.EJBReceiverInvocationContext; import org.jboss.ejb.client.EJBReceiverSessionCreationContext; import org.jboss.ejb.client.EntityEJBLocator; import org.jboss.ejb.client.SessionID; import org.jboss.ejb.client.StatelessEJBLocator; import org.jboss.ejb.client.TransactionID; import org.jboss.invocation.InterceptorContext; import org.jboss.marshalling.cloner.ClassLoaderClassCloner; import org.jboss.marshalling.cloner.ClonerConfiguration; import org.jboss.marshalling.cloner.ObjectCloner; import org.jboss.marshalling.cloner.ObjectCloners; import org.wildfly.security.auth.server.SecurityDomain; import org.wildfly.security.auth.server.SecurityIdentity; import org.wildfly.security.manager.WildFlySecurityManager; /** * {@link EJBReceiver} for local same-VM invocations. This handles all invocations on remote interfaces * within the server JVM. * * @author Stuart Douglas * @author <a href=mailto:[email protected]>Tomasz Adamski</a> */ public class LocalEjbReceiver extends EJBReceiver { private static final EJBReceiverInvocationContext.ResultProducer.Immediate NULL_RESULT = new EJBReceiverInvocationContext.ResultProducer.Immediate(null); private static final AttachmentKey<CancellationFlag> CANCELLATION_FLAG_ATTACHMENT_KEY = new AttachmentKey<>(); private final DeploymentRepository deploymentRepository; private final boolean allowPassByReference; public LocalEjbReceiver(final boolean allowPassByReference, final DeploymentRepository deploymentRepository) { this.allowPassByReference = allowPassByReference; this.deploymentRepository = deploymentRepository; } @Override protected void processInvocation(final EJBReceiverInvocationContext receiverContext) { final EJBClientInvocationContext invocation = receiverContext.getClientInvocationContext(); final EJBLocator<?> locator = invocation.getLocator(); final EjbDeploymentInformation ejb = findBean(locator); final EJBComponent ejbComponent = ejb.getEjbComponent(); final Class<?> viewClass = invocation.getViewClass(); final ComponentView view = ejb.getView(viewClass.getName()); if (view == null) { throw EjbLogger.ROOT_LOGGER.viewNotFound(viewClass.getName(), ejb.getEjbName()); } // make sure it's a remote view if (!ejb.isRemoteView(viewClass.getName())) { throw EjbLogger.ROOT_LOGGER.viewNotFound(viewClass.getName(), ejb.getEjbName()); } final ClonerConfiguration paramConfig = new ClonerConfiguration(); paramConfig.setClassCloner(new ClassLoaderClassCloner(ejb.getDeploymentClassLoader())); final ObjectCloner parameterCloner = createCloner(paramConfig); //TODO: this is not very efficient final Method method = view.getMethod(invocation.getInvokedMethod().getName(), DescriptorUtils.methodDescriptor(invocation.getInvokedMethod())); final boolean async = view.isAsynchronous(method) || invocation.isClientAsync(); final Object[] parameters; if (invocation.getParameters() == null) { parameters = EMPTY_STRING_ARRAY; } else { parameters = new Object[invocation.getParameters().length]; for (int i = 0; i < parameters.length; ++i) { parameters[i] = clone(method.getParameterTypes()[i], parameterCloner, invocation.getParameters()[i], allowPassByReference); } } final InterceptorContext interceptorContext = new InterceptorContext(); interceptorContext.setParameters(parameters); interceptorContext.setMethod(method); interceptorContext.setTransaction(invocation.getTransaction()); interceptorContext.setTarget(invocation.getInvokedProxy()); // setup the context data in the InterceptorContext final Map<AttachmentKey<?>, ?> privateAttachments = invocation.getAttachments(); final Map<String, Object> invocationContextData = invocation.getContextData(); if (invocationContextData == null && privateAttachments.isEmpty()) { // no private or public data interceptorContext.setContextData(new HashMap<String, Object>()); } else { final Map<String, Object> data = new HashMap<String, Object>(); interceptorContext.setContextData(data); // write out public (application specific) context data if (invocationContextData != null) for (Map.Entry<String, Object> entry : invocationContextData.entrySet()) { data.put(entry.getKey(), entry.getValue()); } if (!privateAttachments.isEmpty()) { // now write out the JBoss specific attachments under a single key and the value will be the // entire map of JBoss specific attachments data.put(EJBClientInvocationContext.PRIVATE_ATTACHMENTS_KEY, privateAttachments); } // Note: The code here is just for backward compatibility of 1.0.x version of Jakarta Enterprise Beans client project // against AS7 7.1.x releases. Discussion here https://github.com/jbossas/jboss-ejb-client/pull/11#issuecomment-6573863 final boolean txIdAttachmentPresent = privateAttachments.containsKey(AttachmentKeys.TRANSACTION_ID_KEY); if (txIdAttachmentPresent) { // we additionally add/duplicate the transaction id under a different attachment key // to preserve backward compatibility. This is here just for 1.0.x backward compatibility data.put(TransactionID.PRIVATE_DATA_KEY, privateAttachments.get(AttachmentKeys.TRANSACTION_ID_KEY)); } } interceptorContext.putPrivateData(Component.class, ejbComponent); interceptorContext.putPrivateData(ComponentView.class, view); if (locator.isStateful()) { interceptorContext.putPrivateData(SessionID.class, locator.asStateful().getSessionId()); } else if (locator instanceof EntityEJBLocator) { throw EjbLogger.ROOT_LOGGER.ejbNotFoundInDeployment(locator); } final ClonerConfiguration config = new ClonerConfiguration(); config.setClassCloner(new LocalInvocationClassCloner(WildFlySecurityManager.getClassLoaderPrivileged(invocation.getInvokedProxy().getClass()))); final ObjectCloner resultCloner = createCloner(config); if (async) { if (ejbComponent instanceof SessionBeanComponent) { final CancellationFlag flag = new CancellationFlag(); final SessionBeanComponent component = (SessionBeanComponent) ejbComponent; final boolean isAsync = view.isAsynchronous(method); final boolean oneWay = isAsync && method.getReturnType() == void.class; final boolean isSessionBean = view.getComponent() instanceof SessionBeanComponent; if (isAsync && isSessionBean && !oneWay) { interceptorContext.putPrivateData(CancellationFlag.class, flag); } final SecurityDomain securityDomain; if (WildFlySecurityManager.isChecking()) { securityDomain = AccessController.doPrivileged((PrivilegedAction<SecurityDomain>) SecurityDomain::getCurrent); } else { securityDomain = SecurityDomain.getCurrent(); } final SecurityIdentity securityIdentity = securityDomain != null ? securityDomain.getCurrentSecurityIdentity() : null; final StartupCountdown.Frame frame = StartupCountdown.current(); final Runnable task = () -> { if (! flag.runIfNotCancelled()) { receiverContext.requestCancelled(); return; } StartupCountdown.restore(frame); try { final Object result; try { result = view.invoke(interceptorContext); } catch (Exception e) { // WFLY-4331 - clone the exception of an async task receiverContext.resultReady(new CloningExceptionProducer(resultCloner, e, allowPassByReference)); return; } // if the result is null, there is no cloning needed if(result == null) { receiverContext.resultReady(NULL_RESULT); return; } // WFLY-4331 - clone the result of an async task if(result instanceof Future) { // blocking is very unlikely here, so just defer interrupts when they happen boolean intr = Thread.interrupted(); Object asyncValue; try { for (;;) try { asyncValue = ((Future<?>)result).get(); break; } catch (InterruptedException e) { intr = true; } catch (ExecutionException e) { // WFLY-4331 - clone the exception of an async task receiverContext.resultReady(new CloningExceptionProducer(resultCloner, e, allowPassByReference)); return; } } finally { if (intr) Thread.currentThread().interrupt(); } // if the return value is null, there is no cloning needed if (asyncValue == null) { receiverContext.resultReady(NULL_RESULT); return; } receiverContext.resultReady(new CloningResultProducer(invocation, resultCloner, asyncValue, allowPassByReference)); return; } receiverContext.resultReady(new CloningResultProducer(invocation, resultCloner, result, allowPassByReference)); } finally { StartupCountdown.restore(null); } }; invocation.putAttachment(CANCELLATION_FLAG_ATTACHMENT_KEY, flag); interceptorContext.putPrivateData(CancellationFlag.class, flag); final ExecutorService executor = component.getAsynchronousExecutor(); if (executor == null) { receiverContext.resultReady(new EJBReceiverInvocationContext.ResultProducer.Failed( EjbLogger.ROOT_LOGGER.executorIsNull() )); } else { // this normally isn't necessary unless the client didn't detect that it was an async method for some reason receiverContext.proceedAsynchronously(); executor.execute(securityIdentity == null ? task : () -> securityIdentity.runAs(task)); } } else { throw EjbLogger.ROOT_LOGGER.asyncInvocationOnlyApplicableForSessionBeans(); } } else { final Object result; try { result = view.invoke(interceptorContext); } catch (Exception e) { //we even have to clone the exception type //to make sure it matches receiverContext.resultReady(new CloningExceptionProducer(resultCloner, e, allowPassByReference)); return; } receiverContext.resultReady(new CloningResultProducer(invocation, resultCloner, result, allowPassByReference)); handleReturningContextData(invocation, interceptorContext); } } /** * WFLY-16567 - ContextData not kept in sync when EJB modifies it * * @param invocation * @param interceptorContext */ private static void handleReturningContextData(EJBClientInvocationContext invocation, InterceptorContext interceptorContext) { // WFLY-16567 - clear out all returnKeys Set<String> returnKeys = (Set<String>) invocation.getAttachments() .get(EJBClientInvocationContext.RETURNED_CONTEXT_DATA_KEY); if (returnKeys != null) invocation.getContextData().keySet().removeAll(returnKeys); // WFLY-16567 - the local receiver copies the contextData back, it should remove what the EJB removed // keys in context data when client sent request Set<String> keysRemovedOnServerSide = new HashSet<>(invocation.getContextData().keySet()); // remove keys returned, leaving keys on the client side that should be cleared keysRemovedOnServerSide.removeAll(interceptorContext.getContextData().keySet()); // remove the keys that existed before but do not exist in the response invocation.getContextData().keySet().removeAll(keysRemovedOnServerSide); // copy the returned context data into the invocation for (Map.Entry<String, Object> entry : interceptorContext.getContextData().entrySet()) { if (entry.getValue() instanceof Serializable) { invocation.getContextData().put(entry.getKey(), entry.getValue()); } } } protected boolean cancelInvocation(final EJBReceiverInvocationContext receiverContext, final boolean cancelIfRunning) { CancellationFlag flag = receiverContext.getClientInvocationContext().getAttachment(CANCELLATION_FLAG_ATTACHMENT_KEY); return flag != null && flag.cancel(cancelIfRunning); } static final class CloningResultProducer implements EJBReceiverInvocationContext.ResultProducer { private final EJBClientInvocationContext invocation; private final ObjectCloner resultCloner; private final Object result; private final boolean allowPassByReference; CloningResultProducer(final EJBClientInvocationContext invocation, final ObjectCloner resultCloner, final Object result, final boolean allowPassByReference) { this.invocation = invocation; this.resultCloner = resultCloner; this.result = result; this.allowPassByReference = allowPassByReference; } public Object getResult() throws Exception { return LocalEjbReceiver.clone(invocation.getInvokedMethod().getReturnType(), resultCloner, result, allowPassByReference); } public void discardResult() { } } static final class CloningExceptionProducer implements EJBReceiverInvocationContext.ResultProducer { private final ObjectCloner resultCloner; private final Exception exception; private final boolean allowPassByReference; CloningExceptionProducer(final ObjectCloner resultCloner, final Exception exception, final boolean allowPassByReference) { this.resultCloner = resultCloner; this.exception = exception; this.allowPassByReference = allowPassByReference; } public Object getResult() throws Exception { throw (Exception) LocalEjbReceiver.clone(Exception.class, resultCloner, exception, allowPassByReference); } public void discardResult() { } } private ObjectCloner createCloner(final ClonerConfiguration paramConfig) { ObjectCloner parameterCloner; if(WildFlySecurityManager.isChecking()) { parameterCloner = WildFlySecurityManager.doUnchecked((PrivilegedAction<ObjectCloner>) () -> ObjectCloners.getSerializingObjectClonerFactory().createCloner(paramConfig)); } else { parameterCloner = ObjectCloners.getSerializingObjectClonerFactory().createCloner(paramConfig); } return parameterCloner; } protected SessionID createSession(final EJBReceiverSessionCreationContext receiverContext) throws Exception { final StatelessEJBLocator<?> statelessLocator = receiverContext.getClientInvocationContext().getLocator().asStateless(); final EjbDeploymentInformation ejbInfo = findBean(statelessLocator); final EJBComponent component = ejbInfo.getEjbComponent(); if (!(component instanceof StatefulSessionComponent)) { throw EjbLogger.ROOT_LOGGER.notStatefulSessionBean(statelessLocator.getAppName(), statelessLocator.getModuleName(), statelessLocator.getDistinctName(), statelessLocator.getBeanName()); } component.waitForComponentStart(); return ((StatefulSessionComponent) component).createSession(); } static Object clone(final Class<?> target, final ObjectCloner cloner, final Object object, final boolean allowPassByReference) { if (object == null) { return null; } // don't clone primitives if (target.isPrimitive()) { return object; } if (allowPassByReference && target.isAssignableFrom(object.getClass())) { return object; } return clone(cloner, object); } private static Object clone(final ObjectCloner cloner, final Object object) { if (object == null) { return null; } if(WildFlySecurityManager.isChecking()) { return AccessController.doPrivileged((PrivilegedAction<Object>) () -> { try { return cloner.clone(object); } catch (Exception e) { throw EjbLogger.ROOT_LOGGER.failedToMarshalEjbParameters(e); } }); } else { try { return cloner.clone(object); } catch (Exception e) { throw EjbLogger.ROOT_LOGGER.failedToMarshalEjbParameters(e); } } } private EjbDeploymentInformation findBean(final EJBLocator<?> locator) { final String appName = locator.getAppName(); final String moduleName = locator.getModuleName(); final String distinctName = locator.getDistinctName(); final String beanName = locator.getBeanName(); final DeploymentModuleIdentifier moduleIdentifier = new DeploymentModuleIdentifier(appName, moduleName, distinctName); final ModuleDeployment module = deploymentRepository.getModules().get(moduleIdentifier); if (module == null) { throw EjbLogger.ROOT_LOGGER.unknownDeployment(locator); } final EjbDeploymentInformation ejbInfo = module.getEjbs().get(beanName); if (ejbInfo == null) { throw EjbLogger.ROOT_LOGGER.ejbNotFoundInDeployment(locator); } return ejbInfo; } }
21,564
49.741176
196
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/EJBClientContextService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import static java.security.AccessController.doPrivileged; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.URL; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Properties; import org.jboss.as.ejb3.security.IdentityEJBClientInterceptor; import org.jboss.as.ejb3.subsystem.EJBClientConfiguratorService; import org.jboss.ejb.client.ClusterNodeSelector; import org.jboss.ejb.client.DeploymentNodeSelector; import org.jboss.ejb.client.EJBClientCluster; import org.jboss.ejb.client.EJBClientConnection; import org.jboss.ejb.client.EJBClientContext; import org.jboss.ejb.client.EJBClientInterceptor; import org.jboss.ejb.client.EJBTransportProvider; import org.jboss.ejb.client.legacy.JBossEJBProperties; import org.jboss.ejb.client.legacy.LegacyPropertiesConfiguration; import org.jboss.msc.service.Service; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; import org.jboss.msc.value.InjectedValue; import org.wildfly.security.auth.client.AuthenticationContext; /** * The Jakarta Enterprise Beans client context service. * * @author Stuart Douglas * @author <a href=mailto:[email protected]>Tomasz Adamski</a> * @author <a href="mailto:[email protected]">David M. Lloyd</a> * @author <a href="mailto:[email protected]">Joerg Baesner</a> */ public final class EJBClientContextService implements Service<EJBClientContextService> { public static final ServiceName APP_CLIENT_URI_SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "ejbClientContext", "appClientUri"); public static final ServiceName APP_CLIENT_EJB_PROPERTIES_SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "ejbClientContext", "appClientEjbProperties"); private static final ServiceName BASE_SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "ejbClientContext"); public static final ServiceName DEPLOYMENT_BASE_SERVICE_NAME = BASE_SERVICE_NAME.append("deployment"); public static final ServiceName DEFAULT_SERVICE_NAME = BASE_SERVICE_NAME.append("default"); /** * this list is used so that interceptors that are used in all scenarios don't have to be configured for each deployment * and allow for EJBClientContext sharing if no additional metadata is configured see f.e. WFLY-18040 */ private static List<EJBClientInterceptor> WILDFLY_CLIENT_INTERCEPTORS = new ArrayList<>(Arrays.asList(IdentityEJBClientInterceptor.INSTANCE)); private EJBClientContext clientContext; private final InjectedValue<EJBClientConfiguratorService> configuratorServiceInjector = new InjectedValue<>(); private final InjectedValue<EJBTransportProvider> localProviderInjector = new InjectedValue<>(); private final InjectedValue<RemotingProfileService> profileServiceInjector = new InjectedValue<>(); private InjectedValue<URI> appClientUri = new InjectedValue<>(); private InjectedValue<String> appClientEjbProperties = new InjectedValue<>(); /** * TODO: possibly move to using a per-thread solution for embedded support */ private final boolean makeGlobal; private long invocationTimeout; private DeploymentNodeSelector deploymentNodeSelector; private List<EJBClientCluster> clientClusters = null; private AuthenticationContext clustersAuthenticationContext = null; private List<EJBClientInterceptor> clientInterceptors = null; private int defaultCompression = -1; public EJBClientContextService(final boolean makeGlobal) { this.makeGlobal = makeGlobal; } public EJBClientContextService() { this.makeGlobal = false; } public void start(final StartContext context) throws StartException { final EJBClientContext.Builder builder = new EJBClientContext.Builder(); // apply subsystem-level configuration that applies to all Jakarta Enterprise Beans client contexts configuratorServiceInjector.getValue().accept(builder); builder.setInvocationTimeout(invocationTimeout); builder.setDefaultCompression(defaultCompression); final EJBTransportProvider localTransport = localProviderInjector.getOptionalValue(); if (localTransport != null) { builder.addTransportProvider(localTransport); } final RemotingProfileService profileService = profileServiceInjector.getOptionalValue(); if (profileService != null) { for (RemotingProfileService.RemotingConnectionSpec spec : profileService.getConnectionSpecs()) { final EJBClientConnection.Builder connBuilder = new EJBClientConnection.Builder(); connBuilder.setDestination(spec.getSupplier().get().getDestinationUri()); // connBuilder.setConnectionTimeout(timeout); builder.addClientConnection(connBuilder.build()); } for (RemotingProfileService.HttpConnectionSpec spec : profileService.getHttpConnectionSpecs()) { final EJBClientConnection.Builder connBuilder = new EJBClientConnection.Builder(); connBuilder.setDestination(spec.getUri()); builder.addClientConnection(connBuilder.build()); } } if(appClientUri.getOptionalValue() != null) { final EJBClientConnection.Builder connBuilder = new EJBClientConnection.Builder(); connBuilder.setDestination(appClientUri.getOptionalValue()); builder.addClientConnection(connBuilder.build()); } if (clientClusters != null) { boolean firstSelector = true; for (EJBClientCluster clientCluster : clientClusters) { builder.addClientCluster(clientCluster); ClusterNodeSelector selector = clientCluster.getClusterNodeSelector(); // Currently only one selector is supported per client context if (firstSelector) { if(selector != null) { builder.setClusterNodeSelector(selector); } // TODO: There's a type missmatch in the 'jboss-ejb-client' component. // The EJBClientContext class and his Builder uses 'int' whereas the // EJBClientCluster class and his Builder uses 'long' int maximumConnectedClusterNodes = (int) clientCluster.getMaximumConnectedNodes(); builder.setMaximumConnectedClusterNodes(maximumConnectedClusterNodes); firstSelector = false; } } } if (deploymentNodeSelector != null) { builder.setDeploymentNodeSelector(deploymentNodeSelector); } if(appClientEjbProperties.getOptionalValue() != null) { setupEjbClientProps(appClientEjbProperties.getOptionalValue()); LegacyPropertiesConfiguration.configure(builder); } for (EJBClientInterceptor clientInterceptor : WILDFLY_CLIENT_INTERCEPTORS) { builder.addInterceptor(clientInterceptor); } if (clientInterceptors != null) { for (EJBClientInterceptor clientInterceptor : clientInterceptors) { builder.addInterceptor(clientInterceptor); } } clientContext = builder.build(); if (makeGlobal) { doPrivileged((PrivilegedAction<Void>) () -> { EJBClientContext.getContextManager().setGlobalDefault(clientContext); return null; }); } } public void stop(final StopContext context) { clientContext.close(); clientContext = null; if (makeGlobal) { doPrivileged((PrivilegedAction<Void>) () -> { EJBClientContext.getContextManager().setGlobalDefault(null); return null; }); } } private void setupEjbClientProps(String connectionPropertiesUrl) throws StartException { try { final File file = new File(connectionPropertiesUrl); final URL url; if (file.exists()) { url = file.toURI().toURL(); } else { url = new URL(connectionPropertiesUrl); } Properties properties = new Properties(); InputStream stream = null; try { stream = url.openStream(); properties.load(stream); } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { //ignore } } } JBossEJBProperties ejbProps = JBossEJBProperties.fromProperties(connectionPropertiesUrl, properties); JBossEJBProperties.getContextManager().setGlobalDefault(ejbProps); } catch (Exception e) { throw new StartException(e); } } public EJBClientContextService getValue() throws IllegalStateException, IllegalArgumentException { return this; } public EJBClientContext getClientContext() { return clientContext; } public InjectedValue<EJBClientConfiguratorService> getConfiguratorServiceInjector() { return configuratorServiceInjector; } public InjectedValue<EJBTransportProvider> getLocalProviderInjector() { return localProviderInjector; } public InjectedValue<RemotingProfileService> getProfileServiceInjector() { return profileServiceInjector; } public InjectedValue<URI> getAppClientUri() { return appClientUri; } public InjectedValue<String> getAppClientEjbProperties() { return appClientEjbProperties; } public void setInvocationTimeout(final long invocationTimeout) { this.invocationTimeout = invocationTimeout; } public void setDefaultCompression(int defaultCompression) { this.defaultCompression = defaultCompression; } public void setDeploymentNodeSelector(final DeploymentNodeSelector deploymentNodeSelector) { this.deploymentNodeSelector = deploymentNodeSelector; } public void setClientClusters(final List<EJBClientCluster> clientClusters) { this.clientClusters = clientClusters; } public void setClustersAuthenticationContext(final AuthenticationContext clustersAuthenticationContext) { this.clustersAuthenticationContext = clustersAuthenticationContext; } public void setClientInterceptors(final List<EJBClientInterceptor> clientInterceptors) { this.clientInterceptors = clientInterceptors; } public AuthenticationContext getClustersAuthenticationContext() { return clustersAuthenticationContext; } }
12,052
39.719595
156
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/LocalInvocationClassCloner.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import java.io.IOException; import java.lang.reflect.Proxy; import org.jboss.marshalling.cloner.ClassCloner; /** * {@link ClassCloner} that clones classes between class loaders, falling back * to original class if it cannot be found in the destination class loader. * * @author Stuart Douglas */ public class LocalInvocationClassCloner implements ClassCloner { private final ClassLoader destClassLoader; public LocalInvocationClassCloner(final ClassLoader destClassLoader) { this.destClassLoader = destClassLoader; } public Class<?> clone(final Class<?> original) throws IOException, ClassNotFoundException { final String name = original.getName(); if (name.startsWith("java.")) { return original; } else if (original.getClassLoader() == destClassLoader) { return original; } else { try { return Class.forName(name, true, destClassLoader); } catch (ClassNotFoundException e) { ClassLoader current = Thread.currentThread().getContextClassLoader(); if(current != destClassLoader) { try { return Class.forName(name, true, current); } catch (ClassNotFoundException ignored) { //fall through } } return original; } } } public Class<?> cloneProxy(final Class<?> proxyClass) throws IOException, ClassNotFoundException { final Class<?>[] origInterfaces = proxyClass.getInterfaces(); final Class<?>[] interfaces = new Class[origInterfaces.length]; for (int i = 0, origInterfacesLength = origInterfaces.length; i < origInterfacesLength; i++) { interfaces[i] = clone(origInterfaces[i]); } return Proxy.getProxyClass(destClassLoader, interfaces); } }
2,985
38.289474
102
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/RemoteViewManagedReferenceFactory.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import java.util.function.Supplier; import jakarta.ejb.EJBHome; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.as.naming.ContextListAndJndiViewManagedReferenceFactory; import org.jboss.as.naming.JndiViewManagedReferenceFactory; import org.jboss.as.naming.ManagedReference; import org.jboss.as.naming.ValueManagedReference; import org.jboss.ejb.client.Affinity; import org.jboss.ejb.client.EJBClient; import org.jboss.ejb.client.EJBHomeLocator; import org.jboss.ejb.client.EJBIdentifier; import org.jboss.ejb.client.EJBLocator; import org.jboss.ejb.client.StatelessEJBLocator; import org.wildfly.security.manager.WildFlySecurityManager; /** * Managed reference factory for remote Jakarta Enterprise Beans views that are bound to java: JNDI locations * * @author Stuart Douglas * @author Eduardo Martins */ public class RemoteViewManagedReferenceFactory implements ContextListAndJndiViewManagedReferenceFactory { private final EJBIdentifier identifier; private final String viewClass; private final boolean stateful; private final Supplier<ClassLoader> viewClassLoader; private final boolean appclient; public RemoteViewManagedReferenceFactory(final String appName, final String moduleName, final String distinctName, final String beanName, final String viewClass, final boolean stateful, final Supplier<ClassLoader> viewClassLoader, boolean appclient) { this(new EJBIdentifier(appName == null ? "" : appName, moduleName, beanName, distinctName), viewClass, stateful, viewClassLoader, appclient); } public RemoteViewManagedReferenceFactory(final EJBIdentifier identifier, final String viewClass, final boolean stateful, final Supplier<ClassLoader> viewClassLoader, boolean appclient) { this.identifier = identifier; this.viewClass = viewClass; this.stateful = stateful; this.viewClassLoader = viewClassLoader; this.appclient = appclient; } @Override public String getInstanceClassName() { return viewClass; } @Override public String getJndiViewInstanceValue() { return stateful ? JndiViewManagedReferenceFactory.DEFAULT_JNDI_VIEW_INSTANCE_VALUE : String.valueOf(getReference() .getInstance()); } @Override public ManagedReference getReference() { Class<?> viewClass; try { viewClass = Class.forName(this.viewClass, false, WildFlySecurityManager.getCurrentContextClassLoaderPrivileged()); } catch (ClassNotFoundException e) { if(viewClassLoader == null || viewClassLoader.get() == null) { throw EjbLogger.ROOT_LOGGER.failToLoadViewClassEjb(identifier.toString(), e); } try { viewClass = Class.forName(this.viewClass, false, viewClassLoader.get()); } catch (ClassNotFoundException ce) { throw EjbLogger.ROOT_LOGGER.failToLoadViewClassEjb(identifier.toString(), ce); } } EJBLocator<?> ejbLocator; if (EJBHome.class.isAssignableFrom(viewClass)) { ejbLocator = EJBHomeLocator.create(viewClass.asSubclass(EJBHome.class), identifier, appclient ? Affinity.NONE : Affinity.LOCAL); } else if (stateful) { try { ejbLocator = EJBClient.createSession(StatelessEJBLocator.create(viewClass, identifier, appclient ? Affinity.NONE : Affinity.LOCAL)); } catch (Exception e) { throw EjbLogger.ROOT_LOGGER.failedToCreateSessionForStatefulBean(e, identifier.toString()); } } else { ejbLocator = StatelessEJBLocator.create(viewClass, identifier, appclient ? Affinity.NONE : Affinity.LOCAL); } final Object proxy = EJBClient.createProxy(ejbLocator); return new ValueManagedReference(proxy); } }
4,901
43.972477
255
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/LocalTransportProvider.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import org.jboss.as.ejb3.deployment.DeploymentRepository; import org.jboss.ejb.client.EJBReceiver; import org.jboss.ejb.client.EJBReceiverContext; import org.jboss.ejb.client.EJBTransportProvider; import org.jboss.msc.inject.Injector; import org.jboss.msc.service.Service; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; import org.jboss.msc.value.InjectedValue; /** * @author <a href=mailto:[email protected]>Tomasz Adamski</a> */ public class LocalTransportProvider implements EJBTransportProvider, Service<LocalTransportProvider> { public static final ServiceName DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME = ServiceName.JBOSS.append("ejb").append("default-local-transport-provider"); public static final ServiceName BY_VALUE_SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "localTransportProvider", "value"); public static final ServiceName BY_REFERENCE_SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "localTransportProvider", "reference"); private final boolean allowPassByReference; private final InjectedValue<DeploymentRepository> deploymentRepository = new InjectedValue<>(); private volatile LocalEjbReceiver receiver; public LocalTransportProvider(final boolean allowPassByReference){ this.allowPassByReference = allowPassByReference; } @Override public void start(StartContext startContext) throws StartException { receiver = new LocalEjbReceiver(allowPassByReference, deploymentRepository.getValue()); } @Override public void stop(StopContext stopContext) { } @Override public void close(EJBReceiverContext receiverContext) throws Exception { } public boolean supportsProtocol(final String uriScheme) { switch (uriScheme) { case "local": { return true; } default: { return false; } } } public EJBReceiver getReceiver(final EJBReceiverContext receiverContext, final String uriScheme) throws IllegalArgumentException { switch (uriScheme) { case "local" : { break; } default: { throw new IllegalArgumentException("Unsupported EJB receiver protocol " + uriScheme); } } return receiver; } @Override public LocalTransportProvider getValue() throws IllegalStateException, IllegalArgumentException { return this; } public Injector<DeploymentRepository> getDeploymentRepository() { return deploymentRepository; } }
3,762
35.533981
159
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/EJBRemotingConnectorClientMappingsEntryProviderService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import static org.jboss.as.ejb3.subsystem.EJB3RemoteResourceDefinition.CONNECTOR_CAPABILITY_NAME; import java.net.Inet4Address; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.AbstractMap; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.jboss.as.clustering.controller.CapabilityServiceConfigurator; import org.jboss.as.controller.OperationContext; import org.jboss.as.network.ClientMapping; import org.jboss.as.network.ProtocolSocketBinding; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.group.Group; import org.wildfly.clustering.server.service.ClusteringRequirement; import org.wildfly.clustering.service.CompositeDependency; import org.wildfly.clustering.service.FunctionalService; import org.wildfly.clustering.service.ServiceConfigurator; import org.wildfly.clustering.service.ServiceSupplierDependency; import org.wildfly.clustering.service.SimpleServiceNameProvider; import org.wildfly.clustering.service.SupplierDependency; import org.wildfly.common.net.Inet; /** * @author Jaikiran Pai */ public class EJBRemotingConnectorClientMappingsEntryProviderService extends SimpleServiceNameProvider implements CapabilityServiceConfigurator, Supplier<Map.Entry<String, List<ClientMapping>>> { private static final ServiceName BASE_NAME = ServiceName.JBOSS.append("ejb", "remote", "client-mappings"); private volatile SupplierDependency<ProtocolSocketBinding> remotingConnectorInfo; private final String containerName; private final String connectorName; private volatile SupplierDependency<Group> group; public EJBRemotingConnectorClientMappingsEntryProviderService(String containerName, String connectorName) { super(BASE_NAME.append(connectorName)); this.containerName = containerName; this.connectorName = connectorName; } @Override public ServiceConfigurator configure(OperationContext context) { this.group = new ServiceSupplierDependency<>(ClusteringRequirement.GROUP.getServiceName(context, this.containerName)); this.remotingConnectorInfo = new ServiceSupplierDependency<>(context.getCapabilityServiceName(CONNECTOR_CAPABILITY_NAME, connectorName, ProtocolSocketBinding.class)); return this; } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<Map.Entry<String, List<ClientMapping>>> entry = new CompositeDependency(this.group, this.remotingConnectorInfo).register(builder).provides(name); Service service = new FunctionalService<>(entry, Function.identity(), this); return builder.setInstance(service); } @Override public Map.Entry<String, List<ClientMapping>> get() { return new AbstractMap.SimpleImmutableEntry<>(this.group.get().getLocalMember().getName(), this.getClientMappings()); } /** * This method provides client-mapping entries for all connected Jakarta Enterprise Beans clients. * It returns either a set of user-defined client mappings for a multi-homed host or a single default client mapping for the single-homed host. * Hostnames are preferred over literal IP addresses for the destination address part (due to EJBCLIENT-349). * * @return the client mappings for this host */ List<ClientMapping> getClientMappings() { final List<ClientMapping> ret = new ArrayList<>(); ProtocolSocketBinding info = this.remotingConnectorInfo.get(); if (info.getSocketBinding().getClientMappings() != null && !info.getSocketBinding().getClientMappings().isEmpty()) { ret.addAll(info.getSocketBinding().getClientMappings()); } else { // for the destination, prefer the hostname over the literal IP address final InetAddress destination = info.getSocketBinding().getAddress(); final String destinationName = Inet.toURLString(destination, true); // for the network, send a CIDR that is compatible with the address we are sending final InetAddress clientNetworkAddress; try { if (destination instanceof Inet4Address) { clientNetworkAddress = InetAddress.getByName("0.0.0.0"); } else { clientNetworkAddress = InetAddress.getByName("::"); } } catch (UnknownHostException e) { throw new RuntimeException(e); } final ClientMapping defaultClientMapping = new ClientMapping(clientNetworkAddress, 0, destinationName, info.getSocketBinding().getAbsolutePort()); ret.add(defaultClientMapping); } return ret; } }
6,109
46
194
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/AssociationService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import java.util.AbstractMap; import java.util.AbstractMap.SimpleImmutableEntry; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.Executor; import org.jboss.as.ejb3.deployment.DeploymentRepository; import org.jboss.as.network.ClientMapping; import org.jboss.as.network.ProtocolSocketBinding; import org.jboss.as.server.ServerEnvironment; import org.jboss.as.server.suspend.SuspendController; import org.jboss.ejb.client.Affinity; import org.jboss.ejb.client.EJBClientContext; import org.jboss.ejb.client.EJBModuleIdentifier; import org.jboss.ejb.server.Association; import org.jboss.ejb.server.ListenerHandle; import org.jboss.ejb.server.ModuleAvailabilityListener; import org.jboss.msc.inject.Injector; import org.jboss.msc.service.Service; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; import org.jboss.msc.value.InjectedValue; import org.jboss.msc.value.Value; import org.wildfly.clustering.group.Group; import org.wildfly.clustering.registry.Registry; import org.wildfly.discovery.AttributeValue; import org.wildfly.discovery.ServiceURL; import org.wildfly.discovery.impl.MutableDiscoveryProvider; import org.wildfly.discovery.spi.DiscoveryProvider; import org.wildfly.discovery.spi.DiscoveryRequest; /** * The Jakarta Enterprise Beans server association service. * * @author <a href="mailto:[email protected]">David M. Lloyd</a> */ public final class AssociationService implements Service<AssociationService> { public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("ejb", "association"); private final InjectedValue<DeploymentRepository> deploymentRepositoryInjector = new InjectedValue<>(); @SuppressWarnings("rawtypes") private final List<Map.Entry<Value<ProtocolSocketBinding>, Value<Registry>>> clientMappingsRegistries = new LinkedList<>(); private final InjectedValue<SuspendController> suspendControllerInjector = new InjectedValue<>(); private final InjectedValue<ServerEnvironment> serverEnvironmentServiceInjector = new InjectedValue<>(); private final Object serviceLock = new Object(); private final Set<EJBModuleIdentifier> ourModules = new HashSet<>(); private volatile ServiceURL cachedServiceURL; private final MutableDiscoveryProvider mutableDiscoveryProvider = new MutableDiscoveryProvider(); private volatile AssociationImpl value; private volatile ListenerHandle moduleAvailabilityListener; @Override public void start(final StartContext context) throws StartException { // todo suspendController //noinspection unchecked List<Map.Entry<ProtocolSocketBinding, Registry<String, List<ClientMapping>>>> clientMappingsRegistries = this.clientMappingsRegistries.isEmpty() ? Collections.emptyList() : new ArrayList<>(this.clientMappingsRegistries.size()); for (Map.Entry<Value<ProtocolSocketBinding>, Value<Registry>> entry : this.clientMappingsRegistries) { clientMappingsRegistries.add(new SimpleImmutableEntry<>(entry.getKey().getValue(), entry.getValue().getValue())); } value = new AssociationImpl(deploymentRepositoryInjector.getValue(), clientMappingsRegistries); String ourNodeName = serverEnvironmentServiceInjector.getValue().getNodeName(); // track deployments at an association level for local dispatchers to utilize moduleAvailabilityListener = value.registerModuleAvailabilityListener(new ModuleAvailabilityListener() { public void moduleAvailable(final List<EJBModuleIdentifier> modules) { synchronized (serviceLock) { ourModules.addAll(modules); cachedServiceURL = null; } } public void moduleUnavailable(final List<EJBModuleIdentifier> modules) { synchronized (serviceLock) { ourModules.removeAll(modules); cachedServiceURL = null; } } }); // do this last mutableDiscoveryProvider.setDiscoveryProvider((serviceType, filterSpec, result) -> { ServiceURL serviceURL = this.cachedServiceURL; if (serviceURL == null) { synchronized (serviceLock) { serviceURL = this.cachedServiceURL; if (serviceURL == null) { ServiceURL.Builder b = new ServiceURL.Builder(); b.setUri(Affinity.LOCAL.getUri()).setAbstractType("ejb").setAbstractTypeAuthority("jboss"); b.addAttribute(EJBClientContext.FILTER_ATTR_NODE, AttributeValue.fromString(ourNodeName)); for (Map.Entry<ProtocolSocketBinding, Registry<String, List<ClientMapping>>> entry : clientMappingsRegistries) { Group group = entry.getValue().getGroup(); if (!group.isSingleton()) { b.addAttribute(EJBClientContext.FILTER_ATTR_CLUSTER, AttributeValue.fromString(group.getName())); } } for (EJBModuleIdentifier moduleIdentifier : ourModules) { final String appName = moduleIdentifier.getAppName(); final String moduleName = moduleIdentifier.getModuleName(); final String distinctName = moduleIdentifier.getDistinctName(); if (distinctName.isEmpty()) { if (appName.isEmpty()) { b.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE, AttributeValue.fromString(moduleName)); } else { b.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE, AttributeValue.fromString(appName + '/' + moduleName)); } } else { if (appName.isEmpty()) { b.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE_DISTINCT, AttributeValue.fromString(moduleName + '/' + distinctName)); } else { b.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE_DISTINCT, AttributeValue.fromString(appName + '/' + moduleName + '/' + distinctName)); } } } serviceURL = this.cachedServiceURL = b.create(); } } } if (serviceURL.satisfies(filterSpec)) { result.addMatch(serviceURL); } result.complete(); return DiscoveryRequest.NULL; }); } @Override public void stop(final StopContext context) { value.close(); value = null; moduleAvailabilityListener.close(); moduleAvailabilityListener = null; mutableDiscoveryProvider.setDiscoveryProvider(DiscoveryProvider.EMPTY); synchronized (serviceLock) { cachedServiceURL = null; ourModules.clear(); } } @Override public AssociationService getValue() { return this; } public InjectedValue<ServerEnvironment> getServerEnvironmentServiceInjector() { return serverEnvironmentServiceInjector; } public InjectedValue<DeploymentRepository> getDeploymentRepositoryInjector() { return deploymentRepositoryInjector; } public Map.Entry<Injector<ProtocolSocketBinding>, Injector<Registry>> addConnectorInjectors(String connectorName) { InjectedValue<ProtocolSocketBinding> info = new InjectedValue<>(); InjectedValue<Registry> registry = new InjectedValue<>(); this.clientMappingsRegistries.add(new AbstractMap.SimpleImmutableEntry<>(info, registry)); return new AbstractMap.SimpleImmutableEntry<>(info, registry); } public InjectedValue<SuspendController> getSuspendControllerInjector() { return suspendControllerInjector; } public DiscoveryProvider getLocalDiscoveryProvider() { return mutableDiscoveryProvider; } public Association getAssociation() { return value; } void setExecutor(Executor executor) { this.value.setExecutor(executor); } void sendTopologyUpdateIfLastNodeToLeave() { this.value.sendTopologyUpdateIfLastNodeToLeave(); } }
9,831
44.518519
235
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/RemoteViewInjectionSource.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import java.util.function.Supplier; import org.jboss.as.ee.component.InjectionSource; import org.jboss.as.naming.ManagedReferenceFactory; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.msc.inject.Injector; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceName; /** * Injection source for Jakarta Enterprise Beans remote views. * * @author Stuart Douglas */ public class RemoteViewInjectionSource extends InjectionSource { private final ServiceName serviceName; private final String appName; private final String moduleName; private final String distinctName; private final String beanName; private final String viewClass; private final boolean stateful; private final Supplier<ClassLoader> viewClassLoader; private final boolean appclient; public RemoteViewInjectionSource(final ServiceName serviceName, final String appName, final String moduleName, final String distinctName, final String beanName, final String viewClass, final boolean stateful, final Supplier<ClassLoader> viewClassLoader, boolean appclient) { this.serviceName = serviceName; this.appName = appName; this.moduleName = moduleName; this.distinctName = distinctName; this.beanName = beanName; this.viewClass = viewClass; this.stateful = stateful; this.viewClassLoader = viewClassLoader; this.appclient = appclient; } /** * {@inheritDoc} */ public void getResourceValue(final ResolutionContext resolutionContext, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) { if(serviceName != null) { serviceBuilder.requires(serviceName); } final RemoteViewManagedReferenceFactory factory = new RemoteViewManagedReferenceFactory(appName, moduleName, distinctName, beanName, viewClass, stateful, viewClassLoader, appclient); injector.inject(factory); } @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final RemoteViewInjectionSource that = (RemoteViewInjectionSource) o; if (stateful != that.stateful) return false; if (appName != null ? !appName.equals(that.appName) : that.appName != null) return false; if (beanName != null ? !beanName.equals(that.beanName) : that.beanName != null) return false; if (distinctName != null ? !distinctName.equals(that.distinctName) : that.distinctName != null) return false; if (moduleName != null ? !moduleName.equals(that.moduleName) : that.moduleName != null) return false; if (viewClass != null ? !viewClass.equals(that.viewClass) : that.viewClass != null) return false; return true; } @Override public int hashCode() { int result = appName != null ? appName.hashCode() : 0; result = 31 * result + (moduleName != null ? moduleName.hashCode() : 0); result = 31 * result + (distinctName != null ? distinctName.hashCode() : 0); result = 31 * result + (beanName != null ? beanName.hashCode() : 0); result = 31 * result + (viewClass != null ? viewClass.hashCode() : 0); result = 31 * result + (stateful ? 1 : 0); return result; } }
4,465
43.217822
278
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/AssociationImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote; import java.io.IOException; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CancellationException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; import jakarta.ejb.EJBException; import org.jboss.as.ee.component.Component; import org.jboss.as.ee.component.ComponentIsStoppedException; import org.jboss.as.ee.component.ComponentView; import org.jboss.as.ee.component.interceptors.InvocationType; import org.jboss.as.ejb3.component.EJBComponentUnavailableException; import org.jboss.as.ejb3.component.interceptors.CancellationFlag; import org.jboss.as.ejb3.component.session.SessionBeanComponent; import org.jboss.as.ejb3.component.stateful.StatefulSessionComponent; import org.jboss.as.ejb3.component.stateless.StatelessSessionComponent; import org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier; import org.jboss.as.ejb3.deployment.DeploymentRepository; import org.jboss.as.ejb3.deployment.DeploymentRepositoryListener; import org.jboss.as.ejb3.deployment.EjbDeploymentInformation; import org.jboss.as.ejb3.deployment.ModuleDeployment; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.as.network.ClientMapping; import org.jboss.as.network.ProtocolSocketBinding; import org.jboss.ejb.client.Affinity; import org.jboss.ejb.client.ClusterAffinity; import org.jboss.ejb.client.EJBClientInvocationContext; import org.jboss.ejb.client.EJBIdentifier; import org.jboss.ejb.client.EJBLocator; import org.jboss.ejb.client.EJBMethodLocator; import org.jboss.ejb.client.EJBModuleIdentifier; import org.jboss.ejb.client.NodeAffinity; import org.jboss.ejb.client.SessionID; import org.jboss.ejb.client.StatefulEJBLocator; import org.jboss.ejb.server.Association; import org.jboss.ejb.server.CancelHandle; import org.jboss.ejb.server.ClusterTopologyListener; import org.jboss.ejb.server.InvocationRequest; import org.jboss.ejb.server.ListenerHandle; import org.jboss.ejb.server.ModuleAvailabilityListener; import org.jboss.ejb.server.Request; import org.jboss.ejb.server.SessionOpenRequest; import org.jboss.invocation.InterceptorContext; import org.wildfly.clustering.Registration; import org.wildfly.clustering.group.Group; import org.wildfly.clustering.registry.Registry; import org.wildfly.clustering.registry.RegistryListener; import org.wildfly.common.annotation.NotNull; import org.wildfly.security.auth.server.SecurityIdentity; import org.wildfly.security.manager.WildFlySecurityManager; /** * @author <a href="mailto:[email protected]">Tomasz Adamski</a> * @author <a href="mailto:[email protected]">Joerg Baesner</a> */ final class AssociationImpl implements Association, AutoCloseable { private static final String RETURNED_CONTEXT_DATA_KEY = "jboss.returned.keys"; private static final ListenerHandle NOOP_LISTENER_HANDLE = new ListenerHandle() { @Override public void close() { // Do nothing } }; private final DeploymentRepository deploymentRepository; private final Map<Integer, ClusterTopologyRegistrar> clusterTopologyRegistrars; private volatile Executor executor; AssociationImpl(final DeploymentRepository deploymentRepository, final List<Map.Entry<ProtocolSocketBinding, Registry<String, List<ClientMapping>>>> clientMappingRegistries) { this.deploymentRepository = deploymentRepository; this.clusterTopologyRegistrars = clientMappingRegistries.isEmpty() ? Collections.emptyMap() : new HashMap<>(clientMappingRegistries.size()); for (Map.Entry<ProtocolSocketBinding, Registry<String, List<ClientMapping>>> entry : clientMappingRegistries) { this.clusterTopologyRegistrars.put(entry.getKey().getSocketBinding().getSocketAddress().getPort(), new ClusterTopologyRegistrar(entry.getValue())); } } @Override public void close() { for (ClusterTopologyRegistrar registrar : this.clusterTopologyRegistrars.values()) { registrar.close(); } } @Override public CancelHandle receiveInvocationRequest(@NotNull final InvocationRequest invocationRequest) { final EJBIdentifier ejbIdentifier = invocationRequest.getEJBIdentifier(); final String appName = ejbIdentifier.getAppName(); final String moduleName = ejbIdentifier.getModuleName(); final String distinctName = ejbIdentifier.getDistinctName(); final String beanName = ejbIdentifier.getBeanName(); final EjbDeploymentInformation ejbDeploymentInformation = findEJB(appName, moduleName, distinctName, beanName); if (ejbDeploymentInformation == null) { invocationRequest.writeNoSuchEJB(); return CancelHandle.NULL; } final ClassLoader classLoader = ejbDeploymentInformation.getDeploymentClassLoader(); ClassLoader originalTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); final InvocationRequest.Resolved requestContent; try { requestContent = invocationRequest.getRequestContent(classLoader); } catch (IOException | ClassNotFoundException e) { invocationRequest.writeException(new EJBException(e)); return CancelHandle.NULL; } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(originalTccl); } final Map<String, Object> attachments = requestContent.getAttachments(); final EJBLocator<?> ejbLocator = requestContent.getEJBLocator(); final String viewClassName = ejbLocator.getViewType().getName(); if (!ejbDeploymentInformation.isRemoteView(viewClassName)) { invocationRequest.writeWrongViewType(); return CancelHandle.NULL; } final ComponentView componentView = ejbDeploymentInformation.getView(viewClassName); final Method invokedMethod = findMethod(componentView, invocationRequest.getMethodLocator()); if (invokedMethod == null) { invocationRequest.writeNoSuchMethod(); return CancelHandle.NULL; } final Component component = componentView.getComponent(); try { component.waitForComponentStart(); } catch (RuntimeException e) { invocationRequest.writeException(new EJBException(e)); return CancelHandle.NULL; } final EJBLocator<?> actualLocator; if (component instanceof StatefulSessionComponent) { if (ejbLocator.isStateless()) { final SessionID sessionID = ((StatefulSessionComponent) component).createSessionRemote(); try { invocationRequest.convertToStateful(sessionID); } catch (IllegalArgumentException e) { // cannot convert (old protocol) invocationRequest.writeNotStateful(); return CancelHandle.NULL; } actualLocator = ejbLocator.withSession(sessionID); } else { actualLocator = ejbLocator; } } else { if (ejbLocator.isStateful()) { invocationRequest.writeNotStateful(); return CancelHandle.NULL; } else { actualLocator = ejbLocator; } } final boolean isAsync = componentView.isAsynchronous(invokedMethod); final boolean oneWay = isAsync && invokedMethod.getReturnType() == void.class; if (oneWay) { // send immediate response updateAffinities(invocationRequest, attachments, ejbLocator, componentView); requestContent.writeInvocationResult(null); } else if(isAsync) { invocationRequest.writeProceedAsync(); } final CancellationFlag cancellationFlag = new CancellationFlag(); Runnable runnable = () -> { if (! cancellationFlag.runIfNotCancelled()) { if (! oneWay) invocationRequest.writeCancelResponse(); return; } // invoke the method final Object result; try { final Map<String, Object> contextDataHolder = new HashMap<>(); result = invokeMethod(componentView, invokedMethod, invocationRequest, requestContent, cancellationFlag, actualLocator, contextDataHolder); attachments.putAll(contextDataHolder); } catch (EJBComponentUnavailableException ex) { // if the Jakarta Enterprise Beans are shutting down when the invocation was done, then it's as good as the Jakarta Enterprise Beans not being available. The client has to know about this as // a "no such EJB" failure so that it can retry the invocation on a different node if possible. EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Cannot handle method invocation: %s on bean: %s due to Jakarta Enterprise Beans component unavailability exception. Returning a no such Jakarta Enterprise Beans available message back to client", invokedMethod, beanName); if (! oneWay) invocationRequest.writeNoSuchEJB(); return; } catch (ComponentIsStoppedException ex) { EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Cannot handle method invocation: %s on bean: %s due to Jakarta Enterprise Beans component stopped exception. Returning a no such Jakarta Enterprise Beans available message back to client", invokedMethod, beanName); if (! oneWay) invocationRequest.writeNoSuchEJB(); return; // TODO should we write a specifc response with a specific protocol letting client know that server is suspending? } catch (CancellationException ex) { if (! oneWay) invocationRequest.writeCancelResponse(); return; } catch (Exception exception) { if (oneWay) return; // write out the failure final Exception exceptionToWrite; final Throwable cause = exception.getCause(); if (componentView.getComponent() instanceof StatefulSessionComponent && exception instanceof EJBException && cause != null) { if (!(componentView.getComponent().isRemotable(cause))) { // Avoid serializing the cause of the exception in case it is not remotable // Client might not be able to deserialize and throw ClassNotFoundException exceptionToWrite = new EJBException(exception.getLocalizedMessage()); } else { exceptionToWrite = exception; } } else { exceptionToWrite = exception; } invocationRequest.writeException(exceptionToWrite); return; } // invocation was successful if (! oneWay) try { updateAffinities(invocationRequest, attachments, actualLocator, componentView); requestContent.writeInvocationResult(result); } catch (Throwable ioe) { EjbLogger.REMOTE_LOGGER.couldNotWriteMethodInvocation(ioe, invokedMethod, beanName, appName, moduleName, distinctName); } }; // invoke the method and write out the response, possibly on a separate thread execute(invocationRequest, runnable, isAsync, false); return cancellationFlag::cancel; } private void updateAffinities(InvocationRequest invocationRequest, Map<String, Object> attachments, EJBLocator<?> ejbLocator, ComponentView componentView) { Affinity legacyAffinity = null; Affinity weakAffinity = null; Affinity strongAffinity = null; if (ejbLocator.isStateful() && componentView.getComponent() instanceof StatefulSessionComponent) { final StatefulSessionComponent statefulSessionComponent = (StatefulSessionComponent) componentView.getComponent(); strongAffinity = getStrongAffinity(statefulSessionComponent); weakAffinity = legacyAffinity = getWeakAffinity(statefulSessionComponent, ejbLocator.asStateful()); } else if (componentView.getComponent() instanceof StatelessSessionComponent) { // Stateless invocations no not require strong affinity, only weak affinity to nodes within the same cluster, if present. // However, since V3, the Jakarta Enterprise Beans client does not support weak affinity updates referencing a cluster (and even then, only via Affinity.WEAK_AFFINITY_CONTEXT_KEY), only a node. // Until this is corrected, we need to use the strong affinity instead. strongAffinity = legacyAffinity = this.getStatelessAffinity(invocationRequest); } // cause the affinity values to get sent back to the client if (strongAffinity != null && !(strongAffinity instanceof NodeAffinity)) { invocationRequest.updateStrongAffinity(strongAffinity); } if (weakAffinity != null && !weakAffinity.equals(Affinity.NONE)) { invocationRequest.updateWeakAffinity(weakAffinity); } if (legacyAffinity != null && !legacyAffinity.equals(Affinity.NONE)) { attachments.put(Affinity.WEAK_AFFINITY_CONTEXT_KEY, legacyAffinity); } EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Called receiveInvocationRequest ( bean = %s ): strong affinity = %s, weak affinity = %s \n", componentView.getComponent().getClass().getName(), strongAffinity, weakAffinity); } private void execute(Request request, Runnable task, final boolean isAsync, boolean alwaysDispatch) { if (request.getProtocol().equals("local") && ! isAsync) { task.run(); } else { if(executor != null) { executor.execute(task); } else if(isAsync || alwaysDispatch){ request.getRequestExecutor().execute(task); } else { task.run(); } } } @Override @NotNull public CancelHandle receiveSessionOpenRequest(@NotNull final SessionOpenRequest sessionOpenRequest) { final EJBIdentifier ejbIdentifier = sessionOpenRequest.getEJBIdentifier(); final String appName = ejbIdentifier.getAppName(); final String moduleName = ejbIdentifier.getModuleName(); final String beanName = ejbIdentifier.getBeanName(); final String distinctName = ejbIdentifier.getDistinctName(); final EjbDeploymentInformation ejbDeploymentInformation = findEJB(appName, moduleName, distinctName, beanName); if (ejbDeploymentInformation == null) { sessionOpenRequest.writeNoSuchEJB(); return CancelHandle.NULL; } final Component component = ejbDeploymentInformation.getEjbComponent(); component.waitForComponentStart(); if (!(component instanceof StatefulSessionComponent)) { sessionOpenRequest.writeNotStateful(); return CancelHandle.NULL; } final StatefulSessionComponent statefulSessionComponent = (StatefulSessionComponent) component; // generate the session id and write out the response, possibly on a separate thread final AtomicBoolean cancelled = new AtomicBoolean(); Runnable runnable = () -> { if (cancelled.get()) { sessionOpenRequest.writeCancelResponse(); return; } final SessionID sessionID; try { sessionID = statefulSessionComponent.createSessionRemote(); } catch (EJBComponentUnavailableException ex) { // if the Jakarta Enterprise Beans are shutting down when the invocation was done, then it's as good as the Jakarta Enterprise Beans not being available. The client has to know about this as // a "no such Jakarta Enterprise Beans" failure so that it can retry the invocation on a different node if possible. EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Cannot handle session creation on bean: %s due to Jakarta Enterprise Beans component unavailability exception. Returning a no such Jakarta Enterprise Beans available message back to client", beanName); sessionOpenRequest.writeNoSuchEJB(); return; } catch (ComponentIsStoppedException ex) { EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Cannot handle session creation on bean: %s due to Jakarta Enterprise Beans component stopped exception. Returning a no such Jakarta Enterprise Beans available message back to client", beanName); sessionOpenRequest.writeNoSuchEJB(); return; // TODO should we write a specifc response with a specific protocol letting client know that server is suspending? } catch (Exception t) { EjbLogger.REMOTE_LOGGER.exceptionGeneratingSessionId(t, statefulSessionComponent.getComponentName(), ejbIdentifier); sessionOpenRequest.writeException(t); return; } // do not update strongAffinity when it is of type NodeAffinity; this will be achieved on the client in DiscoveryInterceptor via targetAffinity Affinity strongAffinity = getStrongAffinity(statefulSessionComponent); if (strongAffinity != null && !(strongAffinity instanceof NodeAffinity)) { sessionOpenRequest.updateStrongAffinity(strongAffinity); } Affinity weakAffinity = getWeakAffinity(statefulSessionComponent, sessionID); if (weakAffinity != null && !Affinity.NONE.equals(weakAffinity)) { sessionOpenRequest.updateWeakAffinity(weakAffinity); } EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Called receiveSessionOpenRequest ( bean = %s ): strong affinity = %s, weak affinity = %s \n", statefulSessionComponent.getClass().getName(), strongAffinity, weakAffinity); sessionOpenRequest.convertToStateful(sessionID); }; execute(sessionOpenRequest, runnable, false, true); return ignored -> cancelled.set(true); } @Override public ListenerHandle registerClusterTopologyListener(@NotNull final ClusterTopologyListener listener) { SocketAddress localAddress = listener.getConnection().getLocalAddress(); ClusterTopologyRegistrar registrar = this.findClusterTopologyRegistrar(localAddress); // if the registrar is null, this means that the connector has not been registered on the <remote connectors=/> attribute // and this represents an invalid server configuration (see WFLY-14567) if (registrar == null) { int port = (localAddress instanceof InetSocketAddress) ? ((InetSocketAddress)localAddress).getPort() : 0 ; String address = (localAddress instanceof InetSocketAddress) ? ((InetSocketAddress)localAddress).getAddress().toString() : "0.0.0.0" ; EjbLogger.EJB3_INVOCATION_LOGGER.connectorNotConfiguredForEJBClientInvocations(address, port); } return (registrar != null) ? registrar.registerClusterTopologyListener(listener) : NOOP_LISTENER_HANDLE; } @Override public ListenerHandle registerModuleAvailabilityListener(@NotNull final ModuleAvailabilityListener moduleAvailabilityListener) { final DeploymentRepositoryListener listener = new DeploymentRepositoryListener() { @Override public void listenerAdded(final DeploymentRepository repository) { List<EJBModuleIdentifier> list = new ArrayList<>(); if (!repositoryIsSuspended()) { // only send out the initial list if the deployment repository (i.e. the server + clean transaction state) is not in a suspended state for (DeploymentModuleIdentifier deploymentModuleIdentifier : repository.getModules().keySet()) { EJBModuleIdentifier ejbModuleIdentifier = toModuleIdentifier(deploymentModuleIdentifier); list.add(ejbModuleIdentifier); } EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Sending initial module availability to connecting client: server is not suspended"); } else { // send out empty list if the deploymentRepository is suspended EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Sending empty initial module availability to connecting client: server is suspended"); } moduleAvailabilityListener.moduleAvailable(list); } @Override public void deploymentAvailable(final DeploymentModuleIdentifier deployment, final ModuleDeployment moduleDeployment) { } @Override public void deploymentStarted(final DeploymentModuleIdentifier deployment, final ModuleDeployment moduleDeployment) { // only send out moduleAvailability until module has started (WFLY-13009) moduleAvailabilityListener.moduleAvailable(Collections.singletonList(toModuleIdentifier(deployment))); } @Override public void deploymentRemoved(final DeploymentModuleIdentifier deployment) { moduleAvailabilityListener.moduleUnavailable(Collections.singletonList(toModuleIdentifier(deployment))); } @Override public void deploymentSuspended(DeploymentModuleIdentifier deployment) { moduleAvailabilityListener.moduleUnavailable(Collections.singletonList(toModuleIdentifier(deployment))); } @Override public void deploymentResumed(DeploymentModuleIdentifier deployment) { moduleAvailabilityListener.moduleAvailable(Collections.singletonList(toModuleIdentifier(deployment))); } private boolean repositoryIsSuspended() { return deploymentRepository.isSuspended(); } }; deploymentRepository.addListener(listener); return () -> deploymentRepository.removeListener(listener); } static EJBModuleIdentifier toModuleIdentifier(final DeploymentModuleIdentifier identifier) { return new EJBModuleIdentifier(identifier.getApplicationName(), identifier.getModuleName(), identifier.getDistinctName()); } private EjbDeploymentInformation findEJB(final String appName, final String moduleName, final String distinctName, final String beanName) { final DeploymentModuleIdentifier ejbModule = new DeploymentModuleIdentifier(appName, moduleName, distinctName); final Map<DeploymentModuleIdentifier, ModuleDeployment> modules = this.deploymentRepository.getStartedModules(); if (modules == null || modules.isEmpty()) { return null; } final ModuleDeployment moduleDeployment = modules.get(ejbModule); if (moduleDeployment == null) { return null; } return moduleDeployment.getEjbs().get(beanName); } private static final class ClusterTopologyRegistrar implements RegistryListener<String, List<ClientMapping>> { private final Set<ClusterTopologyListener> clusterTopologyListeners = ConcurrentHashMap.newKeySet(); private final Registry<String, List<ClientMapping>> clientMappingRegistry; private final Registration listenerRegistration; ClusterTopologyRegistrar(Registry<String, List<ClientMapping>> clientMappingRegistry) { this.clientMappingRegistry = clientMappingRegistry; this.listenerRegistration = clientMappingRegistry.register(this); } @Override public void addedEntries(Map<String, List<ClientMapping>> added) { ClusterTopologyListener.ClusterInfo info = getClusterInfo(added); for (ClusterTopologyListener listener : this.clusterTopologyListeners) {// Synchronize each listener to ensure that the initial topology was set before processing new entries synchronized (listener) { listener.clusterNewNodesAdded(info); } } } @Override public void updatedEntries(Map<String, List<ClientMapping>> updated) { this.addedEntries(updated); } @Override public void removedEntries(Map<String, List<ClientMapping>> removed) { List<ClusterTopologyListener.ClusterRemovalInfo> removals = Collections.singletonList(new ClusterTopologyListener.ClusterRemovalInfo(this.clientMappingRegistry.getGroup().getName(), new ArrayList<>(removed.keySet()))); for (ClusterTopologyListener listener : this.clusterTopologyListeners) {// Synchronize each listener to ensure that the initial topology was set before processing removed entries synchronized (listener) { listener.clusterNodesRemoved(removals); } } } ListenerHandle registerClusterTopologyListener(ClusterTopologyListener listener) { // Synchronize on the listener to ensure that the initial topology is set before processing any changes from the registry listener synchronized (listener) { this.clusterTopologyListeners.add(listener); listener.clusterTopology(!this.clientMappingRegistry.getGroup().isSingleton() ? Collections.singletonList(getClusterInfo(this.clientMappingRegistry.getEntries())) : Collections.emptyList()); } return () -> this.clusterTopologyListeners.remove(listener); } void close() { this.listenerRegistration.close(); this.clusterTopologyListeners.clear(); } Group getGroup() { return this.clientMappingRegistry.getGroup(); } ClusterTopologyListener.ClusterInfo getClusterInfo(final Map<String, List<ClientMapping>> entries) { final List<ClusterTopologyListener.NodeInfo> nodeInfoList = new ArrayList<>(entries.size()); for (Map.Entry<String, List<ClientMapping>> entry : entries.entrySet()) { final String nodeName = entry.getKey(); final List<ClientMapping> clientMappingList = entry.getValue(); final List<ClusterTopologyListener.MappingInfo> mappingInfoList = new ArrayList<>(clientMappingList.size()); for (ClientMapping clientMapping : clientMappingList) { try { if (InetAddress.getByName(clientMapping.getDestinationAddress()).isAnyLocalAddress()) { EjbLogger.REMOTE_LOGGER.clusteredEJBsBoundToINADDRANY(nodeName, clientMapping.getDestinationAddress()); } } catch (UnknownHostException e) { // ignore } mappingInfoList.add(new ClusterTopologyListener.MappingInfo( clientMapping.getDestinationAddress(), clientMapping.getDestinationPort(), clientMapping.getSourceNetworkAddress(), clientMapping.getSourceNetworkMaskBits()) ); } nodeInfoList.add(new ClusterTopologyListener.NodeInfo(nodeName, mappingInfoList)); } return new ClusterTopologyListener.ClusterInfo(this.clientMappingRegistry.getGroup().getName(), nodeInfoList); } void sendTopologyUpdateIfLastNodeToLeave() { // if we are the only member, we need to send a topology update, as there will not be other members left in the cluster to send it on our behalf (WFLY-11682) // check if we are the only member in the cluster (either we have a local entry and we are the only member, or we do not and the entries are empty) Map.Entry<String, List<ClientMapping>> localEntry = this.clientMappingRegistry.getEntry(this.clientMappingRegistry.getGroup().getLocalMember()); Map<String, List<ClientMapping>> entries = this.clientMappingRegistry.getEntries(); boolean loneMember = localEntry != null ? (entries.size() == 1) && entries.containsKey(localEntry.getKey()) : entries.isEmpty(); if (loneMember) { String cluster = this.clientMappingRegistry.getGroup().getName(); for (ClusterTopologyListener listener : this.clusterTopologyListeners) { // send the clusterRemoval message to the listener listener.clusterRemoval(Arrays.asList(cluster)); } } } } static Object invokeMethod(final ComponentView componentView, final Method method, final InvocationRequest incomingInvocation, final InvocationRequest.Resolved content, final CancellationFlag cancellationFlag, final EJBLocator<?> ejbLocator, Map<String, Object> contextDataHolder) throws Exception { final InterceptorContext interceptorContext = new InterceptorContext(); interceptorContext.setParameters(content.getParameters()); interceptorContext.setMethod(method); interceptorContext.putPrivateData(Component.class, componentView.getComponent()); interceptorContext.putPrivateData(ComponentView.class, componentView); interceptorContext.putPrivateData(InvocationType.class, InvocationType.REMOTE); interceptorContext.setBlockingCaller(false); // setup the contextData on the (spec specified) InvocationContext final Map<String, Object> invocationContextData = new HashMap<String, Object>(); interceptorContext.setContextData(invocationContextData); if (content.getAttachments() != null) { // attach the attachments which were passed from the remote client for (final Map.Entry<String, Object> attachment : content.getAttachments().entrySet()){ if (attachment == null) { continue; } final String key = attachment.getKey(); final Object value = attachment.getValue(); // these are private to JBoss Jakarta Enterprise Beans implementation and not meant to be visible to the // application, so add these attachments to the privateData of the InterceptorContext if (EJBClientInvocationContext.PRIVATE_ATTACHMENTS_KEY.equals(key)) { final Map<?, ?> privateAttachments = (Map<?, ?>) value; for (final Map.Entry<?, ?> privateAttachment : privateAttachments.entrySet()) { interceptorContext.putPrivateData(privateAttachment.getKey(), privateAttachment.getValue()); } } else { // add it to the InvocationContext which will be visible to the target bean and the // application specific interceptors invocationContextData.put(key, value); } } } // add the session id to the interceptor context, if it's a stateful ejb locator if (ejbLocator.isStateful()) { interceptorContext.putPrivateData(SessionID.class, ejbLocator.asStateful().getSessionId()); } // add transaction if (content.hasTransaction()) { interceptorContext.setTransactionSupplier(content::getTransaction); } // add security identity final SecurityIdentity securityIdentity = incomingInvocation.getSecurityIdentity(); final boolean isAsync = componentView.isAsynchronous(method); final boolean oneWay = isAsync && method.getReturnType() == void.class; final boolean isSessionBean = componentView.getComponent() instanceof SessionBeanComponent; if (isAsync && isSessionBean) { if (! oneWay) { interceptorContext.putPrivateData(CancellationFlag.class, cancellationFlag); } final Object result = invokeWithIdentity(componentView, interceptorContext, securityIdentity); handleReturningContextData(contextDataHolder, interceptorContext, content); return result == null ? null : ((Future<?>) result).get(); } else { Object result = invokeWithIdentity(componentView, interceptorContext, securityIdentity); handleReturningContextData(contextDataHolder, interceptorContext, content); return result; } } private static void handleReturningContextData(Map<String, Object> contextDataHolder, InterceptorContext interceptorContext, InvocationRequest.Resolved content) { Set<String> returnKeys = (Set<String>) content.getAttachments().get(RETURNED_CONTEXT_DATA_KEY); if(returnKeys == null) { return; } for(String key : returnKeys) { if(interceptorContext.getContextData().containsKey(key)) { contextDataHolder.put(key, interceptorContext.getContextData().get(key)); } else { // need to remove the attachment, as the ContextData value for this key got removed content.getAttachments().remove(key); } } } private static Object invokeWithIdentity(final ComponentView componentView, final InterceptorContext interceptorContext, final SecurityIdentity securityIdentity) throws Exception { return securityIdentity == null ? componentView.invoke(interceptorContext) : securityIdentity.runAsFunctionEx(ComponentView::invoke, componentView, interceptorContext); } private static Method findMethod(final ComponentView componentView, final EJBMethodLocator ejbMethodLocator) { final Set<Method> viewMethods = componentView.getViewMethods(); for (final Method method : viewMethods) { if (method.getName().equals(ejbMethodLocator.getMethodName())) { final Class<?>[] methodParamTypes = method.getParameterTypes(); if (methodParamTypes.length != ejbMethodLocator.getParameterCount()) { continue; } boolean found = true; for (int i = 0; i < methodParamTypes.length; i++) { if (!methodParamTypes[i].getName().equals(ejbMethodLocator.getParameterTypeName(i))) { found = false; break; } } if (found) { return method; } } } return null; } private static Affinity getStrongAffinity(final StatefulSessionComponent statefulSessionComponent) { return statefulSessionComponent.getCache().getStrongAffinity(); } private static Affinity getWeakAffinity(final StatefulSessionComponent statefulSessionComponent, final StatefulEJBLocator<?> statefulEJBLocator) { final SessionID sessionID = statefulEJBLocator.getSessionId(); return getWeakAffinity(statefulSessionComponent, sessionID); } private static Affinity getWeakAffinity(final StatefulSessionComponent statefulSessionComponent, final SessionID sessionID) { return statefulSessionComponent.getCache().getWeakAffinity(sessionID); } private Affinity getStatelessAffinity(Request request) { ClusterTopologyRegistrar registrar = this.findClusterTopologyRegistrar(request.getLocalAddress()); Group group = (registrar != null) ? registrar.getGroup() : null; return group != null && !group.isSingleton() ? new ClusterAffinity(group.getName()) : null; } private ClusterTopologyRegistrar findClusterTopologyRegistrar(SocketAddress localAddress) { return (localAddress instanceof InetSocketAddress) ? this.clusterTopologyRegistrars.get(((InetSocketAddress) localAddress).getPort()) : null; } Executor getExecutor() { return executor; } void setExecutor(Executor executor) { this.executor = executor; } /** * Checks if this node is the last node in the cluster and sends a topology update to all connected clients if this is so * This should only be called when the node is known to be shutting down (and not just suspending) */ void sendTopologyUpdateIfLastNodeToLeave() { for (ClusterTopologyRegistrar registrar : this.clusterTopologyRegistrars.values()) { registrar.sendTopologyUpdateIfLastNodeToLeave(); } } }
38,264
51.998615
303
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/remote/http/EJB3RemoteHTTPService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, 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 * 2110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.remote.http; import java.util.function.Function; import io.undertow.server.handlers.PathHandler; import org.jboss.as.ejb3.remote.AssociationService; import org.jboss.msc.service.Service; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; import org.jboss.msc.value.InjectedValue; import org.wildfly.httpclient.ejb.EjbHttpService; import org.wildfly.transaction.client.LocalTransactionContext; /** * @author Stuart Douglas */ public class EJB3RemoteHTTPService implements Service<EJB3RemoteHTTPService> { public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("ejb", "remote", "http-invoker"); private final InjectedValue<PathHandler> pathHandlerInjectedValue = new InjectedValue<>(); private final InjectedValue<AssociationService> associationServiceInjectedValue = new InjectedValue<>(); private final InjectedValue<LocalTransactionContext> localTransactionContextInjectedValue = new InjectedValue<>(); private final Function<String, Boolean> classResolverFilter; public EJB3RemoteHTTPService(final Function<String, Boolean> classResolverFilter) { this.classResolverFilter = classResolverFilter; } @Override public void start(StartContext context) throws StartException { EjbHttpService service = new EjbHttpService(associationServiceInjectedValue.getValue().getAssociation(), null, localTransactionContextInjectedValue.getValue(), classResolverFilter); pathHandlerInjectedValue.getValue().addPrefixPath("/ejb", service.createHttpHandler()); } @Override public void stop(StopContext context) { pathHandlerInjectedValue.getValue().removePrefixPath("/ejb"); } @Override public EJB3RemoteHTTPService getValue() throws IllegalStateException, IllegalArgumentException { return this; } public InjectedValue<PathHandler> getPathHandlerInjectedValue() { return pathHandlerInjectedValue; } public InjectedValue<AssociationService> getAssociationServiceInjectedValue() { return associationServiceInjectedValue; } public InjectedValue<LocalTransactionContext> getLocalTransactionContextInjectedValue() { return localTransactionContextInjectedValue; } }
3,411
40.609756
118
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/resourceadapterbinding/parser/EJBBoundResourceAdapterBindingMetaDataParser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.resourceadapterbinding.parser; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import org.jboss.as.ejb3.resourceadapterbinding.metadata.EJBBoundResourceAdapterBindingMetaData; import org.jboss.metadata.ejb.parser.jboss.ejb3.AbstractEJBBoundMetaDataParser; import org.jboss.metadata.property.PropertyReplacer; /** * Parser for EJBBoundSecurityMetaData components. * * @author <a href="mailto:[email protected]">Marcus Moyses</a> */ public class EJBBoundResourceAdapterBindingMetaDataParser extends AbstractEJBBoundMetaDataParser<EJBBoundResourceAdapterBindingMetaData> { public static final String LEGACY_NAMESPACE_URI = "urn:resource-adapter-binding"; public static final String NAMESPACE_URI_1_0 = "urn:resource-adapter-binding:1.0"; public static final String NAMESPACE_URI_2_0 = "urn:resource-adapter-binding:2.0"; public static final EJBBoundResourceAdapterBindingMetaDataParser INSTANCE = new EJBBoundResourceAdapterBindingMetaDataParser(); private EJBBoundResourceAdapterBindingMetaDataParser() { } @Override public EJBBoundResourceAdapterBindingMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { EJBBoundResourceAdapterBindingMetaData metaData = new EJBBoundResourceAdapterBindingMetaData(); processElements(metaData, reader, propertyReplacer); return metaData; } @Override protected void processElement(EJBBoundResourceAdapterBindingMetaData metaData, XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { final String namespaceURI = reader.getNamespaceURI(); final String localName = reader.getLocalName(); if (LEGACY_NAMESPACE_URI.equals(namespaceURI) || NAMESPACE_URI_2_0.equals(namespaceURI) || NAMESPACE_URI_1_0.equals(namespaceURI)) { if ("resource-adapter-name".equals(localName)) { metaData.setResourceAdapterName(getElementText(reader, propertyReplacer)); } else { throw unexpectedElement(reader); } } else { super.processElement(metaData, reader, propertyReplacer); } } }
3,312
44.383562
176
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/resourceadapterbinding/metadata/EJBBoundResourceAdapterBindingMetaData.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.resourceadapterbinding.metadata; import org.jboss.metadata.ejb.parser.jboss.ejb3.AbstractEJBBoundMetaData; /** * Metadata for resource adapter binding of message driven beans * * @author <a href="mailto:[email protected]">Robert Panzer</a> * */ public class EJBBoundResourceAdapterBindingMetaData extends AbstractEJBBoundMetaData { private static final long serialVersionUID = -5981839317495286524L; private String resourceAdapterName; public String getResourceAdapterName() { return resourceAdapterName; } public void setResourceAdapterName(String resourceAdapterName) { this.resourceAdapterName = resourceAdapterName; } }
1,741
35.291667
86
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StatefulSessionBeanCacheProviderServiceConfigurator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.clustering.controller.CapabilityServiceNameProvider; import org.jboss.as.clustering.controller.ResourceServiceConfigurator; import org.jboss.as.controller.PathAddress; import org.jboss.as.ejb3.component.stateful.StatefulSessionComponentInstance; import org.jboss.as.ejb3.component.stateful.cache.StatefulSessionBeanCacheProvider; import org.jboss.ejb.client.SessionID; 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.service.FunctionalService; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; /** * Base class which provides configure(), build() methods used to allow SimpleResourceServiceHandler to install * a CacheFactoryBuilder service. * * The class installs the service using: * - a service name obtained from a capability and a path address, and * - a service value obtained from this class, via a Supplier<CacheFactoryBuilder> * * Subclasses should implement the get() method to return the CacheFactoryBuilder. */ public abstract class StatefulSessionBeanCacheProviderServiceConfigurator extends CapabilityServiceNameProvider implements ResourceServiceConfigurator, Supplier<StatefulSessionBeanCacheProvider<SessionID, StatefulSessionComponentInstance>> { public StatefulSessionBeanCacheProviderServiceConfigurator(PathAddress address) { super(StatefulSessionBeanCacheProviderResourceDefinition.Capability.CACHE_FACTORY, address); } @Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceName name = this.getServiceName(); ServiceBuilder<?> builder = target.addService(name); Consumer<StatefulSessionBeanCacheProvider<SessionID, StatefulSessionComponentInstance>> provider = builder.provides(name); Service service = new FunctionalService<>(provider, Function.identity(), this); return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND); } }
3,206
47.590909
241
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StaticInterceptorsDependenciesDeploymentUnitProcessor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.Collection; import java.util.HashSet; import org.jboss.as.ejb3.interceptor.server.ServerInterceptorMetaData; import org.jboss.as.server.deployment.Attachments; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessingException; import org.jboss.as.server.deployment.DeploymentUnitProcessor; import org.jboss.as.server.deployment.module.ModuleDependency; import org.jboss.as.server.deployment.module.ModuleSpecification; import org.jboss.modules.Module; import org.jboss.modules.ModuleLoader; /** * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ public class StaticInterceptorsDependenciesDeploymentUnitProcessor implements DeploymentUnitProcessor { final Collection<String> interceptorModules = new HashSet<>(); public StaticInterceptorsDependenciesDeploymentUnitProcessor(final Collection<ServerInterceptorMetaData> serverInterceptors){ for(final ServerInterceptorMetaData si: serverInterceptors){ interceptorModules.add(si.getModule()); } } @Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); final ModuleSpecification deploymentModuleSpec = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); for(final String interceptorModule : interceptorModules) { deploymentModuleSpec.addSystemDependency(new ModuleDependency(moduleLoader, interceptorModule, false, false, true, false)); } } }
2,828
43.904762
135
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StatisticsEnabledWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.STATISTICS_ENABLED; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> * @author <a href="mailto:[email protected]">Richard Opalka</a> */ class StatisticsEnabledWriteHandler extends AbstractWriteAttributeHandler<Void> { static StatisticsEnabledWriteHandler INSTANCE = new StatisticsEnabledWriteHandler(); StatisticsEnabledWriteHandler(){ super(STATISTICS_ENABLED); } @Override protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue, final ModelNode currentValue, final HandbackHolder<Void> voidHandbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateToRuntime(context, model); return false; } @Override protected void revertUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode valueToRestore, final ModelNode valueToRevert, final Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateToRuntime(context, restored); } void updateToRuntime(final OperationContext context, final ModelNode model) throws OperationFailedException { final boolean statisticsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean(); EJBStatistics.getInstance().setEnabled(statisticsEnabled); } }
3,019
47.709677
271
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/DefaultStatefulBeanAccessTimeoutWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.ejb3.component.DefaultAccessTimeoutService; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceRegistry; /** * User: jpai */ class DefaultStatefulBeanAccessTimeoutWriteHandler extends AbstractWriteAttributeHandler<Void> { static final DefaultStatefulBeanAccessTimeoutWriteHandler INSTANCE = new DefaultStatefulBeanAccessTimeoutWriteHandler(); private DefaultStatefulBeanAccessTimeoutWriteHandler() { super(EJB3SubsystemRootResourceDefinition.DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT); } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> voidHandbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateOrCreateDefaultStatefulBeanAccessTimeoutService(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateOrCreateDefaultStatefulBeanAccessTimeoutService(context, restored); } void updateOrCreateDefaultStatefulBeanAccessTimeoutService(final OperationContext context, final ModelNode model) throws OperationFailedException { final long defaultAccessTimeout = EJB3SubsystemRootResourceDefinition.DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT.resolveModelAttribute(context, model).asLong(); final ServiceName serviceName = DefaultAccessTimeoutService.STATEFUL_SERVICE_NAME; final ServiceRegistry registry = context.getServiceRegistry(true); final ServiceController<?> sc = registry.getService(serviceName); if (sc != null) { final DefaultAccessTimeoutService defaultAccessTimeoutService = DefaultAccessTimeoutService.class.cast(sc.getValue()); defaultAccessTimeoutService.setDefaultAccessTimeout(defaultAccessTimeout); } else { // create and install the service final DefaultAccessTimeoutService defaultAccessTimeoutService = new DefaultAccessTimeoutService(defaultAccessTimeout); final ServiceController<?> newService = context.getServiceTarget().addService(serviceName, defaultAccessTimeoutService) .install(); } } }
4,009
51.077922
235
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Subsystem11Parser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.Collections; import java.util.EnumSet; import java.util.List; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLElementReader; import org.jboss.staxmapper.XMLExtendedStreamReader; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import static org.jboss.as.controller.parsing.ParseUtils.missingRequired; import static org.jboss.as.controller.parsing.ParseUtils.readStringAttributeElement; import static org.jboss.as.controller.parsing.ParseUtils.requireNoAttributes; import static org.jboss.as.controller.parsing.ParseUtils.requireNoContent; import static org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_DATA_STORE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.FILE_DATA_STORE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.INSTANCE_ACQUISITION_TIMEOUT; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.INSTANCE_ACQUISITION_TIMEOUT_UNIT; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.MAX_POOL_SIZE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.PATH; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.RELATIVE_TO; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.SERVICE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.STRICT_MAX_BEAN_INSTANCE_POOL; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.TIMER_SERVICE; /** * User: Jaikiran Pai */ public class EJB3Subsystem11Parser implements XMLElementReader<List<ModelNode>> { EJB3Subsystem11Parser() { } /** * {@inheritDoc} */ @Override public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { final ModelNode ejb3SubsystemAddOperation = new ModelNode(); ejb3SubsystemAddOperation.get(OP).set(ADD); ejb3SubsystemAddOperation.get(OP_ADDR).add(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME); operations.add(ejb3SubsystemAddOperation); // elements final EnumSet<EJB3SubsystemXMLElement> encountered = EnumSet.noneOf(EJB3SubsystemXMLElement.class); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemNamespace.forUri(reader.getNamespaceURI())) { case EJB3_1_1: { final EJB3SubsystemXMLElement element = EJB3SubsystemXMLElement.forName(reader.getLocalName()); if (!encountered.add(element)) { throw unexpectedElement(reader); } switch (element) { case MDB: { // read <mdb> this.parseMDB(reader, operations, ejb3SubsystemAddOperation); break; } case POOLS: { // read <pools> this.parsePools(reader, operations); break; } case SESSION_BEAN: { // read <session-bean> this.parseSessionBean(reader, operations, ejb3SubsystemAddOperation); break; } case TIMER_SERVICE: { parseTimerService(reader, operations); break; } default: { throw unexpectedElement(reader); } } break; } default: { throw unexpectedElement(reader); } } } } private ModelNode parseMDB(final XMLExtendedStreamReader reader, List<ModelNode> operations, ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { ModelNode mdbModelNode = new ModelNode(); // no attributes expected requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case BEAN_INSTANCE_POOL_REF: { final String poolName = readStringAttributeElement(reader, EJB3SubsystemXMLAttribute.POOL_NAME.getLocalName()); EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_INSTANCE_POOL.parseAndSetParameter(poolName, ejb3SubsystemAddOperation, reader); break; } case RESOURCE_ADAPTER_REF: { final String resourceAdapterName = readStringAttributeElement(reader, EJB3SubsystemXMLAttribute.RESOURCE_ADAPTER_NAME.getLocalName()); EJB3SubsystemRootResourceDefinition.DEFAULT_RESOURCE_ADAPTER_NAME.parseAndSetParameter(resourceAdapterName, ejb3SubsystemAddOperation, reader); break; } default: { throw unexpectedElement(reader); } } } // if the resource-adapter-ref *hasn't* been explicitly specified, then default it to hornetq-ra if (!ejb3SubsystemAddOperation.hasDefined(EJB3SubsystemModel.DEFAULT_RESOURCE_ADAPTER_NAME)) { final ModelNode defaultRAName = EJB3SubsystemRootResourceDefinition.DEFAULT_RESOURCE_ADAPTER_NAME.getDefaultValue(); if (defaultRAName != null) { ejb3SubsystemAddOperation.get(EJB3SubsystemModel.DEFAULT_RESOURCE_ADAPTER_NAME).set(defaultRAName); } } return mdbModelNode; } private void parseSessionBean(final XMLExtendedStreamReader reader, final List<ModelNode> operations, ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { // no attributes expected requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case STATELESS: { this.parseStatelessBean(reader, operations, ejb3SubsystemAddOperation); break; } default: { throw unexpectedElement(reader); } } } } private void parseStatelessBean(final XMLExtendedStreamReader reader, final List<ModelNode> operations, ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { // no attributes expected requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case BEAN_INSTANCE_POOL_REF: { final String poolName = readStringAttributeElement(reader, EJB3SubsystemXMLAttribute.POOL_NAME.getLocalName()); EJB3SubsystemRootResourceDefinition.DEFAULT_SLSB_INSTANCE_POOL.parseAndSetParameter(poolName, ejb3SubsystemAddOperation, reader); break; } default: { throw unexpectedElement(reader); } } } } private void parsePools(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { // no attributes expected requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case BEAN_INSTANCE_POOLS: { this.parseBeanInstancePools(reader, operations); break; } default: { throw unexpectedElement(reader); } } } } private void parseBeanInstancePools(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { // no attributes expected requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case STRICT_MAX_POOL: { this.parseStrictMaxPool(reader, operations); break; } default: { throw unexpectedElement(reader); } } } } protected void parseStrictMaxPool(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { final int count = reader.getAttributeCount(); String poolName = null; Integer maxPoolSize = null; Long timeout = null; String unit = null; for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: poolName = value; break; case MAX_POOL_SIZE: maxPoolSize = parse(StrictMaxPoolResourceDefinition.MAX_POOL_SIZE, value, reader).asInt(); break; case INSTANCE_ACQUISITION_TIMEOUT: timeout = parse(StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT, value, reader).asLong(); break; case INSTANCE_ACQUISITION_TIMEOUT_UNIT: unit = parse(StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT, value, reader).asString(); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (poolName == null) { throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.NAME.getLocalName())); } // create and add the operation operations.add(this.createAddStrictMaxBeanInstancePoolOperation(poolName, maxPoolSize, timeout, unit)); } private void parseTimerService(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { requireNoAttributes(reader); final ModelNode address = new ModelNode(); address.add(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME); address.add(SERVICE, TIMER_SERVICE); final ModelNode timerServiceAdd = new ModelNode(); timerServiceAdd.get(OP).set(ADD); timerServiceAdd.get(OP_ADDR).set(address); String dataStorePath = null; String dataStorePathRelativeTo = null; while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case THREAD_POOL: { final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case CORE_THREADS: //ignore, no longer supported break; case MAX_THREADS: //ignore, no longer supported break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); break; } case DATA_STORE: { final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case PATH: if (dataStorePath != null) { throw unexpectedAttribute(reader, i); } dataStorePath = parse(FileDataStoreResourceDefinition.PATH, value, reader).asString(); break; case RELATIVE_TO: if (dataStorePathRelativeTo != null) { throw unexpectedAttribute(reader, i); } dataStorePathRelativeTo = parse(FileDataStoreResourceDefinition.RELATIVE_TO, value, reader).asString(); break; default: throw unexpectedAttribute(reader, i); } } if (dataStorePath == null) { throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.PATH)); } timerServiceAdd.get(DEFAULT_DATA_STORE).set("default-file-store"); final ModelNode fileDataStoreAdd = new ModelNode(); final ModelNode fileDataAddress = address.clone(); fileDataAddress.add(FILE_DATA_STORE, "default-file-store"); fileDataStoreAdd.get(OP).set(ADD); fileDataStoreAdd.get(OP_ADDR).set(fileDataAddress); fileDataStoreAdd.get(PATH).set(dataStorePath); if (dataStorePathRelativeTo != null) { fileDataStoreAdd.get(RELATIVE_TO).set(dataStorePathRelativeTo); } requireNoContent(reader); break; } default: { throw unexpectedElement(reader); } } } operations.add(timerServiceAdd); } private ModelNode createAddStrictMaxBeanInstancePoolOperation(final String name, final Integer maxPoolSize, final Long timeout, final String timeoutUnit) { // create /subsystem=ejb3/strict-max-bean-instance-pool=name:add(...) final ModelNode addStrictMaxPoolOperation = new ModelNode(); addStrictMaxPoolOperation.get(OP).set(ADD); // set the address for this operation final PathAddress address = this.getEJB3SubsystemAddress().append(PathElement.pathElement(STRICT_MAX_BEAN_INSTANCE_POOL, name)); addStrictMaxPoolOperation.get(OP_ADDR).set(address.toModelNode()); // set the params for the operation if (maxPoolSize != null) { addStrictMaxPoolOperation.get(MAX_POOL_SIZE).set(maxPoolSize); } if (timeout != null) { addStrictMaxPoolOperation.get(INSTANCE_ACQUISITION_TIMEOUT).set(timeout); } if (timeoutUnit != null) { addStrictMaxPoolOperation.get(INSTANCE_ACQUISITION_TIMEOUT_UNIT).set(timeoutUnit); } return addStrictMaxPoolOperation; } private PathAddress getEJB3SubsystemAddress() { return EJB3Subsystem12Parser.SUBSYSTEM_PATH; } private static ModelNode parse(AttributeDefinition ad, String value, XMLStreamReader reader) throws XMLStreamException { return ad.getParser().parse(ad, value, reader); } }
17,811
46.753351
172
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/DefaultStatefulBeanSessionTimeoutWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.concurrent.atomic.AtomicLong; import org.jboss.as.controller.AbstractWriteAttributeHandler; 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.ServiceController; import org.jboss.msc.service.ServiceName; public class DefaultStatefulBeanSessionTimeoutWriteHandler extends AbstractWriteAttributeHandler<Void> { public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "defaultStatefulSessionTimeout"); static final DefaultStatefulBeanSessionTimeoutWriteHandler INSTANCE = new DefaultStatefulBeanSessionTimeoutWriteHandler(); static final AtomicLong INITIAL_TIMEOUT_VALUE = new AtomicLong(-1); private DefaultStatefulBeanSessionTimeoutWriteHandler() { super(EJB3SubsystemRootResourceDefinition.DEFAULT_STATEFUL_BEAN_SESSION_TIMEOUT); } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> voidHandbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateOrCreateDefaultStatefulBeanSessionTimeoutService(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateOrCreateDefaultStatefulBeanSessionTimeoutService(context, restored); } void updateOrCreateDefaultStatefulBeanSessionTimeoutService(final OperationContext context, final ModelNode model) throws OperationFailedException { final long defaultSessionTimeout = EJB3SubsystemRootResourceDefinition.DEFAULT_STATEFUL_BEAN_SESSION_TIMEOUT.resolveModelAttribute(context, model).asLong(); final ServiceController<?> sc = context.getServiceRegistry(true).getRequiredService(SERVICE_NAME); final AtomicLong existingValue = (AtomicLong) sc.getValue(); existingValue.set(defaultSessionTimeout); } }
3,505
52.121212
235
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StrictMaxPoolResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService.Derive; import java.util.EnumSet; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.ServiceRemoveStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.operations.validation.EnumValidator; import org.jboss.as.controller.operations.validation.IntRangeValidator; import org.jboss.as.controller.operations.validation.LongRangeValidator; import org.jboss.as.controller.operations.validation.TimeUnitValidator; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; import org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService; import org.jboss.as.ejb3.component.pool.StrictMaxPoolConfig; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * {@link org.jboss.as.controller.ResourceDefinition} for the strict-max-bean-pool resource. * * @author Brian Stansberry (c) 2011 Red Hat Inc. */ public class StrictMaxPoolResourceDefinition extends SimpleResourceDefinition { public static final String STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME = "org.wildfly.ejb3.pool-config"; public static final RuntimeCapability<Void> STRICT_MAX_POOL_CONFIG_CAPABILITY = RuntimeCapability.Builder.of(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, true, StrictMaxPoolConfigService.class).build(); public static final SimpleAttributeDefinition MAX_POOL_SIZE = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.MAX_POOL_SIZE, ModelType.INT, true) .setDefaultValue(new ModelNode().set(StrictMaxPoolConfig.DEFAULT_MAX_POOL_SIZE)) .setAllowExpression(true) .setValidator(new IntRangeValidator(1, Integer.MAX_VALUE, true, true)) .setAlternatives(EJB3SubsystemModel.DERIVE_SIZE) .setFlags(AttributeAccess.Flag.RESTART_NONE) .build(); public static final SimpleAttributeDefinition DERIVE_SIZE = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.DERIVE_SIZE, ModelType.STRING, true) .setAllowExpression(true) // DeriveSize.NONE is no longer legal but if presented we will correct to undefined .setValidator(EnumValidator.create(DeriveSize.class, DeriveSize.LEGAL_VALUES)) .setCorrector(((newValue, currentValue) -> (newValue.getType() == ModelType.STRING && DeriveSize.NONE.toString().equalsIgnoreCase(newValue.asString())) ? new ModelNode() : newValue)) .setAlternatives(EJB3SubsystemModel.MAX_POOL_SIZE) .setFlags(AttributeAccess.Flag.RESTART_NONE) .build(); public static final SimpleAttributeDefinition INSTANCE_ACQUISITION_TIMEOUT = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.INSTANCE_ACQUISITION_TIMEOUT, ModelType.LONG, true) .setXmlName(EJB3SubsystemXMLAttribute.INSTANCE_ACQUISITION_TIMEOUT.getLocalName()) .setDefaultValue(new ModelNode().set(StrictMaxPoolConfig.DEFAULT_TIMEOUT)) .setAllowExpression(true) .setValidator(new LongRangeValidator(1, Integer.MAX_VALUE, true, true)) .setFlags(AttributeAccess.Flag.RESTART_NONE) .build(); public static final SimpleAttributeDefinition INSTANCE_ACQUISITION_TIMEOUT_UNIT = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.INSTANCE_ACQUISITION_TIMEOUT_UNIT, ModelType.STRING, true) .setXmlName(EJB3SubsystemXMLAttribute.INSTANCE_ACQUISITION_TIMEOUT_UNIT.getLocalName()) .setValidator(new TimeUnitValidator(true,true)) .setDefaultValue(new ModelNode().set(StrictMaxPoolConfig.DEFAULT_TIMEOUT_UNIT.name())) .setFlags(AttributeAccess.Flag.RESTART_NONE) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition DERIVED_SIZE = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.DERIVED_SIZE, ModelType.INT, true) .setFlags(AttributeAccess.Flag.STORAGE_RUNTIME) .build(); private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { MAX_POOL_SIZE, DERIVE_SIZE, INSTANCE_ACQUISITION_TIMEOUT, INSTANCE_ACQUISITION_TIMEOUT_UNIT }; private static final StrictMaxPoolAdd ADD_HANDLER = new StrictMaxPoolAdd(ATTRIBUTES); private static final String NONE_VALUE = "none"; private static final String FROM_WORKER_POOLS_VALUE = "from-worker-pools"; private static final String FROM_CPU_COUNT_VALUE = "from-cpu-count"; enum DeriveSize { NONE(NONE_VALUE), FROM_WORKER_POOLS(FROM_WORKER_POOLS_VALUE), FROM_CPU_COUNT(FROM_CPU_COUNT_VALUE); // All values but NONE are 'legal' for use, although we provide a corrector to allow NONE as well // I use this convoluted mechanism to name these to make this more robust in case other values get added private static EnumSet<DeriveSize> LEGAL_VALUES = EnumSet.complementOf(EnumSet.of(NONE)); private String value; DeriveSize(String value) { this.value = value; } public String toString() { return value; } public static DeriveSize fromValue(String value) { switch (value) { case NONE_VALUE: return NONE; case FROM_WORKER_POOLS_VALUE: return FROM_WORKER_POOLS; case FROM_CPU_COUNT_VALUE: return FROM_CPU_COUNT; default: return valueOf(value); } } } static Derive parseDeriveSize(OperationContext context, ModelNode strictMaxPoolModel) throws OperationFailedException { ModelNode dsNode = StrictMaxPoolResourceDefinition.DERIVE_SIZE.resolveModelAttribute(context, strictMaxPoolModel); if (dsNode.isDefined()) { DeriveSize deriveSize = DeriveSize.fromValue(dsNode.asString()); switch (deriveSize) { case FROM_WORKER_POOLS: return Derive.FROM_WORKER_POOLS; case FROM_CPU_COUNT: return Derive.FROM_CPU_COUNT; } } return Derive.NONE; } StrictMaxPoolResourceDefinition() { super(new Parameters(EJB3SubsystemModel.STRICT_MAX_BEAN_INSTANCE_POOL_PATH, EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.STRICT_MAX_BEAN_INSTANCE_POOL)) .setAddHandler(ADD_HANDLER) .setRemoveHandler(new ServiceRemoveStepHandler(null, ADD_HANDLER)) .setAddRestartLevel(OperationEntry.Flag.RESTART_NONE) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) .setCapabilities(STRICT_MAX_POOL_CONFIG_CAPABILITY)); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { OperationStepHandler osh = new StrictMaxPoolWriteHandler(ATTRIBUTES); for (AttributeDefinition attr : ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(attr, null, osh); } resourceRegistration.registerReadOnlyAttribute(DERIVED_SIZE, new StrictMaxPoolDerivedSizeReadHandler()); } }
8,996
52.236686
182
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Subsystem60Parser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2020, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.controller.parsing.ParseUtils.requireNoAttributes; import static org.jboss.as.controller.parsing.ParseUtils.requireNoContent; import static org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.CLASS; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.CLIENT_INTERCEPTORS; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.MODULE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.SERVER_INTERCEPTORS; import java.util.List; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; /** * Parser for ejb3:6.0 namespace. * * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ public class EJB3Subsystem60Parser extends EJB3Subsystem50Parser { EJB3Subsystem60Parser() { } @Override protected EJB3SubsystemNamespace getExpectedNamespace() { return EJB3SubsystemNamespace.EJB3_6_0; } @Override protected void readElement(final XMLExtendedStreamReader reader, final EJB3SubsystemXMLElement element, final List<ModelNode> operations, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { switch (element) { case SERVER_INTERCEPTORS: { parseServerInterceptors(reader, ejb3SubsystemAddOperation); break; } case CLIENT_INTERCEPTORS: { parseClientInterceptors(reader, ejb3SubsystemAddOperation); break; } default: { super.readElement(reader, element, operations, ejb3SubsystemAddOperation); } } } protected void parseServerInterceptors(final XMLExtendedStreamReader reader, final ModelNode ejbSubsystemAddOperation) throws XMLStreamException { final ModelNode interceptors = new ModelNode(); requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case INTERCEPTOR: { parseInterceptor(reader, interceptors); break; } default: { throw unexpectedElement(reader); } } } ejbSubsystemAddOperation.get(SERVER_INTERCEPTORS).set(interceptors); } protected void parseClientInterceptors(final XMLExtendedStreamReader reader, final ModelNode ejbSubsystemAddOperation) throws XMLStreamException { final ModelNode interceptors = new ModelNode(); requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case INTERCEPTOR: { parseInterceptor(reader, interceptors); break; } default: { throw unexpectedElement(reader); } } } ejbSubsystemAddOperation.get(CLIENT_INTERCEPTORS).set(interceptors); } protected void parseInterceptor(final XMLExtendedStreamReader reader, final ModelNode interceptors) throws XMLStreamException { final ModelNode interceptor = new ModelNode(); for (int i = 0; i < reader.getAttributeCount(); i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); switch (EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i))) { case MODULE: { interceptor.get(MODULE).set(value); break; } case CLASS: { interceptor.get(CLASS).set(value); break; } default: { throw unexpectedAttribute(reader, i); } } } requireNoContent(reader); interceptors.add(interceptor); } }
5,454
38.817518
212
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/ServerInterceptorsBindingsProcessor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.ee.component.Attachments; import org.jboss.as.ee.component.ComponentDescription; import org.jboss.as.ee.component.EEModuleDescription; import org.jboss.as.ejb3.component.EJBComponentDescription; import org.jboss.as.ejb3.interceptor.server.ServerInterceptorCache; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessingException; import org.jboss.as.server.deployment.DeploymentUnitProcessor; /** * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ public class ServerInterceptorsBindingsProcessor implements DeploymentUnitProcessor { private final ServerInterceptorCache serverInterceptorCache; public ServerInterceptorsBindingsProcessor(final ServerInterceptorCache serverInterceptorCache){ this.serverInterceptorCache = serverInterceptorCache; } @Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); for (final ComponentDescription componentDescription : eeModuleDescription.getComponentDescriptions()) { if (!(componentDescription instanceof EJBComponentDescription)) { continue; } final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) componentDescription; ejbComponentDescription.setServerInterceptorCache(serverInterceptorCache); } } }
2,771
46.793103
120
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/FilePassivationStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.io.File; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.operations.validation.IntRangeValidator; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.OperationEntry; import org.jboss.as.server.ServerEnvironment; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * @author Paul Ferraro */ @Deprecated public class FilePassivationStoreResourceDefinition extends LegacyPassivationStoreResourceDefinition { // this actually has a dependency on a cache factory using default cache container and cache name "passivation" // but no attributes to set requirements for !? @Deprecated public static final SimpleAttributeDefinition MAX_SIZE = MAX_SIZE_BUILDER.build(); @Deprecated public static final SimpleAttributeDefinition RELATIVE_TO = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.RELATIVE_TO, ModelType.STRING, true) .setXmlName(EJB3SubsystemXMLAttribute.RELATIVE_TO.getLocalName()) .setDefaultValue(new ModelNode().set(ServerEnvironment.SERVER_DATA_DIR)) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_NONE) .setDeprecated(DEPRECATED_VERSION) .build() ; @Deprecated public static final SimpleAttributeDefinition GROUPS_PATH = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.GROUPS_PATH, ModelType.STRING, true) .setXmlName(EJB3SubsystemXMLAttribute.GROUPS_PATH.getLocalName()) .setDefaultValue(new ModelNode().set("ejb3" + File.separatorChar + "groups")) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_NONE) .setDeprecated(DEPRECATED_VERSION) .build() ; @Deprecated public static final SimpleAttributeDefinition SESSIONS_PATH = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.SESSIONS_PATH, ModelType.STRING, true) .setXmlName(EJB3SubsystemXMLAttribute.SESSIONS_PATH.getLocalName()) .setDefaultValue(new ModelNode().set("ejb3" + File.separatorChar + "sessions")) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_NONE) .setDeprecated(DEPRECATED_VERSION) .build() ; @Deprecated public static final SimpleAttributeDefinition SUBDIRECTORY_COUNT = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.SUBDIRECTORY_COUNT, ModelType.LONG, true) .setXmlName(EJB3SubsystemXMLAttribute.SUBDIRECTORY_COUNT.getLocalName()) .setDefaultValue(new ModelNode().set(100)) .setAllowExpression(true) .setValidator(new IntRangeValidator(1, Integer.MAX_VALUE, true, true)) .setFlags(AttributeAccess.Flag.RESTART_NONE) .setDeprecated(DEPRECATED_VERSION) .build() ; private static final AttributeDefinition[] ATTRIBUTES = { IDLE_TIMEOUT, IDLE_TIMEOUT_UNIT, MAX_SIZE, RELATIVE_TO, GROUPS_PATH, SESSIONS_PATH, SUBDIRECTORY_COUNT }; private static final FilePassivationStoreAdd ADD = new FilePassivationStoreAdd(ATTRIBUTES); private static final PassivationStoreRemove REMOVE = new PassivationStoreRemove(ADD); FilePassivationStoreResourceDefinition() { super(EJB3SubsystemModel.FILE_PASSIVATION_STORE, ADD, REMOVE, OperationEntry.Flag.RESTART_NONE, OperationEntry.Flag.RESTART_RESOURCE_SERVICES, ATTRIBUTES); } }
4,662
47.572917
168
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJBTransformers.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.ejb3.subsystem.EJB3Model.VERSION_9_0_0; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.transform.ExtensionTransformerRegistration; import org.jboss.as.controller.transform.SubsystemTransformerRegistration; import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder; import org.kohsuke.MetaInfServices; /** * Jakarta Enterprise Beans Transformers used to transform current model version to legacy model versions for domain mode. * * @author Tomaz Cerar (c) 2017 Red Hat Inc. * @author Richard Achmatowicz (c) 2020 Red Hat Inc. */ @MetaInfServices(ExtensionTransformerRegistration.class) public class EJBTransformers implements ExtensionTransformerRegistration { @Override public String getSubsystemName() { return EJB3Extension.SUBSYSTEM_NAME; } @Override public void registerTransformers(SubsystemTransformerRegistration subsystemRegistration) { ModelVersion currentModel = subsystemRegistration.getCurrentSubsystemVersion(); ChainedTransformationDescriptionBuilder chainedBuilder = TransformationDescriptionBuilder.Factory.createChainedSubystemInstance(currentModel); // register the transformations required for each legacy version after 9.0.0 registerTransformers_9_0_0(chainedBuilder.createBuilder(currentModel, VERSION_9_0_0.getVersion())); // create the chained builder which incorporates all transformations chainedBuilder.buildAndRegister(subsystemRegistration, new ModelVersion[] { VERSION_9_0_0.getVersion() }); } /* * Transformers for changes in model version 10.0.0 */ private static void registerTransformers_9_0_0(ResourceTransformationDescriptionBuilder subsystemBuilder) { // Reject ejb3/caches/simple-cache element subsystemBuilder.rejectChildResource(EJB3SubsystemModel.SIMPLE_CACHE_PATH); // Reject ejb3/caches/distributable-cache element subsystemBuilder.rejectChildResource(EJB3SubsystemModel.DISTRIBUTABLE_CACHE_PATH); subsystemBuilder.addChildResource(EJB3SubsystemModel.TIMER_SERVICE_PATH).getAttributeBuilder() .setDiscard(DiscardAttributeChecker.UNDEFINED, TimerServiceResourceDefinition.DEFAULT_PERSISTENT_TIMER_MANAGEMENT, TimerServiceResourceDefinition.DEFAULT_TRANSIENT_TIMER_MANAGEMENT) .addRejectCheck(RejectAttributeChecker.DEFINED, TimerServiceResourceDefinition.DEFAULT_PERSISTENT_TIMER_MANAGEMENT, TimerServiceResourceDefinition.DEFAULT_TRANSIENT_TIMER_MANAGEMENT) .addRejectCheck(RejectAttributeChecker.UNDEFINED, TimerServiceResourceDefinition.THREAD_POOL_NAME, TimerServiceResourceDefinition.DEFAULT_DATA_STORE) .end(); } }
4,188
50.716049
198
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJBDefaultMissingMethodPermissionsWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.concurrent.atomic.AtomicBoolean; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; /** * Write handler for the default missing method permission attribute * * @author Stuart Douglas */ class EJBDefaultMissingMethodPermissionsWriteHandler extends AbstractWriteAttributeHandler<Void> { private final AttributeDefinition attributeDefinition; private final AtomicBoolean denyAccessByDefault; EJBDefaultMissingMethodPermissionsWriteHandler(final AttributeDefinition attributeDefinition, final AtomicBoolean denyAccessByDefault) { super(attributeDefinition); this.attributeDefinition = attributeDefinition; this.denyAccessByDefault = denyAccessByDefault; } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateDefaultMethodPermissionsDenyAccess(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateDefaultMethodPermissionsDenyAccess(context, restored); } private void updateDefaultMethodPermissionsDenyAccess(final OperationContext context, final ModelNode model) throws OperationFailedException { final ModelNode modelNode = this.attributeDefinition.resolveModelAttribute(context, model); final boolean value = modelNode.asBoolean(); this.denyAccessByDefault.set(value); } }
3,358
43.786667
162
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StaticEJBDiscoveryDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, 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 * 2110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.ArrayList; import java.util.List; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.AttributeMarshaller; import org.jboss.as.controller.ObjectListAttributeDefinition; import org.jboss.as.controller.ObjectTypeAttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * {@link AttributeDefinition} implementation for the "static-ejb-discovery" attribute. * * @author Stuart Douglas */ public class StaticEJBDiscoveryDefinition { public static final String APP = "app-name"; public static final String MODULE = "module-name"; public static final String DISTINCT = "distinct-name"; public static final String URI = "uri"; public static final String STATIC_EJB_DISCOVERY = "static-ejb-discovery"; public static final SimpleAttributeDefinition APP_AD = new SimpleAttributeDefinitionBuilder(APP, ModelType.STRING, true) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition MODULE_AD = new SimpleAttributeDefinitionBuilder(MODULE, ModelType.STRING, false) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition DISTINCT_AD = new SimpleAttributeDefinitionBuilder(DISTINCT, ModelType.STRING, true) .setAllowExpression(true) .build(); public static final SimpleAttributeDefinition URI_AD = new SimpleAttributeDefinitionBuilder(URI, ModelType.STRING, false) .setAllowExpression(true) .build(); private static final SimpleAttributeDefinition[] VALUE_TYPE_FIELDS = {URI_AD, APP_AD, MODULE_AD, DISTINCT_AD}; // TODO the default marshalling in ObjectListAttributeDefinition is not so great since it delegates each // element to ObjectTypeAttributeDefinition, and OTAD assumes it's used for complex attributes bound in a // ModelType.OBJECT node under key=OTAD.getName(). So provide a custom marshaller to OTAD. This could be made reusable. private static final AttributeMarshaller VALUE_TYPE_MARSHALLER = new AttributeMarshaller() { @Override public void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException { if (resourceModel.isDefined()) { writer.writeEmptyElement(EJB3SubsystemXMLElement.MODULE.getLocalName()); for (SimpleAttributeDefinition valueType : VALUE_TYPE_FIELDS) { valueType.getMarshaller().marshall(valueType, resourceModel, true, writer); } } } }; private static final ObjectTypeAttributeDefinition VALUE_TYPE_AD = ObjectTypeAttributeDefinition.Builder.of(ModelDescriptionConstants.MODULE, VALUE_TYPE_FIELDS) .setAttributeMarshaller(VALUE_TYPE_MARSHALLER) .build(); public static final AttributeDefinition INSTANCE = ObjectListAttributeDefinition.Builder.of(STATIC_EJB_DISCOVERY, VALUE_TYPE_AD) .setRequired(false) .build(); public static List<StaticEjbDiscovery> createStaticEjbList(final OperationContext context, final ModelNode ejbList) throws OperationFailedException { final List<StaticEjbDiscovery> ret = new ArrayList<>(); if (ejbList.isDefined()) { for (final ModelNode disc : ejbList.asList()) { ModelNode app = APP_AD.resolveModelAttribute(context, disc); String module = MODULE_AD.resolveModelAttribute(context, disc).asString(); ModelNode distinct = DISTINCT_AD.resolveModelAttribute(context, disc); String url = URI_AD.resolveModelAttribute(context, disc).asString(); ret.add(new StaticEjbDiscovery(app.isDefined() ? app.asString() : null, module, distinct.isDefined() ? distinct.asString() : null, url)); } } return ret; } public static final class StaticEjbDiscovery { private final String app; private final String module; private final String distinct; private final String url; public StaticEjbDiscovery(String app, String module, String distinct, String url) { this.app = app; this.module = module; this.distinct = distinct; this.url = url; } public String getApp() { return app; } public String getModule() { return module; } public String getDistinct() { return distinct; } public String getUrl() { return url; } } }
6,150
42.316901
170
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/RemoteConnectorChannelCreationOptionResource.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.RestartParentResourceAddHandler; import org.jboss.as.controller.RestartParentResourceRemoveHandler; import org.jboss.as.controller.RestartParentWriteAttributeHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.ejb3.remote.EJBRemoteConnectorService; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jboss.msc.service.ServiceName; /** * {@link SimpleResourceDefinition} for the channel creation option(s) that are configured for the EJB remote * channel * * @author Jaikiran Pai */ class RemoteConnectorChannelCreationOptionResource extends SimpleResourceDefinition { static final RemoteConnectorChannelCreationOptionResource INSTANCE = new RemoteConnectorChannelCreationOptionResource(); /** * Attribute definition of the channel creation option "value" */ static final SimpleAttributeDefinition CHANNEL_CREATION_OPTION_VALUE = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.VALUE, ModelType.STRING, true) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); /** * Attribute definition of the channel creation option "type" */ static final SimpleAttributeDefinition CHANNEL_CREATION_OPTION_TYPE = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.TYPE, ModelType.STRING, true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES).setValidator(AllowedChannelOptionTypesValidator.INSTANCE).build(); RemoteConnectorChannelCreationOptionResource() { super(PathElement.pathElement(EJB3SubsystemModel.CHANNEL_CREATION_OPTIONS), EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.CHANNEL_CREATION_OPTIONS), new ChannelCreationOptionAdd(), new ChannelCreationOptionRemove()); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { resourceRegistration.registerReadWriteAttribute(CHANNEL_CREATION_OPTION_VALUE, null, new ChannelCreationOptionWriteAttributeHandler(CHANNEL_CREATION_OPTION_VALUE)); resourceRegistration.registerReadWriteAttribute(CHANNEL_CREATION_OPTION_TYPE, null, new ChannelCreationOptionWriteAttributeHandler(CHANNEL_CREATION_OPTION_TYPE)); } private static void recreateParentService(OperationContext context, ModelNode ejb3RemoteServiceModelNode) throws OperationFailedException { EJB3RemoteResourceDefinition.ADD_HANDLER.installRuntimeServices(context, ejb3RemoteServiceModelNode); } /** * A write handler for the "value" attribute of the channel creation option */ private static class ChannelCreationOptionWriteAttributeHandler extends RestartParentWriteAttributeHandler { ChannelCreationOptionWriteAttributeHandler(final AttributeDefinition attributeDefinition) { super(EJB3SubsystemModel.SERVICE, attributeDefinition); } @Override protected void recreateParentService(OperationContext context, PathAddress parentAddress, ModelNode parentModel) throws OperationFailedException { RemoteConnectorChannelCreationOptionResource.recreateParentService(context, parentModel); } @Override protected ServiceName getParentServiceName(PathAddress parentAddress) { return EJBRemoteConnectorService.SERVICE_NAME; } } /** * An add handler for channel creation option */ private static class ChannelCreationOptionAdd extends RestartParentResourceAddHandler { private ChannelCreationOptionAdd() { super(EJB3SubsystemModel.SERVICE); } protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE.validateAndSet(operation, model); RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_TYPE.validateAndSet(operation, model); } @Override protected void recreateParentService(OperationContext context, PathAddress parentAddress, ModelNode parentModel) throws OperationFailedException { RemoteConnectorChannelCreationOptionResource.recreateParentService(context, parentModel); } @Override protected PathAddress getParentAddress(PathAddress address) { for (int i = address.size() - 1; i >= 0; i--) { PathElement pe = address.getElement(i); if (pe.getKey().equals("service") && pe.getValue().equals("remote")) { return address.subAddress(0, i + 1); } } return null; } @Override protected ServiceName getParentServiceName(PathAddress parentAddress) { return EJBRemoteConnectorService.SERVICE_NAME; } } /** * Remove handler for channel creation option */ private static class ChannelCreationOptionRemove extends RestartParentResourceRemoveHandler { private ChannelCreationOptionRemove() { super(EJB3SubsystemModel.SERVICE); } @Override protected void recreateParentService(OperationContext context, PathAddress parentAddress, ModelNode ejb3RemoteServiceModelNode) throws OperationFailedException { RemoteConnectorChannelCreationOptionResource.recreateParentService(context, ejb3RemoteServiceModelNode); } @Override protected ServiceName getParentServiceName(PathAddress parentAddress) { return EJBRemoteConnectorService.SERVICE_NAME; } } }
7,283
44.525
172
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.function.Consumer; import org.jboss.as.controller.AbstractWriteAttributeHandler; 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.ServiceRegistry; /** * @author Stuart Douglas */ public class EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler extends AbstractWriteAttributeHandler<Void> { public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "entity-bean", "optimistic-locking"); public static final EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler INSTANCE = new EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler(); private EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler() { super(EJB3SubsystemRootResourceDefinition.DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING); } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateOptimisticLocking(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateOptimisticLocking(context, restored); } void updateOptimisticLocking(final OperationContext context, final ModelNode model) throws OperationFailedException { final ModelNode enabled = EJB3SubsystemRootResourceDefinition.DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING.resolveModelAttribute(context, model); final ServiceRegistry serviceRegistry = context.getServiceRegistry(true); ServiceController<?> existingService = serviceRegistry.getService(SERVICE_NAME); // if a default optimistic locking config is installed, remove it if (existingService != null) { context.removeService(existingService); } if (enabled.isDefined()) { final ServiceBuilder<?> sb = context.getServiceTarget().addService(SERVICE_NAME); final Consumer<Boolean> c = sb.provides(SERVICE_NAME); sb.setInstance(Service.newInstance(c, enabled.asBoolean())).install(); } } }
4,042
44.943182
162
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemRemove.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractRemoveStepHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.Resource; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.dmr.ModelNode; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_MDB_INSTANCE_POOL; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_SLSB_INSTANCE_POOL; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.DEFAULT_SLSB_POOL_CONFIG_CAPABILITY_NAME; import static org.jboss.as.ejb3.subsystem.StrictMaxPoolResourceDefinition.STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME; /** * Handler for removing the EJB3 subsystem. * * @author Brian Stansberry (c) 2011 Red Hat Inc. */ public class EJB3SubsystemRemove extends AbstractRemoveStepHandler { public static final EJB3SubsystemRemove INSTANCE = new EJB3SubsystemRemove(); private EJB3SubsystemRemove() { } /* * handle conditionally-defined capabilities for default bean instance pools */ @Override protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { ModelNode model = resource.getModel(); // de-register the capability we are exporting as well as its capability requirement on the strict-max-pool that supports it if (model.hasDefined(DEFAULT_SLSB_INSTANCE_POOL)) { context.deregisterCapability(DEFAULT_SLSB_POOL_CONFIG_CAPABILITY_NAME); try { // need to resolve the attribute value before using it String resolvedDefaultSLSBPoolName = context.resolveExpressions(model.get(DEFAULT_SLSB_INSTANCE_POOL)).asString(); String defaultSLSBPoolRequirementName = RuntimeCapability.buildDynamicCapabilityName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, resolvedDefaultSLSBPoolName); context.deregisterCapabilityRequirement(defaultSLSBPoolRequirementName, DEFAULT_SLSB_POOL_CONFIG_CAPABILITY_NAME, DEFAULT_SLSB_INSTANCE_POOL); } catch(OperationFailedException ofe) { EjbLogger.ROOT_LOGGER.defaultPoolExpressionCouldNotBeResolved(DEFAULT_SLSB_INSTANCE_POOL, model.get(DEFAULT_SLSB_INSTANCE_POOL).asString()); } } if (model.hasDefined(DEFAULT_MDB_INSTANCE_POOL)) { context.deregisterCapability(DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME); try { // need to resolve the attribute value before using it String resolvedDefaultMDBPoolName = context.resolveExpressions(model.get(DEFAULT_MDB_INSTANCE_POOL)).asString(); String defaultMDBPoolRequirementName = RuntimeCapability.buildDynamicCapabilityName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, resolvedDefaultMDBPoolName); context.deregisterCapabilityRequirement(defaultMDBPoolRequirementName, DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME, DEFAULT_MDB_INSTANCE_POOL); } catch(OperationFailedException ofe) { EjbLogger.ROOT_LOGGER.defaultPoolExpressionCouldNotBeResolved(DEFAULT_MDB_INSTANCE_POOL, model.get(DEFAULT_MDB_INSTANCE_POOL).asString()); } } super.recordCapabilitiesAndRequirements(context, operation, resource); } @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { // This subsystem registers DUPs, so we can't remove it from the runtime without a reload context.reloadRequired(); } @Override protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { context.revertReloadRequired(); } }
5,105
49.554455
170
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemXMLPersister.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.clustering.controller.Attribute; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.persistence.SubsystemMarshallingContext; import org.jboss.as.threads.ThreadsParser; import org.jboss.dmr.ModelNode; import org.jboss.dmr.Property; import org.jboss.staxmapper.XMLElementWriter; import org.jboss.staxmapper.XMLExtendedStreamWriter; import javax.xml.stream.XMLStreamException; import java.util.EnumSet; import java.util.List; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.ALLOW_EJB_NAME_REGEX; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.APPLICATION_SECURITY_DOMAIN; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.ASYNC; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.CHANNEL_CREATION_OPTIONS; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.CLIENT_INTERCEPTORS; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_DISTINCT_NAME; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_MISSING_METHOD_PERMISSIONS_DENY_ACCESS; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_SECURITY_DOMAIN; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_SFSB_CACHE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_STATEFUL_BEAN_SESSION_TIMEOUT; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DISABLE_DEFAULT_EJB_PERMISSIONS; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.ENABLE_GRACEFUL_TXN_SHUTDOWN; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.IDENTITY; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.IIOP; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.IN_VM_REMOTE_INTERFACE_INVOCATION_PASS_BY_VALUE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.LOG_SYSTEM_EXCEPTIONS; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.PROFILE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.REMOTE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.REMOTE_HTTP_CONNECTION; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.REMOTING_EJB_RECEIVER; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.REMOTING_PROFILE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.SERVER_INTERCEPTORS; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.SERVICE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.STATISTICS_ENABLED; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.THREAD_POOL; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.TIMER_SERVICE; /** * The {@link XMLElementWriter} that handles the EJB subsystem. As we only write out the most recent version of * a subsystem we only need to keep the latest version around. * * @author Stuart Douglas */ public class EJB3SubsystemXMLPersister implements XMLElementWriter<SubsystemMarshallingContext> { public static final EJB3SubsystemXMLPersister INSTANCE = new EJB3SubsystemXMLPersister(); /** * {@inheritDoc} */ @Override public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException { context.startSubsystemElement(EJB3SubsystemNamespace.EJB3_10_0.getUriString(), false); writeElements(writer, context); // write the subsystem end element writer.writeEndElement(); } protected void writeElements(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException { ModelNode model = context.getModelNode(); boolean sessionBeanStartWritten = false; // <stateless> element if (model.hasDefined(EJB3SubsystemModel.DEFAULT_SLSB_INSTANCE_POOL)) { sessionBeanStartWritten = writeSessionBeanStartElement(writer, sessionBeanStartWritten); // <stateless> writer.writeStartElement(EJB3SubsystemXMLElement.STATELESS.getLocalName()); // write out the <bean-instance-pool-ref> this.writeDefaultSLSBPool(writer, model); // </stateless> writer.writeEndElement(); } // <stateful> element if (model.hasDefined(EJB3SubsystemModel.DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT) || model.hasDefined(EJB3SubsystemModel.DEFAULT_SFSB_CACHE) || model.hasDefined(EJB3SubsystemModel.DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE)) { sessionBeanStartWritten = writeSessionBeanStartElement(writer, sessionBeanStartWritten); // <stateful> writer.writeStartElement(EJB3SubsystemXMLElement.STATEFUL.getLocalName()); // write out the <stateful> element contents this.writeStatefulBean(writer, model); // </stateful> writer.writeEndElement(); } // <singleton> element if (model.hasDefined(EJB3SubsystemModel.DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT)) { sessionBeanStartWritten = writeSessionBeanStartElement(writer, sessionBeanStartWritten); // <singleton> writer.writeStartElement(EJB3SubsystemXMLElement.SINGLETON.getLocalName()); // write out the <singleton> element contents this.writeSingletonBean(writer, model); // </singleton> writer.writeEndElement(); } // write out the </session-bean> end element if (sessionBeanStartWritten) { // </session-bean> writer.writeEndElement(); } // write the mdb element if (model.hasDefined(EJB3SubsystemModel.DEFAULT_MDB_INSTANCE_POOL) || model.hasDefined(EJB3SubsystemModel.DEFAULT_RESOURCE_ADAPTER_NAME) || model.hasDefined(EJB3SubsystemModel.MDB_DELIVERY_GROUP)) { // <mdb> writer.writeStartElement(EJB3SubsystemXMLElement.MDB.getLocalName()); // write out the mdb element contents this.writeMDB(writer, model); // </mdb> writer.writeEndElement(); } // write the entity bean element if (model.hasDefined(EJB3SubsystemModel.DEFAULT_ENTITY_BEAN_INSTANCE_POOL) || model.hasDefined(EJB3SubsystemModel.DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING)) { // <entity-bean> writer.writeStartElement(EJB3SubsystemXMLElement.ENTITY_BEAN.getLocalName()); // write out the mdb element contents this.writeEntityBean(writer, model); // </entity-bean> writer.writeEndElement(); } // write the pools element if (model.hasDefined(EJB3SubsystemModel.STRICT_MAX_BEAN_INSTANCE_POOL)) { // <pools> writer.writeStartElement(EJB3SubsystemXMLElement.POOLS.getLocalName()); // <bean-instance-pools> writer.writeStartElement(EJB3SubsystemXMLElement.BEAN_INSTANCE_POOLS.getLocalName()); // write the bean instance pools this.writeBeanInstancePools(writer, model); // </bean-instance-pools> writer.writeEndElement(); // </pools> writer.writeEndElement(); } // write the caches element if (model.hasDefined(EJB3SubsystemModel.CACHE) || model.hasDefined(EJB3SubsystemModel.SIMPLE_CACHE) || model.hasDefined(EJB3SubsystemModel.DISTRIBUTABLE_CACHE)) { // <caches> writer.writeStartElement(EJB3SubsystemXMLElement.CACHES.getLocalName()); // write the caches this.writeCaches(writer, model); this.writeSimpleCaches(writer, model); this.writeDistributableCaches(writer, model); // </caches> writer.writeEndElement(); } // write the passivation-stores element if (model.hasDefined(EJB3SubsystemModel.PASSIVATION_STORE) || model.hasDefined(EJB3SubsystemModel.CLUSTER_PASSIVATION_STORE) || model.hasDefined(EJB3SubsystemModel.FILE_PASSIVATION_STORE)) { // <passivation-stores> writer.writeStartElement(EJB3SubsystemXMLElement.PASSIVATION_STORES.getLocalName()); // write the stores this.writePassivationStores(writer, model); this.writeFilePassivationStores(writer, model); this.writeClusterPassivationStores(writer, model); // </passivation-stores> writer.writeEndElement(); } // write the async element if (model.hasDefined(SERVICE) && model.get(SERVICE).hasDefined(ASYNC)) { writer.writeStartElement(EJB3SubsystemXMLElement.ASYNC.getLocalName()); writeAsync(writer, model.get(SERVICE, ASYNC)); writer.writeEndElement(); } // timer-service if (model.hasDefined(SERVICE) && model.get(SERVICE).hasDefined(TIMER_SERVICE)) { // <timer-service> writer.writeStartElement(EJB3SubsystemXMLElement.TIMER_SERVICE.getLocalName()); final ModelNode timerServiceModel = model.get(SERVICE, TIMER_SERVICE); this.writeTimerService(writer, timerServiceModel); // </timer-service> writer.writeEndElement(); } // write the remote element if (model.hasDefined(SERVICE) && model.get(SERVICE).hasDefined(REMOTE)) { writer.writeStartElement(EJB3SubsystemXMLElement.REMOTE.getLocalName()); writeRemote(writer, model.get(SERVICE, REMOTE)); // profiles element if (model.hasDefined(REMOTING_PROFILE)) { writer.writeStartElement(EJB3SubsystemXMLElement.PROFILES.getLocalName()); writeProfiles(writer, model); writer.writeEndElement(); } writer.writeEndElement(); } // thread-pools if (model.hasDefined(THREAD_POOL)) { // <timer-service> writer.writeStartElement(EJB3SubsystemXMLElement.THREAD_POOLS.getLocalName()); final ModelNode threadsModel = model.get(THREAD_POOL); this.writeThreadPools(writer, threadsModel); // </timer-service> writer.writeEndElement(); } // iiop // write the remote element if (model.hasDefined(SERVICE) && model.get(SERVICE).hasDefined(IIOP)) { writer.writeStartElement(EJB3SubsystemXMLElement.IIOP.getLocalName()); writeIIOP(writer, model.get(SERVICE, IIOP)); writer.writeEndElement(); } // in-vm-remote-interface-invocation element if (model.hasDefined(IN_VM_REMOTE_INTERFACE_INVOCATION_PASS_BY_VALUE)) { writer.writeStartElement(EJB3SubsystemXMLElement.IN_VM_REMOTE_INTERFACE_INVOCATION.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.PASS_BY_VALUE.getLocalName(), model.get(EJB3SubsystemModel.IN_VM_REMOTE_INTERFACE_INVOCATION_PASS_BY_VALUE).asString()); writer.writeEndElement(); } // default-distinct-name element if (model.hasDefined(DEFAULT_DISTINCT_NAME)) { writer.writeStartElement(EJB3SubsystemXMLElement.DEFAULT_DISTINCT_NAME.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.VALUE.getLocalName(), model.get(EJB3SubsystemModel.DEFAULT_DISTINCT_NAME).asString()); writer.writeEndElement(); } if (model.hasDefined(DEFAULT_SECURITY_DOMAIN)) { // default-security-domain element writer.writeStartElement(EJB3SubsystemXMLElement.DEFAULT_SECURITY_DOMAIN.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.VALUE.getLocalName(), model.get(DEFAULT_SECURITY_DOMAIN).asString()); writer.writeEndElement(); } // application-security-domains element if (model.hasDefined(APPLICATION_SECURITY_DOMAIN)) { writer.writeStartElement(EJB3SubsystemXMLElement.APPLICATION_SECURITY_DOMAINS.getLocalName()); writeApplicationSecurityDomains(writer, model); writer.writeEndElement(); } // identity element if (model.hasDefined(SERVICE) && model.get(SERVICE).hasDefined(IDENTITY) && model.get(SERVICE, IDENTITY).hasDefined(IdentityResourceDefinition.OUTFLOW_SECURITY_DOMAINS.getName())) { writer.writeStartElement(EJB3SubsystemXMLElement.IDENTITY.getLocalName()); writeAttribute(writer, model.get(SERVICE, IDENTITY), IdentityResourceDefinition.OUTFLOW_SECURITY_DOMAINS, false); writer.writeEndElement(); } // default-missing-method-permissions-deny-access element if (model.hasDefined(DEFAULT_MISSING_METHOD_PERMISSIONS_DENY_ACCESS)) { writer.writeStartElement(EJB3SubsystemXMLElement.DEFAULT_MISSING_METHOD_PERMISSIONS_DENY_ACCESS.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.VALUE.getLocalName(), model.get(DEFAULT_MISSING_METHOD_PERMISSIONS_DENY_ACCESS).asString()); writer.writeEndElement(); } // disable-default-ejb-permissions element if (model.hasDefined(DISABLE_DEFAULT_EJB_PERMISSIONS)) { writer.writeStartElement(EJB3SubsystemXMLElement.DISABLE_DEFAULT_EJB_PERMISSIONS.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.VALUE.getLocalName(), model.get(DISABLE_DEFAULT_EJB_PERMISSIONS).asString()); writer.writeEndElement(); } // graceful txn shutdown if (model.hasDefined(ENABLE_GRACEFUL_TXN_SHUTDOWN)) { writer.writeStartElement(EJB3SubsystemXMLElement.ENABLE_GRACEFUL_TXN_SHUTDOWN.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.VALUE.getLocalName(), model.get(EJB3SubsystemModel.ENABLE_GRACEFUL_TXN_SHUTDOWN).asString()); writer.writeEndElement(); } // statistics element if (model.hasDefined(STATISTICS_ENABLED)) { writer.writeStartElement(EJB3SubsystemXMLElement.STATISTICS.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.ENABLED.getLocalName(), model.get(EJB3SubsystemModel.STATISTICS_ENABLED).asString()); writer.writeEndElement(); } if (model.hasDefined(LOG_SYSTEM_EXCEPTIONS)) { writer.writeStartElement(EJB3SubsystemXMLElement.LOG_SYSTEM_EXCEPTIONS.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.VALUE.getLocalName(), model.get(EJB3SubsystemModel.LOG_SYSTEM_EXCEPTIONS).asString()); writer.writeEndElement(); } if (model.hasDefined(ALLOW_EJB_NAME_REGEX)) { writer.writeStartElement(EJB3SubsystemXMLElement.ALLOW_EJB_NAME_REGEX.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.VALUE.getLocalName(), model.get(EJB3SubsystemModel.ALLOW_EJB_NAME_REGEX).asString()); writer.writeEndElement(); } if (model.hasDefined(SERVER_INTERCEPTORS)) { writer.writeStartElement(EJB3SubsystemXMLElement.SERVER_INTERCEPTORS.getLocalName()); for (final ModelNode interceptor : model.get(SERVER_INTERCEPTORS).asList()) { writer.writeStartElement(EJB3SubsystemXMLElement.INTERCEPTOR.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.MODULE.getLocalName(), interceptor.get(EJB3SubsystemXMLAttribute.MODULE.getLocalName()).asString()); writer.writeAttribute(EJB3SubsystemXMLAttribute.CLASS.getLocalName(), interceptor.get(EJB3SubsystemXMLAttribute.CLASS.getLocalName()).asString()); writer.writeEndElement(); } writer.writeEndElement(); } if (model.hasDefined(CLIENT_INTERCEPTORS)) { writer.writeStartElement(EJB3SubsystemXMLElement.CLIENT_INTERCEPTORS.getLocalName()); for (final ModelNode interceptor : model.get(CLIENT_INTERCEPTORS).asList()) { writer.writeStartElement(EJB3SubsystemXMLElement.INTERCEPTOR.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.MODULE.getLocalName(), interceptor.get(EJB3SubsystemXMLAttribute.MODULE.getLocalName()).asString()); writer.writeAttribute(EJB3SubsystemXMLAttribute.CLASS.getLocalName(), interceptor.get(EJB3SubsystemXMLAttribute.CLASS.getLocalName()).asString()); writer.writeEndElement(); } writer.writeEndElement(); } } /** * Writes the start of the 'session-bean' element if not already written * @param writer the writer to use * @param alreadyWritten {@code true} if the element has already been written * @return whether the start element has been written by the time this method returns */ private boolean writeSessionBeanStartElement(final XMLExtendedStreamWriter writer, boolean alreadyWritten) throws XMLStreamException { if (!alreadyWritten) { // <session-bean> writer.writeStartElement(EJB3SubsystemXMLElement.SESSION_BEAN.getLocalName()); } return true; } private void writeIIOP(final XMLExtendedStreamWriter writer, final ModelNode model) throws XMLStreamException { EJB3IIOPResourceDefinition.ENABLE_BY_DEFAULT.marshallAsAttribute(model, writer); EJB3IIOPResourceDefinition.USE_QUALIFIED_NAME.marshallAsAttribute(model, writer); } private void writeThreadPools(final XMLExtendedStreamWriter writer, final ModelNode threadPoolsModel) throws XMLStreamException { for (Property threadPool : threadPoolsModel.asPropertyList()) { ThreadsParser.getInstance().writeEnhancedQueueThreadPool(writer, threadPool, EJB3SubsystemXMLElement.THREAD_POOL.getLocalName(), true); } } protected void writeRemote(final XMLExtendedStreamWriter writer, final ModelNode model) throws XMLStreamException { // only write if non-default value? if (model.hasDefined(EJB3SubsystemModel.CLIENT_MAPPINGS_CLUSTER_NAME)) { writer.writeAttribute(EJB3SubsystemXMLAttribute.CLIENT_MAPPINGS_CLUSTER_NAME.getLocalName(), model.require(EJB3SubsystemModel.CLIENT_MAPPINGS_CLUSTER_NAME).asString()); } // the default marshalling will marshal as an element, and we want to marshal as an attribute, so a change of coding here EJB3RemoteResourceDefinition.CONNECTORS.getMarshaller().marshallAsAttribute(EJB3RemoteResourceDefinition.CONNECTORS, model, true, writer); writer.writeAttribute(EJB3SubsystemXMLAttribute.THREAD_POOL_NAME.getLocalName(), model.require(EJB3SubsystemModel.THREAD_POOL_NAME).asString()); EJB3RemoteResourceDefinition.EXECUTE_IN_WORKER.marshallAsAttribute(model, writer); // write out any channel creation options if (model.hasDefined(CHANNEL_CREATION_OPTIONS)) { writeChannelCreationOptions(writer, model.get(CHANNEL_CREATION_OPTIONS)); } } private void writeAsync(final XMLExtendedStreamWriter writer, final ModelNode model) throws XMLStreamException { writer.writeAttribute(EJB3SubsystemXMLAttribute.THREAD_POOL_NAME.getLocalName(), model.require(EJB3SubsystemModel.THREAD_POOL_NAME).asString()); } /** * Writes out the <mdb> element and its nested elements * * @param writer XML writer * @param mdbModelNode The <mdb> element {@link org.jboss.dmr.ModelNode} * @throws javax.xml.stream.XMLStreamException * */ private void writeMDB(final XMLExtendedStreamWriter writer, final ModelNode mdbModelNode) throws XMLStreamException { if (mdbModelNode.hasDefined(EJB3SubsystemModel.DEFAULT_RESOURCE_ADAPTER_NAME)) { // <resource-adapter-ref> writer.writeStartElement(EJB3SubsystemXMLElement.RESOURCE_ADAPTER_REF.getLocalName()); final String resourceAdapterName = mdbModelNode.get(EJB3SubsystemModel.DEFAULT_RESOURCE_ADAPTER_NAME).asString(); // write the value writer.writeAttribute(EJB3SubsystemXMLAttribute.RESOURCE_ADAPTER_NAME.getLocalName(), resourceAdapterName); // </resource-adapter-ref> writer.writeEndElement(); } if (mdbModelNode.hasDefined(EJB3SubsystemModel.DEFAULT_MDB_INSTANCE_POOL)) { // <bean-instance-pool-ref> writer.writeStartElement(EJB3SubsystemXMLElement.BEAN_INSTANCE_POOL_REF.getLocalName()); final String poolRefName = mdbModelNode.get(EJB3SubsystemModel.DEFAULT_MDB_INSTANCE_POOL).asString(); // write the value writer.writeAttribute(EJB3SubsystemXMLAttribute.POOL_NAME.getLocalName(), poolRefName); // </bean-instance-pool-ref> writer.writeEndElement(); } if (mdbModelNode.hasDefined(EJB3SubsystemModel.MDB_DELIVERY_GROUP)) { //<delivery-groups> writer.writeStartElement(EJB3SubsystemXMLElement.DELIVERY_GROUPS.getLocalName()); for (Property property : mdbModelNode.get(EJB3SubsystemModel.MDB_DELIVERY_GROUP).asPropertyList()) { // <delivery-group writer.writeStartElement(EJB3SubsystemXMLElement.DELIVERY_GROUP.getLocalName()); // name= writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); // active= MdbDeliveryGroupResourceDefinition.ACTIVE.marshallAsAttribute(mdbModelNode.get(EJB3SubsystemModel.MDB_DELIVERY_GROUP, property.getName()), writer); // /> writer.writeEndElement(); } //</delivery-groups> writer.writeEndElement(); } } /** * Writes out the <entity-bean> element and its nested elements * * @param writer XML writer * @param entityModelNode The <mdb> element {@link org.jboss.dmr.ModelNode} * @throws javax.xml.stream.XMLStreamException * */ private void writeEntityBean(final XMLExtendedStreamWriter writer, final ModelNode entityModelNode) throws XMLStreamException { if (entityModelNode.hasDefined(EJB3SubsystemModel.DEFAULT_ENTITY_BEAN_INSTANCE_POOL)) { // <bean-instance-pool-ref> writer.writeStartElement(EJB3SubsystemXMLElement.BEAN_INSTANCE_POOL_REF.getLocalName()); final String poolRefName = entityModelNode.get(EJB3SubsystemModel.DEFAULT_ENTITY_BEAN_INSTANCE_POOL).asString(); // write the value writer.writeAttribute(EJB3SubsystemXMLAttribute.POOL_NAME.getLocalName(), poolRefName); // </bean-instance-pool-ref> writer.writeEndElement(); } if (entityModelNode.hasDefined(EJB3SubsystemModel.DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING)) { // <optimistic-locking> writer.writeStartElement(EJB3SubsystemXMLElement.OPTIMISTIC_LOCKING.getLocalName()); final String locking = entityModelNode.get(EJB3SubsystemModel.DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING).asString(); // write the value writer.writeAttribute(EJB3SubsystemXMLAttribute.ENABLED.getLocalName(), locking); // <optimistic-locking> writer.writeEndElement(); } } private void writeSingletonBean(final XMLExtendedStreamWriter writer, final ModelNode singletonBeanModel) throws XMLStreamException { final String defaultAccessTimeout = singletonBeanModel.get(DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT).asString(); writer.writeAttribute(EJB3SubsystemXMLAttribute.DEFAULT_ACCESS_TIMEOUT.getLocalName(), defaultAccessTimeout); } private void writeStatefulBean(final XMLExtendedStreamWriter writer, final ModelNode statefulBeanModel) throws XMLStreamException { if (statefulBeanModel.hasDefined(DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT)) { String defaultAccessTimeout = statefulBeanModel.get(DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT).asString(); writer.writeAttribute(EJB3SubsystemXMLAttribute.DEFAULT_ACCESS_TIMEOUT.getLocalName(), defaultAccessTimeout); } if (statefulBeanModel.hasDefined(DEFAULT_STATEFUL_BEAN_SESSION_TIMEOUT)) { String defaultSessionTimeout = statefulBeanModel.get(DEFAULT_STATEFUL_BEAN_SESSION_TIMEOUT).asString(); writer.writeAttribute(EJB3SubsystemXMLAttribute.DEFAULT_SESSION_TIMEOUT.getLocalName(), defaultSessionTimeout); } if (statefulBeanModel.hasDefined(DEFAULT_SFSB_CACHE)) { String cache = statefulBeanModel.get(DEFAULT_SFSB_CACHE).asString(); writer.writeAttribute(EJB3SubsystemXMLAttribute.CACHE_REF.getLocalName(), cache); } EJB3SubsystemRootResourceDefinition.DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE.marshallAsAttribute(statefulBeanModel, writer); } private void writeDefaultSLSBPool(final XMLExtendedStreamWriter writer, final ModelNode model) throws XMLStreamException { if (model.hasDefined(EJB3SubsystemModel.DEFAULT_SLSB_INSTANCE_POOL)) { // <bean-instance-pool-ref> writer.writeStartElement(EJB3SubsystemXMLElement.BEAN_INSTANCE_POOL_REF.getLocalName()); // contents of pool-ref final String poolRefName = model.get(EJB3SubsystemModel.DEFAULT_SLSB_INSTANCE_POOL).asString(); writer.writeAttribute(EJB3SubsystemXMLAttribute.POOL_NAME.getLocalName(), poolRefName); // </bean-instance-pool-ref> writer.writeEndElement(); } } private void writeBeanInstancePools(final XMLExtendedStreamWriter writer, final ModelNode beanInstancePoolModelNode) throws XMLStreamException { if (beanInstancePoolModelNode.hasDefined(EJB3SubsystemModel.STRICT_MAX_BEAN_INSTANCE_POOL)) { final List<Property> strictMaxPools = beanInstancePoolModelNode.get(EJB3SubsystemModel.STRICT_MAX_BEAN_INSTANCE_POOL).asPropertyList(); for (Property property : strictMaxPools) { // <strict-max-pool> writer.writeStartElement(EJB3SubsystemXMLElement.STRICT_MAX_POOL.getLocalName()); // contents of strict-max-pool this.writeStrictMaxPoolConfig(writer, property); // </strict-max-pool> writer.writeEndElement(); } } } private void writeStrictMaxPoolConfig(final XMLExtendedStreamWriter writer, final Property strictMaxPoolModel) throws XMLStreamException { // write the "name" attribute of the pool final ModelNode strictMaxPoolModelNode = strictMaxPoolModel.getValue(); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), strictMaxPoolModel.getName()); StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.marshallAsAttribute(strictMaxPoolModelNode, writer); StrictMaxPoolResourceDefinition.DERIVE_SIZE.marshallAsAttribute(strictMaxPoolModelNode, writer); StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.marshallAsAttribute(strictMaxPoolModelNode, writer); StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.marshallAsAttribute(strictMaxPoolModelNode, writer); } private void writeCaches(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException { // cache if (model.hasDefined(EJB3SubsystemModel.CACHE)) { List<Property> caches = model.get(EJB3SubsystemModel.CACHE).asPropertyList(); for (Property property : caches) { writer.writeStartElement(EJB3SubsystemXMLElement.CACHE.getLocalName()); ModelNode cache = property.getValue(); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); LegacyCacheFactoryResourceDefinition.PASSIVATION_STORE.marshallAsAttribute(cache, writer); writeAttribute(writer, cache, LegacyCacheFactoryResourceDefinition.ALIASES, true); writer.writeEndElement(); } } } /** * Writes out the <simple-cache> element * * @param writer XML writer * @param model The <simple-cache> element {@link org.jboss.dmr.ModelNode} * @throws javax.xml.stream.XMLStreamException * */ private void writeSimpleCaches(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException { // simple-cache if (model.hasDefined(EJB3SubsystemModel.SIMPLE_CACHE)) { List<Property> simpleCaches = model.get(EJB3SubsystemModel.SIMPLE_CACHE).asPropertyList(); for (Property property : simpleCaches) { writer.writeStartElement(EJB3SubsystemXMLElement.SIMPLE_CACHE.getLocalName()); ModelNode simpleCache = property.getValue(); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); // no attributes writer.writeEndElement(); } } } /** * Writes out the <distributable-cache> element * * @param writer XML writer * @param model The <distributable-cache> element {@link org.jboss.dmr.ModelNode} * @throws javax.xml.stream.XMLStreamException * */ private void writeDistributableCaches(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException { // distributable-cache if (model.hasDefined(EJB3SubsystemModel.DISTRIBUTABLE_CACHE)) { List<Property> distributableCaches = model.get(EJB3SubsystemModel.DISTRIBUTABLE_CACHE).asPropertyList(); for (Property property : distributableCaches) { writer.writeStartElement(EJB3SubsystemXMLElement.DISTRIBUTABLE_CACHE.getLocalName()); ModelNode distributableCache = property.getValue(); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); for (Attribute attribute : EnumSet.allOf(DistributableStatefulSessionBeanCacheProviderResourceDefinition.Attribute.class)) { attribute.getDefinition().getMarshaller().marshallAsAttribute(attribute.getDefinition(), distributableCache, false, writer); } writer.writeEndElement(); } } } private void writePassivationStores(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException { if (model.hasDefined(EJB3SubsystemModel.PASSIVATION_STORE)) { List<Property> caches = model.get(EJB3SubsystemModel.PASSIVATION_STORE).asPropertyList(); for (Property property : caches) { writer.writeStartElement(EJB3SubsystemXMLElement.PASSIVATION_STORE.getLocalName()); ModelNode store = property.getValue(); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); PassivationStoreResourceDefinition.CACHE_CONTAINER.marshallAsAttribute(store, writer); PassivationStoreResourceDefinition.BEAN_CACHE.marshallAsAttribute(store, writer); PassivationStoreResourceDefinition.MAX_SIZE.marshallAsAttribute(store, writer); writer.writeEndElement(); } } } /** * Persist as a passivation-store using relevant attributes */ private void writeClusterPassivationStores(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException { if (model.hasDefined(EJB3SubsystemModel.CLUSTER_PASSIVATION_STORE)) { List<Property> caches = model.get(EJB3SubsystemModel.CLUSTER_PASSIVATION_STORE).asPropertyList(); for (Property property : caches) { // <strict-max-pool> writer.writeStartElement(EJB3SubsystemXMLElement.CLUSTER_PASSIVATION_STORE.getLocalName()); ModelNode store = property.getValue(); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); LegacyPassivationStoreResourceDefinition.IDLE_TIMEOUT.marshallAsAttribute(store, writer); LegacyPassivationStoreResourceDefinition.IDLE_TIMEOUT_UNIT.marshallAsAttribute(store, writer); ClusterPassivationStoreResourceDefinition.MAX_SIZE.marshallAsAttribute(store, writer); ClusterPassivationStoreResourceDefinition.CACHE_CONTAINER.marshallAsAttribute(store, writer); ClusterPassivationStoreResourceDefinition.BEAN_CACHE.marshallAsAttribute(store, writer); ClusterPassivationStoreResourceDefinition.CLIENT_MAPPINGS_CACHE.marshallAsAttribute(store, writer); ClusterPassivationStoreResourceDefinition.PASSIVATE_EVENTS_ON_REPLICATE.marshallAsAttribute(store, writer); writer.writeEndElement(); } } } /** * Persist as a passivation-store using relevant attributes */ private void writeFilePassivationStores(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException { if (model.hasDefined(EJB3SubsystemModel.FILE_PASSIVATION_STORE)) { List<Property> caches = model.get(EJB3SubsystemModel.FILE_PASSIVATION_STORE).asPropertyList(); for (Property property : caches) { // <strict-max-pool> writer.writeStartElement(EJB3SubsystemXMLElement.FILE_PASSIVATION_STORE.getLocalName()); ModelNode store = property.getValue(); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); LegacyPassivationStoreResourceDefinition.IDLE_TIMEOUT.marshallAsAttribute(store, writer); LegacyPassivationStoreResourceDefinition.IDLE_TIMEOUT_UNIT.marshallAsAttribute(store, writer); FilePassivationStoreResourceDefinition.MAX_SIZE.marshallAsAttribute(store, writer); FilePassivationStoreResourceDefinition.RELATIVE_TO.marshallAsAttribute(store, writer); FilePassivationStoreResourceDefinition.GROUPS_PATH.marshallAsAttribute(store, writer); FilePassivationStoreResourceDefinition.SESSIONS_PATH.marshallAsAttribute(store, writer); FilePassivationStoreResourceDefinition.SUBDIRECTORY_COUNT.marshallAsAttribute(store, writer); writer.writeEndElement(); } } } private void writeTimerService(final XMLExtendedStreamWriter writer, final ModelNode timerServiceModel) throws XMLStreamException { for (AttributeDefinition attribute : TimerServiceResourceDefinition.ATTRIBUTES) { attribute.getMarshaller().marshallAsAttribute(attribute, timerServiceModel, false, writer); } writer.writeStartElement(EJB3SubsystemXMLElement.DATA_STORES.getLocalName()); writeFileDataStores(writer, timerServiceModel); writeDatabaseDataStores(writer, timerServiceModel); writer.writeEndElement(); } private void writeDatabaseDataStores(final XMLExtendedStreamWriter writer, final ModelNode timerServiceModel) throws XMLStreamException { if (timerServiceModel.hasDefined(EJB3SubsystemModel.DATABASE_DATA_STORE)) { List<Property> stores = timerServiceModel.get(EJB3SubsystemModel.DATABASE_DATA_STORE).asPropertyList(); for (Property property : stores) { writer.writeStartElement(EJB3SubsystemXMLElement.DATABASE_DATA_STORE.getLocalName()); ModelNode store = property.getValue(); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); DatabaseDataStoreResourceDefinition.DATASOURCE_JNDI_NAME.marshallAsAttribute(store, writer); DatabaseDataStoreResourceDefinition.DATABASE.marshallAsAttribute(store, writer); DatabaseDataStoreResourceDefinition.PARTITION.marshallAsAttribute(store, writer); DatabaseDataStoreResourceDefinition.REFRESH_INTERVAL.marshallAsAttribute(store, writer); DatabaseDataStoreResourceDefinition.ALLOW_EXECUTION.marshallAsAttribute(store, writer); writer.writeEndElement(); } } } private void writeFileDataStores(final XMLExtendedStreamWriter writer, final ModelNode timerServiceModel) throws XMLStreamException { if (timerServiceModel.hasDefined(EJB3SubsystemModel.FILE_DATA_STORE)) { List<Property> stores = timerServiceModel.get(EJB3SubsystemModel.FILE_DATA_STORE).asPropertyList(); for (Property property : stores) { writer.writeStartElement(EJB3SubsystemXMLElement.FILE_DATA_STORE.getLocalName()); ModelNode store = property.getValue(); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); FileDataStoreResourceDefinition.PATH.marshallAsAttribute(store, writer); FileDataStoreResourceDefinition.RELATIVE_TO.marshallAsAttribute(store, writer); writer.writeEndElement(); } } } private void writeChannelCreationOptions(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException { writer.writeStartElement(EJB3SubsystemXMLElement.CHANNEL_CREATION_OPTIONS.getLocalName()); for (final Property optionPropertyModelNode : node.asPropertyList()) { writer.writeStartElement(EJB3SubsystemXMLElement.OPTION.getLocalName()); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), optionPropertyModelNode.getName()); final ModelNode propertyValueModelNode = optionPropertyModelNode.getValue(); RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE.marshallAsAttribute(propertyValueModelNode, writer); RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_TYPE.marshallAsAttribute(propertyValueModelNode, writer); writer.writeEndElement(); } writer.writeEndElement(); } private void writeProfiles(final XMLExtendedStreamWriter writer, final ModelNode model) throws XMLStreamException { final List<Property> profiles = model.get(REMOTING_PROFILE).asPropertyList(); for (final Property property : profiles) { writer.writeStartElement(PROFILE); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); final ModelNode profileNode = property.getValue(); RemotingProfileResourceDefinition.EXCLUDE_LOCAL_RECEIVER.marshallAsAttribute(profileNode, writer); RemotingProfileResourceDefinition.LOCAL_RECEIVER_PASS_BY_VALUE.marshallAsAttribute(profileNode, writer); if(profileNode.hasDefined(REMOTING_EJB_RECEIVER)){ writeRemotingEjbReceivers(writer, profileNode); } if(profileNode.hasDefined(REMOTE_HTTP_CONNECTION)){ writeRemoteHttpConnection(writer, profileNode); } StaticEJBDiscoveryDefinition.INSTANCE.marshallAsElement(profileNode, writer); writer.writeEndElement(); } } private void writeRemotingEjbReceivers(final XMLExtendedStreamWriter writer, final ModelNode profileNode) throws XMLStreamException { final List<Property> receivers = profileNode.get(REMOTING_EJB_RECEIVER).asPropertyList(); for (final Property property : receivers) { writer.writeStartElement(REMOTING_EJB_RECEIVER); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); final ModelNode receiverNode = property.getValue(); RemotingEjbReceiverDefinition.OUTBOUND_CONNECTION_REF.marshallAsAttribute(receiverNode, writer); RemotingEjbReceiverDefinition.CONNECT_TIMEOUT.marshallAsAttribute(receiverNode, writer); if (receiverNode.hasDefined(CHANNEL_CREATION_OPTIONS)) { writeChannelCreationOptions(writer, receiverNode.get(CHANNEL_CREATION_OPTIONS)); } writer.writeEndElement(); } } private void writeRemoteHttpConnection(final XMLExtendedStreamWriter writer, final ModelNode profileNode) throws XMLStreamException { final List<Property> connections = profileNode.get(REMOTE_HTTP_CONNECTION).asPropertyList(); for (final Property property : connections) { writer.writeStartElement(REMOTE_HTTP_CONNECTION); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); final ModelNode connectionNode = property.getValue(); RemoteHttpConnectionDefinition.URI.marshallAsAttribute(connectionNode, writer); writer.writeEndElement(); } } private void writeApplicationSecurityDomains(final XMLExtendedStreamWriter writer, final ModelNode model) throws XMLStreamException { List<Property> applicationSecurityDomains = model.get(APPLICATION_SECURITY_DOMAIN).asPropertyList(); for (Property property : applicationSecurityDomains) { writeApplicationSecurityDomain(writer, property); } } private void writeApplicationSecurityDomain(final XMLExtendedStreamWriter writer, final Property property) throws XMLStreamException { writer.writeStartElement(APPLICATION_SECURITY_DOMAIN); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); ApplicationSecurityDomainDefinition.SECURITY_DOMAIN.marshallAsAttribute(property.getValue(), writer); ApplicationSecurityDomainDefinition.ENABLE_JACC.marshallAsAttribute(property.getValue(), writer); ApplicationSecurityDomainDefinition.LEGACY_COMPLIANT_PRINCIPAL_PROPAGATION.marshallAsAttribute(property.getValue(), writer); writer.writeEndElement(); } private static void writeAttribute(XMLExtendedStreamWriter writer, ModelNode model, AttributeDefinition attribute, boolean marshallDefault) throws XMLStreamException { attribute.getMarshaller().marshallAsAttribute(attribute, model, marshallDefault, writer); } }
43,582
55.822686
189
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/IdentityInterceptorProcessor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION; import org.jboss.as.ee.component.ComponentConfiguration; import org.jboss.as.ee.component.ComponentDescription; import org.jboss.as.ee.component.EEModuleDescription; import org.jboss.as.ee.component.ViewConfiguration; import org.jboss.as.ee.component.ViewConfigurator; import org.jboss.as.ee.component.ViewDescription; import org.jboss.as.ee.component.interceptors.InterceptorOrder; import org.jboss.as.ejb3.component.EJBComponentDescription; import org.jboss.as.ejb3.component.EJBViewDescription; import org.jboss.as.ejb3.security.IdentityInterceptor; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessingException; import org.jboss.as.server.deployment.DeploymentUnitProcessor; import org.jboss.invocation.ImmediateInterceptorFactory; import java.util.Collection; /** * A {@link DeploymentUnitProcessor} that adds interceptors to EJB deployments that will always * runAs the current {@code SecurityIdentity} to activate any outflow identities. * * @author <a href="mailto:[email protected]">Farah Juma</a> */ class IdentityInterceptorProcessor implements DeploymentUnitProcessor { @Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); registerIdentityInterceptor(deploymentUnit); } private static void registerIdentityInterceptor(final DeploymentUnit deploymentUnit) { // this Interceptor will get used when invoking local EJBs final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(EE_MODULE_DESCRIPTION); if (eeModuleDescription == null) { return; } final Collection<ComponentDescription> componentDescriptions = eeModuleDescription.getComponentDescriptions(); if (componentDescriptions == null || componentDescriptions.isEmpty()) { return; } for (ComponentDescription componentDescription : componentDescriptions) { if (componentDescription instanceof EJBComponentDescription) { for (ViewDescription view : componentDescription.getViews()) { final EJBViewDescription ejbView = (EJBViewDescription) view; ejbView.getConfigurators().add(new ViewConfigurator() { @Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { configuration.addClientInterceptor(new ImmediateInterceptorFactory(new IdentityInterceptor()), InterceptorOrder.Client.SECURITY_IDENTITY); } }); } } } } }
4,179
48.761905
166
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Subsystem100Parser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.parsing.ParseUtils.missingRequired; import static org.jboss.as.controller.parsing.ParseUtils.requireNoAttributes; import static org.jboss.as.controller.parsing.ParseUtils.requireNoContent; import static org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.SIMPLE_CACHE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DISTRIBUTABLE_CACHE; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import java.util.Collections; import java.util.List; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.operations.common.Util; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; /** * Parser for ejb3:10.0 namespace. * TODO Parameterize a single parser class by schema version. Inheritence is a poor model for versioning. */ public class EJB3Subsystem100Parser extends EJB3Subsystem90Parser { @Override protected EJB3SubsystemNamespace getExpectedNamespace() { return EJB3SubsystemNamespace.EJB3_10_0; } protected void parseCaches(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { // no attributes expected requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case CACHE: { this.parseCache(reader, operations); break; } case SIMPLE_CACHE: { this.parseSimpleCache(reader, operations); break; } case DISTRIBUTABLE_CACHE: { this.parseDistributableCache(reader, operations); break; } default: { throw unexpectedElement(reader); } } } } private void parseSimpleCache(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { String name = null; ModelNode operation = Util.createAddOperation(); for (int i = 0; i < reader.getAttributeCount(); i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); switch (EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i))) { case NAME: { name = value; break; } default: { throw unexpectedAttribute(reader, i); } } } requireNoContent(reader); if (name == null) { throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.NAME.getLocalName())); } final PathAddress address = this.getEJB3SubsystemAddress().append(PathElement.pathElement(SIMPLE_CACHE, name)); operation.get(OP_ADDR).set(address.toModelNode()); operations.add(operation); } private void parseDistributableCache(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { String name = null; ModelNode operation = Util.createAddOperation(); for (int i = 0; i < reader.getAttributeCount(); i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); switch (EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i))) { case NAME: { name = value; break; } case BEAN_MANAGEMENT: { AttributeDefinition definition = DistributableStatefulSessionBeanCacheProviderResourceDefinition.Attribute.BEAN_MANAGEMENT.getDefinition(); definition.getParser().parseAndSetParameter(definition, value, operation, reader); break; } default: { throw unexpectedAttribute(reader, i); } } } requireNoContent(reader); if (name == null) { throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.NAME.getLocalName())); } final PathAddress address = this.getEJB3SubsystemAddress().append(PathElement.pathElement(DISTRIBUTABLE_CACHE, name)); operation.get(OP_ADDR).set(address.toModelNode()); operations.add(operation); } @Override protected void parseTimerService(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { PathAddress address = PathAddress.pathAddress(EJB3Extension.SUBSYSTEM_PATH, EJB3SubsystemModel.TIMER_SERVICE_PATH); ModelNode operation = Util.createAddOperation(address); operations.add(operation); final int attCount = reader.getAttributeCount(); for (int i = 0; i < attCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case THREAD_POOL_NAME: TimerServiceResourceDefinition.THREAD_POOL_NAME.parseAndSetParameter(value, operation, reader); break; case DEFAULT_DATA_STORE: TimerServiceResourceDefinition.DEFAULT_DATA_STORE.parseAndSetParameter(value, operation, reader); break; case DEFAULT_PERSISTENT_TIMER_MANAGEMENT: TimerServiceResourceDefinition.DEFAULT_PERSISTENT_TIMER_MANAGEMENT.parseAndSetParameter(value, operation, reader); break; case DEFAULT_TRANSIENT_TIMER_MANAGEMENT: TimerServiceResourceDefinition.DEFAULT_TRANSIENT_TIMER_MANAGEMENT.parseAndSetParameter(value, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case DATA_STORES: parseDataStores(reader, operations); } } } }
8,027
44.613636
159
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/ApplicationSecurityDomainDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.CapabilityServiceBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationContext.AttachmentKey; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler; import org.jboss.as.controller.ResourceDefinition; import org.jboss.as.controller.ServiceRemoveStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.StringListAttributeDefinition; import org.jboss.as.controller.access.constraint.ApplicationTypeConfig; import org.jboss.as.controller.access.constraint.SensitivityClassification; import org.jboss.as.controller.access.management.ApplicationTypeAccessConstraintDefinition; import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.operations.validation.StringLengthValidator; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.Resource; import org.jboss.as.ejb3.security.ApplicationSecurityDomainConfig; import org.jboss.as.ejb3.subsystem.ApplicationSecurityDomainService.ApplicationSecurityDomain; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jboss.msc.service.ServiceController.Mode; import org.jboss.msc.service.ServiceName; import org.wildfly.security.auth.server.SecurityDomain; /** * A {@link ResourceDefinition} to define the mapping from a security domain, as specified in a web application, * to an Elytron {@link SecurityDomain}. * * @author <a href="mailto:[email protected]">Farah Juma</a> */ public class ApplicationSecurityDomainDefinition extends SimpleResourceDefinition { public static final String APPLICATION_SECURITY_DOMAIN_CAPABILITY_NAME = "org.wildfly.ejb3.application-security-domain"; public static final String CAPABILITY_APPLICATION_SECURITY_DOMAIN_KNOWN_DEPLOYMENTS = "org.wildfly.ejb3.application-security-domain.known-deployments"; private static final String SECURITY_DOMAIN_CAPABILITY_NAME = "org.wildfly.security.security-domain"; static final RuntimeCapability<Void> APPLICATION_SECURITY_DOMAIN_CAPABILITY = RuntimeCapability .Builder.of(APPLICATION_SECURITY_DOMAIN_CAPABILITY_NAME, true, ApplicationSecurityDomain.class) .build(); static final SimpleAttributeDefinition SECURITY_DOMAIN = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.SECURITY_DOMAIN, ModelType.STRING, false) .setValidator(new StringLengthValidator(1)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setCapabilityReference(SECURITY_DOMAIN_CAPABILITY_NAME, APPLICATION_SECURITY_DOMAIN_CAPABILITY) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.ELYTRON_SECURITY_DOMAIN_REF) .build(); private static final StringListAttributeDefinition REFERENCING_DEPLOYMENTS = new StringListAttributeDefinition.Builder(EJB3SubsystemModel.REFERENCING_DEPLOYMENTS) .setStorageRuntime() .build(); static final SimpleAttributeDefinition ENABLE_JACC = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.ENABLE_JACC, ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.FALSE) .setMinSize(1) .setRestartAllServices() .build(); static final SimpleAttributeDefinition LEGACY_COMPLIANT_PRINCIPAL_PROPAGATION = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.LEGACY_COMPLIANT_PRINCIPAL_PROPAGATION, ModelType.BOOLEAN, true) .setDefaultValue(ModelNode.TRUE) .setRestartAllServices() .build(); private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { SECURITY_DOMAIN, ENABLE_JACC, LEGACY_COMPLIANT_PRINCIPAL_PROPAGATION }; private static final AttachmentKey<KnownDeploymentsApi> KNOWN_DEPLOYMENTS_KEY = AttachmentKey.create(KnownDeploymentsApi.class); ApplicationSecurityDomainDefinition(Set<ApplicationSecurityDomainConfig> knownApplicationSecurityDomains) { this(new Parameters(PathElement.pathElement(EJB3SubsystemModel.APPLICATION_SECURITY_DOMAIN), EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.APPLICATION_SECURITY_DOMAIN)) .setCapabilities(APPLICATION_SECURITY_DOMAIN_CAPABILITY) .addAccessConstraints(new SensitiveTargetAccessConstraintDefinition(new SensitivityClassification(EJB3Extension.SUBSYSTEM_NAME, EJB3SubsystemModel.APPLICATION_SECURITY_DOMAIN, false, false, false)), new ApplicationTypeAccessConstraintDefinition(new ApplicationTypeConfig(EJB3Extension.SUBSYSTEM_NAME, EJB3SubsystemModel.APPLICATION_SECURITY_DOMAIN))) , new AddHandler(knownApplicationSecurityDomains)); } private ApplicationSecurityDomainDefinition(Parameters parameters, AddHandler add) { super(parameters.setAddHandler(add).setRemoveHandler(new RemoveHandler(add))); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { ReloadRequiredWriteAttributeHandler handler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES); for (AttributeDefinition attribute: ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(attribute, null, handler); } if (resourceRegistration.getProcessType().isServer()) { resourceRegistration.registerReadOnlyAttribute(REFERENCING_DEPLOYMENTS, new ReferencingDeploymentsHandler()); } } private static class AddHandler extends AbstractAddStepHandler { private final Set<ApplicationSecurityDomainConfig> knownApplicationSecurityDomains; private AddHandler(Set<ApplicationSecurityDomainConfig> knownApplicationSecurityDomains) { super(ATTRIBUTES); this.knownApplicationSecurityDomains = knownApplicationSecurityDomains; } @Override protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { super.recordCapabilitiesAndRequirements(context, operation, resource); KnownDeploymentsApi knownDeployments = new KnownDeploymentsApi(); context.registerCapability(RuntimeCapability.Builder .of(CAPABILITY_APPLICATION_SECURITY_DOMAIN_KNOWN_DEPLOYMENTS, true, knownDeployments).build() .fromBaseCapability(context.getCurrentAddressValue())); context.attach(KNOWN_DEPLOYMENTS_KEY, knownDeployments); } @Override protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { super.populateModel(context, operation, resource); ModelNode model = resource.getModel(); boolean enableJacc = false; boolean legacyCompliantPrincipalPropagation = true; if (model.hasDefined(ENABLE_JACC.getName())) { enableJacc = ENABLE_JACC.resolveModelAttribute(context, model).asBoolean(); } if (model.hasDefined(LEGACY_COMPLIANT_PRINCIPAL_PROPAGATION.getName())) { legacyCompliantPrincipalPropagation = LEGACY_COMPLIANT_PRINCIPAL_PROPAGATION.resolveModelAttribute(context, model).asBoolean(); } this.knownApplicationSecurityDomains.add(new ApplicationSecurityDomainConfig(context.getCurrentAddressValue(), enableJacc, legacyCompliantPrincipalPropagation)); } @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { String securityDomain = SECURITY_DOMAIN.resolveModelAttribute(context, model).asString(); boolean enableJacc = ENABLE_JACC.resolveModelAttribute(context, model).asBoolean(); boolean legacyCompliantPrincipalPropagation = LEGACY_COMPLIANT_PRINCIPAL_PROPAGATION.resolveModelAttribute(context, model).asBoolean(); RuntimeCapability<?> runtimeCapability = APPLICATION_SECURITY_DOMAIN_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName serviceName = runtimeCapability.getCapabilityServiceName(ApplicationSecurityDomain.class); ServiceName securityDomainServiceName = serviceName.append("security-domain"); CapabilityServiceBuilder<?> serviceBuilder = context.getCapabilityServiceTarget().addCapability(APPLICATION_SECURITY_DOMAIN_CAPABILITY) .setInitialMode(Mode.LAZY); Supplier<SecurityDomain> securityDomainSupplier = serviceBuilder.requires(context.getCapabilityServiceName( SECURITY_DOMAIN_CAPABILITY_NAME, securityDomain, SecurityDomain.class)); Consumer<ApplicationSecurityDomainService.ApplicationSecurityDomain> applicationSecurityDomainConsumer = serviceBuilder.provides(serviceName); Consumer<SecurityDomain> securityDomainConsumer = serviceBuilder.provides(securityDomainServiceName); ApplicationSecurityDomainService service = new ApplicationSecurityDomainService(enableJacc, securityDomainSupplier, applicationSecurityDomainConsumer, securityDomainConsumer); serviceBuilder.setInstance(service); serviceBuilder.install(); KnownDeploymentsApi knownDeploymentsApi = context.getAttachment(KNOWN_DEPLOYMENTS_KEY); knownDeploymentsApi.setApplicationSecurityDomainService(service); } } private static class RemoveHandler extends ServiceRemoveStepHandler { private final Set<ApplicationSecurityDomainConfig> knownApplicationSecurityDomains; protected RemoveHandler(AddHandler addOperation) { super(addOperation); this.knownApplicationSecurityDomains = addOperation.knownApplicationSecurityDomains; } @Override protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { super.performRemove(context, operation, model); String name = context.getCurrentAddressValue(); this.knownApplicationSecurityDomains.removeIf(domain -> domain.isSameDomain(name)); } @Override protected ServiceName serviceName(String name) { return APPLICATION_SECURITY_DOMAIN_CAPABILITY.getCapabilityServiceName(ApplicationSecurityDomain.class, name); } } private static class ReferencingDeploymentsHandler implements OperationStepHandler { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (context.isDefaultRequiresRuntime()) { context.addStep((ctx, op) -> { final KnownDeploymentsApi knownDeploymentsApi = context.getCapabilityRuntimeAPI( CAPABILITY_APPLICATION_SECURITY_DOMAIN_KNOWN_DEPLOYMENTS, ctx.getCurrentAddressValue(), KnownDeploymentsApi.class); ModelNode deploymentList = new ModelNode(); for (String current : knownDeploymentsApi.getKnownDeployments()) { deploymentList.add(current); } context.getResult().set(deploymentList); }, OperationContext.Stage.RUNTIME); } } } private static class KnownDeploymentsApi { private volatile ApplicationSecurityDomainService service; List<String> getKnownDeployments() { return service != null ? Arrays.asList(service.getDeployments()) : Collections.emptyList(); } void setApplicationSecurityDomainService(final ApplicationSecurityDomainService service) { this.service = service; } } }
13,656
53.628
214
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemModel.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.PathElement; import org.jboss.as.threads.ThreadsServices; import org.jboss.msc.service.ServiceName; /** * User: jpai * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ public interface EJB3SubsystemModel { String LITE = "lite"; String ABSTACT_TYPE = "abstract-type"; String ABSTACT_TYPE_AUTHORITY = "abstract-type-authority"; String ALIASES = "aliases"; String ATTRIBUTES = "attributes"; String ASYNC = "async"; String ALLOW_EJB_NAME_REGEX = "allow-ejb-name-regex"; String IIOP = "iiop"; String CONNECTOR_REF = "connector-ref"; String CONNECTORS = "connectors"; String IN_VM_REMOTE_INTERFACE_INVOCATION_PASS_BY_VALUE = "in-vm-remote-interface-invocation-pass-by-value"; String DATASOURCE_JNDI_NAME = "datasource-jndi-name"; String DEFAULT_DISTINCT_NAME = "default-distinct-name"; String DEFAULT_SECURITY_DOMAIN = "default-security-domain"; String DEFAULT_MDB_INSTANCE_POOL = "default-mdb-instance-pool"; String DEFAULT_MISSING_METHOD_PERMISSIONS_DENY_ACCESS = "default-missing-method-permissions-deny-access"; String DEFAULT_RESOURCE_ADAPTER_NAME = "default-resource-adapter-name"; String DEFAULT_SFSB_CACHE = "default-sfsb-cache"; String DEFAULT_CLUSTERED_SFSB_CACHE = "default-clustered-sfsb-cache"; String DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE = "default-sfsb-passivation-disabled-cache"; String DEFAULT_SLSB_INSTANCE_POOL = "default-slsb-instance-pool"; String INSTANCE_ACQUISITION_TIMEOUT = "timeout"; String INSTANCE_ACQUISITION_TIMEOUT_UNIT = "timeout-unit"; String DEFAULT_ENTITY_BEAN_INSTANCE_POOL = "default-entity-bean-instance-pool"; String DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING = "default-entity-bean-optimistic-locking"; String DISABLE_DEFAULT_EJB_PERMISSIONS = "disable-default-ejb-permissions"; String ENABLE_GRACEFUL_TXN_SHUTDOWN = "enable-graceful-txn-shutdown"; String DISCOVERY = "discovery"; String STATIC = "static"; String LOG_SYSTEM_EXCEPTIONS = "log-system-exceptions"; String ENABLE_STATISTICS = "enable-statistics"; String STATISTICS_ENABLED = "statistics-enabled"; String FILE_DATA_STORE = "file-data-store"; String MAX_POOL_SIZE = "max-pool-size"; String DERIVE_SIZE = "derive-size"; String DERIVED_SIZE = "derived-size"; String STRICT_MAX_BEAN_INSTANCE_POOL = "strict-max-bean-instance-pool"; String MAX_THREADS = "max-threads"; String KEEPALIVE_TIME = "keepalive-time"; String RELATIVE_TO = "relative-to"; String PATH = "path"; String DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT = "default-singleton-bean-access-timeout"; String DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT = "default-stateful-bean-access-timeout"; String DEFAULT_STATEFUL_BEAN_SESSION_TIMEOUT = "default-stateful-bean-session-timeout"; String DEFAULT_DATA_STORE = "default-data-store"; String DEFAULT_PERSISTENT_TIMER_MANAGEMENT = "default-persistent-timer-management"; String DEFAULT_TRANSIENT_TIMER_MANAGEMENT = "default-transient-timer-management"; String REMOTE = "remote"; String SERVICE = "service"; String PROFILE = "profile"; String REMOTING_PROFILE = "remoting-profile"; String EXCLUDE_LOCAL_RECEIVER= "exclude-local-receiver"; String LOCAL_RECEIVER_PASS_BY_VALUE = "local-receiver-pass-by-value"; String REMOTING_EJB_RECEIVER = "remoting-ejb-receiver"; String OUTBOUND_CONNECTION_REF= "outbound-connection-ref"; String CONNECT_TIMEOUT= "connect-timeout"; String CLIENT_MAPPINGS_CLUSTER_NAME = "cluster"; String REMOTE_HTTP_CONNECTION = "remote-http-connection"; String TIMER = "timer"; String TIMER_SERVICE = "timer-service"; String THREAD_POOL = "thread-pool"; String THREAD_POOL_NAME = "thread-pool-name"; String DEFAULT = "default"; String USE_QUALIFIED_NAME = "use-qualified-name"; String ENABLE_BY_DEFAULT = "enable-by-default"; @Deprecated String CACHE = "cache"; String SIMPLE_CACHE = "simple-cache"; String DISTRIBUTABLE_CACHE = "distributable-cache"; String BEAN_MANAGEMENT = "bean-management"; @Deprecated String PASSIVATION_STORE = "passivation-store"; String MDB_DELIVERY_GROUP="mdb-delivery-group"; String MDB_DELVIERY_GROUP_ACTIVE = "active"; @Deprecated String FILE_PASSIVATION_STORE = "file-passivation-store"; @Deprecated String IDLE_TIMEOUT = "idle-timeout"; @Deprecated String IDLE_TIMEOUT_UNIT = "idle-timeout-unit"; String MAX_SIZE = "max-size"; @Deprecated String GROUPS_PATH = "groups-path"; @Deprecated String SESSIONS_PATH = "sessions-path"; @Deprecated String SUBDIRECTORY_COUNT = "subdirectory-count"; @Deprecated String CLUSTER_PASSIVATION_STORE = "cluster-passivation-store"; String BEAN_CACHE = "bean-cache"; String CACHE_CONTAINER = "cache-container"; @Deprecated String CLIENT_MAPPINGS_CACHE = "client-mappings-cache"; @Deprecated String PASSIVATE_EVENTS_ON_REPLICATE = "passivate-events-on-replicate"; String CHANNEL_CREATION_OPTIONS = "channel-creation-options"; String VALUE = "value"; String TYPE = "type"; String DATABASE = "database"; String DATABASE_DATA_STORE = "database-data-store"; String PARTITION = "partition"; String REFRESH_INTERVAL = "refresh-interval"; String ALLOW_EXECUTION = "allow-execution"; String STATIC_URLS = "static-urls"; PathElement REMOTE_SERVICE_PATH = PathElement.pathElement(SERVICE, REMOTE); PathElement ASYNC_SERVICE_PATH = PathElement.pathElement(SERVICE, ASYNC); PathElement TIMER_PATH = PathElement.pathElement(TIMER); PathElement TIMER_SERVICE_PATH = PathElement.pathElement(SERVICE, TIMER_SERVICE); PathElement THREAD_POOL_PATH = PathElement.pathElement(THREAD_POOL); PathElement IIOP_PATH = PathElement.pathElement(SERVICE, IIOP); PathElement FILE_DATA_STORE_PATH = PathElement.pathElement(FILE_DATA_STORE); PathElement DATABASE_DATA_STORE_PATH = PathElement.pathElement(DATABASE_DATA_STORE); PathElement MDB_DELIVERY_GROUP_PATH = PathElement.pathElement(MDB_DELIVERY_GROUP); PathElement STRICT_MAX_BEAN_INSTANCE_POOL_PATH = PathElement.pathElement(STRICT_MAX_BEAN_INSTANCE_POOL); PathElement REMOTING_PROFILE_PATH = PathElement.pathElement(REMOTING_PROFILE); PathElement SIMPLE_CACHE_PATH = PathElement.pathElement(SIMPLE_CACHE); PathElement DISTRIBUTABLE_CACHE_PATH = PathElement.pathElement(DISTRIBUTABLE_CACHE); String BASE_EJB_THREAD_POOL_NAME = "ejb3"; ServiceName BASE_THREAD_POOL_SERVICE_NAME = ThreadsServices.EXECUTOR.append(BASE_EJB_THREAD_POOL_NAME); String EXECUTE_IN_WORKER = "execute-in-worker"; // Elytron integration String APPLICATION_SECURITY_DOMAIN = "application-security-domain"; String IDENTITY = "identity"; String OUTFLOW_SECURITY_DOMAINS = "outflow-security-domains"; String REFERENCING_DEPLOYMENTS = "referencing-deployments"; String SECURITY_DOMAIN = "security-domain"; String ENABLE_JACC = "enable-jacc"; String LEGACY_COMPLIANT_PRINCIPAL_PROPAGATION = "legacy-compliant-principal-propagation"; PathElement IDENTITY_PATH = PathElement.pathElement(SERVICE, IDENTITY); //Server interceptors String SERVER_INTERCEPTOR = "server-interceptor"; String SERVER_INTERCEPTORS = "server-interceptors"; //Client interceptors String CLIENT_INTERCEPTOR = "client-interceptor"; String CLIENT_INTERCEPTORS = "client-interceptors"; String MODULE = "module"; String CLASS = "class"; String BINDING = "binding"; String URI = "uri"; }
8,672
44.408377
111
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/DefaultDistinctNameService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.msc.service.Service; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; /** * @author Stuart Douglas */ public class DefaultDistinctNameService implements Service<DefaultDistinctNameService> { public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "defaultDistinctName"); private volatile String defaultDistinctName; public DefaultDistinctNameService(final String defaultDistinctName) { this.defaultDistinctName = defaultDistinctName; } @Override public void start(final StartContext context) throws StartException { } @Override public void stop(final StopContext context) { } @Override public DefaultDistinctNameService getValue() throws IllegalStateException, IllegalArgumentException { return this; } public String getDefaultDistinctName() { return defaultDistinctName; } public void setDefaultDistinctName(final String defaultDistinctName) { this.defaultDistinctName = defaultDistinctName; } }
2,236
32.38806
107
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Subsystem40Parser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.List; import java.util.Set; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.parsing.ParseUtils.missingRequired; import static org.jboss.as.controller.parsing.ParseUtils.readStringAttributeElement; import static org.jboss.as.controller.parsing.ParseUtils.requireNoAttributes; import static org.jboss.as.controller.parsing.ParseUtils.requireNoContent; import static org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DERIVE_SIZE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.MAX_POOL_SIZE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.REMOTE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.SERVICE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.STRICT_MAX_BEAN_INSTANCE_POOL; /** * Parser for ejb3:4.0 namespace. * * @author <a href="mailto:[email protected]">Richard Achmatowicz</a> */ public class EJB3Subsystem40Parser extends EJB3Subsystem30Parser { protected EJB3Subsystem40Parser() { } @Override protected EJB3SubsystemNamespace getExpectedNamespace() { return EJB3SubsystemNamespace.EJB3_4_0; } protected void parseRemote(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { final int count = reader.getAttributeCount(); final PathAddress ejb3RemoteServiceAddress = SUBSYSTEM_PATH.append(SERVICE, REMOTE); ModelNode operation = Util.createAddOperation(ejb3RemoteServiceAddress); final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.CONNECTOR_REF, EJB3SubsystemXMLAttribute.THREAD_POOL_NAME); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case CLIENT_MAPPINGS_CLUSTER_NAME: EJB3RemoteResourceDefinition.CLIENT_MAPPINGS_CLUSTER_NAME.parseAndSetParameter(value, operation, reader); break; case CONNECTOR_REF: // see WFLY-13132 EJB3RemoteResourceDefinition.CONNECTORS.getParser().parseAndSetParameter(EJB3RemoteResourceDefinition.CONNECTORS, value, operation, reader); break; case THREAD_POOL_NAME: EJB3RemoteResourceDefinition.THREAD_POOL_NAME.parseAndSetParameter(value, operation, reader); break; case EXECUTE_IN_WORKER: EJB3RemoteResourceDefinition.EXECUTE_IN_WORKER.parseAndSetParameter(value, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } // each profile adds it's own operation operations.add(operation); final Set<EJB3SubsystemXMLElement> parsedElements = new HashSet<EJB3SubsystemXMLElement>(); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { EJB3SubsystemXMLElement element = EJB3SubsystemXMLElement.forName(reader.getLocalName()); switch (element) { case CHANNEL_CREATION_OPTIONS: { if (parsedElements.contains(EJB3SubsystemXMLElement.CHANNEL_CREATION_OPTIONS)) { throw unexpectedElement(reader); } parsedElements.add(EJB3SubsystemXMLElement.CHANNEL_CREATION_OPTIONS); this.parseChannelCreationOptions(reader, ejb3RemoteServiceAddress, operations); break; } case PROFILES: { parseProfiles(reader, operations); break; } default: { throw unexpectedElement(reader); } } } } @Override protected void parseMDB(final XMLExtendedStreamReader reader, List<ModelNode> operations, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { // no attributes expected requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case BEAN_INSTANCE_POOL_REF: { final String poolName = readStringAttributeElement(reader, EJB3SubsystemXMLAttribute.POOL_NAME.getLocalName()); EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_INSTANCE_POOL.parseAndSetParameter(poolName, ejb3SubsystemAddOperation, reader); break; } case RESOURCE_ADAPTER_REF: { final String resourceAdapterName = readStringAttributeElement(reader, EJB3SubsystemXMLAttribute.RESOURCE_ADAPTER_NAME.getLocalName()); EJB3SubsystemRootResourceDefinition.DEFAULT_RESOURCE_ADAPTER_NAME.parseAndSetParameter(resourceAdapterName, ejb3SubsystemAddOperation, reader); break; } case DELIVERY_GROUPS: { parseDeliveryGroups(reader, operations); break; } default: { throw unexpectedElement(reader); } } } } private void parseDeliveryGroups(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { // no attributes expected requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case DELIVERY_GROUP: { final int count = reader.getAttributeCount(); String groupName = null; final ModelNode operation = Util.createAddOperation(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: groupName = value; break; case ACTIVE: MdbDeliveryGroupResourceDefinition.ACTIVE.parseAndSetParameter(reader.getAttributeValue(i), operation, reader); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (groupName == null) { throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.NAME.getLocalName())); } // create and add the operation // create /subsystem=ejb3/mdb-delivery-group=name:add(...) final PathAddress address = SUBSYSTEM_PATH.append(EJB3SubsystemModel.MDB_DELIVERY_GROUP, groupName); operation.get(OP_ADDR).set(address.toModelNode()); operations.add(operation); break; } default: { throw unexpectedElement(reader); } } } } void parseStrictMaxPool(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { final int count = reader.getAttributeCount(); String poolName = null; final ModelNode operation = Util.createAddOperation(); boolean sizeAttribute = false; for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: poolName = value; break; case MAX_POOL_SIZE: if (sizeAttribute) { throw mutuallyExclusiveAttributes(reader); } sizeAttribute = true; StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.parseAndSetParameter(value, operation, reader); break; case DERIVE_SIZE: if (sizeAttribute) { throw mutuallyExclusiveAttributes(reader); } sizeAttribute = true; StrictMaxPoolResourceDefinition.DERIVE_SIZE.parseAndSetParameter(value, operation, reader); break; case INSTANCE_ACQUISITION_TIMEOUT: StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.parseAndSetParameter(value, operation, reader); break; case INSTANCE_ACQUISITION_TIMEOUT_UNIT: StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.parseAndSetParameter(value, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (poolName == null) { throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.NAME.getLocalName())); } // create and add the operation // create /subsystem=ejb3/strict-max-bean-instance-pool=name:add(...) final PathAddress address = this.getEJB3SubsystemAddress().append(STRICT_MAX_BEAN_INSTANCE_POOL, poolName); operation.get(OP_ADDR).set(address.toModelNode()); operations.add(operation); } private XMLStreamException mutuallyExclusiveAttributes(XMLExtendedStreamReader reader) { return EjbLogger.ROOT_LOGGER.mutuallyExclusiveAttributes(reader.getLocation(), MAX_POOL_SIZE, DERIVE_SIZE); } }
12,355
48.424
164
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/RemotingProfileChildResourceHandlerBase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.RestartParentResourceHandlerBase; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceName; public abstract class RemotingProfileChildResourceHandlerBase extends RestartParentResourceHandlerBase { protected RemotingProfileChildResourceHandlerBase() { super(EJB3SubsystemModel.REMOTING_PROFILE); } @Override protected void recreateParentService(final OperationContext context, final PathAddress parentAddress, final ModelNode parentModel) throws OperationFailedException { switch(context.getCurrentStage()) { case RUNTIME: // service installation in another step: when interruption is thrown then it is handled by RollbackHandler // declared in RestartParentResourceHandlerBase context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { RemotingProfileResourceDefinition.ADD_HANDLER.installServices(context, parentAddress, parentModel); } }, OperationContext.Stage.RUNTIME); break; case DONE: // executed from RollbackHandler - service is being installed using correct configuration RemotingProfileResourceDefinition.ADD_HANDLER.installServices(context, parentAddress, parentModel); break; } } @Override protected ServiceName getParentServiceName(PathAddress parentAddress) { return RemotingProfileResourceDefinition.REMOTING_PROFILE_CAPABILITY.getCapabilityServiceName(parentAddress); } @Override protected void removeServices(OperationContext context, ServiceName parentService, ModelNode parentModel) throws OperationFailedException { super.removeServices(context, parentService, parentModel); } }
3,232
45.185714
168
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/FileDataStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler; import org.jboss.as.controller.ServiceRemoveStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.operations.validation.ModelTypeValidator; import org.jboss.as.controller.operations.validation.StringLengthValidator; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; import org.jboss.as.controller.services.path.PathManager; import org.jboss.as.controller.services.path.ResolvePathHandler; import org.jboss.as.ejb3.timerservice.persistence.TimerPersistence; import org.jboss.dmr.ModelType; /** * {@link org.jboss.as.controller.ResourceDefinition} for the file data store */ public class FileDataStoreResourceDefinition extends SimpleResourceDefinition { public static final SimpleAttributeDefinition PATH = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.PATH, ModelType.STRING, false) .setAllowExpression(true) .setValidator(new ModelTypeValidator(ModelType.STRING, true, true)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); public static final SimpleAttributeDefinition RELATIVE_TO = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.RELATIVE_TO, ModelType.STRING, true) .setValidator(new StringLengthValidator(1, Integer.MAX_VALUE, true, false)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); private final PathManager pathManager; private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { PATH, RELATIVE_TO }; private static final FileDataStoreAdd ADD_HANDLER = new FileDataStoreAdd(ATTRIBUTES); public FileDataStoreResourceDefinition(final PathManager pathManager) { super(new SimpleResourceDefinition.Parameters(EJB3SubsystemModel.FILE_DATA_STORE_PATH, EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.FILE_DATA_STORE)) .setAddHandler(ADD_HANDLER) .setRemoveHandler(new ServiceRemoveStepHandler(TimerPersistence.SERVICE_NAME, ADD_HANDLER)) .setAddRestartLevel(OperationEntry.Flag.RESTART_ALL_SERVICES) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_ALL_SERVICES) .setCapabilities(TimerServiceResourceDefinition.TIMER_PERSISTENCE_CAPABILITY)); this.pathManager = pathManager; } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { for (AttributeDefinition attr : ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(attr, null, new ReloadRequiredWriteAttributeHandler(attr)); } } @Override public void registerOperations(final ManagementResourceRegistration resourceRegistration) { super.registerOperations(resourceRegistration); if (pathManager != null) { final ResolvePathHandler resolvePathHandler = ResolvePathHandler.Builder.of(pathManager) .setPathAttribute(PATH) .setRelativeToAttribute(RELATIVE_TO) .build(); resourceRegistration.registerOperationHandler(resolvePathHandler.getOperationDefinition(), resolvePathHandler); } } }
4,727
50.391304
176
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/FilePassivationStoreAdd.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.dmr.ModelNode; /** * @author Paul Ferraro */ @Deprecated public class FilePassivationStoreAdd extends PassivationStoreAdd { public FilePassivationStoreAdd(AttributeDefinition... attributes) { super(attributes); } @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws IllegalArgumentException, OperationFailedException { int initialMaxSize = FilePassivationStoreResourceDefinition.MAX_SIZE.resolveModelAttribute(context, model).asInt(); String containerName = PassivationStoreResourceDefinition.CACHE_CONTAINER.getDefaultValue().asString(); // despite being called file passivation store, this sets up a cache factory based on the default cache container and cache name "passivation" this.install(context, operation, initialMaxSize, containerName, "passivation"); } }
2,126
43.3125
157
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Subsystem10Parser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.List; import javax.xml.stream.XMLStreamException; import org.jboss.as.controller.parsing.ParseUtils; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLElementReader; import org.jboss.staxmapper.XMLExtendedStreamReader; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; /** * User: Jaikiran Pai */ public class EJB3Subsystem10Parser implements XMLElementReader<List<ModelNode>> { EJB3Subsystem10Parser() { } /** * {@inheritDoc} */ @Override public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException { ParseUtils.requireNoAttributes(reader); ParseUtils.requireNoContent(reader); final ModelNode ejb3Subsystem = new ModelNode(); ejb3Subsystem.get(OP).set(ADD); ejb3Subsystem.get(OP_ADDR).add(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME); list.add(ejb3Subsystem); } }
2,288
36.52459
121
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/ClientInterceptorsBindingsProcessor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.ejb3.interceptor.server.ClientInterceptorCache; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessingException; import org.jboss.as.server.deployment.DeploymentUnitProcessor; import org.jboss.ejb.client.EJBClientInterceptor; import java.util.ArrayList; import java.util.List; /** * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ public class ClientInterceptorsBindingsProcessor implements DeploymentUnitProcessor { private final ClientInterceptorCache clientInterceptorCache; public ClientInterceptorsBindingsProcessor(final ClientInterceptorCache clientInterceptorCache) { this.clientInterceptorCache = clientInterceptorCache; } @Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { try { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); List<EJBClientInterceptor> clientInterceptors = deploymentUnit.getAttachment(org.jboss.as.ejb3.subsystem.Attachments.STATIC_EJB_CLIENT_INTERCEPTORS); if (clientInterceptors == null) { clientInterceptors = new ArrayList<>(); } for (final Class<? extends EJBClientInterceptor> interceptorClass : clientInterceptorCache.getClientInterceptors()) { clientInterceptors.add(interceptorClass.newInstance()); } deploymentUnit.putAttachment(org.jboss.as.ejb3.subsystem.Attachments.STATIC_EJB_CLIENT_INTERCEPTORS, clientInterceptors); } catch (InstantiationException | IllegalAccessException e) { throw new DeploymentUnitProcessingException(e); } } }
2,881
44.746032
161
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Subsystem13Parser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS; import static org.jboss.as.controller.parsing.ParseUtils.missingRequired; import static org.jboss.as.controller.parsing.ParseUtils.requireNoContent; import static org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.REMOTE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.SERVICE; import java.util.EnumSet; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; /** */ public class EJB3Subsystem13Parser extends EJB3Subsystem12Parser { protected EJB3Subsystem13Parser() { } @Override protected void readElement(final XMLExtendedStreamReader reader, final EJB3SubsystemXMLElement element, final List<ModelNode> operations, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { switch (element) { case DEFAULT_DISTINCT_NAME: { parseDefaultDistinctName(reader, ejb3SubsystemAddOperation); break; } case STATISTICS: { parseStatistics(reader, ejb3SubsystemAddOperation); break; } default: { super.readElement(reader, element, operations, ejb3SubsystemAddOperation); } } } @Override protected EJB3SubsystemNamespace getExpectedNamespace() { return EJB3SubsystemNamespace.EJB3_1_3; } private void parseStatistics(final XMLExtendedStreamReader reader, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { final int count = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> missingRequiredAttributes = EnumSet.of(EJB3SubsystemXMLAttribute.ENABLED); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case ENABLED: EJB3SubsystemRootResourceDefinition.STATISTICS_ENABLED.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); // found the mandatory attribute missingRequiredAttributes.remove(EJB3SubsystemXMLAttribute.ENABLED); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (!missingRequiredAttributes.isEmpty()) { throw missingRequired(reader, missingRequiredAttributes); } } private void parseDefaultDistinctName(final XMLExtendedStreamReader reader, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { final int count = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> missingRequiredAttributes = EnumSet.of(EJB3SubsystemXMLAttribute.VALUE); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VALUE: EJB3SubsystemRootResourceDefinition.DEFAULT_DISTINCT_NAME.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); // found the mandatory attribute missingRequiredAttributes.remove(EJB3SubsystemXMLAttribute.VALUE); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (!missingRequiredAttributes.isEmpty()) { throw missingRequired(reader, missingRequiredAttributes); } } @Override protected void parseRemote(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { final int count = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.CONNECTOR_REF, EJB3SubsystemXMLAttribute.THREAD_POOL_NAME); final PathAddress ejb3RemoteServiceAddress = SUBSYSTEM_PATH.append(SERVICE, REMOTE); ModelNode operation = Util.createAddOperation(ejb3RemoteServiceAddress); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case CONNECTOR_REF: EJB3RemoteResourceDefinition.CONNECTOR_REF.parseAndSetParameter(value, operation, reader); break; case THREAD_POOL_NAME: EJB3RemoteResourceDefinition.THREAD_POOL_NAME.parseAndSetParameter(value, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } operation.get(EJB3SubsystemModel.EXECUTE_IN_WORKER).set(ModelNode.FALSE); operations.add(operation); // set the address for this operation final Set<EJB3SubsystemXMLElement> parsedElements = new HashSet<EJB3SubsystemXMLElement>(); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case CHANNEL_CREATION_OPTIONS: { if (parsedElements.contains(EJB3SubsystemXMLElement.CHANNEL_CREATION_OPTIONS)) { throw unexpectedElement(reader); } parsedElements.add(EJB3SubsystemXMLElement.CHANNEL_CREATION_OPTIONS); this.parseChannelCreationOptions(reader, ejb3RemoteServiceAddress, operations); break; } default: { throw unexpectedElement(reader); } } } } protected void parseChannelCreationOptions(final XMLExtendedStreamReader reader, final PathAddress address, final List<ModelNode> operations) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case OPTION: { this.parseChannelCreationOption(reader, address, operations); break; } default: { throw unexpectedElement(reader); } } } } protected void parseChannelCreationOption(final XMLExtendedStreamReader reader, final PathAddress address, final List<ModelNode> operations) throws XMLStreamException { final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.NAME, EJB3SubsystemXMLAttribute.TYPE); final int count = reader.getAttributeCount(); String optionName = null; ModelNode operation = Util.createAddOperation(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String attributeValue = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case NAME: optionName = attributeValue; break; case TYPE: RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_TYPE.parseAndSetParameter(attributeValue, operation, reader); break; case VALUE: RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE.parseAndSetParameter(attributeValue, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } // this element just supports attributes so we expect no more content requireNoContent(reader); operation.get(ADDRESS).set(address.append(EJB3SubsystemModel.CHANNEL_CREATION_OPTIONS, optionName).toModelNode()); operations.add(operation); } }
10,406
46.738532
212
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/IIOPSettingsService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.msc.service.Service; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; /** * Services that manages IIOP settings * @author Stuart Douglas */ public class IIOPSettingsService implements Service<IIOPSettingsService> { public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "iiop", "settingsService"); private volatile boolean enabledByDefault = false; private volatile boolean useQualifiedName = false; public IIOPSettingsService(final boolean enabledByDefault, final boolean useQualifiedName) { this.enabledByDefault = enabledByDefault; this.useQualifiedName = useQualifiedName; } @Override public void start(final StartContext context) throws StartException { } @Override public void stop(final StopContext context) { } @Override public IIOPSettingsService getValue() throws IllegalStateException, IllegalArgumentException { return this; } public boolean isEnabledByDefault() { return enabledByDefault; } public void setEnabledByDefault(final boolean enabledByDefault) { this.enabledByDefault = enabledByDefault; } public boolean isUseQualifiedName() { return useQualifiedName; } public void setUseQualifiedName(final boolean useQualifiedName) { this.useQualifiedName = useQualifiedName; } }
2,578
32.064103
111
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3IIOPAdd.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.ejb3.logging.EjbLogger.ROOT_LOGGER; import org.jboss.as.controller.AbstractBoottimeAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.ejb3.deployment.processors.EjbIIOPDeploymentUnitProcessor; import org.jboss.as.server.AbstractDeploymentChainStep; import org.jboss.as.server.DeploymentProcessorTarget; import org.jboss.as.server.deployment.Phase; import org.jboss.dmr.ModelNode; /** * A {@link org.jboss.as.controller.AbstractBoottimeAddStepHandler} to handle the add operation for the Jakarta Enterprise Beans * IIOP service * * @author Stuart Douglas */ public class EJB3IIOPAdd extends AbstractBoottimeAddStepHandler { EJB3IIOPAdd(AttributeDefinition... attributes) { super(attributes); } @Override protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final boolean enableByDefault = EJB3IIOPResourceDefinition.ENABLE_BY_DEFAULT.resolveModelAttribute(context, model).asBoolean(); final boolean useQualifiedName = EJB3IIOPResourceDefinition.USE_QUALIFIED_NAME.resolveModelAttribute(context, model).asBoolean(); final IIOPSettingsService settingsService = new IIOPSettingsService(enableByDefault, useQualifiedName); context.addStep(new AbstractDeploymentChainStep() { protected void execute(DeploymentProcessorTarget processorTarget) { ROOT_LOGGER.debug("Adding Jakarta Enterprise Beans IIOP support"); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_IIOP, new EjbIIOPDeploymentUnitProcessor(settingsService)); } }, OperationContext.Stage.RUNTIME); context.getCapabilityServiceTarget().addCapability(EJB3IIOPResourceDefinition.EJB3_IIOP_SETTINGS_CAPABILITY).setInstance(settingsService).install(); } }
3,133
48.746032
185
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/Attachments.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.server.deployment.AttachmentKey; import org.jboss.ejb.client.EJBClientInterceptor; import java.util.List; /** * EJB3 related attachments. * * @author <a href="mailto:[email protected]">Tomasz Adamski</a> * */ public final class Attachments { public static final AttachmentKey<List<EJBClientInterceptor>> STATIC_EJB_CLIENT_INTERCEPTORS = AttachmentKey.create(List.class); private Attachments() { } }
1,505
33.227273
132
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3UserTransactionAccessControlService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.ejb3.component.allowedmethods.AllowedMethodsInformation; import org.jboss.as.ejb3.component.allowedmethods.MethodType; import org.jboss.as.txn.service.UserTransactionAccessControl; import org.jboss.as.txn.service.UserTransactionAccessControlService; import org.jboss.msc.inject.Injector; import org.jboss.msc.service.Service; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; import org.jboss.msc.value.InjectedValue; /** * Service which installs the {@link jakarta.transaction.UserTransaction} access control into the transaction subsystem. * * @author Eduardo Martins */ public class EJB3UserTransactionAccessControlService implements Service<EJB3UserTransactionAccessControlService> { public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "EJB3UserTransactionAccessControlService"); private final InjectedValue<UserTransactionAccessControlService> accessControlService = new InjectedValue<UserTransactionAccessControlService>(); @Override public void start(StartContext context) throws StartException { UserTransactionAccessControl accessControl = new UserTransactionAccessControl() { @Override public void authorizeAccess() { AllowedMethodsInformation.checkAllowed(MethodType.GET_USER_TRANSACTION); } }; this.accessControlService.getValue().setAccessControl(accessControl); } @Override public void stop(StopContext context) { this.accessControlService.getValue().setAccessControl(null); } @Override public EJB3UserTransactionAccessControlService getValue() throws IllegalStateException, IllegalArgumentException { return this; } /** * * @return */ public Injector<UserTransactionAccessControlService> getUserTransactionAccessControlServiceInjector() { return this.accessControlService; } }
3,106
39.350649
149
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/LegacyCacheFactoryResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.StringListAttributeDefinition; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; import org.jboss.dmr.ModelType; /** * Defines a CacheFactoryBuilder instance which, during deployment, is used to configure, build and install a CacheFactory for the SFSB being deployed. * The CacheFactory resource instances defined here produce bean caches which are either: * - distributed and have passivation-enabled * - non distributed and do not have passivation-enabled * For passivation enabled CacheFactoryBuilders, the PassivationStoreResourceDefinition must define a supporting passivation store. * * @author Paul Ferraro */ @Deprecated public class LegacyCacheFactoryResourceDefinition extends SimpleResourceDefinition { // capabilities not required as although we install CacheFactoryBuilder services, these do not depend on any defined clustering resources public static final StringListAttributeDefinition ALIASES = new StringListAttributeDefinition.Builder(EJB3SubsystemModel.ALIASES) .setXmlName(EJB3SubsystemXMLAttribute.ALIASES.getLocalName()) .setRequired(false) .build(); public static final SimpleAttributeDefinition PASSIVATION_STORE = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.PASSIVATION_STORE, ModelType.STRING, true) .setXmlName(EJB3SubsystemXMLAttribute.PASSIVATION_STORE_REF.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_NONE) .build(); private static final AttributeDefinition[] ATTRIBUTES = { ALIASES, PASSIVATION_STORE }; private static final LegacyCacheFactoryAdd ADD_HANDLER = new LegacyCacheFactoryAdd(ATTRIBUTES); private static final LegacyCacheFactoryRemove REMOVE_HANDLER = new LegacyCacheFactoryRemove(ADD_HANDLER); LegacyCacheFactoryResourceDefinition() { super(new SimpleResourceDefinition.Parameters(PathElement.pathElement(EJB3SubsystemModel.CACHE), EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.CACHE)) .setAddHandler(ADD_HANDLER) .setRemoveHandler(REMOVE_HANDLER) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES)); this.setDeprecated(EJB3Model.VERSION_10_0_0.getVersion()); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { ReloadRequiredWriteAttributeHandler handler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES); for (AttributeDefinition attribute: ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(attribute, null, handler); } } }
4,276
51.158537
176
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/DatabaseDataStoreAdd.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.Timer; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.CapabilityServiceBuilder; import org.jboss.as.controller.CapabilityServiceTarget; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence; import org.jboss.as.naming.ManagedReferenceFactory; import org.jboss.as.naming.deployment.ContextNames; import org.jboss.as.server.ServerEnvironment; import org.jboss.as.server.Services; import org.jboss.dmr.ModelNode; import org.jboss.modules.ModuleLoader; import org.wildfly.security.manager.WildFlySecurityManager; /** * Adds the timer service file based data store * * @author Stuart Douglas */ public class DatabaseDataStoreAdd extends AbstractAddStepHandler { private static final String TIMER_SERVICE_CAPABILITY_NAME = "org.wildfly.ejb3.timer-service"; DatabaseDataStoreAdd(AttributeDefinition... attributes) { super(attributes); } @Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final String jndiName = DatabaseDataStoreResourceDefinition.DATASOURCE_JNDI_NAME.resolveModelAttribute(context, model).asString(); final ModelNode dataBaseValue = DatabaseDataStoreResourceDefinition.DATABASE.resolveModelAttribute(context, model); final String database; if(dataBaseValue.isDefined()) { database = dataBaseValue.asString(); } else { database = null; } final String partition = DatabaseDataStoreResourceDefinition.PARTITION.resolveModelAttribute(context, model).asString(); int refreshInterval = DatabaseDataStoreResourceDefinition.REFRESH_INTERVAL.resolveModelAttribute(context, model).asInt(); boolean allowExecution = DatabaseDataStoreResourceDefinition.ALLOW_EXECUTION.resolveModelAttribute(context, model).asBoolean(); final String nodeName = WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null); // add the TimerPersistence instance final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget(); final CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(TimerServiceResourceDefinition.TIMER_PERSISTENCE_CAPABILITY); final Consumer<DatabaseTimerPersistence> consumer = builder.provides(TimerServiceResourceDefinition.TIMER_PERSISTENCE_CAPABILITY); final Supplier<ManagedReferenceFactory> dataSourceSupplier = builder.requires(ContextNames.bindInfoFor(jndiName).getBinderServiceName()); final Supplier<ModuleLoader> moduleLoaderSupplier = builder.requires(Services.JBOSS_SERVICE_MODULE_LOADER); final Supplier<Timer> timerSupplier = builder.requiresCapability(TIMER_SERVICE_CAPABILITY_NAME, java.util.Timer.class); final DatabaseTimerPersistence databaseTimerPersistence = new DatabaseTimerPersistence(consumer, dataSourceSupplier, moduleLoaderSupplier, timerSupplier, database, partition, nodeName, refreshInterval, allowExecution); builder.setInstance(databaseTimerPersistence); builder.install(); } }
4,479
49.337079
226
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemDefaultPoolWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_MDB_INSTANCE_POOL; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_SLSB_INSTANCE_POOL; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_POOL_CONFIG_CAPABILITY; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.DEFAULT_SLSB_POOL_CONFIG_CAPABILITY; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller._private.OperationFailedRuntimeException; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.Resource; import org.jboss.as.ejb3.component.pool.PoolConfig; import org.jboss.as.ejb3.logging.EjbLogger; 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.ServiceRegistry; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StopContext; /** * User: jpai */ public class EJB3SubsystemDefaultPoolWriteHandler extends AbstractWriteAttributeHandler<Void> { private static final String STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME = "org.wildfly.ejb3.pool-config"; private static final String DEFAULT_SLSB_POOL_CONFIG_CAPABILITY_NAME = "org.wildfly.ejb3.pool-config.slsb-default"; private static final String DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME = "org.wildfly.ejb3.pool-config.mdb-default"; private static final String DEFAULT_ENTITY_POOL_CONFIG_CAPABILITY_NAME = "org.wildfly.ejb3.pool-config.entity-default"; public static final EJB3SubsystemDefaultPoolWriteHandler SLSB_POOL = new EJB3SubsystemDefaultPoolWriteHandler(DEFAULT_SLSB_POOL_CONFIG_CAPABILITY_NAME, EJB3SubsystemRootResourceDefinition.DEFAULT_SLSB_INSTANCE_POOL); public static final EJB3SubsystemDefaultPoolWriteHandler MDB_POOL = new EJB3SubsystemDefaultPoolWriteHandler(DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME, EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_INSTANCE_POOL); public static final EJB3SubsystemDefaultPoolWriteHandler ENTITY_BEAN_POOL = new EJB3SubsystemDefaultPoolWriteHandler(DEFAULT_ENTITY_POOL_CONFIG_CAPABILITY_NAME, EJB3SubsystemRootResourceDefinition.DEFAULT_ENTITY_BEAN_INSTANCE_POOL); private final String poolConfigCapabilityName; private final AttributeDefinition poolAttribute; public EJB3SubsystemDefaultPoolWriteHandler(String defaultPoolConfigCapabilityName, AttributeDefinition poolAttribute) { super(poolAttribute); this.poolConfigCapabilityName = defaultPoolConfigCapabilityName; this.poolAttribute = poolAttribute; } /* * Update the conditional capabilities for the default bean instance pools if the attribute values have changed * This write handler is registered with the EJB3SubsystemRootResource */ @Override protected void recordCapabilitiesAndRequirements(OperationContext context, AttributeDefinition attributeDefinition, ModelNode newValue, ModelNode oldValue) { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode model = resource.getModel(); // de-register the default bean instance pool capability requirement on the default bean instance pool that supports it if (poolAttribute.getName().equals(DEFAULT_SLSB_INSTANCE_POOL)) { if (oldValue.isDefined()) { // NOTE: the new value may contain an expression, so we need to resolve it first String newSLSBRequirementName = null; try { if (newValue.isDefined()) { ModelNode resolvedNewValue = context.resolveExpressions(newValue); // register the new requirement newSLSBRequirementName = RuntimeCapability.buildDynamicCapabilityName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, resolvedNewValue.asString()); context.registerAdditionalCapabilityRequirement(newSLSBRequirementName, DEFAULT_SLSB_POOL_CONFIG_CAPABILITY_NAME, DEFAULT_SLSB_INSTANCE_POOL); } } catch (OperationFailedException ofe) { // if the new value cannot be resolved, deregister the old value only (in the finally clause) EjbLogger.ROOT_LOGGER.defaultPoolExpressionCouldNotBeResolved(DEFAULT_SLSB_INSTANCE_POOL, model.get(DEFAULT_SLSB_INSTANCE_POOL).asString()); } finally { // de-register the old requirement // if running write-attribute with the same value as the existing one, de-registering the old one // would end up de-registering the new one. So de-register only if they are different. String oldSLSBRequirementName = RuntimeCapability.buildDynamicCapabilityName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, oldValue.asString()); if (!oldSLSBRequirementName.equals(newSLSBRequirementName)) { context.deregisterCapabilityRequirement(oldSLSBRequirementName, DEFAULT_SLSB_POOL_CONFIG_CAPABILITY_NAME, DEFAULT_SLSB_INSTANCE_POOL); } } } else { if (newValue.isDefined()) { try { context.registerCapability(DEFAULT_SLSB_POOL_CONFIG_CAPABILITY); } catch (OperationFailedRuntimeException e) { //ignore, the capability already registered } } } } else if (poolAttribute.getName().equals(DEFAULT_MDB_INSTANCE_POOL)) { if (oldValue.isDefined()) { // NOTE: the new value may contain an expression, so we need to resolve it first String newMDBRequirementName = null; try { if (newValue.isDefined()) { ModelNode resolvedNewValue = context.resolveExpressions(newValue); // register the new requirement newMDBRequirementName = RuntimeCapability.buildDynamicCapabilityName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, resolvedNewValue.asString()); context.registerAdditionalCapabilityRequirement(newMDBRequirementName, DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME, DEFAULT_MDB_INSTANCE_POOL); } } catch (OperationFailedException ofe) { // if the new value cannot be resolved, deregister the old value only (in the finally clause) EjbLogger.ROOT_LOGGER.defaultPoolExpressionCouldNotBeResolved(DEFAULT_MDB_INSTANCE_POOL, model.get(DEFAULT_MDB_INSTANCE_POOL).asString()); } finally { // de-register the old requirement // if running write-attribute with the same value as the existing one, de-registering the old one // would end up de-registering the new one. So de-register only if they are different. String oldMDBRequirementName = RuntimeCapability.buildDynamicCapabilityName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, oldValue.asString()); if (!oldMDBRequirementName.equals(newMDBRequirementName)) { context.deregisterCapabilityRequirement(oldMDBRequirementName, DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME, DEFAULT_MDB_INSTANCE_POOL); } } } else { if (newValue.isDefined()) { try { context.registerCapability(DEFAULT_MDB_POOL_CONFIG_CAPABILITY); } catch (OperationFailedRuntimeException e) { //ignore, the capability already registered } } } } super.recordCapabilitiesAndRequirements(context, attributeDefinition, newValue, oldValue); } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updatePoolService(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updatePoolService(context, restored); } void updatePoolService(final OperationContext context, final ModelNode model) throws OperationFailedException { final ModelNode poolName = poolAttribute.resolveModelAttribute(context, model); ServiceName poolConfigServiceName = context.getCapabilityServiceName(this.poolConfigCapabilityName, PoolConfig.class); final ServiceRegistry serviceRegistry = context.getServiceRegistry(true); ServiceController<?> existingDefaultPoolConfigService = serviceRegistry.getService(poolConfigServiceName); // if a default MDB pool is already installed, then remove it first if (existingDefaultPoolConfigService != null) { context.removeService(existingDefaultPoolConfigService); } if (poolName.isDefined()) { // now install default pool config service which points to an existing pool config service final ServiceName poolConfigDependencyServiceName = context.getCapabilityServiceName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, PoolConfig.class, poolName.asString()); final ServiceBuilder<?> sb = context.getServiceTarget().addService(poolConfigServiceName); final Consumer<PoolConfig> poolConfigConsumer = sb.provides(poolConfigServiceName); final Supplier<PoolConfig> poolConfigSupplier = sb.requires(poolConfigDependencyServiceName); sb.setInstance(new DefaultPoolConfigService(poolConfigConsumer, poolConfigSupplier)).install(); } } private static final class DefaultPoolConfigService implements Service { private final Consumer<PoolConfig> poolConfigConsumer; private final Supplier<PoolConfig> poolConfigSupplier; private DefaultPoolConfigService(final Consumer<PoolConfig> poolConfigConsumer, final Supplier<PoolConfig> poolConfigSupplier) { this.poolConfigConsumer = poolConfigConsumer; this.poolConfigSupplier = poolConfigSupplier; } @Override public void start(final StartContext startContext) { poolConfigConsumer.accept(poolConfigSupplier.get()); } @Override public void stop(final StopContext stopContext) { poolConfigConsumer.accept(null); } } }
12,595
56.254545
176
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Subsystem14Parser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.EnumSet; import java.util.List; import javax.xml.stream.XMLStreamException; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; import static org.jboss.as.controller.parsing.ParseUtils.missingRequired; import static org.jboss.as.controller.parsing.ParseUtils.requireNoContent; import static org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; /** */ public class EJB3Subsystem14Parser extends EJB3Subsystem13Parser { protected EJB3Subsystem14Parser() { } @Override protected void readElement(final XMLExtendedStreamReader reader, final EJB3SubsystemXMLElement element, final List<ModelNode> operations, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { switch (element) { case DEFAULT_SECURITY_DOMAIN: { parseDefaultSecurityDomain(reader, ejb3SubsystemAddOperation); break; } case DEFAULT_MISSING_METHOD_PERMISSIONS_DENY_ACCESS: { parseDefaultMissingMethodPermissionsDenyAccess(reader, ejb3SubsystemAddOperation); break; } default: { super.readElement(reader, element, operations, ejb3SubsystemAddOperation); } } } @Override protected EJB3SubsystemNamespace getExpectedNamespace() { return EJB3SubsystemNamespace.EJB3_1_4; } private void parseDefaultSecurityDomain(final XMLExtendedStreamReader reader, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { final int count = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> missingRequiredAttributes = EnumSet.of(EJB3SubsystemXMLAttribute.VALUE); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VALUE: EJB3SubsystemRootResourceDefinition.DEFAULT_SECURITY_DOMAIN.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); // found the mandatory attribute missingRequiredAttributes.remove(EJB3SubsystemXMLAttribute.VALUE); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (!missingRequiredAttributes.isEmpty()) { throw missingRequired(reader, missingRequiredAttributes); } } private void parseDefaultMissingMethodPermissionsDenyAccess(final XMLExtendedStreamReader reader, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { final int count = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> missingRequiredAttributes = EnumSet.of(EJB3SubsystemXMLAttribute.VALUE); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VALUE: EJB3SubsystemRootResourceDefinition.DEFAULT_MISSING_METHOD_PERMISSIONS_DENY_ACCESS.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); // found the mandatory attribute missingRequiredAttributes.remove(EJB3SubsystemXMLAttribute.VALUE); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (!missingRequiredAttributes.isEmpty()) { throw missingRequired(reader, missingRequiredAttributes); } } }
5,141
43.713043
212
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EjbNameRegexService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, 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 * 2110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.msc.service.Service; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; /** * * * @author Stuart Douglas */ public class EjbNameRegexService implements Service<EjbNameRegexService> { public static final ServiceName SERVICE_NAME = ServiceName.JBOSS.append("ejb3", "ejbNameRegex"); private volatile boolean ejbNameRegexAllowed; public EjbNameRegexService(final boolean defaultDistinctName) { this.ejbNameRegexAllowed = defaultDistinctName; } @Override public void start(final StartContext context) throws StartException { } @Override public void stop(final StopContext context) { } @Override public EjbNameRegexService getValue() throws IllegalStateException, IllegalArgumentException { return this; } public boolean isEjbNameRegexAllowed() { return ejbNameRegexAllowed; } public void setEjbNameRegexAllowed(final boolean ejbNameRegexAllowed) { this.ejbNameRegexAllowed = ejbNameRegexAllowed; } }
2,209
31.028986
100
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/RemotingProfileChildResourceRemoveHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.dmr.ModelNode; /** * @author <a href="mailto:[email protected]">Tomasz Adamski</a> **/ public class RemotingProfileChildResourceRemoveHandler extends RemotingProfileChildResourceHandlerBase{ protected void updateModel(final OperationContext context, final ModelNode operation) throws OperationFailedException { // verify that the resource exist before removing it context.readResource(PathAddress.EMPTY_ADDRESS, false); context.removeResource(PathAddress.EMPTY_ADDRESS); } }
1,743
40.52381
123
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemNamespace.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.HashMap; import java.util.Map; /** * An enumeration of the supported EJB3 subsystem namespaces * * @author Jaikiran Pai */ public enum EJB3SubsystemNamespace { // must be first UNKNOWN(null), EJB3_1_0("urn:jboss:domain:ejb3:1.0"), EJB3_1_1("urn:jboss:domain:ejb3:1.1"), EJB3_1_2("urn:jboss:domain:ejb3:1.2"), EJB3_1_3("urn:jboss:domain:ejb3:1.3"), EJB3_1_4("urn:jboss:domain:ejb3:1.4"), EJB3_1_5("urn:jboss:domain:ejb3:1.5"), EJB3_2_0("urn:jboss:domain:ejb3:2.0"), EJB3_3_0("urn:jboss:domain:ejb3:3.0"), EJB3_4_0("urn:jboss:domain:ejb3:4.0"), EJB3_5_0("urn:jboss:domain:ejb3:5.0"), EJB3_6_0("urn:jboss:domain:ejb3:6.0"), EJB3_7_0("urn:jboss:domain:ejb3:7.0"), EJB3_8_0("urn:jboss:domain:ejb3:8.0"), EJB3_9_0("urn:jboss:domain:ejb3:9.0"), EJB3_10_0("urn:jboss:domain:ejb3:10.0"); private final String name; EJB3SubsystemNamespace(final String name) { this.name = name; } /** * Get the URI of this namespace. * * @return the URI */ public String getUriString() { return name; } private static final Map<String, EJB3SubsystemNamespace> MAP; static { final Map<String, EJB3SubsystemNamespace> map = new HashMap<String, EJB3SubsystemNamespace>(); for (EJB3SubsystemNamespace namespace : values()) { final String name = namespace.getUriString(); if (name != null) map.put(name, namespace); } MAP = map; } public static EJB3SubsystemNamespace forUri(String uri) { final EJB3SubsystemNamespace element = MAP.get(uri); return element == null ? UNKNOWN : element; } }
2,771
31.232558
102
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemDefaultCacheWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.ejb3.component.stateful.cache.StatefulSessionBeanCacheProviderServiceNameProvider; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceRegistry; import org.wildfly.clustering.service.IdentityServiceConfigurator; /** * @author Paul Ferraro */ public class EJB3SubsystemDefaultCacheWriteHandler extends AbstractWriteAttributeHandler<Void> { public static final EJB3SubsystemDefaultCacheWriteHandler SFSB_CACHE = new EJB3SubsystemDefaultCacheWriteHandler(StatefulSessionBeanCacheProviderServiceNameProvider.DEFAULT_CACHE_SERVICE_NAME, EJB3SubsystemRootResourceDefinition.DEFAULT_SFSB_CACHE); public static final EJB3SubsystemDefaultCacheWriteHandler SFSB_PASSIVATION_DISABLED_CACHE = new EJB3SubsystemDefaultCacheWriteHandler(StatefulSessionBeanCacheProviderServiceNameProvider.DEFAULT_PASSIVATION_DISABLED_CACHE_SERVICE_NAME, EJB3SubsystemRootResourceDefinition.DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE); private final ServiceName serviceName; private final AttributeDefinition attribute; public EJB3SubsystemDefaultCacheWriteHandler(ServiceName serviceName, AttributeDefinition attribute) { super(attribute); this.serviceName = serviceName; this.attribute = attribute; } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateCacheService(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateCacheService(context, restored); } void updateCacheService(final OperationContext context, final ModelNode model) throws OperationFailedException { ModelNode cacheName = this.attribute.resolveModelAttribute(context, model); ServiceRegistry registry = context.getServiceRegistry(true); if (registry.getService(this.serviceName) != null) { context.removeService(this.serviceName); } if (cacheName.isDefined()) { new IdentityServiceConfigurator<>(this.serviceName, new StatefulSessionBeanCacheProviderServiceNameProvider(cacheName.asString()).getServiceName()).build(context.getServiceTarget()).install(); } } }
4,283
47.681818
204
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3IIOPResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.ReloadRequiredRemoveStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceRegistry; /** * A {@link org.jboss.as.controller.ResourceDefinition} for the EJB IIOP resource definition * <p/> * * @author Stuart Douglas */ public class EJB3IIOPResourceDefinition extends SimpleResourceDefinition { public static final String EJB3_IIOP_SETTINGS_CAPABILITY_NAME = "org.wildfly.ejb3.iiop.settings-service"; public static final RuntimeCapability<Void> EJB3_IIOP_SETTINGS_CAPABILITY = RuntimeCapability.Builder.of(EJB3_IIOP_SETTINGS_CAPABILITY_NAME, IIOPSettingsService.class).build(); static final SimpleAttributeDefinition USE_QUALIFIED_NAME = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.USE_QUALIFIED_NAME, ModelType.BOOLEAN) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_NONE) .setRequired(true) .build(); static final SimpleAttributeDefinition ENABLE_BY_DEFAULT = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.ENABLE_BY_DEFAULT, ModelType.BOOLEAN) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_NONE) .setRequired(true) .build(); private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { ENABLE_BY_DEFAULT, USE_QUALIFIED_NAME }; EJB3IIOPResourceDefinition() { super(new Parameters(EJB3SubsystemModel.IIOP_PATH, EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.IIOP)) .setAddHandler(new EJB3IIOPAdd(ATTRIBUTES)) .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE) .setCapabilities(EJB3_IIOP_SETTINGS_CAPABILITY)); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { resourceRegistration.registerReadWriteAttribute(USE_QUALIFIED_NAME, null, new AbstractIIOPSettingWriteHandler(USE_QUALIFIED_NAME) { @Override void applySetting(final IIOPSettingsService service, OperationContext context, final ModelNode model) throws OperationFailedException { final boolean value = USE_QUALIFIED_NAME.resolveModelAttribute(context, model).asBoolean(); service.setUseQualifiedName(value); } }); resourceRegistration.registerReadWriteAttribute(ENABLE_BY_DEFAULT, null, new AbstractIIOPSettingWriteHandler(ENABLE_BY_DEFAULT) { @Override void applySetting(final IIOPSettingsService service, OperationContext context, final ModelNode model) throws OperationFailedException { final boolean value = ENABLE_BY_DEFAULT.resolveModelAttribute(context, model).asBoolean(); service.setEnabledByDefault(value); } }); } private abstract static class AbstractIIOPSettingWriteHandler extends AbstractWriteAttributeHandler<Void> { public AbstractIIOPSettingWriteHandler(final AttributeDefinition attribute) { super(attribute); } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); applyModelToRuntime(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); applyModelToRuntime(context, restored); } private void applyModelToRuntime(OperationContext context, final ModelNode model) throws OperationFailedException { final ServiceRegistry serviceRegistry = context.getServiceRegistry(true); ServiceName iiopSettingsServiceName = context.getCapabilityServiceName(EJB3_IIOP_SETTINGS_CAPABILITY_NAME, IIOPSettingsService.class); ServiceController<IIOPSettingsService> controller = (ServiceController<IIOPSettingsService>) serviceRegistry.getService(iiopSettingsServiceName); if (controller != null) { IIOPSettingsService service = controller.getValue(); applySetting(service, context, model); } } abstract void applySetting(final IIOPSettingsService service, final OperationContext context, final ModelNode model) throws OperationFailedException; } }
6,794
50.870229
235
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Subsystem50Parser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.URI; import static org.jboss.as.controller.parsing.ParseUtils.missingRequired; import static org.jboss.as.controller.parsing.ParseUtils.missingRequiredElement; import static org.jboss.as.controller.parsing.ParseUtils.requireNoAttributes; import static org.jboss.as.controller.parsing.ParseUtils.requireNoContent; import static org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.APPLICATION_SECURITY_DOMAIN; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.IDENTITY; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.SERVICE; import java.util.Collections; import java.util.EnumSet; import java.util.List; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.operations.common.Util; import org.jboss.dmr.ModelNode; import org.jboss.ejb.client.EJBClientContext; import org.jboss.staxmapper.XMLExtendedStreamReader; /** * Parser for ejb3:5.0 namespace. * * @author <a href="mailto:[email protected]">Darran Lofthouse</a> * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ public class EJB3Subsystem50Parser extends EJB3Subsystem40Parser { EJB3Subsystem50Parser() { } @Override protected EJB3SubsystemNamespace getExpectedNamespace() { return EJB3SubsystemNamespace.EJB3_5_0; } @Override protected void readElement(final XMLExtendedStreamReader reader, final EJB3SubsystemXMLElement element, final List<ModelNode> operations, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { switch (element) { case APPLICATION_SECURITY_DOMAINS: { parseApplicationSecurityDomains(reader, operations); break; } case IDENTITY: { parseIdentity(reader, operations); break; } case ALLOW_EJB_NAME_REGEX: { parseAllowEjbNameRegex(reader, ejb3SubsystemAddOperation); break; } case ENABLE_GRACEFUL_TXN_SHUTDOWN: { parseEnableGracefulTxnShutdown(reader, ejb3SubsystemAddOperation); break; } default: { super.readElement(reader, element, operations, ejb3SubsystemAddOperation); } } } private void parseApplicationSecurityDomains(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { requireNoAttributes(reader); boolean applicationSecurityDomainFound = false; while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case APPLICATION_SECURITY_DOMAIN: { parseApplicationSecurityDomain(reader, operations); applicationSecurityDomainFound = true; break; } default: { throw unexpectedElement(reader); } } } if (! applicationSecurityDomainFound) { throw missingRequiredElement(reader, Collections.singleton(EJB3SubsystemXMLElement.APPLICATION_SECURITY_DOMAIN.getLocalName())); } } protected void parseApplicationSecurityDomain(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { String applicationSecurityDomain = null; ModelNode operation = Util.createAddOperation(); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String attributeValue = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: applicationSecurityDomain = attributeValue; break; case SECURITY_DOMAIN: ApplicationSecurityDomainDefinition.SECURITY_DOMAIN.parseAndSetParameter(attributeValue, operation, reader); break; case ENABLE_JACC: ApplicationSecurityDomainDefinition.ENABLE_JACC.parseAndSetParameter(attributeValue, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } if (applicationSecurityDomain == null) { throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.NAME.getLocalName())); } requireNoContent(reader); final PathAddress address = this.getEJB3SubsystemAddress().append(PathElement.pathElement(APPLICATION_SECURITY_DOMAIN, applicationSecurityDomain)); operation.get(OP_ADDR).set(address.toModelNode()); operations.add(operation); } private void parseAllowEjbNameRegex(XMLExtendedStreamReader reader, ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { final int count = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> missingRequiredAttributes = EnumSet.of(EJB3SubsystemXMLAttribute.VALUE); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VALUE: EJB3SubsystemRootResourceDefinition.ALLOW_EJB_NAME_REGEX.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); // found the mandatory attribute missingRequiredAttributes.remove(EJB3SubsystemXMLAttribute.VALUE); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (!missingRequiredAttributes.isEmpty()) { throw missingRequired(reader, missingRequiredAttributes); } } private void parseIdentity(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { final PathAddress address = this.getEJB3SubsystemAddress().append(SERVICE, IDENTITY); ModelNode addIdentity = Util.createAddOperation(address); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case OUTFLOW_SECURITY_DOMAINS: { parseAndSetParameter(IdentityResourceDefinition.OUTFLOW_SECURITY_DOMAINS, reader.getAttributeValue(i), addIdentity, reader); break; } default: { throw unexpectedAttribute(reader, i); } } } requireNoContent(reader); operations.add(addIdentity); } private void parseEnableGracefulTxnShutdown(XMLExtendedStreamReader reader, ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { final int count = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> missingRequiredAttributes = EnumSet.of(EJB3SubsystemXMLAttribute.VALUE); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VALUE: EJB3SubsystemRootResourceDefinition.ENABLE_GRACEFUL_TXN_SHUTDOWN.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); // found the mandatory attribute missingRequiredAttributes.remove(EJB3SubsystemXMLAttribute.VALUE); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (!missingRequiredAttributes.isEmpty()) { throw missingRequired(reader, missingRequiredAttributes); } } protected void parseProfile(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { final int count = reader.getAttributeCount(); String profileName = null; final EJBClientContext.Builder builder = new EJBClientContext.Builder(); final ModelNode operation = Util.createAddOperation(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: profileName = value; break; case EXCLUDE_LOCAL_RECEIVER: RemotingProfileResourceDefinition.EXCLUDE_LOCAL_RECEIVER.parseAndSetParameter(value, operation, reader); break; case LOCAL_RECEIVER_PASS_BY_VALUE: RemotingProfileResourceDefinition.LOCAL_RECEIVER_PASS_BY_VALUE.parseAndSetParameter(value, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } if (profileName == null) { throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.NAME.getLocalName())); } final PathAddress address = SUBSYSTEM_PATH.append(EJB3SubsystemModel.REMOTING_PROFILE, profileName); operation.get(OP_ADDR).set(address.toModelNode()); operations.add(operation); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case STATIC_EJB_DISCOVERY: final ModelNode staticEjb = parseStaticEjbDiscoveryType(reader); operation.get(StaticEJBDiscoveryDefinition.STATIC_EJB_DISCOVERY).set(staticEjb); break; case REMOTING_EJB_RECEIVER: { parseRemotingReceiver(reader, address, operations); break; } default: { throw unexpectedElement(reader); } } } } protected ModelNode parseStaticEjbDiscoveryType(final XMLExtendedStreamReader reader) throws XMLStreamException { ModelNode staticDiscovery = new ModelNode(); while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case MODULE: { final ModelNode ejb = new ModelNode(); final int count = reader.getAttributeCount(); String uri = null; String module = null; String app = null; String distinct = null; for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case URI: if (uri != null) { throw unexpectedAttribute(reader, i); } uri = value; StaticEJBDiscoveryDefinition.URI_AD.parseAndSetParameter(uri, ejb, reader); break; case MODULE_NAME: if (module != null) { throw unexpectedAttribute(reader, i); } module = value; StaticEJBDiscoveryDefinition.MODULE_AD.parseAndSetParameter(module, ejb, reader); break; case APP_NAME: if (app != null) { throw unexpectedAttribute(reader, i); } app = value; StaticEJBDiscoveryDefinition.APP_AD.parseAndSetParameter(app, ejb, reader); break; case DISTINCT_NAME: if (distinct != null) { throw unexpectedAttribute(reader, i); } distinct = value; StaticEJBDiscoveryDefinition.DISTINCT_AD.parseAndSetParameter(distinct, ejb, reader); break; default: throw unexpectedAttribute(reader, i); } } if (module == null) { throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.MODULE_NAME.getLocalName())); } if (uri == null) { throw missingRequired(reader, Collections.singleton(URI)); } staticDiscovery.add(ejb); requireNoContent(reader); break; } default: { throw unexpectedElement(reader); } } } return staticDiscovery; } protected static void parseAndSetParameter(AttributeDefinition ad, String value, ModelNode operation, XMLStreamReader reader) throws XMLStreamException { ad.getParser().parseAndSetParameter(ad, value, operation, reader); } }
16,254
46.949853
212
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemAdd.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.ejb3.subsystem.EJB3RemoteResourceDefinition.CONNECTOR_CAPABILITY_NAME; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.CLIENT_INTERCEPTORS; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_MDB_INSTANCE_POOL; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_RESOURCE_ADAPTER_NAME; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_SFSB_CACHE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_SLSB_INSTANCE_POOL; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.SERVER_INTERCEPTORS; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.CLUSTERED_SINGLETON_CAPABILITY; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.DEFAULT_CLUSTERED_SFSB_CACHE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_POOL_CONFIG_CAPABILITY; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.DEFAULT_SLSB_POOL_CONFIG_CAPABILITY; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemRootResourceDefinition.DEFAULT_SLSB_POOL_CONFIG_CAPABILITY_NAME; import static org.jboss.as.ejb3.subsystem.StrictMaxPoolResourceDefinition.STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME; import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; import org.jboss.as.controller.AbstractBoottimeAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.ProcessType; import org.jboss.as.controller.RunningMode; import org.jboss.as.controller.capability.CapabilityServiceSupport; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.Resource; import org.jboss.as.ejb3.clustering.SingletonBarrierService; import org.jboss.as.ejb3.deployment.DeploymentRepository; import org.jboss.as.ejb3.deployment.DeploymentRepositoryService; import org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor; import org.jboss.as.ejb3.deployment.processors.ApplicationExceptionAnnotationProcessor; import org.jboss.as.ejb3.deployment.processors.BusinessViewAnnotationProcessor; import org.jboss.as.ejb3.deployment.processors.CacheDependenciesProcessor; import org.jboss.as.ejb3.deployment.processors.DeploymentRepositoryProcessor; import org.jboss.as.ejb3.deployment.processors.DiscoveryRegistrationProcessor; import org.jboss.as.ejb3.deployment.processors.EJBClientDescriptorMetaDataProcessor; import org.jboss.as.ejb3.deployment.processors.EJBComponentSuspendDeploymentUnitProcessor; import org.jboss.as.ejb3.deployment.processors.EJBDefaultSecurityDomainProcessor; import org.jboss.as.ejb3.deployment.processors.EjbCleanUpProcessor; import org.jboss.as.ejb3.deployment.processors.EjbClientContextSetupProcessor; import org.jboss.as.ejb3.deployment.processors.EjbContextJndiBindingProcessor; import org.jboss.as.ejb3.deployment.processors.EjbDefaultDistinctNameProcessor; import org.jboss.as.ejb3.deployment.processors.EjbDependencyDeploymentUnitProcessor; import org.jboss.as.ejb3.deployment.processors.EjbJarJBossAllParser; import org.jboss.as.ejb3.deployment.processors.EjbJarParsingDeploymentUnitProcessor; import org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor; import org.jboss.as.ejb3.deployment.processors.EjbManagementDeploymentUnitProcessor; import org.jboss.as.ejb3.deployment.processors.EjbRefProcessor; import org.jboss.as.ejb3.deployment.processors.EjbResourceInjectionAnnotationProcessor; import org.jboss.as.ejb3.deployment.processors.HibernateValidatorDeploymentUnitProcessor; import org.jboss.as.ejb3.deployment.processors.IIOPJndiBindingProcessor; import org.jboss.as.ejb3.deployment.processors.ImplicitLocalViewProcessor; import org.jboss.as.ejb3.deployment.processors.MdbDeliveryDependenciesProcessor; import org.jboss.as.ejb3.deployment.processors.PassivationAnnotationParsingProcessor; import org.jboss.as.ejb3.deployment.processors.SessionBeanHomeProcessor; import org.jboss.as.ejb3.deployment.processors.StartupAwaitDeploymentUnitProcessor; import org.jboss.as.ejb3.deployment.processors.TimerServiceJndiBindingProcessor; import org.jboss.as.ejb3.deployment.processors.annotation.EjbAnnotationProcessor; import org.jboss.as.ejb3.deployment.processors.dd.AssemblyDescriptorProcessor; import org.jboss.as.ejb3.deployment.processors.dd.ContainerInterceptorBindingsDDProcessor; import org.jboss.as.ejb3.deployment.processors.dd.DeploymentDescriptorInterceptorBindingsProcessor; import org.jboss.as.ejb3.deployment.processors.dd.DeploymentDescriptorMethodProcessor; import org.jboss.as.ejb3.deployment.processors.dd.InterceptorClassDeploymentDescriptorProcessor; import org.jboss.as.ejb3.deployment.processors.dd.SecurityRoleRefDDProcessor; import org.jboss.as.ejb3.deployment.processors.dd.SessionBeanXmlDescriptorProcessor; import org.jboss.as.ejb3.deployment.processors.merging.ApplicationExceptionMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.CacheMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.ClusteredSingletonMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.ConcurrencyManagementMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.DeclareRolesMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.EjbConcurrencyMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.EjbDependsOnMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.HomeViewMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.InitMethodMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.MdbDeliveryMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.MessageDrivenBeanPoolMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.MethodPermissionsMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.MissingMethodPermissionsDenyAccessMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.RemoveMethodMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.ResourceAdaptorMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.RunAsMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.SecurityDomainMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.SecurityRolesMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.SessionBeanMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.SessionSynchronizationMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.StartupMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.StatefulTimeoutMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.StatelessSessionBeanPoolMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.TransactionAttributeMergingProcessor; import org.jboss.as.ejb3.deployment.processors.merging.TransactionManagementMergingProcessor; import org.jboss.as.ejb3.deployment.processors.security.JaccEjbDeploymentProcessor; import org.jboss.as.ejb3.iiop.POARegistry; import org.jboss.as.ejb3.iiop.RemoteObjectSubstitutionService; import org.jboss.as.ejb3.iiop.stub.DynamicStubFactoryFactory; import org.jboss.as.ejb3.interceptor.server.ClientInterceptorCache; import org.jboss.as.ejb3.interceptor.server.ServerInterceptorCache; import org.jboss.as.ejb3.interceptor.server.ServerInterceptorMetaData; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.as.ejb3.remote.AssociationService; import org.jboss.as.ejb3.remote.EJBClientContextService; import org.jboss.as.ejb3.remote.LocalTransportProvider; import org.jboss.as.ejb3.remote.http.EJB3RemoteHTTPService; import org.jboss.as.ejb3.security.ApplicationSecurityDomainConfig; import org.jboss.as.ejb3.suspend.EJBSuspendHandlerService; import org.jboss.as.network.ProtocolSocketBinding; import org.jboss.as.server.AbstractDeploymentChainStep; import org.jboss.as.server.DeploymentProcessorTarget; import org.jboss.as.server.ServerEnvironment; import org.jboss.as.server.ServerEnvironmentService; import org.jboss.as.server.deployment.Phase; import org.jboss.as.server.deployment.jbossallxml.JBossAllXmlParserRegisteringProcessor; import org.jboss.as.server.suspend.SuspendController; import org.jboss.as.txn.service.TxnServices; import org.jboss.as.txn.service.UserTransactionAccessControlService; import org.jboss.dmr.ModelNode; import org.jboss.ejb.client.EJBTransportProvider; import org.jboss.javax.rmi.RemoteObjectSubstitutionManager; import org.jboss.metadata.ejb.spec.EjbJarMetaData; import org.jboss.msc.inject.Injector; import org.jboss.msc.service.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.jboss.msc.service.StartContext; import org.jboss.msc.service.StopContext; import org.jboss.remoting3.Endpoint; import org.omg.PortableServer.POA; import org.wildfly.clustering.registry.Registry; import org.wildfly.clustering.server.service.ClusteringCacheRequirement; import org.wildfly.clustering.singleton.SingletonDefaultRequirement; import org.wildfly.clustering.singleton.service.SingletonPolicy; import org.wildfly.iiop.openjdk.rmi.DelegatingStubFactoryFactory; import org.wildfly.iiop.openjdk.service.CorbaPOAService; import org.wildfly.transaction.client.LocalTransactionContext; import io.undertow.server.handlers.PathHandler; /** * Add operation handler for the EJB3 subsystem. * * NOTE: References in this file to Enterprise JavaBeans (EJB) refer to the Jakarta Enterprise Beans unless otherwise noted. * * @author Emanuel Muckenhuber * @author <a href="mailto:[email protected]">Richard Opalka</a> */ class EJB3SubsystemAdd extends AbstractBoottimeAddStepHandler { private static final String UNDERTOW_HTTP_INVOKER_CAPABILITY_NAME = "org.wildfly.undertow.http-invoker"; private static final String REMOTING_ENDPOINT_CAPABILITY = "org.wildfly.remoting.endpoint"; private static final String LEGACY_JACC_CAPABILITY = "org.wildfly.legacy-security.jacc"; private static final String ELYTRON_JACC_CAPABILITY = "org.wildfly.security.jacc-policy"; private final AtomicReference<String> defaultSecurityDomainName; private final Iterable<ApplicationSecurityDomainConfig> knownApplicationSecurityDomains; private final Iterable<String> outflowSecurityDomains; private final AtomicBoolean denyAccessByDefault; EJB3SubsystemAdd(AtomicReference<String> defaultSecurityDomainName, Iterable<ApplicationSecurityDomainConfig> knownApplicationSecurityDomains, Iterable<String> outflowSecurityDomains, AtomicBoolean denyAccessByDefault, AttributeDefinition... attributes) { super(attributes); this.defaultSecurityDomainName = defaultSecurityDomainName; this.knownApplicationSecurityDomains = knownApplicationSecurityDomains; this.outflowSecurityDomains = outflowSecurityDomains; this.denyAccessByDefault = denyAccessByDefault; } @Override protected void populateModel(final OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { super.populateModel(context, operation, resource); ModelNode model = resource.getModel(); // WFLY-5520 deal with legacy default-clustered-sfsb-cache ModelNode defClustered = DEFAULT_CLUSTERED_SFSB_CACHE.validateOperation(operation); if (defClustered.isDefined()) { boolean setDefaultSfsbCache = true; // Assume this is a legacy script and try and adapt the params to the new attributes if (model.hasDefined(DEFAULT_SFSB_CACHE)) { if (model.hasDefined(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE)) { // All 3 params were defined. This is only ok if default-clustered-sfsb-cache and default-sfsb-cache // are the same, meaning default-clustered-sfsb-cache is redundant if (!defClustered.equals(model.get(DEFAULT_SFSB_CACHE))) { // No good. Log or fail if(context.getRunningMode() == RunningMode.ADMIN_ONLY) { EjbLogger.ROOT_LOGGER.logInconsistentAttributeNotSupported(DEFAULT_CLUSTERED_SFSB_CACHE.getName(), DEFAULT_SFSB_CACHE); setDefaultSfsbCache = false; // don't overwrite default-sfsb-cache } else { throw EjbLogger.ROOT_LOGGER.inconsistentAttributeNotSupported(DEFAULT_CLUSTERED_SFSB_CACHE.getName(), DEFAULT_SFSB_CACHE); } } } else { // The old attributes were defined; new one wasn't so, move the old default-sfsb-cache to default-passivation-disabled model.get(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE).set(model.get(DEFAULT_SFSB_CACHE)); } } if (setDefaultSfsbCache) { model.get(DEFAULT_SFSB_CACHE).set(defClustered); EjbLogger.ROOT_LOGGER.remappingCacheAttributes(context.getCurrentAddress().toCLIStyleString(), defClustered, model.get(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE)); } } } /* * Conditional registration of capabilities for default bean instance pools (which may or may not be defined) */ @Override protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { ModelNode model = resource.getModel(); // register the capability we are exporting as well as its capability requirement on the strict-max-pool that supports it if (model.hasDefined(DEFAULT_SLSB_INSTANCE_POOL)) { context.registerCapability(DEFAULT_SLSB_POOL_CONFIG_CAPABILITY); try { // need to resolve the attribute value before using it String resolvedDefaultSLSBPoolName = context.resolveExpressions(model.get(DEFAULT_SLSB_INSTANCE_POOL)).asString(); String defaultSLSBPoolRequirementName = RuntimeCapability.buildDynamicCapabilityName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, resolvedDefaultSLSBPoolName); context.registerAdditionalCapabilityRequirement(defaultSLSBPoolRequirementName, DEFAULT_SLSB_POOL_CONFIG_CAPABILITY_NAME, DEFAULT_SLSB_INSTANCE_POOL); } catch (OperationFailedException ofe) { EjbLogger.ROOT_LOGGER.defaultPoolExpressionCouldNotBeResolved(DEFAULT_SLSB_INSTANCE_POOL, model.get(DEFAULT_SLSB_INSTANCE_POOL).asString()); } } if (model.hasDefined(DEFAULT_MDB_INSTANCE_POOL)) { context.registerCapability(DEFAULT_MDB_POOL_CONFIG_CAPABILITY); try { // need to resolve the attribute value before using it String resolvedDefaultMDBPoolName = context.resolveExpressions(model.get(DEFAULT_MDB_INSTANCE_POOL)).asString(); String defaultMDBPoolRequirementName = RuntimeCapability.buildDynamicCapabilityName(STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, resolvedDefaultMDBPoolName); context.registerAdditionalCapabilityRequirement(defaultMDBPoolRequirementName, DEFAULT_MDB_POOL_CONFIG_CAPABILITY_NAME, DEFAULT_MDB_INSTANCE_POOL); } catch(OperationFailedException ofe) { EjbLogger.ROOT_LOGGER.defaultPoolExpressionCouldNotBeResolved(DEFAULT_MDB_INSTANCE_POOL, model.get(DEFAULT_MDB_INSTANCE_POOL).asString()); } } super.recordCapabilitiesAndRequirements(context, operation, resource); } @Override protected void performBoottime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { final ModelNode model = resource.getModel(); // Install the server association service final AssociationService associationService = new AssociationService(); final ServiceName suspendControllerServiceName = context.getCapabilityServiceName("org.wildfly.server.suspend-controller", SuspendController.class); final ServiceBuilder<AssociationService> associationServiceBuilder = context.getServiceTarget().addService(AssociationService.SERVICE_NAME, associationService); associationServiceBuilder.addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, associationService.getDeploymentRepositoryInjector()) .addDependency(suspendControllerServiceName, SuspendController.class, associationService.getSuspendControllerInjector()) .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, associationService.getServerEnvironmentServiceInjector()) .setInitialMode(ServiceController.Mode.LAZY); if (resource.hasChild(EJB3SubsystemModel.REMOTE_SERVICE_PATH)) { ModelNode remoteModel = resource.getChild(EJB3SubsystemModel.REMOTE_SERVICE_PATH).getModel(); String clusterName = EJB3RemoteResourceDefinition.CLIENT_MAPPINGS_CLUSTER_NAME.resolveModelAttribute(context, remoteModel).asString(); // For each connector for (ModelNode connector : EJB3RemoteResourceDefinition.CONNECTORS.resolveModelAttribute(context, remoteModel).asList()) { String connectorName = connector.asString(); Map.Entry<Injector<ProtocolSocketBinding>, Injector<Registry>> entry = associationService.addConnectorInjectors(connectorName); associationServiceBuilder.addDependency(context.getCapabilityServiceName(CONNECTOR_CAPABILITY_NAME, connectorName, ProtocolSocketBinding.class), ProtocolSocketBinding.class, entry.getKey()); associationServiceBuilder.addDependency(ClusteringCacheRequirement.REGISTRY.getServiceName(context, clusterName, connectorName), Registry.class, entry.getValue()); } } associationServiceBuilder.install(); //setup IIOP related stuff //This goes here rather than in EJB3IIOPAdd as it affects the server when it is acting as an iiop client //setup our dynamic stub factory DelegatingStubFactoryFactory.setOverriddenDynamicFactory(new DynamicStubFactoryFactory()); //setup the substitution service, that translates between ejb proxies and IIOP stubs final RemoteObjectSubstitutionService substitutionService = new RemoteObjectSubstitutionService(); context.getServiceTarget().addService(RemoteObjectSubstitutionService.SERVICE_NAME, substitutionService) .addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, substitutionService.getDeploymentRepositoryInjectedValue()) .install(); // register EJB context selector RemoteObjectSubstitutionManager.setRemoteObjectSubstitution(substitutionService); final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT; final ModelNode defaultDistinctName = EJB3SubsystemRootResourceDefinition.DEFAULT_DISTINCT_NAME.resolveModelAttribute(context, model); final DefaultDistinctNameService defaultDistinctNameService = new DefaultDistinctNameService(defaultDistinctName.isDefined() ? defaultDistinctName.asString() : null); context.getServiceTarget().addService(DefaultDistinctNameService.SERVICE_NAME, defaultDistinctNameService).install(); final ModelNode ejbNameRegex = EJB3SubsystemRootResourceDefinition.ALLOW_EJB_NAME_REGEX.resolveModelAttribute(context, model); final EjbNameRegexService ejbNameRegexService = new EjbNameRegexService(ejbNameRegex.isDefined() ? ejbNameRegex.asBoolean() : false); context.getServiceTarget().addService(EjbNameRegexService.SERVICE_NAME, ejbNameRegexService).install(); // set the default security domain name in the deployment unit processor, configured at the subsystem level final ModelNode defaultSecurityDomainModelNode = EJB3SubsystemRootResourceDefinition.DEFAULT_SECURITY_DOMAIN.resolveModelAttribute(context, model); final String defaultSecurityDomain = defaultSecurityDomainModelNode.isDefined() ? defaultSecurityDomainModelNode.asString() : null; this.defaultSecurityDomainName.set(defaultSecurityDomain); // set the default security domain name in the deployment unit processor, configured at the subsytem level final ModelNode defaultMissingMethod = EJB3SubsystemRootResourceDefinition.DEFAULT_MISSING_METHOD_PERMISSIONS_DENY_ACCESS.resolveModelAttribute(context, model); final boolean defaultMissingMethodValue = defaultMissingMethod.asBoolean(); this.denyAccessByDefault.set(defaultMissingMethodValue); final ModelNode defaultStatefulSessionTimeout = EJB3SubsystemRootResourceDefinition.DEFAULT_STATEFUL_BEAN_SESSION_TIMEOUT.resolveModelAttribute(context, model); final AtomicLong defaultTimeout = defaultStatefulSessionTimeout.isDefined() ? new AtomicLong(defaultStatefulSessionTimeout.asLong()) : DefaultStatefulBeanSessionTimeoutWriteHandler.INITIAL_TIMEOUT_VALUE; final ValueService defaultStatefulSessionTimeoutService = new ValueService(defaultTimeout); context.getServiceTarget().addService(DefaultStatefulBeanSessionTimeoutWriteHandler.SERVICE_NAME, defaultStatefulSessionTimeoutService).install(); final boolean defaultMdbPoolAvailable = model.hasDefined(DEFAULT_MDB_INSTANCE_POOL); final boolean defaultSlsbPoolAvailable = model.hasDefined(DEFAULT_SLSB_INSTANCE_POOL); CapabilityServiceSupport capabilitySupport = context.getCapabilityServiceSupport(); final boolean elytronJacc = capabilitySupport.hasCapability(ELYTRON_JACC_CAPABILITY); final boolean legacyJacc = !elytronJacc && capabilitySupport.hasCapability(LEGACY_JACC_CAPABILITY); context.addStep(new AbstractDeploymentChainStep() { @Override protected void execute(DeploymentProcessorTarget processorTarget) { //DUP's that are used even for app client deployments processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_REGISTER_JBOSS_ALL_EJB, new JBossAllXmlParserRegisteringProcessor<EjbJarMetaData>(EjbJarJBossAllParser.ROOT_ELEMENT, EjbJarJBossAllParser.ATTACHMENT_KEY, new EjbJarJBossAllParser())); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_DEFAULT_DISTINCT_NAME, new EjbDefaultDistinctNameProcessor(defaultDistinctNameService)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_CONTEXT_BINDING, new EjbContextJndiBindingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_DEPLOYMENT, new EjbJarParsingDeploymentUnitProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_CREATE_COMPONENT_DESCRIPTIONS, new AnnotatedEJBComponentDescriptionDeploymentUnitProcessor(appclient, defaultMdbPoolAvailable, defaultSlsbPoolAvailable)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_SESSION_BEAN_DD, new SessionBeanXmlDescriptorProcessor(appclient)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_ANNOTATION_EJB, new EjbAnnotationProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_INJECTION_ANNOTATION, new EjbResourceInjectionAnnotationProcessor(appclient)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_ASSEMBLY_DESC_DD, new AssemblyDescriptorProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_EJB, new EjbDependencyDeploymentUnitProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_HOME_MERGE, new HomeViewMergingProcessor(appclient)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_REF, new EjbRefProcessor(appclient)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_BUSINESS_VIEW_ANNOTATION, new BusinessViewAnnotationProcessor(appclient)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_ORB_BIND, new IIOPJndiBindingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_JNDI_BINDINGS, new EjbJndiBindingsDeploymentUnitProcessor(appclient)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_CLIENT_METADATA, new EJBClientDescriptorMetaDataProcessor(appclient)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_DISCOVERY, new DiscoveryRegistrationProcessor(appclient)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_DEFAULT_SECURITY_DOMAIN, new EJBDefaultSecurityDomainProcessor(EJB3SubsystemAdd.this.defaultSecurityDomainName, EJB3SubsystemAdd.this.knownApplicationSecurityDomains, EJB3SubsystemAdd.this.outflowSecurityDomains)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EE_COMPONENT_SUSPEND, new EJBComponentSuspendDeploymentUnitProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EE_COMPONENT_SUSPEND + 1, new EjbClientContextSetupProcessor()); //TODO: real phase numbers processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EE_COMPONENT_SUSPEND + 2, new StartupAwaitDeploymentUnitProcessor()); if (legacyJacc || elytronJacc) { processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_EJB_JACC_PROCESSING, new JaccEjbDeploymentProcessor(elytronJacc ? ELYTRON_JACC_CAPABILITY : LEGACY_JACC_CAPABILITY)); } processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.CLEANUP, Phase.CLEANUP_EJB, new EjbCleanUpProcessor()); if (!appclient) { // add the metadata parser deployment processor // Process @DependsOn after the @Singletons have been registered. processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_TIMERSERVICE_BINDING, new TimerServiceJndiBindingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_APPLICATION_EXCEPTION_ANNOTATION, new ApplicationExceptionAnnotationProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_DD_INTERCEPTORS, new InterceptorClassDeploymentDescriptorProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_SECURITY_ROLE_REF_DD, new SecurityRoleRefDDProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_PASSIVATION_ANNOTATION, new PassivationAnnotationParsingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_IMPLICIT_NO_INTERFACE_VIEW, new ImplicitLocalViewProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_APPLICATION_EXCEPTIONS, new ApplicationExceptionMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_DD_INTERCEPTORS, new DeploymentDescriptorInterceptorBindingsProcessor(ejbNameRegexService)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_DD_METHOD_RESOLUTION, new DeploymentDescriptorMethodProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_TRANSACTION_MANAGEMENT, new TransactionManagementMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_CONCURRENCY_MANAGEMENT_MERGE, new ConcurrencyManagementMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_CONCURRENCY_MERGE, new EjbConcurrencyMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_TX_ATTR_MERGE, new TransactionAttributeMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_RUN_AS_MERGE, new RunAsMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_RESOURCE_ADAPTER_MERGE, new ResourceAdaptorMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_CLUSTERED, new ClusteredSingletonMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_DELIVERY_ACTIVE_MERGE, new MdbDeliveryMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_REMOVE_METHOD, new RemoveMethodMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_STARTUP_MERGE, new StartupMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SECURITY_DOMAIN, new SecurityDomainMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SECURITY_MISSING_METHOD_PERMISSIONS, new MissingMethodPermissionsDenyAccessMergingProcessor(EJB3SubsystemAdd.this.denyAccessByDefault)); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_ROLES, new DeclareRolesMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_METHOD_PERMISSIONS, new MethodPermissionsMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_STATEFUL_TIMEOUT, new StatefulTimeoutMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SESSION_SYNCHRONIZATION, new SessionSynchronizationMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_INIT_METHOD, new InitMethodMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SESSION_BEAN, new SessionBeanMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SECURITY_PRINCIPAL_ROLE_MAPPING_MERGE, new SecurityRolesMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_LOCAL_HOME, new SessionBeanHomeProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_CACHE, new CacheMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SLSB_POOL_NAME_MERGE, new StatelessSessionBeanPoolMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_MDB_POOL_NAME_MERGE, new MessageDrivenBeanPoolMergingProcessor()); // Add the deployment unit processor responsible for processing the user application specific container interceptors configured in jboss-ejb3.xml processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_USER_APP_SPECIFIC_CONTAINER_INTERCEPTORS, new ContainerInterceptorBindingsDDProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_HIBERNATE_VALIDATOR, new HibernateValidatorDeploymentUnitProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_DEPENDS_ON_ANNOTATION, new EjbDependsOnMergingProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_DEPLOYMENT_REPOSITORY, new DeploymentRepositoryProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_EJB_MANAGEMENT_RESOURCES, new EjbManagementDeploymentUnitProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_CACHE_DEPENDENCIES, new CacheDependenciesProcessor()); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_EE_MODULE_CONFIG + 1, new MdbDeliveryDependenciesProcessor()); // TODO Phase: replace by Phase.INSTALL_MDB_DELIVERY_DEPENDENCIES if (model.hasDefined(SERVER_INTERCEPTORS)) { final List<ServerInterceptorMetaData> serverInterceptors = new ArrayList<>(); final ModelNode serverInterceptorsNode = model.get(SERVER_INTERCEPTORS); for (final ModelNode serverInterceptor : serverInterceptorsNode.asList()) { serverInterceptors.add(new ServerInterceptorMetaData(serverInterceptor.get("module").asString(), serverInterceptor.get("class").asString())); } processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_EJB_SERVER_INTERCEPTORS, new StaticInterceptorsDependenciesDeploymentUnitProcessor(serverInterceptors)); final ServerInterceptorCache serverInterceptorCache = new ServerInterceptorCache(serverInterceptors); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SERVER_INTERCEPTORS, new ServerInterceptorsBindingsProcessor(serverInterceptorCache)); } processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_GLOBAL_CLIENT_INTERCEPTORS, new IdentityInterceptorProcessor()); if (model.hasDefined(CLIENT_INTERCEPTORS)) { final List<ServerInterceptorMetaData> clientInterceptors = new ArrayList<>(); final ModelNode clientInterceptorsNode = model.get(CLIENT_INTERCEPTORS); for (final ModelNode clientInterceptor : clientInterceptorsNode.asList()) { clientInterceptors.add(new ServerInterceptorMetaData(clientInterceptor.get("module").asString(), clientInterceptor.get("class").asString())); } processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_EJB_SERVER_INTERCEPTORS, new StaticInterceptorsDependenciesDeploymentUnitProcessor(clientInterceptors)); final ClientInterceptorCache clientInterceptorCache = new ClientInterceptorCache(clientInterceptors); processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SERVER_INTERCEPTORS, new ClientInterceptorsBindingsProcessor(clientInterceptorCache)); } } } }, OperationContext.Stage.RUNTIME); //todo maybe needs EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_INSTANCE_POOL.resolveModelAttribute(context,model).isDefined() if (model.hasDefined(DEFAULT_MDB_INSTANCE_POOL)) { EJB3SubsystemDefaultPoolWriteHandler.MDB_POOL.updatePoolService(context, model); } if (model.hasDefined(DEFAULT_SLSB_INSTANCE_POOL)) { EJB3SubsystemDefaultPoolWriteHandler.SLSB_POOL.updatePoolService(context, model); } if (model.hasDefined(DEFAULT_SFSB_CACHE)) { EJB3SubsystemDefaultCacheWriteHandler.SFSB_CACHE.updateCacheService(context, model); } if (model.hasDefined(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE)) { EJB3SubsystemDefaultCacheWriteHandler.SFSB_PASSIVATION_DISABLED_CACHE.updateCacheService(context, model); } if (model.hasDefined(DEFAULT_RESOURCE_ADAPTER_NAME)) { DefaultResourceAdapterWriteHandler.INSTANCE.updateDefaultAdapterService(context, model); } if (model.hasDefined(DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT)) { DefaultSingletonBeanAccessTimeoutWriteHandler.INSTANCE.updateOrCreateDefaultSingletonBeanAccessTimeoutService(context, model); } if (model.hasDefined(DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT)) { DefaultStatefulBeanAccessTimeoutWriteHandler.INSTANCE.updateOrCreateDefaultStatefulBeanAccessTimeoutService(context, model); } if (model.hasDefined(DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING)) { EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler.INSTANCE.updateOptimisticLocking(context, model); } ExceptionLoggingWriteHandler.INSTANCE.updateOrCreateDefaultExceptionLoggingEnabledService(context, model); final ServiceTarget serviceTarget = context.getServiceTarget(); context.getServiceTarget().addService(DeploymentRepositoryService.SERVICE_NAME, new DeploymentRepositoryService()).install(); addRemoteInvocationServices(context, model, appclient); // add clustering service addClusteringServices(context, appclient); // add user transaction access control service final EJB3UserTransactionAccessControlService userTxAccessControlService = new EJB3UserTransactionAccessControlService(); context.getServiceTarget().addService(EJB3UserTransactionAccessControlService.SERVICE_NAME, userTxAccessControlService) .addDependency(UserTransactionAccessControlService.SERVICE_NAME, UserTransactionAccessControlService.class, userTxAccessControlService.getUserTransactionAccessControlServiceInjector()) .install(); // add ejb suspend handler service boolean enableGracefulShutdown = EJB3SubsystemRootResourceDefinition.ENABLE_GRACEFUL_TXN_SHUTDOWN.resolveModelAttribute(context, model).asBoolean(); final EJBSuspendHandlerService ejbSuspendHandlerService = new EJBSuspendHandlerService(enableGracefulShutdown); context.getServiceTarget().addService(EJBSuspendHandlerService.SERVICE_NAME, ejbSuspendHandlerService) .addDependency(suspendControllerServiceName, SuspendController.class, ejbSuspendHandlerService.getSuspendControllerInjectedValue()) .addDependency(TxnServices.JBOSS_TXN_LOCAL_TRANSACTION_CONTEXT, LocalTransactionContext.class, ejbSuspendHandlerService.getLocalTransactionContextInjectedValue()) .addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, ejbSuspendHandlerService.getDeploymentRepositoryInjectedValue()) .install(); if (!appclient) { // create the POA Registry use by iiop final POARegistry poaRegistry = new POARegistry(); context.getServiceTarget().addService(POARegistry.SERVICE_NAME, poaRegistry) .addDependency(CorbaPOAService.ROOT_SERVICE_NAME, POA.class, poaRegistry.getRootPOA()) .setInitialMode(ServiceController.Mode.PASSIVE) .install(); StatisticsEnabledWriteHandler.INSTANCE.updateToRuntime(context, model); if(context.hasOptionalCapability(UNDERTOW_HTTP_INVOKER_CAPABILITY_NAME, EJB3SubsystemRootResourceDefinition.EJB_CAPABILITY.getName(), null)) { EJB3RemoteHTTPService service = new EJB3RemoteHTTPService(FilterSpecClassResolverFilter.getFilterForOperationContext(context)); context.getServiceTarget().addService(EJB3RemoteHTTPService.SERVICE_NAME, service) .addDependency(context.getCapabilityServiceName(UNDERTOW_HTTP_INVOKER_CAPABILITY_NAME, PathHandler.class), PathHandler.class, service.getPathHandlerInjectedValue()) .addDependency(TxnServices.JBOSS_TXN_LOCAL_TRANSACTION_CONTEXT, LocalTransactionContext.class, service.getLocalTransactionContextInjectedValue()) .addDependency(AssociationService.SERVICE_NAME, AssociationService.class, service.getAssociationServiceInjectedValue()) .setInitialMode(ServiceController.Mode.PASSIVE) .install(); } } } private static void addRemoteInvocationServices(final OperationContext context, final ModelNode ejbSubsystemModel, final boolean appclient) throws OperationFailedException { final ServiceTarget serviceTarget = context.getServiceTarget(); //add the default EjbClientContext final EJBClientConfiguratorService clientConfiguratorService = new EJBClientConfiguratorService(); final ServiceBuilder<EJBClientConfiguratorService> configuratorBuilder = serviceTarget.addService(EJBClientConfiguratorService.SERVICE_NAME, clientConfiguratorService); if(context.hasOptionalCapability(REMOTING_ENDPOINT_CAPABILITY, EJB3SubsystemRootResourceDefinition.EJB_CLIENT_CONFIGURATOR_CAPABILITY.getName(), null)) { ServiceName serviceName = context.getCapabilityServiceName(REMOTING_ENDPOINT_CAPABILITY, Endpoint.class); configuratorBuilder.addDependency(serviceName, Endpoint.class, clientConfiguratorService.getEndpointInjector()); } configuratorBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install(); //TODO: This should be managed final EJBClientContextService clientContextService = new EJBClientContextService(true); final ServiceBuilder<EJBClientContextService> clientContextServiceBuilder = context.getServiceTarget().addService(EJBClientContextService.DEFAULT_SERVICE_NAME, clientContextService); clientContextServiceBuilder.addDependency(EJBClientConfiguratorService.SERVICE_NAME, EJBClientConfiguratorService.class, clientContextService.getConfiguratorServiceInjector()); if(appclient) { clientContextServiceBuilder.addDependency(EJBClientContextService.APP_CLIENT_URI_SERVICE_NAME, URI.class, clientContextService.getAppClientUri()); clientContextServiceBuilder.addDependency(EJBClientContextService.APP_CLIENT_EJB_PROPERTIES_SERVICE_NAME, String.class, clientContextService.getAppClientEjbProperties()); } if (!appclient) { //the default spec compliant EJB receiver final LocalTransportProvider byValueLocalEjbReceiver = new LocalTransportProvider(false); ServiceBuilder<LocalTransportProvider> byValueServiceBuilder = serviceTarget.addService(LocalTransportProvider.BY_VALUE_SERVICE_NAME, byValueLocalEjbReceiver) .addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, byValueLocalEjbReceiver.getDeploymentRepository()) .setInitialMode(ServiceController.Mode.ON_DEMAND); byValueServiceBuilder.install(); //the receiver for invocations that allow pass by reference final LocalTransportProvider byReferenceLocalEjbReceiver = new LocalTransportProvider(true); ServiceBuilder<LocalTransportProvider> byReferenceServiceBuilder = serviceTarget.addService(LocalTransportProvider.BY_REFERENCE_SERVICE_NAME, byReferenceLocalEjbReceiver) .addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, byReferenceLocalEjbReceiver.getDeploymentRepository()) .setInitialMode(ServiceController.Mode.ON_DEMAND); byReferenceServiceBuilder.install(); // setup the default local ejb receiver service EJBRemoteInvocationPassByValueWriteHandler.INSTANCE.updateDefaultLocalEJBReceiverService(context, ejbSubsystemModel); // add the default local ejb receiver to the client context clientContextServiceBuilder.addDependency(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME, EJBTransportProvider.class, clientContextService.getLocalProviderInjector()); } // install the default EJB client context service clientContextServiceBuilder.install(); } private static void addClusteringServices(final OperationContext context, final boolean appclient) { ServiceTarget target = context.getServiceTarget(); if (appclient) { return; } if (context.hasOptionalCapability(SingletonDefaultRequirement.POLICY.getName(), CLUSTERED_SINGLETON_CAPABILITY.getName(), null)) { ServiceBuilder<?> builder = target.addService(SingletonBarrierService.SERVICE_NAME); Supplier<SingletonPolicy> policy = builder.requires(context.getCapabilityServiceName(SingletonDefaultRequirement.POLICY.getName(), SingletonDefaultRequirement.POLICY.getType())); builder.setInstance(new SingletonBarrierService(policy)).setInitialMode(ServiceController.Mode.ON_DEMAND).install(); } } private static final class ValueService implements Service<AtomicLong> { private final AtomicLong value; public ValueService(final AtomicLong value) { this.value = value; } public void start(final StartContext context) { // noop } public void stop(final StopContext context) { // noop } public AtomicLong getValue() throws IllegalStateException { return value; } } }
49,883
78.055468
340
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3AsyncResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ReloadRequiredRemoveStepHandler; import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.threads.ThreadsServices; import org.jboss.dmr.ModelType; import java.util.concurrent.ExecutorService; /** * A {@link org.jboss.as.controller.ResourceDefinition} for the Jakarta Enterprise Beans async service * <p/> * @author Stuart Douglas */ public class EJB3AsyncResourceDefinition extends SimpleResourceDefinition { // this is an unregistered copy of the capability defined and registered in /subsystem=ejb3/thread-pool=* // needed due to the unorthodox way in which the thread pools are defined in ejb3 subsystem protected static final String THREAD_POOL_CAPABILITY_NAME = ThreadsServices.createCapability(EJB3SubsystemModel.BASE_EJB_THREAD_POOL_NAME, ExecutorService.class).getName(); public static final String ASYNC_SERVICE_CAPABILITY_NAME = "org.wildfly.ejb3.async"; public static final RuntimeCapability<Void> ASYNC_SERVICE_CAPABILITY = RuntimeCapability.Builder.of(ASYNC_SERVICE_CAPABILITY_NAME).build(); static final SimpleAttributeDefinition THREAD_POOL_NAME = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.THREAD_POOL_NAME, ModelType.STRING, true) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setCapabilityReference(THREAD_POOL_CAPABILITY_NAME, ASYNC_SERVICE_CAPABILITY) .build(); private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { THREAD_POOL_NAME }; EJB3AsyncResourceDefinition() { super(new Parameters(EJB3SubsystemModel.ASYNC_SERVICE_PATH, EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.ASYNC)) .setAddHandler(new EJB3AsyncServiceAdd(ATTRIBUTES)) .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE) .setCapabilities(ASYNC_SERVICE_CAPABILITY)); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { for (AttributeDefinition attr : ATTRIBUTES) { // TODO: Make this RESTART_NONE by updating AsynchronousMergingProcessor resourceRegistration.registerReadWriteAttribute(attr, null, new ReloadRequiredWriteAttributeHandler(attr)); } } }
3,891
48.897436
176
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/DefaultSessionBeanAccessTimeoutWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.ejb3.component.DefaultAccessTimeoutService; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceRegistry; /** * @author Stuart Douglas */ public class DefaultSessionBeanAccessTimeoutWriteHandler extends AbstractWriteAttributeHandler<Void> { private final AttributeDefinition attribute; private final ServiceName serviceName; public DefaultSessionBeanAccessTimeoutWriteHandler(final AttributeDefinition attribute, final ServiceName serviceName) { super(attribute); this.attribute = attribute; this.serviceName = serviceName; } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); applyModelToRuntime(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); applyModelToRuntime(context, restored); } private void applyModelToRuntime(OperationContext context, final ModelNode model) throws OperationFailedException { long timeout = attribute.resolveModelAttribute(context, model).asLong(); final ServiceRegistry serviceRegistry = context.getServiceRegistry(true); ServiceController<DefaultAccessTimeoutService> controller = (ServiceController<DefaultAccessTimeoutService>) serviceRegistry.getService(serviceName); if (controller != null) { DefaultAccessTimeoutService service = controller.getValue(); if (service != null) { service.setDefaultAccessTimeout(timeout); } } } }
3,550
44.525641
231
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3SubsystemXMLAttribute.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.HashMap; import java.util.Map; /** * @author Jaikiran Pai * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ public enum EJB3SubsystemXMLAttribute { UNKNOWN(null), ALIAS("alias"), @Deprecated ALIASES("aliases"), ALLOW_EXECUTION("allow-execution"), @Deprecated BEAN_CACHE("bean-cache"), BEAN_MANAGEMENT("bean-management"), @Deprecated CACHE_CONTAINER("cache-container"), CACHE_REF("cache-ref"), CLIENT_MAPPINGS_CLUSTER_NAME("cluster"), @Deprecated CLIENT_MAPPINGS_CACHE("client-mappings-cache"), @Deprecated CLUSTERED_CACHE_REF("clustered-cache-ref"), CONNECT_TIMEOUT("connect-timeout"), @Deprecated CONNECTOR_REF("connector-ref"), CONNECTORS("connectors"), CORE_THREADS("core-threads"), DEFAULT_ACCESS_TIMEOUT("default-access-timeout"), DEFAULT_SESSION_TIMEOUT("default-session-timeout"), DEFAULT_DATA_STORE("default-data-store"), DEFAULT_PERSISTENT_TIMER_MANAGEMENT(EJB3SubsystemModel.DEFAULT_PERSISTENT_TIMER_MANAGEMENT), DEFAULT_TRANSIENT_TIMER_MANAGEMENT(EJB3SubsystemModel.DEFAULT_TRANSIENT_TIMER_MANAGEMENT), DATABASE("database"), DATASOURCE_JNDI_NAME("datasource-jndi-name"), ENABLED("enabled"), ENABLE_BY_DEFAULT("enable-by-default"), EXCLUDE_LOCAL_RECEIVER("exclude-local-receiver"), @Deprecated GROUPS_PATH("groups-path"), @Deprecated IDLE_TIMEOUT("idle-timeout"), @Deprecated IDLE_TIMEOUT_UNIT("idle-timeout-unit"), INSTANCE_ACQUISITION_TIMEOUT("instance-acquisition-timeout"), INSTANCE_ACQUISITION_TIMEOUT_UNIT("instance-acquisition-timeout-unit"), KEEPALIVE_TIME("keepalive-time"), LOCAL_RECEIVER_PASS_BY_VALUE("local-receiver-pass-by-value"), MAX_POOL_SIZE("max-pool-size"), MAX_SIZE("max-size"), DERIVE_SIZE("derive-size"), MAX_THREADS("max-threads"), NAME("name"), OUTBOUND_CONNECTION_REF("outbound-connection-ref"), PARTITION("partition"), REFRESH_INTERVAL("refresh-interval"), PASS_BY_VALUE("pass-by-value"), @Deprecated PASSIVATE_EVENTS_ON_REPLICATE("passivate-events-on-replicate"), PASSIVATION_DISABLED_CACHE_REF("passivation-disabled-cache-ref"), @Deprecated PASSIVATION_STORE_REF("passivation-store-ref"), PATH("path"), POOL_NAME("pool-name"), RELATIVE_TO("relative-to"), RESOURCE_ADAPTER_NAME("resource-adapter-name"), @Deprecated SESSIONS_PATH("sessions-path"), STATIC_URLS("static-urls"), @Deprecated SUBDIRECTORY_COUNT("subdirectory-count"), THREAD_POOL_NAME("thread-pool-name"), TYPE("type"), USE_QUALIFIED_NAME("use-qualified-name"), VALUE("value"), ACTIVE("active"), EXECUTE_IN_WORKER("execute-in-worker"), // Elytron integration OUTFLOW_SECURITY_DOMAINS("outflow-security-domains"), SECURITY_DOMAIN("security-domain"), ENABLE_JACC("enable-jacc"), URI("uri"), APP_NAME("app-name"), MODULE_NAME("module-name"), DISTINCT_NAME("distinct-name"), LEGACY_COMPLIANT_PRINCIPAL_PROPAGATION("legacy-compliant-principal-propagation"), // server interceptors MODULE("module"), CLASS("class"), BINDING("binding") ; private final String name; EJB3SubsystemXMLAttribute(final String name) { this.name = name; } /** * Get the local name of this attribute. * * @return the local name */ public String getLocalName() { return name; } private static final Map<String, EJB3SubsystemXMLAttribute> MAP; static { final Map<String, EJB3SubsystemXMLAttribute> map = new HashMap<String, EJB3SubsystemXMLAttribute>(); for (EJB3SubsystemXMLAttribute element : values()) { final String name = element.getLocalName(); if (name != null) map.put(name, element); } MAP = map; } public static EJB3SubsystemXMLAttribute forName(String localName) { final EJB3SubsystemXMLAttribute element = MAP.get(localName); return element == null ? UNKNOWN : element; } @Override public String toString() { return getLocalName(); } }
5,217
30.817073
108
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/DatabaseDataStoreResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler; import org.jboss.as.controller.ServiceRemoveStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.operations.validation.ModelTypeValidator; import org.jboss.as.controller.operations.validation.StringLengthValidator; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.ejb3.timerservice.persistence.TimerPersistence; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * {@link org.jboss.as.controller.ResourceDefinition} for the database data store resource. * */ public class DatabaseDataStoreResourceDefinition extends SimpleResourceDefinition { public static final SimpleAttributeDefinition DATASOURCE_JNDI_NAME = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.DATASOURCE_JNDI_NAME, ModelType.STRING, false) .setAllowExpression(true) .setValidator(new ModelTypeValidator(ModelType.STRING, true, false)) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); public static final SimpleAttributeDefinition DATABASE = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.DATABASE, ModelType.STRING, true) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); public static final SimpleAttributeDefinition PARTITION = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.PARTITION, ModelType.STRING, true) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .setDefaultValue(new ModelNode("default")) .setValidator(new StringLengthValidator(0)) .build(); public static final SimpleAttributeDefinition REFRESH_INTERVAL = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.REFRESH_INTERVAL, ModelType.INT, true) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .setDefaultValue(new ModelNode(-1)) .build(); public static final SimpleAttributeDefinition ALLOW_EXECUTION = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.ALLOW_EXECUTION, ModelType.BOOLEAN, true) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .setDefaultValue(ModelNode.TRUE) .build(); private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { DATASOURCE_JNDI_NAME, DATABASE, PARTITION, REFRESH_INTERVAL, ALLOW_EXECUTION }; private static final DatabaseDataStoreAdd ADD_HANDLER = new DatabaseDataStoreAdd(ATTRIBUTES); DatabaseDataStoreResourceDefinition() { super(new SimpleResourceDefinition.Parameters(EJB3SubsystemModel.DATABASE_DATA_STORE_PATH, EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.DATABASE_DATA_STORE)) .setAddHandler(ADD_HANDLER) .setRemoveHandler(new ServiceRemoveStepHandler(TimerPersistence.SERVICE_NAME, ADD_HANDLER)) .setCapabilities(TimerServiceResourceDefinition.TIMER_PERSISTENCE_CAPABILITY)); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { for (AttributeDefinition attr : ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(attr, null, new ReloadRequiredWriteAttributeHandler(attr)); } } }
5,036
50.397959
184
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Extension.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.Extension; import org.jboss.as.controller.ExtensionContext; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.ResourceDefinition; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.SimpleResourceDefinition.Parameters; import org.jboss.as.controller.SubsystemRegistration; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.descriptions.ResourceDescriptionResolver; import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver; import org.jboss.as.controller.parsing.ExtensionParsingContext; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.services.path.PathManager; import org.jboss.as.ejb3.subsystem.deployment.MessageDrivenBeanResourceDefinition; import org.jboss.as.ejb3.subsystem.deployment.SingletonBeanDeploymentResourceDefinition; import org.jboss.as.ejb3.subsystem.deployment.StatefulSessionBeanDeploymentResourceDefinition; import org.jboss.as.ejb3.subsystem.deployment.StatelessSessionBeanDeploymentResourceDefinition; /** * Extension that provides the EJB3 subsystem. * * @author Emanuel Muckenhuber * @author Brian Stansberry (c) 2011 Red Hat Inc. */ public class EJB3Extension implements Extension { public static final String SUBSYSTEM_NAME = "ejb3"; public static final String NAMESPACE_1_0 = EJB3SubsystemNamespace.EJB3_1_0.getUriString(); public static final String NAMESPACE_1_1 = EJB3SubsystemNamespace.EJB3_1_1.getUriString(); public static final String NAMESPACE_1_2 = EJB3SubsystemNamespace.EJB3_1_2.getUriString(); public static final String NAMESPACE_1_3 = EJB3SubsystemNamespace.EJB3_1_3.getUriString(); public static final String NAMESPACE_1_4 = EJB3SubsystemNamespace.EJB3_1_4.getUriString(); public static final String NAMESPACE_1_5 = EJB3SubsystemNamespace.EJB3_1_5.getUriString(); public static final String NAMESPACE_2_0 = EJB3SubsystemNamespace.EJB3_2_0.getUriString(); public static final String NAMESPACE_3_0 = EJB3SubsystemNamespace.EJB3_3_0.getUriString(); public static final String NAMESPACE_4_0 = EJB3SubsystemNamespace.EJB3_4_0.getUriString(); public static final String NAMESPACE_5_0 = EJB3SubsystemNamespace.EJB3_5_0.getUriString(); public static final String NAMESPACE_6_0 = EJB3SubsystemNamespace.EJB3_6_0.getUriString(); public static final String NAMESPACE_7_0 = EJB3SubsystemNamespace.EJB3_7_0.getUriString(); public static final String NAMESPACE_8_0 = EJB3SubsystemNamespace.EJB3_8_0.getUriString(); public static final String NAMESPACE_9_0 = EJB3SubsystemNamespace.EJB3_9_0.getUriString(); public static final String NAMESPACE_10_0 = EJB3SubsystemNamespace.EJB3_10_0.getUriString(); static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME); private static final String RESOURCE_NAME = EJB3Extension.class.getPackage().getName() + ".LocalDescriptions"; public static ResourceDescriptionResolver getResourceDescriptionResolver(final String keyPrefix) { return new StandardResourceDescriptionResolver(keyPrefix, RESOURCE_NAME, EJB3Extension.class.getClassLoader(), true, true); } /** * {@inheritDoc} */ @Override public void initialize(ExtensionContext context) { final boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid(); final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, EJB3Model.CURRENT.getVersion()); subsystem.registerXMLElementWriter(EJB3SubsystemXMLPersister.INSTANCE); PathManager pathManager = context.getProcessType().isServer() ? context.getPathManager() : null; subsystem.registerSubsystemModel(new EJB3SubsystemRootResourceDefinition(registerRuntimeOnly, pathManager)); if (registerRuntimeOnly) { ResourceDefinition deploymentsDef = new SimpleResourceDefinition(new Parameters(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME), getResourceDescriptionResolver("deployed")).setFeature(false).setRuntime()); final ManagementResourceRegistration deploymentsRegistration = subsystem.registerDeploymentModel(deploymentsDef); deploymentsRegistration.registerSubModel(new MessageDrivenBeanResourceDefinition()); deploymentsRegistration.registerSubModel(new SingletonBeanDeploymentResourceDefinition()); deploymentsRegistration.registerSubModel(new StatelessSessionBeanDeploymentResourceDefinition()); deploymentsRegistration.registerSubModel(new StatefulSessionBeanDeploymentResourceDefinition()); } } /** * {@inheritDoc} */ @Override public void initializeParsers(ExtensionParsingContext context) { context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_1_0, EJB3Subsystem10Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_1_1, EJB3Subsystem11Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_1_2, EJB3Subsystem12Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_1_3, EJB3Subsystem13Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_1_4, EJB3Subsystem14Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_1_5, EJB3Subsystem15Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_2_0, EJB3Subsystem20Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_3_0, EJB3Subsystem30Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_4_0, EJB3Subsystem40Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_5_0, EJB3Subsystem50Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_6_0, EJB3Subsystem60Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_7_0, EJB3Subsystem70Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_8_0, EJB3Subsystem80Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_9_0, EJB3Subsystem90Parser::new); context.setSubsystemXmlMapping(SUBSYSTEM_NAME, NAMESPACE_10_0, EJB3Subsystem100Parser::new); } }
7,469
58.76
169
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/DefaultSingletonBeanAccessTimeoutWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.ejb3.component.DefaultAccessTimeoutService; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceRegistry; /** * User: jpai */ class DefaultSingletonBeanAccessTimeoutWriteHandler extends AbstractWriteAttributeHandler<Void> { static final DefaultSingletonBeanAccessTimeoutWriteHandler INSTANCE = new DefaultSingletonBeanAccessTimeoutWriteHandler(); private DefaultSingletonBeanAccessTimeoutWriteHandler() { super(EJB3SubsystemRootResourceDefinition.DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT); } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> voidHandbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateOrCreateDefaultSingletonBeanAccessTimeoutService(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateOrCreateDefaultSingletonBeanAccessTimeoutService(context, restored); } void updateOrCreateDefaultSingletonBeanAccessTimeoutService(final OperationContext context, final ModelNode model) throws OperationFailedException { final long defaultAccessTimeout = EJB3SubsystemRootResourceDefinition.DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT.resolveModelAttribute(context, model).asLong(); final ServiceName serviceName = DefaultAccessTimeoutService.SINGLETON_SERVICE_NAME; final ServiceRegistry registry = context.getServiceRegistry(true); final ServiceController<?> sc = registry.getService(serviceName); if (sc != null) { final DefaultAccessTimeoutService defaultAccessTimeoutService = DefaultAccessTimeoutService.class.cast(sc.getValue()); defaultAccessTimeoutService.setDefaultAccessTimeout(defaultAccessTimeout); } else { // create and install the service final DefaultAccessTimeoutService defaultAccessTimeoutService = new DefaultAccessTimeoutService(defaultAccessTimeout); final ServiceController<?> newService = context.getServiceTarget().addService(serviceName, defaultAccessTimeoutService) .install(); } } }
4,020
50.551282
235
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/ClusterPassivationStoreAdd.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.dmr.ModelNode; /** * @author Paul Ferraro */ @Deprecated public class ClusterPassivationStoreAdd extends PassivationStoreAdd { public ClusterPassivationStoreAdd(AttributeDefinition... attributes) { super(attributes); } @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws IllegalArgumentException, OperationFailedException { int initialMaxSize = ClusterPassivationStoreResourceDefinition.MAX_SIZE.resolveModelAttribute(context, model).asInt(); String containerName = ClusterPassivationStoreResourceDefinition.CACHE_CONTAINER.resolveModelAttribute(context, model).asString(); ModelNode beanCacheNode = ClusterPassivationStoreResourceDefinition.BEAN_CACHE.resolveModelAttribute(context, model); String cacheName = beanCacheNode.isDefined() ? beanCacheNode.asString() : null; this.install(context, operation, initialMaxSize, containerName, cacheName); } }
2,221
44.346939
157
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJBRemoteInvocationPassByValueWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.ejb3.remote.LocalTransportProvider; 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.ServiceRegistry; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StopContext; /** * @author Jaikiran Pai */ class EJBRemoteInvocationPassByValueWriteHandler extends AbstractWriteAttributeHandler<Void> { public static final EJBRemoteInvocationPassByValueWriteHandler INSTANCE = new EJBRemoteInvocationPassByValueWriteHandler(EJB3SubsystemRootResourceDefinition.PASS_BY_VALUE); private final AttributeDefinition attributeDefinition; private EJBRemoteInvocationPassByValueWriteHandler(final AttributeDefinition attributeDefinition) { super(attributeDefinition); this.attributeDefinition = attributeDefinition; } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateDefaultLocalEJBReceiverService(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateDefaultLocalEJBReceiverService(context, restored); } void updateDefaultLocalEJBReceiverService(final OperationContext context, final ModelNode model) throws OperationFailedException { final ModelNode passByValueModel = this.attributeDefinition.resolveModelAttribute(context, model); final ServiceRegistry registry = context.getServiceRegistry(true); final ServiceName localTransportProviderServiceName; if (passByValueModel.isDefined()) { final boolean passByValue = passByValueModel.asBoolean(true); if (passByValue) { localTransportProviderServiceName = LocalTransportProvider.BY_VALUE_SERVICE_NAME; } else { localTransportProviderServiceName = LocalTransportProvider.BY_REFERENCE_SERVICE_NAME; } } else { localTransportProviderServiceName = LocalTransportProvider.BY_VALUE_SERVICE_NAME; } // uninstall the existing default local Jakarta Enterprise Beans receiver service final ServiceController<?> existingDefaultLocalEJBReceiverServiceController = registry.getService(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME); if (existingDefaultLocalEJBReceiverServiceController != null) { context.removeService(existingDefaultLocalEJBReceiverServiceController); } // now install the new default local Jakarta Enterprise Beans receiver service which points to an existing Local Jakarta Enterprise Beans receiver service final ServiceName sn = LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME; final ServiceBuilder<?> sb = context.getServiceTarget().addService(sn); final Consumer<LocalTransportProvider> transportConsumer = sb.provides(sn); final Supplier<LocalTransportProvider> transportSupplier = sb.requires(localTransportProviderServiceName); sb.setInstance(new DefaultLocalTransportProviderService(transportConsumer, transportSupplier)); sb.install(); } private static final class DefaultLocalTransportProviderService implements Service { private final Consumer<LocalTransportProvider> transportConsumer; private final Supplier<LocalTransportProvider> transportSupplier; private DefaultLocalTransportProviderService(final Consumer<LocalTransportProvider> transportConsumer, final Supplier<LocalTransportProvider> transportSupplier) { this.transportConsumer = transportConsumer; this.transportSupplier = transportSupplier; } @Override public void start(final StartContext startContext) { transportConsumer.accept(transportSupplier.get()); } @Override public void stop(final StopContext stopContext) { transportConsumer.accept(null); } } }
6,139
49.327869
176
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StrictMaxPoolWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.concurrent.TimeUnit; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceRegistry; /** * Handles the "write-attribute" operation for a strict-max-bean-instance-pool resource. * * @author Brian Stansberry (c) 2011 Red Hat Inc. */ class StrictMaxPoolWriteHandler extends AbstractWriteAttributeHandler<Void> { StrictMaxPoolWriteHandler(AttributeDefinition... attributes) { super(attributes); } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); applyModelToRuntime(context, operation, attributeName, model); return false; } private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException { final String poolName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); ServiceName serviceName = context.getCapabilityServiceName(StrictMaxPoolResourceDefinition.STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, poolName, StrictMaxPoolConfigService.class); final ServiceRegistry registry = context.getServiceRegistry(true); ServiceController<?> sc = registry.getService(serviceName); if (sc != null) { StrictMaxPoolConfigService smpc = (StrictMaxPoolConfigService) sc.getService(); if (smpc != null) { if (StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.getName().equals(attributeName)) { int maxPoolSize = StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.resolveModelAttribute(context, model).asInt(-1); smpc.setMaxPoolSize(maxPoolSize); } else if (StrictMaxPoolResourceDefinition.DERIVE_SIZE.getName().equals(attributeName)) { StrictMaxPoolConfigService.Derive derive = StrictMaxPoolResourceDefinition.parseDeriveSize(context, model); smpc.setDerive(derive); } else if (StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.getName().equals(attributeName)) { long timeout = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.resolveModelAttribute(context, model).asLong(); smpc.setTimeout(timeout); } else if (StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.getName().equals(attributeName)) { String timeoutUnit = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.resolveModelAttribute(context, model).asString(); smpc.setTimeoutUnit(TimeUnit.valueOf(timeoutUnit)); } } } } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); applyModelToRuntime(context, operation, attributeName, restored); } }
5,045
52.115789
183
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StatefulSessionBeanCacheProviderResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; 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.controller.PathElement; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.ejb3.component.stateful.cache.StatefulSessionBeanCacheProvider; import java.util.function.UnaryOperator; public class StatefulSessionBeanCacheProviderResourceDefinition extends ChildResourceDefinition<ManagementResourceRegistration> { public static final String CACHE_FACTORY_CAPABILTY_NAME = "jboss.ejb.cache.factory"; enum Capability implements org.jboss.as.clustering.controller.Capability { CACHE_FACTORY(CACHE_FACTORY_CAPABILTY_NAME) ; private final RuntimeCapability<Void> definition; Capability(String name) { this.definition = RuntimeCapability.Builder.of(CACHE_FACTORY_CAPABILTY_NAME, true, StatefulSessionBeanCacheProvider.class) .setAllowMultipleRegistrations(true) .build(); } @Override public RuntimeCapability<?> getDefinition() { return this.definition; } } private final UnaryOperator<ResourceDescriptor> configurator; private final ResourceServiceConfiguratorFactory serviceConfiguratorFactory; public StatefulSessionBeanCacheProviderResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ResourceServiceConfiguratorFactory serviceConfiguratorFactory) { super(path, EJB3Extension.getResourceDescriptionResolver(path.getKey())); 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; } }
3,745
47.025641
192
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Subsystem15Parser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import java.util.EnumSet; import java.util.List; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import static org.jboss.as.controller.parsing.ParseUtils.missingRequired; import static org.jboss.as.controller.parsing.ParseUtils.requireNoContent; import static org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.DATABASE_DATA_STORE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.FILE_DATA_STORE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.PATH; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.RELATIVE_TO; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.SERVICE; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.TIMER_SERVICE; /** */ public class EJB3Subsystem15Parser extends EJB3Subsystem14Parser { protected EJB3Subsystem15Parser() { } protected void parseTimerService(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { final ModelNode address = new ModelNode(); address.add(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME); address.add(SERVICE, TIMER_SERVICE); final ModelNode timerServiceAdd = new ModelNode(); timerServiceAdd.get(OP).set(ADD); timerServiceAdd.get(OP_ADDR).set(address); final int attCount = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.THREAD_POOL_NAME, EJB3SubsystemXMLAttribute.DEFAULT_DATA_STORE); for (int i = 0; i < attCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case THREAD_POOL_NAME: { TimerServiceResourceDefinition.THREAD_POOL_NAME.parseAndSetParameter(value,timerServiceAdd,reader); break; } case DEFAULT_DATA_STORE: { TimerServiceResourceDefinition.DEFAULT_DATA_STORE.parseAndSetParameter(value,timerServiceAdd,reader); break; } default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } operations.add(timerServiceAdd); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case DATA_STORES: { parseDataStores(reader, operations); } } } } private void parseDataStores(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case FILE_DATA_STORE: { parseFileDataStore(reader, operations); break; } case DATABASE_DATA_STORE: { parseDatabaseDataStore(reader, operations); break; } default: { throw unexpectedElement(reader); } } } } private void parseFileDataStore(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { String dataStorePath = null; String dataStorePathRelativeTo = null; String name = null; final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.NAME, EJB3SubsystemXMLAttribute.PATH); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case NAME: if (name != null) { throw unexpectedAttribute(reader, i); } name = reader.getAttributeValue(i); break; case PATH: if (dataStorePath != null) { throw unexpectedAttribute(reader, i); } dataStorePath = parse(FileDataStoreResourceDefinition.PATH, value, reader).asString(); break; case RELATIVE_TO: if (dataStorePathRelativeTo != null) { throw unexpectedAttribute(reader, i); } dataStorePathRelativeTo = parse(FileDataStoreResourceDefinition.RELATIVE_TO, value, reader).asString(); break; default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } final ModelNode address = new ModelNode(); address.add(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME); address.add(SERVICE, TIMER_SERVICE); address.add(FILE_DATA_STORE, name); final ModelNode fileDataStoreAdd = new ModelNode(); fileDataStoreAdd.get(OP).set(ADD); fileDataStoreAdd.get(ADDRESS).set(address); fileDataStoreAdd.get(PATH).set(dataStorePath); if (dataStorePathRelativeTo != null) { fileDataStoreAdd.get(RELATIVE_TO).set(dataStorePathRelativeTo); } operations.add(fileDataStoreAdd); requireNoContent(reader); } protected void parseDatabaseDataStore(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { String name = null; final ModelNode databaseDataStore = new ModelNode(); final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.NAME, EJB3SubsystemXMLAttribute.DATASOURCE_JNDI_NAME); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case NAME: if (name != null) { throw unexpectedAttribute(reader, i); } name = reader.getAttributeValue(i); break; case DATASOURCE_JNDI_NAME: DatabaseDataStoreResourceDefinition.DATASOURCE_JNDI_NAME.parseAndSetParameter(value, databaseDataStore, reader); break; case DATABASE: DatabaseDataStoreResourceDefinition.DATABASE.parseAndSetParameter(value, databaseDataStore, reader); break; case PARTITION: DatabaseDataStoreResourceDefinition.PARTITION.parseAndSetParameter(value, databaseDataStore, reader); break; default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } final ModelNode address = new ModelNode(); address.add(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME); address.add(SERVICE, TIMER_SERVICE); address.add(DATABASE_DATA_STORE, name); databaseDataStore.get(OP).set(ADD); databaseDataStore.get(ADDRESS).set(address); operations.add(databaseDataStore); requireNoContent(reader); } @Override protected EJB3SubsystemNamespace getExpectedNamespace() { return EJB3SubsystemNamespace.EJB3_1_5; } }
10,181
44.864865
161
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/LegacyCacheFactoryRemove.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.ServiceRemoveStepHandler; import org.jboss.as.ejb3.component.stateful.cache.StatefulSessionBeanCacheProviderServiceNameProvider; import org.jboss.msc.service.ServiceName; /** * @author Paul Ferraro */ @Deprecated public class LegacyCacheFactoryRemove extends ServiceRemoveStepHandler { LegacyCacheFactoryRemove(LegacyCacheFactoryAdd addHandler) { super(ServiceName.JBOSS.append("ejb","cache", "factory"), addHandler); } @Override protected ServiceName serviceName(final String name) { return new StatefulSessionBeanCacheProviderServiceNameProvider(name).getServiceName(); } }
1,709
38.767442
102
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3RemoteResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.ReloadRequiredRemoveStepHandler; import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.StringListAttributeDefinition; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import java.util.List; /** * A {@link org.jboss.as.controller.ResourceDefinition} for the EJB remote service * * @author Jaikiran Pai * @author <a href="mailto:[email protected]">Richard Achmatowicz</a> * */ public class EJB3RemoteResourceDefinition extends SimpleResourceDefinition { // todo: add in connector capability reference when connector resources are converted to use capabilities (WFCORE-5055) public static final String CONNECTOR_CAPABILITY_NAME = "org.wildfly.remoting.connector"; protected static final String INFINISPAN_CACHE_CONTAINER_CAPABILITY_NAME = "org.wildfly.clustering.infinispan.cache-container"; protected static final String REMOTE_TRANSACTION_SERVICE_CAPABILITY_NAME = "org.wildfly.transactions.remote-transaction-service"; protected static final String REMOTING_ENDPOINT_CAPABILITY_NAME = "org.wildfly.remoting.endpoint"; protected static final String THREAD_POOL_CAPABILITY_NAME = "org.wildfly.threads.executor.ejb3"; public static final String EJB_REMOTE_CAPABILITY_NAME = "org.wildfly.ejb.remote"; static final RuntimeCapability<Void> EJB_REMOTE_CAPABILITY = RuntimeCapability.Builder.of(EJB_REMOTE_CAPABILITY_NAME) .setServiceType(Void.class) .addRequirements(REMOTING_ENDPOINT_CAPABILITY_NAME) .build(); @Deprecated static final SimpleAttributeDefinition CLIENT_MAPPINGS_CLUSTER_NAME = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.CLIENT_MAPPINGS_CLUSTER_NAME, ModelType.STRING, true) // Capability references should not allow expressions .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setDefaultValue(new ModelNode(org.wildfly.clustering.ejb.bean.LegacyBeanManagementConfiguration.DEFAULT_CONTAINER_NAME)) // TODO: replace this with a Requirement reference when the ejb-spi module for clustering is available .setCapabilityReference(INFINISPAN_CACHE_CONTAINER_CAPABILITY_NAME, EJB_REMOTE_CAPABILITY) .setDeprecated(EJB3Model.VERSION_10_0_0.getVersion()) .build(); @Deprecated static final SimpleAttributeDefinition CONNECTOR_REF = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.CONNECTOR_REF, ModelType.STRING, true) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAlternatives(EJB3SubsystemModel.CONNECTORS) .setDeprecated(EJB3Model.VERSION_8_0_0.getVersion()) .build(); static final StringListAttributeDefinition CONNECTORS = new StringListAttributeDefinition.Builder(EJB3SubsystemModel.CONNECTORS) .setAllowExpression(false) .setRequired(true) .setMinSize(1) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setCapabilityReference(CONNECTOR_CAPABILITY_NAME, EJB_REMOTE_CAPABILITY) .build(); static final SimpleAttributeDefinition THREAD_POOL_NAME = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.THREAD_POOL_NAME, ModelType.STRING, true) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setCapabilityReference(THREAD_POOL_CAPABILITY_NAME, EJB_REMOTE_CAPABILITY) .build(); static final SimpleAttributeDefinition EXECUTE_IN_WORKER = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.EXECUTE_IN_WORKER, ModelType.BOOLEAN, true) .setAllowExpression(true) .setDefaultValue(ModelNode.TRUE) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { CLIENT_MAPPINGS_CLUSTER_NAME, CONNECTORS, THREAD_POOL_NAME, EXECUTE_IN_WORKER }; static final EJB3RemoteServiceAdd ADD_HANDLER = new EJB3RemoteServiceAdd(ATTRIBUTES); EJB3RemoteResourceDefinition() { super(new Parameters(EJB3SubsystemModel.REMOTE_SERVICE_PATH, EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.REMOTE)) .setAddHandler(ADD_HANDLER) .setAddRestartLevel(OperationEntry.Flag.RESTART_ALL_SERVICES) .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_ALL_SERVICES) .addCapabilities(EJB_REMOTE_CAPABILITY)); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { for (AttributeDefinition attr : ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(attr, null, new ReloadRequiredWriteAttributeHandler(attr)); } // register custom handlers for deprecated attribute connector-ref resourceRegistration.registerReadWriteAttribute(CONNECTOR_REF, new RemoteConnectorRefReadAttributeHandler(), new RemoteConnectorRefWriteAttributeHandler()); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { // register channel-creation-options as sub model for EJB remote service resourceRegistration.registerSubModel(new RemoteConnectorChannelCreationOptionResource()); } /** * read-attribute handler for deprecated attribute connector-ref: * - read the first connector from CONNECTORS and return that as the result */ static class RemoteConnectorRefReadAttributeHandler implements OperationStepHandler { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); List<ModelNode> connectorsList = CONNECTORS.resolveModelAttribute(context, model).asList(); // return the first connector in the CONNECTORS list context.getResult().set(connectorsList.get(0)); } } /** * write-attribute handler for deprecated attribute connector-ref * - use the new value passed to write-attribute to create a new singleton List for CONNECTORS */ static class RemoteConnectorRefWriteAttributeHandler implements OperationStepHandler { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode value = operation.get(VALUE); ModelNode targetValue = new ModelNode().add(value); AttributeDefinition targetAttribute = CONNECTORS; PathAddress address = context.getCurrentAddress(); // set up write operation for CONNECTORS ModelNode targetOperation = Util.getWriteAttributeOperation(address, targetAttribute.getName(), targetValue); OperationStepHandler writeAttributeHandler = context.getRootResourceRegistration().getAttributeAccess(address, targetAttribute.getName()).getWriteHandler(); writeAttributeHandler.execute(context, targetOperation); } } }
9,486
52.903409
168
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/PassivationStoreRemove.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.CapabilityReferenceRecorder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.ServiceRemoveStepHandler; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration; import org.jboss.as.controller.registry.Resource; import org.jboss.as.ejb3.component.stateful.cache.StatefulSessionBeanCacheProviderServiceNameProvider; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceName; import java.util.Set; /** * Handler to remove resource at /subsystem=ejb3/passivation-store=X * * In order to work with capabilities from org.wildfly.clustering.infinispan.spi, the handler is modified * to remove capabilities for the resource before the resource itself is removed. * * @author Paul Ferraro */ @Deprecated public class PassivationStoreRemove extends ServiceRemoveStepHandler { public PassivationStoreRemove(final AbstractAddStepHandler addOperation) { super(addOperation); } @Override protected ServiceName serviceName(final String name) { return new StatefulSessionBeanCacheProviderServiceNameProvider(name).getServiceName(); } /** * Override AbstractRemoveStepHandler.performRemove() to remove capabilities before removing child resources */ @Override protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); if (removeInCurrentStep(resource)) { // We need to remove capabilities *before* removing the resource, since the capability reference resolution might involve reading the resource Set<RuntimeCapability> capabilitySet = context.getResourceRegistration().getCapabilities(); PathAddress address = context.getCurrentAddress(); // deregister capabilities which will no longer be available after remove for (RuntimeCapability capability : capabilitySet) { if (capability.isDynamicallyNamed()) { context.deregisterCapability(capability.getDynamicName(address)); } else { context.deregisterCapability(capability.getName()); } } // remove capability requiremnts for attributes which will no longer be required after remove ImmutableManagementResourceRegistration registration = context.getResourceRegistration(); for (String attributeName : registration.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { AttributeDefinition attribute = registration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName).getAttributeDefinition(); if (attribute.hasCapabilityRequirements()) { attribute.removeCapabilityRequirements(context, resource, model.get(attributeName)); } } // remove capability requiremnts for reference recorders which will no longer be required for (CapabilityReferenceRecorder recorder : registration.getRequirements()) { recorder.removeCapabilityRequirements(context, resource, null); } } super.performRemove(context, operation, model); } /* * Determines whether resource removal happens in this step, or a subsequent step */ private static boolean removeInCurrentStep(Resource resource) { for (String childType : resource.getChildTypes()) { for (Resource.ResourceEntry entry : resource.getChildren(childType)) { if (!entry.isRuntime() && resource.hasChild(entry.getPathElement())) { return false; } } } return true; } @Override protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { // we already unregistered our capabilities in performRemove(...) } }
5,410
44.091667
154
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/SimpleAliasReadAttributeHandler.java
/* Copyright 2016 Red Hat, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.registry.Resource; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * Handler for {@code read-attribute} that delegates to a different attribute. * * TODO move this into WildFly Core for reuse. * * @author Brian Stansberry */ class SimpleAliasReadAttributeHandler implements OperationStepHandler { private static final SimpleAttributeDefinition INCLUDE_DEFAULTS = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.INCLUDE_DEFAULTS, ModelType.BOOLEAN) .setRequired(false) .setDefaultValue(ModelNode.TRUE) .build(); private final SimpleAttributeDefinition aliasedAttribute; SimpleAliasReadAttributeHandler(SimpleAttributeDefinition aliasedAttribute) { this.aliasedAttribute = aliasedAttribute; } @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final boolean defaults = INCLUDE_DEFAULTS.resolveModelAttribute(context,operation).asBoolean(); final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS, false); final ModelNode subModel = resource.getModel(); if (subModel.hasDefined(aliasedAttribute.getName())) { final ModelNode result = subModel.get(aliasedAttribute.getName()); context.getResult().set(result); } else if (defaults && aliasedAttribute.getDefaultValue() != null) { // No defined value in the model. See if we should reply with a default from the metadata, // reply with undefined, or fail because it's a non-existent attribute name context.getResult().set(aliasedAttribute.getDefaultValue()); } else { // model had no defined value, but we treat its existence in the model or the metadata // as proof that it's a legit attribute name context.getResult(); // this initializes the "result" to ModelType.UNDEFINED } } }
3,000
42.492754
169
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/RemotingProfileAdd.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.CapabilityServiceBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.OperationStepHandler; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.registry.Resource; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.as.ejb3.remote.LocalTransportProvider; import org.jboss.as.ejb3.remote.RemotingProfileService; import org.jboss.as.network.OutboundConnection; import org.jboss.dmr.ModelNode; import org.jboss.dmr.Property; import org.jboss.ejb.client.EJBClientContext; import org.jboss.ejb.client.EJBTransportProvider; import org.jboss.msc.service.ServiceName; import org.jboss.remoting3.RemotingOptions; import org.wildfly.discovery.AttributeValue; import org.wildfly.discovery.ServiceURL; import org.xnio.Option; import org.xnio.OptionMap; import org.xnio.Options; /** * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ public class RemotingProfileAdd extends AbstractAddStepHandler { private static final String OUTBOUND_CONNECTION_CAPABILITY_NAME = "org.wildfly.remoting.outbound-connection"; RemotingProfileAdd(AttributeDefinition... attributes) { super(attributes); } @Override protected void performRuntime(final OperationContext context,final ModelNode operation,final ModelNode model) throws OperationFailedException { context.addStep((context1, operation1) -> { // Install another RUNTIME handler to actually install the services. This will run after the // RUNTIME handler for any child resources. Doing this will ensure that child resource handlers don't // see the installed services and can just ignore doing any RUNTIME stage work context1.addStep(ServiceInstallStepHandler.INSTANCE, OperationContext.Stage.RUNTIME); }, OperationContext.Stage.RUNTIME); } protected void installServices(final OperationContext context, final PathAddress address, final ModelNode profileNode) throws OperationFailedException { try { final ModelNode staticEjbDiscoery = StaticEJBDiscoveryDefinition.INSTANCE.resolveModelAttribute(context, profileNode); List<StaticEJBDiscoveryDefinition.StaticEjbDiscovery> discoveryList = StaticEJBDiscoveryDefinition.createStaticEjbList(context, staticEjbDiscoery); final List<ServiceURL> urls = new ArrayList<>(); for (StaticEJBDiscoveryDefinition.StaticEjbDiscovery resource : discoveryList) { ServiceURL.Builder builder = new ServiceURL.Builder(); builder.setAbstractType("ejb") .setAbstractTypeAuthority("jboss") .setUri(new URI(resource.getUrl())); String distinctName = resource.getDistinct() == null ? "" : resource.getDistinct(); String appName = resource.getApp() == null ? "" : resource.getApp(); String moduleName = resource.getModule(); if (distinctName.isEmpty()) { if (appName.isEmpty()) { builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE, AttributeValue.fromString(moduleName)); } else { builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE, AttributeValue.fromString(appName + "/" + moduleName)); } } else { if (appName.isEmpty()) { builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE_DISTINCT, AttributeValue.fromString(moduleName + "/" + distinctName)); } else { builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE_DISTINCT, AttributeValue.fromString(appName + "/" + moduleName + "/" + distinctName)); } } urls.add(builder.create()); } final Map<String, RemotingProfileService.RemotingConnectionSpec> map = new HashMap<>(); final List<RemotingProfileService.HttpConnectionSpec> httpConnectionSpecs = new ArrayList<>(); // populating the map after the fact is cheating, but it works thanks to the MSC start service "fence" final CapabilityServiceBuilder capabilityServiceBuilder = context.getCapabilityServiceTarget().addCapability(RemotingProfileResourceDefinition.REMOTING_PROFILE_CAPABILITY); final Consumer<RemotingProfileService> consumer = capabilityServiceBuilder.provides(RemotingProfileResourceDefinition.REMOTING_PROFILE_CAPABILITY); if (profileNode.hasDefined(EJB3SubsystemModel.REMOTING_EJB_RECEIVER)) { for (final Property receiverProperty : profileNode.get(EJB3SubsystemModel.REMOTING_EJB_RECEIVER).asPropertyList()) { final ModelNode receiverNode = receiverProperty.getValue(); final String connectionRef = RemotingEjbReceiverDefinition.OUTBOUND_CONNECTION_REF.resolveModelAttribute(context, receiverNode).asString(); final long timeout = RemotingEjbReceiverDefinition.CONNECT_TIMEOUT.resolveModelAttribute(context, receiverNode).asLong(); final Supplier<OutboundConnection> connectionSupplier = capabilityServiceBuilder.requiresCapability(OUTBOUND_CONNECTION_CAPABILITY_NAME, OutboundConnection.class, connectionRef); final ModelNode channelCreationOptionsNode = receiverNode.get(EJB3SubsystemModel.CHANNEL_CREATION_OPTIONS); OptionMap channelCreationOptions = createChannelOptionMap(context, channelCreationOptionsNode); map.put(connectionRef, new RemotingProfileService.RemotingConnectionSpec( connectionRef, connectionSupplier, channelCreationOptions, timeout )); } } final boolean isLocalReceiverExcluded = RemotingProfileResourceDefinition.EXCLUDE_LOCAL_RECEIVER.resolveModelAttribute(context, profileNode).asBoolean(); if (profileNode.hasDefined(EJB3SubsystemModel.REMOTE_HTTP_CONNECTION)) { for (final Property receiverProperty : profileNode.get(EJB3SubsystemModel.REMOTE_HTTP_CONNECTION) .asPropertyList()) { final ModelNode receiverNode = receiverProperty.getValue(); final String uri = RemoteHttpConnectionDefinition.URI.resolveModelAttribute(context, receiverNode).asString(); httpConnectionSpecs.add(new RemotingProfileService.HttpConnectionSpec(uri)); } } // if the local receiver is enabled for this context, then add a dependency on the appropriate LocalEjbReceive service Supplier<EJBTransportProvider> localTransportProviderSupplier = null; if (!isLocalReceiverExcluded) { final ModelNode passByValueNode = RemotingProfileResourceDefinition.LOCAL_RECEIVER_PASS_BY_VALUE.resolveModelAttribute(context, profileNode); if (passByValueNode.isDefined()) { final ServiceName localTransportProviderServiceName = passByValueNode.asBoolean() == true ? LocalTransportProvider.BY_VALUE_SERVICE_NAME : LocalTransportProvider.BY_REFERENCE_SERVICE_NAME; localTransportProviderSupplier = capabilityServiceBuilder.requires(localTransportProviderServiceName); } else { // setup a dependency on the default local Jakarta Enterprise Beans receiver service configured at the subsystem level localTransportProviderSupplier = capabilityServiceBuilder.requires(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME); } } final RemotingProfileService profileService = new RemotingProfileService(consumer, localTransportProviderSupplier, urls, map, httpConnectionSpecs); capabilityServiceBuilder.setInstance(profileService); capabilityServiceBuilder.install(); } catch (IllegalArgumentException | URISyntaxException e) { throw new OperationFailedException(e.getLocalizedMessage()); } } private OptionMap createChannelOptionMap(final OperationContext context, final ModelNode channelCreationOptionsNode) throws OperationFailedException { final OptionMap optionMap; if (channelCreationOptionsNode.isDefined()) { final OptionMap.Builder optionMapBuilder = OptionMap.builder(); final ClassLoader loader = this.getClass().getClassLoader(); for (final Property optionProperty : channelCreationOptionsNode.asPropertyList()) { final String name = optionProperty.getName(); final ModelNode propValueModel = optionProperty.getValue(); final String type = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_TYPE.resolveModelAttribute(context, propValueModel).asString(); final String optionClassName = this.getClassNameForChannelOptionType(type); final String fullyQualifiedOptionName = optionClassName + "." + name; final Option option = Option.fromString(fullyQualifiedOptionName, loader); final String value = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE.resolveModelAttribute(context, propValueModel).asString(); optionMapBuilder.set(option, option.parseValue(value, loader)); } optionMap = optionMapBuilder.getMap(); } else { optionMap = OptionMap.EMPTY; } return optionMap; } private String getClassNameForChannelOptionType(final String optionType) { if ("remoting".equals(optionType)) { return RemotingOptions.class.getName(); } if ("xnio".equals(optionType)) { return Options.class.getName(); } throw EjbLogger.ROOT_LOGGER.unknownChannelCreationOptionType(optionType); } private static class ServiceInstallStepHandler implements OperationStepHandler { private static final ServiceInstallStepHandler INSTANCE = new ServiceInstallStepHandler(); @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode model = Resource.Tools.readModel(resource); final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); RemotingProfileResourceDefinition.ADD_HANDLER.installServices(context, address, model); } } }
12,457
55.371041
198
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StrictMaxPoolAdd.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService.Derive; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.CapabilityServiceBuilder; import org.jboss.as.controller.CapabilityServiceTarget; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.ejb3.component.pool.StrictMaxPoolConfig; import org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService; import org.jboss.dmr.ModelNode; /** * Adds a strict-max-pool to the EJB3 subsystem's bean-instance-pools. The {#performRuntime runtime action} * will create and install a {@link org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService} * <p/> * User: Jaikiran Pai */ public class StrictMaxPoolAdd extends AbstractAddStepHandler { static final String IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME = "org.wildfly.io.max-threads"; StrictMaxPoolAdd(AttributeDefinition... attributes) { super(attributes); } @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode strictMaxPoolModel) throws OperationFailedException { final String poolName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue(); final int maxPoolSize = StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.resolveModelAttribute(context, strictMaxPoolModel).asInt(); final Derive derive = StrictMaxPoolResourceDefinition.parseDeriveSize(context, strictMaxPoolModel); final long timeout = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.resolveModelAttribute(context, strictMaxPoolModel).asLong(); final String unit = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.resolveModelAttribute(context, strictMaxPoolModel).asString(); // create and install the service CapabilityServiceTarget capabilityServiceTarget = context.getCapabilityServiceTarget(); CapabilityServiceBuilder<?> sb = capabilityServiceTarget.addCapability(StrictMaxPoolResourceDefinition.STRICT_MAX_POOL_CONFIG_CAPABILITY); final Consumer<StrictMaxPoolConfig> configConsumer = sb.provides(StrictMaxPoolResourceDefinition.STRICT_MAX_POOL_CONFIG_CAPABILITY); Supplier<Integer> maxThreadsSupplier = null; if (context.hasOptionalCapability(IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME, null, null)) { maxThreadsSupplier = sb.requiresCapability(IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME, Integer.class); } final StrictMaxPoolConfigService poolConfigService = new StrictMaxPoolConfigService(configConsumer, maxThreadsSupplier, poolName, maxPoolSize, derive, timeout, TimeUnit.valueOf(unit)); sb.setInstance(poolConfigService); sb.install(); } }
4,166
52.423077
192
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/AllowedChannelOptionTypesValidator.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.ArrayList; import java.util.List; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.operations.validation.AllowedValuesValidator; import org.jboss.as.controller.operations.validation.ModelTypeValidator; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; public class AllowedChannelOptionTypesValidator extends ModelTypeValidator implements AllowedValuesValidator { public static final AllowedChannelOptionTypesValidator INSTANCE = new AllowedChannelOptionTypesValidator(); private final List<ModelNode> allowedChannelOptTypes; private AllowedChannelOptionTypesValidator() { super(ModelType.STRING, false); allowedChannelOptTypes = new ArrayList<ModelNode>(); allowedChannelOptTypes.add(new ModelNode().set("remoting")); allowedChannelOptTypes.add(new ModelNode().set("xnio")); } @Override public List<ModelNode> getAllowedValues() { return allowedChannelOptTypes; } @Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined() && value.getType() != ModelType.EXPRESSION && !this.allowedChannelOptTypes.contains(value)) { throw EjbLogger.ROOT_LOGGER.unknownChannelCreationOptionType(value.asString()); } } }
2,556
40.241935
111
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EnableGracefulTxnShutdownWriteHandler.java
/* * Copyright 2017 Red Hat, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.ejb3.suspend.EJBSuspendHandlerService; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceRegistry; /** * Write handler for enable graceful shutdown. * * @author Flavia Rainone */ public class EnableGracefulTxnShutdownWriteHandler extends AbstractWriteAttributeHandler<Void> { public static final EnableGracefulTxnShutdownWriteHandler INSTANCE = new EnableGracefulTxnShutdownWriteHandler( EJB3SubsystemRootResourceDefinition.ENABLE_GRACEFUL_TXN_SHUTDOWN); private final AttributeDefinition gracefulTxnShutdownAttribute; /** * @param attributes the attributes associated with the passivation-store resource, starting with max-size */ EnableGracefulTxnShutdownWriteHandler(AttributeDefinition... attributes) { super(attributes); // enable graceful this.gracefulTxnShutdownAttribute = attributes[0]; } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); this.applyModelToRuntime(context, operation, attributeName, model); return false; } private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException { String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); ServiceRegistry registry = context.getServiceRegistry(true); EJBSuspendHandlerService service = (EJBSuspendHandlerService) registry.getRequiredService(EJBSuspendHandlerService.SERVICE_NAME).getValue(); if (service!= null && this.gracefulTxnShutdownAttribute.getName().equals(attributeName)) { boolean enableGracefulTxnShutdown = this.gracefulTxnShutdownAttribute.resolveModelAttribute(context, model) .asBoolean(); service.enableGracefulTxnShutdown(enableGracefulTxnShutdown); } } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); this.applyModelToRuntime(context, operation, attributeName, restored); } }
3,691
49.575342
226
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/StrictMaxPoolDerivedSizeReadHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2017, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractRuntimeOnlyHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService; import org.jboss.as.ejb3.logging.EjbLogger; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; import org.jboss.msc.service.ServiceRegistry; /** * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ public class StrictMaxPoolDerivedSizeReadHandler extends AbstractRuntimeOnlyHandler{ @Override protected void executeRuntimeStep(final OperationContext context, final ModelNode operation) throws OperationFailedException { final String poolName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); ServiceName serviceName = context.getCapabilityServiceName(StrictMaxPoolResourceDefinition.STRICT_MAX_POOL_CONFIG_CAPABILITY_NAME, poolName, StrictMaxPoolConfigService.class); final ServiceRegistry registry = context.getServiceRegistry(false); ServiceController<?> sc = registry.getService(serviceName); if (sc != null) { StrictMaxPoolConfigService smpc = (StrictMaxPoolConfigService) sc.getService(); if (smpc != null) { context.getResult().set(smpc.getDerivedSize()); return; } } throw EjbLogger.ROOT_LOGGER.cannotReadStrictMaxPoolDerivedSize(serviceName); } }
2,749
44.833333
183
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJBDefaultDistinctNameWriteHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.AttributeDefinition; 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.ServiceController; import org.jboss.msc.service.ServiceRegistry; /** * @author Stuart Douglas */ class EJBDefaultDistinctNameWriteHandler extends AbstractWriteAttributeHandler<Void> { public static final EJBDefaultDistinctNameWriteHandler INSTANCE = new EJBDefaultDistinctNameWriteHandler(EJB3SubsystemRootResourceDefinition.DEFAULT_DISTINCT_NAME); private final AttributeDefinition attributeDefinition; private EJBDefaultDistinctNameWriteHandler(final AttributeDefinition attributeDefinition) { super(attributeDefinition); this.attributeDefinition = attributeDefinition; } @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateDefaultDistinctName(context, model); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateDefaultDistinctName(context, restored); } void updateDefaultDistinctName(final OperationContext context, final ModelNode model) throws OperationFailedException { final ModelNode defaultDistinctName = this.attributeDefinition.resolveModelAttribute(context, model); final ServiceRegistry registry = context.getServiceRegistry(true); final ServiceController<?> existingDefaultLocalEJBReceiverServiceController = registry.getService(DefaultDistinctNameService.SERVICE_NAME); DefaultDistinctNameService service = (DefaultDistinctNameService) existingDefaultLocalEJBReceiverServiceController.getValue(); if (!defaultDistinctName.isDefined()) { service.setDefaultDistinctName(null); } else { service.setDefaultDistinctName(defaultDistinctName.asString()); } } }
3,752
45.9125
168
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/LegacyCacheFactoryAdd.java
/* * JBoss, Home of Professional Open Source. * Copyright 2010, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.ejb3.component.stateful.cache.StatefulSessionBeanCacheProviderServiceNameProvider; import org.jboss.as.ejb3.component.stateful.cache.simple.SimpleStatefulSessionBeanCacheProviderServiceConfigurator; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceTarget; import org.wildfly.clustering.service.IdentityServiceConfigurator; import org.wildfly.clustering.service.ServiceConfigurator; /** * Configure, build and install CacheFactoryBuilders to support SFSB usage. * * @author Paul Ferraro */ @Deprecated public class LegacyCacheFactoryAdd extends AbstractAddStepHandler { LegacyCacheFactoryAdd(AttributeDefinition... attributes) { super(attributes); } @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress pathAddress = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)); final String name = pathAddress.getLastElement().getValue(); ModelNode passivationStoreModel = LegacyCacheFactoryResourceDefinition.PASSIVATION_STORE.resolveModelAttribute(context,model); String passivationStore = passivationStoreModel.isDefined() ? passivationStoreModel.asString() : null; final Collection<String> unwrappedAliasValues = LegacyCacheFactoryResourceDefinition.ALIASES.unwrap(context,model); final Set<String> aliases = unwrappedAliasValues != null ? new HashSet<>(unwrappedAliasValues) : Collections.<String>emptySet(); ServiceTarget target = context.getServiceTarget(); // set up the CacheFactoryBuilder service ServiceConfigurator configurator = (passivationStore != null) ? new IdentityServiceConfigurator<>(new StatefulSessionBeanCacheProviderServiceNameProvider(name).getServiceName(), new StatefulSessionBeanCacheProviderServiceNameProvider(passivationStore).getServiceName()) : new SimpleStatefulSessionBeanCacheProviderServiceConfigurator<>(pathAddress); ServiceBuilder<?> builder = configurator.build(target); // set up aliases to the CacheFactoryBuilder service for (String alias: aliases) { new IdentityServiceConfigurator<>(new StatefulSessionBeanCacheProviderServiceNameProvider(alias).getServiceName(), configurator.getServiceName()).build(target).install(); } builder.install(); } }
3,967
49.871795
187
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/ApplicationSecurityDomainService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import static java.security.AccessController.doPrivileged; import java.security.PrivilegedAction; import java.util.HashSet; import java.util.Set; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.msc.Service; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; import org.wildfly.security.auth.server.SecurityDomain; import org.wildfly.security.manager.WildFlySecurityManager; /** * A {@link Service} that manages a security domain mapping. * * @author <a href="mailto:[email protected]">Farah Juma</a> */ public class ApplicationSecurityDomainService implements Service { private final Supplier<SecurityDomain> securityDomainSupplier; private final Consumer<ApplicationSecurityDomainService.ApplicationSecurityDomain> applicationSecurityDomainConsumer; private final Consumer<SecurityDomain> securityDomainConsumer; private final Set<RegistrationImpl> registrations = new HashSet<>(); private final boolean enableJacc; public ApplicationSecurityDomainService(boolean enableJacc, Supplier<SecurityDomain> securityDomainSupplier, Consumer<ApplicationSecurityDomainService.ApplicationSecurityDomain> applicationSecurityDomainConsumer, Consumer<SecurityDomain> securityDomainConsumer) { this.enableJacc = enableJacc; this.securityDomainSupplier = securityDomainSupplier; this.applicationSecurityDomainConsumer = applicationSecurityDomainConsumer; this.securityDomainConsumer = securityDomainConsumer; } @Override public void start(StartContext context) throws StartException { SecurityDomain securityDomain = securityDomainSupplier.get(); applicationSecurityDomainConsumer.accept(new ApplicationSecurityDomain(securityDomain, enableJacc)); securityDomainConsumer.accept(securityDomain); } @Override public void stop(StopContext context) {} public String[] getDeployments() { synchronized(registrations) { Set<String> deploymentNames = new HashSet<>(); for (RegistrationImpl r : registrations) { String deploymentName = r.deploymentName; deploymentNames.add(deploymentName); } return deploymentNames.toArray(new String[deploymentNames.size()]); } } private class RegistrationImpl implements Registration { private final String deploymentName; private final ClassLoader classLoader; private RegistrationImpl(String deploymentName, ClassLoader classLoader) { this.deploymentName = deploymentName; this.classLoader = classLoader; } @Override public void cancel() { if (WildFlySecurityManager.isChecking()) { doPrivileged((PrivilegedAction<Void>) () -> { SecurityDomain.unregisterClassLoader(classLoader); return null; }); } else { SecurityDomain.unregisterClassLoader(classLoader); } synchronized(registrations) { registrations.remove(this); } } } public interface Registration { /** * Cancel the registration. */ void cancel(); } public final class ApplicationSecurityDomain { private final SecurityDomain securityDomain; private final boolean enableJacc; public ApplicationSecurityDomain(final SecurityDomain securityDomain, boolean enableJacc) { this.securityDomain = securityDomain; this.enableJacc = enableJacc; } public SecurityDomain getSecurityDomain() { return securityDomain; } public boolean isEnableJacc() { return enableJacc; } public BiFunction<String, ClassLoader, Registration> getSecurityFunction() { return this::registerElytronDeployment; } private Registration registerElytronDeployment(final String deploymentName, final ClassLoader classLoader) { if (WildFlySecurityManager.isChecking()) { doPrivileged((PrivilegedAction<Void>) () -> { securityDomain.registerWithClassLoader(classLoader); return null; }); } else { securityDomain.registerWithClassLoader(classLoader); } RegistrationImpl registration = new RegistrationImpl(deploymentName, classLoader); synchronized(registrations) { registrations.add(registration); } return registration; } } }
5,881
35.993711
164
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/FilterSpecClassResolverFilter.java
/* * Copyright (c) 2020. Red Hat, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.ejb3.subsystem; import static org.jboss.as.ejb3.logging.EjbLogger.REMOTE_LOGGER; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Function; import org.jboss.as.controller.OperationContext; import org.wildfly.common.Assert; import org.wildfly.security.manager.WildFlySecurityManager; /** * Class name filtering {@code Function<String, Boolean>} implementation that is configured by a {@code filterSpec} * string provided to the constructor. The function returns {@code true} if the given class name is acceptable * for class resolution, {@code false} otherwise. The function is meant to be used for implementation blocklists * or allowlists of classes that would be loaded when remote Jakarta Enterprise Beans invocations are received. * <p> * The {@code filterSpec} string is composed of one or more filter spec elements separated by the {@code ';'} char. * A filter spec element that begins with the {@code '!'} char is a 'rejecting element' and indicates resolution of a * class name should not be allowed if the rest of the element matches the class name. Otherwise the spec element * indicates the class name can be accepted if it matches. * </p> * <p> * Matching is done according to the following rules: * <ul> * <li>If the spec element does not terminate in the {@code '*'} char the given class name must match.</li> * <li>If the spec element terminates in the string {@code ".*"} the portion of the class name up to and * including any final {@code '.'} char must match. Such a spec element indicates a single package in which a class * must reside.</li> * <li>If the spec element terminates in the string {@code ".**"} the class name must begin with the portion of the * spec element before the first {@code '*'}. Such a spec element indicates a package hierarchy in which a class * must reside.</li> * <li>Otherwise the spec element ends in the {@code '*'} char and the class name must begin with portion * spec element before the first {@code '*'}. Such a spec element indicates a general string 'starts with' match.</li> * </ul> * </> * <p> * The presence of the {@code '='} or {@code '/'} chars anywhere in the filter spec will result in an * {@link IllegalArgumentException} from the constructor. The presence of the {@code '*'} char in any substring * other than the ones described above will also result in an {@link IllegalArgumentException} from the constructor. * </p> * <p> * If any element in the filter spec indicates a class name should be rejected, it will be rejected. If any element * in the filter spec does not begin with the {@code '!'} char, then the filter will act like a allowlist, and * at least one non-rejecting filter spec element must match the class name for the filter to return {@code true}. * Rejecting elements can be used in an overall filter spec for a allowlist, for example to exclude a particular * class from a package that is otherwise allowlisted. * </p> * * @author Brian Stansberry */ final class FilterSpecClassResolverFilter implements Function<String, Boolean> { // Note -- the default filter spec represents a blocklist. /** * Value provided to {@link #FilterSpecClassResolverFilter(String)} by the default no-arg constructor. * Represents the default filtering rules for this library. */ public static final String DEFAULT_FILTER_SPEC = "!org.apache.commons.collections.functors.InvokerTransformer;" + "!org.apache.commons.collections.functors.InstantiateTransformer;" + "!org.apache.commons.collections4.functors.InvokerTransformer;" + "!org.apache.commons.collections4.functors.InstantiateTransformer;" + "!org.codehaus.groovy.runtime.ConvertedClosure;" + "!org.codehaus.groovy.runtime.MethodClosure;" + "!org.springframework.beans.factory.ObjectFactory;" + "!com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;" + "!org.apache.xalan.xsltc.trax.TemplatesImpl"; private static final OperationContext.AttachmentKey<FilterSpecClassResolverFilter> ATTACHMENT_KEY = OperationContext.AttachmentKey.create(FilterSpecClassResolverFilter.class); /** * Gets a {@link FilterSpecClassResolverFilter#FilterSpecClassResolverFilter() default} * {@code FilterSpecClassResolverFilter} that can be shared amongst steps executing * with the same {@link OperationContext}. This is used in preference to a shared static * default filter in order to allow different settings to be applied during a server reload. * * @param operationContext the operation context. Cannot be {@code null} * @return the filter. Will not return {@code null} */ static FilterSpecClassResolverFilter getFilterForOperationContext(OperationContext operationContext) { FilterSpecClassResolverFilter result = operationContext.getAttachment(ATTACHMENT_KEY); if (result == null) { result = new FilterSpecClassResolverFilter(); operationContext.attach(ATTACHMENT_KEY, result); } return result; } private final String filterSpec; private final List<String> parsedFilterSpecs; private final List<Function<String, Boolean>> unmarshallingFilters; private final boolean allowlistUnmarshalling; /** * Creates a filter using the default rules. */ FilterSpecClassResolverFilter() { this(getUnmarshallingFilterSpec()); } private static String getUnmarshallingFilterSpec() { // The default blocklisting can be disabled via system property String disabled = WildFlySecurityManager.getPropertyPrivileged("jboss.ejb.unmarshalling.filter.disabled", null); if ("true".equalsIgnoreCase(disabled)) { return ""; // empty string disables filtering } // This is an unsupported property to facilitate integration testing. It's use can be removed at any time. String spec = WildFlySecurityManager.getPropertyPrivileged("jboss.experimental.ejb.unmarshalling.filter.spec", null); if (spec != null) { return spec; } return DEFAULT_FILTER_SPEC; } /** * Create a filter using the given {@code filterSpec}. * @param filterSpec filter configuration as described in the class javadoc. Cannot be {@code null} * * @throws IllegalArgumentException if the form of {@code filterSpec} violates any of the rules for this class */ FilterSpecClassResolverFilter(String filterSpec) { Assert.checkNotNullParam("filterSpec", filterSpec); this.filterSpec = filterSpec; if (filterSpec.isEmpty()) { parsedFilterSpecs = null; unmarshallingFilters = null; allowlistUnmarshalling = false; } else { parsedFilterSpecs = new ArrayList<>(Arrays.asList(filterSpec.split(";"))); unmarshallingFilters = new ArrayList<>(parsedFilterSpecs.size()); ExactMatchFilter exactMatchAllowlist = null; ExactMatchFilter exactMatchBlocklist = null; boolean allowlist = false; for (String spec : parsedFilterSpecs) { if (spec.contains("=") || spec.contains("/")) { // perhaps this is an attempt to pass a JEPS 290 style limit or module name pattern; not supported throw REMOTE_LOGGER.invalidFilterSpec(spec); } boolean blocklistElement = spec.startsWith("!"); allowlist |= !blocklistElement; // For a blocklist element, return FALSE for a match; i.e. don't resolve // For a allowlist, return TRUE for a match; i.e. definitely do resolve // For any non-match, return null which means that check has no opinion final Boolean matchReturn = blocklistElement ? Boolean.FALSE : Boolean.TRUE; if (blocklistElement) { if (spec.length() == 1) { throw REMOTE_LOGGER.invalidFilterSpec(spec); } spec = spec.substring(1); } Function<String, Boolean> filter = null; int lastStar = spec.lastIndexOf('*'); if (lastStar >= 0) { if (lastStar != spec.length() - 1) { // wildcards only allowed at the end throw REMOTE_LOGGER.invalidFilterSpec(spec); } int firstStar = spec.indexOf('*'); if (firstStar != lastStar) { if (firstStar == lastStar - 1 && spec.endsWith(".**")) { if (spec.length() == 3) { throw REMOTE_LOGGER.invalidFilterSpec(spec); } String pkg = spec.substring(0, spec.length() - 2); filter = cName -> cName.startsWith(pkg) ? matchReturn : null; } else { // there's an extra star in some spot other than between a final '.' and '*' throw REMOTE_LOGGER.invalidFilterSpec(spec); } } else if (spec.endsWith(".*")) { if (spec.length() == 2) { throw REMOTE_LOGGER.invalidFilterSpec(spec); } String pkg = spec.substring(0, spec.length() - 1); filter = cName -> cName.startsWith(pkg) && cName.lastIndexOf('.') == pkg.length() - 1 ? matchReturn : null; } else { String startsWith = spec.substring(0, spec.length() - 1); // note that an empty 'startsWith' is ok; e.g. from a "*" spec to allow all filter = cName -> cName.startsWith(startsWith) ? matchReturn : null; } } else { // For exact matches store them in a set and just do a single set.contains check if (blocklistElement) { if (exactMatchBlocklist == null) { filter = exactMatchBlocklist = new ExactMatchFilter(false); } exactMatchBlocklist.addMatchingClass(spec); } else { if (exactMatchAllowlist == null) { filter = exactMatchAllowlist = new ExactMatchFilter(true); } exactMatchAllowlist.addMatchingClass(spec); } if (filter == null) { // An ExactMatchFilter earlier in the list would have already handled this. // Just add a no-op placeholder function to keep the list of specs and functions in sync filter = cName -> null; } } unmarshallingFilters.add(filter); } if (allowlist) { // Don't force users to allowlist the classes we send. Add a allowlist spec for their package // TODO is this a good idea? final String pkg = "org.jboss.ejb.client."; parsedFilterSpecs.add(pkg + "*"); unmarshallingFilters.add(cName -> cName.startsWith(pkg) && cName.lastIndexOf('.') == pkg.length() - 1 ? true : null); } assert parsedFilterSpecs.size() == unmarshallingFilters.size(); allowlistUnmarshalling = allowlist; } } @Override public Boolean apply(String className) { Assert.checkNotNullParam("className", className); boolean anyAccept = false; if (unmarshallingFilters != null) { for (int i = 0; i < unmarshallingFilters.size(); i++) { Function<String, Boolean> func = unmarshallingFilters.get(i); Boolean accept = func.apply(className); if (accept == Boolean.FALSE) { String failedSpec = func instanceof ExactMatchFilter ? "!" + className : parsedFilterSpecs.get(i); REMOTE_LOGGER.debugf("Class %s has been explicitly rejected by filter spec element %s", className, failedSpec); return false; } else { anyAccept |= accept != null; } } if (allowlistUnmarshalling && !anyAccept) { REMOTE_LOGGER.debugf("Class %s has not been explicitly allowlisted by filter spec %s", className, filterSpec); return false; } } return true; } private static class ExactMatchFilter implements Function<String, Boolean> { private final Set<String> matches = new HashSet<>(); private final Boolean matchResult; private ExactMatchFilter(boolean forAllowlist) { this.matchResult = forAllowlist; } private void addMatchingClass(String name) { matches.add(name); } @Override public Boolean apply(String s) { return matches.contains(s) ? matchResult : null; } } }
14,159
48.51049
157
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/EJB3Subsystem20Parser.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.operations.common.Util; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Set; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import static org.jboss.as.controller.parsing.ParseUtils.missingRequired; import static org.jboss.as.controller.parsing.ParseUtils.requireNoAttributes; import static org.jboss.as.controller.parsing.ParseUtils.requireNoContent; import static org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import static org.jboss.as.ejb3.subsystem.EJB3SubsystemModel.*; /** */ public class EJB3Subsystem20Parser extends EJB3Subsystem14Parser { protected EJB3Subsystem20Parser() { } @Override protected void readElement(final XMLExtendedStreamReader reader, final EJB3SubsystemXMLElement element, final List<ModelNode> operations, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { switch (element) { case TIMER_SERVICE: { parseTimerService(reader, operations); break; } case DISABLE_DEFAULT_EJB_PERMISSIONS: { parseDisableDefaultEjbPermissions(reader, ejb3SubsystemAddOperation); break; } default: { super.readElement(reader, element, operations, ejb3SubsystemAddOperation); } } } private void parseDisableDefaultEjbPermissions(XMLExtendedStreamReader reader, ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { final int count = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> missingRequiredAttributes = EnumSet.of(EJB3SubsystemXMLAttribute.VALUE); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VALUE: EJB3SubsystemRootResourceDefinition.DISABLE_DEFAULT_EJB_PERMISSIONS.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); // found the mandatory attribute missingRequiredAttributes.remove(EJB3SubsystemXMLAttribute.VALUE); break; default: throw unexpectedAttribute(reader, i); } } requireNoContent(reader); if (!missingRequiredAttributes.isEmpty()) { throw missingRequired(reader, missingRequiredAttributes); } } @Override protected EJB3SubsystemNamespace getExpectedNamespace() { return EJB3SubsystemNamespace.EJB3_2_0; } @Override protected void parseStatefulBean(final XMLExtendedStreamReader reader, final List<ModelNode> operations, final ModelNode ejb3SubsystemAddOperation) throws XMLStreamException { final int count = reader.getAttributeCount(); final EnumSet<EJB3SubsystemXMLAttribute> missingRequiredAttributes = EnumSet.of(EJB3SubsystemXMLAttribute.DEFAULT_ACCESS_TIMEOUT, EJB3SubsystemXMLAttribute.CACHE_REF); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case DEFAULT_ACCESS_TIMEOUT: { EJB3SubsystemRootResourceDefinition.DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); break; } case CACHE_REF: { EJB3SubsystemRootResourceDefinition.DEFAULT_SFSB_CACHE.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); break; } case CLUSTERED_CACHE_REF: { EJB3SubsystemRootResourceDefinition.DEFAULT_CLUSTERED_SFSB_CACHE.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); break; } case PASSIVATION_DISABLED_CACHE_REF: { EJB3SubsystemRootResourceDefinition.DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE.parseAndSetParameter(value, ejb3SubsystemAddOperation, reader); break; } default: { throw unexpectedAttribute(reader, i); } } // found the mandatory attribute missingRequiredAttributes.remove(attribute); } requireNoContent(reader); if (!missingRequiredAttributes.isEmpty()) { throw missingRequired(reader, missingRequiredAttributes); } } protected void parseTimerService(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { final ModelNode address = new ModelNode(); address.add(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME); address.add(SERVICE, TIMER_SERVICE); final ModelNode timerServiceAdd = new ModelNode(); timerServiceAdd.get(OP).set(ADD); timerServiceAdd.get(OP_ADDR).set(address); final int attCount = reader.getAttributeCount(); final Set<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.THREAD_POOL_NAME, EJB3SubsystemXMLAttribute.DEFAULT_DATA_STORE); for (int i = 0; i < attCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case THREAD_POOL_NAME: { TimerServiceResourceDefinition.THREAD_POOL_NAME.parseAndSetParameter(value,timerServiceAdd,reader); break; } case DEFAULT_DATA_STORE: { TimerServiceResourceDefinition.DEFAULT_DATA_STORE.parseAndSetParameter(value,timerServiceAdd,reader); break; } default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } operations.add(timerServiceAdd); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case DATA_STORES: { parseDataStores(reader, operations); } } } } protected void parseDataStores(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case FILE_DATA_STORE: { parseFileDataStore(reader, operations); break; } case DATABASE_DATA_STORE: { parseDatabaseDataStore(reader, operations); break; } default: { throw unexpectedElement(reader); } } } } private void parseFileDataStore(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { String dataStorePath = null; String dataStorePathRelativeTo = null; String name = null; final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.NAME, EJB3SubsystemXMLAttribute.PATH); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case NAME: if (name != null) { throw unexpectedAttribute(reader, i); } name = reader.getAttributeValue(i); break; case PATH: if (dataStorePath != null) { throw unexpectedAttribute(reader, i); } dataStorePath = parse(FileDataStoreResourceDefinition.PATH, value, reader).asString(); break; case RELATIVE_TO: if (dataStorePathRelativeTo != null) { throw unexpectedAttribute(reader, i); } dataStorePathRelativeTo = parse(FileDataStoreResourceDefinition.RELATIVE_TO, value, reader).asString(); break; default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } final ModelNode address = new ModelNode(); address.add(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME); address.add(SERVICE, TIMER_SERVICE); address.add(FILE_DATA_STORE, name); final ModelNode fileDataStoreAdd = new ModelNode(); fileDataStoreAdd.get(OP).set(ADD); fileDataStoreAdd.get(ADDRESS).set(address); fileDataStoreAdd.get(PATH).set(dataStorePath); if (dataStorePathRelativeTo != null) { fileDataStoreAdd.get(RELATIVE_TO).set(dataStorePathRelativeTo); } operations.add(fileDataStoreAdd); requireNoContent(reader); } protected void parseDatabaseDataStore(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException { String name = null; final ModelNode databaseDataStore = new ModelNode(); final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.NAME, EJB3SubsystemXMLAttribute.DATASOURCE_JNDI_NAME); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case NAME: if (name != null) { throw unexpectedAttribute(reader, i); } name = reader.getAttributeValue(i); break; case DATASOURCE_JNDI_NAME: DatabaseDataStoreResourceDefinition.DATASOURCE_JNDI_NAME.parseAndSetParameter(value, databaseDataStore, reader); break; case DATABASE: DatabaseDataStoreResourceDefinition.DATABASE.parseAndSetParameter(value, databaseDataStore, reader); break; case PARTITION: DatabaseDataStoreResourceDefinition.PARTITION.parseAndSetParameter(value, databaseDataStore, reader); break; default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } final ModelNode address = new ModelNode(); address.add(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME); address.add(SERVICE, TIMER_SERVICE); address.add(DATABASE_DATA_STORE, name); databaseDataStore.get(OP).set(ADD); databaseDataStore.get(ADDRESS).set(address); operations.add(databaseDataStore); requireNoContent(reader); } @Override protected void parsePassivationStores(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { // no attributes expected requireNoAttributes(reader); while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) { switch (EJB3SubsystemXMLElement.forName(reader.getLocalName())) { case PASSIVATION_STORE: { this.parsePassivationStore(reader, operations); break; } case FILE_PASSIVATION_STORE: { this.parseFilePassivationStore(reader, operations); break; } case CLUSTER_PASSIVATION_STORE: { this.parseClusterPassivationStore(reader, operations); break; } default: { throw unexpectedElement(reader); } } } } protected void parsePassivationStore(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { String name = null; ModelNode operation = Util.createAddOperation(); for (int i = 0; i < reader.getAttributeCount(); i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); switch (EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i))) { case NAME: { name = value; break; } case MAX_SIZE: { PassivationStoreResourceDefinition.MAX_SIZE.parseAndSetParameter(value, operation, reader); break; } case CACHE_CONTAINER: { PassivationStoreResourceDefinition.CACHE_CONTAINER.parseAndSetParameter(value, operation, reader); break; } case BEAN_CACHE: { PassivationStoreResourceDefinition.BEAN_CACHE.parseAndSetParameter(value, operation, reader); break; } default: { throw unexpectedAttribute(reader, i); } } } requireNoContent(reader); if (name == null) { throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.NAME.getLocalName())); } // create and add the operation operation.get(OP_ADDR).set(SUBSYSTEM_PATH.append(PASSIVATION_STORE, name).toModelNode()); operations.add(operation); } }
16,730
45.34626
212
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/RemotingProfileResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ServiceRemoveStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.ejb3.remote.RemotingProfileService; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; /** * {@link org.jboss.as.controller.ResourceDefinition} for remoting profiles. * * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ public class RemotingProfileResourceDefinition extends SimpleResourceDefinition { public static final String REMOTING_PROFILE_CAPABILITY_NAME = "org.wildfly.ejb3.remoting-profile"; public static final RuntimeCapability<Void> REMOTING_PROFILE_CAPABILITY = RuntimeCapability.Builder.of(REMOTING_PROFILE_CAPABILITY_NAME, true, RemotingProfileService.class).build(); public static final SimpleAttributeDefinition EXCLUDE_LOCAL_RECEIVER = new SimpleAttributeDefinitionBuilder( EJB3SubsystemModel.EXCLUDE_LOCAL_RECEIVER, ModelType.BOOLEAN, true).setAllowExpression(true) .setDefaultValue(ModelNode.FALSE).build(); public static final SimpleAttributeDefinition LOCAL_RECEIVER_PASS_BY_VALUE = new SimpleAttributeDefinitionBuilder( EJB3SubsystemModel.LOCAL_RECEIVER_PASS_BY_VALUE, ModelType.BOOLEAN, true).setAllowExpression(true).build(); private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { EXCLUDE_LOCAL_RECEIVER, LOCAL_RECEIVER_PASS_BY_VALUE, StaticEJBDiscoveryDefinition.INSTANCE }; static final RemotingProfileAdd ADD_HANDLER = new RemotingProfileAdd(ATTRIBUTES); RemotingProfileResourceDefinition() { super(new Parameters(EJB3SubsystemModel.REMOTING_PROFILE_PATH, EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.REMOTING_PROFILE)) .setAddHandler(ADD_HANDLER) .setRemoveHandler(new ServiceRemoveStepHandler(ADD_HANDLER)) .setCapabilities(REMOTING_PROFILE_CAPABILITY)); } @Override public void registerChildren(ManagementResourceRegistration subsystemRegistration) { subsystemRegistration.registerSubModel(new RemotingEjbReceiverDefinition()); subsystemRegistration.registerSubModel(new RemoteHttpConnectionDefinition()); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { for (AttributeDefinition attr : ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(attr, null, new RemotingProfileResourceChildWriteAttributeHandler(attr)); } } }
3,908
49.766234
182
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/PassivationStoreAdd.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.ejb3.component.stateful.cache.distributable.LegacyDistributableStatefulSessionBeanCacheProviderServiceConfigurator; import org.jboss.dmr.ModelNode; import org.jboss.msc.service.ServiceController; import org.wildfly.clustering.ejb.bean.LegacyBeanManagementConfiguration; /** * @author Paul Ferraro */ @Deprecated public class PassivationStoreAdd extends AbstractAddStepHandler { private final AttributeDefinition[] attributes; PassivationStoreAdd(AttributeDefinition... attributes) { this.attributes = attributes; } @Override protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { for (AttributeDefinition attr : this.attributes) { attr.validateAndSet(operation, model); } } @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { int initialMaxSize = PassivationStoreResourceDefinition.MAX_SIZE.resolveModelAttribute(context, model).asInt(); String containerName = PassivationStoreResourceDefinition.CACHE_CONTAINER.resolveModelAttribute(context, model).asString(); ModelNode beanCacheNode = PassivationStoreResourceDefinition.BEAN_CACHE.resolveModelAttribute(context, model); String cacheName = beanCacheNode.isDefined() ? beanCacheNode.asString() : null; this.install(context, operation, initialMaxSize, containerName, cacheName); } protected void install(OperationContext context, ModelNode operation, final int maxSize, final String containerName, final String cacheName) { LegacyBeanManagementConfiguration config = new LegacyBeanManagementConfiguration() { @Override public String getContainerName() { return containerName; } @Override public String getCacheName() { return cacheName; } @Override public Integer getMaxActiveBeans() { return maxSize; } }; new LegacyDistributableStatefulSessionBeanCacheProviderServiceConfigurator<>(context.getCurrentAddress(), config).build(context.getServiceTarget()) .setInitialMode(ServiceController.Mode.ON_DEMAND) .install(); } }
3,640
42.345238
155
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/IdentityResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Function; import java.util.function.Consumer; import java.util.function.Supplier; import org.jboss.as.controller.AbstractAddStepHandler; import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.AttributeParser; import org.jboss.as.controller.CapabilityServiceBuilder; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.ReloadRequiredRemoveStepHandler; import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler; import org.jboss.as.controller.ResourceDefinition; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.StringListAttributeDefinition; import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.registry.OperationEntry; import org.jboss.as.controller.registry.Resource; import org.jboss.dmr.ModelNode; import org.jboss.msc.Service; import org.jboss.msc.service.StartContext; import org.jboss.msc.service.StartException; import org.jboss.msc.service.StopContext; import org.wildfly.security.auth.server.RealmUnavailableException; import org.wildfly.security.auth.server.SecurityDomain; import org.wildfly.security.auth.server.SecurityIdentity; import org.wildfly.security.auth.server.ServerAuthenticationContext; /** * A {@link ResourceDefinition} to define the security domains to attempt to outflow an established identity to. * * @author <a href="mailto:[email protected]">Farah Juma</a> */ public class IdentityResourceDefinition extends SimpleResourceDefinition { private static final String SECURITY_DOMAIN_CAPABILITY_NAME = "org.wildfly.security.security-domain"; public static final String IDENTITY_CAPABILITY_NAME = "org.wildfly.ejb3.identity"; static final RuntimeCapability<Void> IDENTITY_CAPABILITY = RuntimeCapability.Builder.of(IDENTITY_CAPABILITY_NAME, Function.class) .build(); public static final StringListAttributeDefinition OUTFLOW_SECURITY_DOMAINS = new StringListAttributeDefinition.Builder(EJB3SubsystemModel.OUTFLOW_SECURITY_DOMAINS) .setRequired(false) .setMinSize(1) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setAttributeParser(AttributeParser.STRING_LIST) .setCapabilityReference(SECURITY_DOMAIN_CAPABILITY_NAME, IDENTITY_CAPABILITY) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.ELYTRON_SECURITY_DOMAIN_REF) .build(); private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] { OUTFLOW_SECURITY_DOMAINS }; IdentityResourceDefinition(List<String> outflowSecurityDomains) { super(new SimpleResourceDefinition.Parameters(EJB3SubsystemModel.IDENTITY_PATH, EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.IDENTITY)) .setAddHandler(new AddHandler(outflowSecurityDomains)) // .setAddRestartLevel(OperationEntry.Flag.RESTART_ALL_SERVICES) .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_ALL_SERVICES) .setCapabilities(IDENTITY_CAPABILITY)); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { ReloadRequiredWriteAttributeHandler handler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES); for (AttributeDefinition attribute: ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(attribute, null, handler); } } private static class AddHandler extends AbstractAddStepHandler { private final List<String> outflowSecurityDomains; private AddHandler(List<String> outflowSecurityDomains) { super(OUTFLOW_SECURITY_DOMAINS); this.outflowSecurityDomains = outflowSecurityDomains; } @Override protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { super.populateModel(context, operation, resource); this.outflowSecurityDomains.clear(); this.outflowSecurityDomains.addAll(OUTFLOW_SECURITY_DOMAINS.unwrap(context, resource.getModel())); } @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final List<Supplier<SecurityDomain>> outflowSecurityDomainSuppliers = new ArrayList<>(); final CapabilityServiceBuilder<?> sb = context.getCapabilityServiceTarget().addCapability(IDENTITY_CAPABILITY); final Consumer<Function<SecurityIdentity, Set<SecurityIdentity>>> consumer = sb.provides(IDENTITY_CAPABILITY); for (String outflowSecurityDomain : outflowSecurityDomains) { outflowSecurityDomainSuppliers.add(sb.requiresCapability(SECURITY_DOMAIN_CAPABILITY_NAME, SecurityDomain.class, outflowSecurityDomain)); } IdentityService identityService = new IdentityService(consumer, outflowSecurityDomainSuppliers); sb.setInstance(identityService).install(); } } static class IdentityService implements Service { private final Consumer<Function<SecurityIdentity, Set<SecurityIdentity>>> consumer; private final List<Supplier<SecurityDomain>> outflowSecurityDomainSuppliers; private Set<SecurityDomain> outflowSecurityDomains = new HashSet<>(); private IdentityService(final Consumer<Function<SecurityIdentity, Set<SecurityIdentity>>> consumer, final List<Supplier<SecurityDomain>> outflowSecurityDomainSuppliers) { this.consumer = consumer; this.outflowSecurityDomainSuppliers = outflowSecurityDomainSuppliers; } @Override public void start(StartContext context) throws StartException { HashSet<SecurityDomain> securityDomains = new HashSet<>(); for (Supplier<SecurityDomain> outflowSecurityDomainInjector : outflowSecurityDomainSuppliers) { SecurityDomain value = outflowSecurityDomainInjector.get(); securityDomains.add(value); } outflowSecurityDomains.addAll(securityDomains); consumer.accept(this::outflowIdentity); } private Set<SecurityIdentity> outflowIdentity(final SecurityIdentity securityIdentity) { Set<SecurityIdentity> outflowedIdentities = new HashSet<>(outflowSecurityDomains.size()); if (securityIdentity != null) { // Attempt to outflow the established identity to each domain in the list for (SecurityDomain outflowSecurityDomain : outflowSecurityDomains) { try { ServerAuthenticationContext serverAuthenticationContext = outflowSecurityDomain.createNewAuthenticationContext(); if (serverAuthenticationContext.importIdentity(securityIdentity)) { outflowedIdentities.add(serverAuthenticationContext.getAuthorizedIdentity()); } } catch (RealmUnavailableException | IllegalStateException e) { // Ignored } } } return outflowedIdentities; } @Override public void stop(StopContext context) { consumer.accept(null); outflowSecurityDomains.clear(); } } }
8,969
50.257143
178
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/DistributableStatefulSessionBeanCacheProviderResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2022, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; 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.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.registry.AttributeAccess; import org.jboss.as.ejb3.component.stateful.cache.distributable.DistributableStatefulSessionBeanCacheProviderServiceConfigurator; import org.jboss.dmr.ModelType; import org.wildfly.clustering.ejb.bean.BeanProviderRequirement; /** * Defines a CacheFactoryBuilder instance which, during deployment, is used to configure, build and install a CacheFactory for the SFSB being deployed. * The CacheFactory resource instances defined here produce bean caches which are non distributed and do not have passivation-enabled. * * @author Paul Ferraro * @author Richard Achmatowicz */ public class DistributableStatefulSessionBeanCacheProviderResourceDefinition extends StatefulSessionBeanCacheProviderResourceDefinition { public enum Attribute implements org.jboss.as.clustering.controller.Attribute { BEAN_MANAGEMENT(EJB3SubsystemModel.BEAN_MANAGEMENT, ModelType.STRING, new CapabilityReference(Capability.CACHE_FACTORY, BeanProviderRequirement.BEAN_MANAGEMENT_PROVIDER)) ; private final AttributeDefinition definition; Attribute(String name, ModelType type, CapabilityReference referenece) { this.definition = new SimpleAttributeDefinitionBuilder(name, type) .setAllowExpression(false) .setRequired(false) .setFlags(AttributeAccess.Flag.RESTART_NONE) .setCapabilityReference(referenece) .build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } public DistributableStatefulSessionBeanCacheProviderResourceDefinition() { super(EJB3SubsystemModel.DISTRIBUTABLE_CACHE_PATH, new SimpleResourceDescriptorConfigurator<>(Attribute.class), DistributableStatefulSessionBeanCacheProviderServiceConfigurator::new); } }
3,237
48.060606
191
java
null
wildfly-main/ejb3/src/main/java/org/jboss/as/ejb3/subsystem/MdbDeliveryGroupResourceDefinition.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.ejb3.subsystem; import org.jboss.as.controller.AbstractWriteAttributeHandler; import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationFailedException; import org.jboss.as.controller.ReloadRequiredRemoveStepHandler; import org.jboss.as.controller.SimpleAttributeDefinition; import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.capability.RuntimeCapability; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.jboss.msc.Service; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceName; /** * {@link org.jboss.as.controller.ResourceDefinition} for mdb delivery group. * * @author Flavia Rainone */ public class MdbDeliveryGroupResourceDefinition extends SimpleResourceDefinition { public static final String MDB_DELIVERY_GROUP_CAPABILITY_NAME = "org.wildfly.ejb3.mdb-delivery-group"; public static final RuntimeCapability<Void> MDB_DELIVERY_GROUP_CAPABILITY = RuntimeCapability.Builder.of(MDB_DELIVERY_GROUP_CAPABILITY_NAME, true, Service.NULL.getClass()).build(); public static final SimpleAttributeDefinition ACTIVE = new SimpleAttributeDefinitionBuilder(EJB3SubsystemModel.MDB_DELVIERY_GROUP_ACTIVE, ModelType.BOOLEAN, true) .setAllowExpression(true) .setDefaultValue(ModelNode.TRUE) .build(); MdbDeliveryGroupResourceDefinition() { super(new SimpleResourceDefinition.Parameters(EJB3SubsystemModel.MDB_DELIVERY_GROUP_PATH, EJB3Extension.getResourceDescriptionResolver(EJB3SubsystemModel.MDB_DELIVERY_GROUP)) .setAddHandler(MdbDeliveryGroupAdd.INSTANCE) .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE) .setCapabilities(MDB_DELIVERY_GROUP_CAPABILITY)); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { resourceRegistration.registerReadWriteAttribute(ACTIVE, null, new AbstractWriteAttributeHandler<Void>(ACTIVE) { @Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { updateDeliveryGroup(context, currentValue, resolvedValue); return false; } @Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { updateDeliveryGroup(context, valueToRevert, valueToRestore); } protected void updateDeliveryGroup(OperationContext context, ModelNode currentValue, ModelNode resolvedValue) throws OperationFailedException { if (currentValue.equals(resolvedValue)) { return; } String groupName = context.getCurrentAddressValue(); ServiceName deliveryGroupServiceName = context.getCapabilityServiceName(MdbDeliveryGroupResourceDefinition.MDB_DELIVERY_GROUP_CAPABILITY_NAME, Service.NULL.getClass(), groupName); context.getServiceRegistry(true).getRequiredService(deliveryGroupServiceName) .setMode(resolvedValue.asBoolean() ? ServiceController.Mode.ACTIVE : ServiceController.Mode.NEVER); } }); } }
5,093
52.0625
203
java