protected void destroy(T bean) { doRemove(bean); }
@Override public void handleRollback(OperationContext context, ModelNode operation) { pool.setMaxSize(oldSize); } });
@Override public EJBBoundPoolMetaData parse(final XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { final String element = reader.getLocalName(); // we only parse <pool> (root) element if (!ROOT_ELEMENT_POOL.equals(element)) { throw unexpectedElement(reader); } final EJBBoundPoolMetaData ejbBoundPoolMetaData = new EJBBoundPoolMetaData(); this.processElements(ejbBoundPoolMetaData, reader, propertyReplacer); return ejbBoundPoolMetaData; }
final ModelNode result = context.getResult(); if (pool != null) { result.set(pool.getAvailableCount()); final ModelNode result = context.getResult(); if (pool != null) { result.set(pool.getCreateCount()); final ModelNode result = context.getResult(); if (pool != null) { result.set(pool.getRemoveCount()); final ModelNode result = context.getResult(); if (pool != null) { result.set(pool.getCurrentSize()); final ModelNode result = context.getResult(); if (pool != null) { result.set(pool.getMaxSize());
@Override protected void processElement(final EJBBoundPoolMetaData poolMetaData, final XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { final String namespaceURI = reader.getNamespaceURI(); final String elementName = reader.getLocalName(); // if it doesn't belong to our namespace then let the super handle this if (!NAMESPACE_URI.equals(namespaceURI)) { super.processElement(poolMetaData, reader, propertyReplacer); return; } if (ELEMENT_BEAN_INSTANCE_POOL_REF.equals(elementName)) { final String poolName = getElementText(reader, propertyReplacer); // set the pool name in the metadata poolMetaData.setPoolName(poolName); } else { throw unexpectedElement(reader); } } }
@Override public Object processInvocation(InterceptorContext context) throws Exception { PooledComponent<ComponentInstance> component = (PooledComponent<ComponentInstance>) getComponent(context, EJBComponent.class); ComponentInstance instance = component.getPool().get(); context.putPrivateData(ComponentInstance.class, instance); boolean discarded = false; component.getPool().discard(instance); component.getPool().discard(instance); throw e; } catch (final Throwable t) { discarded = true; component.getPool().discard(instance); throw new RuntimeException(t); } finally { if (!discarded) { component.getPool().release(instance);
@Override protected void handleDeploymentDescriptor(DeploymentUnit deploymentUnit, DeploymentReflectionIndex deploymentReflectionIndex, Class<?> componentClass, T description) throws DeploymentUnitProcessingException { final String ejbName = description.getEJBName(); final EjbJarMetaData metaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA); if (metaData == null) { return; } final AssemblyDescriptorMetaData assemblyDescriptor = metaData.getAssemblyDescriptor(); if (assemblyDescriptor == null) { return; } // get the pool metadata final List<EJBBoundPoolMetaData> pools = assemblyDescriptor.getAny(EJBBoundPoolMetaData.class); String poolName = null; if (pools != null) { for (final EJBBoundPoolMetaData poolMetaData : pools) { // if this applies for all EJBs and if there isn't a pool name already explicitly specified // for the specific bean (i.e. via an ejb-name match) if ("*".equals(poolMetaData.getEjbName()) && poolName == null) { poolName = poolMetaData.getPoolName(); } else if (ejbName.equals(poolMetaData.getEjbName())) { poolName = poolMetaData.getPoolName(); } } } if (poolName != null) { this.setPoolName(description, poolName); } }
protected void executeWriteAttribute(String attributeName, OperationContext context, ModelNode operation, T component, PathAddress address) throws OperationFailedException { if (componentType.hasPool() && POOL_MAX_SIZE.getName().equals(attributeName)) { int newSize = POOL_MAX_SIZE.resolveValue(context, operation.get(VALUE)).asInt(); final Pool<?> pool = componentType.getPool(component); final int oldSize = pool.getMaxSize(); componentType.getPool(component).setMaxSize(newSize); context.completeStep(new OperationContext.RollbackHandler() { @Override public void handleRollback(OperationContext context, ModelNode operation) { pool.setMaxSize(oldSize); } }); } else { // Bug; we were registered for an attribute but there is no code for handling it throw EjbLogger.ROOT_LOGGER.unknownAttribute(attributeName); } }
@Override public void init() { super.init(); if(this.pool!=null){ this.pool.start(); } }
@Override public void done() { if(this.pool!=null){ this.pool.stop(); } super.done(); }
protected T create() { T bean = factory.create(); createCount.incrementAndGet(); return bean; }
/** * Remove the bean context and invoke any callbacks * and track the remove count * * @param bean */ protected void doRemove(T bean) { try { factory.destroy(bean); } finally { removeCount.incrementAndGet(); } } }
static Map<String, AbstractMetaDataParser<?>> createJbossEjbJarParsers() { Map<String, AbstractMetaDataParser<?>> parsers = new HashMap<String, AbstractMetaDataParser<?>>(); for (ClusteringSchema schema : EnumSet.allOf(ClusteringSchema.class)) { parsers.put(schema.getNamespaceUri(), new EJBBoundClusteringMetaDataParser(schema)); } parsers.put(EJBBoundSecurityMetaDataParser.LEGACY_NAMESPACE_URI, EJBBoundSecurityMetaDataParser.INSTANCE); parsers.put(EJBBoundSecurityMetaDataParser.NAMESPACE_URI_1_0, EJBBoundSecurityMetaDataParser.INSTANCE); parsers.put(EJBBoundSecurityMetaDataParser11.NAMESPACE_URI_1_1, EJBBoundSecurityMetaDataParser11.INSTANCE); parsers.put(SecurityRoleMetaDataParser.LEGACY_NAMESPACE_URI, SecurityRoleMetaDataParser.INSTANCE); parsers.put(SecurityRoleMetaDataParser.NAMESPACE_URI, SecurityRoleMetaDataParser.INSTANCE); parsers.put(EJBBoundResourceAdapterBindingMetaDataParser.LEGACY_NAMESPACE_URI, EJBBoundResourceAdapterBindingMetaDataParser.INSTANCE); parsers.put(EJBBoundResourceAdapterBindingMetaDataParser.NAMESPACE_URI, EJBBoundResourceAdapterBindingMetaDataParser.INSTANCE); parsers.put(EJBBoundMdbDeliveryMetaDataParser.NAMESPACE_URI_1_0, EJBBoundMdbDeliveryMetaDataParser.INSTANCE); parsers.put(EJBBoundMdbDeliveryMetaDataParser11.NAMESPACE_URI_1_1, EJBBoundMdbDeliveryMetaDataParser11.INSTANCE); parsers.put("urn:iiop", new IIOPMetaDataParser()); parsers.put("urn:iiop:1.0", new IIOPMetaDataParser()); parsers.put("urn:trans-timeout", new TransactionTimeoutMetaDataParser()); parsers.put("urn:trans-timeout:1.0", new TransactionTimeoutMetaDataParser()); parsers.put(EJBBoundPoolParser.NAMESPACE_URI, new EJBBoundPoolParser()); parsers.put(EJBBoundCacheParser.NAMESPACE_URI, new EJBBoundCacheParser()); parsers.put(ContainerInterceptorsParser.NAMESPACE_URI_1_0, ContainerInterceptorsParser.INSTANCE); parsers.put(TimerServiceMetaDataParser.NAMESPACE_URI, TimerServiceMetaDataParser.INSTANCE); return parsers; } }
@Deprecated protected void remove(T bean) { this.doRemove(bean); }
@Override public void init() { if (endpoint == null) { throw EjbLogger.ROOT_LOGGER.endpointUnAvailable(this.getComponentName()); } super.init(); suspendController.registerActivity(serverActivity); if (this.pool != null) { this.pool.start(); } }
@Override public void done() { synchronized (this) { if (this.deliveryActive) { this.deactivate(); } this.started = false; } if (this.pool != null) { this.pool.stop(); } suspendController.unRegisterActivity(serverActivity); super.done(); }
public void discard(T ctx) { if (ROOT_LOGGER.isTraceEnabled()) { ROOT_LOGGER.tracef("Discard instance %s#%s", this, ctx); } // If we block when maxSize instances are in use, invoke release on strictMaxSize semaphore.release(); // Let the super do any other remove stuff super.doRemove(ctx); }
@Override @Deprecated public void remove(T ctx) { if (ROOT_LOGGER.isTraceEnabled()) { ROOT_LOGGER.tracef("Removing instance: %s#%s", this, ctx); } semaphore.release(); // let the super do the other remove stuff super.doRemove(ctx); }