Search in sources :

Example 1 with RiverMarshallerFactory

use of org.jboss.marshalling.river.RiverMarshallerFactory in project wildfly by wildfly.

the class FileTimerPersistence method doStart.

private void doStart() {
    final RiverMarshallerFactory factory = new RiverMarshallerFactory();
    final MarshallingConfiguration configuration = new MarshallingConfiguration();
    configuration.setClassResolver(ModularClassResolver.getInstance(moduleLoader.getValue()));
    configuration.setVersion(3);
    this.configuration = configuration;
    this.factory = factory;
    if (pathRelativeTo != null) {
        callbackHandle = pathManager.getValue().registerCallback(pathRelativeTo, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED);
    }
    baseDir = new File(pathManager.getValue().resolveRelativePathEntry(path, pathRelativeTo));
    if (!baseDir.exists()) {
        if (createIfNotExists) {
            if (!baseDir.mkdirs()) {
                throw EJB3_TIMER_LOGGER.failToCreateTimerFileStoreDir(baseDir);
            }
        } else {
            throw EJB3_TIMER_LOGGER.timerFileStoreDirNotExist(baseDir);
        }
    }
    if (!baseDir.isDirectory()) {
        throw EJB3_TIMER_LOGGER.invalidTimerFileStoreDir(baseDir);
    }
}
Also used : MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory) File(java.io.File)

Example 2 with RiverMarshallerFactory

use of org.jboss.marshalling.river.RiverMarshallerFactory in project wildfly by wildfly.

the class EjbIIOPService method start.

@Override
public synchronized void start(final StartContext startContext) throws StartException {
    try {
        final RiverMarshallerFactory factory = new RiverMarshallerFactory();
        final MarshallingConfiguration configuration = new MarshallingConfiguration();
        configuration.setClassResolver(new FilteringClassResolver(ModularClassResolver.getInstance(serviceModuleLoaderInjectedValue.getValue())));
        this.configuration = configuration;
        this.factory = factory;
        final TransactionManager jtsTransactionManager = transactionManagerInjectedValue.getValue().getTransactionManager();
        assert !(jtsTransactionManager instanceof ContextTransactionManager);
        // Should create a CORBA interface repository?
        final boolean interfaceRepositorySupported = false;
        // Build binding name of the bean.
        final EJBComponent component = ejbComponentInjectedValue.getValue();
        final String earApplicationName = component.getEarApplicationName();
        if (iiopMetaData != null && iiopMetaData.getBindingName() != null) {
            name = iiopMetaData.getBindingName();
        } else if (useQualifiedName) {
            if (component.getDistinctName() == null || component.getDistinctName().isEmpty()) {
                name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/";
                name = name + component.getModuleName() + "/" + component.getComponentName();
            } else {
                name = earApplicationName == null || earApplicationName.isEmpty() ? "" : earApplicationName + "/";
                name = name + component.getModuleName() + "/" + component.getDistinctName() + "/" + component.getComponentName();
            }
        } else {
            name = component.getComponentName();
        }
        name = name.replace(".", "_");
        EjbLogger.DEPLOYMENT_LOGGER.iiopBindings(component.getComponentName(), component.getModuleName(), name);
        final ORB orb = this.orb.getValue();
        if (interfaceRepositorySupported) {
            // Create a CORBA interface repository for the enterprise bean
            iri = new InterfaceRepository(orb, irPoa.getValue(), name);
            // Add bean interface info to the interface repository
            iri.mapClass(remoteView.getValue().getViewClass());
            iri.mapClass(homeView.getValue().getViewClass());
            iri.finishBuild();
            EjbLogger.ROOT_LOGGER.cobraInterfaceRepository(name, orb.object_to_string(iri.getReference()));
        }
        IORSecurityConfigMetaData iorSecurityConfigMetaData = this.iorSecConfigMetaData.getOptionalValue();
        if (this.iiopMetaData != null && this.iiopMetaData.getIorSecurityConfigMetaData() != null)
            iorSecurityConfigMetaData = this.iiopMetaData.getIorSecurityConfigMetaData();
        // Create security policies if security metadata has been provided.
        List<Policy> policyList = new ArrayList<Policy>();
        if (iorSecurityConfigMetaData != null) {
            // Create csiv2Policy for both home and remote containing IorSecurityConfigMetadata.
            final Any secPolicy = orb.create_any();
            secPolicy.insert_Value(iorSecurityConfigMetaData);
            Policy csiv2Policy = orb.create_policy(CSIv2Policy.TYPE, secPolicy);
            policyList.add(csiv2Policy);
            // Add ZeroPortPolicy if ssl is required (it ensures home and remote IORs will have port 0 in the primary address).
            boolean sslRequired = false;
            if (iorSecurityConfigMetaData != null && iorSecurityConfigMetaData.getTransportConfig() != null) {
                IORTransportConfigMetaData tc = iorSecurityConfigMetaData.getTransportConfig();
                sslRequired = IORTransportConfigMetaData.INTEGRITY_REQUIRED.equals(tc.getIntegrity()) || IORTransportConfigMetaData.CONFIDENTIALITY_REQUIRED.equals(tc.getConfidentiality()) || IORTransportConfigMetaData.ESTABLISH_TRUST_IN_CLIENT_REQUIRED.equals(tc.getEstablishTrustInClient());
            }
            if (sslRequired) {
                policyList.add(ZeroPortPolicy.getPolicy());
            }
        }
        // TODO: what should this default to
        String securityDomainName = "CORBA_REMOTE";
        if (component.getSecurityMetaData() != null) {
            securityDomainName = component.getSecurityMetaData().getSecurityDomainName();
        }
        Policy[] policies = policyList.toArray(new Policy[policyList.size()]);
        // If there is an interface repository, then get the homeInterfaceDef from the IR
        InterfaceDef homeInterfaceDef = null;
        if (iri != null) {
            Repository ir = iri.getReference();
            homeInterfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(homeRepositoryIds[0]));
        }
        // Get the POACurrent object
        Current poaCurrent = CurrentHelper.narrow(orb.resolve_initial_references("POACurrent"));
        // Instantiate home servant, bind it to the servant registry, and create CORBA reference to the EJBHome.
        final EjbCorbaServant homeServant = new EjbCorbaServant(poaCurrent, homeMethodMap, homeRepositoryIds, homeInterfaceDef, orb, homeView.getValue(), factory, configuration, jtsTransactionManager, module.getClassLoader(), true, securityDomainName, component.getSecurityDomain());
        homeServantRegistry = poaRegistry.getValue().getRegistryWithPersistentPOAPerServant();
        ReferenceFactory homeReferenceFactory = homeServantRegistry.bind(homeServantName(name), homeServant, policies);
        final org.omg.CORBA.Object corbaRef = homeReferenceFactory.createReference(homeRepositoryIds[0]);
        // we do this twice to force eager dynamic stub creation
        ejbHome = (EJBHome) PortableRemoteObject.narrow(corbaRef, EJBHome.class);
        final HomeHandleImplIIOP homeHandle = new HomeHandleImplIIOP(orb.object_to_string(corbaRef));
        homeServant.setHomeHandle(homeHandle);
        // Initialize beanPOA and create metadata
        // This is a session bean (lifespan: transient)
        beanServantRegistry = poaRegistry.getValue().getRegistryWithTransientPOAPerServant();
        if (component instanceof StatelessSessionComponent) {
            // Stateless session bean
            ejbMetaData = new EJBMetaDataImplIIOP(remoteView.getValue().getViewClass(), homeView.getValue().getViewClass(), null, true, true, homeHandle);
        } else {
            // Stateful session bean
            ejbMetaData = new EJBMetaDataImplIIOP(remoteView.getValue().getViewClass(), homeView.getValue().getViewClass(), null, true, false, homeHandle);
        }
        homeServant.setEjbMetaData(ejbMetaData);
        // If there is an interface repository, then get the beanInterfaceDef from the IR
        InterfaceDef beanInterfaceDef = null;
        if (iri != null) {
            final Repository ir = iri.getReference();
            beanInterfaceDef = InterfaceDefHelper.narrow(ir.lookup_id(beanRepositoryIds[0]));
        }
        // Instantiate the ejb object servant and bind it to the servant registry.
        final EjbCorbaServant beanServant = new EjbCorbaServant(poaCurrent, beanMethodMap, beanRepositoryIds, beanInterfaceDef, orb, remoteView.getValue(), factory, configuration, jtsTransactionManager, module.getClassLoader(), false, securityDomainName, component.getSecurityDomain());
        beanReferenceFactory = beanServantRegistry.bind(beanServantName(name), beanServant, policies);
        // Register bean home in local CORBA naming context
        rebind(corbaNamingContext.getValue(), name, corbaRef);
        EjbLogger.ROOT_LOGGER.debugf("Home IOR for %s bound to %s in CORBA naming service", component.getComponentName(), this.name);
        // now eagerly force stub creation, so de-serialization of stubs will work correctly
        final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
        try {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
            try {
                DynamicStubFactoryFactory.makeStubClass(homeView.getValue().getViewClass());
            } catch (Exception e) {
                EjbLogger.ROOT_LOGGER.dynamicStubCreationFailed(homeView.getValue().getViewClass().getName(), e);
            }
            try {
                DynamicStubFactoryFactory.makeStubClass(remoteView.getValue().getViewClass());
            } catch (Exception e) {
                EjbLogger.ROOT_LOGGER.dynamicStubCreationFailed(remoteView.getValue().getViewClass().getName(), e);
            }
        } finally {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
        }
    } catch (Exception e) {
        throw new StartException(e);
    }
}
Also used : ZeroPortPolicy(com.sun.corba.se.spi.extension.ZeroPortPolicy) CSIv2Policy(org.wildfly.iiop.openjdk.csiv2.CSIv2Policy) Policy(org.omg.CORBA.Policy) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) ArrayList(java.util.ArrayList) InterfaceRepository(org.wildfly.iiop.openjdk.rmi.ir.InterfaceRepository) Any(org.omg.CORBA.Any) StatelessSessionComponent(org.jboss.as.ejb3.component.stateless.StatelessSessionComponent) MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration) EJBMetaDataImplIIOP(org.jboss.ejb.iiop.EJBMetaDataImplIIOP) StartException(org.jboss.msc.service.StartException) IORTransportConfigMetaData(org.jboss.metadata.ejb.jboss.IORTransportConfigMetaData) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) InvalidClassException(java.io.InvalidClassException) StartException(org.jboss.msc.service.StartException) IOException(java.io.IOException) InterfaceDef(org.omg.CORBA.InterfaceDef) InterfaceRepository(org.wildfly.iiop.openjdk.rmi.ir.InterfaceRepository) Repository(org.omg.CORBA.Repository) IORSecurityConfigMetaData(org.jboss.metadata.ejb.jboss.IORSecurityConfigMetaData) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) TransactionManager(javax.transaction.TransactionManager) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory) Current(org.omg.PortableServer.Current) ORB(org.omg.CORBA.ORB) HomeHandleImplIIOP(org.jboss.ejb.iiop.HomeHandleImplIIOP)

Example 3 with RiverMarshallerFactory

use of org.jboss.marshalling.river.RiverMarshallerFactory in project wildfly by wildfly.

the class AbstractPersistentSessionManager method start.

@Override
public void start(final StartContext startContext) throws StartException {
    final RiverMarshallerFactory factory = new RiverMarshallerFactory();
    final MarshallingConfiguration configuration = new MarshallingConfiguration();
    configuration.setClassResolver(ModularClassResolver.getInstance(moduleLoader.get()));
    this.configuration = configuration;
    this.factory = factory;
    this.serviceConsumer.accept(this);
}
Also used : MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory)

Example 4 with RiverMarshallerFactory

use of org.jboss.marshalling.river.RiverMarshallerFactory in project eap-additional-testsuite by jboss-set.

the class MarshallingTestCase method deserializationTest.

@ATTest({ "modules/testcases/jdkAll/Wildfly/core/src/main/java#10.0.0.Final*11.0.0.Beta1" })
public void deserializationTest() throws Exception {
    RiverMarshallerFactory factory = new RiverMarshallerFactory();
    MarshallingConfiguration configuration = new MarshallingConfiguration();
    configuration.setVersion(2);
    // Create a marshaller on some stream we have
    RiverMarshaller marshaller = (RiverMarshaller) factory.createMarshaller(configuration);
    final ByteArrayOutputStream fileOutputStream = new ByteArrayOutputStream();
    marshaller.start(new OutputStreamByteOutput(fileOutputStream));
    Bar bar = new Bar("Hello");
    Foo foo = new Foo(bar);
    // Write lots of stuff
    marshaller.writeObject(foo);
    // Done
    marshaller.finish();
    RiverUnmarshaller unmarshaller = (RiverUnmarshaller) factory.createUnmarshaller(configuration);
    ByteArrayInputStream fileInputStream = new ByteArrayInputStream(fileOutputStream.toByteArray());
    unmarshaller.start(new InputStreamByteInput(fileInputStream));
    try {
        Foo f = unmarshaller.readObject(Foo.class);
        Assert.assertEquals(f.bar.aString, "Hello");
    } catch (ClassNotFoundException ex) {
        ex.printStackTrace();
    }
    unmarshaller.finish();
}
Also used : RiverUnmarshaller(org.jboss.marshalling.river.RiverUnmarshaller) OutputStreamByteOutput(org.jboss.marshalling.OutputStreamByteOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration) InputStreamByteInput(org.jboss.marshalling.InputStreamByteInput) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RiverMarshaller(org.jboss.marshalling.river.RiverMarshaller) ATTest(org.jboss.eap.additional.testsuite.annotations.ATTest)

Example 5 with RiverMarshallerFactory

use of org.jboss.marshalling.river.RiverMarshallerFactory in project jvm-serializers by eishay.

the class JBossMarshalling method register.

public static void register(final TestGroups groups) {
    MarshallerFactory riverFactory = new RiverMarshallerFactory();
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river", riverFactory, false, false), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.ZERO_KNOWLEDGE, "full graph zero knowledge"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river-manual", riverFactory, false, true), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.MANUAL_OPT, "full graph with manual optimizations"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river-ct", riverFactory, true, false), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.CLASSES_KNOWN, "full graph with preregistered classes"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river-ct-manual", riverFactory, true, true), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.MANUAL_OPT, "full graph preregistered classes, manual optimization"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-serial", new SerialMarshallerFactory(), false, false), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.ZERO_KNOWLEDGE, ""));
}
Also used : MarshallerFactory(org.jboss.marshalling.MarshallerFactory) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory) SerialMarshallerFactory(org.jboss.marshalling.serial.SerialMarshallerFactory) SerialMarshallerFactory(org.jboss.marshalling.serial.SerialMarshallerFactory) MediaContent(data.media.MediaContent) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory)

Aggregations

RiverMarshallerFactory (org.jboss.marshalling.river.RiverMarshallerFactory)6 MarshallingConfiguration (org.jboss.marshalling.MarshallingConfiguration)5 ZeroPortPolicy (com.sun.corba.se.spi.extension.ZeroPortPolicy)1 MediaContent (data.media.MediaContent)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InvalidClassException (java.io.InvalidClassException)1 ArrayList (java.util.ArrayList)1 TransactionManager (javax.transaction.TransactionManager)1 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)1 StatelessSessionComponent (org.jboss.as.ejb3.component.stateless.StatelessSessionComponent)1 ATTest (org.jboss.eap.additional.testsuite.annotations.ATTest)1 EJBMetaDataImplIIOP (org.jboss.ejb.iiop.EJBMetaDataImplIIOP)1 HomeHandleImplIIOP (org.jboss.ejb.iiop.HomeHandleImplIIOP)1 InputStreamByteInput (org.jboss.marshalling.InputStreamByteInput)1 MarshallerFactory (org.jboss.marshalling.MarshallerFactory)1 OutputStreamByteOutput (org.jboss.marshalling.OutputStreamByteOutput)1 RiverMarshaller (org.jboss.marshalling.river.RiverMarshaller)1