Search in sources :

Example 1 with ManagerPersistenceService

use of org.openremote.manager.persistence.ManagerPersistenceService in project openremote by openremote.

the class Main method main.

public static void main(String[] args) throws Exception {
    List<ContainerService> services = new ArrayList<ContainerService>() {

        {
            addAll(Arrays.asList(new TimerService(), new ManagerExecutorService(), new I18NService(), new ManagerPersistenceService(), new MessageBrokerSetupService(), new ManagerIdentityService(), new SetupService(), new ClientEventService(), new RulesetStorageService(), new RulesService(), new AssetStorageService(), new AssetDatapointService(), new AssetAttributeLinkingService(), new AssetProcessingService(), new MessageBrokerService()));
            ServiceLoader.load(Protocol.class).forEach(this::add);
            addAll(Arrays.asList(new AgentService(), new SimulatorService(), new MapService(), new NotificationService(), new ConsoleAppService(), new ManagerWebService()));
        }
    };
    new Container(services).startBackground();
}
Also used : MessageBrokerSetupService(org.openremote.container.message.MessageBrokerSetupService) AssetStorageService(org.openremote.manager.asset.AssetStorageService) ConsoleAppService(org.openremote.manager.apps.ConsoleAppService) ArrayList(java.util.ArrayList) AssetProcessingService(org.openremote.manager.asset.AssetProcessingService) TimerService(org.openremote.container.timer.TimerService) ManagerIdentityService(org.openremote.manager.security.ManagerIdentityService) AssetDatapointService(org.openremote.manager.datapoint.AssetDatapointService) Container(org.openremote.container.Container) AgentService(org.openremote.manager.agent.AgentService) RulesService(org.openremote.manager.rules.RulesService) ManagerWebService(org.openremote.manager.web.ManagerWebService) SimulatorService(org.openremote.manager.simulator.SimulatorService) ClientEventService(org.openremote.manager.event.ClientEventService) Protocol(org.openremote.agent.protocol.Protocol) MapService(org.openremote.manager.map.MapService) RulesetStorageService(org.openremote.manager.rules.RulesetStorageService) I18NService(org.openremote.manager.i18n.I18NService) ManagerPersistenceService(org.openremote.manager.persistence.ManagerPersistenceService) NotificationService(org.openremote.manager.notification.NotificationService) AssetAttributeLinkingService(org.openremote.manager.asset.AssetAttributeLinkingService) ManagerExecutorService(org.openremote.manager.concurrent.ManagerExecutorService) MessageBrokerSetupService(org.openremote.container.message.MessageBrokerSetupService) SetupService(org.openremote.manager.setup.SetupService) ContainerService(org.openremote.container.ContainerService) MessageBrokerService(org.openremote.container.message.MessageBrokerService)

Example 2 with ManagerPersistenceService

use of org.openremote.manager.persistence.ManagerPersistenceService in project openremote by openremote.

the class SchemaExporter method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        throw new IllegalArgumentException("Missing target file path argument");
    }
    File schemaFile = new File(args[0]);
    Container container = new Container(new ManagerExecutorService(), new ManagerPersistenceService() {

        @Override
        protected void openDatabase(Container container, Database database) {
        // Ignore, we don't want to connect to the database when exporting schema
        }

        @Override
        public void start(Container container) throws Exception {
            Map<String, Object> createSchemaProperties = new HashMap<>(persistenceUnitProperties);
            createSchemaProperties.put("javax.persistence.schema-generation.scripts.action", "create");
            createSchemaProperties.put("javax.persistence.schema-generation.scripts.create-target", schemaFile.getAbsolutePath());
            if (schemaFile.exists()) {
                LOG.info("Deleting existing schema file: " + schemaFile.getAbsolutePath());
                schemaFile.delete();
            }
            LOG.info("Exporting database schema for persistence unit: " + persistenceUnitName);
            Persistence.generateSchema(persistenceUnitName, createSchemaProperties);
            LOG.fine("Schema export complete: " + schemaFile.getAbsolutePath());
        }
    });
    container.start();
}
Also used : Container(org.openremote.container.Container) ManagerPersistenceService(org.openremote.manager.persistence.ManagerPersistenceService) Database(org.openremote.container.persistence.Database) ManagerExecutorService(org.openremote.manager.concurrent.ManagerExecutorService) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

Container (org.openremote.container.Container)2 ManagerExecutorService (org.openremote.manager.concurrent.ManagerExecutorService)2 ManagerPersistenceService (org.openremote.manager.persistence.ManagerPersistenceService)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Protocol (org.openremote.agent.protocol.Protocol)1 ContainerService (org.openremote.container.ContainerService)1 MessageBrokerService (org.openremote.container.message.MessageBrokerService)1 MessageBrokerSetupService (org.openremote.container.message.MessageBrokerSetupService)1 Database (org.openremote.container.persistence.Database)1 TimerService (org.openremote.container.timer.TimerService)1 AgentService (org.openremote.manager.agent.AgentService)1 ConsoleAppService (org.openremote.manager.apps.ConsoleAppService)1 AssetAttributeLinkingService (org.openremote.manager.asset.AssetAttributeLinkingService)1 AssetProcessingService (org.openremote.manager.asset.AssetProcessingService)1 AssetStorageService (org.openremote.manager.asset.AssetStorageService)1 AssetDatapointService (org.openremote.manager.datapoint.AssetDatapointService)1 ClientEventService (org.openremote.manager.event.ClientEventService)1