@Override public void performRuntime(final OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { // Compensating is remove final ModelNode address = operation.require(OP_ADDR); final String name = PathAddress.pathAddress(address).getLastElement().getValue(); final String archiveOrModuleName; if (!model.hasDefined(ARCHIVE.getName()) && !model.hasDefined(MODULE.getName())) { throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired(); } if (model.get(ARCHIVE.getName()).isDefined()) { archiveOrModuleName = model.get(ARCHIVE.getName()).asString(); } else { archiveOrModuleName = model.get(MODULE.getName()).asString(); } ModifiableResourceAdapter resourceAdapter = RaOperationUtil.buildResourceAdaptersObject(name, context, operation, archiveOrModuleName); List<ServiceController<?>> newControllers = new ArrayList<ServiceController<?>>(); if (model.get(ARCHIVE.getName()).isDefined()) { RaOperationUtil.installRaServices(context, name, resourceAdapter, newControllers); } else { RaOperationUtil.installRaServicesAndDeployFromModule( context, name, resourceAdapter, archiveOrModuleName, newControllers); if (context.isBooting()) { context.addStep( new OperationStepHandler() { public void execute(final OperationContext context, ModelNode operation) throws OperationFailedException { // Next lines activate configuration on module deployed rar // in case there is 2 different resource-adapter config using same module deployed // rar // a Deployment sercivice could be already present and need a restart to consider // also this // newly added configuration ServiceName restartedServiceName = RaOperationUtil.restartIfPresent(context, archiveOrModuleName, name); if (restartedServiceName == null) { RaOperationUtil.activate(context, name, archiveOrModuleName); } context.completeStep( new OperationContext.RollbackHandler() { @Override public void handleRollback(OperationContext context, ModelNode operation) { try { RaOperationUtil.removeIfActive(context, archiveOrModuleName, name); } catch (OperationFailedException e) { } } }); } }, OperationContext.Stage.RUNTIME); } } }
@Override public void chargeViewInfo() { Intent intent = getIntent(); beanCommunicator = intent.getParcelableExtra(MODULE.name()); String[] params = {"idContact", beanCommunicator.id}; this.executeTask(params, TypeInfoServer.getContact); }
@Override public Builder<Configuration> configure(OperationContext context, ModelNode model) throws OperationFailedException { this.module = ModelNodes.asModuleIdentifier(MODULE.getDefinition().resolveModelAttribute(context, model)); boolean enabled = STATISTICS_ENABLED.getDefinition().resolveModelAttribute(context, model).asBoolean(); this.statistics = new ConfigurationBuilder().jmxStatistics().enabled(enabled).available(enabled).create(); return this; }
@Override public Builder<P> configure(OperationContext context, ModelNode model) throws OperationFailedException { this.module = ModelNodes.asModuleIdentifier(MODULE.getDefinition().resolveModelAttribute(context, model)); String binding = ModelNodes.asString(SOCKET_BINDING.getDefinition().resolveModelAttribute(context, model)); if (binding != null) { this.socketBinding = new InjectedValueDependency<>( SocketBinding.JBOSS_BINDING_NAME.append(binding), SocketBinding.class); } for (Property property : ModelNodes.asPropertyList( PROPERTIES.getDefinition().resolveModelAttribute(context, model))) { this.properties.put(property.getName(), property.getValue().asString()); } return this; }
/** * Create a new compiled code object with the given properties. * * @param nybbles The nybblecodes. * @param locals The number of local variables. * @param stack The maximum stack depth. * @param functionType The type that the code's functions will have. * @param primitive Which primitive to invoke, or zero. * @param literals A tuple of literals. * @param localTypes A tuple of types of local variables. * @param outerTypes A tuple of types of outer (captured) variables. * @param module The module in which the code, or nil. * @param lineNumber The module line number on which this code starts. * @return The new compiled code object. */ public static AvailObject create( final A_Tuple nybbles, final int locals, final int stack, final A_Type functionType, final @Nullable Primitive primitive, final A_Tuple literals, final A_Tuple localTypes, final A_Tuple outerTypes, final A_Module module, final int lineNumber) { if (primitive != null) { // Sanity check for primitive blocks. Use this to hunt incorrectly // specified primitive signatures. final boolean canHaveCode = primitive.canHaveNybblecodes(); assert canHaveCode == (nybbles.tupleSize() > 0); final A_Type restrictionSignature = primitive.blockTypeRestriction(); assert restrictionSignature.isSubtypeOf(functionType); } else { assert nybbles.tupleSize() > 0; } assert localTypes.tupleSize() == locals; final A_Type argCounts = functionType.argsTupleType().sizeRange(); final int numArgs = argCounts.lowerBound().extractInt(); assert argCounts.upperBound().extractInt() == numArgs; final int literalsSize = literals.tupleSize(); final int outersSize = outerTypes.tupleSize(); assert 0 <= numArgs && numArgs <= 0xFFFF; assert 0 <= locals && locals <= 0xFFFF; final int slotCount = numArgs + locals + stack; assert 0 <= slotCount && slotCount <= 0xFFFF; assert 0 <= outersSize && outersSize <= 0xFFFF; assert module.equalsNil() || module.isInstanceOf(MODULE.o()); assert lineNumber >= 0; final AvailObject code = mutable.create(literalsSize + outersSize + locals); final InvocationStatistic statistic = new InvocationStatistic(); statistic.countdownToReoptimize.set(L2Chunk.countdownForNewCode()); final AvailObject statisticPojo = RawPojoDescriptor.identityWrap(statistic); code.setSlot(NUM_LOCALS, locals); code.setSlot(NUM_ARGS, numArgs); code.setSlot(FRAME_SLOTS, slotCount); code.setSlot(NUM_OUTERS, outersSize); code.setSlot(PRIMITIVE, primitive == null ? 0 : primitive.primitiveNumber); code.setSlot(NYBBLES, nybbles.makeShared()); code.setSlot(FUNCTION_TYPE, functionType.makeShared()); code.setSlot(PROPERTY_ATOM, NilDescriptor.nil()); code.setSlot(STARTING_CHUNK, L2Chunk.unoptimizedChunk().chunkPojo); code.setSlot(INVOCATION_STATISTIC, statisticPojo); // Fill in the literals. int dest; for (dest = 1; dest <= literalsSize; dest++) { code.setSlot(LITERAL_AT_, dest, literals.tupleAt(dest).makeShared()); } for (int i = 1; i <= outersSize; i++) { code.setSlot(LITERAL_AT_, dest++, outerTypes.tupleAt(i).makeShared()); } for (int i = 1; i <= locals; i++) { code.setSlot(LITERAL_AT_, dest++, localTypes.tupleAt(i).makeShared()); } assert dest == literalsSize + outersSize + locals + 1; final A_Atom propertyAtom = AtomWithPropertiesDescriptor.create(TupleDescriptor.empty(), module); propertyAtom.setAtomProperty(lineNumberKeyAtom(), IntegerDescriptor.fromInt(lineNumber)); code.setSlot(PROPERTY_ATOM, propertyAtom.makeShared()); final int hash = propertyAtom.hash() ^ -0x3087B215; code.setSlot(HASH, hash); code.makeShared(); // Add the newborn raw function to the weak set being used for code // coverage tracking. activeRawFunctions.add(code); return code; }
private void writeRaElement(XMLExtendedStreamWriter streamWriter, ModelNode ra, final String name) throws XMLStreamException { streamWriter.writeStartElement(Activations.Tag.RESOURCE_ADAPTER.getLocalName()); streamWriter.writeAttribute(ResourceAdapterParser.Attribute.ID.getLocalName(), name); STATISTICS_ENABLED.marshallAsAttribute(ra, streamWriter); ARCHIVE.marshallAsElement(ra, streamWriter); MODULE.marshallAsElement(ra, streamWriter); BOOTSTRAP_CONTEXT.marshallAsElement(ra, streamWriter); if (ra.hasDefined(BEANVALIDATION_GROUPS.getName())) { streamWriter.writeStartElement(Activation.Tag.BEAN_VALIDATION_GROUPS.getLocalName()); for (ModelNode bvg : ra.get(BEANVALIDATION_GROUPS.getName()).asList()) { streamWriter.writeStartElement(BEANVALIDATION_GROUPS.getXmlName()); streamWriter.writeCharacters(bvg.asString()); streamWriter.writeEndElement(); } streamWriter.writeEndElement(); } TRANSACTION_SUPPORT.marshallAsElement(ra, streamWriter); writeNewConfigProperties(streamWriter, ra); TransactionSupportEnum transactionSupport = ra.hasDefined(TRANSACTION_SUPPORT.getName()) ? TransactionSupportEnum.valueOf(ra.get(TRANSACTION_SUPPORT.getName()).asString()) : null; boolean isXa = false; if (transactionSupport == TransactionSupportEnum.XATransaction) { isXa = true; } if (ra.hasDefined(WM_SECURITY.getName()) && ra.get(WM_SECURITY.getName()).asBoolean()) { streamWriter.writeStartElement(Activation.Tag.WORKMANAGER.getLocalName()); streamWriter.writeStartElement(WorkManager.Tag.SECURITY.getLocalName()); WM_SECURITY_MAPPING_REQUIRED.marshallAsElement(ra, streamWriter); WM_SECURITY_DOMAIN.marshallAsElement(ra, streamWriter); WM_SECURITY_DEFAULT_PRINCIPAL.marshallAsElement(ra, streamWriter); if (ra.hasDefined(WM_SECURITY_DEFAULT_GROUPS.getName())) { streamWriter.writeStartElement(WM_SECURITY_DEFAULT_GROUPS.getXmlName()); for (ModelNode group : ra.get(WM_SECURITY_DEFAULT_GROUPS.getName()).asList()) { streamWriter.writeStartElement(WM_SECURITY_DEFAULT_GROUP.getXmlName()); streamWriter.writeCharacters(group.asString()); streamWriter.writeEndElement(); } streamWriter.writeEndElement(); } if (ra.hasDefined(WM_SECURITY_MAPPING_USERS.getName()) || ra.hasDefined(WM_SECURITY_MAPPING_GROUPS.getName())) { streamWriter.writeStartElement(WorkManagerSecurity.Tag.MAPPINGS.getLocalName()); if (ra.hasDefined(WM_SECURITY_MAPPING_USERS.getName())) { streamWriter.writeStartElement(WorkManagerSecurity.Tag.USERS.getLocalName()); for (ModelNode node : ra.get(WM_SECURITY_MAPPING_USERS.getName()).asList()) { streamWriter.writeStartElement(WorkManagerSecurity.Tag.MAP.getLocalName()); WM_SECURITY_MAPPING_FROM.marshallAsAttribute(node, streamWriter); WM_SECURITY_MAPPING_TO.marshallAsAttribute(node, streamWriter); streamWriter.writeEndElement(); } streamWriter.writeEndElement(); } if (ra.hasDefined(WM_SECURITY_MAPPING_GROUPS.getName())) { streamWriter.writeStartElement(WorkManagerSecurity.Tag.GROUPS.getLocalName()); for (ModelNode node : ra.get(WM_SECURITY_MAPPING_GROUPS.getName()).asList()) { streamWriter.writeStartElement(WorkManagerSecurity.Tag.MAP.getLocalName()); WM_SECURITY_MAPPING_FROM.marshallAsAttribute(node, streamWriter); WM_SECURITY_MAPPING_TO.marshallAsAttribute(node, streamWriter); streamWriter.writeEndElement(); } streamWriter.writeEndElement(); } streamWriter.writeEndElement(); } streamWriter.writeEndElement(); streamWriter.writeEndElement(); } if (ra.hasDefined(CONNECTIONDEFINITIONS_NAME)) { streamWriter.writeStartElement(Activation.Tag.CONNECTION_DEFINITIONS.getLocalName()); for (Property conDef : ra.get(CONNECTIONDEFINITIONS_NAME).asPropertyList()) { writeConDef(streamWriter, conDef.getValue(), conDef.getName(), isXa); } streamWriter.writeEndElement(); } if (ra.hasDefined(ADMIN_OBJECTS_NAME)) { streamWriter.writeStartElement(Activation.Tag.ADMIN_OBJECTS.getLocalName()); for (Property adminObject : ra.get(ADMIN_OBJECTS_NAME).asPropertyList()) { writeAdminObject(streamWriter, adminObject.getValue(), adminObject.getName()); } streamWriter.writeEndElement(); } streamWriter.writeEndElement(); }